forked from KohaPE/Combats
/
AMonk.cs
393 lines (324 loc) · 13.1 KB
/
AMonk.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading.Tasks;
using Anthrax.WoW.Classes.ObjectManager;
using Anthrax.WoW.Internals;
using Anthrax.AI.Controllers;
using Anthrax.WoW;
using Anthrax;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Collections;
using System.ComponentModel;
using System.Threading;
using System.Xml.Serialization;
using System.IO;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// nrgdret AOE/Single Target Rotation Used in this. (well done) //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Anthrax
{
class Monk : Modules.ICombat
{
#region private vars
bool isAOE;
WowLocalPlayer ME;
//Stopwatch stopwatch;
//List<long> averageScanTimes;
#endregion
[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(int vKey);
public override string Name
{
get { return "A Monk by Koha"; } //This is the name displayed in SPQR's Class selection DropdownList
}
#region enums
internal enum Spells : int //This is a convenient list of all spells used by our combat routine
{ //you can have search on wowhead.com for spell name, and get the id in url
KegSmash = 121253,
PuriBrew = 119582,
Jab = 108557,
BOK = 100784,
BoF = 115181,
ExpelHarm = 115072,
RJW = 116847,
TigerPalm = 100787,
Guard = 115295,
DampHarm = 122278,
ElusiveBrew = 115308,
ZP = 124081,
SCK = 101546,
PureBrew = 119582,
ChiWave = 115098,
}
internal enum Auras : int //This is another convenient list of Auras used in our combat routine
{ //you can have those in wowhead.com (again) and get the id in url
ElusiveBrew = 128939,
Elusive = 115308,
Shuffle = 115307,
Guard = 115295,
ZP = 124081,
PG = 118636,
RJW = 116847,
BoF = 123725,
StagL = 12427,
StagM = 124274,
StagH = 124273,
DHaze1 = 123727,
DHaze2 = 116330,
TankCheck = 120267,
TP = 125359,
}
#endregion
public override void OnPatrol()
{
}
// /!\ WARNING /!\
// The OnPull function should NOT be blocking function !
// The bot will handle calling it in loop until the combat is over.
// Blocking function may lead to slow behavior.
public override void OnPull(WoW.Classes.ObjectManager.WowUnit unit)
{
}
#region singleRotation
//public override void OnCombat(WoW.Classes.ObjectManager.WowUnit unit)
//{
//}
private void castNextSpellbySinglePriority(WowUnit TARGET)
{
var MyChi = ObjectManager.LocalPlayer.GetPower(WoW.Classes.ObjectManager.WowUnit.WowPowerType.MonkChi);
var MyEnergy = ObjectManager.LocalPlayer.GetPower(Anthrax.WoW.Classes.ObjectManager.WowUnit.WowPowerType.Energy);
if (TARGET.Health >= 1 && ME.InCombat)
{
if (ME.HasAuraById((int)Auras.TankCheck))
{
//Healing & Survival
{
if (ME.HealthPercent <= 95 && MyChi >= 3 && AI.Controllers.Spell.CanCast((int)Spells.Guard) && ME.HasAuraById((int)Auras.PG) && !ME.HasAuraById((int)Auras.Guard))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.Guard);
return;
}
if (ME.HealthPercent <= 99 && AI.Controllers.Spell.CanCast((int)Spells.ZP) && !ME.HasAuraById((int)Auras.ZP))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ZP);
return;
}
if (ME.HealthPercent <= 80 && MyChi < 4 && AI.Controllers.Spell.CanCast((int)Spells.ExpelHarm))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ExpelHarm);
return;
}
//Defensive
if (MyChi >= 1 && ME.HasAuraById((int)Auras.StagM) || ME.HasAuraById((int)Auras.StagH)
|| MyChi >= 1 && ME.HasAuraById((intAuras.StagL) && ME.Auras.Where(x => x.SpellId == (int)Auras.StagL && x.TimeLeft <= 7000).Any() )
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.PureBrew);
return;
}
if (ME.Auras.Where(x => x.SpellId == (int)Auras.ElusiveBrew && x.StackCount >= 5).Any() &&
AI.Controllers.Spell.CanCast((int)Spells.ElusiveBrew) && !ME.HasAuraById((int)Auras.Elusive)
|| ME.Auras.Where(x => x.SpellId == (int)Auras.ElusiveBrew && x.StackCount >= 15).Any() &&
AI.Controllers.Spell.CanCast((int)Spells.ElusiveBrew) && !ME.HasAuraById((int)Auras.Elusive))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ElusiveBrew);
return;
}
if (ME.HealthPercent <= 94 && AI.Controllers.Spell.CanCast((int)Spells.Guard) && ME.HasAuraById((int)Auras.PG) && !ME.HasAuraById((int)Auras.Guard))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.Guard);
return;
}
//Rotation!!!
if (AI.Controllers.Spell.CanCast((int)Spells.BOK) && !ME.HasAuraById((int)Auras.Shuffle)
|| AI.Controllers.Spell.CanCast((int)Spells.BOK) && ME.Auras.Where(x => x.SpellId == (int)Auras.Shuffle && x.TimeLeft < 12000).Any())
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.BOK);
return;
}
if (AI.Controllers.Spell.CanCast((int)Spells.TigerPalm) && ME.Auras.Where(x => x.SpellId == (int)Auras.TP && x.TimeLeft < 3000).Any()
|| AI.Controllers.Spell.CanCast((int)Spells.TigerPalm) && !ME.HasAuraById((int)Auras.TP))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.TigerPalm);
return;
}
if (MyChi <= 3 && AI.Controllers.Spell.CanCast((int)Spells.KegSmash))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.KegSmash);
return;
}
if (MyChi < 4 && AI.Controllers.Spell.CanCast((int)Spells.Jab))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.Jab);
return;
}
if (MyChi >= 3 && AI.Controllers.Spell.CanCast((int)Spells.BOK))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.BOK);
return;
}
if (AI.Controllers.Spell.CanCast((int)Spells.TigerPalm))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.TigerPalm);
return;
}
}
}
}
}
#endregion
#region AOE>4 rotation
private void castNextSpellbyAOEPriority(WowUnit TARGET)
{
var MyChi = ObjectManager.LocalPlayer.GetPower(WoW.Classes.ObjectManager.WowUnit.WowPowerType.MonkChi);
var MyEnergy = ObjectManager.LocalPlayer.GetPower(Anthrax.WoW.Classes.ObjectManager.WowUnit.WowPowerType.Energy);
if (TARGET.Health >= 1 && ME.InCombat)
{
if (ME.HasAuraById((int)Auras.TankCheck))
{
//Healing & Survival
if (ME.HealthPercent <= 95 && MyChi >= 3 && AI.Controllers.Spell.CanCast((int)Spells.Guard) && ME.HasAuraById((int)Auras.PG) && !ME.HasAuraById((int)Auras.Guard))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.Guard);
return;
}
if (ME.HealthPercent <= 99 && AI.Controllers.Spell.CanCast((int)Spells.ZP) && !ME.HasAuraById((int)Auras.ZP))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ZP);
return;
}
if (ME.HealthPercent <= 80 && MyChi < 4 && AI.Controllers.Spell.CanCast((int)Spells.ExpelHarm))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ExpelHarm);
return;
}
//Defensive
if (MyChi >= 1 && ME.HasAuraById((int)Auras.StagM) || ME.HasAuraById((int)Auras.StagH)
|| MyChi >= 1 && ME.HasAuraById((intAuras.StagL) && ME.Auras.Where(x => x.SpellId == (int)Auras.StagL && x.TimeLeft <= 7000).Any() )
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.PureBrew);
return;
}
if (ME.Auras.Where(x => x.SpellId == (int)Auras.ElusiveBrew && x.StackCount >= 5).Any() &&
AI.Controllers.Spell.CanCast((int)Spells.ElusiveBrew) && !ME.HasAuraById((int)Auras.Elusive)
|| ME.Auras.Where(x => x.SpellId == (int)Auras.ElusiveBrew && x.StackCount >= 15).Any() &&
AI.Controllers.Spell.CanCast((int)Spells.ElusiveBrew) && !ME.HasAuraById((int)Auras.Elusive))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.ElusiveBrew);
return;
}
//ROTATION!!!!
if (TARGET.Position.Distance3DFromPlayer < 8)
{
if (AI.Controllers.Spell.CanCast((int)Spells.RJW) && !ME.HasAuraById((int)Auras.RJW))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.RJW);
return;
}
//Shuffle and Black out Kick
if (AI.Controllers.Spell.CanCast((int)Spells.BOK) && !ME.HasAuraById((int)Auras.Shuffle)
|| AI.Controllers.Spell.CanCast((int)Spells.BOK) && ME.Auras.Where(x => x.SpellId == (int)Auras.Shuffle && x.TimeLeft < 8000).Any())
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.BOK);
return;
}
//Breath of Fire
if (MyChi >= 3 && AI.Controllers.Spell.CanCast((int)Spells.BoF) && TARGET.HasAuraById((int)Auras.DHaze1)
&& ME.Auras.Where(x => x.SpellId == (int)Auras.Shuffle && x.TimeLeft > 8000).Any())
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.BoF);
return;
}
//TigerPalm Buff
if (AI.Controllers.Spell.CanCast((int)Spells.TigerPalm) && ME.Auras.Where(x => x.SpellId == (int)Auras.TP && x.TimeLeft < 3000).Any()
|| AI.Controllers.Spell.CanCast((int)Spells.TigerPalm) && !ME.HasAuraById((int)Auras.TP))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.TigerPalm);
return;
}
//Keg Smash
if (MyChi <= 2 && AI.Controllers.Spell.CanCast((int)Spells.KegSmash))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.KegSmash);
return;
}
if (MyChi < 3 && AI.Controllers.Spell.CanCast((int)Spells.Jab))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.Jab);
return;
}
if (MyChi >= 3 && AI.Controllers.Spell.CanCast((int)Spells.BOK))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.BOK);
return;
}
if (AI.Controllers.Spell.CanCast((int)Spells.TigerPalm))
{
WoW.Internals.ActionBar.ExecuteSpell((int)Spells.TigerPalm);
return;
}
}
}
}}
#endregion
#region auxFunctions
public void changeRotation()
{
if (isAOE)
{
Console.Beep(5000, 100);
isAOE = false;
Logger.WriteLine("Rotation Single!!");
}
else
{
Console.Beep(5000, 100);
Console.Beep(5000, 100);
Console.Beep(5000, 100);
isAOE = true;
Logger.WriteLine("Rotation AOE!!");
}
}
#endregion
public override void OnCombat(WowUnit TARGET)
{
/* Performance tests
stopwatch.Stop();
averageScanTimes.Add(stopwatch.ElapsedMilliseconds);
SPQR.Logger.WriteLine("Elapsed: " + stopwatch.ElapsedMilliseconds.ToString() + " miliseconds, average:" + (averageScanTimes.Sum() / averageScanTimes.Count()).ToString() + ",Max:" + averageScanTimes.Max());
stopwatch.Restart();
*/
if (!Cooldown.IsGlobalCooldownActive && TARGET.IsValid)
{
if (isAOE) { castNextSpellbyAOEPriority(TARGET); } else { castNextSpellbySinglePriority(TARGET); }
}
if ((GetAsyncKeyState(90) == -32767))
{
changeRotation();
}
}
public override void OnLoad() //This is called when the Customclass is loaded in SPQR
{
Logger.WriteLine("CustomClass " + Name + " Loaded");
}
public override void OnUnload() //This is called when the Customclass is unloaded in SPQR
{
Logger.WriteLine("CustomClass " + Name + " Unloaded, Goodbye !");
}
public override void OnBotStart() //This is called once, when you hit CTRL+X to start SPQR combat routine
{
ME = ObjectManager.LocalPlayer;
Logger.WriteLine("Launching " + Name + " routine... enjoy! Press z to switch between single/aoe");
/* Performance tests
stopwatch=new Stopwatch();
averageScanTimes = new List<long>();
*/
}
public override void OnBotStop() //This is called once, when you hit CTRL+X to stop SPQR combat routine
{
Logger.WriteLine("Stopping " + Name + " routine... gl smashing keys.");
}
}}