-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMQ2NetBots.cpp
More file actions
4085 lines (3919 loc) · 124 KB
/
MQ2NetBots.cpp
File metadata and controls
4085 lines (3919 loc) · 124 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
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// 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
//
// v2.1 woobs
// - Upped most of the maximum values to handle more buffs.
// - Add Detrimental information to merge in MQ2Debuffs functions
// v2.2 eqmule
// - Added String Safety
// v3.0 woobs
// - Updated .Stacks
// - Added .StacksPet
// v3.1 woobs
// - Updated for Spell Blocker (148) fix from swifty.
// v3.2 woobs
// - Added NBGetEffectAmt to get adjusted values for compare.
// - Removed 85/419 from triggering formula. These Procs stack/don't stack based on
// the normal base check (for these, it is SpellID). It seems newer spells simply
// overwrite older spells.
// v4.0 woobs
// - Merged in MMOBUGS data items and in-game window (thank you MMOBUGS).
// - Added Detrimental/Beneficial buff type data items.
// - Remove internal Stacks/StacksPet. Use new EQ/MQ coding.
// - Added WillLand,WillLandPet,TooPowerful,TooPowerfulPet.
// - Added Extended data options for Gems and Buff/Song/Pet Durations.
// - Added TotalCounters,CountersCurse,CountersDisease,CountersPoison,CountersCorruption
// to accurately report current counters on the client (not counters on the spell).
// - Added PetAffinity and AAPointsAssigned.
// - Added a new version of the in-game window (switchable with old) along with new
// ini and command options. LClick,RClick,ConColors,CleanNames.
// - Code clean-up.
#include <mq/Plugin.h>
#include <Blech/Blech.h>
#include <string>
PreSetup("MQ2NetBots");
PLUGIN_VERSION(4.0);
#define PLUGIN_NAME "MQ2NetBots"
bool DEBUGGING = false;
constexpr int PETS_MAX = MAX_TOTAL_BUFFS_NPC;
constexpr int NOTE_MAX = 500;
constexpr int NETTICK = 50;
constexpr int REFRESH = 60000;
constexpr int UPDATES = 6000;
#if defined(ROF2EMU)
constexpr char PetAAName[] = "Pet Affinity";
constexpr int PetAARank = 1;
#else
constexpr char PetAAName[] = "Companion's Suspension";
constexpr int PetAARank = 3;
#endif
enum eStates : uint32_t {
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_ITU = 0x00000100,
STATE_ATTACK = 0x00000200,
STATE_MOVING = 0x00000400,
STATE_STUN = 0x00000800,
STATE_RAID = 0x00001000,
STATE_GROUP = 0x00002000,
STATE_LFG = 0x00004000,
STATE_AFK = 0x00008000,
STATE_LEV = 0x00010000,
STATE_RANGED = 0x00020000,
STATE_WANTAGGRO = 0x00040000,
STATE_HAVEAGGRO = 0x00080000,
STATE_HOVER = 0x00100000,
STATE_NAVACTIVE = 0x00200000,
STATE_NAVPAUSED = 0x00400000,
STATE_BOTACTIVE = 0x00800000,
STATE_HASPETAA = 0x01000000
};
enum eElements {
E_BUFFS,
E_CASTD,
E_ENDUS,
E_EXPER,
E_LEADR,
E_LEVEL,
E_HPS,
E_MANAS,
E_PBUFF,
E_PETIL,
E_SPGEM,
E_SONGS,
E_STATE,
E_TARGT,
E_ZONES,
E_BUFFD,
E_LOCAT,
E_HEADN,
E_AAPTS,
E_OOCST,
E_NOTE,
E_DETR,
E_FREEB,
E_EXTEND,
E_MACRO,
E_FREEI,
E_VERSN,
E_CAMPS,
E_LUAINFO,
E_EQBC,
E_QUERY,
E_BSTAT,
E_SONGD,
E_PETD,
ESIZE
};
enum buffTypes {
BT_DETRIMENTAL,
BT_BENEFICIAL
};
enum buffDetrimentalStates : uint32_t {
BD_SLOWED = 0x00000001,
BD_ROOTED = 0x00000002,
BD_MESMERIZED = 0x00000004,
BD_CRIPPLED = 0x00000008,
BD_MALOED = 0x00000010,
BD_TASHED = 0x00000020,
BD_SNARED = 0x00000040,
BD_REVDSED = 0x00000080,
BD_CHARMED = 0x00000100,
BD_DISEASED = 0x00000200,
BD_POISONED = 0x00000400,
BD_CURSED = 0x00000800,
BD_CORRUPTED = 0x00001000,
BD_BLINDED = 0x00002000,
BD_CASTINGLEVEL = 0x00004000,
BD_ENDUDRAIN = 0x00008000,
BD_FEARED = 0x00010000,
BD_HEALING = 0x00020000,
BD_INVULNERABLE = 0x00040000,
BD_LIFEDRAIN = 0x00080000,
BD_MANADRAIN = 0x00100000,
BD_RESISTANCE = 0x00200000,
BD_SILENCED = 0x00400000,
BD_SPELLCOST = 0x00800000,
BD_SPELLDAMAGE = 0x01000000,
BD_SPELLSLOWED = 0x02000000,
BD_TRIGGER = 0x04000000
};
enum buffBeneficialStates : uint32_t {
BB_DSED = 0x00000001,
BB_AEGO = 0x00000002,
BB_SKIN = 0x00000004,
BB_FOCUS = 0x00000008,
BB_REGEN = 0x00000010,
BB_SYMBOL = 0x00000020,
BB_CLARITY = 0x00000040,
BB_PRED = 0x00000080,
BB_STRENGTH = 0x00000100,
BB_BRELLS = 0x00000200,
BB_SV = 0x00000400,
BB_SE = 0x00000800,
BB_HYBRIDHP = 0x00001000,
BB_GROWTH = 0x00002000,
BB_SHINING = 0x00004000,
BB_HASTED = 0x00008000
};
enum eSpellTypes {
ST_SLOWED = 1,
ST_ROOTED,
ST_MESMERIZED,
ST_CRIPPLED,
ST_MALOED,
ST_TASHED,
ST_SNARED,
ST_REVDSED,
ST_CHARMED,
ST_DISEASED,
ST_POISONED,
ST_CURSED,
ST_CORRUPTED,
ST_BLINDED,
ST_CASTINGLEVEL,
ST_ENDUDRAIN,
ST_FEARED,
ST_HEALING,
ST_INVULNERABLE,
ST_LIFEDRAIN,
ST_MANADRAIN,
ST_RESISTANCE,
ST_SILENCED,
ST_SPELLCOST,
ST_SPELLDAMAGE,
ST_SPELLSLOWED,
ST_TRIGGER,
ST_DSED,
ST_AEGO,
ST_SKIN,
ST_FOCUS,
ST_REGEN,
ST_SYMBOL,
ST_CLARITY,
ST_PRED,
ST_STRENGTH,
ST_BRELLS,
ST_SV,
ST_SE,
ST_HYBRIDHP,
ST_GROWTH,
ST_SHINING,
ST_HASTED
};
enum eDetrimentals {
D_DETRIMENTALS,
D_COUNTERS,
D_CURSED,
D_DISEASED,
D_POISONED,
D_CORRUPTED,
D_NOCURE,
D_LIFEDRAIN,
D_MANADRAIN,
D_ENDUDRAIN,
DSIZE
};
enum eItemSize {
I_TINY = 0,
I_SMALL = 1,
I_MEDIUM = 2,
I_LARGE = 3,
I_GIANT = 4,
ISIZE
};
enum eMacroStatus {
MACRO_NONE,
MACRO_RUNNING,
MACRO_PAUSED
};
enum eClickActions {
CA_NO_ACTION = 0,
CA_BRING_TO_FOREGROUND = 1,
CA_TARGET_PLAYER = 2,
CA_TARGET_PLAYER_TARGET = 3,
CASIZE
};
enum eInvisStates : uint32_t {
INVIS_NORMAL = 0x00000001,
INVIS_UNDEAD = 0x00000002
};
enum eExtended {
EX_NONE = 0,
EX_GEMS_AND_BUFF_DURATIONS = 1,
EX_SONG_DURATIONS = 2,
EX_PET_DURATIONS = 3,
EXSIZE
};
struct CaseInsensitiveComparator
{
bool operator() (const std::string& a, const std::string& b) const noexcept
{
return _stricmp(a.c_str(), b.c_str()) < 0;
}
};
class BotInfo {
public:
char Name[EQ_MAX_NAME]; // Client Name
int ClassID; // Class ID
int Level; // Level
int SpawnID; // Spawn ID
int ZoneID; // Zone ID
int InstanceID; // Instance ID
int HPCurrent; // HP Current
int HPMax; // HP Maximum
int ManaCurrent; // Mana Current
int ManaMax; // Mana Maximum
int EnduranceCurrent; // Endurance Current
int EnduranceMax; // Endurance Maximum
int PetID; // Pet ID
int PetHPPct; // Pet HP Percentage
int TargetID; // Target ID
int TargetHPPct; // Target HP Percentage
int Gem[NUM_SPELL_GEMS]; // Spells Memorized
int Buff[NUM_LONG_BUFFS]; // Buffs
int Song[NUM_SHORT_BUFFS]; // Songs
int Pets[PETS_MAX]; // Pet Buffs
int BDuration[NUM_LONG_BUFFS]; // Buff durations
int SDuration[NUM_SHORT_BUFFS]; // Song durations
int PDuration[PETS_MAX]; // Pet Buff durations
int FreeBuff; // Free Buff Slots
int CastID; // Casting Spell ID
int CombatState; // Combat State
int64_t Exp; // Experience
uint32_t AAExp; // AA Experience
#if HAS_LEADERSHIP_EXPERIENCE
double GroupLeaderExp; // Group Leadership Experience
#endif
char Leader[EQ_MAX_NAME]; // Group Leader Name
char Location[64]; // Y,X,Z
float X; // Location X-value
float Y; // Location Y-value
float Z; // Location Z-value
char Heading[64]; // Heading
int AAPoints; // Unused AA Points
int AAPointsSpent; // Spent AA Points
int AAPointsAssigned; // Assigned AA Points
uint32_t State; // State
uint32_t DetrState; // Detrimental Buff States
uint32_t BeneState; // Beneficial Buff States
int64_t Detrimental[DSIZE]; // Detrimentals
int FreeInventory[ISIZE]; // Free Inventory Slots of, at least, size 0-4
float Version; // Plugin Version
int Extended; // Extended Setting
int MacroState; // Current Macro State (0=No Macro Running,1=Running,2=Paused)
char MacroName[MAX_PATH]; // Current Macro Name
int MakeCampStatus; // MakeCamp Status (0=None/OFF,1=ON,2=PAUSED)
float MakeCampX; // MakeCamp AnchorX
float MakeCampY; // MakeCamp AnchorY
float MakeCampRadius; // MakeCamp CampRadius
float MakeCampDistance; // MakeCamp CampDistance
char LuaInfo[MAX_STRING]; // LUA Process Info
uint64_t EQBC_Packets; // EQBC Packets
uint64_t EQBC_HeartBeat; // EQBC HeartBeat
char Note[NOTE_MAX]; // User Message
char Query[MAX_STRING]; // Result of NetQuery
uint32_t Updated; // Update Time
};
int NetInit = 0; // Plugin Initialized?
int NetStat = 0; // Plugin is On?
int NetGrab = 0; // Grab Information?
int NetSend = 0; // Send Information?
int NetExtended = 0; // Send Extended Information (0=None, 1=Gems+Buff Durations, 2=Add Short Durations, 3= Add Pet Buff Durations)
int NetSimple = 0; // Allow any substring of Buff/ShortBuff/PetBuff to return result
int NetShow = 0; // Show UI window?
int NetLClick = 0; // UI Window Left Click Action
int NetRClick = 0; // UI Window Right Click Action
int NetConColors = 0; // Use NPC Con Colors in UI Window
int NetCleanNames = 0; // Use NPC Clean Names in UI Window
int NetRightMost = 0; // If > 0, only send this number right-most characters of target name in UI Window
int NetUseNewWindow = -1; // 0/1 Use Old/New NetBots Window layout (requires the associated MQUI_NetBotsWnd.xml file)
int NetEQBCData = 0; // Send EQBC Packets/Heartbeat data
int NetLast = 0; // Last Send Time Mark
uint64_t ShowTime = 0; // Window Show Time Mark
char NetNote[NOTE_MAX]; // Network Note
char NetQuery[MAX_STRING]; // Network Query
char NetWindowTitle[MAX_STRING]; // UI Window Title (Can be Macro-Parsed)
std::map<std::string, std::shared_ptr<BotInfo>, CaseInsensitiveComparator> NetMap; // BotInfo Mapped List
Blech Packet('#'); // BotInfo Event Triggers
BotInfo *CurBot = 0; // BotInfo Current Bot
int 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
char bBuffs[MAX_STRING]; // Buff List
char bSongs[MAX_STRING]; // Song List
char bPBuffs[MAX_STRING]; // Pet Buff List
char bBuffd[MAX_STRING]; // Buff Duration List
char bSongd[MAX_STRING]; // Song Duration List
char bPBuffd[MAX_STRING]; // Pet Buff Duration List
uint32_t detrStatus; // Detrimental Buff Status (States)
uint32_t beneStatus; // Beneficial Buff Status (States)
uint32_t invisStatus; // Invisible Buff Status (States)
int64_t dValues[DSIZE]; // Detrimental Counters and Drain Values
int AvailBuffSlots; // Available Buff Slots
char GlobalINIFileName[MAX_STRING] = { 0 };
char PlayerSectionName[MAX_STRING] = { 0 };
char WindowID[MAX_STRING] = { 0 };
char ScreenID[MAX_STRING] = { 0 };
struct BuffData { // Buff Data (for mapped list)
int Type; // Buff Type (BT_) Enum
uint32_t State; // Buff Detrimental/Benefical State (BD_/BB_) Enum
int SpellType; // Buff Spell Type (ST_) Enum
BuffData(int i, uint32_t j, int k) : Type(i), State(j), SpellType(k) {}
};
std::map<std::string, BuffData> BuffMap; // Buff Data Mapped List
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
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) {
DebugSpewAlways("%s->BroadCasting(%s)", PLUGIN_NAME, Buffer);
}
requestf(Buffer);
}
}
}
std::shared_ptr<BotInfo> BotLoad(const char* Name) {
BotInfo RecInfo;
ZeroMemory(&RecInfo.Name, sizeof(BotInfo));
strcpy_s(RecInfo.Name, Name);
auto [f, _] = NetMap.emplace(RecInfo.Name, std::make_shared<BotInfo>(RecInfo));
return f->second;
}
void BotQuit(const char* Name) {
auto f = NetMap.find(Name);
if (NetMap.end() != f)
NetMap.erase(f);
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
void InfoSong(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for (int i = 0; i < NUM_SHORT_BUFFS; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->Song[i] = GetIntFromString(szTemp, 0);
}
}
void InfoPets(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for (int i = 0; i < PETS_MAX; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->Pets[i] = GetIntFromString(szTemp, 0);
}
}
void InfoGems(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for(int i = 0; i < NUM_SPELL_GEMS; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->Gem[i] = GetIntFromString(szTemp, 0);
}
}
void InfoBuff(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for (int i = 0; i < NUM_LONG_BUFFS; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->Buff[i] = GetIntFromString(szTemp, 0);
}
}
void InfoBDura(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for(int i = 0; i < NUM_LONG_BUFFS; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->BDuration[i] = GetIntFromString(szTemp, 0);
}
}
void InfoSDura(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for(int i = 0; i < NUM_SHORT_BUFFS; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->SDuration[i] = GetIntFromString(szTemp, 0);
}
}
void InfoPDura(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for(int i = 0; i < PETS_MAX; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->PDuration[i] = GetIntFromString(szTemp, 0);
}
}
void InfoDetr(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for (int i = 0; i < DSIZE; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->Detrimental[i] = GetInt64FromString(szTemp, 0);
}
}
void InfoLoc(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
strcpy_s(botInfo->Location, Line);
GetArg(szTemp, Line, 1, FALSE, FALSE, FALSE, ':');
botInfo->Y = GetFloatFromString(szTemp, 0);
GetArg(szTemp, Line, 2, FALSE, FALSE, FALSE, ':');
botInfo->X = GetFloatFromString(szTemp, 0);
GetArg(szTemp, Line, 3, FALSE, FALSE, FALSE, ':');
botInfo->Z = GetFloatFromString(szTemp, 0);
}
void InfoFreeI(BotInfo* botInfo, const char* Line) {
char szTemp[MAX_STRING];
for (int i = 0; i < ISIZE; i++) {
GetArg(szTemp, Line, i + 1, FALSE, FALSE, FALSE, ':');
botInfo->FreeInventory[i] = GetIntFromString(szTemp, 0);
}
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
bool Evaluate(const char* expression) {
char szTemp[MAX_STRING] = { 0 };
strcpy_s(szTemp, expression);
ParseMacroData(szTemp, sizeof(szTemp));
return GetIntFromString(szTemp, 0) != 0;
}
int GetAARankByName(const char* AAName) {
int level = pLocalPlayer->Level;
for (int nAbility = 0; nAbility < AA_CHAR_MAX_REAL; nAbility++) {
if (CAltAbilityData* pAbility = GetAAById(pLocalPC->GetAlternateAbilityId(nAbility), level)) {
if (const char* pName = pCDBStr->GetString(pAbility->nName, eAltAbilityName)) {
if (!_stricmp(AAName, pName)) {
int CurrentRank = pAbility->CurrentRank - 1;
if (pLocalPC->HasAlternateAbility(pAbility->Index)) {
CurrentRank++;
}
return CurrentRank;
}
}
}
}
return 0;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
template <unsigned int _Size>char* MakeBUFFS(char(&Buffer)[_Size]) {
strcpy_s(Buffer, bBuffs);
return Buffer;
}
template <unsigned int _Size>char* MakeBUFFD(char(&Buffer)[_Size]) {
if (NetExtended >= EX_GEMS_AND_BUFF_DURATIONS) {
strcpy_s(Buffer, bBuffd);
} else {
Buffer[0] = 0;
}
return Buffer;
}
template <unsigned int _Size>char* MakeSONGS(char(&Buffer)[_Size]) {
strcpy_s(Buffer, bSongs);
return Buffer;
}
template <unsigned int _Size>char* MakeSONGD(char(&Buffer)[_Size]) {
if (NetExtended >= EX_SONG_DURATIONS) {
strcpy_s(Buffer, bSongd);
} else {
Buffer[0] = 0;
}
return Buffer;
}
template <unsigned int _Size>char* MakePBUFF(char(&Buffer)[_Size]) {
strcpy_s(Buffer, bPBuffs);
return Buffer;
}
template <unsigned int _Size>char* MakePETD(char(&Buffer)[_Size]) {
if (NetExtended >= EX_PET_DURATIONS) {
strcpy_s(Buffer, bPBuffd);
} else {
Buffer[0] = 0;
}
return Buffer;
}
template <unsigned int _Size>char* MakeFREEB(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d", AvailBuffSlots);
return Buffer;
}
template <unsigned int _Size>char* MakeCASTD(char(&Buffer)[_Size]) {
int Casting = pLocalPlayer->CastingData.SpellID;
if (Casting > 0) {
sprintf_s(Buffer, "%d", Casting);
} else {
Buffer[0] = 0;
}
return Buffer;
}
template <unsigned int _Size>char* MakeHEADN(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%4.2f", pLocalPlayer->Heading);
return Buffer;
}
template <unsigned int _Size>char* MakeLOCAT(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%4.2f:%4.2f:%4.2f:%d", pLocalPlayer->Y, pLocalPlayer->X, pLocalPlayer->Z, pLocalPlayer->Animation);
return Buffer;
}
template <unsigned int _Size>char* MakeENDUS(char(&Buffer)[_Size]) {
if (int Max = GetMaxEndurance()) {
sprintf_s(Buffer, "%d/%d", GetCurEndurance(), Max);
} else {
strcpy_s(Buffer, "/");
}
return Buffer;
}
template <unsigned int _Size>char* MakeMACRO(char(&Buffer)[_Size]) {
int Status = MACRO_NONE;
if (gszMacroName[0]) {
Status = MACRO_RUNNING;
if (MQMacroBlockPtr pBlock = GetCurrentMacroBlock()) {
if (pBlock->Paused) {
Status = MACRO_PAUSED;
}
}
sprintf_s(Buffer, "%d:%s", Status, gszMacroName);
} else {
sprintf_s(Buffer, "%d:", Status);
}
return Buffer;
}
template <unsigned int _Size>char* MakeEXPER(char(&Buffer)[_Size]) {
#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 _Size>char* MakeLEADR(char(&Buffer)[_Size]) {
Buffer[0] = 0;
if (pLocalPC && pLocalPC->Group && pLocalPC->Group->GetGroupLeader()) {
strcpy_s(Buffer, pLocalPC->Group->GetGroupLeader()->GetName());
}
return Buffer;
}
template <unsigned int _Size>char* MakeNOTE(char(&Buffer)[_Size]) {
strcpy_s(Buffer, NetNote);
return Buffer;
}
template <unsigned int _Size>char* MakeLEVEL(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d:%d", GetPcProfile()->Level, GetPcProfile()->Class);
return Buffer;
}
template <unsigned int _Size>char* MakeHPS(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d/%d", GetCurHPS(), GetMaxHPS());
return Buffer;
}
template <unsigned int _Size>char* MakeMANAS(char(&Buffer)[_Size]) {
if (int Max = GetMaxMana()) {
sprintf_s(Buffer, "%d/%d", GetCurMana(), Max);
} else {
strcpy_s(Buffer, "/");
}
return Buffer;
}
template <unsigned int _Size>char* MakePETIL(char(&Buffer)[_Size]) {
auto Pet = GetSpawnByID(pLocalPlayer->PetID);
if (Pet && pPetInfoWnd) {
sprintf_s(Buffer, "%d:%d", Pet->SpawnID, static_cast<int32_t>(Pet->HPMax == 0 ? 0 : Pet->HPCurrent * 100 / Pet->HPMax));
} else {
strcpy_s(Buffer, ":");
}
return Buffer;
}
template <unsigned int _Size>char* MakeSPGEM(char(&Buffer)[_Size]) {
Buffer[0] = '\0';
if (NetExtended >= EX_GEMS_AND_BUFF_DURATIONS) {
char szTemp[MAX_STRING] = { 0 };
for (int i = 0; i < NUM_SPELL_GEMS; i++) {
if (auto pSpell = GetSpellByID(GetMemorizedSpell(i))) {
sprintf_s(szTemp, "%d:", pSpell->ID);
strcat_s(Buffer, szTemp);
}
else {
strcat_s(Buffer,"0:");
}
}
}
return Buffer;
}
template <unsigned int _Size>char* MakeBSTAT(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%u:%u", detrStatus, beneStatus);
return Buffer;
}
template <unsigned int _Size>char* MakeSTATE(char(&Buffer)[_Size]) {
uint32_t Status = 0;
if (pEverQuestInfo->bAutoAttack) {
Status |= STATE_ATTACK;
}
if (pEverQuestInfo->bAutoRangeAttack) {
Status |= STATE_RANGED;
}
if (pRaid && pRaid->RaidMemberCount) {
Status |= STATE_RAID;
}
if (pLocalPlayer->PlayerState & 0x20) {
Status |= STATE_STUN;
}
if (pLocalPC->pGroupInfo) {
Status |= STATE_GROUP;
}
if (fabs(pLocalPlayer->SpeedRun) > 0.0f) {
Status |= STATE_MOVING;
}
if (pLocalPlayer->Mount) {
Status |= STATE_MOUNT;
}
if (pLocalPlayer->AFK) {
Status |= STATE_AFK;
}
if ((pLocalPlayer->HideMode & 0x01) ||
(invisStatus & INVIS_NORMAL)) {
Status |= STATE_INVIS;
}
if (invisStatus & INVIS_UNDEAD) {
Status |= STATE_ITU;
}
if (pLocalPlayer->mPlayerPhysicsClient.Levitate == 2) {
Status |= STATE_LEV;
}
if (pLocalPlayer->LFG) {
Status |= STATE_LFG;
}
if (pLocalPlayer->RespawnTimer != 0) {
Status |= STATE_HOVER;
}
switch (pLocalPlayer->StandState) {
case STANDSTATE_STAND:
Status |= STATE_STAND;
break;
case STANDSTATE_SIT:
Status |= STATE_SIT;
break;
case STANDSTATE_DUCK:
Status |= STATE_DUCK;
break;
case STANDSTATE_BIND:
Status |= STATE_BIND;
break;
case STANDSTATE_FEIGN:
Status |= STATE_FEIGN;
break;
case STANDSTATE_DEAD:
Status |= STATE_DEAD;
break;
default:
break;
}
if (pTarget && pLocalPlayer->TargetOfTarget == pLocalPlayer->GetId()) {
if (GetSpawnType(pTarget) == NPC) {
Status |= STATE_HAVEAGGRO;
}
}
if (int i = IsPluginLoaded("MQ2Melee") ? Evaluate("${If[${Melee.AggroMode},1,0]}") : 0) {
Status |= STATE_WANTAGGRO;
}
if (IsPluginLoaded("MQ2Nav")) {
if (Evaluate("${If[${Navigation.Active},1,0]}")) {
Status |= STATE_NAVACTIVE;
}
if (Evaluate("${If[${Navigation.Paused},1,0]}")) {
Status |= STATE_NAVPAUSED;
}
}
if (int i = IsPluginLoaded("MQ2Bot") ? Evaluate("${If[${Bot.Active},1,0]}") : 0) {
Status |= STATE_BOTACTIVE;
}
if (int Rank = GetAARankByName(PetAAName)) {
if (Rank >= PetAARank) {
Status |= STATE_HASPETAA;
}
}
sprintf_s(Buffer, "%u", Status);
return Buffer;
}
template <unsigned int _Size>char* MakeOOCST(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d", GetCombatState());
return Buffer;
}
template <unsigned int _Size>char* MakeAAPTS(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d:%d:%d", GetPcProfile()->AAPoints, GetPcProfile()->AAPointsSpent, GetPcProfile()->AAPointsAssigned[0]);
return Buffer;
}
template <unsigned int _Size>char* MakeTARGT(char(&Buffer)[_Size]) {
if (pTarget) {
sprintf_s(Buffer, "%d:%d", pTarget->SpawnID, static_cast<int32_t>(pTarget->HPMax == 0 ? 0 : pTarget->HPCurrent * 100 / pTarget->HPMax));
} else {
strcpy_s(Buffer, ":");
}
return Buffer;
}
template <unsigned int _Size>char* MakeZONES(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d:%d>%d", pLocalPC->zoneId, pLocalPC->instance, pLocalPlayer->SpawnID);
return Buffer;
}
template <unsigned int _Size>char* MakeDETR(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING];
Buffer[0] = 0;
for (int i = 0; i < DSIZE; i++) {
sprintf_s(szTemp, "%lld:", dValues[i]);
strcat_s(Buffer, szTemp);
}
return Buffer;
}
template <unsigned int _Size>char* MakeFREEI(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING];
Buffer[0] = 0;
int freeSlots[ISIZE] = { 0 };
int slotMax = ISIZE - 1;
for (int slot = InvSlot_FirstBagSlot; slot <= GetHighestAvailableBagSlot(); slot++) {
if (ItemPtr pItem = GetPcProfile()->InventoryContainer.GetItem(slot)) {
if (pItem->IsContainer()) {
int iSize = std::clamp((int)pItem->GetItemDefinition()->SizeCapacity, 0, slotMax);
freeSlots[iSize] += pItem->GetHeldItems().GetSize() - pItem->GetHeldItems().GetCount();
}
} else {
freeSlots[slotMax]++;
}
}
for (int slot = slotMax; slot > 0; slot--) {
freeSlots[slot - 1] += freeSlots[slot];
}
for (int i = 0; i < ISIZE; i++) {
sprintf_s(szTemp, "%d:", freeSlots[i]);
strcat_s(Buffer, szTemp);
}
return Buffer;
}
template <unsigned int _Size>char* MakeVERSN(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%.2f", MQ2Version);
return Buffer;
}
template <unsigned int _Size>char* MakeEXTEND(char(&Buffer)[_Size]) {
sprintf_s(Buffer, "%d", NetExtended);
return Buffer;
}
template <unsigned int _Size>char* MakeCAMPS(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING];
if (IsPluginLoaded("MQ2MoveUtils")) {
strcpy_s(szTemp, "${Select[${MakeCamp.Status},ON,PAUSED]}:${MakeCamp.AnchorX}:${MakeCamp.AnchorY}:${MakeCamp.CampRadius}:${MakeCamp.CampDist}");
ParseMacroData(szTemp, sizeof(szTemp));
strcpy_s(Buffer, szTemp);
} else {
strcpy_s(Buffer, "0:0:0:0:0");
}
return Buffer;
}
template <unsigned int _Size>char* MakeLUA(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING] = { 0 };
char szScriptName[MAX_STRING] = { 0 };
char* token = NULL;
char* next_token = NULL;
Buffer[0] = '\0';
if (IsPluginLoaded("Lua")) {
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 _Size>char* MakeEQBC(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING];
if (NetEQBCData && IsPluginLoaded("MQ2EQBC")) {
strcpy_s(szTemp, "${EQBC.Packets}:${EQBC.HeartBeat}");
ParseMacroData(szTemp, sizeof(szTemp));
strcpy_s(Buffer, szTemp);
} else {
strcpy_s(Buffer, "0:0");
}
return Buffer;
}
template <unsigned int _Size>char* MakeQUERY(char(&Buffer)[_Size]) {
char szTemp[MAX_STRING] = { 0 };
strcpy_s(szTemp, NetQuery);
ParseMacroData(szTemp, sizeof(szTemp));
strcpy_s(Buffer, szTemp);
return Buffer;
}
int SlotCalculate(EQ_Spell* spell, int slot) {
char szTemp[MAX_STRING] = { 0 };
SlotValueCalculate(szTemp, spell, slot, 1);
return GetIntFromString(szTemp, 0);
}
unsigned int SpellClassMask(std::initializer_list<int> classlist) {
unsigned int mask = 0;
for (int num : classlist) {
mask |= (1 << num);
}
return mask;
}
void EvalDetrimental(EQ_Spell* spell) {
bool detr = false;
bool counter = false;
int subcat = GetSpellSubcategory(spell);
int attrib = 0;
int64_t base = 0;
for (int s = 0; s < GetSpellNumEffects(spell); s++) {
attrib = GetSpellAttrib(spell, s);
base = GetSpellBase(spell, s);
switch (attrib) {
case SPA_CHA:
break;
case SPA_HP:
if (base < 0) {
detrStatus |= BD_LIFEDRAIN;
dValues[D_LIFEDRAIN] += SlotCalculate(spell, s);
detr = true;
}
break;
case SPA_MOVEMENT_RATE:
if (base < 0) {
detrStatus |= BD_SNARED;
detr = true;
}
break;
case SPA_HASTE:
if (base < 100) {
detrStatus |= BD_SLOWED;
detr = true;
}
break;
case SPA_MANA:
if (base < 0) {
detrStatus |= BD_MANADRAIN;
dValues[D_MANADRAIN] += SlotCalculate(spell, s);
detr = true;
}
break;
case SPA_BLINDNESS:
detrStatus |= BD_BLINDED;
detr = true;
break;