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


using System;
using System.Collections;
using Server.Spells;

namespace Server.Items
{
	/// <summary>
	/// Adds extra Physical and Poison damage to the target, as well as increasing the attacker's strenght temporarly 
	/// </summary>
	public class ForceOfNature : WeaponAbility
	{
		public ForceOfNature()
		{
		}

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


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

			ClearCurrentAbility( attacker );

			attacker.SendLocalizedMessage(1074374); //You attack your enemy with the force of nature!
			defender.SendLocalizedMessage(1074375); //You are assaulted with great force!
			
			//attacker.FixedParticles( 0x3967, 1, 22, 0x7F5, 667, 0x3, EffectLayer.Waist );
			attacker.FixedParticles( 0x376A, 1, 14, 0x7F5, 1420, 0x3, EffectLayer.Head ); 
			attacker.FixedParticles( 0x3946, 1, 14, 0x7F5, 1420, 0x3, EffectLayer.Head ); 

			
			defender.PlaySound(1470);
			
			int seconds=60+Utility.Random(60);
			
			SpellHelper.AddStatBonus( attacker, attacker, StatType.Str,20,TimeSpan.FromSeconds(seconds));
			
			StartEffect(attacker,seconds);
		}
		
		
		private static Hashtable m_Table = new Hashtable();
		
		public static void StartEffect(Mobile defender,int seconds)
		{
		if(m_Table.Contains(defender))m_Table.Remove(defender);
		
		Timer t = new InternalTimer( defender,TimeSpan.FromSeconds(seconds));
		t.Start();		
		m_Table[defender]=(Timer)t;		
		}
		
		
		public static void StopEffect(Mobile defender)
		{
		if(defender==null)return;
		if(m_Table.Contains(defender))m_Table.Remove(defender);		
		}
		
		public static bool IsUnderEffect(Mobile attacker)
		{
		if(attacker==null)return false;
		return(m_Table.Contains(attacker));
		}
		
		
		private class InternalTimer : Timer
		{
			private Mobile m_attacker;
			private DateTime expire;

			public InternalTimer( Mobile attacker,TimeSpan duration ): base(TimeSpan.FromSeconds(1),TimeSpan.FromSeconds(4) )	
			{
				m_attacker = attacker;
				expire=DateTime.Now+duration;
			}

			protected override void OnTick()
			{
				if(m_attacker==null || !m_attacker.Alive || DateTime.Now>expire)
				{
				StopEffect(m_attacker);
				Stop();
				}
	
			}
		}
		
		
	}
}ÿ