forked from gunslingermod/gunslinger_wpnpatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMisc.pas
1812 lines (1490 loc) · 40.5 KB
/
Misc.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
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
unit Misc;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
uses MatVectors, windows, xr_strings, BaseGameData, vector;
//âñÿ÷èíà, êîòîðóþ íå îñîáî ïîíÿòíî, â êàêèå ìîäóëè ñïèõíóòü
type CSE_Abstract = packed record
vftable:pointer;
_flags_ISE:cardinal;
vec_memend:pointer;
vec_end:pointer;
vec_start:pointer;
unk1:cardinal;
unk2:cardinal;
unk3:cardinal;
s_name_replace:PChar;
net_Ready:integer;
net_Processed:integer;
m_wVersion:word;
m_script_version:word;
RespawnTime:word;
ID:word;
ID_Parent:word;
//to be continued...
end;
type pCSE_Abstract = ^CSE_Abstract;
type CSE_ALifeInventoryItem = packed record
vftable:pointer;
m_fCondition:single;
//offset: 0x8
m_fMass:single;
m_dwCost:cardinal;
m_iHealthValue:integer;
m_iFoodValue:integer;
m_fDeteriorationValue:single;
m_self:pointer {CSE_ALifeObject};
m_last_update_time:cardinal;
//offset: 0x24
m_upgrades:xr_vector; {shared_str}
//to be continued...
end;
type pCSE_ALifeInventoryItem = ^CSE_ALifeInventoryItem;
type xr_list_entry_base = packed record
_Next:pointer; //really xr_list_entry_base or child
_Prev:pointer; //really xr_list_entry_base or child
//Next should be item of template type T. Use derived records for it emulation.
end;
NET_Buffer = packed record
data: array[0..16383] of Byte;
count:cardinal;
end;
pNET_Buffer=^NET_Buffer;
NET_Packet = packed record
inistream:pointer; //0x0
B:NET_Buffer; //0x4
r_pos:cardinal; //0x4008
timeReceive:cardinal; //0x400C
w_allow:boolean; //0x4010
_unused1:byte;
_unused2:word;
end;
pNET_Packet = ^NET_Packet;
pxr_list_entry_base = ^xr_list_entry_base;
const
GE_HIT:word = 5;
function Init():boolean;stdcall;
function dxGeomUserData__get_ph_ref_object(dxGeomUserData:pointer):pointer;
function PHRetrieveGeomUserData(dxGeom:pointer):pointer; stdcall;
function game_object_GetScriptGameObject(obj:pointer):pointer;stdcall;
function get_server_object_by_id(id:cardinal):pointer;stdcall;
function alife():pointer;stdcall;
function alife_create(section:PChar; pos:pointer; lvid:cardinal; gvid:cardinal):pCSE_Abstract;stdcall;
function alife_release(srv_obj:pointer):boolean;stdcall;
function xrMemory__allocate(count:cardinal):pointer;stdcall;
function xrMemory__release(addr:pointer):pointer;stdcall;
function CALifeSimulator__spawn_item2(section:PChar; position:pFVector3; level_vertex_id:cardinal; game_vertex_id:cardinal; id_parent:cardinal):{CSE_Abstract*}pointer; stdcall;
function GetMaterialIdx(name:PChar):word; stdcall;
function GetDevicedwFrame():cardinal; stdcall;
procedure DecDevicedwFrame(); stdcall;
function GetDeviceView():pFMatrix4x4; stdcall;
function GetDeviceProjection():pFMatrix4x4; stdcall;
function GetDeviceFullTransform():pFMatrix4x4; stdcall;
function GetDeviceTimeDelta():single; stdcall;
function GetDeviceWidth():cardinal; stdcall;
function GetDeviceHeight():cardinal; stdcall;
procedure DrawSphere(parent: pFMatrix4x4; center:pFVector3; radius:single; clr_s:cardinal; clr_w:cardinal; bSolid:boolean; bWire:boolean); stdcall;
function IsMainMenuActive():boolean; stdcall;
procedure ClearNetPacket(packet:pNET_Packet); stdcall;
procedure WriteToPacket(packet:pNET_Packet; data:pointer; bytes_count:cardinal); stdcall;
procedure SendNetPacket(packet:pNET_Packet); stdcall;
procedure ReadFromReader(r:pIReader; buf:pointer; bytes_count:cardinal); stdcall;
function ReaderLength(r:pIReader):cardinal; stdcall;
function ReaderElapsed(r:pIReader):cardinal; stdcall;
procedure IWriter__w_u32(this:pointer; value:cardinal); stdcall;
procedure IWriter__w_stringZ(this:pointer; value:PAnsiChar); stdcall;
function CastHudItemToCObject(wpn:pointer):pointer; stdcall;
function GetCObjectID(CObject:pointer):word; stdcall;
function GetCObjectXForm(CObject:pointer):pFMatrix4x4; stdcall;
function GetCObjectVisual(CObject:pointer):pointer; stdcall;
function GetCObjectSection(CObject:pointer):pshared_str; stdcall;
function GetCObjectUpdateFrame(CObject:pointer):cardinal; stdcall;
procedure CObject__processing_activate(o:pointer); stdcall;
procedure CObject__processing_deactivate(o:pointer); stdcall;
function get_time_hours():cardinal; stdcall;
function get_time_minutes():cardinal; stdcall;
function get_split_time(years:pcardinal; months:pcardinal; days:pcardinal; hours:pcardinal; minutes:pcardinal; seconds:pcardinal; milliseconds:pcardinal):boolean; stdcall;
function GetAngleByLegs(x,y:single):single;
function IsInputExclusive:boolean; stdcall;
procedure set_name_replace(swpn:pointer; name:PChar); stdcall;
function is_object_has_health(obj:pointer):boolean;
function is_visible_by_thermovisor(cobject:pointer):boolean; stdcall;
procedure ResetElectronicsProblems(); stdcall;
procedure ResetElectronicsProblems_Full(); stdcall;
function ElectronicsProblemsDec():boolean; stdcall;
function ElectronicsProblemsInc():boolean; stdcall;
function TargetElectronicsProblemsCnt():single; stdcall;
function CurrentElectronicsProblemsCnt():single; stdcall;
function PreviousElectronicsProblemsCnt():single; stdcall;
function ElectronicsProblemsImmediateApply():boolean; stdcall;
procedure UpdateElectronicsProblemsCnt(dt:cardinal); stdcall;
function IsElectronicsProblemsDecreasing():boolean; stdcall;
function IsObjectSeePoint(CObject:pointer; point:FVector3; unconditional_vision_dist:single; object_y_correction_value:single; can_backsee:boolean):boolean; stdcall;
procedure DropItemAndTeleport(CObject:pointer; pos:pFVector3); stdcall;
function IsHardUpdates():boolean; stdcall;
function GetHudNearClipPtr():psingle; stdcall;
function GetNegHudNearClipPtr():psingle; stdcall;
procedure get_bone_position(obj:pointer; bone_name:pAnsiChar; res:pFVector3); stdcall;
type MouseCoord = TPoint;
function GetSysMousePoint():MouseCoord;
procedure SetSysMousePoint(c:MouseCoord);
procedure CSE_ALifeInventoryItem__add_upgrade(itm:pCSE_ALifeInventoryItem; up:pshared_str); stdcall;
procedure CSE_ALifeInventoryItem__clone_upgrades(itm_to:pCSE_ALifeInventoryItem; itm_from:pCSE_ALifeInventoryItem); stdcall;
implementation
uses ActorUtils, gunsl_config, Math, HudItemUtils, dynamic_caster, sysutils, raypick, level, LensDoubleRender, throwable;
var
cscriptgameobject_restoreweaponimmediatly_addr:pointer;
previous_electronics_problems_counter:single;
current_electronics_problems_counter:single;
target_electronics_problems_counter:single;
last_problems_update_was_decrease:boolean;
get_addons_state_ptr:pointer;
set_addons_state_ptr:pointer;
set_scope_idx_ptr:pointer;
clone_upgrades_ptr:pointer;
procedure ResetElectronicsProblems(); stdcall;
begin
target_electronics_problems_counter:=0;
end;
procedure ResetElectronicsProblems_Full(); stdcall;
begin
ResetElectronicsProblems();
current_electronics_problems_counter:=0;
previous_electronics_problems_counter:=0;
last_problems_update_was_decrease:=false;
end;
function PreviousElectronicsProblemsCnt():single; stdcall;
begin
result:=previous_electronics_problems_counter;
end;
function ElectronicsProblemsImmediateApply():boolean; stdcall;
begin
current_electronics_problems_counter:=target_electronics_problems_counter;
result:=true;
end;
function ElectronicsProblemsInc():boolean; stdcall;
begin
target_electronics_problems_counter:=target_electronics_problems_counter+1;
result:=true;
end;
function TargetElectronicsProblemsCnt():single; stdcall;
begin
result:=target_electronics_problems_counter;
end;
function CurrentElectronicsProblemsCnt():single; stdcall;
begin
result:=current_electronics_problems_counter;
end;
function ElectronicsProblemsDec():boolean; stdcall;
begin
if target_electronics_problems_counter > 0 then begin
target_electronics_problems_counter:=target_electronics_problems_counter-1;
result:=true;
end else begin
result:=false;
end;
end;
function IsElectronicsProblemsDecreasing():boolean; stdcall;
begin
result:=last_problems_update_was_decrease;
end;
procedure UpdateElectronicsProblemsCnt(dt:cardinal); stdcall;
var
delta, max_delta:single;
begin
previous_electronics_problems_counter := current_electronics_problems_counter;
if target_electronics_problems_counter = current_electronics_problems_counter then begin
exit;
end;
max_delta:= dt/2000;
delta:=target_electronics_problems_counter-current_electronics_problems_counter;
if abs(delta) <= abs(max_delta) then begin
current_electronics_problems_counter:=target_electronics_problems_counter;
end else begin
current_electronics_problems_counter:=current_electronics_problems_counter+sign(delta)*max_delta;
last_problems_update_was_decrease := (delta<0)
end;
// Log(floattostr(current_electronics_problems_counter));
end;
procedure set_name_replace(swpn:pointer; name:PChar); stdcall;
asm
pushad
mov edx, swpn
mov edx, [edx]
mov eax, [edx+$14]
push name
push swpn
call eax
popad
end;
function dxGeomUserData__get_ph_ref_object(dxGeomUserData:pointer):pointer;
asm
mov eax, dxGeomUserData
cmp eax, 0
je @null
mov eax, [eax+$20]
mov @result, eax
jmp @finish
@null:
mov @result, 0
@finish:
end;
function PHRetrieveGeomUserData(dxGeom:pointer):pointer; stdcall;
asm
pushad
mov eax, dxGeom
cmp eax, 0
je @null
push eax //dxGeom
mov eax, xrgame_addr
add eax, $5131d4
call [eax]
add esp, 4
mov @result, eax
jmp @finish
@null:
mov @result, 0
@finish:
popad
end;
function game_object_GetScriptGameObject(obj:pointer):pointer;stdcall;
asm
pushad
mov ecx, obj
mov eax, xrgame_addr
add eax, $27FD40
call eax
mov @result, eax
popad
end;
function is_object_has_health(obj:pointer):boolean;
asm
mov @result, false
pushad
push obj
call game_object_GetScriptGameObject
cmp eax, 0
je @finish
mov ecx, eax
mov ebx, xrgame_addr
add ebx, $1EF870
call ebx
mov @result, al
@finish:
popad
end;
function get_server_object_by_id(id:cardinal):pointer;stdcall;
//!!Changes ECX!!
asm
pushad
pushfd
mov ecx, xrGame_addr
mov ecx, [ecx+$64DA98]
mov ecx, [ecx+$14]
push id
push ecx
mov eax, xrgame_addr
add eax, $99450
call eax
add esp,8
mov @Result, eax
popfd
popad
end;
function alife():pointer;
begin
asm
pushad
pushfd
mov eax, xrgame_addr
add eax, $97780
call eax
mov @result, eax
popfd
popad
end;
end;
function alife_create(section:PChar; pos:pointer; lvid:cardinal; gvid:cardinal):pCSE_Abstract; stdcall;
asm
mov @result, 0
pushad
call alife
cmp eax, 0
je @finish
push gvid
push lvid
push pos
push section
push eax
mov eax, xrgame_addr
add eax, $96eb0
call eax
add esp, $14
mov @result, eax
@finish:
popad
end;
function CALifeSimulator__spawn_item2(section:PChar; position:pFVector3; level_vertex_id:cardinal; game_vertex_id:cardinal; id_parent:cardinal):{CSE_Abstract*}pointer; stdcall;
asm
mov @result, 0
pushad
call alife
cmp eax, 0
je @finish
push id_parent
push game_vertex_id
push level_vertex_id
push position
push section
push eax
mov eax, xrgame_addr
add eax, $99490
call eax
mov @result, eax
add esp, $18
@finish:
popad
end;
function alife_release(srv_obj:pointer):boolean;stdcall;
asm
mov @result, 0
pushad
cmp srv_obj, 0
je @finish
call alife
cmp eax, 0
je @finish
push 01
push srv_obj
push eax
mov eax, xrgame_addr
add eax, $98410
call eax
add esp, $C
mov @result, al
@finish:
popad
end;
procedure get_rank_Patch(); stdcall;
asm
xor esi, esi
end;
procedure CScriptgameobject__restoreweaponimmediatly_impl(act:pointer);stdcall;
var
i:integer;
cnt:cardinal;
begin
if act<>GetActor() then exit;
ChangeSlotsBlockStatus(false);
end;
procedure CScriptgameobject__restoreweaponimmediatly();stdcall;
asm
pushad
push [ecx+4]
call CScriptgameobject__restoreweaponimmediatly_impl
popad
end;
procedure register_cscriptgameobject_methods();stdcall;
const
name_restore:PChar='restore_weapon_immediatly';
asm
//restore_weapon_immediatly
mov [esp+$58], bl
mov ecx, [esp+$58]
push ecx
mov [esp+$28], bl
mov edx, [esp+$28]
push edx
lea ecx, [esp+$60]
push ecx
lea edx, [esp+$28]
push edx
push name_restore
mov ecx, eax
mov edx, cscriptgameobject_restoreweaponimmediatly_addr
mov [esp+$30], edx
mov edx, xrgame_addr
add edx, $1D4350
call edx
//restore cut
mov [esp+$58], bl
mov ecx, [esp+$58]
end;
function GetMaterialIdx(name:PChar):word; stdcall;
asm
pushad
mov ecx, xrgame_addr
mov ecx, [ecx+$512bd4]
push name
mov eax, [xrengine_addr]
add eax, $34250
call eax
mov @result, ax
popad
end;
function xrMemory__allocate(count:cardinal):pointer;stdcall;
asm
pushad
push count
mov eax, xrCore_addr
lea ecx, [eax+$3f854] //xrCore.Memory
add eax, $1AF00
call eax
mov @result, eax
popad
end;
function xrMemory__release(addr:pointer):pointer;stdcall;
asm
pushad
push addr
mov eax, xrCore_addr
lea ecx, [eax+$3f854] //xrCore.Memory
add eax, $1AFF0
call eax
popad
end;
function GetDevicedwFrame():cardinal; stdcall;
begin
asm
mov eax, xrEngine_addr
mov eax, [eax+$92EF0]
mov @result, eax
end;
end;
procedure DecDevicedwFrame(); stdcall;
asm
push eax
mov eax, xrEngine_addr
dec [eax+$92EF0]
pop eax
end;
function IsMainMenuActive():boolean; stdcall;
begin
asm
pushad
mov @result, 0
mov eax, xrEngine_addr
mov eax, [eax+$92D30]
test eax, eax
je @finish
mov ecx, [eax+$46C]
mov edx, [ecx]
mov eax, [edx+$08]
call eax
mov @result, al
@finish:
popad
end;
end;
function GetDeviceView():pFMatrix4x4; stdcall;
begin
asm
mov eax, xrEngine_addr
lea eax, [eax+$92ED8+$60]
mov @result, eax
end;
end;
function GetDeviceProjection():pFMatrix4x4; stdcall;
begin
asm
mov eax, xrEngine_addr
lea eax, [eax+$92ED8+$A0]
mov @result, eax
end;
end;
function GetDeviceFullTransform():pFMatrix4x4; stdcall;
begin
asm
mov eax, xrEngine_addr
lea eax, [eax+$92ED8+$E0]
mov @result, eax
end;
end;
//-----------------------------------------------------------------------------------------------------------
procedure ClearNetPacket(packet:pNET_Packet); stdcall;
begin
packet^.inistream:=nil;
packet^.B.count:=0;
packet^.r_pos:=0;
packet^.timeReceive:=0;
packet^.w_allow:=true;
end;
procedure WriteToPacket(packet:pNET_Packet; data:pointer; bytes_count:cardinal); stdcall;
asm
pushad
mov eax, xrgame_addr
mov eax, [eax+$5127cc] //NET_Packet::w
push bytes_count
push data
mov ecx, packet
call eax;
popad
end;
procedure SendNetPacket(packet:pNET_Packet); stdcall;
asm
pushad
call GetLevel
push 0
push 8
push packet
mov edx,[eax+$40110]
mov edx,[edx+$10]
lea ecx,[eax+$40110]
call edx
popad
end;
procedure ReadFromReader(r:pIReader; buf:pointer; bytes_count:cardinal); stdcall;
asm
pushad
mov eax, xrgame_addr
mov eax, [eax+$5127D4]
push bytes_count
push buf
mov ecx, r
call eax;
popad
end;
function ReaderLength(r:pIReader):cardinal; stdcall;
asm
pushad
mov eax, xrgame_addr
mov eax, [eax+$512970]
mov ecx, r
call eax
mov @result, eax
popad
end;
function ReaderElapsed(r:pIReader):cardinal; stdcall;
asm
push ecx
mov ecx, r
mov eax, [ecx+$10]
sub eax, [ecx+$c]
mov @result, eax
pop ecx
end;
procedure IWriter__w_u32(this:pointer; value:cardinal); stdcall;
asm
pushad
push value
mov ecx, this
mov eax, xrgame_addr
add eax, $5129e8 //IWriter::w_u32
call [eax]
popad
end;
procedure IWriter__w_stringZ(this:pointer; value:PAnsiChar); stdcall;
asm
pushad
push value
mov ecx, this
mov eax, xrgame_addr
add eax, $5128b4 //IWriter::w_stringZ
call [eax]
popad
end;
function GetDeviceTimeDelta():single; stdcall;
begin
asm
mov eax, xrEngine_addr
mov eax, [eax+$92ED8+$1C]
mov @result, eax
end;
end;
function GetDeviceWidth():cardinal; stdcall;
begin
asm
mov eax, xrEngine_addr
mov eax, [eax+$92ED8+$04]
mov @result, eax
end;
end;
function GetDeviceHeight():cardinal; stdcall;
begin
asm
mov eax, xrEngine_addr
mov eax, [eax+$92ED8+$08]
mov @result, eax
end;
end;
function GetCObjectID(CObject:pointer):word; stdcall;
asm
mov eax, [CObject]
movzx eax, word ptr [eax+$A4]
mov @result, ax
end;
function GetCObjectXForm(CObject:pointer):pFMatrix4x4; stdcall;
asm
mov eax, [CObject]
lea eax, [eax+$50]
mov @result, eax
end;
function GetCObjectVisual(CObject:pointer):pointer; stdcall;
asm
mov eax, [CObject]
mov eax, [eax+$90]
mov @result, eax
end;
function GetCObjectSection(CObject:pointer):pshared_str; stdcall;
asm
mov eax, [CObject]
lea eax, [eax+$ac]
mov @result, eax
end;
function GetCObjectUpdateFrame(CObject:pointer):cardinal; stdcall;
asm
mov eax, [CObject]
mov eax, [eax+$FC]
mov @result, eax
end;
function CastHudItemToCObject(wpn:pointer):pointer; stdcall;
asm
mov eax, [wpn]
add eax, $e8 //nonportable - cast to CObject
mov [result], eax
end;
//-----------------------------------------------------------------------------------------------------------
procedure CHW__CreateDevice_VSync_R1_R2; stdcall;
asm
pushad
call IsVSyncEnabled
cmp al, 0
je @no_vsync
mov [edi+$34], 0 //D3DPRESENT_INTERVAL_DEFAULT
jmp @finish
@no_vsync:
mov [edi+$34], $80000000 //D3DPRESENT_INTERVAL_IMMEDIATE
@finish:
popad
end;
procedure CHW__Reset_VSync_R1_R2; stdcall;
asm
pushad
call IsVSyncEnabled
cmp al, 0
je @no_vsync
mov [ebx+$A8], 0 //D3DPRESENT_INTERVAL_DEFAULT
jmp @finish
@no_vsync:
mov [ebx+$A8], $80000000 //D3DPRESENT_INTERVAL_IMMEDIATE
@finish:
popad
end;
function IsInputExclusive:boolean; stdcall;
begin
asm
mov eax, xrengine_addr
add eax, $9032B
mov al, byte ptr [eax]
mov @result, al
end;
end;
function GetAngleByLegs(x,y:single):single;
var
gyp, k:single;
begin
gyp:=sqrt(x*x+y*y);
k:=clamp(y/gyp, -1.0, 1.0);
result:=arcsin(k);
if (x<0) then begin
result:=pi-result
end;
if result<0 then result:=result+2*pi;
end;
procedure CGameObject_x_axis(v:pFVector3); stdcall;
asm
pushad
mov eax, [ecx+4]
sub eax, $e8 //nonportable - cast to CWeapon
push eax
call GetXFORM
mov esi, [eax+FMatrix4x4.i.x]
mov edi, [eax+FMatrix4x4.i.y]
mov ebx, [eax+FMatrix4x4.i.z]
mov edx, v
mov [edx+FVector3.x], esi
mov [edx+FVector3.y], edi
mov [edx+FVector3.z], ebx
popad
mov eax, v
end;
procedure CGameObject_y_axis(v:pFVector3); stdcall;
asm
pushad
mov eax, [ecx+4]
sub eax, $e8 //nonportable - cast to CWeapon
push eax
call GetXFORM
mov esi, [eax+FMatrix4x4.j.x]
mov edi, [eax+FMatrix4x4.j.y]
mov ebx, [eax+FMatrix4x4.j.z]
mov edx, v
mov [edx+FVector3.x], esi
mov [edx+FVector3.y], edi
mov [edx+FVector3.z], ebx
popad
mov eax, v
end;
procedure CGameObject_z_axis(v:pFVector3); stdcall;
asm
pushad
mov eax, [ecx+4]
sub eax, $e8 //nonportable - cast to CWeapon
push eax
call GetXFORM
mov esi, [eax+FMatrix4x4.k.x]
mov edi, [eax+FMatrix4x4.k.y]
mov ebx, [eax+FMatrix4x4.k.z]
mov edx, v
mov [edx+FVector3.x], esi
mov [edx+FVector3.y], edi
mov [edx+FVector3.z], ebx
popad
mov eax, v
end;
procedure CScriptGameObject_ExportAxisVectors; stdcall;
const
get_x:PChar='get_x_axis';
get_y:PChar='get_y_axis';
get_z:PChar='get_z_axis';
asm
mov [esp+$24], 0
mov edx, [esp+$24]
push edx
mov [esp+$1C], 0
mov ecx, [esp+$1C]
push ecx
lea edx, [esp+$1C]
push edx
lea ecx, [esp+$28]
push ecx
push get_x
mov ecx, eax
lea edx, dword ptr [CGameObject_x_axis]
mov [esp+$30], edx
mov edx, xrgame_addr
add edx, $1D6D20
call edx
mov [esp+$24], 0
mov edx, [esp+$24]
push edx
mov [esp+$1C], 0
mov ecx, [esp+$1C]
push ecx
lea edx, [esp+$1C]
push edx
lea ecx, [esp+$28]
push ecx
push get_y
mov ecx, eax
lea edx, dword ptr [CGameObject_y_axis]
mov [esp+$30], edx
mov edx, xrgame_addr
add edx, $1D6D20
call edx
mov [esp+$24], 0
mov edx, [esp+$24]
push edx
mov [esp+$1C], 0
mov ecx, [esp+$1C]
push ecx
lea edx, [esp+$1C]
push edx
lea ecx, [esp+$28]
push ecx
push get_z
mov ecx, eax
lea edx, dword ptr [CGameObject_z_axis]
mov [esp+$30], edx
mov edx, xrgame_addr
add edx, $1D6D20
call edx
mov [esp+$24], 0
mov edx, [esp+$20]
end;
function is_visible_by_thermovisor(cobject:pointer):boolean; stdcall;
begin
if dynamic_cast(cobject, 0, RTTI_CObject, RTTI_CAI_Crow, false)<>nil then begin
result:=true;
exit;
end;
if dynamic_cast(cobject, 0, RTTI_CObject, RTTI_CAI_Bloodsucker, false)<>nil then begin
result:=false;
exit;
end;