-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3.mac
executable file
·557 lines (445 loc) · 14.4 KB
/
p3.mac
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
| todo:
| add hott type for heals
| summon a pet
| check stackability on debuffs
|
#include p3_events.inc
#include p3_global.inc
#include p3_movement.inc
#include p3_casting.inc
#include p3_spellcombat.inc
#include p3_meleecombat.inc
#include p3_targetting.inc
#include p3_assist_tags.inc
#include p3_autoabilities.inc
#include p3_buffs.inc
#include p3_heals.inc
#include p3_assist.inc
#include p3_buffrequests.inc
#include p3_bardtwist.inc
#include p3_slay.inc
#include p3_camp.inc
#include p3_retreat.inc
#include p3_castorders.inc
#include p3_roam.inc
#include p3_automed.inc
#include p3_exptrack.inc
#include p3_autotrapdisarm.inc
#include p3_tank.inc
#include p3_autodebuff.inc
#include p3_automez.inc
#include p3_autodispell.inc
#include p3_charm.inc
#include p3_autoloot.inc
#include p3_tribute.inc
#include p3_manastone.inc
#include p3_petcontrol.inc
#include p3_mine.inc
#include p3_eqemu.inc
#turbo 240
SUB MAIN {
|/wire drawchaton
|/wire BGRenderRate 100
/declare p3version string outer 0.11C
/echo p3 alpha [${p3version}]: Starting...
/declare debugEcho bool outer FALSE
/declare cq list outer
/declare cqHead string outer
/declare commands list outer
/declare modules list outer
/declare navPlugin bool outer FALSE
/declare perfLog list outer
/declare perfStart int outer
/declare perfIdle int outer
/declare p3paused bool outer FALSE
/declare st int local
/declare et int local
/declare hardLoopReset bool outer FALSE
/declare lastZonedMark int64 outer ${Me.LastZoned}
/declare recentlyZoned bool outer FALSE
/declare recentlyZonedCheckTimer timer outer 0
/invoke ${cq.Delimiter[^]}
/invoke ${modules.Append[global,eqemu,assist_tags,targetting,slay,movement,casting,castorders,charm,autoloot,automez,autodebuff,assist,petcontrol,tank,exptrack,automed,manastone,heals,meleecombat,spellcombat,autoabilities,buffs,buffrequests,bardtwist,camp,retreat,roam,autotrapdisarm,autodispell,tribute,mine]}
/call importCommandLine "${Param0}" "${Param1}" "${Param2}" "${Param3}" "${Param4}"
/call p3Setup
/call checkPlugins
/call initializeModules
/echo p3 alpha:Startup complete.
/setwintitle ${Me.CleanName}
/varset perfStart ${MacroQuest.Running}
/while (1) {
/if (${p3paused}==TRUE) {
/delay 3
/doevents
/continue
}
/if (!${MacroQuest.GameState.Equal[INGAME]}) /end
/if (!${Bool[${Me.Class}]}) /endmacro
/call checkZoning
/call checkCommandQueue
/if (${cq.Count}>0) /continue
/call checkMaintenance
/varset st ${MacroQuest.Running}
/delay 1
/varset et ${MacroQuest.Running}
/varset perfIdle ${Math.Calc[${perfIdle}+ (${et}-${st})]}
}
/END
}
SUB checkZoning {
/if (${Me.LastZoned}!=${lastZonedMark}) {
/varset lastZonedMark ${Me.LastZoned}
/varset recentlyZoned TRUE
/varset recentlyZonedCheckTimer ${holdDelayDuration}
/bc ZONED!
/invoke ${cq.Clear}
/invoke (${cq.Append[ZONECHANGE;]})
/delay 30
} else {
/if (${recentlyZoned} == TRUE && ${recentlyZonedCheckTimer}==0) {
/varset recentlyZoned FALSE
}
}
/RETURN
}
SUB checkMaintenance {
/declare i int local
/declare st int local
/declare et int local
/for i 0 to ${Math.Calc[ ${modules.Count}-1 ]}
/doevents
/if (${hardLoopReset}==TRUE) {
/varset hardLoopReset FALSE
/break
}
/varset st ${MacroQuest.Running}
/if (${debugEcho}==TRUE) /echo ${modules.Item[${i}]}Maintenance
/call ${modules.Item[${i}]}Maintenance
/varset et ${MacroQuest.Running}
/varset p3_${modules.Item[${i}]}_perftime ${Math.Calc[${p3_${modules.Item[${i}]}_perftime} + (${et}-${st})]}
/if (${Macro.Return.Equal[RESET]}) {
/if (${debugEcho}==TRUE) /echo ${modules.Item[${i}]}Maintenance returned RESET.
/break
}
/next i
/RETURN
}
SUB checkCommandQueue {
/declare root string local
/declare opts string local
/declare i int local
/if (${cq.Count}==0) /return FALSE
/varset cqHead ${cq.Head}
/varset root ${cqHead.Token[1,;]}
/if (${Defined[commandStack${root}]}==FALSE) {
/echo Unknown root command: ${root}
/return
} else {
/for i 0 to ${Math.Calc[ ${commandStack${root}.Count}-1 ]}
|/echo /call ${commandStack${root}.Item[${i}].Token[2,:]} "${root}" "${cqHead}"
/call ${commandStack${root}.Item[${i}].Token[2,:]} "${root}" "${cqHead}"
/if (${Macro.Return.Equal[RESET]}) {
/echo FALSE caught. Abanoning chain: ${commandStack${root}.Item[${i}].Token[2,:]}
/break
}
/next i
}
/RETURN
}
SUB importCommandLine(string Param0, string Param1, string Param2, string Param3, string Param4, string Param5) {
/declare commandLine[8] string outer
/declare cmdINI string outer 1
/declare cmdTAGS string outer 2
/declare cmdDEBUG string outer 3
/declare cmdDIRECTINI string outer 4
/declare cmdPAST string outer 5
/declare opts list local
/invoke ${opts.Delimiter[|]}
/declare i int local
/declare k string local
/declare v string local
/if (${Bool[${Param0}]}==TRUE) {
/invoke ${opts.Append[${Param0}]}
}
/if (${Bool[${Param1}]}==TRUE) {
/invoke ${opts.Append[${Param1}]}
}
/if (${Bool[${Param2}]}==TRUE) {
/invoke ${opts.Append[${Param2}]}
}
/if (${Bool[${Param3}]}==TRUE) {
/invoke ${opts.Append[${Param3}]}
}
/if (${Bool[${Param4}]}==TRUE) {
/invoke ${opts.Append[${Param4}]}
}
/if (${Bool[${Param5}]}==TRUE) {
/invoke ${opts.Append[${Param5}]}
}
/if (${opts.Count}==0) /RETURN
/for i 0 to ${Math.Calc[ ${opts.Count}-1 ]}
/varset k ${opts.Item[${i}].Token[1,=].Upper}
/varset v ${opts.Item[${i}].Token[2,=]}
/if (${Defined[cmd${k}]}==TRUE) {
/varset commandLine[${cmd${k}}] ${v}
}
/next i
/RETURN
}
SUB p3Setup {
/declare generalIniFile string outer p3_bots\general.ini
/declare defaultMeleeCombatClasses string outer BRD,BER,BST,MNK,PAL,RNG,ROG,SHD,WAR
/declare defaultSpellCombatClasses string outer CLR,DRU,NEC,WIZ,MAG,ENC,SHM
/declare manaClasses string outer CLR,DRU,ENC,PAL,BRD,WIZ,MAG,SHM,NEC,BST,SHD
/declare manaRegenClasses string outer CLR,DRU,ENC,PAL,WIZ,MAG,SHM,BST,SHD
/declare hasteClasses string outer MNK,ROG,WAR,RNG,BST,SHD,BER
/declare meleeClasses string outer BRD,BER,BST,MNK,PAL,RNG,ROG,SHD,WAR
/declare priestClasses string outer CLR,DRU,SHM
/declare hybridClasses string outer PAL,BST,BRD,RNG
/declare pureCasterClasses string outer ENC,MAG,NEC,WIZ
/declare rangedClasses string outer CLR,DRU,SHM,ENC,MAG,NEC,WIZ
/declare castWhileMovingClasses string outer ROG,MNK,BRD
/declare tankClasses string outer WAR,PAL,SHD
/declare knightClasses string outer PAL,SHD
/declare canCastWhileMoving bool outer ${Me.Class.ShortName.Equal[BRD]}
/declare amBard bool outer ${Me.Class.ShortName.Equal[BRD]}
/declare cfNone int outer 0
/declare cfMoving int outer 1
/declare cfNaving int outer 2
/declare cfSticking int outer 4
/declare cfCasting int outer 8
/declare cfInvis int outer 16
/squelch /moveto set dist 10
/squelch /netbots on
/squelch /netbots grab=on
/squelch /netbots send=on
/squelch /netbots ext=on
/RETURN
}
SUB initializeModules {
/declare i int local
/for i 0 to ${Math.Calc[ ${modules.Count}-1 ]}
/declare p3_${modules.Item[${i}]}_perftime int outer
/call p3_${modules.Item[${i}]}_init
/next i
/for i 0 to ${Math.Calc[ ${commands.Count}-1 ]}
/invoke ${commandStack${commands.Item[${i}]}.Sort}
/next i
/RETURN
}
SUB checkPlugins () {
/if (${Plugin[MQ2EQBC].Name.Length}==NULL) {
/echo >>> MQ2EQBC not loaded. Cannot continue. Ending.
/end
}
/if (${Plugin[MQ2Dannet].Name.Length}==NULL) {
/echo >>> MQ2Dannet not loaded. ExtendedStackCheck flag will not function.
}
/if (${Plugin[MQ2Collections].Name.Length}==NULL) {
/echo >>> MQ2Collections not loaded. Cannot continue. Ending.
/end
}
/if (${Bool[${EQBC}]}) {
/if (!${EQBC.Connected}) {
/bccmd connect
/delay 100 ${EQBC.Connected}
/delay 5
/if (!${EQBC.Connected}) /echo >>> Could not connect to EQBCS. Macro functionality will be very limited.
}
}
/if (${Plugin[MQ2NetBots].Name.Length}==NULL) {
/echo MQ2NetBots not loaded. Cannot continue. Ending.
/end
} else {
/if (${NetBots}) {
/squelch /netbots on grab=on send=on
}
}
/if (${Plugin[MQ2Nav].Name.Length}==NULL) {
/echo MQ2Nav Plugin not loaded. Some movements mechanics will be limited.
} else {
/varset navPlugin TRUE
}
/if (${Plugin[MQ2MoveUtils].Name.Length}==NULL) {
/echo MQ2MoveUtils not loaded. Cannot continue. Ending.
/end
}
/RETURN
}
SUB p3RegisterCommand(string cmd, string funcName, string order) {
/varset order ${strPad[${order}]}
/varset cmd ${cmd.Upper}
/declare stackName string local commandStack${cmd}
/if (${commands.Contains[${cmd}]}==FALSE) {
/invoke ${commands.Append[${cmd}]}
}
/if (${Defined[${stackName}]}==FALSE) {
/declare ${stackName} list outer
}
/invoke ${${stackName}.Append[${order}:${funcName}]}
/RETURN
}
SUB getStackCommandOpt (string opts, string k) {
/declare sp int local ${opts.Find[;${k}=]}
/declare ret string local -
/if (${sp}!=NULL) {
/varset ret ${opts.Right[-${sp}].Token[1,;].Token[2,=]}
}
/RETURN ${ret}
}
SUB getBotIniOption(string opt, string defaultResponse, string iniSource) {
/if (${iniSource.Length}==0) /varset iniSource bot
/declare iniKey string local
/declare iniValue string local
/declare useSource string local
/if (${iniSource.Equal[general]}) /varset useSource ${generalIniFile}
/if (${iniSource.Equal[bot]}) /varset useSource ${botIniFile}
/declare response string local
/varset iniKey ${useSource},${opt.Token[1,.]},${opt.Token[2,.]}
/varset iniValue ${Ini[${iniKey}]}
/if (${iniValue.Equal[NULL]}) {
/if (${defaultResponse.Equal[FALSE]}) /varset defaultResponse NO
/if (${defaultResponse.Equal[TRUE]}) /varset defaultResponse YES
/call writeBotIniOption "${opt}" "${defaultResponse}" ${iniSource}
/varset response ${defaultResponse}
} else {
/varset response ${iniValue}
}
/if (${response.Upper.Equal[ON]} || ${response.Upper.Equal[YES]} || ${response.Upper.Equal[TRUE]}) {
/RETURN TRUE
} else /if (${response.Upper.Equal[OFF]} || ${response.Upper.Equal[FALSE]} || ${response.Upper.Equal[NO]} || ${response.Upper.Equal[NONE]} || ${response.Upper.Equal[-]}) {
/RETURN FALSE
} else {
/RETURN ${response}
}
/RETURN
}
SUB writeBotIniOption(string opt, string value, string iniSource) {
/if (${iniSource.Length}==0) /varset iniSource bot
/if (${iniSource.Equal[BOT]}) {
/ini "${botIniFile}" "${opt.Arg[1,.]}" "${opt.Arg[2,.]}" "${value}"
} else {
/ini "${generalIniFile}" "${opt.Arg[1,.]}" "${opt.Arg[2,.]}" "${value}"
}
/RETURN
}
SUB getSpellFromCastRequest(string castRequest) {
/if (${FindItemCount[=${castRequest}]}>0) /return FindItem[=${castRequest}].Spell
/if (${Spell[${castRequest}].ID}) /return Spell[${castRequest}]
/if (${Me.AltAbility[${castRequest}].ID}) /return Me.AltAbility[${castRequest}].Spell
/if (${Me.CombatAbility[${castRequest}].ID}) {
/return Spell[${castRequest}]
|/varset combatAbilityIndex ${Me.CombatAbility[${castRequest}]}
|/return CombatAbility[${combatAbilityIndex}]
}
/if (${Me.Ability[${castRequest}]}!=NULL) /return ABILITY
/RETURN UNKNOWN
}
SUB isLockoutExpired(string timerName) {
/if (${Defined[${timerName}]}==TRUE) {
|/echo ${timerName} was defined. val: ${${timerName}}
/if (${${timerName}}==0) {
/deletevar ${timerName}
/return TRUE
} else {
/return FALSE
}
}
/return TRUE
}
SUB lockout(string timerName, string dur) {
/if (${dur.Right[1].Equal[s]}) {
/varset dur ${Math.Calc[${dur.Left[-1]}*10]}
}
/if (${Defined[${timerName}]}==TRUE) {
/if (${${timerName}}<${dur}) {
/varset ${timerName} ${dur}
}
} else {
/echo /declare ${timerName} timer outer ${dur}
/declare ${timerName} timer outer ${dur}
}
/RETURN
}
SUB wipeLockout(string timerName) {
/if (${Defined[${timerName}]}==TRUE) {
/deletevar ${timerName}
}
/RETURN
}
SUB isCastReady(string request) {
/declare castType string local
/call getCastTypeByCastRequest "${request}"
/varset castType ${Macro.Return}
/if (${castType.Equal[UNKNOWN]}) /return FALSE
/if (${Me.Silenced.ID}!=NULL) /return FALSE
/if (${castType.Equal[SPELL]}) {
/if (${Me.Class.ShortName.Equal[BRD]} && ${Me.SpellInCooldown}==TRUE) /RETURN TRUE
/if (${Me.SpellReady[${request}]}==FALSE) /RETURN FALSE
/if (${Me.CurrentMana}<${Spell[${request}].Mana}) /RETURN FALSE
}
/if (${castType.Equal[ALTABILITY]} && ${Me.AltAbilityReady[${request}]}==FALSE) /return FALSE
/if (${castType.Equal[ITEM]} && ${Me.ItemReady[${request}]}==FALSE) /return FALSE
/if (${castType.Equal[SPELL]} && ${Me.SpellInCooldown}==TRUE && ${Me.Class.ShortName.NotEqual[BRD]}) /return FALSE
|/if (${castType.Equal[DISCIPLINE]} && ${Me.ActiveDisc.ID}!=NULL) /return FALSE
/if (${castType.Equal[DISCIPLINE]} && ${Me.CombatAbilityReady[${request}]}==FALSE) /return FALSE
/if (${castType.Equal[ABILITY]} && ${Me.AbilityReady[${Me.Ability[${request}]}]}==FALSE) /return FALSE
/return TRUE
}
SUB getCastTypeByCastRequest(string castRequest) {
/if (${Me.AltAbility[${castRequest}].ID}) /return ALTABILITY
/if (${Me.CombatAbility[${castRequest}]}) /return DISCIPLINE
| changed to me.spell because bash was showing up with just "spell"
/if (${Me.Spell[${castRequest}].ID}) /return SPELL
/if (${FindItemCount[${castRequest}]}) /return ITEM
/if (${Me.Ability[${castRequest}]}!=NULL) /return ABILITY
/RETURN UNKNOWN
}
SUB p3command(string cmd) {
/varset cmd ${cmd.Replace[`,\\"].Replace[\,]}
/if (${cmd.Find[!!]}!=NULL) {
/echo ${cmd.Replace[!!,$]}
/docommand ${cmd.Replace[!!,$]}
} else {
/docommand ${cmd}
}
/RETURN
}
SUB iniSectionExists(string sectionName) {
/declare i int local
/varset i ${Select[${sectionName},${Ini[${botIniFile}].Replace[|,,]}]}
/if (${i}==0) /RETURN FALSE
/RETURN TRUE
}
SUB getSpellDurationByRequestName(string castRequest) {
/declare s spell local
/call getSpellFromCastRequest "${castRequest}"
/if (${Macro.Return.Equal[UNKNOWN]}) /RETURN 0
/if (${Macro.Return.Equal[ABILITY]}) {
/bc Warning: getSpellDurationByRequestName() performed against an ABILITY. Defaulting to 3 seconds.
/RETURN 3
}
/vardata s ${Macro.Return}
/RETURN ${s.MyDuration.TotalSeconds}
}
SUB MathDistanceXYZ(string x, string y, string z) {
/RETURN ${Math.Distance[${y} ${x} ${z}]}
}
SUB checkOpenWindows() {
/if (${Window[BigBankWnd].Open}) /return TRUE
/if (${Window[TradeWnd].Open}) /return TRUE
/if (${Window[GuildBankWnd].Open}) /return TRUE
/if (${Window[MerchantWnd].Open}) /return TRUE
/if (${Window[SpellBookWnd].Open}) /return TRUE
/return FALSE
}
SUB clearStackActions(string action) {
/declare i int local
/if (${cq.Count}==0) /return
/for i ${Math.Calc[${cq.Count}-1]} downto 0
/if (${cq.Item[${i}].Token[1,;].Equal[${action}]}) {
/invoke ${cq.Erase[${i}]}
}
/next i
/RETURN
}