/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\mobiles\PhantomAsp.cs
Lines of code: 132
***********************************************************/


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

//Abilities:
//Paralyze and armor ignore
//Camouflage attack (Becomes ethereal hue and speeds up)
//Regular attack (Green but hits harder)
//Stealth jumping (Hides and pops up someplace else to confuse the attacker)
//Can hide and stealth at will

namespace Server.Mobiles
{
	[CorpseName("a phantom asp corpse")]
	public class PhantomAsp : BaseCreature
	{
	
		public override WeaponAbility GetWeaponAbility()
		{
			switch ( Utility.Random( 6 ) )
			{
				default:
				case 0: return WeaponAbility.Dismount;
				case 1: return WeaponAbility.ArmorIgnore;
				case 2: return WeaponAbility.ParalyzingBlow;
				case 3: return WeaponAbility.ParalyzingBlow;
				case 4: return WeaponAbility.Dismount;
				case 5: return WeaponAbility.ParalyzingBlow;
			}
		}

		[Constructable]
		public PhantomAsp() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Body = 92;
			Name = "a phantom asp";
			BaseSoundID = 219;
			Hue = 877; 

			SetStr( 161, 360 );
			SetDex( 300, 600 );
			SetInt( 110, 140 );

			SetHits( 289, 365 );

			SetDamage( 8, 16 );

			if ( 0.3 > Utility.RandomDouble() ) {
				this.Hidden = true;
				this.AllowedStealthSteps = 2000;
			}
			
			ActiveSpeed = 0.11;
			CurrentSpeed = 0.11;
			PassiveSpeed = 0.11;
			
			SetDamageType( ResistanceType.Physical, 50 );
			SetDamageType( ResistanceType.Poison, 50 );

			SetResistance( ResistanceType.Physical, 40, 60 );
			SetResistance( ResistanceType.Fire, 40, 60 );
			SetResistance( ResistanceType.Cold, 70 );
			SetResistance( ResistanceType.Poison, 100 );
			SetResistance( ResistanceType.Energy, 70 );

			SetSkill( SkillName.Poisoning, 120 );
			SetSkill( SkillName.MagicResist, 95.1, 100.0 );
			SetSkill( SkillName.Tactics, 90);
			SetSkill( SkillName.Wrestling, 120 );
			SetSkill( SkillName.Stealth, 120 );

			Fame = 9000;
			Karma = -9000;

			VirtualArmor = 40;
			PackItem( new NoxCrystal(10) );
			
			if ( 0.4 > Utility.RandomDouble())
				PackItem( new DeadlyPoisonPotion() );
				
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Rich, 4 );
			AddLoot( LootPack.Gems, 2 );
		}

		public override void OnGaveMeleeAttack(Mobile defender)
 		{
			if ( 0.4 > Utility.RandomDouble() && this.Hidden == false)
			{
				this.Hidden = true;
				this.AllowedStealthSteps = 200;
				this.Stam = 600;
			}
			base.OnGaveMeleeAttack(defender);
		}

		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
		if(attacker==null || attacker.InRange(this,15))return;
		
			if ( 0.2 > Utility.RandomDouble() && this.Hue != 32214 && this.Hidden == false) //Camouflage attack
			{
				attacker.SendMessage( "The snake camouflages itself" ); 
				SetDamage( 5, 10 );
				ActiveSpeed = 0.001;
				CurrentSpeed = 0.001;
				PassiveSpeed = 0.001;
				Hue = 32214; 
			}
			
			if ( 0.2 > Utility.RandomDouble() && this.Hue == 32214 && this.Hidden == false) //Regular attack
			{
				attacker.SendMessage( "The snake breaks out of camouflage" ); 
				SetDamage( 8, 16 );
				ActiveSpeed = 0.11;
				CurrentSpeed = 0.11;
				PassiveSpeed = 0.11;
				Hue = 877; 
			}
			
			if ( 0.2 > Utility.RandomDouble() && this.Hidden == false) //Stealth jumping
			{
				this.Hidden = true;
				Map map = attacker.Map;
				
				int x = this.X + Utility.RandomMinMax( -10, 10 );
				int y = this.Y + Utility.RandomMinMax( -10, 10 );
				int z = this.Z;
				if ( map.CanSpawnMobile( new Point3D( x, y, z) ) )
					{
					this.MoveToWorld( new Point3D( x, y, z ), Map );
					this.AllowedStealthSteps = 200;
					}
			}
			
		}

		public override int Meat{ get{ return 4; } }
		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
		public override Poison HitPoison{ get{ return Poison.Lethal; } }
		public override double HitPoisonChance{ get{ return 0.6; } }

		public PhantomAsp(Serial serial) : base(serial)
		{
		}

		public override void Serialize(GenericWriter writer)
		{
			base.Serialize(writer);

			writer.Write((int) 0);
		}

		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			if ( BaseSoundID == -1 )
				BaseSoundID = 219;
		}
	}
}