RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Druidic Spells Final-all 16 spells - updated 6th Jan 04

Status
Not open for further replies.

Voran

Wanderer
*wakes up*
No worries:
[code:1]using System;
using System.Collections;
using Server;

namespace Server.Mobiles
{
public class DruidVendor : BaseVendor
{
private ArrayList m_SBInfos = new ArrayList();
protected override ArrayList SBInfos{ get { return m_SBInfos; } }

[Constructable]
public DruidVendor() : base( "the druid" )
{
SetSkill( SkillName.AnimalLore, 85.0, 100.0 );
SetSkill( SkillName.Healing, 90.0, 100.0 );

}

public override void InitSBInfo()
{
m_SBInfos.Add( new SBDruid() );
}
public override VendorShoeType ShoeType
{
get{ return Utility.RandomBool() ? VendorShoeType.Shoes : VendorShoeType.Sandals; }
}

public override void InitOutfit()
{
base.InitOutfit();

AddItem( new Server.Items.Robe( Utility.RandomYellowHue() ) );
}
public DruidVendor( Serial serial ) : base( serial )
{
}

public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int) 0 ); // version
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );

int version = reader.ReadInt();

}
}
}
[/code:1]


[code:1]using System;
using System.Collections;
using Server.Items;

namespace Server.Mobiles
{
public class SBDruid : SBInfo
{
private ArrayList m_BuyInfo = new InternalBuyInfo();
private IShopSellInfo m_SellInfo = new InternalSellInfo();

public SBDruid()
{
}

public override IShopSellInfo SellInfo { get { return m_SellInfo; } }
public override ArrayList BuyInfo { get { return m_BuyInfo; } }

public class InternalBuyInfo : ArrayList
{
public InternalBuyInfo()
{


Add( new GenericBuyInfo( typeof( BlackPearl ), 5, 999, 0xF7A, 0 ) );
Add( new GenericBuyInfo( typeof( Bloodmoss ), 5, 999, 0xF7B, 0 ) );
Add( new GenericBuyInfo( typeof( MandrakeRoot ), 3, 999, 0xF86, 0 ) );
Add( new GenericBuyInfo( typeof( Garlic ), 3, 999, 0xF84, 0 ) );
Add( new GenericBuyInfo( typeof( Ginseng ), 3, 999, 0xF85, 0 ) );
Add( new GenericBuyInfo( typeof( Nightshade ), 3, 999, 0xF88, 0 ) );
Add( new GenericBuyInfo( typeof( SpidersSilk ), 3, 999, 0xF8D, 0 ) );
Add( new GenericBuyInfo( typeof( SulfurousAsh ), 3, 999, 0xF8C, 0 ) );


Add( new GenericBuyInfo( "petrified wood",typeof( PetrafiedWood ), 3, 999, 0x97A, 0x46C ) );
Add( new GenericBuyInfo( "spring water",typeof( SpringWater ), 3, 999, 0xE24, 0x47F ) );
Add( new GenericBuyInfo( "destroying angel",typeof( DestroyingAngel ), 6, 999, 0xE1F, 0x290 ) );



Add( new GenericBuyInfo( typeof( ScribesPen ), 8, 10, 0xFBF, 0 ) );

}
}

public class InternalSellInfo : GenericSellInfo
{
public InternalSellInfo()
{
Add( typeof( Runebook ), 1250 );
Add( typeof( BlackPearl ), 3 );
Add( typeof( Bloodmoss ), 3 );
Add( typeof( MandrakeRoot ), 2 );
Add( typeof( Garlic ), 2 );
Add( typeof( Ginseng ), 2 );
Add( typeof( Nightshade ), 2 );
Add( typeof( SpidersSilk ), 2 );
Add( typeof( SulfurousAsh ), 2 );
Add( typeof( RecallRune ), 5 );
Add( typeof( Spellbook ), 9 );
Add( typeof( BlankScroll ), 3 );


Add( typeof( PetrafiedWood ), 2 );
Add( typeof( SpringWater ), 2 );
Add( typeof( DestroyingAngel ), 3 );


Type[] types = Loot.RegularScrollTypes;

for ( int i = 0; i < types.Length; ++i )
Add( types, 6 + ((i / 8) * 5) );
}
}
}
}
[/code:1]
 

