forked from gunslingermod/gunslinger_wpnpatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxr_BoneUtils.pas
177 lines (150 loc) · 4.29 KB
/
xr_BoneUtils.pas
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
unit xr_BoneUtils;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
procedure SetWorldModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
procedure SetHudModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
procedure SetWeaponModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
procedure SetWeaponMultipleBonesStatus(wpn: pointer; bones:PChar; status:boolean); stdcall;
procedure SetWorldModelMultipleBonesStatus(wpn: pointer; bones:PChar; status:boolean); stdcall;
function IKinematics__LL_BoneID(IKinematics:pointer; name:PChar):word; stdcall;
implementation
uses BaseGameData, ActorUtils, HudItemUtils, DetectorUtils, xr_strings;
procedure SetWeaponMultipleBonesStatus(wpn: pointer; bones:PChar; status:boolean); stdcall;
var
bones_string:string;
bone:string;
begin
bones_string:=bones;
while (GetNextSubStr(bones_string, bone, ',')) do begin
SetWeaponModelBoneStatus(wpn, PChar(bone), status);
end;
end;
procedure SetWorldModelMultipleBonesStatus(wpn: pointer; bones:PChar; status:boolean); stdcall;
var
bones_string:string;
bone:string;
begin
bones_string:=bones;
while (GetNextSubStr(bones_string, bone, ',')) do begin
SetWorldModelBoneStatus(wpn, PChar(bone), status);
end;
end;
procedure SetWeaponModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
var
act:pointer;
begin
act:=GetActor();
if (act<>nil) and ((GetActorActiveItem() = wpn) or (GetActiveDetector(act)=wpn)) then begin
SetHudModelBoneStatus(wpn, bone_name, status);
end;
SetWorldModelBoneStatus(wpn, bone_name, status);
end;
procedure SetHudModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
asm
pushad
pushfd
//Ïîëó÷èì îñíîâíîé îáúåêò attachable_hud_item
push wpn
call CHudItem__HudItemData
test eax, eax
je @finish
mov esi, eax
//Ïîìåñòèì bone_name â str_container
push bone_name
call str_container_dock
test eax, eax
je @finish
push eax
push esp //ñðàçó çàãíàëè â ñòåê àðãóìåíò - óêàçàòåëü íà óêàçàòåëü íà îáúåêò-ñòðîêó ñ èìåíåì êîñòè
//Äàëåå íàéäåì è âûçîâåì ôóíêöèþ îïðåäåëåíèÿ èíäåêñà êîñòè
mov eax, [esi+$0C] //mov eax, IKinematics* m_model
mov ecx, [eax]
mov edx, [ecx+$10]
push eax
call edx //call m_model->LL_BoneID
add esp, 4
movzx edi, ax
cmp di, $FFFF
je @finish
//Òåïåðü âûçîâåì ôóíêöèþ óñòàíîâêè ñòàòóñà äëÿ íàéäåííîé êîñòè
push 00 //âèäèìîñòü äî÷åðíèõ êîñòåé íå ìåíÿòü
movzx eax, status
push eax
push edi
mov ecx, [esi+$0C] //mov ecx, IKinematics* m_model
mov eax, [ecx]
mov edx, [eax+$60]
call edx //call m_model->LL_SetBoneVisible
@finish:
popfd
popad
end;
procedure SetWorldModelBoneStatus(wpn: pointer; bone_name:PChar; status:boolean); stdcall;
asm
pushad
pushfd
//Ïîëó÷èì èíäåêñ êîñòè â ñêåëåòå
push bone_name
call str_container_dock
test eax, eax
je @finish
push eax
push esp //ñîõðàíèëè óêàçàòåëü íà óêàçàòåëü íà îáúåêò-ñòðîêó ñ èìåíåì êîñòè
mov edi, wpn
test edi, edi
je @before_finish
mov esi, [edi+$178] //Ïîìåùàåì pVisual â esi
test esi, esi
je @before_finish
push esi
mov eax, xrgame_addr
add eax, $3483C0
call eax
add esp, 4 //ñíèìàåì ñî ñòåêà àðãóìåíò ôóíêöèè
mov esi, eax
push esi
mov edx, [esi]
mov edx, [edx+$10]
call edx //ïîëó÷àåì èíäåêñ èíòåðåñóþùåé íàñ êîñòè (â ax)
add esp, 4 //ñíèìàåì íàøó ñîõðàíåííóþ "ñòðîêó"
movzx ebx, ax
cmp ebx, $FFFF //Ïðîâåðÿåì, îáíàðóæåíà ëè òàêàÿ êîñòü âîîáùå
je @finish
//ïîëó÷èì àäðåñ íàøåé ôóíêöèè, ïîêàçûâàþùåé/ñêðûâàþùåé êîñòü
mov edx, [esi]
mov edx, [edx+$60]
//à òåïåðü âûïîëíèì îïåðàöèþ ñîêðûòèÿ\îòîáðàæåíèÿ
movzx eax, status
push 00 //âèäèìîñòü äî÷åðíèõ êîñòåé íå ìåíÿòü
push eax
push ebx
mov ecx, esi
call edx
jmp @finish
@before_finish:
add esp, 8
@finish:
popfd
popad
end;
function IKinematics__LL_BoneID(IKinematics:pointer; name:PChar):word; stdcall;
asm
mov @result, $FFFF
pushad
push name
call str_container_dock
test eax, eax
je @finish
push eax
push esp
mov eax, IKinematics
mov ecx, [eax]
mov edx, [ecx+$10]
push eax
call edx
add esp, 4
mov @result, ax
@finish:
popad
end;
end.