-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3a.mac
7618 lines (5865 loc) · 212 KB
/
p3a.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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SUB p3_assist_init {
/call p3RegisterCommand STOP assistStop 50
/call p3RegisterCommand FOLLOW assistFollow 50
/call p3RegisterCommand KILL assistKill 40
/call p3RegisterCommand KILL assistKillNameCheck 1
/call p3RegisterCommand KILL assistKillNoTouchCheck 2
/call p3RegisterCommand KILL assistKillLockCheck 5
/declare assistSpawnID int outer 0
/declare assistSpawnIDZone int outer 0
/declare combatStateCheckTimer timer outer 0
/declare combatStateTimer timer outer 0
/declare combatStateTimerMax int outer 50
/declare combatStateLongTimer timer outer 0
/declare combatStateLongTimerMax int outer 150
/declare assistTime timer outer 0
/declare assistLock bool outer FALSE
/declare assistMustHaveName string outer -
/declare assistMustNotHaveName string outer -
/declare noTouchIDs list outer
/declare autoAssistHoldTimer timer outer 0
/declare autoAssistCheckTimer timer outer 0
/declare autoAssist bool outer TRUE
/declare maxAssistDistance int outer 500
/declare useAutoFire bool outer FALSE
/declare autoAssistPercent int outer 99
/declare useEQCombatIndicator bool outer FALSE
/varset autoAssist ${getBotIniOption[Assist.AutoAssist,${autoAssist}]}
/varset autoAssistPercent ${getBotIniOption[Assist.AutoAssistPercent,${autoAssistPercent}]}
/varset maxAssistDistance ${getBotIniOption[Assist.MaxAssistDistance,${maxAssistDistance}]}
/varset useAutoFire ${getBotIniOption[Assist.UseAutoFire,${useAutoFire}]}
/varset assistMustHaveName ${getBotIniOption[Assist.MustHaveName,${assistMustHaveName}]}
/varset assistMustNotHaveName ${getBotIniOption[Assist.MustNotHaveName,${assistMustNotHaveName}]}
/varset useEQCombatIndicator ${getBotIniOption[Misc.CombatStateUsesGameIndicator,${useEQCombatIndicator}]}
/RETURN
}
SUB assistKillNoTouchCheck(string cmd, string opts) {
/declare checkSpawnID string local
/varset checkSpawnID ${getStackCommandOpt[${opts},SPAWNID]}
/if (${noTouchIDs.Contains[${checkSpawnID}]}) {
/bc Won't attack spawnID ${checkSpawnID}. Marked as no-touch.
/RETURN RESET
}
/RETURN
}
SUB assistKillNameCheck(string cmd, string opts) {
/declare checkSpawnID int local
/if (${assistMustHaveName.NotEqual[FALSE]}) {
/varset checkSpawnID ${getStackCommandOpt[${opts},SPAWNID]}
/if (${Spawn[id ${checkSpawnID}].CleanName.Upper.Find[${assistMustHaveName.Upper}]}==NULL) /RETURN RESET
}
/if (${assistMustNotHaveName.NotEqual[FALSE]}) {
/varset checkSpawnID ${getStackCommandOpt[${opts},SPAWNID]}
/if (${Spawn[id ${checkSpawnID}].CleanName.Upper.Find[${assistMustNotHaveName.Upper}]}!=NULL) /RETURN RESET
}
/RETURN
}
SUB assistAddNoTouchID(string spawnID) {
/if (${noTouchIDs.Contains[${spawnID}]}==TRUE) /return
/invoke ${noTouchIDs.Append[${spawnID}]}
/bc Added ${spawnID} as a no-touch mob.
/RETURN
}
SUB assistKillLockCheck(string cmd, string opts) {
|/if (${assistLock}==TRUE) /RETURN RESET
/RETURN
}
SUB assistKill(string cmd, string opts) {
/declare checkSpawnID ${getStackCommandOpt[${opts},SPAWNID]}
/declare sourceName string local ${getStackCommandOpt[${opts},AUTHOR]}
/if (${Spawn[=${sourceName}].ID}==NULL) /RETURN RESET
/if (${Spawn[id ${checkSpawnID}].ID}==NULL) /RETURN RESET
/if (${Spawn[id ${checkSpawnID}].Distance}>${maxAssistDistance}) /RETURN RESET
/varset assistSpawnID ${checkSpawnID}
/varset assistSpawnIDZone ${Zone.ID}
/varset assistTime 1200s
/declare lock string local
/varset lock ${getStackCommandOpt[${opts},LOCK]}
/if (${lock.NotEqual[-]}) {
/bc locking on ${assistSpawnID}
/varset assistLock TRUE
}
/RETURN
}
SUB assistStop(string cmd, string opts) {
/declare holdTimer string local ${getStackCommandOpt[${opts},ASSISTHOLDTIMER]}
/if (${holdTimer.NotEqual[-]}) {
/varset autoAssistHoldTimer ${holdTimer}
}
| setting this low too fast will trigger buffs in the middle of combat
|/varset combatStateTimer 5
/varset assistSpawnID 0
/varset assistTime 0
/varset assistLock FALSE
/RETURN
}
SUB assistFollow(string cmd, string opts) {
/call assistStop STOP STOP;ASSISTHOLDTIMER=20
/RETURN
}
SUB assistMaintenance() {
/call updateCombatStateTimer
/if (${assistSpawnID}!=0) {
/if (${assistSpawnIDZone}!=${Zone.ID}) {
/invoke ${cq.Append[STOP;AUTHOR=${Me.CleanName};ASSISTHOLDTIMER=50]}
/RETURN
}
/if (${Spawn[id ${assistSpawnID}].ID}==NULL || ${Spawn[id ${assistSpawnID}].Dead}==TRUE) {
/call assistStop
/RETURN
}
/if (${assistMustHaveName.NotEqual[FALSE]}) {
/if (${Spawn[id ${assistSpawnID}].CleanName.Upper.Find[${assistMustHaveName.Upper}]}==NULL) {
/call assistStop
/RETURN
}
}
/if (${assistMustNotHaveName.NotEqual[FALSE]}) {
/if (${Spawn[id ${assistSpawnID}].CleanName.Upper.Find[${assistMustNotHaveName.Upper}]}!=NULL) {
/call assistStop
/RETURN
}
}
}
/call checkAutoAssist
/RETURN
}
SUB checkAutoAssist() {
/if (${autoAssistHoldTimer}>0) /return
/if (${autoAssistCheckTimer}>0) /return
/if (${autoAssist}==FALSE) /return
/if (${assistSpawnID}!=0) /return
/varset autoAssistCheckTimer 5
/declare i int local
/declare netbotName string local
/declare targetID int local 0
/for i 1 to ${NetBots.Counts}
/varset netbotName ${NetBots.Client[${i}]}
/if (${NetBots[${netbotName}].InZone}==FALSE) /continue
/if (${NetBots[${netbotName}].Attacking}==FALSE) /continue
/if (${NetBots[${netbotName}].TargetID}==0) /continue
/if (${Spawn[id ${NetBots[${netbotName}].TargetID}].Dead}==TRUE) /continue
/if (${Spawn[pc ${netbotName}].Distance} > ${maxAssistDistance}) /continue
/if (${Spawn[id ${NetBots[${netbotName}].TargetID}].Type.NotEqual[PC]} && ${NetBots[${netbotName}].TargetHP}<=${autoAssistPercent}) {
/varset targetID ${NetBots[${netbotName}].TargetID}
}
/next i
/if (${targetID}!=0) {
/invoke ${cq.Append[KILL;AUTHOR=${Me.CleanName};SPAWNID=${targetID}]}
}
/RETURN
}
SUB updateCombatStateTimer() {
/declare i int local
/declare botName string local
/if (${combatStateCheckTimer}>0) /return
/varset combatStateCheckTimer 5
/if (${Me.CombatState.Equal[COMBAT]}) {
/varset combatStateTimer ${combatStateTimerMax}
/varset combatStateLongTimer ${combatStateLongTimerMax}
/return
}
/for i 1 to ${NetBots.Counts}
/varset botName ${NetBots.Client[${i}]}
/if (${useEQCombatIndicator}==TRUE) {
/if (${NetBots[${botName}].CombatState}==0) {
/varset combatStateTimer ${combatStateTimerMax}
/varset combatStateLongTimer ${combatStateLongTimerMax}
/RETURN
}
} else {
/if (${NetBots[${botName}].Attacking} == TRUE) {
/if (${NetBots[${botName}].Zone} != ${Zone.ID}) /continue
/if (${Spawn[pc ${botName}].Distance} > ${maxAssistDistance}) /continue
/varset combatStateTimer ${combatStateTimerMax}
/varset combatStateLongTimer ${combatStateLongTimerMax}
/return
}
}
/next i
/RETURN
}
SUB p3_assist_tags_init {
/declare assistTags list outer
/declare tempCombatTags list outer
/declare iniPastTags string outer -
/varset iniPastTags ${getBotIniOption[Misc.StartupAssistTags,${iniPastTags}]}
/if (${commandLine[${cmdPAST}].Length}>0) {
/bc Adding PAST tags from startup: ${commandLine[${cmdPAST}].Replace[ ,]}
/invoke ${assistTags.Append[${commandLine[${cmdPAST}].Replace[ ,]}]}
}
/call processIniPastTags
/RETURN
}
SUB assist_tagsMaintenance() {
/call checkExpiringTags
/RETURN
}
SUB checkExpiringTags() {
/declare i int local
/declare tName string local
/if (${assistTags.Count}==0) /RETURN
|/echo count: ${assistTags.Count}
/for i 0 to ${Math.Calc[${assistTags.Count}-1]}
/varset tName ${assistTags.Item[${i}]}
|/echo checking: ${tName}...
/if (${Defined[past_${tName}]}==TRUE) {
/if (${past_${tName}}==0) {
/bc detected expired tag: ${tName} -- should remove
/call wipeLockout past_${tName}
/call removePastTags ${tName}
/return
}
}
/next i
/RETURN
}
SUB validateAssistTags(string tagsToCheck, bool asOrOperator) {
/declare i int local
/declare t string local
/declare matches int local 0
/declare res bool local TRUE
/declare checkTags list local
/declare fullTags list local
/if (${assistTags.Count}>0) {
/vardata fullTags assistTags.Splice
}
/if (${tempCombatTags.Count}>0) {
/for i 0 to ${Math.Calc[ ${tempCombatTags.Count}-1 ]}
/invoke ${fullTags.Append[${tempCombatTags.Item[${i}]}]}
/next i
}
/invoke ${checkTags.Append[${tagsToCheck}]}
/for i 0 to ${Math.Calc[${checkTags.Count}-1]}
/if (${fullTags.Contains[${checkTags.Item[${i}]}]}) {
/varset matches ${Math.Calc[${matches}+1]}
}
/next i
/if (${asOrOperator}==TRUE && ${matches}>0) {
/varset res TRUE
} else /if (${matches}>0 && ${matches} >= ${checkTags.Count}) {
/varset res TRUE
} else {
/varset res FALSE
}
/return ${res}
/RETURN
}
SUB removePastTags(string remTags) {
/declare i int local
/declare tok string local
/for i 1 to ${Math.Calc[${remTags.Count[,]}+1]}
/varset tok ${remTags.Token[${i},,]}
/if (${assistTags.Contains[${tok.Lower}]}==TRUE) {
/invoke ${assistTags.Remove[${tok}]}
/bc Removed ${tok} from assist tags.
}
/next i
/invoke ${cq.Append[TAGSCHANGED;]}
/RETURN
}
SUB processIniPastTags() {
/declare i int local
/declare tok string local
|/declare importTags list local
|/invoke ${importTags.Append[${iniPastTags}]}
/if (${iniPastTags.Equal[FALSE]}) /return
/for i 1 to ${Math.Calc[${iniPastTags.Count[,]}+1]}
/varset tok ${iniPastTags.Token[${i},,]}
/if (${assistTags.Contains[${tok.Lower}]}==FALSE) {
/invoke ${assistTags.Append[${tok}]}
/bc Adding ${tok} to assist tags from INI setting.
}
/next i
/invoke ${cq.Append[TAGSCHANGED;]}
/RETURN
}
SUB p3_autoabilities_init {
/declare autoAbilitiesCheckTimer timer outer 0
/if (${iniSectionExists[AutoAbilities]}==FALSE) /call autoabilitiesSetupINI
/RETURN
}
SUB autoabilitiesSetupINI() {
/invoke ${getBotIniOption[AutoAbilities.Sense Heading,CastableOnlyResting]}
/RETURN
}
SUB autoabilitiesMaintenance() {
/if (${autoAbilitiesCheckTimer}>0) /return
/varset autoAbilitiesCheckTimer 2
/call checkAutoAbilities
/RETURN
}
SUB checkAutoAbilities() {
/declare i int local
/declare abilityName string local
/for i 1 to ${iniAutoAbilities.Size}
/varset abilityName ${iniAutoAbilities[${i},1]}
/if (${abilityName.Equal[-]}) /break
/if (${Me.AbilityReady[${abilityName}]}==FALSE) {
/continue
}
/if (${iniAutoAbilities[${i},${bInMaxRangeTo}].NotEqual[-]}) {
/if (${Spawn[id ${assistSpawnID}].Distance} > ${Spawn[id ${assistSpawnID}].MaxRangeTo}) /continue
}
/if (${iniAutoAbilities[${i},${bRequireBehindAssistTarget}].NotEqual[-]}) {
/if (${assistSpawnID}==0) /continue
/if (${Stick.Active}==FALSE) /continue
/if (${Spawn[id ${assistSpawnID}].Distance} > ${Spawn[id ${assistSpawnID}].MaxRangeTo}) /continue
/if (${Stick.Behind}==FALSE) /continue
}
/if (${iniAutoAbilities[${i},${bSelfOverAggro}].NotEqual[-]}) {
/if (${assistSpawnID}==0) /continue
/if (${Target.ID} != ${assistSpawnID}) /continue
/if (${Me.PctAggro} < ${iniAutoAbilities[${i},${bSelfOverAggro}]}) /CONTINUE
}
/if (${iniAutoAbilities[${i},${bSelfUnderAggro}].NotEqual[-]}) {
/if (${assistSpawnID}==0) /continue
/if (${Target.ID} != ${assistSpawnID}) /continue
/if (${Me.PctAggro} > ${iniAutoAbilities[${i},${bSelfUnderAggro}]}) /CONTINUE
}
/if (${iniAutoAbilities[${i},${bCastableOnlyResting}].NotEqual[-]}) {
/if (${assistSpawnID}!=0) /continue
}
/if (${iniAutoAbilities[${i},${bSelfUnderHP}].NotEqual[-]}) {
/if (${Me.PctHPs} >= ${iniAutoAbilities[${i},${bSelfUnderHP}]}) /continue
}
/if (${iniAutoAbilities[${i},${bSelfOverHP}].NotEqual[-]}) {
/if (${Me.PctHPs} < ${iniAutoAbilities[${i},${bSelfUnderHP}]}) /continue
}
/if (${iniAutoAbilities[${i},${bRequireAssistTarget}].NotEqual[-]}) {
/if (${assistSpawnID}==0) /continue
}
/if (${iniAutoAbilities[${i},${bFreeze}].NotEqual[-]}) {
/delay ${iniAutoAbilities[${i},${bFreeze}].NotEqual[-]}
}
/if (${iniAutoAbilities[${i},${bDoCommand}].NotEqual[-]}) {
/call p3command "${iniAutoAbilities[${i},${bDoCommand}]}"
}
/doability "${abilityName}"
/next i
/RETURN
}
SUB p3_autodebuff_init() {
|/call p3RegisterCommand KILL autoMezKillCheck 5
/declare autoDebuffIDsList list outer
/declare autoDebuffCheckTimer timer outer 0
/declare autoDebuffCheckTimerDelay int outer 10
/declare autoDebuffMobRadius int outer 50
/declare autoDebuffSpawnSearch string outer NPC LOS TARGETABLE
/declare autoDebuffEnabled bool outer TRUE
/varset autoDebuffEnabled ${getBotIniOption[AutoDebuff.AutoDebuffEnabled,${autoDebuffEnabled}]}
/varset autoDebuffMobRadius ${getBotIniOption[AutoDebuff.AutoDebuffRadius,${autoDebuffMobRadius}]}
/varset autoDebuffSpawnSearch ${getBotIniOption[AutoDebuff.AutoDebuffSpawnSearch,${autoDebuffSpawnSearch}]}
/varset autoDebuffSpawnSearch ${autoDebuffSpawnSearch} RADIUS ${autoDebuffMobRadius} RANGE ${autoDebuffSpawnSearch}
/declare autoDebuffSpellIDsList list outer
/call populateAutoDebuffSpellIDs
/if (${autoDebuffSpellIDsList.Count}==0) {
/echo There are no AutoDebuff-flagged entries in [CombatSpells]. Disabling auto-debuff routines.
/varset autoDebuffEnabled FALSE
}
/RETURN
}
SUB autodebuffMaintenance() {
/if (${healIdleTimer}>0) /return
/if (${autoDebuffCheckTimer}>0) /return
/varset autoDebuffCheckTimer ${autoDebuffCheckTimerDelay}
/if (${isCastBehaviorBusy}==TRUE) /RETURN
/if (${autoDebuffEnabled}==FALSE) /RETURN
/if (${Stick.Active}==TRUE || ${Nav.Active}==TRUE) /RETURN
/call checkAutoDebuffs
/RETURN
}
SUB checkAutoDebuffs() {
/declare xspawn spawn local
/declare i int local
/declare targetEntry string local
/declare targetID string local
/declare targetZone string local
| SCAN AREA FOR NEW MOBS TO DEBUFF
/declare mobCountInArea int local ${SpawnCount[${autoDebuffSpawnSearch}]}
/if (${mobCountInArea}>0) {
/for i 1 to ${mobCountInArea}
/vardata xspawn NearestSpawn[${i},${autoDebuffSpawnSearch}]
/if (${xspawn.Aggressive}==FALSE) /continue
/if (${charmSpawnID}!=0 && ${xspawn.ID}==${charmSpawnID}) /continue
/call addTargetForDebuffs ${xspawn.ID}
/next i
}
| CLEAN UP THE LIST OF ANYTHING DEAD/GONE, ETC
/for i ${Math.Calc[${autoDebuffIDsList.Count}-1]} downto 0
/varset targetEntry ${autoDebuffIDsList.Item[${i}]}
/varset targetID ${targetEntry.Arg[1,_]}
/varset targetZone ${targetEntry.Arg[2,_]}
/if (${Zone.ID} != ${targetZone} || ${Spawn[id ${targetID}].Dead}==TRUE || ${SpawnCount[id ${targetID}]}==0) {
/invoke ${autoDebuffIDsList.Erase[${i}]}
}
/if (${Spawn[id ${targetID}].Distance}>150 || ${Spawn[id ${targetID}].LineOfSight}==FALSE) {
/invoke ${autoDebuffIDsList.Erase[${i}]}
}
/next i
/if (${autoDebuffIDsList.Count}==0) /RETURN
/for i 0 to ${Math.Calc[${autoDebuffIDsList.Count}-1]}
|/echo ${autoDebuffIDsList.Item[${i}]}
/next i
| PERFORM DEBUFFS
/for i 0 to ${Math.Calc[${autoDebuffIDsList.Count}-1]}
/if (${autoDebuffIDsList.Item[${i}].Arg[3,_].Equal[1]}) /continue
/call processDebuffsForTargetID ${autoDebuffIDsList.Item[${i}].Arg[1,_]} TRUE
/if (${Macro.Return}==TRUE) {
/varset buffCheckTimer 60
/return
}
/next i
/RETURN
}
SUB processDebuffsForTargetID(int targetID, bool requireAutoDebuffFlag) {
/declare i int local
/declare castName string local
/declare spellTime int local
/declare debuffResult string local
/declare castSpell spell local
/declare timerName string local
/declare minDuration int local 30
/declare requireMana int local 0
/declare entry string local
/declare maxResists int local 5
/declare currentResistCount int local 0
/declare cancelConditions string local
/declare lifeDeficit int local
/declare lifeRatio int local
/for i 1 to ${iniCombatSpells.Size}
/varset currentResistCount 0
/varset cancelConditions TARGETDEAD|
/if (${iniCombatSpells[${i},1].Equal[-]}) /break
/if (${requireAutoDebuffFlag}==TRUE) {
/if (${iniCombatSpells[${i},${bAutoDebuff}].Equal[-]} && ${iniCombatSpells[${i},${bAutoDebuffOnly}].Equal[-]}) /continue
}
/if (${iniCombatSpells[${i},${bEnabled}].Equal[NO]}) /continue
/if (${iniCombatSpells[${i},${bNotIfAssistTag}].NotEqual[-]}) {
/if (${assistTags.Count}>0 || ${persistentAssistTags.Count}>0) {
/call validateAssistTags ${iniCombatSpells[${i},${bNotIfAssistTag}]} TRUE
/if (${Macro.Return}==TRUE) /continue
}
}
/if (${iniCombatSpells[${i},${bRequireAssistTag}].NotEqual[-]}) {
/if (${assistTags.Count}==0 && ${persistentAssistTags.Count}==0) /continue
/call validateAssistTags ${iniCombatSpells[${i},${bRequireAssistTag}]}
/if (${Macro.Return}==FALSE) /continue
}
/if (${iniCombatSpells[${i},${bTargetOverLevel}].NotEqual[-]}) {
/if (${Spawn[id ${targetID}].Level} < ${iniCombatSpells[${i},${bTargetOverLevel}]}) /continue
}
/if (${iniCombatSpells[${i},${bTargetUnderLevel}].NotEqual[-]}) {
/if (${Spawn[id ${targetID}].Level} >= ${iniCombatSpells[${i},${bTargetUnderLevel}]}) /continue
}
/if (${iniCombatSpells[${i},${bSelfOverMana}].NotEqual[-]}) {
/if (${Me.PctMana} < ${iniCombatSpells[${i},${bSelfOverMana}]}) /continue
}
/if (${iniCombatSpells[${i},${bRequireMobsInProximity}].NotEqual[-]}) {
/if (${SpawnCount[npc loc ${Me.X} ${Me.Y} radius 45]} < ${iniCombatSpells[${i},${bRequireMobsInProximity}]}) /continue
}
/if (${iniCombatSpells[${i},${bRequireMaxMobsInProximity}].NotEqual[-]}) {
/if (${SpawnCount[npc loc ${Me.X} ${Me.Y} radius 45]} > ${iniCombatSpells[${i},${bRequireMaxMobsInProximity}]}) /continue
}
/if (${iniCombatSpells[${i},${bRequireTargetClass}].NotEqual[-]}) {
|/echo ${Spawn[id ${targetID}].Class.ShortName} === ${iniCombatSpells[${i},${bRequireTargetClass}]}
|/echo ${Select[${Spawn[id ${targetID}].Class.ShortName},${iniCombatSpells[${i},${bRequireTargetClass}]}]}
/if (${Select[${Spawn[id ${targetID}].Class.ShortName},${iniCombatSpells[${i},${bRequireTargetClass}]}]}==0) /continue
}
/if (${iniCombatSpells[${i},${bTargetUnderHP}].NotEqual[-]}) {
/call fullTarget ${targetID}
/if (${Target.PctHPs} > ${iniCombatSpells[${i},${bTargetUnderHP}]}) /continue
}
/if (${iniCombatSpells[${i},${bTargetOverHP}].NotEqual[-]}) {
/call fullTarget ${targetID}
/if (${Target.PctHPs} <= ${iniCombatSpells[${i},${bTargetOverHP}]}) /continue
/varset cancelConditions ${cancelConditions}|TARGETUNDERHP:${iniCombatSpells[${i},${bTargetOverHP}]}
}
/if (${iniCombatSpells[${i},${bTargetLifeManaRatio}].NotEqual[-]}) {
/call fullTarget ${targetID}
/varset lifeDeficit ${Math.Calc[100-${Target.PctHPs}]}
/varset lifeRatio ${iniCombatSpells[${i},${bTargetLifeManaRatio}]}
/if (${Me.PctMana} < ${Math.Calc[100-(${lifeDeficit}/${lifeRatio})]}) {
/continue
}
}
/if (${iniCombatSpells[${i},${bMaxResists}].NotEqual[-]}) {
/varset maxResists ${iniCombatSpells[${i},${bMaxResists}]}
}
/varset castName ${iniCombatSpells[${i},1]}
/call getSpellFromCastRequest "${castName}"
/vardata castSpell ${Macro.Return}
/varset spellTime ${castSpell.Duration.TotalSeconds}
/if (${iniCombatSpells[${i},${bRecastDelay}].NotEqual[-]}) {
/varset spellTime ${Math.Calc[${spellTime} + ${iniCombatSpells[${i},${bRecastDelay}]}]}
}
/varset timerName detriTimer_${targetID}_${castSpell.ID}
| ALREADY TIMER FOR IT? ITS LOCKED OUT...
/if (${Defined[${timerName}]}==TRUE) {
/if (${${timerName}}>0) /continue
/deletevar ${timerName}
}
|/if (${FindItemCount[=${castName}]}>0) {
| /call waitForInt "FindItem[=${castName}].TimerReady" 0
|}
| LAST CHANCE DEAD/GONE CHECK
/if (${Spawn[id ${targetID}].Dead}==TRUE || ${SpawnCount[id ${targetID}]}==0) /break
/if (${iniCombatSpells[${i},${bMemInGem}].NotEqual[-]}) {
/if (${Me.Gem[${castName}]}==NULL) {
/call memorizeSpellInGem "${castName}" ${iniCombatSpells[${i},${bMemInGem}]}
}
}
/if (${isCastReady[${castName}]}==FALSE) {
/echo Spell was not ready: ${castName}
/continue
}
| A CAST WILL HAPPEN -- PRE-TARGET AND CHECK FOR BUFF
/call fullTarget ${targetID}
/if (${Target.Buff[${castSpell.Name}].ID}!=NULL) {
/if (${Math.Calc[${Target.BuffDuration[${castSpell.Name}].TotalSeconds} * ${castSpell.MyDuration.TotalSeconds} > 0.3]}) {
/varset spellTime ${Target.BuffDuration[${castSpell.Name}].TotalSeconds}
/echo Detected debuff already on target. Locking out for duration: ${spellTime}
/call lockout ${timerName} ${spellTime}
/continue
}
}
| CHECK STACKABILITY
/if (${Spell[${castSpell.Name}].StacksTarget}==FALSE) {
/bc My debuff (${castSpell.Name}) will not stack on target. Lockout out for 60s
/call lockout ${timerName} 60s
/continue
}
/if (${iniCombatSpells[${i},${bDoCommand}].NotEqual[-]}) {
/docommand ${iniCombatSpells[${i},${bDoCommand}]}
/delay 3
}
/invoke (${cq.Append[CAST;SPELL=${castName};TARGETID=${targetID};SRC=iniCombatSpells;SRCIDX=${i};ONRESULT=onDebuffCastResult;cancelConditions=${cancelConditions}]})
/varset autoDebuffCheckTimer 10s
/RETURN TRUE
/next i
/RETURN FALSE
}
SUB populateAutoDebuffSpellIDs() {
/declare i int local
/declare cSpell spell local
/for i 1 to ${iniCombatSpells.Size}
/if (${iniCombatSpells[${i},1].Equal[-]}) /break
/if (${iniCombatSpells[${i},${bEnabled}].Equal[NO]}) /continue
/if (${iniCombatSpells[${i},${bAutoDebuff}].Equal[-]} && ${iniCombatSpells[${i},${bAutoDebuffOnly}].Equal[-]}) /continue
/call getSpellFromCastRequest "${iniCombatSpells[${i},1]}"
/vardata cSpell ${Macro.Return}
/invoke ${autoDebuffSpellIDsList.Append[${cSpell.ID}]}
/next i
/return
}
SUB queueContainsCast(string castName, string targetID) {
/declare i int local
/for i 0 to ${Math.Calc[${cq.Count}-1]}
/if (${cq.Item[${i}].Find[SPELL=${castName}]}!=NULL && ${cq.Item[${i}].Find[TARGETID=${targetID}]}) /RETURN TRUE
/next i
/RETURN FALSE
}
SUB onDebuffCastResult(string result, string opts) {
/varset autoDebuffCheckTimer 0
/declare targetID string local ${getStackCommandOpt[${castingOpts},TARGETID]}
/declare cSpellName string local ${getStackCommandOpt[${castingOpts},SPELL]}
/declare cSpell spell local
/call getSpellFromCastRequest "${cSpellName}"
/vardata cSpell ${Macro.Return}
/declare before string local ${targetID}_${Zone.ID}_${cSpell.ID}_0
/declare after string local ${targetID}_${Zone.ID}_${cSpell.ID}_1
/echo DCR: ${result} /invoke autoDebuffIDsList.Replace[${before},${after}]
/invoke ${autoDebuffIDsList.Replace[${before},${after}]}
/RETURN
}
SUB addTargetForDebuffs(int targetID, int force) {
/declare i int local
/declare spellID string local
/declare onString string local
/declare offString string local
/for i 0 to ${Math.Calc[${autoDebuffSpellIDsList.Count}-1]}
/varset spellID ${autoDebuffSpellIDsList.Item[${i}]}
/varset onString ${targetID}_${Zone.ID}_${spellID}_1
/varset offString ${targetID}_${Zone.ID}_${spellID}_0
| IF FORCE WAS SUPPLIED, REMOVE ANY EXISTING ENTRIES SO IT WILL BE GURANTEED TO BE ADDED
/if (${force}==TRUE) {
/invoke ${autoDebuffIDsList.Remove[${onString}]}
/invoke ${autoDebuffIDsList.Remove[${offString}]}
}
/if (${autoDebuffIDsList.Contains[${onString}]}) /continue
/if (${autoDebuffIDsList.Contains[${offString}]}) /continue
/echo add: ${offString}
/invoke ${autoDebuffIDsList.Append[${offString}]}
/next i
/RETURN
}
SUB xcheckAutoMez() {
/if (${autoMezCheckTimer}>0) /RETURN FALSE
/if (${Stick.Active}==TRUE) /RETURN FALSE
/if (${Me.Moving}==TRUE) /RETURN FALSE
/if (${Me.Invis}==TRUE) /RETURN FALSE
/varset autoMezCheckTimer 5
}
SUB xmezCastRequestResult(string result, string opts) {
/declare targetID int local ${getStackCommandOpt[${opts},TARGETID]}
/declare cSpellName string local ${getStackCommandOpt[${opts},SPELL]}
/declare cSpell spell local
/call getSpellFromCastRequest "${cSpellName}"
/vardata cSpell ${Macro.Return}
/if (${result.Find[PASS_]}!=NULL) {
/call lockout mez_${targetID} ${Math.Calc[(${cSpell.Duration.TotalSeconds}-${autoMezTimerMarginSeconds})*10]}
}
/RETURN
}
SUB p3_autodispell_init() {
/declare autoDispellEnabled bool outer FALSE
/declare autoDispellCheckDelay int outer 10
/declare autoDispellSpell string outer -
/varset autoDispellEnabled ${getBotIniOption[Misc.AutoDispellEnabled,${autoDispellEnabled}]}
/varset autoDispellCheckDelay ${getBotIniOption[Misc.AutoDispellCheckDelay,${autoDispellCheckDelay}]}
/varset autoDispellSpell ${getBotIniOption[Misc.AutoDispellSpell,${autoDispellSpell}]}
/declare autoDispellCheckTimer timer outer 0
/RETURN
}
SUB autodispellMaintenance() {
/if (${autoDispellEnabled}==TRUE && ${autoDispellCheckTimer}==0) {
/call checkAutoDispell
/varset autoDispellCheckTimer ${autoDispellCheckDelay}
/if (${Macro.Return}==TRUE) /RETURN RESET
}
/RETURN
}
SUB checkAutoDispell() {
/if (${assistSpawnID}==0) /return
/if (${targetHasBeneficial[]}==TRUE) {
/if (${isCastReady[${autoDispellSpell}]}==FALSE) /RETURN
|/if (${Cast.Ready[${autoDispellSpell}]}==FALSE) /RETURN
/invoke (${cq.Append[CAST;SPELL=${autoDispellSpell};TARGETID=${assistSpawnID};]})
/RETURN TRUE
}
/RETURN
}
SUB targetHasBeneficial() {
| FOR SOME REASON NOT TARGETTING ANYTHING?
/if (${Target.ID}==NULL) /return
/if (${assistSpawnID}==0) /return
/if (${Target.BuffsPopulated}==FALSE) /return
/declare i int local
/declare hasDispellable bool local FALSE
/for i 1 to ${Target.BuffCount}
/if (${Target.Buff[${i}].Beneficial}==TRUE && ${Target.Buff[${i}].Name.Upper.Find[MITIGATION OF THE MIGHTY]}==NULL) {
/return TRUE
|/varset hasDispellable TRUE
}
/next i
/return FALSE
}
SUB p3_autoloot_init() {
/declare looter bool outer FALSE
/declare canLootDuringCombat bool outer FALSE
/declare lootEntries[256,2] string outer -
/declare lootCheckTimer timer outer 0
/declare lootCheckTimerTime string outer 5s
/declare skipCorpseIDs list outer
/declare skipCorpseTrigger bool outer FALSE
/varset looter ${getBotIniOption[Misc.Looter,${looter}]}
/varset canLootDuringCombat ${getBotIniOption[Misc.CanLootDuringCombat,${canLootDuringCombat}]}
/if (${looter}==TRUE) {
/hidec looted
/call loadLootIni
}
/RETURN
}
SUB autolootMaintenance() {
/if (${looter}==FALSE) /RETURN
/if (${lootCheckTimer}>0) /RETURN
/if (${canLootDuringCombat}==FALSE && ${combatStateTimer}>0) /RETURN
/if (${Stick.Active}==TRUE || ${Nav.Active}==TRUE) /return
/if (${Me.FreeInventory}==0 && ${Cursor.ID} != NULL) {
/beep
/g Destroying ${Cursor}
/keypress delete
/delay 3
}
/call checkLoot
/if (${Macro.Return}==FALSE) /RETURN FALSE
/RETURN
}
SUB checkLoot() {
/declare i int local 0
/declare j int local 0
/declare k int local 0
/declare lootString string local
/declare lootTries int local 0
/declare needsLoot bool local FALSE
/declare xCorpseID int local 0
:BEGIN LOOT CYCLE
/declare corpseIDs[128] int local
/declare corpseCount int local ${SpawnCount[npccorpse LOS radius 100]}
/if (${corpseCount}==0) /return
/for k 1 to ${SpawnCount[npccorpse LOS radius 100]}
/varset corpseIDs[${k}] ${NearestSpawn[${k},npccorpse LOS radius 100].ID}
/next k
| CHECK SKIP CORPSES FOR IDs THAT DONT EXIST
/if (${skipCorpseIDs.Count}>0) {
/for k ${Math.Calc[ ${skipCorpseIDs.Count}-1]} downto 0
/if (${Spawn[id ${skipCorpseIDs.Item[${k}]}].ID}==NULL) {
/bc Removing corpseID ${skipCorpseIDs.Item[${k}]} from skip-corpse list becaust it seems to have disappeared from the zone.
/invoke ${skipCorpseIDs.Erase[${i}]}
}
/next k
}
/if (${corpseCount}==0) /RETURN
/for k 1 to ${corpseCount}
/doevents
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/call ensureNoLootWindow
/call ensureNoItemDisplayWindows
/varset xCorpseID ${corpseIDs[${k}]}
/if (${skipCorpseIDs.Contains[${xCorpseID}]}==TRUE) /continue
/if (${Nav.PathExists[id ${xCorpseID}]}==FALSE) {
/bc p3-loot: [+y+] Can't nav to corpse to loot. Abandoning. ID: ${xCorpseID}
/invoke ${skipCorpseIDs.Append[${xCorpseID}]}
/continue
}
:tryLoot
/echo Trying to loot ${xCorpseID}...
/nav id ${xCorpseID}
| this needs to be distance3d
/call waitForIntLTE "Spawn[id ${xCorpseID}].Distance" 13
/call waitForIntLTE "Me.Speed" 1
/tar id ${corpseIDs[${k}]}
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/if (${Spawn[id ${xCorpseID}].ID}==NULL) /goto :loopnextk
/tar id ${xCorpseID}
/delay 2
/doevents
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/if (${stopWait}) {
/goto :loopnextk
/varset stopWait FALSE
}
/hidec looted
/loot
/delay 5
/doevents
/if (${skipCorpseTrigger}==TRUE) {
/varset skipCorpseTrigger FALSE
/invoke ${skipCorpseIDs.Append[${xCorpseID}]}
/bc p3-loot: [+y+] Abandoning corpse ID ${xCorpseID} - I can't loot it for some reason.