iZJokersWild

Wanderer
Are there reagents to go with this? I keep getting this error:
Scripts: Compiling C# scripts...failed (16 errors, 4 warnings)
- Error: Scripts\Custom\Druid\DruidicSpellBook.cs: CS0117: (line 10, column 64)
'Server.Items.SpellbookType' does not contain a definition for 'Druidic'
- Error: Scripts\Custom\Druid\EnchantedGrove.cs: CS0117: (line 20, column 13) '
Server.Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Custom\Druid\EnchantedGrove.cs: CS0117: (line 21, column 13) '
Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\GraspingRootsSpell.cs: CS0117: (line 17, column 1
3) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\LureStoneSpell.cs: CS0117: (line 22, column 13) '
Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\MushroomCircleSpell.cs: CS0117: (line 23, column
13) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\MushroomGatewaySpell.cs: CS0117: (line 20, column
5) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\PackOfBeastSpell.cs: CS0117: (line 18, column 13)
'Server.Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Custom\Druid\RestorativeSoilSpell.cs: CS0117: (line 20, column
13) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\ShieldOfEarthSpell.cs: CS0117: (line 18, column 1
3) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\SpringOfLifeSpell.cs: CS0117: (line 18, column 13
) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\SpringOfLifeSpell.cs: CS0117: (line 19, column 13
) 'Server.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Custom\Druid\SummonFireflySpell.cs: CS0117: (line 17, column 1
3) 'Server.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
- Error: Scripts\Custom\Druid\SwarmofInsectsSpell.cs: CS0117: (line 19, column
13) 'Server.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
- Error: Scripts\Custom\Druid\TreefellowSpell.cs: CS0117: (line 18, column 13)
'Server.Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Custom\Druid\VolcanicEruption.cs: CS0117: (line 18, column 13)
'Server.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
- Warning: Scripts\Custom\Guard Bribe\GuardBribe.cs: CS0219: (line 35, column 4
6) The variable 'initialState' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 48, column 9)
The variable 'foundBet' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 66, column 9)
The variable 'foundTym' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 72, column 9)
The variable 'foundZu' is assigned but its value is never used
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Not sure what it is meaning..usually if something else goes bad, the runemagic goes bad too.
 
Seems pretty silly to me to leave a script of vital importance out like reagent.cs. Especially when the release notes from Voran says that :

"v 2.1
Updated Reagent.cs now included - please note, if you have a custom Reagent.cs already, you will need to update it by hand. "

If an updated reagent.cs in the current release, then i'll shit it my hat and eat it.

Try this:

[code:1]
using System;
using Server.Items;

namespace Server.Spells
{
public class Reagent
{
private static Type[] m_Types = new Type[16]
{
typeof( BlackPearl ),
typeof( Bloodmoss ),
typeof( Garlic ),
typeof( Ginseng ),
typeof( MandrakeRoot ),
typeof( Nightshade ),
typeof( SulfurousAsh ),
typeof( SpidersSilk ),
typeof( BatWing ),
typeof( GraveDust ),
typeof( DaemonBlood ),
typeof( NoxCrystal ),
typeof( PigIron ),
typeof( DestroyingAngel ),
typeof( PetrafiedWood ),
typeof( SpringWater )
};

public Type[] Types
{
get{ return m_Types; }
}

public static Type BlackPearl
{
get{ return m_Types[0]; }
set{ m_Types[0] = value; }
}

public static Type Bloodmoss
{
get{ return m_Types[1]; }
set{ m_Types[1] = value; }
}

public static Type Garlic
{
get{ return m_Types[2]; }
set{ m_Types[2] = value; }
}

public static Type Ginseng
{
get{ return m_Types[3]; }
set{ m_Types[3] = value; }
}

public static Type MandrakeRoot
{
get{ return m_Types[4]; }
set{ m_Types[4] = value; }
}

public static Type Nightshade
{
get{ return m_Types[5]; }
set{ m_Types[5] = value; }
}

public static Type SulfurousAsh
{
get{ return m_Types[6]; }
set{ m_Types[6] = value; }
}

public static Type SpidersSilk
{
get{ return m_Types[7]; }
set{ m_Types[7] = value; }
}

public static Type BatWing
{
get{ return m_Types[8]; }
set{ m_Types[8] = value; }
}

public static Type GraveDust
{
get{ return m_Types[9]; }
set{ m_Types[9] = value; }
}

public static Type DaemonBlood
{
get{ return m_Types[10]; }
set{ m_Types[10] = value; }
}

public static Type NoxCrystal
{
get{ return m_Types[11]; }
set{ m_Types[11] = value; }
}

public static Type PigIron
{
get{ return m_Types[12]; }
set{ m_Types[12] = value; }
}

public static Type DestroyingAngel
{
get{ return m_Types[13]; }
set{ m_Types[13] = value; }
}
public static Type PetrafiedWood

{
get{ return m_Types[14]; }
set{ m_Types[14] = value; }
}

public static Type SpringWater
{
get{ return m_Types[15]; }
set{ m_Types[15] = value; }

}
}
}

