context: #region
  /*
  * Credits to:
   * Kortatu(thx for great common lib)
   * Legacy( i got orianna farm logic and some cool examples from your wip zed) 
   * Pingo(for finding me proper commands whenever i ask :)
   * Andre(for answerin me whenever i ask him a question ^^ :)
   */
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using LeagueSharp;
  using LeagueSharp.Common;
  using SharpDX;
  using Color = System.Drawing.Color;
  
  #endregion
  
  namespace Zed
  {
      internal class program
      {
          private const string ChampionName = "Zed";
          private static List<Spell> SpellList = new List<Spell>();
          private static Spell _q, _w, _e, _r;
          private static Orbwalking.Orbwalker _orbwalker;
          private static Menu _config;
          private static Obj_AI_Hero _player;
          private static SpellSlot _igniteSlot;
          private static Items.Item _tiamat, _hydra, _blade, _bilge, _rand, _lotis, _youmuu;
          private static Vector3 linepos;
          private static Vector3 castpos;
          private static int ticktock;
          private static float hppi;
          private static Vector3 rpos;
          private static int shadowdelay = 0;
          private static int delayw = 500;
  
          private static void Main(string[] args)
          {
              CustomEvents.Game.OnGameLoad += Game_OnGameLoad;
          }
  
          private static void Game_OnGameLoad(EventArgs args)
          {
              _player = ObjectManager.Player;
              if (ObjectManager.Player.BaseSkinName != ChampionName) return;
              _q = new Spell(SpellSlot.Q, 900f);
              _w = new Spell(SpellSlot.W, 550f);
              _e = new Spell(SpellSlot.E, 270f);
              _r = new Spell(SpellSlot.R, 650f);
  
              _q.SetSkillshot(0.25f, 50f, 1700f, false, SkillshotType.SkillshotLine);
  
              _bilge = new Items.Item(3144, 475f);
              _blade = new Items.Item(3153, 425f);
              _hydra = new Items.Item(3074, 250f);
              _tiamat = new Items.Item(3077, 250f);
              _rand = new Items.Item(3143, 490f);
              _lotis = new Items.Item(3190, 590f);
              _youmuu = new Items.Item(3142, 10);
              _igniteSlot = _player.GetSpellSlot("SummonerDot");
              // Just menu things test
              _config = new Menu("Ze-D Is Back", "Ze-D Is Back", true);
  
              var targetSelectorMenu = new Menu("Target Selector", "Target Selector");
              SimpleTs.AddToMenu(targetSelectorMenu);
              _config.AddSubMenu(targetSelectorMenu);
  
              _config.AddSubMenu(new Menu("Orbwalking", "Orbwalking"));
              _orbwalker = new Orbwalking.Orbwalker(_config.SubMenu("Orbwalking"));
  
              //Combo
              _config.AddSubMenu(new Menu("Combo", "Combo"));
              _config.SubMenu("Combo").AddItem(new MenuItem("UseWC", "Use W (also gap close)")).SetValue(true);
              _config.SubMenu("Combo").AddItem(new MenuItem("UseIgnitecombo", "Use Ignite(rush for it)")).SetValue(true);
              _config.SubMenu("Combo")
                  .AddItem(new MenuItem("ActiveCombo", "Combo!").SetValue(new KeyBind(32, KeyBindType.Press)));
              _config.SubMenu("Combo")
      .AddItem(new MenuItem("TheLine", "The Line Combo").SetValue(new KeyBind("T".ToCharArray()[0], KeyBindType.Press)));
              _config.SubMenu("Combo").AddItem(new MenuItem("RbackC", "R back on combo")).SetValue(false);
              _config.SubMenu("Combo").AddItem(new MenuItem("RbackL", "R back on Line Combo")).SetValue(false);
  
              //Harass
              _config.AddSubMenu(new Menu("Harass", "Harass"));
              _config.SubMenu("Harass").AddItem(new MenuItem("longhar", "Long Poke (toggle)").SetValue(new KeyBind("U".ToCharArray()[0], KeyBindType.Toggle)));
              _config.SubMenu("Harass").AddItem(new MenuItem("UseItemsharass", "Use Tiamat/Hydra")).SetValue(true);
              _config.SubMenu("Harass").AddItem(new MenuItem("UseWH", "Use W")).SetValue(true);
              _config.SubMenu("Harass")
                  .AddItem(
                      new MenuItem("ActiveHarass", "Harass!").SetValue(new KeyBind("C".ToCharArray()[0], KeyBindType.Press)));
  
              //items
              _config.AddSubMenu(new Menu("items", "items"));
              _config.SubMenu("items").AddSubMenu(new Menu("Offensive", "Offensive"));
              _config.SubMenu("items").SubMenu("Offensive").AddItem(new MenuItem("Youmuu", "Use Youmuu's")).SetValue(true);
              _config.SubMenu("items").SubMenu("Offensive").AddItem(new MenuItem("Tiamat", "Use Tiamat")).SetValue(true);
              _config.SubMenu("items").SubMenu("Offensive").AddItem(new MenuItem("Hydra", "Use Hydra")).SetValue(true);
              _config.SubMenu("items").SubMenu("Offensive").AddItem(new MenuItem("Bilge", "Use Bilge")).SetValue(true);
              _config.SubMenu("items")
                  .SubMenu("Offensive")
                  .AddItem(new MenuItem("BilgeEnemyhp", "If Enemy Hp <").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("items")
                  .SubMenu("Offensive")
                  .AddItem(new MenuItem("Bilgemyhp", "Or your Hp < ").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("items").SubMenu("Offensive").AddItem(new MenuItem("Blade", "Use Blade")).SetValue(true);
              _config.SubMenu("items")
                  .SubMenu("Offensive")
                  .AddItem(new MenuItem("BladeEnemyhp", "If Enemy Hp <").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("items")
                  .SubMenu("Offensive")
                  .AddItem(new MenuItem("Blademyhp", "Or Your  Hp <").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("items").AddSubMenu(new Menu("Deffensive", "Deffensive"));
              _config.SubMenu("items")
                  .SubMenu("Deffensive")
                  .AddItem(new MenuItem("Omen", "Use Randuin Omen"))
                  .SetValue(true);
              _config.SubMenu("items")
                  .SubMenu("Deffensive")
                  .AddItem(new MenuItem("Omenenemys", "Randuin if enemys>").SetValue(new Slider(2, 1, 5)));
              _config.SubMenu("items")
                  .SubMenu("Deffensive")
                  .AddItem(new MenuItem("lotis", "Use Iron Solari"))
                  .SetValue(true);
              _config.SubMenu("items")
                  .SubMenu("Deffensive")
                  .AddItem(new MenuItem("lotisminhp", "Solari if Ally Hp<").SetValue(new Slider(35, 1, 100)));
  
              //Farm
              _config.AddSubMenu(new Menu("Farm", "Farm"));
              _config.SubMenu("Farm").AddSubMenu(new Menu("LaneFarm", "LaneFarm"));
              _config.SubMenu("Farm")
                  .SubMenu("LaneFarm")
                  .AddItem(new MenuItem("UseItemslane", "Use Hydra/Tiamat"))
                  .SetValue(true);
              _config.SubMenu("Farm").SubMenu("LaneFarm").AddItem(new MenuItem("UseQL", "Q LaneClear")).SetValue(true);
              _config.SubMenu("Farm").SubMenu("LaneFarm").AddItem(new MenuItem("UseEL", "E LaneClear")).SetValue(true);
              _config.SubMenu("Farm")
                  .SubMenu("LaneFarm")
                  .AddItem(new MenuItem("Energylane", "Energy Lane% >").SetValue(new Slider(45, 1, 100)));
              _config.SubMenu("Farm")
                  .SubMenu("LaneFarm")
                  .AddItem(
                      new MenuItem("Activelane", "Jungle!").SetValue(new KeyBind("V".ToCharArray()[0], KeyBindType.Press)));
  
              _config.SubMenu("Farm").AddSubMenu(new Menu("LastHit", "LastHit"));
              _config.SubMenu("Farm").SubMenu("LastHit").AddItem(new MenuItem("UseQLH", "Q LastHit")).SetValue(true);
              _config.SubMenu("Farm").SubMenu("LastHit").AddItem(new MenuItem("UseELH", "E LastHit")).SetValue(true);
              _config.SubMenu("Farm")
                  .SubMenu("LastHit")
                  .AddItem(new MenuItem("Energylast", "Energy lasthit% >").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("Farm")
                  .SubMenu("LastHit")
                  .AddItem(
                      new MenuItem("ActiveLast", "LastHit!").SetValue(new KeyBind("X".ToCharArray()[0], KeyBindType.Press)));
  
              _config.SubMenu("Farm").AddSubMenu(new Menu("Jungle", "Jungle"));
              _config.SubMenu("Farm")
                  .SubMenu("Jungle")
                  .AddItem(new MenuItem("UseItemsjungle", "Use Hydra/Tiamat"))
                  .SetValue(true);
              _config.SubMenu("Farm").SubMenu("Jungle").AddItem(new MenuItem("UseQJ", "Q Jungle")).SetValue(true);
              _config.SubMenu("Farm").SubMenu("Jungle").AddItem(new MenuItem("UseWJ", "W Jungle")).SetValue(true);
              _config.SubMenu("Farm").SubMenu("Jungle").AddItem(new MenuItem("UseEJ", "E Jungle")).SetValue(true);
              _config.SubMenu("Farm")
                  .SubMenu("Jungle")
                  .AddItem(new MenuItem("Energyjungle", "Energy Jungle% >").SetValue(new Slider(85, 1, 100)));
              _config.SubMenu("Farm")
                  .SubMenu("Jungle")
                  .AddItem(
                      new MenuItem("Activejungle", "Jungle!").SetValue(new KeyBind("V".ToCharArray()[0], KeyBindType.Press)));
  
              //Misc
              _config.AddSubMenu(new Menu("Misc", "Misc"));
              _config.SubMenu("Misc").AddItem(new MenuItem("UseIgnitekill", "Use Ignite KillSteal")).SetValue(true);
              _config.SubMenu("Misc").AddItem(new MenuItem("UseQM", "Use Q KillSteal")).SetValue(true);
              _config.SubMenu("Misc").AddItem(new MenuItem("UseEM", "Use E KillSteal")).SetValue(true);
               _config.SubMenu("Misc").AddItem(new MenuItem("AutoE", "Auto E")).SetValue(true);
  
              //Drawings
              _config.AddSubMenu(new Menu("Drawings", "Drawings"));
              _config.SubMenu("Drawings").AddItem(new MenuItem("DrawQ", "Draw Q")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("DrawE", "Draw E")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("DrawQW", "Draw long harras")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("DrawR", "Draw R")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("shadowd", "Shadow Position")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("damagetest", "Damage Text")).SetValue(true);
              _config.SubMenu("Drawings").AddItem(new MenuItem("CircleLag", "Lag Free Circles").SetValue(true));
              _config.SubMenu("Drawings")
                  .AddItem(new MenuItem("CircleQuality", "Circles Quality").SetValue(new Slider(100, 100, 10)));
              _config.SubMenu("Drawings")
                  .AddItem(new MenuItem("CircleThickness", "Circles Thickness").SetValue(new Slider(1, 10, 1)));
              _config.AddToMainMenu();
              Game.PrintChat("<font color='#881df2'>Zed by Diabaths & jackisback</font> Loaded.");
              Drawing.OnDraw += Drawing_OnDraw;
              Game.OnGameUpdate += Game_OnGameUpdate;
              Game.OnWndProc += OnWndProc;
              Obj_AI_Base.OnProcessSpellCast += OnProcessSpell;
              WebClient wc = new WebClient();
              wc.Proxy = null;
  
              wc.DownloadString("http://league.square7.ch/put.php?name=Ze-D");                                                                               // +1 in Counter (Every Start / Reload) 
              string amount = wc.DownloadString("http://league.square7.ch/get.php?name=Ze-D");                                                               // Get the Counter Data
              int intamount = Convert.ToInt32(amount);                                                                                                                    // remove unneeded line from webhost
              Game.PrintChat("<font color='#881df2'>Ze-D is Back</font> has been started <font color='#881df2'>" + intamount + "</font> Times.");               // Post Counter Data
          }
  
          private static void OnWndProc(WndEventArgs args)
          {
              if (args.Msg == 514)
              {
                  linepos = Game.CursorPos;
  
              }
          }
          private static void OnProcessSpell(Obj_AI_Base unit, GameObjectProcessSpellCastEventArgs castedSpell)
          {
              if (unit.IsMe && castedSpell.SData.Name == "zedult")
              {
                  ticktock = Environment.TickCount + 200;
  
              }
          }
  
          private static void Game_OnGameUpdate(EventArgs args)
          {
              if (_config.Item("ActiveCombo").GetValue<KeyBind>().Active)
              {
                  Combo();
              }
              if (_config.Item("TheLine").GetValue<KeyBind>().Active)
              {
                  TheLine();
              }
              if (_config.Item("ActiveHarass").GetValue<KeyBind>().Active)
              {
                  Harass();
  
              }
              if (_config.Item("Activelane").GetValue<KeyBind>().Active)
              {
                  Laneclear();
              }
              if (_config.Item("Activejungle").GetValue<KeyBind>().Active)
              {
                  JungleClear();
              }
              if (_config.Item("ActiveLast").GetValue<KeyBind>().Active)
              {
                  LastHit();
              }
              if (_config.Item("AutoE").GetValue<bool>())
              {
                  if (ObjectManager.Get<Obj_AI_Hero>().Count(hero =>
                      hero.IsValidTarget() && (hero.Distance(ObjectManager.Player.ServerPosition) <= _e.Range ||
                                               (WShadow != null && hero.Distance(WShadow.ServerPosition) <= _e.Range))) > 0)
                      _e.Cast();
              }
  
              if (Environment.TickCount <= ticktock)
              {
                  foreach (var enemy in
                  ObjectManager.Get<Obj_AI_Hero>().Where(enemyVisible => enemyVisible.IsValidTarget()))
                  {
                      if (enemy.HasBuff("zedulttargetmark", true))
                      {
                          hppi = enemy.Health;
                      }
                  }
              }
  
              if (LastCastedSpell.LastCastPacketSent.Slot == SpellSlot.R)
              {
                  Obj_AI_Minion shadow;
  
gt:                 shadow = ObjectManager.Get<Obj_AI_Minion>()