context: using System;
  using System.Collections;
  using Server.Items;
  
  namespace Server.Mobiles
  {
      [CorpseName("a meer's corpse")]
      public class MeerEternal : BaseCreature
      {
          private DateTime m_NextAbilityTime;
          [Constructable]
          public MeerEternal()
              : base(AIType.AI_Spellweaving, FightMode.Aggressor, 10, 1, 0.2, 0.4)
          {
              this.Name = "a meer eternal";
              this.Body = 772;
  
              this.SetStr(416, 505);
              this.SetDex(146, 165);
              this.SetInt(566, 655);
  
              this.SetHits(250, 303);
  
              this.SetDamage(11, 13);
  
              this.SetDamageType(ResistanceType.Physical, 100);
  
              this.SetResistance(ResistanceType.Physical, 45, 55);
              this.SetResistance(ResistanceType.Fire, 15, 25);
              this.SetResistance(ResistanceType.Cold, 45, 55);
              this.SetResistance(ResistanceType.Poison, 30, 40);
              this.SetResistance(ResistanceType.Energy, 30, 40);
  
              this.SetSkill(SkillName.EvalInt, 90.1, 100.0);
              this.SetSkill(SkillName.Magery, 90.1, 100.0);
              this.SetSkill(SkillName.Meditation, 90.1, 100.0);
              this.SetSkill(SkillName.MagicResist, 150.5, 200.0);
              this.SetSkill(SkillName.Tactics, 50.1, 70.0);
              this.SetSkill(SkillName.Wrestling, 60.1, 80.0);
              this.SetSkill(SkillName.Spellweaving, 90.1, 100.0);
  
              this.Fame = 18000;
              this.Karma = 18000;
  
              this.VirtualArmor = 34;
  
  			switch (Utility.Random(12))
              {
                  case 0: PackItem(new StrangleScroll()); break;
                  case 1: PackItem(new WitherScroll()); break;
                  case 2: PackItem(new VampiricEmbraceScroll()); break;
  			}
  
              this.m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5));
          }
  
          public MeerEternal(Serial serial)
              : base(serial)
          {
          }
  
          public override bool AutoDispel
          {
              get
              {
                  return true;
              }
          }
          public override bool BardImmune
          {
              get
              {
                  return !Core.AOS;
              }
          }
          public override bool CanRummageCorpses
          {
              get
              {
                  return true;
              }
          }
          public override Poison PoisonImmune
          {
              get
              {
                  return Poison.Lethal;
              }
          }
          public override int TreasureMapLevel
          {
              get
              {
                  return Core.AOS ? 5 : 4;
              }
          }
          public override bool InitialInnocent
          {
              get
              {
                  return true;
              }
          }
          public override void GenerateLoot()
          {
              this.AddLoot(LootPack.FilthyRich, 2);
              this.AddLoot(LootPack.MedScrolls, 2);
              this.AddLoot(LootPack.HighScrolls, 2);
          }
  
          public override int GetHurtSound()
          {
              return 0x167;
          }
  
          public override int GetDeathSound()
          {
              return 0xBC;
          }
  
          public override int GetAttackSound()
          {
              return 0x28B;
          }
  
          public override void OnThink()
          {
              if (DateTime.UtcNow >= this.m_NextAbilityTime)
              {
                  Mobile combatant = this.Combatant as Mobile;
  
                  if (combatant != null && combatant.Map == this.Map && combatant.InRange(this, 12))
                  {
                      this.m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(10, 15));
  
                      int ability = Utility.Random(4);
  
                      switch ( ability )
                      {
                          case 0:
                              this.DoFocusedLeech(combatant, "Thine essence will fill my withering body with strength!");
                              break;
                          case 1:
                              this.DoFocusedLeech(combatant, "I rebuke thee, worm, and cleanse thy vile spirit of its tainted blood!");
                              break;
                          case 2:
                              this.DoFocusedLeech(combatant, "I devour your life's essence to strengthen my resolve!");
                              break;
                          case 3:
                              this.DoAreaLeech();
                              break;
                      // TODO: Resurrect ability
                      }
                  }
              }
  
              base.OnThink();
          }
  
          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();
          }
  
          private void DoAreaLeech()
          {
              this.m_NextAbilityTime += TimeSpan.FromSeconds(2.5);
  
              this.Say(true, "Beware, mortals!  You have provoked my wrath!");
              this.FixedParticles(0x376A, 10, 10, 9537, 33, 0, EffectLayer.Waist);
  
              Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(DoAreaLeech_Finish));
          }
  
          private void DoAreaLeech_Finish()
          {
              ArrayList list = new ArrayList();
              IPooledEnumerable eable = GetMobilesInRange(6);
  
              foreach (Mobile m in eable)
              {
                  if (this.CanBeHarmful(m) && this.IsEnemy(m))
                      list.Add(m);
              }
              eable.Free();
  
              if (list.Count == 0)
              {
                  this.Say(true, "Bah! You have escaped my grasp this time, mortal!");
              }
              else
              {
                  double scalar;
  
  
gt:                 if (list.Count == 1)