forked from ikkeflikkeri/LeagueSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Champion.cs
139 lines (113 loc) · 4.48 KB
/
Champion.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections.Generic;
using System.Linq;
using LeagueSharp;
using LeagueSharp.Common;
public abstract class Champion
{
protected Obj_AI_Hero Player;
protected MenuWrapper Menu;
protected SkinManager Skins;
protected Spell Q;
protected Spell W;
protected Spell E;
protected Spell R;
protected Dictionary<string, MenuWrapper.BoolLink> BoolLinks = new Dictionary<string, MenuWrapper.BoolLink>();
protected Dictionary<string, MenuWrapper.CircleLink> CircleLinks = new Dictionary<string, MenuWrapper.CircleLink>();
protected Dictionary<string, MenuWrapper.KeyBindLink> KeyLinks = new Dictionary<string, MenuWrapper.KeyBindLink>();
protected Dictionary<string, MenuWrapper.SliderLink> SliderLinks = new Dictionary<string, MenuWrapper.SliderLink>();
protected List<Obj_AI_Hero> Enemies;
private const int tick = 1000 / 20;
private int lastTick = Environment.TickCount;
private string targetChampion;
protected Champion(string championName)
{
targetChampion = championName;
CustomEvents.Game.OnGameLoad += OnGameLoad;
}
~Champion()
{
CustomEvents.Game.OnGameLoad -= OnGameLoad;
Game.OnUpdate -= OnUpdate;
Drawing.OnDraw -= OnDraw;
Drawing.OnEndScene -= OnEndScene;
AntiGapcloser.OnEnemyGapcloser -= OnEnemyGapcloser;
Interrupter.OnPossibleToInterrupt -= OnPossibleToInterrupt;
}
private void OnGameLoad(EventArgs args)
{
if(ObjectManager.Player.ChampionName.ToLower() != targetChampion.ToLower())
return;
Player = ObjectManager.Player;
Skins = new SkinManager();
OnInitSpells();
OnInit();
OnInitSkins();
Menu = new MenuWrapper("Easy" + Player.ChampionName);
Skins.AddToMenu(Menu.MainMenu);
OnInitMenu();
BoolLinks.Add("packets", Menu.MainMenu.AddLinkedBool("Use packet cast", true));
Game.OnUpdate += OnUpdate;
Drawing.OnDraw += OnDraw;
Drawing.OnEndScene += OnEndScene;
AntiGapcloser.OnEnemyGapcloser += OnEnemyGapcloser;
Interrupter.OnPossibleToInterrupt += OnPossibleToInterrupt;
Spellbook.OnCastSpell += OnCastSpell;
Obj_AI_Hero.OnProcessSpellCast += OnProcessSpellCast;
Game.PrintChat("Easy" + Player.ChampionName + " is loaded! Skin Changer does not work!");
}
protected bool IsPacketCastEnabled()
{
return BoolLinks["packets"].Value;
}
private void OnUpdate(EventArgs args)
{
if (Environment.TickCount < lastTick + tick) return;
lastTick = Environment.TickCount;
Spells.PacketCast = IsPacketCastEnabled();
Enemies = ObjectManager.Get<Obj_AI_Hero>().Where(x => x.IsEnemy && x.IsValidTarget()).ToList();
OnUpdate();
if (Player.IsWindingUp || Player.IsDashing()) return;
bool minionBlock = MinionManager.GetMinions(Player.Position, Player.AttackRange, MinionTypes.All, MinionTeam.Enemy, MinionOrderTypes.None).Count(x => HealthPrediction.GetHealthPrediction(x, 1500) <= Player.GetAutoAttackDamage(x)) > 0;
switch (Menu.Orbwalker.ActiveMode)
{
case Orbwalking.OrbwalkingMode.Combo:
OnCombo();
break;
case Orbwalking.OrbwalkingMode.Mixed:
if (!minionBlock) OnHarass();
break;
case Orbwalking.OrbwalkingMode.LaneClear:
case Orbwalking.OrbwalkingMode.LastHit:
default:
if (!minionBlock) OnAuto();
break;
}
}
private void OnDraw(EventArgs args)
{
OnDraw();
}
private void OnEndScene(EventArgs args)
{
OnEndScene();
}
protected SpellDataInst GetSpellData(SpellSlot spell)
{
return Player.Spellbook.GetSpell(spell);
}
protected virtual void OnInit() { }
protected virtual void OnInitSpells() { }
protected virtual void OnInitSkins() { }
protected virtual void OnInitMenu() { }
protected virtual void OnUpdate() { }
protected virtual void OnDraw() { }
protected virtual void OnEndScene() { }
protected virtual void OnCombo() { }
protected virtual void OnHarass() { }
protected virtual void OnAuto() { }
protected virtual void OnEnemyGapcloser(ActiveGapcloser gapcloser) { }
protected virtual void OnPossibleToInterrupt(Obj_AI_Base unit, InterruptableSpell spell) { }
protected virtual void OnCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args) { }
protected virtual void OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { }
}