Nice system Voran....

[/code:1]
 

Voran

Wanderer
It did have reagents.cs in, but I had to constantly mod my regs file every time I updated the zip - and then the pagen regs were posted, which made it unnecessary.
 
Rats I got it all to work but the Spell Book Gump is screwy the first two pages just over write all the spells, guess its time to learn gumps.
 
Voran said:
It did have reagents.cs in, but I had to constantly mod my regs file every time I updated the zip - and then the pagen regs were posted, which made it unnecessary.

Ok. I understand now. I thought I was going blind trying to find it in the CURRENT zip. I had a feeling it was omitted due to constant tweaks between the two systems.

(Not to mention, I was having a bad night.)

BTW, very nice system Voran. My compliments to you!

Adam
 
update it only seems to mess with the gumps when you have only the last spell on the 2nd page and the first spell on the second page add one more spell to the book and it straightens its self out. I find that odd and had to do it several times before i believed it. But then again i have done very little with gumps. Is anyone else able to reproduce this or do i need to put down the pipe?
 

Markvg

Wanderer
Problem

This is a very good scipt thx Voran. I got a bug tho which is that some spells are over each other in the spell book. Can u help?
 

Voran

Wanderer
Re: Problem

Voran said:
You need to use the already posted modification to SpellRegistry.cs
Code:
[code:1]
using System;

namespace Server.Spells
{
public class SpellRegistry
{
private static Type[] m_Types = new Type[500];
private static int m_Count;

public static Type[] Types
{
get
{
m_Count = -1;
return m_Types;
}
}

public static int Count
{
get
{
if ( m_Count == -1 )
{
m_Count = 0;

for ( int i = 0; i < 64; ++i )
{
if ( m_Types != null )
++m_Count;
}
}

return m_Count;
}
}

public static void Register( int spellID, Type type )
{
if ( spellID < 0 || spellID >= m_Types.Length )
return;

if ( m_Types[spellID] == null )
++m_Count;

m_Types[spellID] = type;
}

private static object[] m_Params = new object[2];

public static Spell NewSpell( int spellID, Mobile caster, Item scroll )
{
if ( spellID < 0 || spellID >= m_Types.Length )
return null;

Type t = m_Types[spellID];

if ( t == null )
return null;

m_Params[0] = caster;
m_Params[1] = scroll;

return (Spell)Activator.CreateInstance( t, m_Params );
}

private static string[] m_CircleNames = new string[]
{
"First",
"Second",
"Third",
"Fourth",
"Fifth",
"Sixth",
"Seventh",
"Eighth",
"Necromancy",
"Chivalry"
};

public static Spell NewSpell( string name, Mobile caster, Item scroll )
{
for ( int i = 0; i < m_CircleNames.Length; ++i )
{
Type t = ScriptCompiler.FindTypeByFullName( String.Format( "Server.Spells.{0}.{1}", m_CircleNames, name ) );

if ( t != null )
{
m_Params[0] = caster;
m_Params[1] = scroll;

try
{
return (Spell)Activator.CreateInstance( t, m_Params );
}
catch
{
}
}
}

return null;
}
}
}
[/code:1]

 

