context: using System;
  using System.Collections.Generic;
  using Server;
  using Server.Items;
  namespace Server.Mobiles
  {
  	[CorpseName("a raptor corpse")]
  	public class Raptor : BaseCreature
  	{
  		private const int MaxFriends = 2;
  
  		private bool m_IsFriend;
  		private List<Mobile> m_Friends = new List<Mobile>();
  		private InternalTimer m_FriendsTimer;
  
  		[Constructable]
  		public Raptor()
  			: this(false)
  		{
  		}
  
  		[Constructable]
  		public Raptor(bool isFriend)
  			: base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.175, 0.350)
  		{
  			m_IsFriend = isFriend;
  
  			Name = "a raptor";
  			Body = 730;
  
  			SetStr(404, 471);
  			SetDex(132, 155);
  			SetInt(105, 145);
  
  			SetHits(343, 400);
  
  			SetDamage(11, 17);
  
  			SetDamageType(ResistanceType.Physical, 100);
  
  			SetResistance(ResistanceType.Physical, 45, 50);
  			SetResistance(ResistanceType.Fire, 50, 60);
  			SetResistance(ResistanceType.Cold, 40, 50);
  			SetResistance(ResistanceType.Poison, 20, 30);
  			SetResistance(ResistanceType.Energy, 30, 40);
  
  			SetSkill(SkillName.MagicResist, 75.1, 90.0);
  			SetSkill(SkillName.Tactics, 75.1, 100.0);
  			SetSkill(SkillName.Wrestling, 70.1, 95.1);
  
  			Fame = 7500;
  			Karma = -7500;
  			QLPoints = 20;
  			Tamable = !isFriend;
  			MinTameSkill = 107.1;
  			ControlSlots = 2;
  		}
  
  		public override int Meat
  		{
  			get { return 7; }
  		}
  
  		public override int Hides
  		{
  			get { return 11; }
  		}
  
  		public override HideType HideType
  		{
  			get { return HideType.Horned; }
  		}
  
  		public override PackInstinct PackInstinct
  		{
  			get { return PackInstinct.Ostard; }
  		}
  
  		public override WeaponAbility GetWeaponAbility()
  		{
  			return WeaponAbility.BleedAttack;
  		}
  
  		public override void GenerateLoot()
  		{
  			AddLoot(LootPack.Rich, 2);
  		}
  
  		public override int GetIdleSound()
  		{
  			return 1573;
  		}
  
  		public override int GetAngerSound()
  		{
  			return 1570;
  		}
  
  		public override int GetHurtSound()
  		{
  			return 1572;
  		}
  
  		public override int GetDeathSound()
  		{
  			return 1571;
  		}
  
  
  		public override void OnCombatantChange()
  		{
  			if (!m_IsFriend && !Controlled && Combatant != null && m_FriendsTimer == null)
  			{
  				m_FriendsTimer = new InternalTimer(this);
  				m_FriendsTimer.Start();
  			}
  		}
  
  		public void CheckFriends()
  		{
  			if (!Alive || Combatant == null || Controlled || Map == null || Map == Map.Internal)
  			{
  				m_Friends.ForEach(f => f.Delete());
  				m_Friends.Clear();
  
  				m_FriendsTimer.Stop();
  				m_FriendsTimer = null;
  			}
  			else
  			{
  				int count = 0;
  
  				for (int i = 0; i < m_Friends.Count; i++)
  				{
  					// remove dead friends
  
  					Mobile friend = m_Friends[i];
  
  					if (friend == null || friend.Deleted)
  						m_Friends.Remove(friend);
  					else
  						count++;
  				}
  
  				for (int i = count; i < MaxFriends; i++)
  				{
  					// spawn new friends
  
  					BaseCreature friend = new Raptor(true);
  					var loc = Location;
  					var validLocation = false;
  					for (var j = 0; !validLocation && j < 10; ++j)
  					{
  						var x = X + Utility.Random(3) - 1;
  						var y = Y + Utility.Random(3) - 1;
  						var z = Map.GetAverageZ(x, y);
  
  						if (validLocation = Map.CanFit(x, y, Z, 16, false, false))
  							loc = new Point3D(x, y, Z);
  						else if (validLocation = Map.CanFit(x, y, z, 16, false, false))
  							loc = new Point3D(x, y, z);
  					}
  
  					friend.MoveToWorld(loc, Map);
  					friend.Combatant = Combatant;
  
  					if (friend.AIObject != null)
  						friend.AIObject.Action = ActionType.Combat;
  
  					m_Friends.Add(friend);
  				}
  			}
  		}
  
  		public override void OnDeath(Container c)
  		{
  			base.OnDeath(c);
  
  			if (Utility.RandomDouble() < 0.25)
  			{
  				c.DropItem(new AncientPotteryFragments());
  			}
  
  			if (c != null && !c.Deleted && c is Corpse)
  			{
  				var corpse = (Corpse)c;
  				if (Utility.RandomDouble() < 0.01 && corpse.Killer != null && !corpse.Killer.Deleted)
  				{
  					GiveVArtifactTo(corpse.Killer);
  				}
  			}
  		}
  
  		public static void GiveVArtifactTo(Mobile m)
  		{
              var item = new RaptorClaw();
  			m.PlaySound(0x5B4);
  
  			if (m.AddToBackpack(item))
  				m.SendLocalizedMessage(1062317);
  			// For your valor in combating the fallen beast, a special artifact has been bestowed on you.
  			else
  				m.SendMessage("As your backpack is full, your reward has been placed at your feet.");
  			{
  			}
  		}
  
  		public Raptor(Serial serial)
  			: base(serial)
  		{
  		}
  
  		public override void Serialize(GenericWriter writer)
  		{
  			base.Serialize(writer);
  
  			writer.Write((int)1);
  
  			writer.Write((bool)m_IsFriend);
  		}
  
  		public override void Deserialize(GenericReader reader)
  		{
  			base.Deserialize(reader);
  
  			int version = reader.ReadInt();
  
  
gt: 			if (version > 0)