forked from jewalky/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 5
/
srvmgr.cpp
2914 lines (2562 loc) · 74.5 KB
/
srvmgr.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 <winsock2.h>
#include <windows.h>
#include "srvmgr.h"
#include "srvmgrdef.h"
#include "charcheck.h"
#include "shared.h"
#pragma warning(disable:4996) // no_deprecate
#include "config_new.h"
#include <string>
#include <stdexcept>
#include <vector>
#include <sstream>
#include <ctime>
#include "lib\utils.hpp"
#include "lib\packet.hpp"
#include "lib\socket.hpp"
#include "srvmgr_new.h"
#include "player_info.h"
#include "quests.h"
#include "zxmgr.h"
/// CDECL нет очистки стека функцией
/// STDCALL есть
char alog_vis[] = " id: 0x%.4X; (%d, %d)[%d] - vision=%d.%d\n";
char camp1[] = "Player %s tried to camp from building.";
char camp2[] = "Player %s initiated camping.";
char player_respawn[] = "Player %s respawned.";
char enter_b1[] = "<cmd: enter to building>\n";
char cancel_camp1[] = "Player %s cancelled camping.";
char enter_shop1[] = "Player %s entered shop ID=%u from (%u, %u).";
char enter_inn1[] = "Player %s entered inn ID=%u from (%u, %u).";
char left_shop1[] = "Player %s left shop.";
char left_inn1[] = "Player %s left inn.";
char aErrPoint[] = "name: %s, error dst\n";
char aArea_Cast[] = "player %s: area_cast from (%d, %d)[%d] to (%d, %d)[%d], vision=%d.%d\n";
char config[BUF_MAX];
bool exiting = false;
int(__cdecl *print_log)(char *message);
HANDLE hThread;
char avisall[] = "name: %s - id: 0x%.2X\n";
DWORD dwThreadId;
char ctl_dir[BUF_MAX];
Encoding encoding = CP1251;
char map_name_buf[0x200];
char log_invalid_packet[]="Invalid packet '%.2X' from '%s'\n";
char log_color_crasher[]="Player %s tried to use color crash bug\n";
unsigned spirit_factor = 256;
#include "bugs.h"
#ifdef SRV_LOG
struct client {
SOCKET s;
std::string ip, name;
struct client *n, *p;
} *c0 = 0;
#endif
char info[100];
char numb[] = "0123456789ABCDEF";
char spirit[MAX_PATH];
char perc_s[]="%s\n";
double exp_death = 1; // 1.0
double exp_full = 0.9; // 0.9
const char * __stdcall get_player_name(void *pl)
{
return *(const char **)((char *)pl + 0x18);
}
void * __stdcall get_player(void *un)
{
return *(void **)((char *)un + 0x14);
}
void __stdcall auto_war_cpp(void *unit_from, void *unit_to, int att)
{
void *player_from = get_player(unit_from);
void *player_to = get_player(unit_to);
Printf("Player %s (%s) set auto-war to player %s", get_player_name(player_from), att ? "attacker" : "victim", get_player_name(player_to));
}
void __declspec(naked) auto_war_1()
{ // 005B56EF
__asm
{
push 1
push [ebp+0xc]
push [ebp+8]
call auto_war_cpp
mov ecx, [ebp+8]
mov edx, [ecx+0x14]
push edx
mov edx, 0x05B56F6
jmp edx
}
}
void __declspec(naked) auto_war_2()
{ // 005B57C6
__asm
{
push 0
push [ebp+8]
push [ebp+0xc]
call auto_war_cpp
mov ecx, [ebp+8]
mov edx, [ecx+0x14]
push edx
mov edx, 0x05B57CD
jmp edx
}
}
void __stdcall log_dip_change_cpp(byte *player_from, byte *player_to, int was, int became)
{
char names[][7] = {"war", "ally", "ignore", "vision"};
int flags[4] = {1, 2, 4, 0x10};
for (int i = 0; i < 4; ++i)
{
if ((was & flags[i]) && !(became & flags[i]))
Printf("Player %s unset %s to player %s", get_player_name(player_from), names[i], get_player_name(player_to));
if (!(was & flags[i]) && (became & flags[i]))
Printf("Player %s set %s to player %s", get_player_name(player_from), names[i], get_player_name(player_to));
}
}
void __declspec(naked) log_dip_change()
{ // 005081DC
__asm
{
// magic here
mov ecx, [ebp-0x9E8]
mov ecx, dword ptr [ecx+0x14]
and ecx, GMF_PLAYERS_VISION
cmp ecx, GMF_PLAYERS_VISION
jnz do_no_vision
mov eax, [ebp-0xA0C]
mov ecx, [ebp-0x9DC]
movzx ebx, word ptr [ecx+eax*2]
or ebx, 0x10
mov word ptr [ecx+eax*2], bx
do_no_vision:
mov ecx, [ebp-0x9E8]
mov ecx, dword ptr [ecx+0x14]
and ecx, GMF_PLAYERS_ALLY
cmp ecx, GMF_PLAYERS_ALLY
jnz do_normal
mov eax, [ebp-0xA0C]
mov ecx, [ebp-0x9DC]
movzx ebx, word ptr [ecx+eax*2]
or ebx, 0x02
mov word ptr [ecx+eax*2], bx
do_normal:
push esi
push edx
push [ebp - 0x9E8]
push [ebp - 0x9E4]
call log_dip_change_cpp
mov edx, [ebp - 0xA08]
mov ecx, 0x005081E2
jmp ecx
}
}
char * _stdcall chat_log_cpp(char *msg, char *player_from, char *player_to, unsigned int type)
{
static char m[5000];
if (type == 1)
{
_snprintf(m, sizeof(m)-1, "--> %s: %s", player_from, msg);
}
else if (type == 2)
{
_snprintf(m, sizeof(m)-1, "%s >>> %s: %s", player_from, player_to, msg);
}
else
{
_snprintf(m, sizeof(m)-1, "%s: %s", player_from, msg);
}
return m;
}
void _declspec(naked) chat_log()
{ // 0050721C
__asm
{
mov edx, [ebp-0x528]
mov eax, [edx+0x0a]
sar eax, 8
and eax, 0xFF
push eax
cmp eax, 2
jnz skip_player_to
mov edx, [ebp-0x528]
mov eax, [edx+0x0a]
and eax, 0xFF
push eax
mov ecx, 0x6CDB24
mov ecx, [ecx]
mov edx, 0x535B50
call edx
test eax, eax
jz skip_player_to
mov eax, [eax+0x18]
push eax
jmp join_player_to
skip_player_to:
xor eax, eax
push eax
jmp join_player_to
join_player_to:
mov ecx, [ebp-0x104]
mov eax, [ecx+0x18]
push eax
mov eax, [ebp-0x108]
push eax
call chat_log_cpp
push eax
mov edx, 0x0043A857
call edx
add esp, 4
mov edx, 0x00507267
jmp edx
}
}
void _declspec(naked) player_respawned_init()
{
__asm
{
mov eax, [ebp-0x34]
mov dword ptr [eax+0x130], 0
mov eax, [eax + 0x14]
test eax, eax
jz pri_skip
mov eax, [eax + 0x18]
test eax, eax
jz pri_skip
push eax
push offset player_respawn
call Printf
pri_skip:
mov edx, 0x531197
jmp edx
}
}
unsigned int _stdcall respawn_update_exp_cpp(unsigned int exp)
{
return static_cast<unsigned int>(exp * Config::RespawnExpMult2);
// return static_cast<unsigned int>(exp * (exp_full / exp_death));
}
void _declspec(naked) player_respawned()
{ // 00531278
__asm
{
push eax
call respawn_update_exp_cpp
mov edx, 0x0531283
jmp edx
}
}
unsigned int _stdcall death_update_exp_cpp(unsigned int exp)
{
return static_cast<unsigned int>(exp * Config::DeathExpMult);
// return static_cast<unsigned int>(exp * exp_death);
}
unsigned int _stdcall _double_to_int32(double val)
{
return static_cast<unsigned int>(val);
}
void _declspec(naked) death_update_exp(void *unit)
{ //st(0) = exp_Multiplier
__asm
{
push ebp
mov ebp, esp
sub esp, 4
mov edx, dword ptr [ebp+8] // unit
mov dword ptr [edx+0x130], 0
mov dword ptr [ebp-4], 1
due_cycle: cmp dword ptr [ebp-4], 6
jge due_cycle_ex
mov edx, dword ptr [ebp+8] // unit
mov ecx, dword ptr [ebp-4] // i
mov eax, [edx + ecx*4 + 0x23C]
push eax
push eax
fild dword ptr [esp]
fmul st,st(1)
fstp qword ptr [esp]
call _double_to_int32
//push eax
//call death_update_exp_cpp
mov edx, dword ptr [ebp+8] // unit
mov ecx, dword ptr [ebp-4] // i
mov [edx + ecx*4 + 0x23C], eax
add [edx + 0x130], eax
inc dword ptr [ebp-4]
jmp due_cycle
due_cycle_ex:
mov esp, ebp
pop ebp
ret 4
}
}
void _declspec(naked) player_died()
{ // 00556A56
__asm
{
fld Config::DeathExpMult
push [ebp - 0x18]
call death_update_exp
fstp st
mov edx, 0x556A5D
jmp edx
}
}
void _declspec(naked) player_killed()
{ // 00557005
__asm
{
fld Config::KilledExpMult
push [ebp - 0x18]
call death_update_exp
fstp st
mov edx, 0x55700C
jmp edx
}
}
void _declspec(naked) player_pkilled()
{ // 00556BE6
__asm
{
fld Config::PKExpMult
push [ebp - 0x18]
call death_update_exp
fstp st
mov edx, 0x556BED
jmp edx
}
}
///////////////////////////////////////////////
// extend checking max player parameters
void _declspec(naked) set_max_player_parameters()
{
__asm
{
pop edx
mov al,[ecx]MainCharacterParameters.Spirit
mov ss:[ebp+edx],al
pop edx
mov al,[ecx]MainCharacterParameters.Mind
mov ss:[ebp+edx],al
pop edx
mov al,[ecx]MainCharacterParameters.Reaction
mov ss:[ebp+edx],al
pop edx
mov al,[ecx]MainCharacterParameters.Body
mov ss:[ebp+edx],al
retn
}
}
// 52bd75
// Unit should die at 0 HP instead of getting into the limbo
// and stay with 0 HP forever (gives cheat to hide player behind
// "nearly-dead" monsters).
void __declspec(naked) check_health()
{
__asm
{
mov edx, [ebp + -0x10] // Org: Load unit's base address
movsx eax, word ptr [edx + 0x94] // Org: Load unit's HP into EAX
test eax, eax // Test if HP is negative or zero
jge HP_Zero_check // If HP >= 0, jump to HP_Zero_check
mov edx, 0x0052bd83 // Org: if HP < 0 continue to Org
jmp edx
HP_Zero_check:
// Check if HP is exactly 0
cmp eax, 0 // Compare HP with 0
jne NextFunction // If HP is not 0, skip patch
// Check HPRegen
mov ecx, [edx + 0x98] // Load HPRegen value into ECX
test ecx, ecx // Test if HPRegen is zero
jz NextFunction // If HPRegen == 0, skip patch
// Pseudo-random decision based on current time (1 in 60 chance)
call GetCurrentTimeModulo // Call the function to check time-based condition
test eax, eax // Test if the result is zero
jz NextFunction // If zero, go to NextFunction
// If HP is 0, HPRegen > 0, and the random condition is met, continue to custom handling
mov edx, 0x0052bd83 // Jump to this->HP = this->HP + -1
jmp edx
NextFunction:
mov edx, 0x0052bdd3 // Continue with the original code
jmp edx
}
}
// Function to return a simple random-like value based on the current time
int GetCurrentTimeModulo()
{
std::time_t now = std::time(0); // Get the current time in seconds
return (now % 60 == 0); // every 60 seconds
}
// min.speed:
// 1-2: 15 | 3: 12 | 4: 11 | 5: 10 | 6: 9 | 7+: 8
// max.speed:
// 1-2: 15 | 3: 21 | 4: 23 | 5: 25 | 6: 30 | 7+: 35
//531b72
// we insert HC speed right before starting of other instruction...
// means that we kinda adding new HC value, instead of
// changing previous ones
void _declspec(naked) set_char_min_speed()
{
/*
dword ptr [EBP + -0x28] - this->
word ptr [ExX + 0x84] - body
word ptr [ExX + 0x86] - reaction
word ptr [ExX + 0x8c] - speed
*/
__asm
{
mov EAX, [Config::ServerID] // get server ID
cmp EAX, 3 // check if server ID is less than 3
jle handle_speed_1_to_3 // jump to handle speeds 1-3 if true
cmp EAX, 4 // if server ID is 4: ZF = 1
jz set_speed_4
cmp EAX, 5 // if server ID is 5: ZF = 1
jz set_speed_5
cmp EAX, 6 // if server ID is 6: ZF = 1
jz set_speed_6
// Handle servers 7 and above (same speed settings)
cmp EAX, 7 // if server ID is 7 or higher: ZF = 1
jge set_speed_7_plus
handle_speed_1_to_3:
cmp EAX, 1 // if server ID is 1 or 2: ZF = 1
jz set_speed_1_2
cmp EAX, 2 // if server ID is 2: ZF = 1
jz set_speed_1_2
jmp set_speed_3
set_speed_1_2:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 15 // put 15 to register
mov word ptr [ECX + 0x8c],DX // to base+8c put 15
jmp set_min_speed
set_speed_3:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 12 // put 12 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 12 // check if current speed is less than 12
jge skip_min_speed_3 // if current speed is not less than 12, skip setting min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 12
skip_min_speed_3:
/////////////////////////////////////
mov DX, 21 // put 21 to register
cmp AX, 21 // check if current speed is greater than 21
jle set_min_speed // if current speed is not greater than 21, set min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 21
jmp set_min_speed
set_speed_4:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 11 // put 11 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 11 // check if current speed is less than 11
jge skip_min_speed_4 // if current speed is not less than 11, skip setting min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 11
skip_min_speed_4:
/////////////////////////////////////
mov DX, 23 // put 23 to register
cmp AX, 23 // check if current speed is greater than 23
jle set_min_speed // if current speed is not greater than 23, set min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 23
jmp set_min_speed
set_speed_5:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 10 // put 10 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 10 // check if current speed is less than 10
jge skip_min_speed_5 // if current speed is not less than 10, skip setting min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 10
skip_min_speed_5:
/////////////////////////////////////
mov DX, 25 // put 25 to register
cmp AX, 25 // check if current speed is greater than 25
jle set_min_speed // if current speed is not greater than 25, set min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 25
jmp set_min_speed
set_speed_6:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 9 // put 9 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 9 // check if current speed is less than 9
jge skip_min_speed_6 // if current speed is not less than 9, skip setting min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 9
skip_min_speed_6:
/////////////////////////////////////
mov DX, 30 // put 30 to register
cmp AX, 30 // check if current speed is greater than 30
jle set_min_speed // if current speed is not greater than 30, set min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 30
jmp set_min_speed
set_speed_7_plus:
/////////////////////////////////////
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 8 // put 8 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 8 // check if current speed is less than 8
jge skip_min_speed_7 // if current speed is not less than 8, skip setting min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 8
skip_min_speed_7:
/////////////////////////////////////
mov DX, 35 // put 35 to register
cmp AX, 35 // check if current speed is greater than 35
jle set_min_speed // if current speed is not greater than 35, set min speed
mov word ptr [ECX + 0x8c],DX // to base+8c put 35
jmp set_min_speed
skip:
jmp set_min_speed
/////////////////////////////////////
set_min_speed:
///////////////////////////////////// Fix when player speed might be negative
mov ECX,dword ptr [EBP + -0x28] // get base for stats
mov DX, 2 // put 2 to register
mov AX, word ptr [ECX + 0x8c] // get current speed
cmp AX, 2 // check if current speed is less than or equal to 2
jg end // if current speed is greater than 2, end
mov word ptr [ECX + 0x8c],DX // to base+8c put 2
end:
/////////////////////////////////////
mov EAX,dword ptr [EBP + -0x28]
movsx ECX,word ptr [EAX + 0x84]
mov edx, 0x00531b7c
jmp edx
}
}
// using potions - drinking stat potions
void _declspec(naked) set_max_player_parameters_for_use_potion()
{
__asm
{
push 0x005316C8
push -0x20
push -0x0C
push -0x24
push -0x08
jmp set_max_player_parameters
}
}
void _declspec(naked) set_warrior_male_max_parameters()
{ // 00531650
__asm
{
lea ecx,Config::WarriorMaleMaxParameters
jmp set_max_player_parameters_for_use_potion
}
}
void _declspec(naked) set_warrior_female_max_parameters()
{ // 53166C
__asm
{
lea ecx,Config::WarriorFemaleMaxParameters
jmp set_max_player_parameters_for_use_potion
}
}
void _declspec(naked) set_mage_male_max_parameters()
{ // 531696
__asm
{
lea ecx,Config::MageMaleMaxParameters
jmp set_max_player_parameters_for_use_potion
}
}
void _declspec(naked) set_mage_female_max_parameters()
{ // 5316B8
__asm
{
lea ecx,Config::MageFemaleMaxParameters
jmp set_max_player_parameters_for_use_potion
}
}
// taking potions - getting stat potions from tavern quest
void _declspec(naked) set_max_player_parameters_for_take_potion()
{
__asm
{
push 0x00566206
push -0x110
push -0x104
push -0x114
push -0x100
jmp set_max_player_parameters
}
}
void _declspec(naked) set_warrior_male_max_parameters_taking_potion()
{ // 566149
__asm
{
lea ecx,Config::WarriorMaleMaxParameters
jmp set_max_player_parameters_for_take_potion
}
}
void _declspec(naked) set_warrior_female_max_parameters_taking_potion()
{ // 56617A
__asm
{
lea ecx,Config::WarriorFemaleMaxParameters
jmp set_max_player_parameters_for_take_potion
}
}
void _declspec(naked) set_mage_male_max_parameters_taking_potion()
{ // 5661B6
__asm
{
lea ecx,Config::MageMaleMaxParameters
jmp set_max_player_parameters_for_take_potion
}
}
void _declspec(naked) set_mage_female_max_parameters_taking_potion()
{ // 5661EA
__asm
{
lea ecx,Config::MageFemaleMaxParameters
jmp set_max_player_parameters_for_take_potion
}
}
///////////////////////////////////////////////
// extend inns
void _declspec(naked) bound_quest_reward()
{ // 565406
__asm
{
mov eax, [ebp-0x18]
cmp eax, Config::MinQuestReward
jge not_too_low
mov eax, Config::MinQuestReward
not_too_low:
cmp eax, Config::MaxQuestReward
jle not_too_high
mov eax, Config::MaxQuestReward
not_too_high:
mov [ebp-0x18], eax
mov edx, 0x00565426
jmp edx
}
}
void _declspec(naked) heal_enemies()
{ // 0053A5CB
__asm
{ // skip a check
mov edx, 0x0053A5D5
jmp edx
}
}
void _declspec(naked) add_health_potions()
{ // 0054D700
__asm
{ // пропустить добавление зельев
mov edx, 0x54D8AC
jmp edx
}
}
void _declspec(naked) skip_updating_character_log()
{
__asm
{
mov edx, 0x4F119B
jmp edx
}
}
void _declspec(naked) skip_returning_character_log()
{
__asm
{
mov edx, 0x4F1414
jmp edx
}
}
unsigned int get_spirit_level(unsigned int power)
{
if (spirit_factor == 0) return 5;
unsigned int level = power / spirit_factor + 1;
if (level > 5) level = 5;
return level;
}
char *__stdcall get_zombie(unsigned int power)
{
unsigned int level = get_spirit_level(power);
if (level == 1) return "F_Zombie.1";
_snprintf(spirit, MAX_PATH-1, "%c_Zombie.%d", "AF"[rand()%2], level);
return spirit;
}
char *__stdcall get_skeleton(unsigned int power)
{
_snprintf(spirit, MAX_PATH-1, "%c_Skeleton.%d", "AF"[rand()%2], get_spirit_level(power));
return spirit;
}
char *__stdcall get_ghost(unsigned int power)
{
unsigned int level = get_spirit_level(power);
if (level == 1) return "Ghost";
_snprintf(spirit, MAX_PATH-1, "Ghost.%d", level);
return spirit;
}
void __declspec(naked) zombie_gen()
{ // 53B6D3
__asm
{
mov edx, [ebp-0x40]
push edx
call get_zombie
push eax
lea ecx, [ebp - 0x0EC]
mov edx, 0x53B6DE
jmp edx
}
}
void __declspec(naked) skeleton_gen()
{ // 53B7EB
__asm
{
mov edx, [ebp-0x40]
push edx
call get_skeleton
push eax
lea ecx, [ebp - 0x0F0]
mov edx, 0x53B7F6
jmp edx
}
}
void __declspec(naked) ghost_gen()
{ // 53B910
__asm
{
mov edx, [ebp-0x40]
push edx
call get_ghost
push eax
lea ecx, [ebp - 0x0F4]
mov edx, 0x53B91B
jmp edx
}
}
void __declspec(naked) redir_log()
{
__asm
{
push dword ptr [ebp+8]
push offset perc_s
call log_format
mov edx, 0x401D90
call edx
mov [ebp-0x14],eax
mov edx, 0x43A87A
jmp edx
}
}
//char mtap_test[] = "unit %.4X, flags: %.2X, sig: %.2X\n";
//char ucss_test[] = "unit %.4X, flags: %.2X, change\n";
char eghp_test[] = "unit %.4X, eff: %d, bit: %d, ret: %.6X, ret2: %.6X\n";
char ep1t[] = "effect packet 1\n";
char ep2t[] = "effect packet 2, id=%.2X\n";
char ep3t[] = "effect packet 3\n";
char ep4t[] = "effect packet 4\n";
void __declspec(naked) effect_packet_1()
{
__asm // 0051BAC3
{
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp-4]
mov edx, 0x51baca
jmp edx
}
}
void __declspec(naked) effect_packet_2()
{
__asm // 0051BBA7
{
mov eax, [ebp+0x0c]
xor ecx, ecx
mov cl, [eax+8]
cmp cl, 0x02
jz ep2_send_coords
cmp cl, 0x03
jz ep2_send_coords
cmp cl, 0x11
jz ep2_send_coords
cmp cl, 0x17
jz ep2_send_coords
cmp cl, 0x16
jz ep2_send_coords
cmp cl, 0x07
jz ep2_send_coords
cmp cl, 0x06
jz ep2_send_coords
jmp ep2_skip_coords
ep2_send_coords:
mov edx, 0xFFB
xor ecx, ecx
push ecx
push ecx
push edx
mov eax, 0x10000010
push eax
push ecx
mov eax, [ebp + 8]
push eax
mov ecx, 0x6C3A08
mov edx, 0x519221
call edx
ep2_skip_coords:
jmp ep2_skip
mov eax, [ebp+0x0c]
xor ecx, ecx
mov cl, [eax+8]
push ecx
push offset ep2t
call log_format
ep2_skip:
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp-4]
mov edx, 0x51bbae
jmp edx
}
}
void __declspec(naked) effect_packet_3()
{
__asm // 0051BE21
{
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp+8]
mov edx, 0x51be28
jmp edx
}
}
void __declspec(naked) effect_packet_4()
{
__asm // 0051BEB0
{
mov edx, [ebp-0x18]
mov byte ptr [edx+9], 0x86
mov eax, [ebp+8]
mov edx, 0x51beb7
jmp edx
}
}
char eg1_t[] = "invisibility gone 1\n";
char eg2_t[] = "invisibility gone 2\n";
/*
* effect packet 2
* invisibility gone 1
* invisible has gone packet sent, 5564F6 52A921 53EF9A 51BD9E
*/
void __declspec(naked) effect_gone_1()
{
__asm
{
mov eax, [ebp-4]
xor ecx, ecx
mov cx, [eax+0x0c]
mov edx, 0x53ef5e
jmp edx
}
}
void __declspec(naked) effect_gone_2()
{
__asm
{
mov eax, [ebp-0x14]
xor ecx, ecx
mov cx, [eax+0x0c]
mov edx, 0x53F121
jmp edx
}
}
/*
* [5.12.2010 0:20:29.811] unit 0001, eff: 32, ret: 53F717, ret2: 537624 hang
* [5.12.2010 0:20:35.062] unit 0001, eff: 32, ret: 51BD9E, ret2: 53EF9A gone
*/
char ehgp_t[] = "invisible has gone packet sent, %.6X %.6X %.6X %.6X\n";
void __declspec(naked) effect_hang_gone_packet()
{
__asm
{
mov eax, [ebp+0x10]
cmp al, 0x89
jnz ehgp_pass // not gone
mov eax, [ebp+8]
xor edx, edx
mov dx, [eax+0x0C]
cmp edx, 12