iZJokersWild

Wanderer
Okay, I am a retart and will ask. I have the new version of the Druid spells and all, but I read that I needed the original as well? What about reagents? I loaded it all up as it said and this is the error that I am getting:
[code:1]
Scripts: Compiling C# scripts...failed (16 errors, 4 warnings)
- Warning: Scripts\Custom\Guard Bribe\GuardBribe.cs: CS0219: (line 35, column 4
6) The variable 'initialState' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 48, column 9)
The variable 'foundBet' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 66, column 9)
The variable 'foundTym' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 72, column 9)
The variable 'foundZu' is assigned but its value is never used
- Error: Scripts\Druid\DruidicSpellBook.cs: CS0117: (line 10, column 64) 'Serve
r.Items.SpellbookType' does not contain a definition for 'Druidic'
- Error: Scripts\Druid\EnchantedGrove.cs: CS0117: (line 20, column 13) 'Server.
Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Druid\EnchantedGrove.cs: CS0117: (line 21, column 13) 'Server.
Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\GraspingRootsSpell.cs: CS0117: (line 17, column 13) 'Ser
ver.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\LureStoneSpell.cs: CS0117: (line 22, column 13) 'Server.
Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\MushroomCircleSpell.cs: CS0117: (line 23, column 13) 'Se
rver.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\MushroomGatewaySpell.cs: CS0117: (line 20, column 5) 'Se
rver.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\PackOfBeastSpell.cs: CS0117: (line 18, column 13) 'Serve
r.Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Druid\RestorativeSoilSpell.cs: CS0117: (line 20, column 13) 'S
erver.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\ShieldOfEarthSpell.cs: CS0117: (line 18, column 13) 'Ser
ver.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\SpringOfLifeSpell.cs: CS0117: (line 18, column 13) 'Serv
er.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\SpringOfLifeSpell.cs: CS0117: (line 19, column 13) 'Serv
er.Spells.Reagent' does not contain a definition for 'SpringWater'
- Error: Scripts\Druid\SummonFireflySpell.cs: CS0117: (line 17, column 13) 'Ser
ver.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
- Error: Scripts\Druid\SwarmofInsectsSpell.cs: CS0117: (line 19, column 13) 'Se
rver.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
- Error: Scripts\Druid\TreefellowSpell.cs: CS0117: (line 18, column 13) 'Server
.Spells.Reagent' does not contain a definition for 'PetrafiedWood'
- Error: Scripts\Druid\VolcanicEruption.cs: CS0117: (line 18, column 13) 'Serve
r.Spells.Reagent' does not contain a definition for 'DestroyingAngel'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
[/code:1]

Help please!!
 

iZJokersWild

Wanderer
It looks like I am jsut missing the reagents. Where can I find the script for them? I have been searching through, but did not see any off hand so far.
Voran, I must say, you are THE MAN. It is good to see somebody that offers as much support as you with their scripts.
 

Voran

Wanderer
No worries :)
Directly above you, maybe 5, 6 posts up is the regaent.cs, and you need the spellbook.cs just below that
 

iZJokersWild

Wanderer
LoL! Wow I am blind! I kept doing searches for reagent.cs throughout the forums and scripts, and nothing. Where was it? Right above my question asking where it was!! *SCREAMS*!!!
I thank thee much kind sirs!
 

iZJokersWild

Wanderer
Okay..I added the stuff that I was missing, and this is what I get:

[code:1]
Scripts: Compiling C# scripts...failed (1 errors, 4 warnings)
- Error: Scripts\Custom\Druid\DruidicSpellBook.cs: CS0117: (line 10, column 64)
'Server.Items.SpellbookType' does not contain a definition for 'Druidic'
- Warning: Scripts\Custom\Guard Bribe\GuardBribe.cs: CS0219: (line 35, column 4
6) The variable 'initialState' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 48, column 9)
The variable 'foundBet' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 66, column 9)
The variable 'foundTym' is assigned but its value is never used
- Warning: Scripts\Custom\Rune Magic\RuneMagic.cs: CS0219: (line 72, column 9)
The variable 'foundZu' is assigned but its value is never used
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
[/code:1]

