I am trying to add a VirtualArmorMod to one of my spells with a timer with no luck any help will be greatful.
Code:
using System;
using System.Collections;
using Server.Targeting;
using Server.Network;
using Server.Mobiles;
using Server.Spells.Necromancy;
namespace Server.Spells.Cleric
{
public class SheildofFaithSpell : ClericSpell
{
private static SpellInfo m_Info = new SpellInfo( "Purge", "Repurgo", 212, 9041 );
public override TimeSpan CastDelayBase { get { return TimeSpan.FromSeconds( 1.5 ); } }
public override int RequiredTithing{ get{ return 10; } }
public override double RequiredSkill{ get{ return 45.0; } }
public override int RequiredMana{ get{ return 10; } }
public override bool BlocksMovement{ get{ return false; } }
public SheildofFaithSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
{
}
public override void OnCast()
{
if ( CheckSequence() )
{
TimeSpan duration = TimeSpan.FromSeconds( Caster.Skills[SkillName.AnimalLore].Value * 0.1 );
int amount = (int)( Caster.Skills[SkillName.AnimalLore].Value * .45 );
Caster.SendMessage( "Your prayers have been answered and bleesed with the sheild of faith!" );
ResistanceMod mod1 = new ResistanceMod( ResistanceType.Physical, + amount );
ResistanceMod mod2 = new ResistanceMod( ResistanceType.Energy, + amount );
VirtualArmorMod mod3 = new VirtualArmorMod( + 20 );
Caster.FixedParticles( 0x373A, 10, 15, 5012, 0x14, 3, EffectLayer.Waist );
Caster.AddResistanceMod( mod1 );
Caster.AddResistanceMod( mod2 );
Caster.VirtualArmorMod( mod3 );
new ExpireTimer( Caster, mod1, duration ).Start();
new ExpireTimer( Caster, mod2, duration ).Start();
new ExpireTimer( Caster, mod3, duration ).Start();
if ( Caster is GPlayerMobile )
{
Misc.Levels.AwardExp( Caster, +5, true );
}
else
{
}
}
FinishSequence();
}
private class ExpireTimer : Timer
{
private Mobile m_Mobile;
private ResistanceMod m_Mods;
//private VirtualArmorMod m_VMods;
public ExpireTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
{
m_Mobile = m;
m_Mods = mod;
//m_VMods = vmod;
}
public void DoExpire()
{
m_Mobile.RemoveResistanceMod( m_Mods );
//m_Mobile.RemoveVirtualArmorMod( m_VMods );
Stop();
}
protected override void OnTick()
{
if ( m_Mobile != null )
{
//m_Mobile.VirtualArmorMod
m_Mobile.SendMessage( "The effect of sheild of faith wears off." );
DoExpire();
}
}
}
}
}