Example #1
0
 private void OnEnemyTargetCast(object sender, TargetCastArgs args)
 {
     try
     {
         if (Menu.Item(Menu.Name + ".shield.enabled").GetValue <bool>() && args.Target.IsMe &&
             ManaManager.Check("shield"))
         {
             if (args.Type == SpellDataTargetType.SelfAoe)
             {
                 E.Cast();
             }
             if (args.Type == SpellDataTargetType.Unit && args.Target != null && args.Target.IsMe)
             {
                 var delay = (int)(Utils.SpellArrivalTime(args.Sender, Player, args.Delay, args.Speed, true)) *
                             1000;
                 var ping = Game.Ping / 2000;
                 if (delay - 200 - ping > 0)
                 {
                     Utility.DelayAction.Add(
                         delay - 100 - ping, delegate
                     {
                         if (E.IsReady())
                         {
                             E.Cast();
                         }
                     });
                 }
                 else if (E.IsReady())
                 {
                     E.Cast();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
 }