using System;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Misc;
using Server.Spells;
using Server.Targeting;
namespace Server.Mobiles
{
    [CorpseName("an orcish corpse")]
    public class OrcGeneral : BaseCreature
    {
        [Constructable]
        public OrcGeneral()
            : base(AIType.AI_OrcScout, FightMode.Closest, 10, 7, 0.2, 0.4)
        {
            Name = "an orc general";
            this.Body = 0xB5;
            this.Hue = 2221;
            this.BaseSoundID = 0x45A;
            this.SetStr(986, 1185);
            this.SetDex(177, 255);
            this.SetInt(151, 250);
            this.SetHits(592, 711);
            this.SetDamage(22, 29);
            this.SetDamageType(ResistanceType.Physical, 50);
            this.SetDamageType(ResistanceType.Fire, 25);
            this.SetDamageType(ResistanceType.Energy, 25);
            this.SetResistance(ResistanceType.Physical, 65, 80);
            this.SetResistance(ResistanceType.Fire, 60, 80);
            this.SetResistance(ResistanceType.Cold, 50, 60);
            this.SetResistance(ResistanceType.Poison, 100);
            this.SetResistance(ResistanceType.Energy, 40, 50);
            this.SetSkill(SkillName.Anatomy, 25.1, 50.0);
            this.SetSkill(SkillName.EvalInt, 90.1, 100.0);
            this.SetSkill(SkillName.Magery, 95.5, 100.0);
            this.SetSkill(SkillName.Meditation, 25.1, 50.0);
            this.SetSkill(SkillName.MagicResist, 100.5, 150.0);
            this.SetSkill(SkillName.Tactics, 90.1, 100.0);
            this.SetSkill(SkillName.Wrestling, 90.1, 100.0);
            this.Fame = 24000;
            this.Karma = -24000;
            this.VirtualArmor = 90;
            PackItem(new Apple(Utility.RandomMinMax(3, 5)));
            PackItem(new Arrow(Utility.RandomMinMax(60, 70)));
            PackItem(new Bandage(Utility.RandomMinMax(1, 15)));
        }
        public OrcGeneral(Serial serial)
            : base(serial)
        { }
        public override InhumanSpeech SpeechType { get { return InhumanSpeech.Orc; } }
        public override OppositionGroup OppositionGroup { get { return OppositionGroup.SavagesAndOrcs; } }
        public override bool CanHeal { get { return true; } }
        public override bool CanRummageCorpses { get { return true; } }
        public override int Meat { get { return 1; } }
        public override int TreasureMapLevel
        {
            get
            {
                return 5;
            }
        }
        public override void GenerateLoot()
        {
            this.AddLoot(LootPack.FilthyRich, 2);
            this.AddLoot(LootPack.Rich);
        }
        public override void OnDeath(Container c)
        {
            base.OnDeath(c);
            if (Utility.RandomDouble() < 0.15)
               c.DropItem( new SpikeHead(Combatant.Name) );
            if (Utility.RandomDouble() < 0.25)
                c.DropItem(new MaulOfOrigin());
        }
        public override bool IsEnemy(Mobile m)
        {
            if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask)
            {
                return false;
            }
            return base.IsEnemy(m);
        }
        public override void AggressiveAction(Mobile aggressor, bool criminal)
        {
            base.AggressiveAction(aggressor, criminal);
            Item item = aggressor.FindItemOnLayer(Layer.Helm);
            if (item is OrcishKinMask)
            {
                AOS.Damage(aggressor, 50, 0, 100, 0, 0, 0);
                item.Delete();
                aggressor.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head);
                aggressor.PlaySound(0x307);
            }
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
        private Mobile FindTarget()
        {
            foreach (Mobile m in GetMobilesInRange(10))
            {
                if (m.Player && m.Hidden && m.IsPlayer())
                {
                    return m;
                }
            }
            return null;
        }
        private void TryToDetectHidden()
        {
            Mobile m = FindTarget();
            if (m != null)
            {
                if (Core.TickCount >= NextSkillTime && UseSkill(SkillName.DetectHidden))
                {
                    Target targ = Target;
                    if (targ != null)
                    {
                        targ.Invoke(this, this);
                    }
                    Effects.PlaySound(Location, Map, 0x340);
                }
            }
        }
    }
}