-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chicken.cpp
268 lines (226 loc) · 5.69 KB
/
Chicken.cpp
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#include "DevilPK.h"
int DrankHealthPot;
int DrankManaPot;
int DrankRejLife;
int DrankRejMana;
void ChickenCheck(void)
{
if(GameReady())
{
UnitAny *pUnit = D2CLIENT_GetPlayerUnit();
if(pUnit)
{
int LifePercent=((GetCurrentLife())*100)/(GetMaxLife());
int ManaPercent=((GetCurrentMana())*100)/(GetMaxMana());
int CurrentLife=GetCurrentLife();
if(pUnit->dwMode == PLAYER_MODE_DEAD || pUnit->dwMode == PLAYER_MODE_DEATH) return;
if(cfg.Drink && cfg.DrinkLife > 0 && LifePercent <= cfg.DrinkLife && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
if(DrankHealthPot == -1 || GetTickCount() - DrankHealthPot > cfg.DrinkLifeTimer
&& !D2COMMON_GetUnitState(Myself,AFFECT_HEALTHPOT))
{
if(SupplyHealth())
{
DrankHealthPot = GetTickCount(); Sleep(50);
}
}
}
if(cfg.Drink && cfg.DrinkMana > 0 && ManaPercent <= cfg.DrinkMana && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
if(DrankManaPot == -1 || GetTickCount() - DrankManaPot > cfg.DrinkManaTimer
&& !D2COMMON_GetUnitState(Myself,AFFECT_MANAPOT))
{
if(SupplyMana())
{
DrankManaPot = GetTickCount(); Sleep(50);
}
}
}
if(cfg.Drink && cfg.DrinkLifeRej > 0 && LifePercent <= cfg.DrinkLifeRej && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
if(DrankRejLife == -1 || GetTickCount() - DrankRejLife > cfg.DrinkRejuTimer)
{
if(SupplyJuv())
{
DrankRejLife = GetTickCount(); Sleep(50);
}
else if(cfg.QuitOnJuvRunOut) D2CLIENT_ExitGame();
}
}
if(cfg.Drink && cfg.DrinkManaRej > 0 && ManaPercent <= cfg.DrinkManaRej && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
if(DrankRejMana == -1 || GetTickCount() - DrankRejMana > cfg.DrinkRejuTimer)
{
if(SupplyJuv())
{
DrankRejMana = GetTickCount(); Sleep(50);
}
else if(cfg.QuitOnJuvRunOut) D2CLIENT_ExitGame();
}
}
if(cfg.TownLifeChicken!=0 && LifePercent<=cfg.TownLifeChicken && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
else TownLife();
}
if(cfg.TownManaChicken!=0 && ManaPercent<=cfg.TownManaChicken && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
else TownMana();
}
if(cfg.QuitLife!=0 && LifePercent <= cfg.QuitLife && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
else D2CLIENT_ExitGame();
}
if(cfg.QuitMana!=0 && ManaPercent<=cfg.QuitMana && CurrentLife > 0)
{
if(IsTownLevel(GetPlayerArea())) return;
else D2CLIENT_ExitGame();
}
}
}
}
void TownLife()
{
int LifePercent=((GetCurrentLife())*100)/(GetMaxLife());
int ManaPercent=((GetCurrentMana())*100)/(GetMaxMana());
int CurrentLife=GetCurrentLife();
TakeNextTP=true; v_AntiTppkBusy=true;
if(MakeTP())
{
Sleep(250);
if(cfg.QuitOnFailedTP && !IsTownLevel(GetPlayerArea()) && LifePercent <= cfg.TownLifeChicken
&& CurrentLife > 0) D2CLIENT_ExitGame();
else return;
}
else
{
v_AntiTppkBusy=false; D2CLIENT_ExitGame();
}
}
void TownMana()
{
int LifePercent=((GetCurrentLife())*100)/(GetMaxLife());
int ManaPercent=((GetCurrentMana())*100)/(GetMaxMana());
int CurrentLife=GetCurrentLife();
TakeNextTP=true; v_AntiTppkBusy=true;
if(MakeTP())
{
Sleep(250);
if(cfg.QuitOnFailedTP && !IsTownLevel(GetPlayerArea()) && ManaPercent<=cfg.TownManaChicken
&& CurrentLife > 0) D2CLIENT_ExitGame();
else return;
}
else
{
v_AntiTppkBusy=false; D2CLIENT_ExitGame();
}
}
char* PotionName(DWORD dwTxtFileNo)
{
switch(dwTxtFileNo)
{
case 515:
{
return "Rejuvenation";
}
case 516:
{
return "Full Rejuvenation";
}
case 587:
{
return "Minor Healing";
}
case 588:
{
return "Light Healing";
}
case 589:
{
return "Healing";
}
case 590:
{
return "Greater Healing";
}
case 591:
{
return "Super Healing";
}
case 592:
{
return "Minor Mana";
}
case 593:
{
return "Light Mana";
}
case 594:
{
return "Mana";
}
case 595:
{
return "Greater Mana";
}
case 596:
{
return "Super Mana";
}
default:
{
return "Unknown";
}
}
}
BOOL SupplyHealth()
{
LPSTR szItemCodes[] = {"hp5", "hp4", "hp3", "hp2", "hp1"};
UnitAny* pItem;
for(INT i = 0; i < ArraySize(szItemCodes); i++)
{
pItem = FindItem(szItemCodes[i], STORAGE_BELT);
if(!pItem) pItem = FindItem(szItemCodes[i], STORAGE_INVENTORY);
if(!pItem) continue;
UseItem(pItem);
if(cfg.PrintIHPKMessages) PrintDevilPKString("Auto Potion drank a %s potion!",PotionName(pItem->dwTxtFileNo));
return TRUE;
}
return FALSE;
}
BOOL SupplyMana()
{
LPSTR szItemCodes[] = {"mp5", "mp4", "mp3", "mp2", "mp1"};
UnitAny* pItem;
for(INT i = 0; i < ArraySize(szItemCodes); i++)
{
pItem = FindItem(szItemCodes[i], STORAGE_BELT);
if(!pItem) pItem = FindItem(szItemCodes[i], STORAGE_INVENTORY);
if(!pItem) continue;
UseItem(pItem);
if(cfg.PrintIHPKMessages) PrintDevilPKString("Auto Potion drank a %s potion!",PotionName(pItem->dwTxtFileNo));
return TRUE;
}
return FALSE;
}
BOOL SupplyJuv()
{
LPSTR szItemCodes[] = {"rvl", "rvs"};
UnitAny* pItem;
for(INT i = 0; i < ArraySize(szItemCodes); i++)
{
pItem = FindItem(szItemCodes[i], STORAGE_BELT);
if(!pItem) pItem = FindItem(szItemCodes[i], STORAGE_INVENTORY);
if(!pItem) continue;
UseItem(pItem);
if(cfg.PrintIHPKMessages) PrintDevilPKString("Auto Potion drank a %s potion!",PotionName(pItem->dwTxtFileNo));
return TRUE;
}
return FALSE;
}