diff --git a/Scripts/Items/Skill Items/Misc/Bandage.cs b/Scripts/Items/Skill Items/Misc/Bandage.cs index f770b1c33..9e282e8af 100644 --- a/Scripts/Items/Skill Items/Misc/Bandage.cs +++ b/Scripts/Items/Skill Items/Misc/Bandage.cs @@ -1,17 +1,18 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server; -using Server.Mobiles; +using Server.Gumps; using Server.Items; +using Server.Mobiles; using Server.Network; using Server.Targeting; -using Server.Gumps; -using System.Collections.Generic; namespace Server.Items { public class Bandage : Item, IDyable { + public static int Range = ( Core.AOS ? 2 : 1 ); + public override double DefaultWeight { get { return 0.1; } @@ -59,7 +60,7 @@ namespace Server.Items public override void OnDoubleClick( Mobile from ) { - if ( from.InRange( GetWorldLocation(), Core.AOS ? 2 : 1 ) ) + if ( from.InRange( GetWorldLocation(), Range ) ) { from.RevealingAction(); @@ -72,11 +73,12 @@ namespace Server.Items from.SendLocalizedMessage( 500295 ); // You are too far away to do that. } } + private class InternalTarget : Target { private Bandage m_Bandage; - public InternalTarget( Bandage bandage ) : base( 1, false, TargetFlags.Beneficial ) + public InternalTarget( Bandage bandage ) : base( Bandage.Range, false, TargetFlags.Beneficial ) { m_Bandage = bandage; } @@ -88,9 +90,9 @@ namespace Server.Items if ( targeted is Mobile ) { - if ( from.InRange( m_Bandage.GetWorldLocation(), Core.AOS ? 2 : 1 ) ) + if ( from.InRange( m_Bandage.GetWorldLocation(), Bandage.Range ) ) { - if ( BandageContext.BeginHeal( from, (Mobile) targeted ) != null ) + if ( BandageContext.BeginHeal( from, (Mobile)targeted ) != null ) { m_Bandage.Consume(); } @@ -145,11 +147,13 @@ namespace Server.Items m_Timer = null; } - private static Hashtable m_Table = new Hashtable(); + private static Dictionary m_Table = new Dictionary(); public static BandageContext GetContext( Mobile healer ) { - return (BandageContext)m_Table[healer]; + BandageContext bc = null; + m_Table.TryGetValue( healer, out bc ); + return bc; } public static SkillName GetPrimarySkill( Mobile m ) @@ -187,7 +191,7 @@ namespace Server.Items patientNumber = -1; playSound = false; } - else if ( !m_Healer.InRange( m_Patient, Core.AOS ? 2 : 1 ) ) + else if ( !m_Healer.InRange( m_Patient, Bandage.Range ) ) { healerNumber = 500963; // You did not stay close enough to heal your target. patientNumber = -1; diff --git a/Scripts/Mobiles/Townfolk/Banker.cs b/Scripts/Mobiles/Townfolk/Banker.cs index 4cb607990..bb5a0b0cc 100644 --- a/Scripts/Mobiles/Townfolk/Banker.cs +++ b/Scripts/Mobiles/Townfolk/Banker.cs @@ -104,7 +104,7 @@ namespace Server.Mobiles if ( box == null ) return false; - ArrayList items = new ArrayList(); + List items = new List(); while ( amount > 0 ) { diff --git a/Scripts/Spells/Base/Spell.cs b/Scripts/Spells/Base/Spell.cs index ef750f81e..c0502bb16 100644 --- a/Scripts/Spells/Base/Spell.cs +++ b/Scripts/Spells/Base/Spell.cs @@ -46,38 +46,64 @@ namespace Server.Spells //the possibility of stacking 'em. Note that a MA & an Explosion will stack, but //of course, two MA's won't. - private static Dictionary> m_ContextTable = new Dictionary>(); + private static Dictionary> m_ContextTable = new Dictionary>(); - public void StartDelayedDamageContext( Mobile m, Timer t ) + private class DelayedDamageContext { + public Mobile Target; + public Type Type; + public Timer Timer; + + public DelayedDamageContext( Mobile target, Type type, Timer timer ) { + Target = target; + Type = type; + Timer = timer; + } + } + + public void StartDelayedDamageContext( Mobile target, Timer timer ) { if( DelayedDamageStacking ) return; //Sanity - Dictionary contexts; + List contexts; + Type type = this.GetType(); - if( !m_ContextTable.TryGetValue( GetType(), out contexts ) ) - { - contexts = new Dictionary(); - m_ContextTable.Add( GetType(), contexts ); + if( !m_ContextTable.TryGetValue( m_Caster, out contexts ) ) + contexts = new List(); + else { + for ( int i = 0; i < contexts.Count; i++ ) { + DelayedDamageContext ddc = contexts[i]; + + if ( ddc.Target == target && ddc.Type == type ) { + ddc.Timer.Stop(); + contexts.RemoveAt( i ); + break; + } + } } - if( contexts.ContainsKey( m ) ) - { - contexts[m].Stop(); - contexts.Remove( m ); - } + contexts.Add( new DelayedDamageContext( target, type, timer ); + } - contexts.Add( m, t ); - } - - public void RemoveDelayedDamageContext( Mobile m ) + public void RemoveDelayedDamageContext( Mobile target ) { - Dictionary contexts; + List contexts; + Type type = this.GetType(); - if( !m_ContextTable.TryGetValue( GetType(), out contexts ) ) + if( !m_ContextTable.TryGetValue( m_Caster, out contexts ) ) return; - contexts.Remove( m ); + for ( int i = 0; i < contexts.Count; i++ ) { + DelayedDamageContext ddc = contexts[i]; + + if ( ddc.Target == target && ddc.Type == type ) { + contexts.RemoveAt( i ); + break; + } + } + + if ( contexts.Count == 0 ) + m_ContextTable.Remove( m_Caster ); } public Spell( Mobile caster, Item scroll, SpellInfo info ) diff --git a/Scripts/Spells/Base/SpellHelper.cs b/Scripts/Spells/Base/SpellHelper.cs index da519b689..0c6b6064b 100644 --- a/Scripts/Spells/Base/SpellHelper.cs +++ b/Scripts/Spells/Base/SpellHelper.cs @@ -876,7 +876,7 @@ namespace Server.Spells m_Spell = s; if ( m_Spell != null && m_Spell.DelayedDamage && !m_Spell.DelayedDamageStacking ) - m_Spell.StartDelayedDamageContext( from, this ); + m_Spell.StartDelayedDamageContext( target, this ); Priority = TimerPriority.TwentyFiveMS; } @@ -891,7 +891,7 @@ namespace Server.Spells m_Target.Damage( m_Damage ); if ( m_Spell != null ) - m_Spell.RemoveDelayedDamageContext( m_From ); + m_Spell.RemoveDelayedDamageContext( m_Target ); } } @@ -917,7 +917,7 @@ namespace Server.Spells m_DFA = dfa; m_Spell = s; if ( m_Spell != null && m_Spell.DelayedDamage && !m_Spell.DelayedDamageStacking ) - m_Spell.StartDelayedDamageContext( from, this ); + m_Spell.StartDelayedDamageContext( target, this ); Priority = TimerPriority.TwentyFiveMS; } @@ -938,7 +938,7 @@ namespace Server.Spells ( (BaseCreature) m_Target ).OnDamagedBySpell( m_From ); if ( m_Spell != null ) - m_Spell.RemoveDelayedDamageContext( m_From ); + m_Spell.RemoveDelayedDamageContext( m_Target ); } } diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 11a119684..ebafc29f6 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -3741,7 +3741,7 @@ namespace Server return; else if( m_Deleted ) return; - else if( !Region.OnDeath( this ) ) + else if( !Region.OnBeforeDeath( this ) ) return; else if( !OnBeforeDeath() ) return; @@ -3900,6 +3900,7 @@ namespace Server eable.Free(); } + Region.OnDeath( this ); OnDeath( c ); } diff --git a/Server/Region.cs b/Server/Region.cs index 8b7d2507f..6985a7f7a 100644 --- a/Server/Region.cs +++ b/Server/Region.cs @@ -742,14 +742,20 @@ namespace Server return true; } - public virtual bool OnDeath( Mobile m ) + public virtual bool OnBeforeDeath( Mobile m ) { if ( m_Parent != null ) - return m_Parent.OnDeath( m ); + return m_Parent.OnBeforeDeath( m ); return true; } + public virtual void OnDeath( Mobile m ) + { + if ( m_Parent != null ) + m_Parent.OnDeath( m ); + } + public virtual bool OnDamage( Mobile m, ref int Damage ) { if ( m_Parent != null )