-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathReloadAnimationSelector.pas
More file actions
149 lines (129 loc) · 3.25 KB
/
ReloadAnimationSelector.pas
File metadata and controls
149 lines (129 loc) · 3.25 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
unit ReloadAnimationSelector;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
function Init:boolean;
implementation
uses BaseGameData;
var
reload_pistols_patch_addr:cardinal;
reload_nogl_patch_addr:cardinal;
reload_withgl_patch_addr:cardinal;
function PistolAssaultAnimationSelector(weapon_addr:cardinal):PChar; stdcall;
asm
pushad
pushf
mov ecx, weapon_addr
//Åñëè ó íàñ ÐÏÃ - îáðàáàòûâàåì èíäèâèäóàëüíî
mov ax, word ptr [eax]
cmp ax, W_RPG7
je @rpg7
//Åñëè â ìàãàçèíå íåò ïàòðîíîâ - òî âàðèàíò äåéñòâèé îäèí
cmp [ecx+$690], 0
jle @empty
//Ñìîòðèì, íå çàêëèíèëî ëè îðóæèå
cmp byte ptr [ecx+$45A], 0
jne @jamned
//Ïðîâåðÿåì, íå èäåò ëè ñìåíà òèïà ïàòðîíîâ
cmp byte ptr [ecx+$6C7], $FF
jne @changeammotype
//Ïðîâåðÿåì, ñòîèò ëè ïîäñòâîë
test byte ptr [ecx+$460], 2
jz @reload_nogl
mov ebx, anm_reload_w_gl
jmp @finish
@reload_nogl:
mov ebx, anm_reload
jmp @finish
@jamned:
//Îòìåíèì ñìåíó òèïà ïàòðîíîâ
mov byte ptr [ecx+$6C7], $FF
//Ïðîâåðèì, íå ïîñëåäíèé ëè ïàòðîí îñòàëñÿ â ìàãàçèíå
cmp [ecx+$690], 1
jle @last_jamned
//Ñìîòðèì, àêòèâåí ëè ïîäñòâîë
test byte ptr [ecx+$460], 2
jz @jamned_nogl
mov ebx, anm_jamned_w_gl
jmp @finish
@jamned_nogl:
mov ebx, anm_jamned
jmp @finish
@last_jamned:
test byte ptr [ecx+$460], 2
jz @jamned_nogl_last
mov ebx, anm_jamned_last_w_gl
jmp @finish
@jamned_nogl_last:
mov ebx, anm_jamned_last
jmp @finish
@changeammotype:
test byte ptr [ecx+$460], 2
jz @changingammo_nogl
mov ebx, anm_changecartridgetype_w_gl
jmp @finish
@changingammo_nogl:
mov ebx, anm_changecartridgetype
jmp @finish
@empty:
//Ïðîâåðÿåì ïîäñòâîë
test byte ptr [ecx+$460], 2
jz @empty_nogl
mov ebx, anm_reload_empty_w_gl
jmp @finish
@empty_nogl:
mov ebx, anm_reload_empty
jmp @finish
@rpg7:
//ïðîâåðèì íà êëèí
cmp byte ptr [ecx+$45A], 1
je @rpg7_jamned
mov ebx, anm_reload
jmp @finish
@rpg7_jamned:
mov ebx, anm_jamned
jmp @finish
@finish:
mov @result, ebx
//-------------------------------------------------------------
popf
popad
end;
procedure AK74ReloadNoGLAnimationSelector;
asm
push ecx
push esi
call PistolAssaultAnimationSelector
pop ecx
push eax
jmp reload_nogl_patch_addr
end;
procedure AK74ReloadWithGLAnimationSelector;
asm
push ecx
push esi
call PistolAssaultAnimationSelector
pop ecx
push eax
jmp reload_withgl_patch_addr
end;
procedure PistolReloadAnimationSelector;
asm
push ecx
push esi
call PistolAssaultAnimationSelector
pop ecx
push eax
jmp reload_pistols_patch_addr
end;
function Init:boolean;
begin
result:=false;
reload_nogl_patch_addr:=xrGame_addr+$2CCFB2;
reload_withgl_patch_addr:=xrGame_addr+$2D18AB;
reload_pistols_patch_addr:=xrGame_addr+$2C5451;
if not WriteJump(reload_nogl_patch_addr, cardinal(@AK74ReloadNoGLAnimationSelector), 5) then exit;
if not WriteJump(reload_withgl_patch_addr, cardinal(@AK74ReloadWithGLAnimationSelector), 5) then exit;
if not WriteJump(reload_pistols_patch_addr, cardinal(@PistolReloadAnimationSelector), 14) then exit;
result:=true;
end;
end.