What to do!!
 

iZJokersWild

Wanderer
Okay, I got everything but that DrudicSpellbook.cs thing to work.
This is the code, which I did not alter from the file.
[code:1]
{
public class DruidicSpellbook : Spellbook
{
public override SpellbookType SpellbookType{ get{ return SpellbookType.Druidic; } }
public override int BookOffset{ get{ return 301; } }
public override int BookCount{ get{ return 16; } }

public override Item Dupe( int amount )
{
Spellbook book = new DruidicSpellbook();

book.Content = this.Content;

return base.Dupe( book, amount );
}
[/code:1]

This has nothing to do with the spellbook.cs file does it? I added them both, yet still get this.
 

iZJokersWild

Wanderer
Okay, I think it was in the Spellbook.cs file. I did some basic editing in there, but still come up with these errors:
[code:1]
SScripts: Compiling C# scripts...failed (6 errors, 1 warnings)
- Error: Scripts\Items\Skill Items\Magical\Spellbook.cs: CS0117: (line 73, colu
mn 20) 'Server.Items.SpellbookType' does not contain a definition for 'Druidic'
- Error: Scripts\Items\Skill Items\Magical\Spellbook.cs: CS0117: (line 121, col
umn 12) 'Server.Items.SpellbookType' does not contain a definition for 'Druidic'

- Error: Scripts\Items\Skill Items\Magical\Spellbook.cs: CS1026: (line 143, col
umn 26) ) expected
- Error: Scripts\Items\Skill Items\Magical\Spellbook.cs: CS1002: (line 143, col
umn 48) ; expected
- Error: Scripts\Items\Skill Items\Magical\Spellbook.cs: CS1525: (line 143, col
umn 48) Invalid expression term ')'
- Error: Scripts\Custom\Druid\DruidicSpellBook.cs: CS0117: (line 10, column 64)
'Server.Items.SpellbookType' does not contain a definition for 'Druidic'
[/code:1]

This is the script for Spellbook.cs:

[code:1]
using System;
using System.Collections;
using Server;
using Server.Targeting;
using Server.Network;
using Server.Spells;
using Server.Scripts.Commands;

namespace Server.Items
{
public enum SpellbookType
{
Invalid = -1,
Regular,
Necromancer,
Paladin
}

public class Spellbook : Item
{
public static void Initialize()
{
EventSink.OpenSpellbookRequest += new OpenSpellbookRequestEventHandler( EventSink_OpenSpellbookRequest );
EventSink.CastSpellRequest += new CastSpellRequestEventHandler( EventSink_CastSpellRequest );
Commands.Register( "AllSpells", AccessLevel.GameMaster, new CommandEventHandler( AllSpells_OnCommand ) );
}

[Usage( "AllSpells" )]
[Description( "Completely fills a targeted spellbook with scrolls." )]
private static void AllSpells_OnCommand( CommandEventArgs e )
{
e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetCallback( AllSpells_OnTarget ) );
e.Mobile.SendMessage( "Target the spellbook to fill." );
}

private static void AllSpells_OnTarget( Mobile from, object obj )
{
if ( obj is Spellbook )
{
Spellbook book = (Spellbook)obj;

if ( book.BookCount == 64 )
book.Content = ulong.MaxValue;
else
book.Content = (1ul << book.BookCount) - 1;

from.SendMessage( "The spellbook has been filled." );

CommandLogging.WriteLine( from, "{0} {1} filling spellbook {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( book ) );
}
else
{
from.BeginTarget( -1, false, TargetFlags.None, new TargetCallback( AllSpells_OnTarget ) );
from.SendMessage( "That is not a spellbook. Try again." );
}
}

private static void EventSink_OpenSpellbookRequest( OpenSpellbookRequestEventArgs e )
{
Mobile from = e.Mobile;

if ( !Multis.DesignContext.Check( from ) )
return; // They are customizing

SpellbookType type;

switch ( e.Type )
{
default:
case 1: type = SpellbookType.Regular; break;
case 2: type = SpellbookType.Necromancer; break;
case 3: type = SpellbookType.Paladin; break;
case 4: type = SpellbookType.Druidic; break;
}

Spellbook book = Spellbook.Find( from, -1, type );

if ( book != null )
book.DisplayTo( from );
}

private static void EventSink_CastSpellRequest( CastSpellRequestEventArgs e )
{
Mobile from = e.Mobile;

if ( !Multis.DesignContext.Check( from ) )
return; // They are customizing

Spellbook book = e.Spellbook as Spellbook;
int spellID = e.SpellID;

if ( book == null || !book.HasSpell( spellID ) )
book = Find( from, spellID );

if ( book != null && book.HasSpell( spellID ) )
{
Spell spell = SpellRegistry.NewSpell( spellID, from, null );

if ( spell != null )
spell.Cast();
else
from.SendLocalizedMessage( 502345 ); // This spell has been temporarily disabled.
}
else
{
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
}

private static Hashtable m_Table = new Hashtable();

public static SpellbookType GetTypeForSpell( int spellID )
{
if ( spellID >= 0 && spellID < 64 )
return SpellbookType.Regular;
else if ( spellID >= 100 && spellID < 116 )
return SpellbookType.Necromancer;
else if ( spellID >= 200 && spellID < 210 )
return SpellbookType.Paladin;
else if ( spellID >= 300 && spellID < 317 )
return SpellbookType.Druidic;

return SpellbookType.Invalid;
}

public static Spellbook FindRegular( Mobile from )
{
return Find( from, -1, SpellbookType.Regular );
}

public static Spellbook FindNecromancer( Mobile from )
{
return Find( from, -1, SpellbookType.Necromancer );
}

public static Spellbook FindPaladin( Mobile from )
{
return Find( from, -1, SpellbookType.Paladin );
}

public static Spellbook FindDrudic ( Mobile from )
{
return Find( from, -1 SpellbookType.Druidic );
}

public static Spellbook Find( Mobile from, int spellID )
{
return Find( from, spellID, GetTypeForSpell( spellID ) );
}

public static Spellbook Find( Mobile from, int spellID, SpellbookType type )
{
if ( from == null )
return null;

ArrayList list = (ArrayList)m_Table[from];

if ( from.Deleted )
{
m_Table.Remove( from );
return null;
}

bool searchAgain = false;

if ( list == null )
m_Table[from] = list = FindAllSpellbooks( from );
else
searchAgain = true;

Spellbook book = FindSpellbookInList( list, from, spellID, type );

if ( book == null && searchAgain )
{
m_Table[from] = list = FindAllSpellbooks( from );

book = FindSpellbookInList( list, from, spellID, type );
}

return book;
}

public static Spellbook FindSpellbookInList( ArrayList list, Mobile from, int spellID, SpellbookType type )
{
Container pack = from.Backpack;

for ( int i = list.Count - 1; i >= 0; --i )
{
if ( i >= list.Count )
continue;

Spellbook book = (Spellbook)list;

if ( !book.Deleted && (book.Parent == from || (pack != null && book.Parent == pack)) && ValidateSpellbook( book, spellID, type ) )
return book;

list.Remove( i );
}

return null;
}

public static ArrayList FindAllSpellbooks( Mobile from )
{
ArrayList list = new ArrayList();

Item item = from.FindItemOnLayer( Layer.OneHanded );

if ( item is Spellbook )
list.Add( item );

Container pack = from.Backpack;

if ( pack == null )
return list;

for ( int i = 0; i < pack.Items.Count; ++i )
{
item = (Item)pack.Items;

if ( item is Spellbook )
list.Add( item );
}

return list;
}

public static bool ValidateSpellbook( Spellbook book, int spellID, SpellbookType type )
{
return ( book.SpellbookType == type && ( spellID == -1 || book.HasSpell( spellID ) ) );
}

public virtual SpellbookType SpellbookType{ get{ return SpellbookType.Regular; } }
public virtual int BookOffset{ get{ return 0; } }
public virtual int BookCount{ get{ return 64; } }

private ulong m_Content;
private int m_Count;

public override bool AllowEquipedCast( Mobile from )
{
return true;
}

public override Item Dupe( int amount )
{
Spellbook book = new Spellbook();

book.Content = this.Content;

return base.Dupe( book, amount );
}

public override bool OnDragDrop( Mobile from, Item dropped )
{
if ( dropped is SpellScroll && dropped.Amount == 1 )
{
SpellScroll scroll = (SpellScroll)dropped;

SpellbookType type = GetTypeForSpell( scroll.SpellID );

if ( type != this.SpellbookType )
{
return false;
}
else if ( HasSpell( scroll.SpellID ) )
{
from.SendLocalizedMessage( 500179 ); // That spell is already present in that spellbook.
return false;
}
else
{
int val = scroll.SpellID - BookOffset;

if ( val >= 0 && val < BookCount )
{
m_Content |= (ulong)1 << val;
++m_Count;

InvalidateProperties();

scroll.Delete();

from.Send( new PlaySound( 0x249, GetWorldLocation() ) );
return true;
}

return false;
}
}
else
{
return false;
}
}

[CommandProperty( AccessLevel.GameMaster )]
public ulong Content
{
get
{
return m_Content;
}
set
{
if ( m_Content != value )
{
m_Content = value;

m_Count = 0;

while ( value > 0 )
{
m_Count += (int)(value & 0x1);
value >>= 1;
}

InvalidateProperties();
}
}
}

[CommandProperty( AccessLevel.GameMaster )]
public int SpellCount
{
get
{
return m_Count;
}
}

[Constructable]
public Spellbook() : this( (ulong)0 )
{
}

[Constructable]
public Spellbook( ulong content ) : this( content, 0xEFA )
{
}

public Spellbook( ulong content, int itemID ) : base( itemID )
{
Weight = 3.0;
Layer = Layer.OneHanded;
LootType = LootType.Blessed;

Content = content;
}

public bool HasSpell( int spellID )
{
spellID -= BookOffset;

return ( spellID >= 0 && spellID < BookCount && (m_Content & ((ulong)1 << spellID)) != 0 );
}

public Spellbook( Serial serial ) : base( serial )
{
}

private static readonly ClientVersion Version_400a = new ClientVersion( "4.0.0a" );

public void DisplayTo( Mobile to )
{
// The client must know about the spellbook or it will crash!

if ( Parent == null )
{
to.Send( this.WorldPacket );
}
else if ( Parent is Item )
{
// What will happen if the client doesn't know about our parent?
to.Send( new ContainerContentUpdate( this ) );
}
else if ( Parent is Mobile )
{
// What will happen if the client doesn't know about our parent?
to.Send( new EquipUpdate( this ) );
}

to.Send( new DisplaySpellbook( this ) );

if ( Core.AOS && to.NetState != null && to.NetState.Version != null && to.NetState.Version >= Version_400a )
to.Send( new NewSpellbookContent( this, ItemID, BookOffset + 1, m_Content ) );
else
to.Send( new SpellbookContent( m_Count, BookOffset + 1, m_Content, this ) );
}

public override bool DisplayLootType{ get{ return false; } }

public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );

list.Add( 1042886, m_Count.ToString() ); // ~1_NUMBERS_OF_SPELLS~ Spells
}

public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );

this.LabelTo( from, 1042886, m_Count.ToString() );
}

public override void OnDoubleClick( Mobile from )
{
Container pack = from.Backpack;

if ( Parent == from || ( pack != null && Parent == pack ) )
DisplayTo( from );
else
from.SendLocalizedMessage( 500207 ); // The spellbook must be in your backpack (and not in a container within) to open.
}

public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int) 0 ); // version

writer.Write( m_Content );
writer.Write( m_Count );
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
LootType = LootType.Blessed;

int version = reader.ReadInt();

switch ( version )
{
case 0:
{
m_Content = reader.ReadULong();
m_Count = reader.ReadInt();

break;
}
}
}
}
}
[/code:1]

I think I am stuck at this point. I fixed all my great spelling errors and such, but I think I am beat at this point for self-help.
 
Status
Not open for further replies.
Top