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


using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	/// <summary>
	/// Does damage and paralyses your opponent for a short time.
	/// </summary>
	public class NerveStrike : WeaponAbility
	{
		public NerveStrike()
		{
		}

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

		public override bool CheckSkills( Mobile from )
		{
			if( GetSkill( from, SkillName.Bushido ) < 50.0 )
			{
				from.SendLocalizedMessage( 1070768, "50" ); // You need ~1_SKILL_REQUIREMENT~ Bushido skill to perform that attack!
				return false;
			}

			return base.CheckSkills( from );
		}

		public override bool OnBeforeSwing( Mobile attacker, Mobile defender )
		{
			if( defender.Paralyzed )
			{
				attacker.SendLocalizedMessage( 1061923 ); // The target is already frozen.
				return false;
			}

			return true;
		}

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

			ClearCurrentAbility( attacker );

			if( Server.Items.ParalyzingBlow.IsImmune( defender ) )	//After mana consumption intentional
			{
				attacker.SendLocalizedMessage( 1070804 ); // Your target resists paralysis.
				defender.SendLocalizedMessage( 1070813 ); // You resist paralysis.
				return;
			}

			attacker.SendLocalizedMessage( 1063356 ); // You cripple your target with a nerve strike!
			defender.SendLocalizedMessage( 1063357 ); // Your attacker dealt a crippling nerve strike!

			attacker.PlaySound( 0x204 );
			defender.FixedEffect( 0x376A, 9, 32 );
			defender.FixedParticles( 0x37C4, 1, 8, 0x13AF, 0, 0, EffectLayer.Waist );
			
			int dmg=(int)((attacker.Skills[SkillName.Bushido].Value - 50.0) * (3.0/14.0) + Utility.Random(11));
			if(dmg<1)dmg=1;

			
			AOS.Damage( defender, attacker,dmg, false, 0,0,0,0,0,0,100,false );
			

			int duration = (int)(attacker.Skills[SkillName.Bushido].Value)/((defender is BaseCreature) ? 20 : 60);

			
			defender.Paralyze( TimeSpan.FromSeconds( duration) );
			Server.Items.ParalyzingBlow.BeginImmunity( defender, TimeSpan.FromSeconds( 15.0 + Utility.Random(11) ) );
		}
	}
}
