/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\Mobiles\Animals\Misc\Boar.cs
Lines of code: 89
***********************************************************/


using System;
using Server.Mobiles;

namespace Server.Mobiles
{
	[CorpseName( "a pig corpse" )]
	public class Boar : BaseCreature
	{
	private bool IsMad=false;
	
		[Constructable]
		public Boar() : base( AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4 )
		{
		//has a chance of being totally mad and do insane damage
			int StatMultiplyer=1;
			if(0.004>Utility.RandomDouble())
			{
			StatMultiplyer=100;
			IsMad=true;
			}
		
		
			Name = "a boar";
			Body = 0x122;
			BaseSoundID = 0xC4;

			SetStr( 25 * StatMultiplyer );
			SetDex( 15 * StatMultiplyer);
			SetInt( 5 * StatMultiplyer);

			SetHits( 15 );
			SetMana( 0 );

			SetDamage( 3 * StatMultiplyer, 6 * StatMultiplyer );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 10, 15 + (StatMultiplyer/2) );
			SetResistance( ResistanceType.Fire, 5, 10 + (StatMultiplyer/2));
			SetResistance( ResistanceType.Poison, 5, 10 + (StatMultiplyer/2));

			SetSkill( SkillName.MagicResist, 9.0 + (StatMultiplyer));
			SetSkill( SkillName.Tactics, 9.0 + (StatMultiplyer));
			SetSkill( SkillName.Wrestling, 9.0 + (StatMultiplyer));

			Fame = 300 + ((StatMultiplyer-1)*50);
			Karma = 0 - ((StatMultiplyer-1)*50);;

			VirtualArmor = 10;

			if(IsMad)
			{
			Tamable = true;
			ControlSlots = 5;
			MinTameSkill = 119.9;			
			}
			else
			{
			Tamable = true;
			ControlSlots = 1;
			MinTameSkill = 29.1;
			}
			
		}

		public override int Meat{ get{ return 2; } }
		public override FoodType FavoriteFood{ get{ return FoodType.FruitsAndVegies | FoodType.GrainsAndHay; } }
		
		
		public override void OnThink()
		{
		base.OnThink();
		
		if(!IsMad)return;
		//auto target anyone with less than 10hp
		
					

		if ( this.Map != null)
		{
			IPooledEnumerable eable = this.Map.GetMobilesInRange( new Point3D( this), 50 );

			foreach ( Mobile m in eable )
			{
				if (m == this)
					continue;
					
				if(m is PlayerMobile && m.Hits<=25 && m.AccessLevel==AccessLevel.Player)
				{
				CurrentSpeed=0.08;
				this.Combatant=m;
				break;
				}
					
			}

			eable.Free();
		}


		}
		

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

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

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