a few generics and misc code cleanup

slight tweaks/opt
This commit is contained in:
mark 2007-01-19 19:33:13 +00:00
parent 83190372f8
commit 566de1c2cf
20 changed files with 125 additions and 164 deletions

View file

@ -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!
}
}
}
}