/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\engines\ML Peerless + misc areas\travesty\mobiles\Travesty.cs
Lines of code: 277
***********************************************************/


using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Engines.CannedEvil;
using System.Collections.Generic;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Mobiles
{

	[CorpseName( "Travesty's corpse" )]
	public class Travesty :  Changeling
	{
	
		public override int SuperAI_DelayMax{ get{ return 0; } }
		public override int SuperAI_Intensity{ get{ return 150; } }		
	
		Random rand = new Random(); 
		private int amount;
		private int spawntype = 0;
		public override string OriginalName {get{ return "Travesty";}}		

		[Constructable]
		public Travesty()
		{
			Name = "Travesty";
			Body = 264;
			BaseSoundID = 0x451;
           
			SetStr( 909, 949 );
			SetDex( 901, 948 );
			SetInt( 903, 947 );

			SetHits( 35000 );

			SetDamage( 29, 35 );
			SetStam ( 901, 948 ); 
			SetMana ( 903, 947 );

			SetResistance( ResistanceType.Physical, 52, 67 );
			SetResistance( ResistanceType.Fire, 51, 68 );
			SetResistance( ResistanceType.Cold, 51, 69 );
			SetResistance( ResistanceType.Poison, 51, 70 );
			SetResistance( ResistanceType.Energy, 50, 68 );

			SetSkill( SkillName.MagicResist, 101.2, 119.6 );
			SetSkill( SkillName.Magery, 97.5, 98.5 );
			SetSkill( SkillName.Spellweaving, 102.3, 118.5 );
			SetSkill( SkillName.EvalInt, 102.3, 118.5 );
			SetSkill( SkillName.Anatomy, 100.1, 117.5 );
			SetSkill( SkillName.Tactics, 102.3, 118.5 );
			SetSkill( SkillName.Wrestling, 120.1, 150.0 );

			Fame = 19500;
			Karma = -19500;

			VirtualArmor = 75;
		}

		public override bool OnBeforeDeath()
		{
			for ( int j = 0; j < 6; j++ )
			{
				PackItem(RandomMResources.Generate());	
			}
			
			for (int i = 0; i < Utility.RandomMinMax(1, 2); i++)
			{
				PackItem( new PetParrotStatue (Utility.RandomList(41, 495, 567, 48, 131, 75, 1001, 1169, 1155, 1164, 1160, 1162, 2210, 1324, 1157, 1364, 1156, 2101))); //Common hues/reward
			}
			
			if (0.15 >= Utility.RandomDouble())
				PackItem( new PetParrotStatue (Utility.RandomList(1281, 1158, 1266, 1150, 1167, 1109, 33, 1420, 1644, 1359))); //Uncommon 
			else if (0.05 >= Utility.RandomDouble())
				PackItem( new PetParrotStatue (Utility.RandomList(1166, 1165, 1172, 1168, 1175, 1152, 1161, 1151, 1154, 1153, 0, 1177)));//Rare reward hues

			switch ( Utility.Random( 75 ))
            {                                   
            	case 14: PackItem( new CrimsonCinture() ); break;
            	case 31: PackItem( new MarkOfTravesty () ); break;     
			}
			
			switch ( Utility.Random( 2 ))
            {                                   
				case 1: PackItem( new TravestyShells () ); break;         	
			}
			
			switch ( Utility.Random( 4 ))
            {                                   
				case 3: PackItem( new TeakwoodTray () ); break;
			}
			
			switch ( Utility.Random( 7 ))
            {                                   
				case 4: PackItem( new TragicRemains() ); break;
			}
			
			switch ( Utility.Random( 7 ))
            {              
				case 5: PackItem( new TravestySushi() ); break;		      	
			}
			
			switch ( Utility.Random( 17 ))
            {              
				case 5: PackItem( new ImprisonedDogCrystal() ); break;		      	
			}
			
			switch ( Utility.Random( 32 ))
            {                                   
            	case 0: PackItem( new PlateOfHonorArms() ); break;
            	case 1: PackItem( new PlateOfHonorChest() ); break;
				case 2: PackItem( new PlateOfHonorGloves () ); break;
            	case 3: PackItem( new PlateOfHonorGorget () ); break;       
				case 4: PackItem( new PlateOfHonorHelm () ); break;		
				case 5: PackItem( new PlateOfHonorLegs () ); break;		
				case 6: PackItem( new AcolyteArms() ); break;
            	case 7: PackItem( new AcolyteChest() ); break;
				case 8: PackItem( new AcolyteGloves () ); break;	
				case 9: PackItem( new AcolyteLegs () ); break;	
				case 10: PackItem( new EvocaricusSword() ); break;
            	case 11: PackItem( new MalekisHonor() ); break;
				case 12: PackItem( new GrizzleArms() ); break;
            	case 13: PackItem( new GrizzleChest() ); break;
				case 14: PackItem( new GrizzleGloves () ); break;       
				case 15: PackItem( new GrizzleHelm () ); break;		
				case 16: PackItem( new PlateOfHonorLegs () ); break;
				case 17: PackItem( new MageArmorArms() ); break;
            	case 18: PackItem( new MageArmorChest() ); break;
				case 19: PackItem( new MageArmorGloves () ); break;	
				case 20: PackItem( new MageArmorLegs () ); break;                    
				case 21: PackItem( new MyrmidonArms() ); break;
            	case 22: PackItem( new MyrmidonChest() ); break;
				case 23: PackItem( new MyrmidonGloves () ); break;
            	case 24: PackItem( new MyrmidonGorget () ); break;       
				case 25: PackItem( new MyrmidonHelm () ); break;		
				case 26: PackItem( new MyrmidonLegs () ); break;		
				case 27: PackItem( new DeathEssenceArms() ); break;
            	case 28: PackItem( new DeathEssenceChest() ); break;
				case 29: PackItem( new DeathEssenceGloves () ); break;      
				case 30: PackItem( new DeathEssenceHelm () ); break;		
				case 31: PackItem( new DeathEssenceLegs () ); break;		
			}
			
			for ( int k = 0; k < Utility.RandomMinMax( 1, 3 ); k++ )
			{
				PackItem(new RandomTalisman());
			}
			
			if (0.4 >= Utility.RandomDouble()) 
			{
				switch (Utility.RandomMinMax(0, 2 ))
				{
					case 0: PackItem(Loot.RandomMPWeapon(90,110, 0));break;
					case 1: PackItem(Loot.RandomMPWeapon(90,110, 1));break;
					case 2: PackItem(Loot.RandomMPWeapon(90,110, 2));break;      		
				}
			}
				
			if (0.10 >= Utility.RandomDouble()) 
			{
				switch (Utility.RandomMinMax(0, 2 ))
				{
					case 0: PackItem(Loot.RandomMPWeapon(110,130, 0));break;
					case 1: PackItem(Loot.RandomMPWeapon(110,130, 1));break;
					case 2: PackItem(Loot.RandomMPWeapon(110,130, 2));break;      		
				}
			}
			
			if (0.05 >= Utility.RandomDouble())
			{
				switch (Utility.RandomMinMax(0, 2 ))
				{
					case 0: PackItem(Loot.RandomMPWeapon(130,150, 0));break;
					case 1: PackItem(Loot.RandomMPWeapon(130,150, 1));break;
					case 2: PackItem(Loot.RandomMPWeapon(130,150, 2));break;      		
				}
			}
			
			if (0.8 >= Utility.RandomDouble()) PackItem( new EyeOfTheTravesty(1) );	
			
			if (Map == Map.Felucca)
				amount = 12;
			else
				amount = 8;

			for (int n = 0; n < amount; n++)
			{
				switch (Utility.RandomMinMax(0, 5 ))
				{
					case 0: PackItem( new Taint(1));break;
					case 1: PackItem( new Muculent(1));break;
					case 2: PackItem( new Corruption(1));break;      		
					case 3: PackItem( new Blight (1));break;
					case 4: PackItem( new Scourge(1));break;
					case 5: PackItem( new Putrefaction(1));break;
				}
			}
			
			 for(int i=Utility.Random(4);i>0;i--)PackItem(RandomRecipe.Peerless());

		return base.OnBeforeDeath();
		}
		
		
		public override void GenerateLoot()
		{
			AddLoot( LootPack.AosUltraRich, 2 );
			AddLoot( LootPack.AosSuperBoss, 2);
			AddLoot( LootPack.FilthyRich, 3 );
		}
		
		
		public override void OnThink()
		{
		
			Mobile spawn;
		
			if (this.Hits <= 20000 && spawntype == 0)
			{
				spawntype += 1;
				this.Say( 1075121 );
				
				for(int i=0;i<6;i++)
				{
				spawn = new EliteNinja();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}

			}	
			else if (this.Hits <= 10000 && spawntype == 1)
			{
				spawntype += 1;
				this.Say( 1075121 );

				for(int i=0;i<4;i++)
				{
				spawn = new BlackOrderAssasin();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}
				
			}
			else if (this.Hits <= 5000 && spawntype == 2)
			{
				spawntype += 1;
				this.Say( 1075121 );
				
				for(int i=0;i<4;i++)
				{
				spawn = new BlackOrderThief();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}				


			}
			else if (this.Hits <= 2000 && spawntype == 3)
			{
				spawntype += 1;
				this.Say( 1075121 );
				
				
				for(int i=0;i<4;i++)
				{
				spawn = new BlackOrderMage();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}	

			}
			
			base.OnThink();		
		}
		
		public override void ResetSkills(bool dobaseskills)
		{
		base.ResetSkills(false);
	
			SetSkill( SkillName.MagicResist, 101.2, 119.6 );
			SetSkill( SkillName.Anatomy, 100.1, 117.5 );
			SetSkill( SkillName.Tactics, 102.3, 118.5 );
			SetSkill( SkillName.Wrestling, 120.1, 150.0 );				
		}		
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
			if (attacker!=null && this.Hits == this.HitsMax && !attacker.InRange( this, 2 ))
			{
				this.Combatant = attacker;
				this.Location = attacker.Location; 
				this.FixedParticles( 0x376A, 9, 32, 0x13AF, EffectLayer.Waist );
				attacker.PlaySound( 0x1FE );
			}
			
			base.OnDamage(amount, attacker, willKill);	
		}	

		public override void OnDamagedBySpell( Mobile from )
		{
	
		base.OnDamagedBySpell( from );
		}

		public override bool AutoDispel{ get{ return true; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override Poison PoisonImmune{ get{ return Poison.Deadly; } }
		public override bool IsMLCreature { get { return true;} }
		public override bool IsMLBoss { get { return true;} }
		public override int ArcaneLevel{ get{ return 6; } }
		public override double TargetTamerChance { get { return 0.45; }}
		public override bool NoFlee { get { return true; } }		
 

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

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
			writer.Write(spawntype);
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			spawntype = reader.ReadInt();
		}
	}
}