public static bool OnCast( Mobile caster, Spell spell )
{
ITransformationSpell transformSpell = spell as ITransformationSpell;
if( transformSpell == null )
return false;
if( !caster.CanBeginAction( typeof( PolymorphSpell ) ) )
{
caster.SendLocalizedMessage( 1061628 ); // You can't do that while polymorphed.
}
else if ( DisguiseTimers.IsDisguised( caster ) )
{
caster.SendLocalizedMessage( 1061631 ); // You can't do that while disguised.
return false;
}
else if( !caster.CanBeginAction( typeof( IncognitoSpell ) ) || (caster.IsBodyMod && GetContext( caster ) == null) )
{
spell.DoFizzle();
}
else if( spell.CheckSequence() )
{
TransformContext context = GetContext( caster );
Type ourType = spell.GetType();
bool wasTransformed = (context != null);
bool ourTransform = (wasTransformed && context.Type == ourType);
if( wasTransformed )
{
RemoveContext( caster, context, ourTransform );
if( ourTransform )
{
caster.PlaySound( 0xFA );
caster.FixedParticles( 0x3728, 1, 13, 5042, EffectLayer.Waist );
}
}
if( !ourTransform )
{
if( !((Body)transformSpell.Body).IsHuman )
{
Mobiles.IMount mt = caster.Mount;
if( mt != null )
mt.Rider = null;
}
caster.BodyMod = transformSpell.Body;
caster.HueMod = transformSpell.Hue;
transformSpell.DoEffect( caster );
Timer timer = new TransformTimer( caster, transformSpell );
timer.Start();
AddContext( caster, new TransformContext( timer, ourType, transformSpell ) );
return true;
}
}
return false;
}
}