context: using EloBuddy; 
  using LeagueSharp.Common; 
  namespace xSaliceResurrected_Rework.Pluging
  {
      using System;
      using System.Linq;
      using LeagueSharp;
      using LeagueSharp.Common;
      using SharpDX;
      using Base;
      using Managers;
      using Utilities;
      using Color = System.Drawing.Color;
  
      internal class Ahri : Champion
      {
          private static bool _rOn;
          private static int _rTimer;
          private static int _rTimeLeft;
  
          public Ahri()
          {
              SpellManager.Q = new Spell(SpellSlot.Q, 900f);
              SpellManager.W = new Spell(SpellSlot.W, 600f);
              SpellManager.E = new Spell(SpellSlot.E, 950f);
              SpellManager.R = new Spell(SpellSlot.R, 850f);
  
              SpellManager.Q.SetSkillshot(0.25f, 90f, 1550f, false, SkillshotType.SkillshotLine);
              SpellManager.E.SetSkillshot(0.25f, 60f, 1550f, true, SkillshotType.SkillshotLine);
  
              SpellManager.SpellList.Add(Q);
              SpellManager.SpellList.Add(W);
              SpellManager.SpellList.Add(E);
              SpellManager.SpellList.Add(R);
  
              var combo = new Menu("Combo", "Combo");
              {
                  combo.AddItem(new MenuItem("UseQCombo", "Use Q", true).SetValue(true));
                  combo.AddItem(new MenuItem("UseWCombo", "Use W", true).SetValue(true));
                  combo.AddItem(new MenuItem("UseECombo", "Use E", true).SetValue(true));
                  combo.AddItem(new MenuItem("UseRCombo", "Use R", true).SetValue(true));
                  combo.AddItem(new MenuItem("rSpeed", "Use All R fast Duel", true).SetValue(true));
                  combo.AddItem(new MenuItem("charmCombo", "Q if Charmed in Combo", true).SetValue(new KeyBind("I".ToCharArray()[0], KeyBindType.Toggle)));
                  Menu.AddSubMenu(combo);
              }
  
              var harass = new Menu("Harass", "Harass");
              {
                  harass.AddItem(new MenuItem("UseQHarass", "Use Q", true).SetValue(true));
                  harass.AddItem(new MenuItem("UseWHarass", "Use W", true).SetValue(false));
                  harass.AddItem(new MenuItem("UseEHarass", "Use E", true).SetValue(true));
                  harass.AddItem(new MenuItem("longQ", "Cast Long range Q", true).SetValue(true));
                  harass.AddItem(new MenuItem("FarmT", "Harass (toggle)!", true).SetValue(new KeyBind("N".ToCharArray()[0], KeyBindType.Toggle)));
                  ManaManager.AddManaManagertoMenu(harass, "Harass", 60);
                  Menu.AddSubMenu(harass);
              }
  
              var farm = new Menu("Farm", "Farm");
              {
                  farm.AddItem(new MenuItem("UseQFarm", "Use Q", true).SetValue(false));
                  farm.AddItem(new MenuItem("UseWFarm", "Use W", true).SetValue(false));
                  ManaManager.AddManaManagertoMenu(farm, "Farm", 50);
                  Menu.AddSubMenu(farm);
              }
  
              var misc = new Menu("Misc", "Misc");
              {
                  misc.AddSubMenu(AoeSpellManager.AddHitChanceMenuCombo(true, false, false, false));
                  misc.AddItem(new MenuItem("UseInt", "Use E to Interrupt", true).SetValue(true));
                  misc.AddItem(new MenuItem("UseGap", "Use E for GapCloser", true).SetValue(true));
                  misc.AddItem(new MenuItem("EQ", "Use Q onTop of E", true).SetValue(true));
                  misc.AddItem(new MenuItem("smartKS", "Smart KS", true).SetValue(true));
                  Menu.AddSubMenu(misc);
              }
  
              var drawing = new Menu("Drawings", "Drawings");
              {
                  drawing.AddItem(
                          new MenuItem("QRange", "Q range", true).SetValue(new Circle(false, Color.FromArgb(100, 255, 0, 255))));
                  drawing.AddItem(
                          new MenuItem("WRange", "W range", true).SetValue(new Circle(true, Color.FromArgb(100, 255, 0, 255))));
                  drawing.AddItem(
                          new MenuItem("ERange", "E range", true).SetValue(new Circle(false, Color.FromArgb(100, 255, 0, 255))));
                  drawing.AddItem(
                          new MenuItem("RRange", "R range", true).SetValue(new Circle(false, Color.FromArgb(100, 255, 0, 255))));
                  drawing.AddItem(
                          new MenuItem("cursor", "Draw R Dash Range", true).SetValue(new Circle(false, Color.FromArgb(100, 255, 0, 255))));
  
                  var drawComboDamageMenu = new MenuItem("Draw_ComboDamage", "Draw Combo Damage", true).SetValue(true);
                  var drawFill = new MenuItem("Draw_Fill", "Draw Combo Damage Fill", true).SetValue(new Circle(true, Color.FromArgb(90, 255, 169, 4)));
                  drawing.AddItem(drawComboDamageMenu);
                  drawing.AddItem(drawFill);
                  //DamageIndicator.DamageToUnit = GetComboDamage;
                  //DamageIndicator.Enabled = drawComboDamageMenu.GetValue<bool>();
                  //DamageIndicator.Fill = drawFill.GetValue<Circle>().Active;
                  //DamageIndicator.FillColor = drawFill.GetValue<Circle>().Color;
                  drawComboDamageMenu.ValueChanged +=
                      delegate (object sender, OnValueChangeEventArgs eventArgs)
                      {
                          //DamageIndicator.Enabled = eventArgs.GetNewValue<bool>();
                      };
                  drawFill.ValueChanged +=
                      delegate (object sender, OnValueChangeEventArgs eventArgs)
                      {
                          //DamageIndicator.Fill = eventArgs.GetNewValue<Circle>().Active;
                          //DamageIndicator.FillColor = eventArgs.GetNewValue<Circle>().Color;
                      };
                  Menu.AddSubMenu(drawing);
              }
  
              var customMenu = new Menu("Custom Perma Show", "Custom Perma Show");
              {
                  var myCust = new CustomPermaMenu();
                  customMenu.AddItem(new MenuItem("custMenu", "Move Menu", true).SetValue(new KeyBind("L".ToCharArray()[0], KeyBindType.Press)));
                  customMenu.AddItem(new MenuItem("enableCustMenu", "Enabled", true).SetValue(true));
                  customMenu.AddItem(myCust.AddToMenu("Combo Active: ", "Orbwalk"));
                  customMenu.AddItem(myCust.AddToMenu("Harass Active: ", "Farm"));
                  customMenu.AddItem(myCust.AddToMenu("Harass(T) Active: ", "FarmT"));
                  customMenu.AddItem(myCust.AddToMenu("Laneclear Active: ", "LaneClear"));
                  customMenu.AddItem(myCust.AddToMenu("Require Charm: ", "charmCombo"));
                  Menu.AddSubMenu(customMenu);
              }
          }
  
          private float GetComboDamage(Obj_AI_Base enemy)
          {
              if (enemy == null)
                  return 0;
  
              var damage = 0d;
  
              if (Q.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.Q);
                  damage += Player.GetSpellDamage(enemy, SpellSlot.Q, 1);
              }
              if (W.IsReady())
                  damage += Player.GetSpellDamage(enemy, SpellSlot.W);
  
              if (_rOn)
                  damage += Player.GetSpellDamage(enemy, SpellSlot.R) * RCount();
              else if (R.IsReady())
                  damage += Player.GetSpellDamage(enemy, SpellSlot.R) * 3;
  
              damage = ItemManager.CalcDamage(enemy, damage);
  
              if (E.IsReady())
                  damage += Player.GetSpellDamage(enemy, SpellSlot.E);
  
              return (float)damage;
          }
  
          private void Combo()
          {
              var eTarget = TargetSelector.GetTarget(E.Range, TargetSelector.DamageType.Magical);
              var rETarget = TargetSelector.GetTarget(E.Range, TargetSelector.DamageType.Magical);
  
              var dmg = GetComboDamage(eTarget);
  
              if (eTarget == null)
                  return;
  
              ItemManager.Target = eTarget;
  
              if (dmg > eTarget.Health - 50)
                  ItemManager.KillableTarget = true;
  
              ItemManager.UseTargetted = true;
  
              //E
              if (Menu.Item("UseECombo", true).GetValue<bool>() && E.IsReady() && Player.Distance(eTarget.Position) < E.Range)
              {
                  SpellCastManager.CastBasicSkillShot(E, E.Range, TargetSelector.DamageType.Magical, HitChance.VeryHigh);
                  if (Menu.Item("EQ", true).GetValue<bool>() && Q.IsReady() && !E.IsReady())
                  {
                      SpellCastManager.CastBasicSkillShot(Q, Q.Range, TargetSelector.DamageType.Magical, HitChance.VeryHigh);
                  }
              }
  
              //W
              if (Menu.Item("UseWCombo", true).GetValue<bool>() && W.IsReady() && Player.Distance(eTarget.Position) <= W.Range - 100 &&
                  ShouldW(eTarget))
              {
                  W.Cast();
              }
  
              if (Menu.Item("UseQCombo", true).GetValue<bool>() && Q.IsReady() && Player.Distance(eTarget.Position) <= Q.Range &&
                       ShouldQ(eTarget))
              {
                  SpellCastManager.CastBasicSkillShot(Q, Q.Range, TargetSelector.DamageType.Magical, HitChance.VeryHigh);
              }
  
              //R
              if (Menu.Item("UseRCombo", true).GetValue<bool>() && R.IsReady() && Player.Distance(eTarget.Position) < R.Range)
              {
                  if (E.IsReady())
                  {
                      if (CheckReq(rETarget))
                          SpellCastManager.CastBasicSkillShot(E, E.Range, TargetSelector.DamageType.Magical, HitChance.VeryHigh);
                  }
                  if (ShouldR(eTarget, dmg) && R.IsReady())
                  {
                      R.Cast(Game.CursorPos);
                      _rTimer = Utils.TickCount - 250;
                  }
  
gt:                 if (_rTimeLeft > 9500 && _rOn && R.IsReady())