context: using System;
  using System.Text;
  using System.Collections;
  using DOL.GS.Effects;
  using DOL.GS.PacketHandler;
  using System.Reflection;
  using DOL.AI.Brain;
  using DOL.Events;
  
  namespace DOL.GS.Spells
  {
      //http://www.camelotherald.com/masterlevels/ma.php?ml=Banelord
      //shared timer 1
      #region Banelord-1
      [SpellHandlerAttribute("CastingSpeedDebuff")]
      public class CastingSpeedDebuff : MasterlevelDebuffHandling
      {
          public override eProperty Property1 { get { return eProperty.CastingSpeed; } }
  		
  		public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
  		{
  			base.ApplyEffectOnTarget(target, effectiveness);
  			target.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster);
  		}
  
          // constructor
          public CastingSpeedDebuff(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { }
      }
      #endregion
  
      //shared timer 5 for ml2 - shared timer 3 for ml8
      #region Banelord-2/8
      [SpellHandlerAttribute("PBAEDamage")]
      public class PBAEDamage : MasterlevelHandling
      {
          // constructor
          public PBAEDamage(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { }
  
          public override void FinishSpellCast(GameLiving target)
          {
              m_caster.Mana -= PowerCost(target);
              //For Banelord ML 8, it drains Life from the Caster
              if (Spell.Damage > 0)
              {
                  int chealth;
                  chealth = (m_caster.Health * (int)Spell.Damage) / 100;
  
                  if (m_caster.Health < chealth)
                      chealth = 0;
  
                  m_caster.Health -= chealth;
              }
              base.FinishSpellCast(target);
          }
  
          public override void OnDirectEffect(GameLiving target, double effectiveness)
          {
              if (!target.IsAlive || target.ObjectState != GameLiving.eObjectState.Active) return;
  
              GamePlayer player = target as GamePlayer;
              if (target is GamePlayer)
              {
                  int mana;
                  int health;
                  int end;
  
                  int value = (int)Spell.Value;
                  mana = (player.Mana * value) / 100;
                  end = (player.Endurance * value) / 100;
                  health = (player.Health * value) / 100;
  
                  //You don't gain RPs from this Spell
                  if (player.Health < health)
                      player.Health = 1;
                  else
                      player.Health -= health;
  
                  if (player.Mana < mana)
                      player.Mana = 1;
                  else
                      player.Mana -= mana;
  
                  if (player.Endurance < end)
                      player.Endurance = 1;
                  else
                      player.Endurance -= end;
  
                  GameSpellEffect effect2 = SpellHandler.FindEffectOnTarget(target, "Mesmerize");
                  if (effect2 != null)
                  {
                      effect2.Cancel(true);
                      return;
                  }
                  foreach (GamePlayer ply in player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                  {
                      SendEffectAnimation(player, 0, false, 1);
                  }
                  player.StartInterruptTimer(target.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster);
              }
          }
  
          public override int CalculateSpellResistChance(GameLiving target)
          {
              return 25;
          }
      }
      #endregion
  
      //shared timer 3
      #region Banelord-3
      [SpellHandlerAttribute("Oppression")]
      public class OppressionSpellHandler : MasterlevelHandling
      {
          public override bool IsOverwritable(GameSpellEffect compare)
          {
              return true;
          }
          public override void FinishSpellCast(GameLiving target)
          {
              m_caster.Mana -= PowerCost(target);
              base.FinishSpellCast(target);
          }
          public override int CalculateSpellResistChance(GameLiving target)
          {
              return 0;
          }
          public override void OnEffectStart(GameSpellEffect effect)
          {
              base.OnEffectStart(effect);
              if (effect.Owner is GamePlayer)
                  ((GamePlayer)effect.Owner).UpdateEncumberance();
  			effect.Owner.StartInterruptTimer(effect.Owner.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster);
          }
  
          public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
          {
              GameSpellEffect mezz = SpellHandler.FindEffectOnTarget(target, "Mesmerize");
              if (mezz != null)
                  mezz.Cancel(false);
              base.ApplyEffectOnTarget(target, effectiveness);
          }
  
          public override int OnEffectExpires(GameSpellEffect effect, bool noMessages)
          {
              if (effect.Owner is GamePlayer)
                  ((GamePlayer)effect.Owner).UpdateEncumberance();
              return base.OnEffectExpires(effect, noMessages);
          }
          public OppressionSpellHandler(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { }
      }
      #endregion
  
      //shared timer 1
      #region Banelord-4
      [SpellHandler("MLFatDebuff")]
      public class MLFatDebuffHandler : MasterlevelDebuffHandling
      {
          public override eProperty Property1 { get { return eProperty.FatigueConsumption; } }	
  
          public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
          {
              GameSpellEffect effect2 = SpellHandler.FindEffectOnTarget(target, "Mesmerize");
              if (effect2 != null)
              {
                  effect2.Cancel(false);
                  return;
              }
              base.ApplyEffectOnTarget(target, effectiveness);
          }
  
          public override void OnEffectStart(GameSpellEffect effect)
          {
  			effect.Owner.StartInterruptTimer(effect.Owner.SpellInterruptDuration, AttackData.eAttackType.Spell, Caster);
              base.OnEffectStart(effect);
          }
  
          public override int CalculateSpellResistChance(GameLiving target)
          {
              return 0;
          }
  
          // constructor
          public MLFatDebuffHandler(GameLiving caster, Spell spell, SpellLine spellLine) : base(caster, spell, spellLine) { }
      }
      #endregion
  
      //shared timer 5
      #region Banelord-5
      [SpellHandlerAttribute("MissHit")]
      public class MissHit : MasterlevelBuffHandling
      {
          public override eProperty Property1 { get { return eProperty.MissHit; } }
  
          // constructor
          public MissHit(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { }
      }
      #endregion
  
      //shared timer 1
      #region Banelord-6
      #region ML6Snare
      [SpellHandler("MLUnbreakableSnare")]
      public class MLUnbreakableSnare : BanelordSnare
      {
          protected override int CalculateEffectDuration(GameLiving target, double effectiveness)
          {
              int duration = Spell.Duration;
              if (duration < 1)
                  duration = 1;
  
gt:             else if (duration > (Spell.Duration * 4))