-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMQ2NetBots.cpp
More file actions
3493 lines (3326 loc) · 102 KB
/
MQ2NetBots.cpp
File metadata and controls
3493 lines (3326 loc) · 102 KB
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
// This File Came From MMOBugs.com
// Please Do Not Distribute Without Authors or MMOBugs Consent.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// Projet: MQ2NetBots.cpp
// Author: s0rCieR
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//
// Deadchicken added .Duration on or about September 2007 and tried not to
// mangle s0rCieR's code to much. Thanks to Kroak for helping debug.
// Updated for 10/9 release of MQ2
// CombatState member added Thanks mijuki.
// .Stacks member added
//
// Up to 1.23: Updated by several people (www.macroquest2.com) VIP forums.
// 1.24 - 8/11/09: mmobugs.com/devestator, added code to Buff, ShortBuff, PetBuff to allow index by name as well as number
// 1.25: Small correction to Buff code
// 1.26: Added INI value to allow 'extended' info spam
// v2.1 woobs
// Upped most of the maximum values to handle more buffs.
// Add Detrimental information to merge in MQ2Debuffs functions
// v2.2 Added String Safety - eqmule
// v3.0 woobs
// Updated .Stacks
// Added .StacksPet
// v3.01+ htw
// Lot of fixes/additions, TLO handling and additions
#include <mq/Plugin.h>
#include "../Blech/Blech.h"
#include <string>
#include <map>
#include <iostream>
#include <sstream>
using namespace std;
PreSetup("MQ2NetBots");
double compile_date();
#define PLUGIN_VERS compile_date()
PLUGIN_VERSION(PLUGIN_VERS);
#define PLUGIN_DATE compile_date()
#define PLUGIN_TITLE "MQ2NetBots"
#define PETS_MAX 65
#define NOTE_MAX 500
#define DETR_MAX 30
#define NETTICK 50
#define REFRESH 60000
#define UPDATES 6000
#define UIUPDATE 100
#define DEBUGGING 0
double compile_date()
{
string datestr = __DATE__;
string timestr = __TIME__;
istringstream iss_date(datestr);
string str_month;
int day;
int year;
iss_date >> str_month >> day >> year;
int month;
if (str_month == "Jan") month = 1;
else if (str_month == "Feb") month = 2;
else if (str_month == "Mar") month = 3;
else if (str_month == "Apr") month = 4;
else if (str_month == "May") month = 5;
else if (str_month == "Jun") month = 6;
else if (str_month == "Jul") month = 7;
else if (str_month == "Aug") month = 8;
else if (str_month == "Sep") month = 9;
else if (str_month == "Oct") month = 10;
else if (str_month == "Nov") month = 11;
else if (str_month == "Dec") month = 12;
else return ((double)0.0);
return ((double)year + ((double)month / (double)100.0) + ((double)day / (double)10000.0));
}
struct PredIgnoreCase
{
bool operator() (const string& str1, const string& str2) const
{
string str1NoCase(str1), str2NoCase(str2);
transform(str1.begin(), str1.end(), str1NoCase.begin(), ::tolower);
transform(str2.begin(), str2.end(), str2NoCase.begin(), ::tolower);
return (str1NoCase < str2NoCase);
};
};
enum
{
STATE_DEAD = 0x00000001, STATE_FEIGN = 0x00000002, STATE_DUCK = 0x00000004, STATE_BIND = 0x00000008,
STATE_STAND = 0x00000010, STATE_SIT = 0x00000020, STATE_MOUNT = 0x00000040, STATE_INVIS = 0x00000080,
STATE_LEV = 0x00000100, STATE_ATTACK = 0x00000200, STATE_MOVING = 0x00000400, STATE_STUN = 0x00000800,
STATE_RAID = 0x00001000, STATE_GROUP = 0x00002000, STATE_LFG = 0x00004000, STATE_AFK = 0x00008000,
STATE_ITU = 0x00010000, STATE_RANGED = 0x00020000, STATE_WANTAGGRO = 0x00040000, STATE_HAVEAGGRO = 0x00080000,
STATE_HOVER = 0x00100000
};
enum
{
BUFFS, CASTD, ENDUS, EXPER, LEADR, LEVEL, LIFES, MANAS, PBUFF,
PETIL, SPGEM, SONGS, STATE, TARGT, ZONES, DURAS, LOCAT, HEADN,
AAPTS, OOCST, NOTE, DETR, MSTATE, MNAME, NAVACT, NAVPAU, NVERS,
BOTACT, CAMPSTATUS, CAMPX, CAMPY, CAMPRADIUS, CAMPDISTANCE, EQBC,
FREEINV, GROUPLEADER, LUAINFO, QUERY, ESIZE
};
enum
{
RESERVED, DETRIMENTALS, COUNTERS, BLINDED, CASTINGLEVEL, CHARMED, CURSED, DISEASED, ENDUDRAIN,
FEARED, HEALING, INVULNERABLE, LIFEDRAIN, MANADRAIN, MESMERIZED, POISONED, RESISTANCE, ROOTED,
SILENCED, SLOWED, SNARED, SPELLCOST, SPELLDAMAGE, SPELLSLOWED, TRIGGR, CORRUPTED, NOCURE, DSIZE
};
enum
{
MACRO_NONE, MACRO_RUNNING, MACRO_PAUSED
};
class BotInfo
{
public:
char Name[0x40]; // Client NAME
char Leader[0x40]; // Leader Name
DWORD State; // State
long ZoneID; // Zone ID
long InstID; // Instance ID
long SpawnID; // Spawn ID
long ClassID; // Class ID
long Level; // Level
long CastID; // Casting Spell ID
long LifeCur; // HP Current
long LifeMax; // HP Maximum
long EnduCur; // ENDU Current
long EnduMax; // ENDU Maximum
long ManaCur; // MANA Current
long ManaMax; // MANA Maximum
long PetID; // PET ID
long PetHP; // PET HP Percentage
long TargetID; // Target ID
long TargetHP; // Target HP Percentage
long Gem[NUM_SPELL_GEMS]; // Spell Memorized
long Pets[PETS_MAX]; // Spell Pets
long Song[NUM_SHORT_BUFFS]; // Spell Song
long Buff[NUM_LONG_BUFFS]; // Spell Buff
long Duration[NUM_LONG_BUFFS]; // Buff duration
long FreeBuff; // FreeBuffSlot;
char GroupLeader[64]; // Group Leader Name
#if HAS_LEADERSHIP_EXPERIENCE
double glXP; // glXP
#endif
DWORD aaXP; // aaXP
__int64 XP; // XP
DWORD Updated; // Update
char Location[0x40]; // Y,X,Z
char Heading[0x40]; // Heading
long TotalAA; // totalAA
long UsedAA; // usedAA
long UnusedAA; // unusedAA
DWORD CombatState; // CombatState
char Note[NOTE_MAX]; // User Mesg
int Detrimental[DSIZE];
int MacroState;
char MacroName[MAX_PATH];
char LuaInfo[MAX_STRING];
bool NavActive;
bool NavPaused;
double Version;
bool bBotActive;
bool MakeCampStatus;
double MakeCampX;
double MakeCampY;
double MakeCampRadius;
double MakeCampDistance;
float X; // Break loc down
float Y; //
float Z; //
ULONGLONG EQBC_Packets;
ULONGLONG EQBC_HeartBeat;
int FreeInventory;
char Query[MAX_STRING];
};
#define TIME unsigned long long
long NetInit = 0; // Plugin Initialized?
long NetStat = 0; // Plugin is On?
long NetGrab = 0; // Grab Information?
long NetSend = 0; // Send Information?
long NetLast = 0; // Last Send Time Mark
char NetNote[NOTE_MAX]; // Network Note
TIME NetShow = 0; // Flag for showing UI window
char NetQuery[MAX_STRING]; // Network Query
map<string, BotInfo, PredIgnoreCase> NetMap; // BotInfo Mapped List
Blech Packet('#'); // BotInfo Event Triggers
BotInfo* CurBot = 0; // BotInfo Current
long sTimers[ESIZE]; // Save Timers
char sBuffer[ESIZE][MAX_STRING]; // Save Buffer
char wBuffer[ESIZE][MAX_STRING]; // Work Buffer
bool wChange[ESIZE]; // Work Change
bool wUpdate[ESIZE]; // Work Update
int dValues[DSIZE];
bool bExtended = false; // Allow extended info?
bool bUseSimpleSearch = false; // Allow any substring of Buff/ShortBuff/PetBuff to return result
bool bSendBuffs = false;
bool bSendPetBuffs = false;
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
void WriteWindowINI(CSidlScreenWnd* pWindow);
void ReadWindowINI(CSidlScreenWnd* pWindow);
void DestroyMyWindow();
void CreateMyWindow();
void HideMyWindow();
void ShowMyWindow();
void WindowUpdate();
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
char zOutput[MAX_STRING] = { 0 };
long Evaluate(const char* zFormat, ...)
{
va_list vaList; va_start(vaList, zFormat);
vsprintf_s(zOutput, zFormat, vaList); if (!zOutput[0]) return 1;
//DebugSpewAlways("E[%s]",zOutput);
ParseMacroData(zOutput, MAX_STRING);
//DebugSpewAlways("R[%s]",zOutput);
return atoi(zOutput);
}
bool NetParseMacroData(PCHAR szOriginal, SIZE_T BufferSize)
{
int oldParserVersion = std::exchange(gParserVersion, 2);
bool result = ParseMacroData(szOriginal, BufferSize);
gParserVersion = oldParserVersion;
return result;
}
bool EQBCConnected()
{
using fEqbcIsConnected = uint16_t(*)();
if (fEqbcIsConnected checkf = (fEqbcIsConnected)GetPluginProc("MQ2EQBC", "isConnected"))
{
return checkf();
}
return false;
}
void EQBCBroadCast(const char* Buffer)
{
using fEqbcNetBotSendMsg = void(*)(const char*);
if (strlen(Buffer) > 9)
{
if (fEqbcNetBotSendMsg requestf = (fEqbcNetBotSendMsg)GetPluginProc("MQ2EQBC", "NetBotSendMsg"))
{
#if DEBUGGING > 1
DebugSpewAlways("%s->BroadCasting(%s)", PLUGIN_TITLE, Buffer);
#endif
requestf(Buffer);
}
}
}
BotInfo* BotFind(const char* Name)
{
unsigned int iNameVal = atoi(Name);
if (IsNumber(Name))
{
if (iNameVal <= NetMap.size() && iNameVal > 0)
{
auto it = NetMap.begin();
std::advance(it, iNameVal - 1);
return (NetMap.end() == it) ? NULL : &(*it).second;
}
}
auto f = NetMap.find(Name);
return (NetMap.end() == f) ? NULL : &(*f).second;
}
BotInfo* BotLoad(PCHAR Name)
{
auto f = NetMap.find(Name);
if (NetMap.end() == f)
{
BotInfo RecInfo;
ZeroMemory(&RecInfo.Name, sizeof(BotInfo));
strcpy_s(RecInfo.Name, Name);
NetMap.emplace(RecInfo.Name, RecInfo);
f = NetMap.find(Name);
}
return &f->second;
}
void BotQuit(PCHAR Name)
{
auto f = NetMap.find(Name);
if (NetMap.end() != f)
NetMap.erase(f);
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
bool inGroup(const char* szName)
{
char szTemp[MAX_STRING] = { 0 };
if (pLocalPC && pLocalPlayer)
{
if (!_stricmp(szName, pLocalPC->Name))
{
return true;
}
if (pLocalPC->pGroupInfo)
{
for (int G = 1; G < MAX_GROUP_SIZE; G++)
{
sprintf_s(szTemp, "${Group.Member[%d].Name}", G);
ParseMacroData(szTemp, MAX_STRING);
if (!_stricmp(szTemp, szName))
{
return true;
}
}
}
}
return false;
}
bool inZoned(unsigned long zID, unsigned long iID)
{
int ZoneID = 0;
if (pLocalPC)
ZoneID = pLocalPC->zoneId;
if (ZoneID > MAX_ZONES)
ZoneID &= 0x7FFF;
if (ZoneID <= 0 || ZoneID >= MAX_ZONES)
return 0;
return (pLocalPC && ZoneID == zID && pLocalPC->instance == iID);
}
// ***************************************************************************
// Function: LargerEffectTest
// Description: Return boolean true if the spell effect is to be ignored
// for stacking purposes
// ***************************************************************************
bool NBLargerEffectTest(PSPELL aSpell, PSPELL bSpell, int i)
{
int aAttrib = GetSpellNumEffects(aSpell) > i ? GetSpellAttrib(aSpell, i) : SPA_NOSPELL;
int bAttrib = GetSpellNumEffects(bSpell) > i ? GetSpellAttrib(bSpell, i) : SPA_NOSPELL;
if (aAttrib == bAttrib
&& (aAttrib == SPA_HP // HP +/-: heals/regen/dd
|| aAttrib == SPA_AC // Ac Mod
|| aAttrib == SPA_STONESKIN // Add Effect: Absorb Damage
|| aAttrib == 69 // Max HP Mod
|| aAttrib == 79 // HP Mod
|| aAttrib == 114 // Aggro Multiplier
|| aAttrib == 127)) // Spell Haste
return abs(GetSpellBase(aSpell, i)) >= abs(GetSpellBase(bSpell, i));
return false;
}
// ***************************************************************************
// Function: TriggeringEffectSpell
// Description: Return boolean true if the spell effect is to be ignored
// for stacking purposes
// ***************************************************************************
BOOL NBTriggeringEffectSpell(PSPELL aSpell, int i)
{
LONG aAttrib = GetSpellNumEffects(aSpell) > i ? GetSpellAttrib(aSpell, i) : SPA_NOSPELL;
return (aAttrib == 85 // Add Proc
|| aAttrib == 374 // Trigger Spell
|| aAttrib == 419 // Add Proc
|| aAttrib == 442 // Trigger Effect
|| aAttrib == 443 // Trigger Effect
|| aAttrib == 453 // Trigger Effect
|| aAttrib == 454 // Trigger Effect
|| aAttrib == 475 // Trigger Spell Non-Item
|| aAttrib == 481); // Trigger Spell
}
// ***************************************************************************
// Function: DurationWindowTest
// Description: Return boolean true if the spell effect is to be ignored
// for stacking purposes
// ***************************************************************************
BOOL NBDurationWindowTest(PSPELL aSpell, PSPELL bSpell, int i)
{
LONG aAttrib = GetSpellNumEffects(aSpell) > i ? GetSpellAttrib(aSpell, i) : SPA_NOSPELL;
LONG bAttrib = GetSpellNumEffects(bSpell) > i ? GetSpellAttrib(bSpell, i) : SPA_NOSPELL;
if ((aSpell->SpellType != SpellType_Beneficial && aSpell->SpellType != SpellType_BeneficialGroupOnly)
|| (bSpell->SpellType != SpellType_Beneficial && bSpell->SpellType != SpellType_BeneficialGroupOnly)
|| (aSpell->DurationWindow == bSpell->DurationWindow))
return false;
return (!(aAttrib == bAttrib &&
(aAttrib == SPA_ATTACK_POWER // Attack Mod
|| aAttrib == SPA_MELEE_GUARD))); // Mitigate Melee Damage
}
// ***************************************************************************
// Function: SpellEffectTest
// Description: Return boolean true if the spell effect is to be ignored
// for stacking purposes
// ***************************************************************************
BOOL NBSpellEffectTest(PSPELL aSpell, PSPELL bSpell, int i, BOOL bIgnoreTriggeringEffects, BOOL bIgnoreCrossDuration)
{
LONG aAttrib = GetSpellNumEffects(aSpell) > i ? GetSpellAttrib(aSpell, i) : 254;
LONG bAttrib = GetSpellNumEffects(bSpell) > i ? GetSpellAttrib(bSpell, i) : 254;
return ((aAttrib == 57 || bAttrib == 57) // Levitate
|| (aAttrib == 134 || bAttrib == 134) // Limit: Max Level
|| (aAttrib == 135 || bAttrib == 135) // Limit: Resist
|| (aAttrib == 136 || bAttrib == 136) // Limit: Target
|| (aAttrib == 137 || bAttrib == 137) // Limit: Effect
|| (aAttrib == 138 || bAttrib == 138) // Limit: SpellType
|| (aAttrib == 139 || bAttrib == 139) // Limit: Spell
|| (aAttrib == 140 || bAttrib == 140) // Limit: Min Duraction
|| (aAttrib == 141 || bAttrib == 141) // Limit: Instant
|| (aAttrib == 142 || bAttrib == 142) // Limit: Min Level
|| (aAttrib == 143 || bAttrib == 143) // Limit: Min Cast Time
|| (aAttrib == 144 || bAttrib == 144) // Limit: Max Cast Time
|| (aAttrib == 254 || bAttrib == 254) // Placeholder
|| (aAttrib == 311 || bAttrib == 311) // Limit: Combat Skills not Allowed
|| (aAttrib == 339 || bAttrib == 339) // Trigger DoT on cast
|| (aAttrib == 340 || bAttrib == 340) // Trigger DD on cast
|| (aAttrib == 348 || bAttrib == 348) // Limit: Min Mana
|| (aAttrib == 385 || bAttrib == 385) // Limit: SpellGroup
|| (aAttrib == 391 || bAttrib == 391) // Limit: Max Mana
|| (aAttrib == 403 || bAttrib == 403) // Limit: SpellClass
|| (aAttrib == 404 || bAttrib == 404) // Limit: SpellSubclass
|| (aAttrib == 411 || bAttrib == 411) // Limit: PlayerClass
|| (aAttrib == 412 || bAttrib == 412) // Limit: Race
|| (aAttrib == 414 || bAttrib == 414) // Limit: CastingSkill
|| (aAttrib == 415 || bAttrib == 415) // Limit: Item Class
|| (aAttrib == 420 || bAttrib == 420) // Limit: Use
|| (aAttrib == 421 || bAttrib == 421) // Limit: Use Amt
|| (aAttrib == 422 || bAttrib == 422) // Limit: Use Min
|| (aAttrib == 423 || bAttrib == 423) // Limit: Use Type
|| (aAttrib == 428 || bAttrib == 428) // Limit: Skill
|| (aAttrib == 442 || bAttrib == 442) // Trigger Effect
|| (aAttrib == 443 || bAttrib == 443) // Trigger Effect
|| (aAttrib == 453 || bAttrib == 453) // Trigger Effect
|| (aAttrib == 454 || bAttrib == 454) // Trigger Effect
|| (aAttrib == 460 || bAttrib == 460) // Limit: Include Non-Focusable
|| (aAttrib == 475 || bAttrib == 475) // Trigger Spell Non-Item
|| (aAttrib == 479 || bAttrib == 479) // Limit: Value
|| (aAttrib == 480 || bAttrib == 480) // Limit: Value
|| (aAttrib == 481 || bAttrib == 481) // Trigger Spell
|| (aAttrib == 485 || bAttrib == 485) // Limit: Caster Class
|| (aAttrib == 486 || bAttrib == 486) // Limit: Caster
|| (NBLargerEffectTest(aSpell, bSpell, i)) // Ignore if the new effect is greater than the old effect
|| (bIgnoreTriggeringEffects && (NBTriggeringEffectSpell(aSpell, i) || NBTriggeringEffectSpell(bSpell, i))) // Ignore triggering effects validation
|| (bIgnoreCrossDuration && NBDurationWindowTest(aSpell, bSpell, i))); // Ignore if the effects cross Long/Short Buff windows (with exceptions)
}
// ***************************************************************************
// Function: BuffStackTest
// Description: Return boolean true if the two spells will stack
// ***************************************************************************
BOOL NBBuffStackTest(PSPELL aSpell, PSPELL bSpell, BOOL bIgnoreTriggeringEffects, BOOL bIgnoreCrossDuration)
{
if (aSpell->ID == bSpell->ID)
return true;
// We need to loop over the largest of the two, this may seem silly but one could have stacking command blocks
// which we will always need to check.
LONG effects = max(GetSpellNumEffects(aSpell), GetSpellNumEffects(bSpell));
for (int i = 0; i < effects; i++)
{
//Compare 1st Buff to 2nd. If Attrib[i]==254 its a place holder. If it is 10 it
//can be 1 of 3 things: PH(Base=0), CHA(Base>0), Lure(Base=-6). If it is Lure or
//Placeholder, exclude it so slots don't match up. Now Check to see if the slots
//have equal attribute values. If the do, they don't stack.
LONG aAttrib = 254, bAttrib = 254; // Default to placeholder ...
int64_t aBase = 0, bBase = 0, aBase2 = 0, bBase2 = 0;
if (GetSpellNumEffects(aSpell) > i)
{
aAttrib = GetSpellAttrib(aSpell, i);
aBase = GetSpellBase(aSpell, i);
aBase2 = GetSpellBase2(aSpell, i);
}
if (GetSpellNumEffects(bSpell) > i)
{
bAttrib = GetSpellAttrib(bSpell, i);
bBase = GetSpellBase(bSpell, i);
bBase2 = GetSpellBase2(bSpell, i);
}
// if (TriggeringEffectSpell(aSpell, i) || TriggeringEffectSpell(bSpell, i))
// {
// if (!BuffStackTest(GetSpellByID(TriggeringEffectSpell(aSpell, i) ? aBase2 : aSpell->ID), GetSpellByID(TriggeringEffectSpell(bSpell, i) ? bBase2 : bSpell->ID), bIgnoreTriggeringEffects))
// return false;
// }
if (bAttrib == aAttrib && !NBSpellEffectTest(aSpell, bSpell, i, bIgnoreTriggeringEffects, bIgnoreCrossDuration))
{
if (aAttrib == 55 && bAttrib == 55)
{
//WriteChatf("Increase Absorb Damage by %d over %d", aBase, bBase);
return (aBase >= bBase);
}
else if (!((bAttrib == 10 && (bBase == -6 || bBase == 0)) ||
(aAttrib == 10 && (aBase == -6 || aBase == 0)) ||
(bAttrib == 79 && bBase > 0 && bSpell->TargetType == 6) ||
(aAttrib == 79 && aBase > 0 && aSpell->TargetType == 6) ||
(bAttrib == 0 && bBase < 0) ||
(aAttrib == 0 && aBase < 0) ||
(bAttrib == 148 || bAttrib == 149) ||
(aAttrib == 148 || aAttrib == 149)))
{
return false;
}
}
//Check to see if second buffs blocks first buff:
//148: Stacking: Block new spell if slot %d is effect
//149: Stacking: Overwrite existing spell if slot %d is effect
if (bAttrib == 148 || bAttrib == 149)
{
// in this branch we know bSpell has enough slots
int tmpSlot = (bAttrib == 148 ? (int)bBase2 - 1 : GetSpellCalc(bSpell, i) - 200 - 1);
int tmpAttrib = (int)bBase;
if (GetSpellNumEffects(aSpell) > tmpSlot) // verify aSpell has that slot
{
if (GetSpellMax(bSpell, i) > 0)
{
int64_t tmpVal = abs(GetSpellMax(bSpell, i));
if (GetSpellAttrib(aSpell, tmpSlot) == tmpAttrib && GetSpellBase(aSpell, tmpSlot) < tmpVal)
{
return false;
}
}
else if (GetSpellAttrib(aSpell, tmpSlot) == tmpAttrib)
{
return false;
}
}
}
//Now Check to see if the first buff blocks second buff. This is necessary
//because only some spells carry the Block Slot. Ex. Brells and Spiritual
//Vigor don't stack Brells has 1 slot total, for HP. Vigor has 4 slots, 2
//of which block Brells.
if (aAttrib == 148 || aAttrib == 149)
{
// in this branch we know aSpell has enough slots
int tmpSlot = (aAttrib == 148 ? (int)aBase2 - 1 : GetSpellCalc(aSpell, i) - 200 - 1);
int tmpAttrib = (int)aBase;
if (GetSpellNumEffects(bSpell) > tmpSlot) // verify bSpell has that slot
{
if (GetSpellMax(aSpell, i) > 0)
{
int64_t tmpVal = abs(GetSpellMax(aSpell, i));
if (GetSpellAttrib(bSpell, tmpSlot) == tmpAttrib && GetSpellBase(bSpell, tmpSlot) < tmpVal)
{
return false;
}
}
else if (GetSpellAttrib(bSpell, tmpSlot) == tmpAttrib)
{
return false;
}
}
}
}
return true;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
void InfoSong(const char* Line)
{
char Buf[MAX_STRING];
for (long Idx = 0; Idx < NUM_SHORT_BUFFS; Idx++)
{
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Song[Idx] = atol(Buf);
}
}
void InfoPets(const char* Line)
{
char Buf[MAX_STRING];
for (long Idx = 0; Idx < PETS_MAX; Idx++)
{
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Pets[Idx] = atol(Buf);
}
}
void InfoGems(const char* Line)
{
char Buf[MAX_STRING];
if (!bExtended)
return;
for (long Idx = 0; Idx < NUM_SPELL_GEMS; Idx++)
{
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Gem[Idx] = atol(Buf);
}
}
void InfoBuff(const char* Line)
{
char Buf[MAX_STRING];
for (long Idx = 0; Idx < NUM_LONG_BUFFS; Idx++)
{
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Buff[Idx] = atol(Buf);
}
}
void InfoDura(const char* Line)
{
char Buf[MAX_STRING];
if (!bExtended)
return;
for (long Idx = 0; Idx < NUM_LONG_BUFFS; Idx++)
{
// WriteChatf("We got=%s", Line);
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Duration[Idx] = atol(Buf);
// WriteChatf("Set Duration to %s", Buf);
// WriteChatf("CurBot->Duration is %d", CurBot->Duration[Idx]);
}
}
void InfoDetr(const char* Line)
{
char Buf[MAX_STRING];
for (long Idx = 0; Idx < DSIZE; Idx++)
{
GetArg(Buf, Line, Idx + 1, FALSE, FALSE, FALSE, ':');
CurBot->Detrimental[Idx] = atoi(Buf);
}
}
void InfoLoc(const char* Line)
{
char Buf[MAX_STRING];
strcpy_s(CurBot->Location, Line);
GetArg(Buf, Line, 1, FALSE, FALSE, FALSE, ':');
CurBot->Y = (float)atof(Buf);
GetArg(Buf, Line, 2, FALSE, FALSE, FALSE, ':');
CurBot->X = (float)atof(Buf);
GetArg(Buf, Line, 3, FALSE, FALSE, FALSE, ':');
CurBot->Z = (float)atof(Buf);
}
int SlotCalculate(PSPELL spell, int slot)
{
char Buf[MAX_STRING] = { 0 };
SlotValueCalculate(Buf, spell, slot, 1);
return atoi(Buf);
}
void __stdcall ParseInfo(unsigned int ID, void* pData, PBLECHVALUE pValues)
{
if (CurBot)
while (pValues)
{
// WriteChatf("Parsing=%s", pValues->Name);
switch (atoi(pValues->Name.c_str()))
{
case 1: CurBot->ZoneID = atol(pValues->Value.c_str()) & 0x7fff; break;
case 2: CurBot->InstID = atol(pValues->Value.c_str()); break;
case 3: CurBot->SpawnID = atol(pValues->Value.c_str()); break;
case 4: CurBot->Level = atol(pValues->Value.c_str()); break;
case 5: CurBot->ClassID = atol(pValues->Value.c_str()); break;
case 6: CurBot->LifeCur = atol(pValues->Value.c_str()); break;
case 7: CurBot->LifeMax = atol(pValues->Value.c_str()); break;
case 8: if (!bExtended) CurBot->EnduCur = 0; else CurBot->EnduCur = atol(pValues->Value.c_str()); break;
case 9: if (!bExtended) CurBot->EnduMax = 0; else CurBot->EnduMax = atol(pValues->Value.c_str()); break;
case 10: CurBot->ManaCur = atol(pValues->Value.c_str()); break;
case 11: CurBot->ManaMax = atol(pValues->Value.c_str()); break;
case 12: CurBot->PetID = atol(pValues->Value.c_str()); break;
case 13: CurBot->PetHP = atol(pValues->Value.c_str()); break;
case 14: CurBot->TargetID = atol(pValues->Value.c_str()); break;
case 15: CurBot->TargetHP = atol(pValues->Value.c_str()); break;
case 16: CurBot->CastID = atol(pValues->Value.c_str()); break;
case 17: CurBot->State = (DWORD)atol(pValues->Value.c_str()); break;
case 18: CurBot->XP = (__int64)atol(pValues->Value.c_str()); break;
case 19: CurBot->aaXP = (DWORD)atol(pValues->Value.c_str()); break;
#if HAS_LEADERSHIP_EXPERIENCE
case 20: CurBot->glXP = GetDoubleFromString(pValues->Value, 0.0); break;
#endif
case 21: CurBot->FreeBuff = atol(pValues->Value.c_str()); break;
case 22: strcpy_s(CurBot->Leader, pValues->Value.c_str()); break;
case 30: InfoGems(pValues->Value.c_str()); break;
case 31: InfoBuff(pValues->Value.c_str()); break;
case 32: InfoSong(pValues->Value.c_str()); break;
case 33: InfoPets(pValues->Value.c_str()); break;
case 34: InfoDura(pValues->Value.c_str()); break;
case 35: CurBot->TotalAA = atol(pValues->Value.c_str()); break;
case 36: CurBot->UsedAA = atol(pValues->Value.c_str()); break;
case 37: CurBot->UnusedAA = atol(pValues->Value.c_str()); break;
case 38: CurBot->CombatState = atol(pValues->Value.c_str()); break;
case 39: strcpy_s(CurBot->Note, pValues->Value.c_str()); break;
case 40: InfoDetr(pValues->Value.c_str()); break;
case 89: InfoLoc(pValues->Value.c_str()); break;
case 90: strcpy_s(CurBot->Heading, pValues->Value.c_str()); break;
case 91: CurBot->MacroState = atoi(pValues->Value.c_str()); break;
case 92: strcpy_s(CurBot->MacroName, pValues->Value.c_str()); break;
case 93: CurBot->NavActive = !_stricmp(pValues->Value.c_str(), "TRUE") ? true : false; break;
case 94: CurBot->NavPaused = !_stricmp(pValues->Value.c_str(), "TRUE") ? true : false; break;
case 95: CurBot->Version = atof(pValues->Value.c_str()); break;
case 96: CurBot->bBotActive = !_stricmp(pValues->Value.c_str(), "TRUE") ? true : false; break;
case 97: CurBot->MakeCampStatus = !_stricmp(pValues->Value.c_str(), "ON") ? true : false; break;
case 98: CurBot->MakeCampX = atof(pValues->Value.c_str()); break;
case 99: CurBot->MakeCampY = atof(pValues->Value.c_str()); break;
case 100: CurBot->MakeCampRadius = atof(pValues->Value.c_str()); break;
case 101: CurBot->MakeCampDistance = atof(pValues->Value.c_str()); break;
case 102:
{
CurBot->EQBC_Packets = 0;
CurBot->EQBC_HeartBeat = 0;
char szTemp[MAX_STRING] = { 0 };
char* token1 = NULL, * next_token1 = NULL;
bool iSet = false;
strcpy_s(szTemp, pValues->Value.c_str());
token1 = strtok_s(szTemp, ",", &next_token1);
while (token1 != NULL)
{
if (token1 != NULL)
{
if (strlen(token1))
{
ULONGLONG ulValue = strtoull(token1, NULL, 10);
if (!iSet)
CurBot->EQBC_Packets = ulValue;
else
CurBot->EQBC_HeartBeat = ulValue;
iSet = true;
}
token1 = strtok_s(NULL, ",", &next_token1);
}
}
break;
}
case 103:
CurBot->FreeInventory = atoi(pValues->Value.c_str()); break;
case 104:
strcpy_s(CurBot->GroupLeader, pValues->Value.c_str()); break;
case 105:
strcpy_s(CurBot->LuaInfo, pValues->Value.c_str()); break;
case 106:
strcpy_s(CurBot->Query, pValues->Value.c_str()); break;
}
pValues = pValues->pNext;
}
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
template <unsigned int SizeT>
char* MakeDURAS(char(&Buffer)[SizeT])
{
long SpellID, Duration;
char tmp[MAX_STRING] = { 0 };
Buffer[0] = 0;
if (!bExtended)
return Buffer;
for (int b = 0; b < NUM_LONG_BUFFS; b++)
{
if ((SpellID = GetPcProfile()->GetEffect(b).SpellID) > 0)
{
Duration = GetSpellBuffTimer(SpellID);
sprintf_s(tmp, "%d:", Duration);
strcat_s(Buffer, tmp);
}
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeBUFFS(char(&Buffer)[SizeT])
{
long SpellID;
char tmp[MAX_STRING] = { 0 };
Buffer[0] = '\0';
for (int b = 0; b < NUM_LONG_BUFFS; b++)
{
if ((SpellID = GetPcProfile()->GetEffect(b).SpellID) > 0)
{
sprintf_s(tmp, "%d:", SpellID);
strcat_s(Buffer, tmp);
}
}
sprintf_s(tmp, "|F=${Me.FreeBuffSlots}");
ParseMacroData(tmp, sizeof(tmp));
strcat_s(Buffer, tmp);
return Buffer;
}
template <unsigned int SizeT>
char* MakeCASTD(char(&Buffer)[SizeT])
{
long Casting = pLocalPlayer->CastingData.SpellID;
if (Casting > 0)
_itoa_s(Casting, Buffer, 10);
else
Buffer[0] = 0;
return Buffer;
}
template <unsigned int SizeT>
char* MakeHEADN(char(&Buffer)[SizeT])
{
if (strlen(Buffer))
{
sprintf_s(Buffer, "%4.2f", pLocalPlayer->Heading);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeLOCAT(char(&Buffer)[SizeT])
{
if (strlen(Buffer))
{
sprintf_s(Buffer, "%4.2f:%4.2f:%4.2f:%d", pLocalPlayer->Y, pLocalPlayer->X, pLocalPlayer->Z, pLocalPlayer->Animation);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeNVERS(char(&Buffer)[SizeT])
{
if (strlen(Buffer))
{
sprintf_s(Buffer, "%.2f", MQ2Version);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeENDUS(char(&Buffer)[SizeT])
{
if (long EnduMax = GetMaxEndurance()) sprintf_s(Buffer, "%d/%d", GetPcProfile()->Endurance, EnduMax);
else strcpy_s(Buffer, "/");
return Buffer;
}
template <unsigned int SizeT>
char* MakeEXPER(char(&Buffer)[SizeT])
{
#if HAS_LEADERSHIP_EXPERIENCE
sprintf_s(Buffer, "%I64d:%d:%02.3f", pLocalPC->Exp, pLocalPC->AAExp, pLocalPC->GroupLeadershipExp);
#else
sprintf_s(Buffer, "%I64d:%d", pLocalPC->Exp, pLocalPC->AAExp);
#endif
return Buffer;
}
template <unsigned int SizeT>
char* MakeLEADR(char(&Buffer)[SizeT])
{
if (pLocalPC && pLocalPC->pGroupInfo && pLocalPC->pGroupInfo->GetGroupLeader())
strcpy_s(Buffer, pLocalPC->pGroupInfo->GetGroupLeader()->GetName());
else
Buffer[0] = 0;
return Buffer;
}
template <unsigned int SizeT>
char* MakeNOTE(char(&Buffer)[SizeT])
{
strcpy_s(Buffer, NetNote);
return Buffer;
}
template <unsigned int SizeT>
char* MakeMNAME(char(&Buffer)[SizeT])
{
strcpy_s(Buffer, gszMacroName);
return Buffer;
}
template <unsigned int SizeT>
char* MakeMSTATE(char(&Buffer)[SizeT])
{
WORD Status = MACRO_NONE;
if (gszMacroName[0])
{
Status = MACRO_RUNNING;
MQMacroBlockPtr pBlock = GetCurrentMacroBlock();
if (pBlock && pBlock->Paused)
Status = MACRO_PAUSED;
}
_itoa_s(Status, Buffer, 10);
return Buffer;
}
template <unsigned int SizeT>
char* MakeLUA(char(&Buffer)[SizeT])
{
char szTemp[MAX_STRING] = { 0 };
char szScriptName[MAX_STRING] = { 0 };
char* token = NULL;
char* next_token = NULL;
Buffer[0] = '\0';
strcpy_s(szTemp, "${Lua.PIDs}");
ParseMacroData(szTemp, sizeof(szTemp));
token = strtok_s(szTemp, ",", &next_token);
while (token != NULL)
{
sprintf_s(szScriptName, "${Lua.Script[%s].Name}", token);
ParseMacroData(szScriptName, sizeof(szScriptName));
if (szScriptName[0] && _stricmp(szScriptName, "NULL"))
{
if (strlen(Buffer))
strcat_s(Buffer, ",");
strcat_s(Buffer, szScriptName);
}
token = strtok_s(NULL, ",", &next_token);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeQUERY(char(&Buffer)[SizeT])
{
char tmp[MAX_STRING] = { 0 };
strcpy_s(tmp, NetQuery);
NetParseMacroData(tmp, sizeof(tmp));
strcpy_s(Buffer, tmp);
return Buffer;
}
template <unsigned int _Size>
char* MakeFREEINV(CHAR(&Buffer)[_Size])
{
sprintf_s(Buffer, "%d", GetFreeInventory(0));
return Buffer;
}
template <unsigned int SizeT>
char* MakeNAVACT(char(&Buffer)[SizeT])
{
strcpy_s(Buffer, "0");
if (GetPlugin("MQ2Nav"))
{
strcpy_s(Buffer, "${Navigation.Active}");
ParseMacroData(Buffer, SizeT);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeNAVPAU(char(&Buffer)[SizeT])
{
strcpy_s(Buffer, "0");
if (GetPlugin("MQ2Nav"))
{
strcpy_s(Buffer, "${Navigation.Paused}");
ParseMacroData(Buffer, SizeT);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeBOTACTIVE(char(&Buffer)[SizeT])
{
strcpy_s(Buffer, "0");
if (GetPlugin("mq2bot"))
{
strcpy_s(Buffer, "${Bot.Active}");
ParseMacroData(Buffer, SizeT);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeEQBC(char(&Buffer)[SizeT])
{
char szTemp[MAX_STRING] = { 0 };
strcpy_s(Buffer, "0,0");
if (GetPlugin("mq2eqbc"))
{
strcpy_s(szTemp, "${EQBC.Packets}");
ParseMacroData(szTemp, MAX_STRING);
strcpy_s(Buffer, SizeT, szTemp);
strcpy_s(szTemp, "${EQBC.HeartBeat}");
ParseMacroData(szTemp, MAX_STRING);
strcat_s(Buffer, SizeT, ",");
strcat_s(Buffer, SizeT, szTemp);
}
return Buffer;
}
template <unsigned int SizeT>
char* MakeMAKECAMPSTATUS(char(&Buffer)[SizeT])