context: using EloBuddy; 
  using LeagueSharp.Common; 
  namespace Flowers_Riven
  {
      using FlowersRivenCommon;
      using LeagueSharp;
      using LeagueSharp.Common;
      using System;
      using System.Linq;
      using Color = System.Drawing.Color;
  
      internal class Program
      {
          private static Spell Q, W, E, R;
          private static SpellSlot Ignite = SpellSlot.Unknown, Flash = SpellSlot.Unknown;
          private static Menu Menu;
          private static AIHeroClient Me;
          private static bool canQ;
          private static int qStack;
          private static Orbwalking.Orbwalker Orbwalker;
          private static Obj_AI_Base qTarget;
  
          public static void Main()
          {
              OnLoad(new EventArgs());
          }
  
          private static void OnLoad(EventArgs Args)
          {
              if (ObjectManager.Player.ChampionName != "Riven")
              {
                  return;
              }
  
              Me = ObjectManager.Player;
  
              Q = new Spell(SpellSlot.Q, 325f);
              W = new Spell(SpellSlot.W, 260f);
              E = new Spell(SpellSlot.E, 312f);
              R = new Spell(SpellSlot.R, 900f);
              R.SetSkillshot(0.25f, 45f, 1600f, false, SkillshotType.SkillshotCone);
  
              Ignite = Me.GetSpellSlot("SummonerDot");
              Flash = Me.GetSpellSlot("SummonerFlash");
  
              Menu = new Menu("Flowers' Riven", "Flowers' Riven", true);
  
              var targetMenu = Menu.AddSubMenu(new Menu("Target Selector", "Target Selector"));
              {
                  TargetSelector.AddToMenu(targetMenu);
              }
  
              var orbMenu = Menu.AddSubMenu(new Menu("Orbwalking", "Orbwalking"));
              {
                  Orbwalker = new Orbwalking.Orbwalker(orbMenu);
              }
  
              var comboMenu = Menu.AddSubMenu(new Menu("Combo", "Combo"));
              {
                  comboMenu.AddItem(new MenuItem("ComboW", "Use W", true).SetValue(true));
                  comboMenu.AddItem(new MenuItem("ComboE", "Use E", true).SetValue(true));
                  comboMenu.AddItem(new MenuItem("ComboR", "Use R", true).SetValue(true));
                  comboMenu.AddItem(
                      new MenuItem("R1Combo", "Use R1", true).SetValue(new KeyBind('L', KeyBindType.Toggle, true))).Permashow();
                  comboMenu.AddItem(
                      new MenuItem("R2Mode", "Use R2 Mode: ", true).SetValue(
                          new StringList(new[] { "Killable", "Max Damage", "First Cast", "Off" }, 1)));
                  comboMenu.AddItem(new MenuItem("ComboIgnite", "Use Ignite", true).SetValue(true));
              }
  
              var burstMenu = Menu.AddSubMenu(new Menu("Burst", "Burst"));
              {
                  burstMenu.AddItem(new MenuItem("BurstFlash", "Use Flash", true).SetValue(true));
                  burstMenu.AddItem(new MenuItem("BurstIgnite", "Use Ignite", true).SetValue(true));
                  burstMenu.AddItem(new MenuItem("Note...", "Note: ", true));
                  burstMenu.AddItem(new MenuItem("target...", "Left Cilck the Target", true));
                  burstMenu.AddItem(new MenuItem("range...", "And Target in Burst Range", true));
                  burstMenu.AddItem(new MenuItem("press...", "And then Press the Burst Key", true));
              }
  
              var harassMenu = Menu.AddSubMenu(new Menu("Harass", "Harass"));
              {
                  harassMenu.AddItem(new MenuItem("HarassQ", "Use Q", true).SetValue(true));
                  harassMenu.AddItem(new MenuItem("HarassW", "Use W", true).SetValue(true));
                  harassMenu.AddItem(new MenuItem("HarassE", "Use E", true).SetValue(true));
                  harassMenu.AddItem(
                      new MenuItem("HarassMode", "Harass Mode", true).SetValue(new StringList(new[] {"Smart", "Burst"})));
              }
  
              var clearMenu = Menu.AddSubMenu(new Menu("Clear", "Clear"));
              {
                  var laneClearMenu = clearMenu.AddSubMenu(new Menu("LaneClear", "LaneClear"));
                  {
                      laneClearMenu.AddItem(new MenuItem("LaneClearQ", "Use Q", true).SetValue(true));
                      laneClearMenu.AddItem(new MenuItem("LaneClearW", "Use W", true).SetValue(true));
                  }
  
                  var jungleClearMenu = clearMenu.AddSubMenu(new Menu("JungleClear", "JungleClear"));
                  {
                      jungleClearMenu.AddItem(new MenuItem("JungleClearQ", "Use Q", true).SetValue(true));
                      jungleClearMenu.AddItem(new MenuItem("JungleClearW", "Use W", true).SetValue(true));
                      jungleClearMenu.AddItem(new MenuItem("JungleClearWLogic", "Use W| Smart", true).SetValue(true));
                      jungleClearMenu.AddItem(new MenuItem("JungleClearE", "Use E", true).SetValue(true));
                  }
              }
  
              var killStealMenu = Menu.AddSubMenu(new Menu("KillSteal", "KillSteal"));
              {
                  killStealMenu.AddItem(new MenuItem("KillStealW", "Use W", true).SetValue(true));
                  killStealMenu.AddItem(
                      new MenuItem("KillStealE", "Use E", true).SetValue(true).SetTooltip("E Gapcloser and R2 Kill"));
                  killStealMenu.AddItem(new MenuItem("KillStealR", "Use R", true).SetValue(true));
              }
  
              var miscMenu = Menu.AddSubMenu(new Menu("Misc", "Misc"));
              {
                  var qMenu = miscMenu.AddSubMenu(new Menu("Q Setting", "Q Setting"));
                  {
                      var qDelayMenu = qMenu.AddSubMenu(new Menu("Delay Settings", "Delay Settings"));
                      {
                          qDelayMenu.AddItem(new MenuItem("Q1Delay", "Q1 Delay: ", true).SetValue(new Slider(242, 200, 300)));
                          qDelayMenu.AddItem(new MenuItem("Q2Delay", "Q2 Delay: ", true).SetValue(new Slider(242, 200, 300)));
                          qDelayMenu.AddItem(new MenuItem("Q3Delay", "Q3 Delay: ", true).SetValue(new Slider(342, 300, 400)));
                          qDelayMenu.AddItem(new MenuItem("AutoSetDelay", "Auto Set Q Delay?", true).SetValue(false)).ValueChanged +=
                              DelayChanged;
                      }
  
                      qMenu.AddItem(new MenuItem("KeepQALive", "Keep Q alive", true).SetValue(true));
                      qMenu.AddItem(new MenuItem("Dance", "Dance Emote in QA", true).SetValue(false));
                      qMenu.AddItem(
                          new MenuItem("QMode", "Q Mode : ", true).SetValue(
                              new StringList(new[] {"Target Position", "Mouse", "Max Q To Target", "Max Q To Mouse"})));
                  }
  
                  var wMenu = miscMenu.AddSubMenu(new Menu("W Setting", "W Setting"));
                  {
                      wMenu.AddItem(new MenuItem("AntiGapCloserW", "AntiGapCloser", true).SetValue(true));
                      wMenu.AddItem(new MenuItem("InterruptTargetW", "Interrupt Danger Spell", true).SetValue(true));
                  }
  
                  var eMenu = miscMenu.AddSubMenu(new Menu("E Settings", "E Settings"));
                  {
                      foreach (var target in HeroManager.Enemies)
                      {
                          if (target.ChampionName == "Darius")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Darius", "Darius Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeDariusR", "Shield R", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Garen")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Garen", "Garen Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeGarenQ", "Shield Q", true).SetValue(true));
                                  spellMenu.AddItem(new MenuItem("EDodgeGarenR", "Shield R", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Irelia")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Irelia", "Irelia Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeIreliaE", "Shield E", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "LeeSin")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("LeeSin", "LeeSin Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeLeeSinR", "Shield R", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Olaf")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Olaf", "Olaf Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeOlafE", "Shield E", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Pantheon")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Pantheon", "Pantheon Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgePantheonW", "Shield W", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Renekton")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Renekton", "RenektonW Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeRenektonW", "Shield W", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Rengar")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Rengar", "Rengar Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeRengarQ", "Shield Q", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Veigar")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Veigar", "Veigar Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeVeigarR", "Shield R", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "Volibear")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Volibear", "Volibear Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeVolibearW", "Shield W", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "XenZhao")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("XenZhao", "XenZhao Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeXenZhaoQ3", "Shield Q3", true).SetValue(true));
                              }
                          }
  
                          if (target.ChampionName == "TwistedFate")
                          {
                              var spellMenu = eMenu.AddSubMenu(new Menu("Twisted Fate", "TwistedFate Spell"));
                              {
                                  spellMenu.AddItem(new MenuItem("EDodgeTwistedFateW", "Shield W", true).SetValue(true));
                              }
                          }
                      }
  
                      eMenu.AddItem(new MenuItem("EShielddogde", "Use E Shield Spell", true).SetValue(true));
                  }
  
                  var skinMenu = miscMenu.AddSubMenu(new Menu("SkinChance", "SkinChance"));
                  {
                      SkinManager.AddToMenu(skinMenu, 7);
                  }
              }
  
              var drawMenu = Menu.AddSubMenu(new Menu("Drawings", "Drawings"));
              {
                  drawMenu.AddItem(new MenuItem("DrawW", "Draw W Range", true).SetValue(false));
                  drawMenu.AddItem(new MenuItem("DrawBurst", "Draw Burst Range", true).SetValue(true));
                  drawMenu.AddItem(new MenuItem("DrawRStatus", "Draw R Status", true).SetValue(true));
                  DamageIndicator.AddToMenu(drawMenu, GetComboDamage);
              }
  
              Menu.AddItem(new MenuItem("asdvre1w56", "  "));
              Menu.AddItem(new MenuItem("Credit", "Credit : NightMoon"));
              Menu.AddItem(new MenuItem("Version", "Version : 1.0.0.5"));
  
              Menu.AddToMainMenu();
  
              if (!Menu.Item("AutoSetDelay", true).GetValue<bool>())
              {
                  Menu.Item("Q1Delay", true).SetValue(new Slider(242, 200, 300));
                  Menu.Item("Q2Delay", true).SetValue(new Slider(242, 200, 300));
                  Menu.Item("Q3Delay", true).SetValue(new Slider(342, 300, 400));
              }
  
              Obj_AI_Base.OnProcessSpellCast += OnProcessSpellCast;
              Obj_AI_Base.OnPlayAnimation += OnPlayAnimation;
              AntiGapcloser.OnEnemyGapcloser += OnEnemyGapcloser;
              Interrupter2.OnInterruptableTarget += OnInterruptableTarget;
              Obj_AI_Base.OnSpellCast += OnSpellCast;
              Game.OnUpdate += OnUpdate;
              Drawing.OnDraw += OnDraw;
          }
  
          private static void DelayChanged(object obj, OnValueChangeEventArgs Args)
          {
              if (!Args.GetNewValue<bool>())
              {
                  Menu.Item("Q1Delay", true).SetValue(new Slider(242, 200, 300));
                  Menu.Item("Q2Delay", true).SetValue(new Slider(242, 200, 300));
                  Menu.Item("Q3Delay", true).SetValue(new Slider(342, 300, 400));
              }
          }
  
          private static void OnEnemyGapcloser(ActiveGapcloser Args)
          {
              if (Menu.GetBool("AntiGapCloserW") && W.IsReady() && Args.Sender.IsValidTarget(W.Range) && 
                  Me.CountEnemiesInRange(1000) < 3)
              {
                  W.Cast(true);
              }
          }
  
          private static void OnInterruptableTarget(AIHeroClient sender, Interrupter2.InterruptableTargetEventArgs Args)
          {
              if (Menu.GetBool("InterruptTargetW")&& W.IsReady() && sender.IsValidTarget(W.Range) && 
                  !sender.ServerPosition.UnderTurret(true))
              {
                  W.Cast(true);
              }
          }
  
          private static void OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs Args)
          {
              if (sender.IsMe)
              {
                  LogicSpellCast(Args);
              }
  
              if (sender.IsEnemy && sender.Type == GameObjectType.AIHeroClient && Args.Target != null && Args.Target.IsMe)
              {
                  if (Menu.GetBool("EShielddogde") && E.IsReady() && Me.CanMoveMent())
                  {
                      LogicSpellShield(sender, Args);
                  }
              }
          }
  
          private static void LogicSpellCast(GameObjectProcessSpellCastEventArgs Args)
          {
              if (Args.SData.Name == "ItemTiamatCleave")
              {
                  if (!HeroManager.Enemies.Any(x => x.DistanceToPlayer() <= W.Range))
                  {
                      return;
                  }
  
                  if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
                  {
                      if (Menu.GetBool("ComboW") && W.IsReady())
                      {
                          W.Cast();
                      }
  
                      if (Menu.GetBool("ComboR") && R.IsReady())
                      {
                          var target = TargetSelector.GetSelectedTarget() ??
                                       TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Physical);
  
                          if (target.IsValidTarget(R.Range))
                          {
                              R2Logic(target);
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
                  {
                      W.Cast();
  
                      if (R.IsReady())
                      {
                          if (TargetSelector.GetSelectedTarget().IsValidTarget(R.Range))
                          {
                              var rPred = R.GetPrediction(TargetSelector.GetSelectedTarget(), true);
  
                              if (rPred.Hitchance >= HitChance.High)
                              {
                                  R.Cast(rPred.CastPosition, true);
                              }
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Mixed)
                  {
                      if (Menu.GetBool("HarassW") && W.IsReady())
                      {
                          W.Cast();
                      }
                  }
              }
              else if (Args.SData.Name == "RivenTriCleave")
              {
                  canQ = false;
  
                  if (!HeroManager.Enemies.Any(x => x.DistanceToPlayer() <= 400))
                  {
                      return;
                  }
  
                  if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
                  {
                      CastItem(true);
  
                      if (Menu.GetBool("ComboR") && R.IsReady())
                      {
                          var target = TargetSelector.GetSelectedTarget() ??
                                       TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Physical);
  
                          if (target.IsValidTarget(R.Range))
                          {
                              R2Logic(target);
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
                  {
                      CastItem(true);
  
                      if (R.IsReady())
                      {
                          if (TargetSelector.GetSelectedTarget().IsValidTarget(R.Range))
                          {
                              var rPred = R.GetPrediction(TargetSelector.GetSelectedTarget(), true);
  
                              if (rPred.Hitchance >= HitChance.High)
                              {
                                  R.Cast(rPred.CastPosition, true);
                              }
                          }
                      }
                  }
              }
              else if (Args.SData.Name == "RivenTriCleaveBuffer")
              {
                  if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
                  {
                      if (Menu.GetBool("ComboR") && R.IsReady())
                      {
                          var target = TargetSelector.GetSelectedTarget() ??
                                       TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Physical);
  
                          if (target.IsValidTarget(R.Range))
                          {
                              R2Logic(target);
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
                  {
                      if (R.IsReady())
                      {
                          if (TargetSelector.GetSelectedTarget().IsValidTarget(R.Range))
                          {
                              var rPred = R.GetPrediction(TargetSelector.GetSelectedTarget(), true);
  
                              if (rPred.Hitchance >= HitChance.High)
                              {
                                  R.Cast(rPred.CastPosition, true);
                              }
                          }
                      }
                  }
              }
              else if (Args.SData.Name == "RivenMartyr")
              {
                  if ((Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo || Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst) &&
                      HeroManager.Enemies.Any(x => x.DistanceToPlayer() <= 400))
                  {
                      CastItem(true);
                  }
              }
              else if (Args.SData.Name == "RivenFeint")
              {
                  if (!R.IsReady())
                  {
                      return;
                  }
  
                  if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
                  {
                      var target = TargetSelector.GetSelectedTarget() ??
                                   TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Physical);
  
                      if (target.IsValidTarget(R.Range))
                      {
                          if (R.Instance.Name == "RivenFengShuiEngine")
                          {
                              if (Menu.GetKey("R1Combo"))
                              {
                                  if (target.DistanceToPlayer() <= 500 &&
                                      HeroManager.Enemies.Any(x => x.DistanceToPlayer() <= 500))
                                  {
                                      R.Cast(true);
                                  }
                              }
                          }
                          else if (R.Instance.Name == "RivenIzunaBlade")
                          {
                              R2Logic(target);
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
                  {
                      if (TargetSelector.GetSelectedTarget().IsValidTarget(R.Range))
                      {
                          if (R.Instance.Name == "RivenFengShuiEngine")
                          {
                              R.Cast();
                          }
                          else if (R.Instance.Name == "RivenIzunaBlade")
                          {
                              var rPred = R.GetPrediction(TargetSelector.GetSelectedTarget(), true);
  
                              if (rPred.Hitchance >= HitChance.High)
                              {
                                  R.Cast(rPred.CastPosition, true);
                              }
                          }
                      }
                  }
              }
              else if (Args.SData.Name == "RivenIzunaBlade")
              {
                  if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
                  {
                      var target = TargetSelector.GetSelectedTarget() ??
                                   TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Physical);
  
                      if (target != null && target.IsValidTarget())
                      {
                          if (Q.IsReady() && target.IsValidTarget(Q.Range))
                          {
                              CastQ(target);
                          }
                          else if (W.IsReady() && target.IsValidTarget(W.Range))
                          {
                              W.Cast();
                          }
                      }
                  }
                  else if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
                  {
                      if (TargetSelector.GetSelectedTarget().IsValidTarget())
                      {
                          if (TargetSelector.GetSelectedTarget().IsValidTarget(Q.Range))
                          {
                              CastQ(TargetSelector.GetSelectedTarget());
                          }
                          else if (TargetSelector.GetSelectedTarget().IsValidTarget(W.Range) && W.IsReady())
                          {
                              W.Cast();
                          }
                      }
                  }
              }
          }
  
          private static void LogicSpellShield(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs Args)
          {
              if (Args.SData.Name.Contains("DariusR"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeDariusR"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("GarenQ"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeGarenQ"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("GarenR"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeGarenR"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("IreliaE"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeIreliaE"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("LeeSinR"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeLeeSinR"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("OlafE"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeOlafE"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("PantheonW"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgePantheonW"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("RenektonW"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeRenektonW"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("RengarQ"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeRengarQ"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("VeigarR"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeVeigarR"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("VolibearW"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeVolibearW"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("XenZhaoThrust3"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeXenZhaoQ3"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
  
              if (Args.SData.Name.Contains("attack") && Args.Target.IsMe &&
                  sender.Buffs.Any(
                      buff =>
                          buff.Name == "BlueCardAttack" || buff.Name == "GoldCardAttack" ||
                          buff.Name == "RedCardAttack"))
              {
                  if (E.IsReady() && Menu.GetBool("EDodgeTwistedFateW"))
                  {
                      E.Cast(Me.Position.Extend(Game.CursorPos, E.Range), true);
                  }
              }
          }
  
          private static void OnPlayAnimation(Obj_AI_Base sender, GameObjectPlayAnimationEventArgs Args)
          {
              if (!sender.IsMe)
              {
                  return;
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.None || Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Flee)
              {
                  return;
              }
  
              if (Args.Animation.Contains("Spell1a"))
              {
                  qStack = 1;
                  ResetQA(Menu.Item("Q1Delay", true).GetValue<Slider>().Value);
              }
              else if (Args.Animation.Contains("Spell1b"))
              {
                  qStack = 2;
                  ResetQA(Menu.Item("Q2Delay", true).GetValue<Slider>().Value);
              }
              else if (Args.Animation.Contains("Spell1c"))
              {
                  qStack = 0;
                  ResetQA(Menu.Item("Q3Delay", true).GetValue<Slider>().Value);
              }
          }
  
          private static void ResetQA(int time)
          {
              if (Menu.GetBool("Dance"))
              {
                  EloBuddy.Player.DoEmote(Emote.Dance);
              }
              LeagueSharp.Common.Utility.DelayAction.Add(time, () =>
              {
                  EloBuddy.Player.DoEmote(Emote.Dance);
                  Orbwalking.ResetAutoAttackTimer();
                  EloBuddy.Player.IssueOrder(GameObjectOrder.MoveTo, Me.Position.Extend(Game.CursorPos, +10));
              });
          }
  
          private static void OnSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs Args)
          {
              if (!sender.IsMe || !Orbwalking.IsAutoAttack(Args.SData.Name))
              {
                  return;
              }
  
              if (Args.Target == null)
              {
                  return;
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
              {
                  var target = Args.Target as AIHeroClient;
  
                  if (target != null && !target.IsDead && !target.IsZombie)
                  {
                      CastItem(true, true);
  
                      if (Q.IsReady())
                      {
                          CastQ(target);
                      }
                      else if (W.IsReady() && target.IsValidTarget(W.Range) && !target.HasBuffOfType(BuffType.SpellShield) &&
                               (target.IsMelee || target.IsFacing(Me) || !Q.IsReady() || Me.HasBuff("RivenFeint") ||
                                qStack != 0))
                      {
                          W.Cast();
                      }
                  }
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Burst)
              {
                  var target = TargetSelector.GetSelectedTarget();
  
                  if (target != null && !target.IsDead && !target.IsZombie)
                  {
                      CastItem(true, true);
  
                      if (Q.IsReady())
                      {
                          CastQ(target);
                      }
                      else if (W.IsReady() && target.IsValidTarget(W.Range))
                      {
                          W.Cast();
                      }
                  }
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Mixed)
              {
                  var target = Args.Target as AIHeroClient;
  
                  if (target != null && !target.IsDead && !target.IsZombie)
                  {
                      CastItem(true);
  
                      if (Menu.GetBool("HarassQ") && Q.IsReady())
                      {
                          if (Menu.GetList("HarassMode") == 0)
                          {
                              if (qStack == 1)
                              {
                                  CastQ(target);
                              }
                          }
                          else
                          {
                              CastQ(target);
                          }
                      }
                  }
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.LaneClear)
              {
                  LaneClear(Args);
                  JungleClear(Args);
              }
          }
  
          private static void LaneClear(GameObjectProcessSpellCastEventArgs Args)
          {
              if (Menu.GetBool("LaneClearQ") && Q.IsReady())
              {
                  if (Args.Target.Type == GameObjectType.obj_AI_Turret || Args.Target.Type == GameObjectType.obj_Turret ||
                      Args.Target.Type == GameObjectType.obj_LampBulb)
                  {
                      if (Q.IsReady() && !Args.Target.IsDead)
                      {
                          CastQ((Obj_AI_Base)Args.Target);
                      }
                  }
                  else
                  {
                      var minion = Args.Target as Obj_AI_Minion;
  
gt:                     var minions = MinionManager.GetMinions(Me.Position, 500f);