/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:15pm
Filepath: scripts\events and scenarios\Thanksgiving 2011\GiantTurkey.cs
Lines of code: 173

Description: 

***********************************************************/


using System; 
using Server;
using Server.Items;
using Server.Targeting;
using Server.Network;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Server.Mobiles
{
	[CorpseName( "the remains of one foul bird" )]
	public class GiantTurkey : BaseCreature
	{
	
	
		public override WeaponAbility GetWeaponAbility()
		{
			return WeaponAbility.DoubleStrike;
		}
	
		public int HitTimes = 0; 
		
		public static void GiveReward(Mobile boss)
		{
			ArrayList toGive = new ArrayList();
			List<DamageStore> rights = BaseCreature.GetLootingRights( boss.DamageEntries, boss.HitsMax );

			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];
				if ( ds.m_HasRight )	toGive.Add( ds.m_Mobile );
			}
			if ( rights.Count == 0 )return;	
			
			for(int i=0;i<rights.Count;i++)
			{
				Mobile m = rights[i].m_Mobile;			
				PlayerMobile pm = m as PlayerMobile;	
	
				Item gift = new BlackToadstool();	
						
				if(0.9 >= Utility.RandomDouble())
				{
					if(0.70 >= Utility.RandomDouble()) 
					{
						gift = new BronzeToken();	
						m.SendMessage(200,"You receive a gift: Bronze Roulette Token");
					}
					else if (0.10 >= Utility.RandomDouble()) 
					{
						gift = new SilverToken();
						m.SendMessage(200,"You receive a gift: Silver Roulette Token");
					}
					else if (0.10 >= Utility.RandomDouble()) 
					{
						gift = new GoldToken();
						m.SendMessage(200,"You receive a gift: Gold Roulette Token");
					}
					else if (0.10 >= Utility.RandomDouble())
					{
						gift = new PlatinumToken();
						m.SendMessage(200,"You receive a gift: Platinum Roulette Token");
					}
					else
					{
						gift = new BronzeToken();	
						m.SendMessage(200,"You receive a gift: Bronze Roulette Token");
					}
					m.GiveItem(gift);			
				}
				else 
				{
					gift = new HornOfPlenty();	
					m.SendMessage(200,"You receive a gift: Horn Of Plenty");
					m.GiveItem(gift);				
				}
			}
		}	

		public override void OnDeath( Container c )
		{
			base.OnDeath( c );
			GiveReward(this);	
		}

		[Constructable]
		public GiantTurkey() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.15, 0.18 )
		{
		
			Name = "a giant turkey";
		    Body = 1026;
			BaseSoundID = 402;
			
			SetStr( 800, 830 );  
			SetDex( 1000, 1200 );
			SetInt( 100, 120 );

			SetHits( 2500, 3500 );
			SetMana( 100, 130 );

			SetDamage( 11, 16 );

			SetDamageType( ResistanceType.Physical, 20 );
			SetDamageType( ResistanceType.Fire, 20 );
			SetDamageType( ResistanceType.Cold, 20 );
			SetDamageType( ResistanceType.Poison, 20 );
			SetDamageType( ResistanceType.Energy, 20 );
			
			
			SetResistance( ResistanceType.Physical, 70, 80);
			SetResistance( ResistanceType.Fire, 70, 80 );
			SetResistance( ResistanceType.Cold, 60, 70 );
			SetResistance( ResistanceType.Poison, 25, 40 );
			SetResistance( ResistanceType.Energy, 25, 40 );
			
			SetSkill( SkillName.MagicResist, 80,90);
			SetSkill( SkillName.Tactics, 100,110);
			SetSkill( SkillName.Anatomy, 70,80);		
			SetSkill( SkillName.Wrestling, 120,160);
			

			Fame = 50000;
			Karma = -50000;

			VirtualArmor = 18;	
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Rich, 7 );
			AddLoot( LootPack.SuperBoss, 5 );		
		}
		
		public override bool ReacquireOnMovement{ get{ return true; } }
		
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool CantbeSupreme { get { return true;} }
		public override bool CantbeParagon { get { return true;} }	
		public override bool NoFlee { get { return true; } }	
		
		public override bool IsMLBoss { get { return true;} }		

		public GiantTurkey(Serial serial) : base(serial)
		{
		}
		
		/*public override void OnGaveMeleeAttack( Mobile defender )
		{	
			if ( 0.02 > Utility.RandomDouble() )
			{
				Random rand = new Random();
				HitTimes = rand.Next( 2, 7 );
			
				for (int i = 0; i < HitTimes; i++)
				{
					AOS.Damage( defender, this, 5, true, 100, 0, 0, 0, 0 );
				}
				defender.SendMessage("The turkey claws at you, hitting you " + HitTimes + " times");
			}
	
		base.OnGaveMeleeAttack( defender );
		}*/
		
		public override void OnGotMeleeAttack( Mobile attacker )
		{
			/*if (!attacker.InRange( this, 1 ))
			{
				if ( 0.02 > Utility.RandomDouble() )
				{
					Random rand = new Random();
					HitTimes = rand.Next( 2, 7 );
			
					for (int i = 0; i < HitTimes; i++)
					{
						this.MovingParticles( attacker, 0x36D4, 7, 0, false, true, 1868, 3, 9502, 4019, 0x47E, 0x100 );
						AOS.Damage( attacker, this, 5, true, 0, 100, 0, 0, 0 );
					}
					attacker.SendMessage("The turkey launches hot gravy at you, hitting you " + HitTimes + " times");
				}
			}*/
			
			if (this.InLOS( attacker ) && !attacker.InRange( this, 5 ) && attacker.Alive && !attacker.Blessed && 0.05 >= Utility.RandomDouble()) {
				this.Location = attacker.Location; 
				this.PlaySound( 0x63E );
				this.Combatant = attacker;
				attacker.SendMessage( "The giant turkey angrily flies to your location!" );
			}
	
		base.OnGotMeleeAttack( attacker );
		}
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
			if(attacker!=null && attacker is BaseCreature && 0.1 >= Utility.RandomDouble())
			{
				if(((BaseCreature)attacker).ControlMaster!=null)
				{
					Combatant=((BaseCreature)attacker).ControlMaster;
				}
				else if(((BaseCreature)attacker).SummonMaster!=null)
				{
					Combatant=((BaseCreature)attacker).SummonMaster;
				}
			}	
			
			if (!this.InLOS( attacker ) && attacker.InRange( this, 12 ) && attacker.Alive && !attacker.Blessed && 0.5 >= Utility.RandomDouble()) {
				attacker.Location = this.Location; 
				this.PlaySound( 0x63E );
				this.Combatant = attacker;
				attacker.SendMessage( "The giant turkey summons you to its location!" );
			}
				
			base.OnDamage(amount, attacker, willKill );			
		}
		
		public override void OnDamagedBySpell(Mobile attacker)
		{
			/*if (!attacker.InRange( this, 2 ))
			{
				if ( 0.05 > Utility.RandomDouble() )
				{
					Random rand = new Random();
					HitTimes = rand.Next( 2, 7 );
			
					for (int i = 0; i < HitTimes; i++)
					{
						this.MovingParticles( attacker, 0x36D4, 7, 0, false, true, 1868, 3, 9502, 4019, 0x47E, 0x100 );
						AOS.Damage( attacker, this, 5, true, 0, 100, 0, 0, 0 );
					}
					attacker.SendMessage("The turkey launches hot gravy at you, hitting you " + HitTimes + " times");
				}
			}*/
			
			if (this.InLOS( attacker ) && !attacker.InRange( this, 5 ) && attacker.Alive && !attacker.Blessed && 0.01 >= Utility.RandomDouble()) {
				this.Location = attacker.Location; 
				this.PlaySound( 0x63E );
				this.Combatant = attacker;
				attacker.SendMessage( "The giant turkey angrily flies to your location!" );
			}
			
		base.OnDamagedBySpell( attacker );
		}
		

		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();
		}
	}
}