diff --git a/Scripts/Commands/Batch.cs b/Scripts/Commands/Batch.cs index 71fdbf645..c382c5b1e 100644 --- a/Scripts/Commands/Batch.cs +++ b/Scripts/Commands/Batch.cs @@ -63,7 +63,7 @@ namespace Server.Commands bc.GetDetails( out commandString, out argString, out args ); - BaseCommand command = (BaseCommand)m_Scope.Commands[commandString]; + BaseCommand command = m_Scope.Commands[commandString]; commands[i] = command; eventArgs[i] = new CommandEventArgs( e.Mobile, commandString, argString, args ); @@ -415,7 +415,7 @@ namespace Server.Commands /* Options */ for ( int i = 0; i < BaseCommandImplementor.Implementors.Count; ++i ) { - BaseCommandImplementor impl = (BaseCommandImplementor)BaseCommandImplementor.Implementors[i]; + BaseCommandImplementor impl = BaseCommandImplementor.Implementors[i]; if ( m_From.AccessLevel < impl.AccessLevel ) continue; @@ -441,7 +441,7 @@ namespace Server.Commands { if ( index < BaseCommandImplementor.Implementors.Count ) { - BaseCommandImplementor impl = (BaseCommandImplementor)BaseCommandImplementor.Implementors[index]; + BaseCommandImplementor impl = BaseCommandImplementor.Implementors[index]; if ( m_From.AccessLevel >= impl.AccessLevel ) m_Batch.Scope = impl; diff --git a/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs b/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs index 5840e3801..6016d2130 100644 --- a/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs +++ b/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs @@ -1,8 +1,8 @@ using System; -using System.Text; using System.Collections; -using Server; using System.Collections.Generic; +using System.Text; +using Server; namespace Server.Commands.Generic { @@ -45,7 +45,7 @@ namespace Server.Commands.Generic private string[] m_Accessors; private AccessLevel m_AccessLevel; private CommandSupport m_SupportRequirement; - private Hashtable m_Commands; + private Dictionary m_Commands; private string m_Usage; private string m_Description; private bool m_SupportsConditionals; @@ -86,14 +86,14 @@ namespace Server.Commands.Generic set{ m_SupportRequirement = value; } } - public Hashtable Commands + public Dictionary Commands { get{ return m_Commands; } } public BaseCommandImplementor() { - m_Commands = new Hashtable( StringComparer.OrdinalIgnoreCase ); + m_Commands = new Dictionary( StringComparer.OrdinalIgnoreCase ); } public virtual void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj ) @@ -276,7 +276,7 @@ namespace Server.Commands.Generic { if ( e.Length >= 1 ) { - BaseCommand command = (BaseCommand)m_Commands[e.GetString( 0 )]; + BaseCommand command = m_Commands[e.GetString( 0 )]; if ( command == null ) { diff --git a/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs b/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs index fc1c06a9f..9cf3d5c4e 100644 --- a/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs +++ b/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs @@ -35,7 +35,7 @@ namespace Server.Commands.Generic } else { - BaseCommand command = (BaseCommand) this.Commands[e.GetString( 1 )]; + BaseCommand command = this.Commands[e.GetString( 1 )]; if ( command == null ) { diff --git a/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs b/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs index 7a9a0b5e9..364bba375 100644 --- a/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs +++ b/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs @@ -26,7 +26,7 @@ namespace Server.Commands.Generic public void Redirect( CommandEventArgs e ) { - BaseCommand command = (BaseCommand)Commands[e.Command]; + BaseCommand command = Commands[e.Command]; if ( command == null ) e.Mobile.SendMessage( "That is either an invalid command name or one that does not support this modifier." ); diff --git a/Scripts/Engines/AI/Creature/BaseCreature.cs b/Scripts/Engines/AI/Creature/BaseCreature.cs index 945d3dafb..fa289fa2a 100644 --- a/Scripts/Engines/AI/Creature/BaseCreature.cs +++ b/Scripts/Engines/AI/Creature/BaseCreature.cs @@ -4706,11 +4706,11 @@ namespace Server.Mobiles private DateTime m_NextHourlyCheck; protected override void OnTick() - { - bool hasHourElapsed = ( DateTime.Now >= m_NextHourlyCheck ); - - if ( hasHourElapsed ) + { + if ( DateTime.Now >= m_NextHourlyCheck ) m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours( 1.0 ); + else + return; List toRelease = new List(); @@ -4751,9 +4751,7 @@ namespace Server.Mobiles if ( c.Map != Map.Internal ) { - // Every hour all pets lose 10% of max loyalty. - if ( hasHourElapsed ) - c.Loyalty -= (BaseCreature.MaxLoyalty / 10); + c.Loyalty -= (BaseCreature.MaxLoyalty / 10); if( c.Loyalty < (BaseCreature.MaxLoyalty / 10) ) { @@ -4767,7 +4765,7 @@ namespace Server.Mobiles } // added lines to check if a wild creature in a house region has to be removed or not - if ( (!c.Controlled && ( c.Region.IsPartOf( typeof( HouseRegion ) ) && c.CanBeDamaged()) || (hasHourElapsed && c.RemoveIfUntamed && c.Spawner == null )) ) + if ( (!c.Controlled && ( c.Region.IsPartOf( typeof( HouseRegion ) ) && c.CanBeDamaged()) || ( c.RemoveIfUntamed && c.Spawner == null )) ) { c.RemoveStep++; diff --git a/Scripts/Engines/AI/Targets/AIControlMobileTarget.cs b/Scripts/Engines/AI/Targets/AIControlMobileTarget.cs index 117e31138..c11c818e5 100644 --- a/Scripts/Engines/AI/Targets/AIControlMobileTarget.cs +++ b/Scripts/Engines/AI/Targets/AIControlMobileTarget.cs @@ -1,27 +1,25 @@ using System; +using System.Collections.Generic; using Server; -using Server.Targeting; using Server.Mobiles; -using System.Collections; +using Server.Targeting; namespace Server.Targets { public class AIControlMobileTarget : Target { - private ArrayList m_List; + private List m_List; private OrderType m_Order; - public OrderType Order - { - get - { + public OrderType Order { + get { return m_Order; } } public AIControlMobileTarget( BaseAI ai, OrderType order ) : base( -1, false, ( order == OrderType.Attack ? TargetFlags.Harmful : TargetFlags.None ) ) { - m_List = new ArrayList(); + m_List = new List(); m_Order = order; AddAI( ai ); @@ -35,10 +33,10 @@ namespace Server.Targets protected override void OnTarget( Mobile from, object o ) { - if ( o is Mobile ) - { + if ( o is Mobile ) { + Mobile m = (Mobile)o; for ( int i = 0; i < m_List.Count; ++i ) - ((BaseAI)m_List[i]).EndPickTarget( from, (Mobile)o, m_Order ); + m_List[i].EndPickTarget( from, m, m_Order ); } } } diff --git a/Scripts/Engines/BulkOrders/SmallSmithBOD.cs b/Scripts/Engines/BulkOrders/SmallSmithBOD.cs index ecdb3b74d..58d7e0bf8 100644 --- a/Scripts/Engines/BulkOrders/SmallSmithBOD.cs +++ b/Scripts/Engines/BulkOrders/SmallSmithBOD.cs @@ -1,10 +1,9 @@ using System; -using System.Collections; -using Server; -using Server.Items; -using Server.Engines.Craft; -using Mat = Server.Engines.BulkOrders.BulkMaterialType; using System.Collections.Generic; +using Server; +using Server.Engines.Craft; +using Server.Items; +using Mat = Server.Engines.BulkOrders.BulkMaterialType; namespace Server.Engines.BulkOrders { @@ -132,7 +131,7 @@ namespace Server.Engines.BulkOrders CraftSystem system = DefBlacksmithy.CraftSystem; - ArrayList validEntries = new ArrayList(); + List validEntries = new List(); for ( int i = 0; i < entries.Length; ++i ) { @@ -156,7 +155,7 @@ namespace Server.Engines.BulkOrders if ( validEntries.Count > 0 ) { - SmallBulkEntry entry = (SmallBulkEntry)validEntries[Utility.Random( validEntries.Count )]; + SmallBulkEntry entry = validEntries[Utility.Random( validEntries.Count )]; return new SmallSmithBOD( entry, material, amountMax, reqExceptional ); } } diff --git a/Scripts/Engines/BulkOrders/SmallTailorBOD.cs b/Scripts/Engines/BulkOrders/SmallTailorBOD.cs index baf765fb7..8de2c1b44 100644 --- a/Scripts/Engines/BulkOrders/SmallTailorBOD.cs +++ b/Scripts/Engines/BulkOrders/SmallTailorBOD.cs @@ -1,9 +1,8 @@ using System; -using System.Collections; -using Server; -using Server.Items; -using Server.Engines.Craft; using System.Collections.Generic; +using Server; +using Server.Engines.Craft; +using Server.Items; namespace Server.Engines.BulkOrders { @@ -124,7 +123,7 @@ namespace Server.Engines.BulkOrders CraftSystem system = DefTailoring.CraftSystem; - ArrayList validEntries = new ArrayList(); + List validEntries = new List(); for ( int i = 0; i < entries.Length; ++i ) { @@ -148,7 +147,7 @@ namespace Server.Engines.BulkOrders if ( validEntries.Count > 0 ) { - SmallBulkEntry entry = (SmallBulkEntry)validEntries[Utility.Random( validEntries.Count )]; + SmallBulkEntry entry = validEntries[Utility.Random( validEntries.Count )]; return new SmallTailorBOD( entry, material, amountMax, reqExceptional ); } } diff --git a/Scripts/Engines/Harvest/Core/HarvestDefinition.cs b/Scripts/Engines/Harvest/Core/HarvestDefinition.cs index 6babb929a..70552e1ed 100644 --- a/Scripts/Engines/Harvest/Core/HarvestDefinition.cs +++ b/Scripts/Engines/Harvest/Core/HarvestDefinition.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; namespace Server.Engines.Harvest { @@ -53,9 +53,9 @@ namespace Server.Engines.Harvest public HarvestVein[] Veins{ get{ return m_Veins; } set{ m_Veins = value; } } public bool RaceBonus { get { return m_RaceBonus; } set { m_RaceBonus = value; } } - private Hashtable m_BanksByMap; + private Dictionary> m_BanksByMap; - public Hashtable Banks{ get{ return m_BanksByMap; } set{ m_BanksByMap = value; } } + public Dictionary> Banks{ get{ return m_BanksByMap; } set{ m_BanksByMap = value; } } public void SendMessageTo( Mobile from, object message ) { @@ -73,13 +73,15 @@ namespace Server.Engines.Harvest x /= m_BankWidth; y /= m_BankHeight; - Hashtable banks = (Hashtable)m_BanksByMap[map]; + Dictionary banks = null; + m_BanksByMap.TryGetValue( map, out banks ); if ( banks == null ) - m_BanksByMap[map] = banks = new Hashtable(); + m_BanksByMap[map] = banks = new Dictionary(); Point2D key = new Point2D( x, y ); - HarvestBank bank = (HarvestBank)banks[key]; + HarvestBank bank = null; + banks.TryGetValue( key, out bank ); if ( bank == null ) banks[key] = bank = new HarvestBank( this, GetVeinAt( map, x, y ) ); @@ -108,7 +110,7 @@ namespace Server.Engines.Harvest public HarvestDefinition() { - m_BanksByMap = new Hashtable(); + m_BanksByMap = new Dictionary>(); } public bool Validate( int tileID ) diff --git a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs index a39e8e779..ad8a00716 100644 --- a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs +++ b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs @@ -166,13 +166,13 @@ namespace Server.PathAlgorithms.FastAStar int newCost = m_Nodes[bestNode].cost + 1; int newTotal = newCost + Heuristic( newNode % AreaSize, (newNode / AreaSize) % AreaSize, m_Nodes[newNode].z ); - if ( !wasTouched || m_Nodes[newNode].total > newTotal ) + if ( m_Nodes[newNode].total > newTotal ) { m_Nodes[newNode].parent = bestNode; m_Nodes[newNode].cost = newCost; m_Nodes[newNode].total = newTotal; - if ( !wasTouched || !m_OnOpen[newNode] ) + if ( !m_OnOpen[newNode] ) { AddToChain( newNode ); diff --git a/Scripts/Gumps/Go/GoGump.cs b/Scripts/Gumps/Go/GoGump.cs index 47041243d..d8554092a 100644 --- a/Scripts/Gumps/Go/GoGump.cs +++ b/Scripts/Gumps/Go/GoGump.cs @@ -79,7 +79,8 @@ namespace Server.Gumps else tree = Tokuno; - ParentNode branch = (ParentNode)tree.LastBranch[from]; + ParentNode branch = null; + tree.LastBranch.TryGetValue( from, out branch ); if ( branch == null ) branch = tree.Root; diff --git a/Scripts/Gumps/Go/LocationTree.cs b/Scripts/Gumps/Go/LocationTree.cs index e5140e058..17fae6d1a 100644 --- a/Scripts/Gumps/Go/LocationTree.cs +++ b/Scripts/Gumps/Go/LocationTree.cs @@ -1,7 +1,7 @@ using System; +using System.Collections.Generic; using System.IO; using System.Xml; -using System.Collections; using Server; namespace Server.Gumps @@ -10,11 +10,11 @@ namespace Server.Gumps { private Map m_Map; private ParentNode m_Root; - private Hashtable m_LastBranch; + private Dictionary m_LastBranch; public LocationTree( string fileName, Map map ) { - m_LastBranch = new Hashtable(); + m_LastBranch = new Dictionary(); m_Map = map; string path = Path.Combine( "Data/Locations/", fileName ); @@ -31,7 +31,7 @@ namespace Server.Gumps } } - public Hashtable LastBranch + public Dictionary LastBranch { get { diff --git a/Scripts/Gumps/WhoGump.cs b/Scripts/Gumps/WhoGump.cs index 62635bd0a..2c0c36362 100644 --- a/Scripts/Gumps/WhoGump.cs +++ b/Scripts/Gumps/WhoGump.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Commands; using Server.Mobiles; @@ -75,38 +74,28 @@ namespace Server.Gumps private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; private Mobile m_Owner; - private ArrayList m_Mobiles; + private List m_Mobiles; private int m_Page; - private class InternalComparer : IComparer + private class InternalComparer : IComparer { - public static readonly IComparer Instance = new InternalComparer(); + public static readonly IComparer Instance = new InternalComparer(); public InternalComparer() { } - public int Compare( object x, object y ) + public int Compare( Mobile x, Mobile y ) { - if ( x == null && y == null ) - return 0; - else if ( x == null ) - return -1; - else if ( y == null ) - return 1; - - Mobile a = x as Mobile; - Mobile b = y as Mobile; - - if ( a == null || b == null ) + if ( x == null || y == null ) throw new ArgumentException(); - if ( a.AccessLevel > b.AccessLevel ) + if ( x.AccessLevel > y.AccessLevel ) return -1; - else if ( a.AccessLevel < b.AccessLevel ) + else if ( x.AccessLevel < y.AccessLevel ) return 1; else - return Insensitive.Compare( a.Name, b.Name ); + return Insensitive.Compare( x.Name, y.Name ); } } @@ -114,7 +103,7 @@ namespace Server.Gumps { } - public WhoGump( Mobile owner, ArrayList list, int page ) : base( GumpOffsetX, GumpOffsetY ) + public WhoGump( Mobile owner, List list, int page ) : base( GumpOffsetX, GumpOffsetY ) { owner.CloseGump( typeof( WhoGump ) ); @@ -124,14 +113,14 @@ namespace Server.Gumps Initialize( page ); } - public static ArrayList BuildList( Mobile owner, string filter ) + public static List BuildList( Mobile owner, string filter ) { if ( filter != null && (filter = filter.Trim()).Length == 0 ) filter = null; else filter = filter.ToLower(); - ArrayList list = new ArrayList(); + List list = new List(); List states = NetState.Instances; for ( int i = 0; i < states.Count; ++i ) @@ -213,7 +202,7 @@ namespace Server.Gumps x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; - Mobile m = (Mobile)m_Mobiles[index]; + Mobile m = m_Mobiles[index]; AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID ); AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, GetHueFor( m ), m.Deleted ? "(deleted)" : m.Name ); @@ -280,7 +269,7 @@ namespace Server.Gumps if ( index >= 0 && index < m_Mobiles.Count ) { - Mobile m = (Mobile)m_Mobiles[index]; + Mobile m = m_Mobiles[index]; if ( m.Deleted ) { diff --git a/Scripts/Items/Clothing/BaseClothing.cs b/Scripts/Items/Clothing/BaseClothing.cs index df8bfc872..8bc812efe 100644 --- a/Scripts/Items/Clothing/BaseClothing.cs +++ b/Scripts/Items/Clothing/BaseClothing.cs @@ -1,9 +1,9 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server; -using Server.Network; using Server.Engines.Craft; using Server.Factions; +using Server.Network; namespace Server.Items { @@ -637,7 +637,7 @@ namespace Server.Items public override void OnSingleClick( Mobile from ) { - ArrayList attrs = new ArrayList(); + List attrs = new List(); if ( DisplayLootType ) { @@ -670,7 +670,7 @@ namespace Server.Items if ( attrs.Count == 0 && Crafter == null && Name != null ) return; - EquipmentInfo eqInfo = new EquipmentInfo( number, m_Crafter, false, (EquipInfoAttribute[])attrs.ToArray( typeof( EquipInfoAttribute ) ) ); + EquipmentInfo eqInfo = new EquipmentInfo( number, m_Crafter, false, attrs.ToArray() ); from.Send( new DisplayEquipmentInfo( this, eqInfo ) ); } diff --git a/Scripts/Items/Construction/Doors/BaseDoor.cs b/Scripts/Items/Construction/Doors/BaseDoor.cs index a4356f9e9..6864084e9 100644 --- a/Scripts/Items/Construction/Doors/BaseDoor.cs +++ b/Scripts/Items/Construction/Doors/BaseDoor.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Commands; using Server.Network; @@ -90,7 +89,7 @@ namespace Server.Items [Description( "Chain-links two or more targeted doors together." )] private static void ChainLink_OnCommand( CommandEventArgs e ) { - e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), new ArrayList() ); + e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), new List() ); e.Mobile.SendMessage( "Target the first of a sequence of doors to link." ); } @@ -105,14 +104,14 @@ namespace Server.Items } else { - ArrayList list = (ArrayList)state; + List list = (List)state; if ( list.Count > 0 && list[0] == door ) { if ( list.Count >= 2 ) { for ( int i = 0; i < list.Count; ++i ) - ((BaseDoor)list[i]).Link = ((BaseDoor)list[(i + 1) % list.Count]); + list[i].Link = list[(i + 1) % list.Count]; from.SendMessage( "The chain of doors have been linked." ); } @@ -403,9 +402,9 @@ namespace Server.Items public virtual bool UseChainedFunctionality{ get{ return false; } } - public ArrayList GetChain() + public List GetChain() { - ArrayList list = new ArrayList(); + List list = new List(); BaseDoor c = this; do @@ -422,12 +421,12 @@ namespace Server.Items if ( !UseChainedFunctionality ) return CanClose(); - ArrayList list = GetChain(); + List list = GetChain(); bool freeToClose = true; for ( int i = 0; freeToClose && i < list.Count; ++i ) - freeToClose = ((BaseDoor)list[i]).CanClose(); + freeToClose = list[i].CanClose(); return freeToClose; } @@ -490,10 +489,10 @@ namespace Server.Items { bool open = !m_Open; - ArrayList list = GetChain(); + List list = GetChain(); for ( int i = 0; i < list.Count; ++i ) - ((BaseDoor)list[i]).Open = open; + list[i].Open = open; } else { diff --git a/Scripts/Items/Containers/Strongbox.cs b/Scripts/Items/Containers/Strongbox.cs index 5d1a372e6..9ecf137f7 100644 --- a/Scripts/Items/Containers/Strongbox.cs +++ b/Scripts/Items/Containers/Strongbox.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server; using Server.Multis; using Server.Network; @@ -152,7 +152,7 @@ namespace Server.Items public Container ConvertToStandardContainer() { Container metalBox = new MetalBox(); - ArrayList subItems = new ArrayList( Items ); + List subItems = new List( Items ); foreach ( Item subItem in subItems ) { diff --git a/Scripts/Items/Containers/TreasureMapChest.cs b/Scripts/Items/Containers/TreasureMapChest.cs index ba69fe43e..40a7ab65c 100644 --- a/Scripts/Items/Containers/TreasureMapChest.cs +++ b/Scripts/Items/Containers/TreasureMapChest.cs @@ -1,12 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using Server; +using Server.ContextMenus; +using Server.Engines.PartySystem; using Server.Gumps; using Server.Multis; using Server.Network; -using Server.ContextMenus; -using Server.Engines.PartySystem; namespace Server.Items { @@ -274,7 +273,7 @@ namespace Server.Items } } - private ArrayList m_Lifted = new ArrayList(); + private List m_Lifted = new List(); private bool CheckLoot( Mobile m, bool criminalAction ) { @@ -365,7 +364,7 @@ namespace Server.Items writer.Write( (int) m_Level ); writer.WriteDeltaTime( m_DeleteTime ); - writer.WriteItemList( m_Lifted, true ); + writer.Write( m_Lifted, true ); } public override void Deserialize( GenericReader reader ) @@ -393,7 +392,7 @@ namespace Server.Items { m_Level = reader.ReadInt(); m_DeleteTime = reader.ReadDeltaTime(); - m_Lifted = reader.ReadItemList(); + m_Lifted = reader.ReadStrongItemList(); if ( version < 2 ) m_Guardians = new List(); diff --git a/Scripts/Items/Misc/Corpses/Corpse.cs b/Scripts/Items/Misc/Corpses/Corpse.cs index ebde64c15..10a3da35b 100644 --- a/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Scripts/Items/Misc/Corpses/Corpse.cs @@ -387,16 +387,16 @@ namespace Server.Items writer.WriteDeltaTime( m_TimeOfDeath ); - ArrayList list = ( m_RestoreTable == null ? null : new ArrayList( m_RestoreTable ) ); + List> list = ( m_RestoreTable == null ? null : new List>( m_RestoreTable ) ); int count = ( list == null ? 0 : list.Count ); writer.Write( count ); - for ( int i = 0; list != null && i < list.Count; ++i ) + for ( int i = 0; i < list.Count; ++i ) { - DictionaryEntry de = (DictionaryEntry)list[i]; - Item item = (Item)de.Key; - Point3D loc = (Point3D)de.Value; + KeyValuePair kvp = list[i]; + Item item = kvp.Key; + Point3D loc = kvp.Value; writer.Write( item ); @@ -644,20 +644,14 @@ namespace Server.Items list.Add( new OpenCorpseEntry() ); } - private Hashtable m_RestoreTable; + private Dictionary m_RestoreTable; public bool GetRestoreInfo( Item item, ref Point3D loc ) { if ( m_RestoreTable == null || item == null ) return false; - object obj = m_RestoreTable[item]; - - if ( obj == null ) - return false; - - loc = (Point3D)obj; - return true; + return m_RestoreTable.TryGetValue( item, out loc ); } public void SetRestoreInfo( Item item, Point3D loc ) @@ -666,7 +660,7 @@ namespace Server.Items return; if ( m_RestoreTable == null ) - m_RestoreTable = new Hashtable(); + m_RestoreTable = new Dictionary(); m_RestoreTable[item] = loc; } diff --git a/Scripts/Mobiles/Vendors/GenericBuy.cs b/Scripts/Mobiles/Vendors/GenericBuy.cs index 94aadc2e6..0ad26dfb8 100644 --- a/Scripts/Mobiles/Vendors/GenericBuy.cs +++ b/Scripts/Mobiles/Vendors/GenericBuy.cs @@ -253,8 +253,6 @@ namespace Server.Mobiles public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args ) { - amount = 20; - m_Type = type; m_Price = price; m_MaxAmount = m_Amount = amount; diff --git a/Scripts/Spells/Sixth/Dispel.cs b/Scripts/Spells/Sixth/Dispel.cs index 70af011ad..b99822006 100644 --- a/Scripts/Spells/Sixth/Dispel.cs +++ b/Scripts/Spells/Sixth/Dispel.cs @@ -28,50 +28,6 @@ namespace Server.Spells.Sixth Caster.Target = new InternalTarget( this ); } - public void Target( Mobile m ) - { - Type t = m.GetType(); - bool dispellable = false; - - if ( m is BaseCreature ) - dispellable = ( m as BaseCreature ).IsDispellable; - - if ( !Caster.CanSee( m ) ) - { - Caster.SendLocalizedMessage( 500237 ); // Target can not be seen. - } - else if ( !dispellable ) - { - Caster.SendLocalizedMessage( 1005049 ); // That cannot be dispelled. - } - else if ( CheckHSequence( m ) ) - { - SpellHelper.Turn( Caster, m ); - - BaseCreature bc = m as BaseCreature; - - double dispelChance = 0; - - if ( bc != null ) - dispelChance = (50.0 + ((100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty)) / (bc.DispelFocus*2))) / 100; - - if ( dispelChance > Utility.RandomDouble() ) - { - Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 ); - Effects.PlaySound( m, m.Map, 0x201 ); - - m.Delete(); - } - else - { - m.FixedEffect( 0x3779, 10, 20 ); - Caster.SendLocalizedMessage( 1010084 ); // The creature resisted the attempt to dispel it! - } - } - - FinishSequence(); - } - public class InternalTarget : Target { private DispelSpell m_Owner; @@ -85,7 +41,36 @@ namespace Server.Spells.Sixth { if ( o is Mobile ) { - m_Owner.Target( (Mobile)o ); + Mobile m = (Mobile)o; + BaseCreature bc = m as BaseCreature; + + if ( !from.CanSee( m ) ) + { + from.SendLocalizedMessage( 500237 ); // Target can not be seen. + } + else if ( bc == null || !bc.IsDispellable ) + { + from.SendLocalizedMessage( 1005049 ); // That cannot be dispelled. + } + else if ( m_Owner.CheckHSequence( m ) ) + { + SpellHelper.Turn( from, m ); + + double dispelChance = (50.0 + ((100 * (from.Skills.Magery.Value - bc.DispelDifficulty)) / (bc.DispelFocus*2))) / 100; + + if ( dispelChance > Utility.RandomDouble() ) + { + Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 ); + Effects.PlaySound( m, m.Map, 0x201 ); + + m.Delete(); + } + else + { + m.FixedEffect( 0x3779, 10, 20 ); + from.SendLocalizedMessage( 1010084 ); // The creature resisted the attempt to dispel it! + } + } } }