forked from Screeder/SAwareness
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoPot.cs
More file actions
145 lines (133 loc) · 4.65 KB
/
AutoPot.cs
File metadata and controls
145 lines (133 loc) · 4.65 KB
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
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LeagueSharp;
using LeagueSharp.Common;
namespace SAwareness
{
class AutoPot
{
float lastTimeActive = 0;
private List<Pot> pots = new List<Pot>();
public class Pot
{
public int Id;
public String Buff;
public float LastTime;
public PotType Type;
public Pot()
{
}
public Pot(int id, String buff, PotType type)
{
Id = id;
Buff = buff;
Type = type;
}
public enum PotType
{
None,
Health,
Mana,
Both
}
}
public AutoPot()
{
pots.Add(new Pot(2037, "PotionOfGiantStrengt", Pot.PotType.Health)); //elixirOfFortitude
pots.Add(new Pot(2039, "PotionOfBrilliance", Pot.PotType.Mana)); //elixirOfBrilliance
pots.Add(new Pot(2041, "ItemCrystalFlask", Pot.PotType.Both)); //crystalFlask
pots.Add(new Pot(2009, "ItemMiniRegenPotion", Pot.PotType.Both)); //biscuit
pots.Add(new Pot(2003, "RegenerationPotion", Pot.PotType.Health)); //healthPotion
pots.Add(new Pot(2004, "FlaskOfCrystalWater", Pot.PotType.Mana)); //manaPotion
Game.OnGameUpdate += Game_OnGameUpdate;
}
~AutoPot()
{
Game.OnGameUpdate -= Game_OnGameUpdate;
}
public bool IsActive()
{
return Menu.AutoPot.GetActive();
}
void Game_OnGameUpdate(EventArgs args)
{
if (!IsActive() || ObjectManager.Player.IsDead)
return;
Pot myPot = null;
if (
Menu.AutoPot.GetMenuSettings("SAwarenessAutoPotHealthPot")
.GetMenuItem("SAwarenessAutoPotHealthPotActive")
.GetValue<bool>())
{
foreach (var pot in pots)
{
if (pot.Type == Pot.PotType.Health || pot.Type == Pot.PotType.Both)
{
if (ObjectManager.Player.Health / ObjectManager.Player.MaxHealth * 100 <=
Menu.AutoPot.GetMenuSettings("SAwarenessAutoPotHealthPot")
.GetMenuItem("SAwarenessAutoPotHealthPotPercent")
.GetValue<Slider>().Value)
{
if (!Items.HasItem(pot.Id))
continue;
if (!Items.CanUseItem(pot.Id))
continue;
myPot = pot;
break;
}
}
}
}
if (myPot != null)
UsePot(myPot);
if (
Menu.AutoPot.GetMenuSettings("SAwarenessAutoPotManaPot")
.GetMenuItem("SAwarenessAutoPotManaPotActive")
.GetValue<bool>())
{
foreach (var pot in pots)
{
if (pot.Type == Pot.PotType.Mana || pot.Type == Pot.PotType.Both)
{
if (ObjectManager.Player.Mana / ObjectManager.Player.MaxMana * 100 <=
Menu.AutoPot.GetMenuSettings("SAwarenessAutoPotManaPot")
.GetMenuItem("SAwarenessAutoPotManaPotPercent")
.GetValue<Slider>().Value)
{
if (!Items.HasItem(pot.Id))
continue;
if (!Items.CanUseItem(pot.Id))
continue;
myPot = pot;
break;
}
}
}
}
if (myPot != null)
UsePot(myPot);
}
void UsePot(Pot pot)
{
foreach (var buff in ObjectManager.Player.Buffs)
{
Console.WriteLine(buff.Name);
if (buff.Name.Contains(pot.Buff))
{
return;
}
}
if (pot.LastTime + 5 > Game.Time)
return;
if (!Items.HasItem(pot.Id))
return;
if (!Items.CanUseItem(pot.Id))
return;
Items.UseItem(pot.Id);
pot.LastTime = Game.Time;
}
}
}