fix bandage range, change some ondeath/onbeforedeath region calls, fix spell delayed damage

This commit is contained in:
mark 2007-01-14 02:06:27 +00:00
parent 85fbf8ab81
commit 603f1bf8fe
6 changed files with 75 additions and 38 deletions

View file

@ -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<Type, Dictionary<Mobile, Timer>> m_ContextTable = new Dictionary<Type, Dictionary<Mobile, Timer>>();
private static Dictionary<Mobile, List<DelayedDamageContext>> m_ContextTable = new Dictionary<Mobile, List<DelayedDamageContext>>();
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<Mobile, Timer> contexts;
List<DelayedDamageContext> contexts;
Type type = this.GetType();
if( !m_ContextTable.TryGetValue( GetType(), out contexts ) )
{
contexts = new Dictionary<Mobile, Timer>();
m_ContextTable.Add( GetType(), contexts );
if( !m_ContextTable.TryGetValue( m_Caster, out contexts ) )
contexts = new List<DelayedDamageContext>();
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<Mobile, Timer> contexts;
List<DelayedDamageContext> 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 )

View file

@ -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 );
}
}