context: #region
  
  using System;
  using System.Collections.Generic;
  using System.Drawing;
  using System.Linq;
  using LeagueSharp;
  using LeagueSharp.Common;
  using Marksman.Utils;
  using Marksman.Common;
  using SharpDX;
  using Collision = LeagueSharp.Common.Collision;
  using Orbwalking = LeagueSharp.Common.Orbwalking;
  
  #endregion
  
  using EloBuddy; 
  using LeagueSharp.Common; 
   namespace Marksman.Champions
  {
      internal class Jinx : Champion
      {
          public static Spell Q, W, E, R;
          private int wCastTime;
          private Obj_AI_Minion aMinion;
          public Jinx()
          {
              Q = new Spell(SpellSlot.Q);
  
              W = new Spell(SpellSlot.W, 1450f);
              W.SetSkillshot(0.6f, 60f, 3300f, true, SkillshotType.SkillshotLine);
  
              E = new Spell(SpellSlot.E, 900f);
              E.SetSkillshot(1.1f, 1f, 1750f, false, SkillshotType.SkillshotCircle);
  
              R = new Spell(SpellSlot.R, 4000f);
              R.SetSkillshot(0.6f, 140f, 1700f, false, SkillshotType.SkillshotLine);
              
              Obj_AI_Base.OnBuffGain += (sender, args) =>
              {
                  if (E.IsReady())
                  {
                      BuffInstance aBuff =
                          (from fBuffs in
                               sender.Buffs.Where(
                                   s =>
                                   sender.Team != ObjectManager.Player.Team
                                   && sender.Distance(ObjectManager.Player.Position) < E.Range)
                           from b in new[]
                                             {
                                                  "teleport_", /* Teleport */
                                                  "pantheon_grandskyfall_jump", /* Pantheon */ 
                                                  "crowstorm", /* FiddleScitck */
                                                  "zhonya", "katarinar", /* Katarita */
                                                  "MissFortuneBulletTime", /* MissFortune */
                                                  "gate", /* Twisted Fate */
                                                  "chronorevive" /* Zilean */
                                             }
                           where args.Buff.Name.ToLower().Contains(b)
                           select fBuffs).FirstOrDefault();
  
                      if (aBuff != null && aBuff.StartTime + CommonUtils.GetRandomDelay(1000, 1500) <= Game.Time)
                      {
                          E.Cast(sender.Position);
                      }
                  }
              };
  
              //LeagueSharp.Common.Utility.HpBar//DamageIndicator.DamageToUnit = GetComboDamage;
              //LeagueSharp.Common.Utility.HpBar//DamageIndicator.Enabled = true;
  
              Utils.Utils.PrintMessage("Jinx");
          }
  
          public override void Orbwalking_BeforeAttack(Orbwalking.BeforeAttackEventArgs args)
          {
              /*
              var minion = args.Target as Obj_AI_Minion;
              if (minion != null && LaneClearActive)
              {
                  var mobs =
                      MinionManager.GetMinions(ObjectManager.Player.Position, Orbwalking.GetRealAutoAttackRange(null) + 65,
                          MinionTypes.All, MinionTeam.Enemy).Count(m => m.Distance(minion) < 155);
                  if (mobs < 2 && FishBoneActive)
                  {
                      args.Process = false;
                      Q.Cast();
                  }
              }
              */
          }
  
          public override void AntiGapcloser_OnEnemyGapcloser(ActiveGapcloser gapcloser)
          {
              if (!E.IsReady()) return;
              if (gapcloser.End.Distance(ObjectManager.Player.Position) <= 200)
                  E.Cast(gapcloser.End);
          }
  
  
          public override void Interrupter2_OnInterruptableTarget(AIHeroClient sender, Interrupter2.InterruptableTargetEventArgs args)
          {
              if (!E.IsReady()) return;
              if (args.DangerLevel >= Interrupter2.DangerLevel.Medium)
                  E.Cast(sender);
          }
  
          public override void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
          {
              if (!sender.IsMe) return;
              if (args.Slot == SpellSlot.W)
                  wCastTime = Environment.TickCount;
          }
  
  
          private static float GetComboDamage(AIHeroClient t)
          {
              var fComboDamage = 0f;
  
              fComboDamage += (float) GetRDamage(t);
  
              if (ObjectManager.Player.GetSpellSlot("summonerdot") != SpellSlot.Unknown
                  && ObjectManager.Player.Spellbook.CanUseSpell(ObjectManager.Player.GetSpellSlot("summonerdot"))
                  == SpellState.Ready && ObjectManager.Player.Distance(t) < 550) fComboDamage += (float)ObjectManager.Player.GetSummonerSpellDamage(t, Damage.SummonerSpell.Ignite);
  
              if (Items.CanUseItem(3144) && ObjectManager.Player.Distance(t) < 550) fComboDamage += (float)ObjectManager.Player.GetItemDamage(t, Damage.DamageItems.Bilgewater);
  
              if (Items.CanUseItem(3153) && ObjectManager.Player.Distance(t) < 550) fComboDamage += (float)ObjectManager.Player.GetItemDamage(t, Damage.DamageItems.Botrk);
  
              return fComboDamage;
          }
  
  
          public float QExtraRange => 50 + 25 * ObjectManager.Player.Spellbook.GetSpell(SpellSlot.Q).Level;
  
          private bool FishBoneActive => ObjectManager.Player.AttackRange > 565f;
  
          private int PowPowStacks
          {
              get
              {
                  return
                      ObjectManager.Player.Buffs.Where(buff => buff.DisplayName.ToLower() == "jinxqramp")
                          .Select(buff => buff.Count)
                          .FirstOrDefault();
              }
          }
  
          public override void Drawing_OnDraw(EventArgs args)
          {
              if (aMinion != null)
                  Render.Circle.DrawCircle(aMinion.Position, 50f, System.Drawing.Color.Red);
              Render.Circle.DrawCircle(ObjectManager.Player.Position, 125, System.Drawing.Color.Red);
              return;
              /*----------------------------------------------------*/
              var drawQbound = GetValue<Circle>("DrawQBound");
              foreach (var spell in new[] { W, E })
              {
                  var menuItem = GetValue<Circle>("Draw" + spell.Slot);
                  if (menuItem.Active)
                  {
                      Render.Circle.DrawCircle(ObjectManager.Player.Position, spell.Range, menuItem.Color);
                  }
              }
  
              if (drawQbound.Active)
              {
                  if (FishBoneActive)
                  {
                      Render.Circle.DrawCircle(ObjectManager.Player.Position, 525f + ObjectManager.Player.BoundingRadius + 65f, drawQbound.Color);
                  }
                  else
                  {
                      Render.Circle.DrawCircle(ObjectManager.Player.Position, 525f + ObjectManager.Player.BoundingRadius + 65f + QExtraRange + 20f, drawQbound.Color);
                  }
              }
          }
  
          public override void GameOnUpdate(EventArgs args)
          {
              if (GetValue<bool>("PingCH"))
              {
                  foreach (var enemy in
                      HeroManager.Enemies.Where(
                          enemy =>
                              R.IsReady() && enemy.IsValidTarget() && R.GetDamage(enemy) > enemy.Health))
                  {
                      //Marksman.Utils.Utils.MPing.Ping(enemy.Position.To2D());
                  }
              }
  
              if (Q.IsReady() && GetValue<bool>("SwapDistance") && Program.ChampionClass.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
              {
  
                  var nKillableEnemy = HeroManager.Enemies.Find(e => e.Health <= Q.GetDamage(e)*2 && e.Health >= ObjectManager.Player.TotalAttackDamage*4);
  
                  var activeQ = ObjectManager.Player.Spellbook.GetSpell(SpellSlot.Q).Level * 25 + 650;
                  var t = TargetSelector.GetTarget(activeQ, TargetSelector.DamageType.Physical);
  
                  if (t.IsValidTarget() && !t.IsValidTarget(Orbwalking.GetRealAutoAttackRange(null) + 65))
                  {
                      if (!FishBoneActive)
                      {
                          Q.Cast();
                          Orbwalker.ForceTarget(t);
                          return;
                      }
                  }
              }
  
              if (GetValue<bool>("PingCH"))
              {
                  foreach (var enemy in
                      HeroManager.Enemies.Where(
                          t =>
                          R.IsReady() && t.IsValidTarget() && R.GetDamage(t) > t.Health
                          && t.Distance(ObjectManager.Player) > Orbwalking.GetRealAutoAttackRange(null) + 65 + QExtraRange))
                  {
                      Utils.Utils.MPing.Ping(enemy.Position.To2D(), 2, PingCategory.Normal);
                  }
              }
  
           
  
              if (GetValue<bool>("SwapQ") && FishBoneActive && !ComboActive)
              {
                  Q.Cast();
              }
  
  
gt:             if ((!ComboActive && !HarassActive) || !Orbwalking.CanMove(100))