/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Feb-01-2009 08:18:27pm
Filepath: scripts\_custom\events and scenarios\super bowl\FootballPlayer.cs
Lines of code: 111
***********************************************************/


using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;

namespace Server.Mobiles
{
	[CorpseName( "a sports injury victim" )]
	public class FootballPlayer : BaseCreature
	{
		public override bool ClickTitle{ get{ return false; } }

		
		[Constructable]
		public FootballPlayer() : this(Utility.RandomBool())
		{
		}			
		
		[Constructable]
		public FootballPlayer(bool red) : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.05, 0.14 )
		{
			SpeechHue = Utility.RandomDyedHue();
			Hue = Utility.RandomSkinHue();
			Name = "a football player";
			Female=false;
			
			Body = 0x190;

			HairItemID = 0;
			
			SetStr( 140, 140 );
			SetDex( 200, 400 );
			SetInt( 10, 40 );

	        SetHits( 100, 100 );
			SetMana( 50, 50 );

			SetDamage( 15, 25 );

			SetDamageType( ResistanceType.Physical, 70 );

			SetResistance( ResistanceType.Physical, 70, 90 );
			SetResistance( ResistanceType.Fire, 40, 50);
			SetResistance( ResistanceType.Cold, 20, 40 );
			SetResistance( ResistanceType.Poison, 30, 50 );
			SetResistance( ResistanceType.Energy, 50, 60  );
			

			
			SetSkill( SkillName.Tactics, 120);
			SetSkill( SkillName.Anatomy, 120 );
			SetSkill( SkillName.Wrestling, 160 );			
			SetSkill( SkillName.Healing, 120);			


			Fame = 7000;
			Karma = -1900;
			
			if(red)Team=2;
			else Team=1;


			PlateHelm helmet = new PlateHelm();
			helmet.Hue = red ? 34 : 105;
			AddItem(helmet);

			PlateGloves gloves = new PlateGloves();
			gloves.Hue = red ? 34 : 105;
			AddItem(gloves);

			PlateArms arms = new PlateArms();
			arms.Hue = red ? 34 : 105;
			AddItem(arms);

			PlateChest chest = new PlateChest();
			chest.Hue = 1150;
			AddItem(chest);

			PlateLegs legs = new PlateLegs();
			legs.Hue = red ? 34 : 105;
			AddItem(legs);

			PlateGorget gorget = new PlateGorget();
			gorget.Hue = 1150;
			AddItem(gorget);
			
			if(0.15>Utility.RandomDouble())PackItem(new FootBall());

		}
		
	
		
		
		DateTime m_lastthink;

		public override void OnThink()
        {	
			if((m_lastthink+TimeSpan.FromSeconds(10))<DateTime.Now)
			{
				if(Utility.Random(70)>HitsPerc || Combatant!=null)
				{
					//consider passing the ball if we have it:
					
					if(this.Backpack!=null && this.Backpack.GetAmount(typeof(FootBall))>0)
					{						
						//we have the ball, find someone to pass it to:
						
						List<Mobile> targets = new List<Mobile>();

						foreach ( Mobile m in this.GetMobilesInRange( 20 ) )
						{
							if ( this != m && this.InLOS( m ) && this.Team==m.Team && (this.Hits<=m.Hits) )
								targets.Add( m );
						}
						
						if(targets.Count>0)
						{
							Item ball = this.Backpack.FindItemByType(typeof(FootBall));							

							if(ball!=null)((FootBall)ball).Throw(this,targets[Utility.Random(targets.Count)]);
						}					
					}				
				}		
		
				m_lastthink=DateTime.Now;
			}	
		
		}
		


		public override void GenerateLoot()
		{
			AddLoot( LootPack.FilthyRich );
			AddLoot( LootPack.Average);
			AddLoot( LootPack.Potions);			
		}

		public override bool BardImmune{ get{ return true; } }
		public override bool ShowFameTitle{ get{ return false; } }

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

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

			writer.Write( (int) 0 ); // version
		}

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

			int version = reader.ReadInt();
		}
	}
}
