Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.57 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using LeagueSharp;
  4. using LeagueSharp.Common;
  5. using Color = System.Drawing.Color;
  6.  
  7. class Program
  8. {
  9.     // declare shorthandle to access the player object
  10.     // Properties http://msdn.microsoft.com/en-us/library/aa288470%28v=vs.71%29.aspx
  11.     private static Obj_AI_Hero Player { get { return ObjectManager.Player; } }
  12.  
  13.     // declare orbwalker class
  14.     private static Orbwalking.Orbwalker Orbwalker;
  15.  
  16.     // declare  list of spells
  17.     private static Spell Q, W, E, R;
  18.  
  19.     // declare list of items
  20.     private static Items.Item Dfg;
  21.  
  22.     // declare menu
  23.     private static Menu Menu;
  24.  
  25.     // declare Laugh
  26.     private static int LastLaugh;
  27.  
  28.     /// <summary>
  29.     /// Default programm entrypoint, gets called once on programm creation
  30.     /// </summary>
  31.     static void Main(string[] args)
  32.     {
  33.         // Events http://msdn.microsoft.com/en-us/library/edzehd2t%28v=vs.110%29.aspx
  34.         // OnGameLoad event, gets fired after loading screen is over
  35.         CustomEvents.Game.OnGameLoad += Game_OnGameLoad;
  36.     }
  37.  
  38.     /// <summary>
  39.     /// Game Loaded Method
  40.     /// </summary>
  41.     private static void Game_OnGameLoad(EventArgs args)
  42.     {
  43.         if (Player.ChampionName != "Nunu") // check if the current champion is Nunu
  44.             return; // stop programm
  45.  
  46.         // the Spell class provides methods to check and cast Spells
  47.         // Constructor Spell(SpellSlot slot, float range)
  48.         Q = new Spell(SpellSlot.Q, 125); // create Q spell with a range of 125 units
  49.         W = new Spell(SpellSlot.W, 700); // create W spell with a range of 700 units
  50.         E = new Spell(SpellSlot.E, 550); // create E spell with a range of 550 units
  51.         R = new Spell(SpellSlot.R, 650); // create R spell with a range of 650 units
  52.  
  53.         // set spells prediction values, not used on Nunu
  54.         // Method Spell.SetSkillshot(float delay, float width, float speed, bool collision, SkillshotType type)
  55.         // Q.SetSkillshot(0.25f, 80f, 1800f, false, SkillshotType.SkillshotLine);
  56.  
  57.         // create Dfg item id 3128 and range of 750 units
  58.         // Constructor Items.Item(int id, float range)
  59.         Dfg = new Items.Item(3128, 750);
  60.  
  61.         // create root menu
  62.         // Constructor Menu(string displayName, string name, bool root)
  63.         Menu = new Menu(Player.ChampionName, Player.ChampionName, true);
  64.  
  65.         // create and add submenu 'Orbwalker'
  66.         // Menu.AddSubMenu(Menu menu) returns added Menu
  67.         Menu orbwalkerMenu = Menu.AddSubMenu(new Menu("Orbwalker", "Orbwalker"));
  68.  
  69.         // creates Orbwalker object and attach to orbwalkerMenu
  70.         // Constructor Orbwalking.Orbwalker(Menu menu);
  71.         Orbwalker = new Orbwalking.Orbwalker(orbwalkerMenu);
  72.  
  73.         // create submenu for TargetSelector used by Orbwalker
  74.         Menu ts = Menu.AddSubMenu(new Menu("Target Selector", "Target Selector")); ;
  75.  
  76.         // attach
  77.         SimpleTs.AddToMenu(ts);
  78.  
  79.         //Spells menu
  80.         Menu spellMenu = Menu.AddSubMenu(new Menu("Spells", "Spells"));
  81.  
  82.         // Menu.AddItem(MenuItem item) returns added MenuItem
  83.         // Constructor MenuItem(string name, string displayName)
  84.         // .SetValue(true) on/off button
  85.         spellMenu.AddItem(new MenuItem("useQ", "Use Q").SetValue(true));
  86.         spellMenu.AddItem(new MenuItem("useW", "Use W").SetValue(true));
  87.         spellMenu.AddItem(new MenuItem("useE", "Use E").SetValue(true));
  88.         spellMenu.AddItem(new MenuItem("useR", "Use R to Farm").SetValue(true));
  89.  
  90.         // create MenuItem 'LaughButton' as Keybind
  91.         // Constructor KeyBind(int keyCode, KeyBindType type)
  92.         spellMenu.AddItem(new MenuItem("LaughButton", "Combo").SetValue(new KeyBind(32, KeyBindType.Press)));
  93.  
  94.         // create MenuItem 'ConsumeHealth' as Slider
  95.         // Constructor Slider(int value, int min, int max)
  96.         spellMenu.AddItem(new MenuItem("ConsumeHealth", "Consume below HP").SetValue(new Slider(40, 1, 100)));
  97.  
  98.         // attach to 'Sift/F9' Menu
  99.         Menu.AddToMainMenu();
  100.  
  101.         // subscribe to Drawing event
  102.         Drawing.OnDraw += Drawing_OnDraw;
  103.  
  104.         // subscribe to Update event gets called every game update around 10ms
  105.         Game.OnGameUpdate += Game_OnGameUpdate;
  106.  
  107.         // print text in local chat
  108.         Game.PrintChat("Welcome to Education Nunu");
  109.     }
  110.  
  111.     /// <summary>
  112.     /// Main Update Method
  113.     /// </summary>
  114.     private static void Game_OnGameUpdate(EventArgs args)
  115.     {
  116.         // dont do stuff while dead
  117.         if (Player.IsDead)
  118.             return;
  119.  
  120.         // checks the current Orbwalker mode Combo/Mixed/LaneClear/LastHit
  121.         if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
  122.         {
  123.             // combo to kill the enemy
  124.             Consume();
  125.             Bloodboil();
  126.             Iceblast();
  127.         }
  128.  
  129.         if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Mixed)
  130.         {
  131.             // farm and harass
  132.             Consume();
  133.             Iceblast();
  134.         }
  135.  
  136.         if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.LaneClear)
  137.         {
  138.             // fast minion farming
  139.             AbsoluteZero();
  140.         }
  141.  
  142.         // special keybind pressed (32 = Space)
  143.         if (Menu.Item("LaughButton").GetValue<KeyBind>().Active)
  144.         {
  145.             // send Laugh every 4.20 seconds
  146.             if (Environment.TickCount > LastLaugh + 4200)
  147.             {
  148.                 // create Laugh emote packet and send it
  149.                 Packet.C2S.Emote.Encoded(new Packet.C2S.Emote.Struct((byte)Packet.Emotes.Laugh)).Send();
  150.  
  151.                 // save last time Laugh was send
  152.                 LastLaugh = Environment.TickCount;
  153.             }
  154.         }
  155.     }
  156.  
  157.     /// <summary>
  158.     /// Main Draw Method
  159.     /// </summary>
  160.     private static void Drawing_OnDraw(EventArgs args)
  161.     {
  162.         // dont draw stuff while dead
  163.         if (Player.IsDead)
  164.             return;
  165.  
  166.         // check if E ready
  167.         if (E.IsReady())
  168.         {
  169.             // draw Aqua circle around the player
  170.             Utility.DrawCircle(Player.Position, Q.Range, Color.Aqua);
  171.         }
  172.         else
  173.         {
  174.             // draw DarkRed circle around the player while on cd
  175.             Utility.DrawCircle(Player.Position, Q.Range, Color.DarkRed);
  176.         }
  177.     }
  178.  
  179.     /// <summary>
  180.     /// Consume logic
  181.     /// </summary>
  182.     private static void Consume()
  183.     {
  184.         // check if the player wants to use Q
  185.         if (!Menu.Item("useQ").GetValue<bool>())
  186.             return;
  187.  
  188.         // check if Q ready
  189.         if (Q.IsReady())
  190.         {
  191.             // get sliders value of 'ConsumeHealth'
  192.             int sliderValue = Menu.Item("ConsumeHealth").GetValue<Slider>().Value;
  193.  
  194.             // calc current percent hp
  195.             float healthPercent = Player.Health / Player.MaxHealth * 100;
  196.  
  197.             // check if we should heal
  198.             if (healthPercent < sliderValue)
  199.             {
  200.                 // get first minion in Q range
  201.                 Obj_AI_Base minion = MinionManager.GetMinions(Player.Position, Q.Range).FirstOrDefault();
  202.  
  203.                 // check if we found a minion to consume
  204.                 if (minion.IsValidTarget())
  205.                 {
  206.                     Q.CastOnUnit(minion); // nom nom nom
  207.                 }
  208.             }
  209.         }
  210.     }
  211.  
  212.     /// <summary>
  213.     /// Bloodboil logic
  214.     /// </summary>
  215.     private static void Bloodboil()
  216.     {
  217.         // check if the player wants to use W
  218.         if (!Menu.Item("useW").GetValue<bool>())
  219.             return;
  220.  
  221.         // check if W ready
  222.         if (W.IsReady())
  223.         {
  224.             // gets best target in a range of 800 units
  225.             Obj_AI_Hero target = SimpleTs.GetTarget(800, SimpleTs.DamageType.Magical);
  226.  
  227.             // check if there is an ally in range to buff, be nice :>
  228.             Obj_AI_Hero ally =
  229.                 ObjectManager.Get<Obj_AI_Hero>()
  230.                     // only get ally + not dead + in W range
  231.                     .Where(hero => hero.IsAlly && !hero.IsDead && Player.Distance(hero) < W.Range)
  232.                     // get the ally with the most AttackDamage
  233.                     .OrderByDescending(hero => hero.FlatPhysicalDamageMod).FirstOrDefault();
  234.  
  235.             // check if we found an ally
  236.             if (ally != null)
  237.             {
  238.                 // check if there is a target in our AttackRange or in our ally AttackRange
  239.                 if (target.IsValidTarget(Player.AttackRange + 100) || ally.CountEnemysInRange((int)ally.AttackRange + 100) > 0)
  240.                 {
  241.                     // buff your ally and yourself
  242.                     W.CastOnUnit(ally);
  243.                 }
  244.             }
  245.  
  246.             // no ally in range to buff, selcast!
  247.             // checks if your target is valid (not dead, not too far away, not in zhonyas etc.)
  248.             // we add +100 to our AttackRange to catch up to the target
  249.             if (target.IsValidTarget(Player.AttackRange + 100))
  250.             {
  251.                 // buff yourself
  252.                 W.CastOnUnit(Player);
  253.             }
  254.         }
  255.     }
  256.  
  257.     /// <summary>
  258.     /// Iceblast logic
  259.     /// </summary>
  260.     private static void Iceblast()
  261.     {
  262.         // check if the player wants to use E
  263.         if (!Menu.Item("useE").GetValue<bool>())
  264.             return;
  265.  
  266.         // gets best target in Dfg(750) / E(550)
  267.         Obj_AI_Hero target = SimpleTs.GetTarget(750, SimpleTs.DamageType.Magical);
  268.  
  269.         // check if dfg ready
  270.         if (Dfg.IsReady())
  271.         {
  272.             // check if we found a valid target in range
  273.             if (target.IsValidTarget(Dfg.Range))
  274.             {
  275.                 // use dfg on him
  276.                 Dfg.Cast(target);
  277.             }
  278.         }
  279.  
  280.         // check if E ready
  281.         if (E.IsReady())
  282.         {
  283.             // check if we found a valid target in range
  284.             if (target.IsValidTarget(E.Range))
  285.             {
  286.                 // blast him
  287.                 E.CastOnUnit(target);
  288.             }
  289.         }
  290.     }
  291.  
  292.     private static void AbsoluteZero()
  293.     {
  294.         // check if the player wants to use R
  295.         if (!Menu.Item("useR").GetValue<bool>())
  296.             return;
  297.  
  298.         // fast lane clear
  299.         // use Nunu R to clear the lane faster
  300.         if (R.IsReady()) // check if R ready
  301.         {
  302.             // get the amount of enemy minions in Ultimate range
  303.             int minionsInUltimateRange = MinionManager.GetMinions(Player.Position, R.Range).Count;
  304.  
  305.             if (minionsInUltimateRange > 10)
  306.             {
  307.                 // cast Ultimate, gold incomming
  308.                 R.CastOnUnit(Player);
  309.             }
  310.         }
  311.     }
  312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement