forked from jewalky/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cheat_codes_new.cpp
1290 lines (1092 loc) · 39.1 KB
/
cheat_codes_new.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
#include "cheat_codes_new.h"
#include "srvmgrdef.h"
#include "lib\utils.hpp"
#include "pvm2.h"
#include "config_new.h"
#include "protolayer_hat.h"
#include "srvmgr.h"
#include <fstream>
#include "zxmgr.h"
#include "player_info.h"
#include "pktmgr.h"
#include <math.h>
#include "quests.h"
#include "scanrange.h"
#include "screenshots.h"
#include "utils.h"
uint32_t ParseFlags(std::string string)
{
if (CheckHex(string))
return HexToInt(string);
else
{
uint32_t flags = 0;
std::vector<std::string> v = Explode(string, "|");
for (std::vector<std::string>::iterator it = v.begin(); it != v.end(); ++it)
{
std::string par = ToLower(Trim((*it)));
if (!par.length())
continue;
uint32_t flag = 0;
bool erase = false;
if (par[0] == '-')
{
erase = true;
par.erase(0, 1);
}
if (par == "pvm")
flag = SVF_PVM;
else if (par == "muted")
flag = SVF_MUTED;
else if (par == "closed")
flag = SVF_CLOSED;
else if (par == "advanced_pvm")
flag = SVF_ADVPVM;
else if (par == "nohealing")
flag = SVF_NOHEALING;
else if (par == "noobsrv")
flag = SVF_NOOBSRV;
else if (par == "softcore")
flag = SVF_SOFTCORE;
else if (par == "nodrop")
flag = SVF_NODROP;
else if (par == "fnodrop")
flag = SVF_FNODROP;
else if (par == "nosaving")
flag = SVF_NOSAVING;
else if (par == "sandbox")
flag = SVF_SANDBOX;
else if (par == "entermage")
flag = SVF_ENTERMAGE;
else if (par == "enterwarrior")
flag = SVF_ENTERWARRIOR;
if (!flag)
continue;
if (!erase)
flags |= flag;
else
flags &= ~flag;
}
return flags;
}
}
char SpellNames[32][2][32] =
{
{"", 0},
{"Fire_Arrow", 1},
{"Fire_Ball", 1},
{"Wall_of_Fire", 1},
{"Protection_from_Fire", 1},
{"Ice_Missile", 2},
{"Poison_Cloud", 2},
{"Blizzard", 2},
{"Protection_from_Water", 2},
{"Acid_Stream", 2},
{"Lightning", 3},
{"Prismatic_Spray", 3},
{"Invisibility", 3},
{"Protection_from_Air", 3},
{"Darkness", 3},
{"Light", 3},
{"Diamond_Dust", 4},
{"Wall_of_Earth", 4},
{"Stone_Curse", 4},
{"Protection_from_Earth", 4},
{"Bless", 5},
{"Haste", 5},
{"Control_Spirit", 5},
{"Teleport", 5},
{"Heal", 5},
{"Summon", 5},
{"Drain_Life", 5},
{"Shield", 5},
{"Curse", 5},
{"Slow", 5},
{"", 0},
{"", 0},
};
char SpellBooks[6][10] =
{
"None",
"Fire",
"Water",
"Air",
"Earth",
"Astral",
};
void DropEverything(byte* unit, bool full = false)
{
if (Config::GameMode != 0) return;
uint32_t p_x = *(uint8_t*)(*(byte**)(unit + 0x10));
uint32_t p_y = *(uint8_t*)(*(byte**)(unit + 0x10) + 1);
uint32_t spellmask = zxmgr::GetSpells(unit);
for (int i = 0; i < 32; i++)
{
if ((1 << i) & spellmask && strlen(SpellNames[i][0]) && SpellNames[i][1][0])
{
std::string cstrp = Format("Book %s {teachSpell=%s}", SpellBooks[SpellNames[i][1][0]], SpellNames[i][0]);
zxmgr::CreateSack(cstrp.c_str(), p_x, p_y, 0);
}
}
zxmgr::SetSpells(unit, 0);
zxmgr::UpdateUnit(unit, NULL, 0xA31FFFFF, 0xFFB, 0, 0);
if (!full) return;
byte* player = *(byte**)(unit + 0x14);
if (!player) return;
uint32_t money = *(uint32_t*)(player + 0x3C);
if (!money) return;
if (money > 0x7FFFFFFF) money = 0x7FFFFFFF;
zxmgr::CreateSack(NULL, p_x, p_y, money);
*(uint32_t*)(player + 0x3C) = 0;
zxmgr::GiveMoney(player, 0, 0);
}
void ProcessCheat_Quest(byte* player, const std::string& args) {
if (!Config::AllowQuestFilters) {
zxmgr::SendMessage(player, "Quest filtering is disabled");
return;
}
T_PLAYER* p = (T_PLAYER*)player;
short player_id = p->id_ext.id;
std::string filter = NormalizeMobName(TrimLeft(args).c_str());
int mob_count = 0;
int spacepos = filter.find(' ');
if (spacepos != std::string::npos) {
std::string raw_count = TrimLeft(filter.substr(spacepos+1));
filter.erase(spacepos);
if (!CheckInt(raw_count)) {
zxmgr::SendMessage(player, "'%s' is not an integer, ignored", raw_count.c_str());
} else {
mob_count = static_cast<int>(StrToInt(raw_count));
}
}
if (filter.length() > 0) {
int matching_mobs = 0;
InitializeMobNames();
for (auto mob = mob_names->begin(); mob != mob_names->end(); mob++) {
if (mob->second.find(filter) != std::string::npos) {
matching_mobs++;
}
}
if (matching_mobs == 0) {
zxmgr::SendMessage(player, "'%s' does not match any mobs, quest filter unchanged", filter.c_str());
return;
}
}
player_settings[player_id]->quest_filter = filter;
player_settings[player_id]->quest_mob_count = mob_count;
if (filter.length() > 0) {
if (mob_count > 0) {
zxmgr::SendMessage(player, "Quest filter set to '%s', mob count set to %d", filter.c_str(), mob_count);
} else {
zxmgr::SendMessage(player, "Quest filter set to '%s'", filter.c_str());
}
} else {
zxmgr::SendMessage(player, "Quest filter reset");
}
}
void ProcessCheat_QuestsInfo(byte* player, const std::string& args) {
T_PLAYER* p = (T_PLAYER*)player;
short player_id = p->id_ext.id;
zxmgr::SendMessage(player, "Current player: %d", player_id);
for (auto it = player_settings.begin(); it != player_settings.end(); ++it) {
if (!it->second->quest_filter.empty()) {
zxmgr::SendMessage(player, "Quest filter for %d: '%s'", it->first, it->second->quest_filter.c_str());
}
}
if (mob_names.get()) {
zxmgr::SendMessage(player, "Total mob names: %d", mob_names->size());
}
}
void ProcessCheat_QuestState(byte* player, const std::string& args) {
T_PLAYER* p = (T_PLAYER*)player;
short player_id = p->id_ext.id;
std::vector<std::string> messages = QuestStateNMonsters(p);
for (auto it = messages.begin(); it != messages.end(); ++it) {
zxmgr::SendMessage(player, "%s", it->c_str());
}
}
void RunCommand(byte* _this, byte* player, const char* ccommand, uint32_t rights, bool console)
{
if (!ccommand) return;
if (ccommand[0] != '#') return;
std::string command(ccommand);
command = Trim(command);
std::string rawcmd = command;
std::string args;
size_t spacepos = command.find_first_of(' ');
if (spacepos != std::string::npos) {
rawcmd.erase(spacepos);
args = command.substr(spacepos+1);
}
if (rawcmd == "#mapinfo")
{
const char* map_file = Config::CurrentMapName.c_str();
const char* map_name = Config::CurrentMapTitle.c_str();
uint32_t tme = zxmgr::GetCurrentMapTime()/1000;
uint32_t tm_h = tme / 3600;
uint32_t tm_m = tme / 60 - tm_h * 60;
uint32_t tm_s = tme - (tm_h * 3600 + tm_m * 60);
tme = zxmgr::GetTotalMapTime()*60;
uint32_t tt_h = tme / 3600;
uint32_t tt_m = tme / 60 - tt_h * 60;
uint32_t tt_s = tme - (tt_h * 3600 + tt_m * 60);
std::string time_left = "infinite";
if (!Config::Suspended && zxmgr::GetTotalMapTime() != 0x7FFFFFFF)
time_left = Format("%u:%02u:%02u", tt_h, tt_m, tt_s);
if (player)
zxmgr::SendMessage(player, "map: \"%s\" in \"%s\", time elapsed: %u:%02u:%02u, time total: %s",
map_name, map_file, tm_h, tm_m, tm_s, time_left.c_str());
else if (console)
Printf("Map: \"%s\" in \"%s\", time elapsed: %u:%02u:%02u, time total: %s",
map_name, map_file, tm_h, tm_m, tm_s, time_left.c_str());
goto ex;
}
if (rawcmd == "#quest" || rawcmd == "#q") {
ProcessCheat_Quest(player, args);
return;
}
if (rawcmd == "#quests_info") {
ProcessCheat_QuestsInfo(player, args);
return;
}
if (rawcmd == "#quest_state" || rawcmd == "#qs") {
ProcessCheat_QuestState(player, args);
return;
}
if (rights & GMF_CMD_CHAT)
{
if (command.find("#@") == 0)
{
command.erase(0, 2);
std::string what = "";
if (!player || console)
what = Format("[broadcast] <server%u>: %s", Config::ServerID, command.c_str());
else if (player)
what = Format("[broadcast] %s: %s", *(const char**)(player + 0x18), command.c_str());
else
what = Format("[broadcast] %s", command.c_str());
if (!NetCmd_Broadcast(what))
NetHat::Connected = false;
goto ex;
}
else if (command.find("#!") == 0)
{
command.erase(0, 2);
if (!player || console)
zxmgr::SendMessage(NULL, "<server>: %s", command.c_str());
else if (player)
zxmgr::SendMessage(NULL, "%s: %s", *(const char**)(player + 0x18), command.c_str());
else
zxmgr::SendMessage(NULL, command.c_str());
goto ex;
}
}
if(rights & GMF_CMD_KICK)
{
if (rawcmd == "#kick")
{
command.erase(0, 5);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target)
zxmgr::Kick(target, false);
goto ex;
}
else if (rawcmd == "#kickme")
{
if (!player || console)
{
Printf("This command may not be used from the console.");
goto ex;
}
if (player)
zxmgr::Kick(player, true);
goto ex;
}
else if (rawcmd == "#kickall")
{
zxmgr::KickAll(NULL);
goto ex;
}
else if (rawcmd == "#kick_silent")
{
command.erase(0, 12);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target)
zxmgr::Kick(target, true);
goto ex;
}
else if (rawcmd == "#disconnect")
{
command.erase(0, 11);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target)
zxmgr::Disconnect(target);
goto ex;
}
}
if (rights & GMF_CMD_INFO)
{
if (rawcmd == "#locate")
{
command.erase(0, 7);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target && *(byte**)(target + 0x38))
{
uint32_t p_x = *(uint8_t*)(*(uint32_t*)(*(byte**)(target + 0x38) + 0x10));
uint32_t p_y = *(uint8_t*)(*(uint32_t*)(*(byte**)(target + 0x38) + 0x10) + 1);
if (!player || console)
Printf("%s (%u:%u)", *(const char**)(target + 0x18), p_x, p_y);
else if (player)
zxmgr::SendMessage(player, "%s (%u:%u)", *(const char**)(target + 0x18), p_x, p_y);
}
goto ex;
}
else if (rawcmd == "#info")
{
command.erase(0, 5);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (!target) goto ex;
if (!*(byte**)(target + 0x38)) goto ex;
const char* p_charname = *(const char**)(target + 0x18);
const char* p_logname = *(const char**)(target + 0x0A78);
byte* netinf = zxmgr::GetNetworkStruct(target);
bool p_connected = (netinf);
const char* p_address = "n/a";
if (p_connected)
p_address = (const char*)(netinf + 8);
std::string p_state;
if (p_connected)
p_state = Format("connected (%s)", p_address);
else
p_state = "disconnected";
byte* unit = *(byte**)(target + 0x38);
uint8_t p_body = *(uint8_t*)(unit + 0x84);
uint8_t p_reaction = *(uint8_t*)(unit + 0x86);
uint8_t p_mind = *(uint8_t*)(unit + 0x88);
uint8_t p_spirit = *(uint8_t*)(unit + 0x8A);
const char* p_strong = (vd2_CheckStrong(unit) ? "yes" : "no");
if (!player || console)
{
Printf("nickname: \"%s\", login: \"%s\", state: %s, stats: [%u,%u,%u,%u], strong: %s",
p_charname, p_logname, p_state.c_str(),
p_body, p_reaction, p_mind, p_spirit, p_strong);
}
else if (player)
{
zxmgr::SendMessage(player, "nickname: \"%s\", login: \"%s\", state: %s, stats: [%u,%u,%u,%u], strong: %s\n",
p_charname, p_logname, p_state.c_str(),
p_body, p_reaction, p_mind, p_spirit, p_strong);
}
goto ex;
}
else if (rawcmd == "#scan")
{
Printf("#scan command entered.\n");
if (!player) goto ex;
Printf("#scan performed. player found.\n");
byte* unit = *(byte**)(player + 0x38);
if (!unit) goto ex;
Printf("check for unit OK.. getting dump\n");
SR_DumpToFile(player);
Printf("dump finished\n");
goto ex;
}
}
if (rights & GMF_CMD_KILL)
{
if (rawcmd == "#kill")
{
command.erase(0, 5);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target)
{
uint32_t tri = 0;
if (!*(uint32_t*)(target + 0x2C))
tri = *(uint32_t*)(target + 0x14);
if (CHECK_FLAG(tri, GMF_ANY))
{
if (((tri & GMF_GODMODE) &&
(rights & GMF_GODMODE_ADMIN)) ||
(tri & GMF_GODMODE_ADMIN)) goto ex;
}
zxmgr::Kill(target, player);
}
goto ex;
}
else if (rawcmd == "#murder")
{
command.erase(0, 7);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (target)
{
uint32_t tri = 0;
if (!*(uint32_t*)(target + 0x2C))
tri = *(uint32_t*)(target + 0x14);
if (CHECK_FLAG(tri, GMF_ANY))
{
if ((((tri & GMF_GODMODE) && !(rights & GMF_GODMODE_ADMIN)) ||
(tri & GMF_GODMODE_ADMIN)) && target != player)
goto ex;
}
zxmgr::Kill(target, player);
byte* unit = *(byte**)(target + 0x38);
if (unit && target != player)
DropEverything(unit, true);
}
goto ex;
}
else if (rawcmd == "#killall")
{
zxmgr::KillAll(player, false);
}
else if (rawcmd == "#killai")
{
zxmgr::KillAll(player, true);
}
}
if (rights & GMF_CMD_PICKUP)
{
if (rawcmd == "#pickup")
{
if (!player || console)
{
Printf("This command may not be used from the console.");
goto ex;
}
if (player)
{
cheat_codes_2(player, ccommand);
}
goto ex;
}
}
if (rights & GMF_CMD_SUMMON)
{
if (rawcmd == "#summon")
{
if (!player || console)
{
Printf("This command may not be used from the console.");
goto ex;
}
if (player && *(byte**)(player + 0x38))
{
command.erase(0, 7);
command = Trim(command);
if (!command.length()) goto ex;
uint32_t count = 1;
size_t fsp = command.find_first_of(" ");
if (fsp != std::string::npos)
{
std::string intstr = command;
intstr.erase(fsp);
if (CheckInt(intstr))
{
command.erase(0, fsp + 1);
command = TrimLeft(command);
count = StrToInt(intstr);
if (!count) count = 1;
}
}
if (!command.length()) goto ex;
for (uint32_t i = 0; i < count; i++)
{
byte* unit = zxmgr::Summon(player, command.c_str(), *(byte**)(0x00642C2C), false, NULL);
/*if (rights & GMF_UNITS_NOCLIP)
zxmgr::MakeUnitNoClip(unit);*/
//byte* unit = Map::CreateUnitForEx(player, command.c_str(), false);
//zxmgr::SendMessage(NULL, "what: %02X\n", *(uint8_t*)(*(byte**)(unit + 0x1C4) + 0x78));
//Unit::SetSpells(unit);
}
}
}
}
if (rights & GMF_CMD_SET)
{
if (rawcmd == "#nextmap")
{
zxmgr::NextMap();
goto ex;
}
else if (rawcmd == "#prevmap")
{
zxmgr::PrevMap();
goto ex;
}
else if (rawcmd == "#resetmap")
{
if (Config::Suspended)
{
zxmgr::SetTotalMapTime(Config::OriginalTime);
Config::Suspended = false;
}
zxmgr::ResetMap();
goto ex;
}
else if (rawcmd == "#shutdown")
{
TerminateProcess(GetCurrentProcess(), 100);
goto ex;
}
else if (rawcmd == "#suspend")
{
if (!Config::Suspended)
{
Config::OriginalTime = zxmgr::GetTotalMapTime();
zxmgr::SetTotalMapTime(0x7FFFFFFF);
if (!player || console)
Printf("Map timer suspended.");
else if (player)
zxmgr::SendMessage(player, "suspend: map timer suspended.");
}
else
{
bool change_map = false;
uint32_t cur_time = zxmgr::GetCurrentMapTime() / 60000;
if (cur_time >= Config::OriginalTime) change_map = true;
zxmgr::SetTotalMapTime(Config::OriginalTime);
Config::OriginalTime = 0;
if (!player || console)
Printf("Map timer released.");
else if (player)
zxmgr::SendMessage(player, "suspend: map timer released.");
if (change_map)
{
Printf("Note: map timer beyond total map time. Changing map...");
zxmgr::NextMap();
}
}
Config::Suspended = !Config::Suspended;
goto ex;
}
else if (rawcmd == "#set" && (command.find("#set mode") == 0))
{
command.erase(0, 9);
command = Trim(command);
if (!command.length())
{
if (!player || console)
Printf("Mode is set to %08X.", Config::ServerFlags);
else if (player)
zxmgr::SendMessage(player, "mode is set to %08X", Config::ServerFlags);
}
else
{
int32_t add_flags = 0;
if (command[0] == '+') add_flags = 1;
else if (command[0] == '-') add_flags = -1;
else if (command[0] == '=') add_flags = 0;
else goto ex;
if (add_flags != 0) command.erase(0, 1);
if (command[0] != '=') goto ex;
command.erase(0, 1);
uint32_t old_mode = Config::ServerFlags;
uint32_t flags = ParseFlags(TrimLeft(command));
if (add_flags == -1) Config::ServerFlags &= ~flags;
else if (add_flags == 1) Config::ServerFlags |= flags;
else Config::ServerFlags = flags;
if (old_mode != Config::ServerFlags)
{
if (!player || console)
Printf("Mode is set to %08X (was: %08X).", Config::ServerFlags, old_mode);
else if (player)
zxmgr::SendMessage(player, "mode is set to %08X (was: %08X)", Config::ServerFlags, old_mode);
if (Config::ServerFlags & SVF_SOFTCORE)
{
MAX_SKILL = 110;
Config::ServerCaps |= SVC_SOFTCORE;
}
else
{
MAX_SKILL = 100;
Config::ServerCaps &= ~SVC_SOFTCORE;
}
}
else
{
if (!player || console)
Printf("Mode is set to %08X.", Config::ServerFlags);
else if (player)
zxmgr::SendMessage(player, "mode is set to %08X", Config::ServerFlags);
}
}
goto ex;
}
else if (command.find("#speed") == 0)
{
command.erase(0, 6);
command = Trim(command);
if (!CheckInt(command)) goto ex;
uint32_t speed = StrToInt(command);
if (!speed) speed = 1;
if (speed > 8) speed = 8;
zxmgr::SetSpeed(speed);
goto ex;
}
else if (rawcmd == "#mapwide")
{
if (!player || console)
{
Printf("This command may not be used from the console.");
goto ex;
}
uint32_t what = 7; // blizzard
command.erase(0, 8);
command = Trim(command);
if (CheckInt(command) && command.length())
what = StrToInt(command);
byte* unit = *(byte**)(player + 0x38);
if (!unit) goto ex;
uint8_t p_x = *(uint8_t*)(*(byte**)(unit + 0x10));
uint8_t p_y = *(uint8_t*)(*(byte**)(unit + 0x10) + 1);
uint32_t p_mapwidth = *(uint32_t*)(*(uint32_t*)(0x006B16A8) + 0x50000);
uint32_t p_mapheight = *(uint32_t*)(*(uint32_t*)(0x006B16A8) + 0x50004);
uint32_t step_x = 1;
uint32_t step_y = 1;
switch (what)
{
case 7: // blizzard
step_x = 1;
step_y = 1;
break;
case 14: // darkness
case 15: // light
case 6: // poison cloud
step_x = 1;
step_y = 1;
break;
case 9: // acid steam
step_x = 1;
step_y = 1;
break;
case 2: // fire ball
step_x = 1;
step_y = 1;
break;
case 3: // fire wall
step_x = 1;
step_y = 1;
break;
default: // any other spell is forbidden
goto ex;
}
uint32_t count_x = 51;
uint32_t count_y = 51;
int32_t start_x = p_x - 25;
int32_t start_y = p_y - 25;
for (int32_t i = start_x; i <= start_x+count_x; i++)
{
for (int32_t j = start_y; j <= start_y+count_y; j++)
{
if (i < 8 || i > p_mapwidth - 8 ||
j < 8 || j > p_mapheight - 8) continue;
zxmgr::CastPointEffect(unit, i, j, what);
}
}
goto ex;
}
else if(rawcmd == "#inn")
{
if (!player) goto ex;
byte* unit = *(byte**)(player + 0x38);
if (!unit) goto ex;
byte* item = *(byte**)(unit + 0x74);
if (!item) goto ex;
zxmgr::SendMessage(NULL, "%04x", *(uint16_t*)(item+0x40));
goto ex;
}
}
if (rights & GMF_CMD_SCREENSHOT)
{
if (rawcmd == "#screenshot")
{
command.erase(0, 11);
command = TrimLeft(command);
byte* target = zxmgr::FindByNickname(command.c_str());
if (!target)
{
if (player) zxmgr::SendMessage(player, "screenshot: Player %s not found", command.c_str());
else Printf("screenshot: Player %s not found", command.c_str());
goto ex;
}
Player* p = PI_Get(target);
if (!p)
{
if (player) zxmgr::SendMessage(player, "screenshot: Player %s has no playerinfo!", *(const char**)(target + 0x18));
else Printf("screenshot: Player %s has no playerinfo!", *(const char**)(target + 0x18));
goto ex;
}
SOCKET ps = zxmgr::GetSocket(target);
if (!ps)
{
if (player) zxmgr::SendMessage(player, "screenshot: Player %s has no socket (AI or disconnected?)", *(const char**)(target + 0x18));
else Printf("screenshot: Player %s has no socket (AI or disconnected?)", *(const char**)(target + 0x18));
goto ex;
}
uint32_t uid = ClientScreenshot_Enqueue(player, target);
Packet cmd;
cmd.WriteUInt8(0x01);
cmd.WriteString(*(const char**)(target + 0x0A78));
cmd.WriteUInt32(uid);
p->EnqueuedPackets.push_back(cmd);
if (player) zxmgr::SendMessage(player, "screenshot: Request sent to player %s", *(const char**)(target + 0x18), uid);
else Printf("screenshot: Request sent to player %s", *(const char**)(target + 0x18), uid);
goto ex;
}
}
if(rights & GMF_CMD_CREATE)
{
if (rawcmd == "#create")
{
if (!player || console)
{
Printf("This command may not be used from the console.");
goto ex;
}
if (!*(byte**)(player + 0x38)) goto ex;
command.erase(0, 7);
command = Trim(command);
uint32_t count = 1;
size_t fsp = command.find_first_of(" ");
if (fsp != std::string::npos)
{
std::string intstr = command;
intstr.erase(fsp);
if (CheckInt(intstr))
{
command.erase(0, fsp + 1);
command = TrimLeft(command);
count = StrToInt(intstr);
if (!count) count = 1;
}
}
if (ToLower(command) == "gold")
{
zxmgr::GiveMoney(player, count, 1);
}
else
{
if (command.find("{") != std::string::npos)
{
for (uint32_t i = 0; i < count; i++)
{
byte* t_item = zxmgr::ConstructItem(command);
if (!t_item) goto ex;
// special case for scrolls/potions
if (*(uint8_t*)(t_item + 0x58) == 0 && *(uint8_t*)(t_item + 0x45) == 0 && *(uint8_t*)(t_item + 0x46) == 0 && *(uint16_t*)(t_item + 0x4A) == 1)
{
*(uint16_t*)(t_item + 0x42) = count;
zxmgr::GiveItemTo(t_item, player);
break;
}
*(uint16_t*)(t_item + 0x42) = 1;
zxmgr::GiveItemTo(t_item, player);
}
}
else
{
byte* t_item = zxmgr::ConstructItem(command);
if (!t_item) goto ex;
*(uint16_t*)(t_item + 0x42) = count;
zxmgr::GiveItemTo(t_item, player);
}
}
zxmgr::UpdateUnit(*(byte**)(player + 0x38), player, 0xFFFFFFFF, 0xFFB, 0, 0);
goto ex;
}
}
// #modify player +god:
// включает годмод. годмод сбрасывается при выходе игрока с карты ИЛИ при выходе установившего ГМа с карты.
// #modify player ++god: годмод НЕ сбрасывается при выходе ГМа с карты.
// #modify player -god (--god): отменяет команды выше. количество минусов в данном случае значения не имеет.
// #modify player +spells: временно добавляет все заклинания. при выходе игрока или установившего ГМа с карты заклинания
// сбрасываются обратно на старую книгу. также можно сбросить заклинания через #modify player -spells.
// #modify player -spells: если книга заклинаний игрока не менялась, временно удаляет все заклинания.
// при выходе игрока или ГМа с карты заклинания возвращаются в норму. эффект отменяется через #modify player +spells.
// #modify player ++spells: то же самое, но навсегда. сбросить заклинания обратно невозможно.
// #modify player --spells: см. выше про -spells.
if (rights & GMF_CMD_MODIFY)
{
if (rawcmd == "#modify")
{
command.erase(0, 7);
command = Trim(command);
byte* target = NULL;
std::string targetname = "";
for (size_t i = 0; i < command.length(); i++)
{
targetname += command[i];
if (targetname == "self") continue;
target = zxmgr::FindByNickname(targetname.c_str());
if (target) break;
}
if (!target)
{
std::string lowercommand = ToLower(command);
if (lowercommand.find("self") == 0)
{
targetname = "self";
target = player;
}
else goto ex;
}
Player* pi = PI_Get(target);
if (!pi) goto ex;
command.erase(0, targetname.length());
command = TrimLeft(command);
if (!command.length()) goto ex;
int r_change = 0;
if (command[0] == '+') r_change = 1;
else if (command[0] == '-') r_change = -1;
if (!r_change) goto ex;
command.erase(0, 1);