/
MQ2Bot.cpp
5403 lines (5252 loc) · 189 KB
/
MQ2Bot.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
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
/* notes:
save for later:
// to use discs: pCharData->DoCombatAbility(vMaster[i].ID);
try
{
if(pSpawn)
{
SPAWNINFO tSpawn;
memcpy(&tSpawn,pSpawn,sizeof(SPAWNINFO));
RemoveFromNotify(&tSpawn, true);
}
}
catch(...)
{
DebugSpewAlways("MQ2Bot::LoadZoneTargets() **Exception**");
}
*/
#define MQ2Bot2 1
#ifdef MQ2Bot2
#pragma region Headers
// Can safely ignore these warnings
//#pragma warning ( disable : 4710 4365 4018 4244 4505 4189 4101 4100 4482 )
#pragma warning( push )
#pragma warning ( disable : 4482 )
#pragma warning(disable: 26495)
// includes
#include "../MQ2Plugin.h"
#include "../moveitem2.h"
#include "../Blech/Blech.h"
#include <vector>
#include <list>
#include <map>
#include <iterator>
#include <deque>
#include <Windows.h>
#include <cstdio>
#include <stdio.h>
#include <Shlwapi.h>
using namespace std;
#include <algorithm>
#pragma comment(lib, "Shlwapi.lib")
#ifdef MMOBUGS
#undef MMOBUGS
#endif
extern char MYPLUGIN_NAME[MAX_PATH] = "MQ2BotBeta"; // this needs reenabled when not using mmobugs source code
PreSetup("MQ2BotBeta");
#define MMOBUGS 1
// defines
#define NewSource 1
#define TargetIT(X) *(PSPAWNINFO*)ppTarget=X
#define ADD_HP vAdds[0]->HPCurrent*100/vAdds[0]->HPMax
#define ISINDEX() (Index[0])
#define ISNUMBER() (IsNumber(Index))
#define GETNUMBER() (atoi(Index))
#define GETFIRST() Index
#pragma endregion Headers
#pragma region Prototypes
// enums
enum CLASSES { NONE, WAR, CLR, PAL, RNG, SHD, DRU, MNK, BRD, ROG, SHM, NEC, WIZ, MAG, ENC, BST, BER };
enum ATTRIBSLOTS { ATTRIB, BASE, BASE2, CALC, MAX }; // attrib enum
enum OPTIONS { // used to check routines automatically
ZERO, AA, AGGRO, AURA, BARD, BUFF, CALL, CHARM, CLICKIES, CLICKYBUFFS, ITEMS,
CLICKYNUKES, DEBUFF, DOT, ENDURANCE, FADE, FIGHTBUFF, GRAB, HEAL, HEALPET, HEALTOT,
IMHIT, JOLT, KNOCKBACK, LIFETAP, MAINTANKBUFF, MANA, NUKE, NUKETOT, PET, REZ,
ROOT, SELFBUFF, SNARE, SUMMONITEM, SWARM, DISC, CURE, MEZ
};
enum TARGETTYPE {
UNKNOWN, LoS, AE_PCv1, Group_v1, PB_AE, Single, Self, Ignore, Targeted_AE, Animal, Undead, Summoned, Lifetap = 13,
Pet = 14, Corpse, Plant, UberGiants, UberDragons, Targeted_AE_Tap = 20, AE_Undead = 24, AE_Summoned = 25, Hatelist = 32, Hatelist2 = 33, Chest = 34,
SpecialMuramites = 35, Caster_PB_PC = 36, Caster_PB_NPC = 37, Pet2 = 38, NoPets = 39, AE_PCv2 = 40, Group_v2 = 41, Directional_AE = 42, SingleInGroup = 43,
Beam = 44, FreeTarget = 45, TargetOfTarget = 46, PetOwner = 47, Target_AE_No_Players_Pets = 50
};
enum BUFFTYPE {
NOTYPE, Charge, Aego, Skin, Focus, Regen, Symbol, Clarity, Pred, Strength, Brells, SV, SE, HybridHP,
Growth, Rune, Rune2, Shining, SpellHaste, MeleeProc, SpellProc, Invis, IVU, Levitate, MoveSpeed, Haste,
DS1, DS2, DS3, DS4, DS5, DS6, DS7, DS8, DS9, DS10, DS11, DS12, Tash, Malo, Snare, Root, Slow, Mez, Cripple, Fero, Retort, KillShotProc, Unity, DefensiveProc,
Rune3, Preincarnation,
};
enum SKILLTYPES { TYPE_SPELL = 1, TYPE_AA = 2, TYPE_ITEM = 3, TYPE_DISC = 4 }; // struct for spell data, how to use the spell, and how the spell was used
// structs
typedef struct _Spawns
{
//vector<_BotSpell> vSpellList; // list of what they have? was going to use as bufflist but maybe it is deprecated
//vector<_Buff> vBuffList; // tracks buffs on this character (mine or others)
char SpawnBuffList[MAX_STRING]; // might want string version? idk maybe not
char Class[MAX_STRING]; // class short name for buff purposes.
DWORD ID; // ID
int PetID; // ID of any pet
bool Add; // is this a confirmed add?
bool Friendly; // is this a friendly?
PSPAWNINFO Spawn; // actual spawn entry, might dump this due to crashes in original bot
SPAWNINFO SpawnCopy; // use this copy instead maybe
int Priority; // priority of spawn. can assign for adds or for spells id think.
bool NeedsCheck; // do i need to check this spawn for buffs/mez/whatever
ULONGLONG LastChecked; // timestamp of last check
ULONGLONG Slow; //mq2 time stamp of when slow should last until, repeat et al for rest
ULONGLONG Malo;
ULONGLONG Tash;
ULONGLONG Haste;
ULONGLONG Root;
ULONGLONG Snare;
ULONGLONG Mez;
ULONGLONG DS;
ULONGLONG RevDS;
ULONGLONG Cripple;
ULONGLONG Charge;
ULONGLONG Concuss;
ULONGLONG MindFroze;
ULONGLONG Charm;
ULONGLONG Aego;
ULONGLONG Skin;
ULONGLONG Focus;
ULONGLONG Regen;
ULONGLONG Symbol;
ULONGLONG Clarity;
ULONGLONG Pred;
ULONGLONG Strength;
ULONGLONG Brells;
ULONGLONG SV;
ULONGLONG SE;
ULONGLONG HybridHP;
ULONGLONG Growth;
ULONGLONG Shining;
ULONGLONG DeepSleep;
ULONGLONG SpellHaste; // TODO: Code this in if valid requirement
ULONGLONG MeleeProc; // TODO: Code this in if valid requirement
ULONGLONG SpellProc; // TODO: Code this in if valid requirement
ULONGLONG Hot;
ULONGLONG Fero;
ULONGLONG DelayedHeal;// TODO: Code this in if valid requirement
int PoisonCounters;
int DiseaseCounters;
int CorruptedCounters;
int CurseCounters;
int DetrimentalCounters;
BYTE State;
} Spawns, * PSpawns, SpawnCopy;
typedef struct _BotSpell // has to be before the FunctionDeclarations because a bunch use it
{
PSPELL Spell; // store the spell itself so I can access all of its members
char Name[MAX_STRING]; // Check ini to see if they want to use a custom spell, if not then store the name of the spell/AA/Disc/item we actually want to /cast since that is often different
bool CanIReprioritize; // if a specific custom spell or priority was set, then i want to ignore reprioritizing it
DWORD SpellIcon; // store the name of the icon in case it is special like mana reiteration buff icon
char Gem[MAX_STRING]; // in case they want to use a custom gem, otherwise this will be alt, disc, item, or default gem
char If[MAX_STRING]; // is there a custom if statement in the ini?
_Spawns MyTarget; // My Target for this spell
char SpellCat[MAX_STRING]; // what SpellType() is this, so i dont have to check over and over
char SpellType[MAX_STRING] = { 0 }; // this will be a custom spell type for each routine. Ie. Fast Heal, Normal Heal, Fire, Cold, Tash, because I will use this info later on checks and prioritization
OPTIONS SpellTypeOption; // int conversion from spell type
ULONGLONG Duration; // my actual duration, will use GetDuration2() and store it so i dont have to calculate every cast.
int UseOnce; // only use this spell once per mob? this will be an option ini entry
int ForceCast; // should i force memorize this spell if it is not already memmed? ini entry, will be 1 on buffs, optional on rest
int Use; // should i use this spell at all? this will allow people to memorize but not use spells in case they want manual control
int StartAt; // individual control of when to start using this spell on friend or foe
int StopAt; // individual control of when to stop using this spell on friend or foe
int NamedOnly; // ini entry to let user determine if they only want to use this on a named. could use it as a level to say only use it on named above this level to avoid wasting it on easy named. int for now
int Priority; // ini entry that will default to 0, but we can set this priority internally for things like heals and nukes to determine order of cast. higher number = higher priority
ULONGLONG Recast; // ini entry that will give us a timestamp to reuse a spell if different from it's fastest refresh. I may only want to cast swarm pets once every 30 seconds even though i could every 12.
ULONGLONG LastCast; // timestamp of last time i cast this spell
int LastTargetID; // last target id that i cast this spell on.
char Color[10]; // color to use when cast a spell
DWORD ID = 0; // ID, for Alt ability for now, maybe others
PALTABILITY AA; // AA if this is an AA
DWORD PreviousID; // Needed for my current memmed spells to see if something changed
int Type; // TYPE_AA, TYPE_SPELL, TYPE_DISC, TYPE_ITEM
int CastTime; // Casting time
DWORD TargetID; // Id of target i want to cast on
int IniMatch; // what spell number is this in the ini, if any.
bool Prestige; // if this is an item, is it prestige?
int RequiredLevel; // required level for this
int UseInCombat; // use the skill in combat? default yes combat skill/heals/fightbuffs, default no on buffs, pets, etc.
char Classes[MAX_STRING] = { 0 }; // for buffs only. what classes should i buff this one?
DWORD GroupID; // what is the group ID for ez access
BUFFTYPE BuffType = ::BUFFTYPE::NOTYPE; // what BUFFTYPE enum is this, if any
PSPELL UnitySpell; // whats my unified spell for this, if any
// save this just in case: void(*CheckFunc)(std::vector<_BotSpell> &, int);
void(*CheckFunc)(int);
} BotSpell, * PBotSpell;
typedef struct _BotItem // going to need this eventually
{
} BotItem, * PBotItem;
typedef struct _Buff
{
BUFFTYPE Type; // type of buff
PALTABILITY Unity; // special spell for unity
PALTABILITY UnityBeza; // special spell for unity beza
BotSpell UnitySpell; // special spell for unity
BotSpell UnityBezaSpell; // special spell for unity beza
BotSpell Self;
BotSpell Single;
BotSpell Group;
BotSpell Pet;
} Buff, * PBuff;
typedef struct _Buffs
{
Buff DS1;
Buff DS2;
Buff DS3;
Buff DS4;
Buff DS5;
Buff DS6;
Buff DS7;
Buff DS8;
Buff DS9;
Buff DS10;
Buff DS11;
Buff DS12;
Buff Charge;
Buff Aego;
Buff Haste;
Buff Skin;
Buff Focus;
Buff Regen;
Buff Symbol;
Buff Clarity;
Buff Pred;
Buff Strength;
Buff Brells;
Buff SV;
Buff SE;
Buff HybridHP;
Buff Growth;
Buff Rune;
Buff Rune2;
Buff Shining;
Buff Fero;
Buff Retort;
Buff SpellHaste; // TODO: Code this in if valid requirement
Buff MeleeProc; // TODO: Code this in if valid requirement
Buff SpellProc; // TODO: Code this in if valid requirement
Buff KillShotProc; // TODO: Code this in if valid requirement
Buff Invis; // TODO: Code this in if valid requirement
Buff IVU; // TODO: Code this in if valid requirement
Buff Levitate; // TODO: Code this in if valid requirement
Buff MoveSpeed; // TODO: Code this in if valid requirement
Buff DefensiveProc; // TODO:
Buff Rune3;
Buff Preincarnation;
} Buffs, * PBuffs;
typedef struct _Debuffs
{
BotSpell Malo;
BotSpell Tash;
BotSpell Haste;
BotSpell Root;
BotSpell Snare;
BotSpell Mez;
BotSpell DS;
BotSpell RevDS;
BotSpell Cripple;
BotSpell Charge;
BotSpell Concuss;
BotSpell MindFroze;
BotSpell Charm;
BotSpell Aego;
BotSpell Skin;
BotSpell Focus;
BotSpell Regen;
BotSpell Symbol;
BotSpell Clarity;
BotSpell Pred;
BotSpell Strength;
BotSpell Brells;
BotSpell SV;
BotSpell SE;
BotSpell HybridHP;
BotSpell Growth;
BotSpell Shining;
BotSpell DeepSleep;
BotSpell SpellHaste; // TODO: Code this in if valid requirement
BotSpell MeleeProc; // TODO: Code this in if valid requirement
BotSpell SpellProc; // TODO: Code this in if valid requirement
BotSpell KillShotProc; // TODO: Code this in if valid requirement
} Debuffs, * PDebuffs;
#pragma region FunctionDeclarations
//
void BuildBuff(_BotSpell& spell);
// declaration of create functions
void CreateAA();
void CreateDisc();
void CreateHeal();
// declaration of check routines
void CheckAA(int spell);
void CheckAggro(int spell);
void CheckAura(int spell);
void CheckBard(int spell);
void CheckBuff(int spell);
void CheckCall(int spell);
void CheckCharm(int spell);
void CheckClickies(int item);
void CheckClickyBuffs(int item);
void CheckClickyNukes(int item);
void CheckCure(int spell);
void CheckDebuff(int spell);
void CheckDisc(int spell);
void CheckDot(int spell);
void CheckEndurance(int spell);
void CheckFade(int spell);
void CheckFightBuff(int spell);
void CheckGrab(int spell);
void CheckHeal(int spell);
void CheckHealPet(int spell);
void CheckHealToT(int spell);
void CheckImHit(int spell);
void CheckItems(int item);
void CheckJolt(int spell);
void CheckKnockback(int spell);
void CheckLifetap(int spell);
void CheckMainTankBuff(int spell);
void CheckMana(int spell);
void CheckMez(int spell);
void CheckNuke(int spell);
void CheckNukeToT(int spell);
void CheckPet(int spell);
void CheckRez(int spell);
void CheckRoot(int spell);
void CheckSelfBuff(int spell);
void CheckSnare(int spell);
void CheckSummonItem(int spell);
void CheckSwarm(int spell);
// declaration of general functions
int CalcDuration(PSPELL pSpell);
void BotCastCommand(_BotSpell& spell);
VOID DebugWrite(PCHAR szFormat, ...);
void EQBCSwap(char startColor[MAX_STRING]);
double botround(double d);
// declaration of spawn functions
void CheckGroupPets(int i);
int PctEnd(PSPAWNINFO pSpawn);
int PctHP(PSPAWNINFO pSpawn);
int PctMana(PSPAWNINFO pSpawn);
// declaration of spell functions
void DiscCategory(PSPELL pSpell);
DWORD GetSpellDuration2(PSPELL pSpell);
void PopulateIni(vector<_BotSpell>& v, char VectorName[MAX_STRING]);
void SortSpellVector(vector<_BotSpell>& v);
void SpellCategory(PSPELL pSpell);
void SkillType(char szName[MAX_STRING]);
void SpellType(PSPELL pSpell);
bool ValidDet(PSPELL pSpell, PSPAWNINFO Target);
bool ValidBen(PSPELL pSpell, PSPAWNINFO Target);
#pragma endregion FunctionDeclarations
#pragma region VariableDefinitions
// function declare
void(*spellFunc)(int);
// bool declares
bool BardClass = false, ConfigureLoaded = false, InCombat = false, summoned = false, UseManualAssist = false, UseNetBots = false, storePrestige = false, bGoldStatus = false;
// char declares
char AddList[MAX_STRING] = { 0 }, AssistName[MAX_STRING] = { 0 }, BodyTypeFix[MAX_STRING] = { 0 }, CurrentRoutine[MAX_STRING] = { 0 }, EQBCColor[MAX_STRING] = { 0 },
INISection[MAX_STRING] = { 0 }, NetBotsName[MAX_STRING] = "NULL", spellCat[MAX_STRING] = { 0 }, spellType[MAX_STRING] = { 0 }, storeGem[10] = { 0 }, storeName[MAX_STRING] = { 0 },
conColor[MAX_STRING] = { 0 }, DEBUG_DUMPFILE[MAX_STRING] = { 0 };
char DSClasses[MAX_STRING], HasteClasses[MAX_STRING], AegoClasses[MAX_STRING], SkinClasses[MAX_STRING],
SymbolClasses[MAX_STRING], FocusClasses[MAX_STRING], RegenClasses[MAX_STRING], ClarityClasses[MAX_STRING],
PredClasses[MAX_STRING], StrengthClasses[MAX_STRING], BrellsClasses[MAX_STRING], SVClasses[MAX_STRING],
SEClasses[MAX_STRING], FeroClasses[MAX_STRING], SpellHasteClasses[MAX_STRING], ACClasses[MAX_STRING];
char BuffClasses[MAX_STRING] = "|DS|Haste|Aego|Skin|Symbol|Focus|Regen|Clarity|Pred|Strength|Brells|SV|SE|Fero|SpellHaste|AC|";
// Long declares
long MyClass;
// DWORD declares
DWORD LastBodyID, storeID;
// int declares
int AnnounceAdds = 1, AnnounceEcho = 1, AnnounceEQBC = 0, AssistAt = 100, AssistRange = 100, DefaultGem = 1, dotExtend = 0, hotExtend = 0, storeType = 0, storeRequiredLevel = 0,
mezExtend = 0;
BUFFTYPE buffType = ::BUFFTYPE::NOTYPE;
// float declares
float benDurExtend = 0.00, benRngExtend = 1.00, detDurExtend = 0.00, detRngExtend = 1.00, fCampX, fCampY, fCampZ, FightX = 0, FightY = 0, FightZ = 0,
reinforcement = 0.00, WarpDistance = 0.00;
// ULONGLONG declares
ULONGLONG AssistTimer = 0, LastAnnouncedSpell = 0, SpellTimer = 0;
// PSPELL declares
PSPELL storeSpell, UnitySpell, invisgroup, invisself, ivugroup, ivuself, levitategroup, levitateself;
//vector _BotSpell declares
//vector<_BotSpell> vMaster, vMemmedSpells, vTemp;
vector<_BotSpell> vMaster;
vector<_BotSpell> vMemmedSpells(NUM_SPELL_GEMS - 1, _BotSpell());
vector<_BotSpell> vTemp;
vector<_BotSpell> vCustomSpells;
vector<_Buff> vBuff;
//vector int declares
vector<int> vClickyPrestige;
// vector PSPELL declares
vector<PSPELL> vClickySpell;
// vector PSPAWNINFO declares
_Spawns KillTarget, xNotTargetingMe, xTargetingMe; // we always store the current kill target here
vector<_Spawns> vGroup, vXTarget, vSpawns, vPets; // manage all the various spawns, and if something is mezzed, dont remove it unless it is banished.
// buffs
_Buffs MyBuffs;
_Debuffs MyDebuffs;
// vector string declares
vector<string> vClicky;
// map declares
std::map<string, string> SpellIf;
std::map<string, string>::iterator SpellIt;
// deque declares
deque<_Spawns> vAdds;
// buff spells for hardcoding
// unified lines: symbol, aego, bst SV/SE unity
BotSpell
//long duration buffs
buffSelfSpellResist, buffSingleSpellResist, buffGroupSpellResist, // might need to break this out by class or resist type since there's so many.
buffSingleResistCorruption, buffGroupResistCorruption, //maybe?
buffSelfHybridHP, // pal/sk self hp buffs
buffSelfConvert, // SK/nec mana conversion
buffSelfAttack, // SK attack buff
buffSingleAego, buffGroupAego, buffSingleUnifiedAego, buffGroupUnifiedAego, buffGroupSpellHaste, buffSingleAC, buffGroupAC,//clr
buffSingleSymbol, buffGroupSymbol, buffSingleUnifiedSymbol, buffGroupUnifiedSymbol, buffSingleSpellHaste, //clr ..
buffSingleHaste, buffGrouphaste, buffAAHaste, // shm, enc, bst (single)
buffSingleSkin, buffGroupSkin, //dru /rng (single only rng)
buffSelfFocus, //clr/casters
buffSingleFocus, buffGroupFocus, // shm / bst (group only except for one single spell at level 67)
buffSingleRegen, buffGroupRegen, // shm/dru rang(single)
buffSelfClarity, buffSingleClarity, buffGroupClarity, // rng, dru self . enc single/group
buffSelfPred, buffGroupPred, buffGroupStrength, // rng
buffGroupBrells, //pal only
buffGroupSV, buffGroupSE, //bst only
//HybridHP, //not sure if i need this atm
buffSelfDS, buffSingleDS, buffGroupDS,
buffSingleFerocity, buffGroupFerocity, // dont use single if you have group
// there are a ton of different lines for procs on hit or cast. many classes get 2, sometimes 3
buffSelfMeleeProc, buffSingleMeleeProc, buffGroupMeleeProc,
buffSelfMeleeProc2,
buffSelfSpellProc, buffSingleSpellProc, buffGroupSpellProc,
buffSelfKillShotProc,
// misc buffs common across classes
buffSelfInvis, buffSingleInvis, buffGroupInvis,
buffSelfIVU, buffSingleIVU, buffGroupIVU,
buffSelfLevitate, buffSingleLevitate, buffGroupLevitate,
buffSingleMoveSpeed, buffGroupMoveSpeed,
//things i might only use if memmed, usually short duration and require getting hit to matter
buffSelfDefensiveProc, buffSingleDefensiveProc,
buffSelfRune, buffSingleRune, buffGroupRune,
buffSelfRune2, buffSingleRune2, buffGroupRune2,
//things i should only use if memmed.. high reuse timer or extremely short duration or both
buffSingleRetort, buffSelfDivineAura, buffSingleDivineAura, buffSelfDivineAura2, buffYaulp, buffSingleShining, buffDivineIntervention, //clr.. ok clerics.. we get it. you are special
buffSelfWard, buffSingleWard,
buffSingleGrowth;// dru/shm buffPetDS,
// PCHAR declares
PCHAR ChatColors[] = { "\ay", "\a-y", "\ao", "\a-o", "\ag", "\a-g", "\ab", "\a-b", "\ar", "\a-r",
"\at", "\a-t", "\am", "\a-m", "\ap", "\a-p", "\aw", "\a-w", "\ax", "\a-x", "\au", "\a-u", NULL };
PCHAR EQBCColors[] = { "[+y+]", "[+Y+]", "[+o+]", "[+O+]", "[+g+]", "[+G+]", "[+b+]", "[+B+]", "[+r+]", "[+R+]", "[+t+]",
"[+T+]", "[+m+]", "[+M+]", "[+p+]", "[+P+]", "[+w+]", "[+W+]", "[+x+]", "[+X+]", "[+u+]", "[+U+]", NULL };
PCHAR cast_status[] = { "SUCCESS","INTERRUPTED","RESIST","COLLAPSE","RECOVER","FIZZLE","STANDING","STUNNED","INVISIBLE","NOTREADY",
"OUTOFMANA","OUTOFRANGE","NOTARGET","CANNOTSEE","COMPONENTS","OUTDOORS","TAKEHOLD","IMMUNE","DISTRACTED","ABORTED", "UNKNOWN", "IMMUNE_RUN", "IMMUNE_MEZ","IMMUNE_SLOW",NULL };
PCHAR DefaultSection[] = { "AA", "Aggro","Aura","Bard","Buff","Call","Charm","Clickies", "ClickyBuffs","Items",
"ClickyNukes","Debuff","Dot","Endurance","Fade","FightBuff","Grab","Heal","HealPet","HealToT",
"ImHit","Jolt","KnockBack","Lifetap","MainTankBuff","Mana","Nuke","NukeToT","Pet","Rez",
"Root","SelfBuff","Snare","SummonItem","Swarm", "Disc","Cure", "Mez", NULL }; // 10 per line
PCHAR DefaultUseInCombat[] = { "1","1","0","1","0","1","1","1","0","1",
"1","1","1","0","1","1","1","1","1","1",
"1","1","1","1","1","0","1","1","0","1",
"1","0","1","0","1","1","1","1",NULL }; // 10 per line
PCHAR DefaultColor[] = { "\ap", "\a-r","\a-m","\a-t","\aw","\ao","\am","\a-o","\a-o","\a-o",
"\a-o","\ay","\ay","\ag","\a-w","\am","\a-g","\at","\a-t","\a-t",
"\ay","\at","\a-g","\ag","\ag","\ao","\ar","\a-t","\a-t","\a-o",
"\a-g","\aw","\a-g","\a-o","\a-r", "\a-y","\ag","\a-m", NULL };// 10 per line
PCHAR DefaultPriority[] = { "300","900", "1", "1", "1", "1", "1", "1", "1", "1",
"400","800", "700", "1", "950", "1", "1", "990", "850", "1",
"980","1000", "1", "910", "1", "1", "450", "1", "1", "1",
"500","1", "750", "1", "720","600","1", "1000", NULL };// 10 per line
PCHAR DefaultStartAt[] = { "99","100", "100", "100", "100", "100", "100", "100", "100", "100",
"99","100", "99", "17", "50", "100", "100", "80", "80", "80",
"80","70", "100", "80", "100", "80", "99", "99", "100", "100",
"100","100", "100", "100", "99","99", "99", "100", NULL };// 10 per line
PCHAR DefaultStopAt[] = { "0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0","0", "0","0",NULL };// 10 per line
PCHAR DefaultUse[] = { "1","1", "1", "1", "1", "1", "1", "1", "1", "1",
"1","1", "1", "1", "1", "1", "1", "1", "1", "1",
"1","1", "1", "1", "1", "1", "1", "1", "1", "1",
"1","1", "1", "1", "1","1","1","1", NULL };// 10 per line
PCHAR DefaultForceCast[] = { "0","0", "0", "0", "1", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "1", "0", "1",
"0","1", "0", "1", "0", "0","0","0", NULL };// 10 per line
PCHAR DefaultNamedOnly[] = { "0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0","0","0", NULL };// 10 per line
PCHAR DefaultUseOnce[] = { "0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0", "0", "0", "0", "0",
"0","0", "0", "0", "0", "0","0","0", NULL };// 10 per line
// special declares
OPTIONS spellTypeOption;
_BotSpell EndRegenSpell;
#pragma endregion VariableDefinitions
#pragma endregion Prototypes
#pragma region Inlines
// Returns TRUE if character is in game and has valid character data structures
inline bool InGameOK()
{
return(GetGameState() == GAMESTATE_INGAME && GetCharInfo() && GetCharInfo()->pSpawn && GetCharInfo2());
}
// Returns TRUE if the specified UI window is visible
static inline BOOL WinState(CXWnd* Wnd)
{
return (Wnd && ((PCSIDLWND)Wnd)->IsVisible());
}
static inline LONG GetSpellAttribX(PSPELL spell, int slot) {
return slot < GetSpellNumEffects(spell) ? GetSpellAttrib(spell, slot) : 254;
}
static inline LONG GetSpellBaseX(PSPELL spell, int slot) {
return slot < GetSpellNumEffects(spell) ? GetSpellBase(spell, slot) : 0;
}
static inline LONG GetSpellBase2X(PSPELL spell, int slot) {
return slot < GetSpellNumEffects(spell) ? GetSpellBase2(spell, slot) : 0;
}
static inline LONG GetSpellMaxX(PSPELL spell, int slot) {
return slot < GetSpellNumEffects(spell) ? GetSpellMax(spell, slot) : 0;
}
static inline LONG GetSpellCalcX(PSPELL spell, int slot) {
return slot < GetSpellNumEffects(spell) ? GetSpellCalc(spell, slot) : 0;
}
#pragma endregion Inlines
#pragma region GeneralFunctionDefinitions
void Announce(_BotSpell& spell)
{
if (PSPAWNINFO pSpawn = (PSPAWNINFO)GetSpawnByID(spell.TargetID))
{
if (AnnounceEcho && pSpawn && LastAnnouncedSpell != spell.Spell->ID)
{
WriteChatf("%s%s \aw--> %s", spell.Color, spell.Name, pSpawn->DisplayedName);
}
if (AnnounceEQBC && pSpawn && LastAnnouncedSpell != spell.Spell->ID)
{
EQBCSwap(spell.Color);
char castLine[MAX_STRING] = { 0 };
sprintf_s(castLine, "/bc %s%s [+x+]--> %s", EQBCColor, spell.Name, pSpawn->DisplayedName);
HideDoCommand(GetCharInfo()->pSpawn, castLine, FromPlugin);
}
LastAnnouncedSpell = spell.Spell->ID;
}
}
DWORD ChkCreateDir(char* pszDir)
{
DWORD dwAtt = 0;
dwAtt = GetFileAttributes(pszDir);
if (FILE_ATTRIBUTE_DIRECTORY == dwAtt) return(dwAtt);
char acDir[MAX_PATH];
strcpy_s(acDir, pszDir);
bool bCreateFolder = true;
static bool bIsFile = false;
char* pc = NULL;
pc = strrchr(acDir, '\\');
if (pc) {
if (!bIsFile) {
bIsFile = true;
bCreateFolder = false;
}
*pc = (char)0;
}
else
return(0xffffffff);
dwAtt = ChkCreateDir(acDir);
if (FILE_ATTRIBUTE_DIRECTORY == dwAtt && bCreateFolder) {
if (!CreateDirectory(pszDir, NULL))
return GetLastError();
return(dwAtt);
}
return(0);
}
VOID DebugWrite(PCHAR szFormat, ...)
{
if (_stricmp(DEBUG_DUMPFILE, "all") && _stricmp(DEBUG_DUMPFILE, CurrentRoutine))
return;
try
{
va_list vaList;
va_start(vaList, szFormat);
int len = _vscprintf(szFormat, vaList) + 1;
if (char* szOutput = (char*)LocalAlloc(LPTR, len + 32))
{
vsprintf_s(szOutput, len + 32, szFormat, vaList);
FILE* fOut = NULL;
CHAR Filename[MAX_STRING] = { 0 };
CHAR szBuffer[MAX_STRING] = { 0 };
DWORD i;
sprintf_s(Filename, "%s\\MQ2Bot_Debug.log", gszLogPath);
ChkCreateDir(gszLogPath);
for (i = 0; i < strlen(Filename); i++)
{
if (Filename[i] == '\\')
{
strncpy_s(szBuffer, Filename, i);
szBuffer[i] = 0;
}
}
fOut = _fsopen(Filename, "at", SH_DENYNO);
if (!fOut)
{
return;
}
char tmpbuf[128];
struct tm today;
time_t tm;
tm = time(NULL);
localtime_s(&today, &tm);
strftime(tmpbuf, 128, "%Y/%m/%d %H:%M:%S", &today);
CHAR PlainText[MAX_STRING] = { 0 };
StripMQChat(szOutput, PlainText);
sprintf_s(szBuffer, "[%s] %s", tmpbuf, PlainText);
for (unsigned int i = 0; i < strlen(szBuffer); i++) {
if (szBuffer[i] == 0x07) {
if ((i + 2) < strlen(szBuffer))
strcpy_s(&szBuffer[i], MAX_STRING, &szBuffer[i + 2]);
else
szBuffer[i] = 0;
}
}
fprintf(fOut, "%s\n", szBuffer);
fclose(fOut);
LocalFree(szOutput);
}
}
catch (exception & e)
{
sprintf_s(DEBUG_DUMPFILE, NULL);
//FatalError("[%s::%s] Severe Error: %s : %s", MYPLUGIN_NAME, __FUNCTION__, e.what(), typeid(e).name());
}
catch (...)
{
sprintf_s(DEBUG_DUMPFILE, NULL);
//FatalError("[%s::%s] Severe Error: Unknown", MYPLUGIN_NAME, __FUNCTION__);
}
}
void DurationSetup()
{
if (!InGameOK())
return;
PCHARINFO2 pChar2 = GetCharInfo2();
int ben = 0, det = 0, mez = 0;
//remove char itemName[MAX_STRING], spellName[MAX_STRING], itemlevel[MAX_STRING];
if (pChar2 && pChar2->pInventoryArray && pChar2->pInventoryArray->InventoryArray)
{
for (int i = 1; i < NUM_INV_SLOTS; i++)
{
if (PCONTENTS Cont = GetCharInfo2()->pInventoryArray->InventoryArray[i])
if (PSPELL pFocus = GetSpellByID(GetItemFromContents(Cont)->Focus.SpellID))
{
if (GetSpellAttribX(pFocus, 0) == 128 && GetSpellBaseX(pFocus, 2) == 1)
benDurExtend = (float)GetSpellBaseX(pFocus, 0) / 100;
if (GetSpellAttribX(pFocus, 0) == 128 && GetSpellBaseX(pFocus, 2) == 0)
detDurExtend = (float)GetSpellBaseX(pFocus, 0) / 100;
if (GetSpellAttribX(pFocus, 0) == 129 && GetSpellBaseX(pFocus, 3) == 1)
benRngExtend = (float)GetSpellBaseX(pFocus, 0) / 100 + 1;
if (GetSpellAttribX(pFocus, 0) == 129 && GetSpellBaseX(pFocus, 3) == 0)
detRngExtend = (float)GetSpellBaseX(pFocus, 0) / 100 + 1;
}
}
if (reinforcement < 0.01 && GetCharInfo()->pSpawn->Level>55) {
long Index = GetAAIndexByName("Spell Casting Reinforcement");
if (Index > 0)
{
if (PlayerHasAAAbility(Index))
for (int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j) == Index)
reinforcement = (float)(0.025 * GetCharInfo2()->AAList[j].PointsSpent);
if (reinforcement > 0.01 || !pPCData->GetAlternateAbilityId(j))
break;
}
}
Index = GetAAIndexByName("Prolonged Salve");
if (Index > 0)
{
if (PlayerHasAAAbility(Index))
for (int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j) == Index)
hotExtend = (int)botround(GetCharInfo2()->AAList[j].PointsSpent / 12);
if (hotExtend > 0.01 || !pPCData->GetAlternateAbilityId(j))
break;
}
}
Index = GetAAIndexByName("Powerful Elixirs");
if (Index > 0)
{
if (PlayerHasAAAbility(Index))
for (int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j) == Index)
hotExtend = (int)botround(GetCharInfo2()->AAList[j].PointsSpent / 12);
if (hotExtend > 0.01 || !pPCData->GetAlternateAbilityId(j))
break;
}
}
if (PlayerHasAAAbility(GetAAIndexByName("Mesmerization Mastery"))) {
for (unsigned int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j)) {
if (pPCData->GetAlternateAbilityId(j) == GetAAIndexByName("Mesmerization Mastery")) {
mez = GetCharInfo2()->AAList[j].PointsSpent;
if (mez >= 28) // level 3+ (add more checks before this if expansions add more ranks)
mezExtend += 3;
else if (mez >= 20) // level 2
mezExtend += 2;
else if (mez >= 12) // level 1
mezExtend += 1;
break;
}
}
}
}
Index = GetAAIndexByName("Lingering Death");
if (Index > 0)
{
if (PlayerHasAAAbility(Index))
for (int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j) == Index)
dotExtend = (int)botround(GetCharInfo2()->AAList[j].PointsSpent / 13);
if (dotExtend > 0.01 || !pPCData->GetAlternateAbilityId(j))
break;
}
}
Index = GetAAIndexByName("Extended Pestilence");
if (Index > 0)
{
if (PlayerHasAAAbility(Index))
for (int j = 0; j < AA_CHAR_MAX_REAL; j++) {
if (pPCData->GetAlternateAbilityId(j) == Index)
if (GetCharInfo2()->AAList[j].PointsSpent >= 48)
dotExtend = 3;
if (dotExtend > 0.01 || !pPCData->GetAlternateAbilityId(j))
break;
}
}
}
}
}
void EQBCSwap(char startColor[MAX_STRING])
{
strcpy_s(EQBCColor, "[+x+]");
for (int i = 0; ChatColors[i] && EQBCColors[i]; i++)
{
if (strstr(startColor, ChatColors[i]))
{
strcpy_s(EQBCColor, EQBCColors[i]);
return;
}
}
}
bool FindPlugins(PCHAR PluginName)
{
PMQPLUGIN pPlugin = pPlugins;
while (pPlugin)
{
if (!_stricmp(pPlugin->szFilename, PluginName))
return true;
pPlugin = pPlugin->pNext;
}
return false;
}
int FindSpellAttrib(PSPELL pSpell, int attrib)
{
for (int slot = 0; slot < GetSpellNumEffects(pSpell); ++slot)
{
if (GetSpellAttrib(pSpell, slot) == attrib)
return slot;
}
return -1; // not found
}
bool HasSpellAttrib(PSPELL pSpell, int attrib)
{
return FindSpellAttrib(pSpell, attrib) != -1;
}
PLUGIN_API DWORD OnWriteChatColor(PCHAR Line, DWORD Color, DWORD Filter)
{
if (_stricmp(DEBUG_DUMPFILE, "all") && _stricmp(DEBUG_DUMPFILE, CurrentRoutine))
DebugWrite(Line);
return 0;
}
int PctEnd(PSPAWNINFO pSpawn)
{
if (pSpawn)
{
if (pSpawn->GetMaxEndurance() > 0)
return ((pSpawn->GetCurrentEndurance() * 100) / pSpawn->GetMaxEndurance());
else
return 0;
}
return 0;
}
int PctHP(PSPAWNINFO pSpawn)
{
if (pSpawn)
{
if (pSpawn->HPMax > 0)
return (unsigned int)((pSpawn->HPCurrent * 100) / pSpawn->HPMax);
else
return 0;
}
return 0;
}
int PctMana(PSPAWNINFO pSpawn)
{
if (pSpawn)
{
if (pSpawn->GetMaxMana() > 0)
return ((pSpawn->GetCurrentMana() * 100) / pSpawn->GetMaxMana());
else
return 0;
}
return 0;
}
void PopulateIni(vector<_BotSpell>& v, char VectorName[MAX_STRING])
{
char szTemp[MAX_STRING] = { 0 }, szSpell[MAX_STRING];
int vSize = v.size();
for (int x = 0; x < vSize; x++)
{
int i = x + 1;
sprintf_s(szSpell, "%sTotal", VectorName);
_itoa_s(v.size(), szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dName", VectorName, i);
WritePrivateProfileString(INISection, szSpell, v[x].Name, INIFileName);
//sprintf_s(szSpell, "%sSpellIconName%d", VectorName, i);
//WritePrivateProfileString(INISection, szSpell, v[x].SpellIconName, INIFileName);
sprintf_s(szSpell, "%s%dIf", VectorName, i);
if (IsNumber(v[x].If))
{
_itoa_s(atoi(v[x].If), szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
}
else
WritePrivateProfileString(INISection, szSpell, v[x].If, INIFileName);
sprintf_s(szSpell, "%s%dGem", VectorName, i);
if (IsNumber(szSpell))
{
_itoa_s(atoi(v[x].Gem), szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
}
else
WritePrivateProfileString(INISection, szSpell, v[x].Gem, INIFileName);
sprintf_s(szSpell, "%s%dUseOnce", VectorName, i);
_itoa_s(v[x].UseOnce, szTemp, 10);
sprintf_s(szSpell, "%s%dForceCast", VectorName, i);
_itoa_s(v[x].ForceCast, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dUse", VectorName, i);
_itoa_s(v[x].Use, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dStartAt", VectorName, i);
_itoa_s(v[x].StartAt, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dStopAt", VectorName, i);
_itoa_s(v[x].StopAt, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dNamedOnly", VectorName, i);
_itoa_s(v[x].NamedOnly, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dPriority", VectorName, i);
_itoa_s(v[x].Priority, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
sprintf_s(szSpell, "%s%dUseInCombat", VectorName, i);
_itoa_s(v[x].UseInCombat, szTemp, 10);
WritePrivateProfileString(INISection, szSpell, szTemp, INIFileName);
}
}
double botround(double d)
{
return floor(d + 0.5);
}
bool SpellStacks(PSPELL pSpell)
{
if (!InGameOK())
return true;
unsigned long nBuff;
PCHARINFO2 pChar = GetCharInfo2();
bool stacks = true;
//remove char cTest[MAX_STRING];
PSPELL tmpSpell2;
// Check Buffs
for (nBuff = 0; nBuff < NUM_LONG_BUFFS && pChar; nBuff++)
{
if (pChar->Buff[nBuff].SpellID > 0 && GetSpellByID(pChar->Buff[nBuff].SpellID)) {
PSPELL tmpSpell = GetSpellByID(pChar->Buff[nBuff].SpellID);
if (tmpSpell && pSpell)
{
for (int nSlot = 0; nSlot < GetSpellNumEffects(pSpell); nSlot++)
{
int attrib = GetSpellAttrib(pSpell, nSlot);
if (attrib == 374 || attrib == 419 || attrib == 339)
{
tmpSpell2 = GetSpellByID(GetSpellBase2(pSpell, nSlot));
if (tmpSpell2 && !BuffStackTest(tmpSpell, tmpSpell2) || !outdoor && tmpSpell2->ZoneType == 1 || tmpSpell == tmpSpell2 || attrib == 339 && GetSpellAttribX(tmpSpell, nSlot) == 339 || strstr(pSpell->Name, tmpSpell->Name))
{
stacks = false;
return stacks;
}
}
if (attrib == 339 && GetSpellAttribX(tmpSpell, nSlot) == 339 || strstr(pSpell->Name, tmpSpell->Name) || !outdoor && tmpSpell->ZoneType == 1)
{
stacks = false;
return stacks;
}
}
if ((!BuffStackTest(pSpell, tmpSpell) || pSpell == tmpSpell || strstr(pSpell->Name, tmpSpell->Name)) || !outdoor && pSpell->ZoneType == 1)
{
stacks = false;
return stacks;
}
}
}
}
// Check Songs
for (nBuff = 0; nBuff < NUM_SHORT_BUFFS && pChar; nBuff++)
{
if (pChar->ShortBuff[nBuff].SpellID > 0) {
PSPELL tmpSpell = GetSpellByID(pChar->ShortBuff[nBuff].SpellID);
if (tmpSpell && pSpell && (!(tmpSpell->ClassLevel[Bard] == 255 ? 0 : tmpSpell->ClassLevel[Bard]) && (!(GetSpellAttribX(pSpell, 0) == 58) || !(pSpell->DurationWindow == 1))))
{
for (int nSlot = 0; nSlot < GetSpellNumEffects(pSpell); nSlot++)
{
int attrib = GetSpellAttrib(pSpell, nSlot);
if (attrib == 374 || attrib == 419)
{
tmpSpell2 = GetSpellByID(GetSpellBase2(pSpell, nSlot));
if (tmpSpell2 && !BuffStackTest(tmpSpell, tmpSpell2) || pSpell == tmpSpell2 || tmpSpell == tmpSpell2 || strstr(pSpell->Name, tmpSpell->Name))
{
stacks = false;
return stacks;
}
}
if (attrib == 339 && GetSpellAttribX(tmpSpell, nSlot) == 339 || strstr(pSpell->Name, tmpSpell->Name))
{
stacks = false;
return stacks;
}
}
if ((!BuffStackTest(pSpell, tmpSpell) || pSpell == tmpSpell || strstr(pSpell->Name, tmpSpell->Name)))
{