/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\Items\Weapons\Abilities\ForceArrow.cs
Lines of code: 53
***********************************************************/


using System;
using System.Collections;
using Server.Items;

namespace Server.Items
{
	/// <summary>
	/// Makes oponent easier to hit, and gives a chance of them forgetting who they are attacking (loose target?)
	/// </summary>
	public class ForceArrow : WeaponAbility
	{
		private static Hashtable m_Registry = new Hashtable();
		public static Hashtable Registry { get { return m_Registry; } }

		public ForceArrow()
		{
		}

		public override int BaseMana { get { return 20; } }



		public override void OnHit( Mobile attacker, Mobile defender, int damage )
		{
			if( !Validate( attacker ) || !CheckMana( attacker, true ) )
				return;

			if( Registry.Contains( defender ) )
			{
				ForceArrowTimer existingtimer = (ForceArrowTimer)Registry[defender];
				existingtimer.Stop();
				Registry.Remove( defender );
			}

			ClearCurrentAbility( attacker );

			attacker.SendMessage( "You daze your target with a forced arrow" ); 
			
			defender.PlaySound(1469);
			defender.FixedParticles( 0x3728, 1, 13, 0x7F3, 0x962, 0, EffectLayer.Waist );

			//40% chance? to loose aggro 
			if(0.4>Utility.RandomDouble())
			{
			defender.Combatant=null;			
			defender.SendMessage( "You are dazed from the forced arrow and forget who you are fighting!");
			}
			else defender.SendMessage( "You are dazed from the forced arrow");
			
			Timer t = new ForceArrowTimer( defender);	//20-50 % decrease

			t.Start();
			Registry.Add( defender, t );
		}

		public class ForceArrowTimer : Timer
		{
			private Mobile m_Defender;
			//private int m_SwingSpeedReduction;

			//public int SwingSpeedReduction { get { return m_SwingSpeedReduction; } }

			public ForceArrowTimer( Mobile defender )	: base( TimeSpan.FromSeconds( 8.0 ) ) //8 Second Duration
			{
				m_Defender = defender;
				//m_SwingSpeedReduction = swingSpeedReduction;
				Priority = TimerPriority.FiftyMS;
			}

			protected override void OnTick()
			{
				m_Defender.SendMessage( "You are no longer dazed");
				Registry.Remove( m_Defender );
			}
		}
	}
}ÿ