-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathActorUtils.pas
5283 lines (4502 loc) · 152 KB
/
ActorUtils.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 ActorUtils;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
//xrgame+4e212a - ìåíÿòü óñëîâèÿ äëÿ âêëþ÷åíèÿ êîëëèçèè
{$define USE_SCRIPT_USABLE_HUDITEMS} //íà âñÿêèé - ïîòîì âñå ðàâíî â äâèã íàäî ïåðåêèíóòü, íî âëîì - è òàê îòëè÷íî ðàáîòàåò
interface
uses LightUtils, WeaponAdditionalBuffer, MatVectors, HitUtils, vector, xr_map, physics;
const
actMovingForward:cardinal = $1;
actMovingBack:cardinal = $2;
actMovingLeft:cardinal = $4;
actMovingRight:cardinal = $8;
actCrouch:cardinal = $10;
actSlow:cardinal = $20;
actJump:cardinal = $80;
actFall:cardinal = $100;
actLanding:cardinal = $200;
actLanding2:cardinal = $400;
actSprint:cardinal = $1000;
actLLookout:cardinal = $2000;
actRLookout:cardinal = $4000;
actModNeedBlowoutAnim:cardinal = $02000000;
actAimStarted:cardinal = $04000000;
actShowDetectorNow:cardinal = $08000000; //ïðåääîñòàâàíèå ïðîèãðàëoñü, ìîæíî ïîêàçûâàòü äåòåêòîð
actModSprintStarted:cardinal = $10000000;
actModNeedMoveReassign:cardinal = $20000000;
actModDetectorSprintStarted:cardinal = $40000000;
actModDetectorAimStarted:cardinal = $80000000;
actTotalActions:cardinal = $FFFFFFFF;
mState_WISHFUL:cardinal = $58c;
mState_OLD:cardinal = $590;
mState_REAL:cardinal = $594;
kfUNZOOM:cardinal=$1;
kfRELOAD:cardinal=$2;
kfNEXTFIREMODE:cardinal=$8;
kfPREVFIREMODE:cardinal=$10;
kfGLAUNCHSWITCH:cardinal=$20;
kfWPNHIDE:cardinal=$40;
kfDETECTOR:cardinal=$80;
kfZOOM:cardinal=$100;
kfFIRE:cardinal=$200;
kfLASER:cardinal=$400;
kfTACTICALTORCH:cardinal=$800;
kfNEXTAMMO:cardinal = $1000;
kfHEADLAMP:cardinal = $2000;
kfNIGHTVISION:cardinal = $4000;
kfQUICKKICK:cardinal = $8000;
kfPDAHIDE:cardinal = $10000;
kfPDASHOW:cardinal = $20000;
kfINVENTORYSHOW:cardinal=$40000;
type
priority_group = packed record
m_sections:xr_set;
end;
ppriority_group = ^priority_group;
CInventory = packed record
vftable:pointer;
m_all:xr_vector;
m_ruck:xr_vector;
m_belt:xr_vector;
m_activ_last_items:xr_vector;
m_slots:xr_vector;
m_iActiveSlot:word;
m_iNextActiveSlot:word;
m_iPrevActiveSlot:word;
_unused1:word;
m_pOwner:pointer;
m_bBeltUseful:byte;
m_bSlotsUseful:byte;
_unused2:word;
m_fMaxWeight:single;
m_fTotalWeight:single;
m_dwModifyFrame:cardinal;
m_drop_last_frame:byte;
_unused3:byte;
_unused4:word;
m_slot2_priorities:array[0..4] of ppriority_group;
m_slot3_priorities:array[0..4] of ppriority_group;
m_groups: array [0..4] of priority_group;
m_null_priority:priority_group;
m_next_items_exceptions:xr_set;
m_next_item_iteration_time:cardinal;
m_blocked_slots:array[0..12] of byte;
end;
pCInventory=^CInventory;
lefthanded_torchlight_params = packed record
base:torchlight_params;
aim_offset:FVector3;
end;
CEntityConditionSimple = packed record
vftable:pointer;
m_fHealth:single;
m_fHealthMax:single;
end;
SConditionChangeV = packed record //sizeof = 0x20
m_fV_Radiation:single;
m_fV_PsyHealth:single;
m_fV_Circumspection:single;
m_fV_EntityMorale:single;
m_fV_RadiationHealth:single;
m_fV_Bleeding:single;
m_fV_WoundIncarnation:single;
m_fV_HealthRestore:single;
end;
SBooster = packed record
fBoostTime:single;
fBoostValue:single;
m_type:cardinal;
end;
pSBooster = ^SBooster;
BOOSTER_MAP = packed record // sizeof = 0x1c
data:xr_integerindexed_map_base;
end;
CEntityCondition = packed record //xizeof = 0x140;
base_CEntityConditionSimple:CEntityConditionSimple;
base_CHitImmunity:CHitImmunity;
//offset: 0x40
m_use_limping_state:byte; {boolean}
_unused1:byte;
_unused2:word;
m_object:pointer;
m_WoundVector:xr_vector;
m_fPower:single;
m_fRadiation:single;
m_fPsyHealth:single;
m_fEntityMorale:single;
//offset:0x64
m_fPowerMax:single;
m_fRadiationMax:single;
m_fPsyHealthMax:single;
m_fEntityMoraleMax:single;
//offset:0x74
m_fDeltaHealth:single;
m_fDeltaPower:single;
m_fDeltaRadiation:single;
m_fDeltaPsyHealth:single;
m_fDeltaCircumspection:single;
m_fDeltaEntityMorale:single;
//offset:0x8c
m_change_v:SConditionChangeV;
//offset:0xac
m_fMinWoundSize:single;
//offset:0xb0
m_bIsBleeding:boolean;
_unused3:byte;
_unused4:word;
m_fHealthHitPart:single;
m_fPowerHitPart:single;
//offset:0xbc
m_fBoostBurnImmunity:single;
m_fBoostShockImmunity:single;
m_fBoostRadiationImmunity:single;
m_fBoostTelepaticImmunity:single;
m_fBoostChemicalBurnImmunity:single;
m_fBoostExplImmunity:single;
m_fBoostStrikeImmunity:single;
m_fBoostFireWoundImmunity:single;
m_fBoostWoundImmunity:single;
m_fBoostRadiationProtection:single;
m_fBoostTelepaticProtection:single;
m_fBoostChemicalBurnProtection:single;
//offset:0xec
m_fHealthLost:single;
m_fKillHitTreshold:single;
m_fLastChanceHealth:single;
m_fInvulnerableTime:single;
m_fInvulnerableTimeDelta:single;
//offset:0x100
m_iLastTimeCalled:Int64;
m_fDeltaTime:single;
m_pWho:pointer;
//offset:0x110
m_iWhoID:word;
_unused5:word;
m_fHitBoneScale:single;
m_fWoundBoneScale:single;
m_limping_threshold:single;
//offset:0x120
m_bTimeValid:byte; {boolean}
m_bCanBeHarmed:byte; {boolean}
_unused6:word;
m_booster_influences:BOOSTER_MAP;
end;
pCEntityCondition=^CEntityCondition;
SMedicineInfluenceValues = packed record //sizeof = 0x24
fHealth:single;
fPower:single;
fSatiety:single;
fRadiation:single;
fWoundsHeal:single;
fMaxPowerUp:single;
fAlcohol:single;
fTimeTotal:single;
fTimeCurrent:single;
end;
CActorCondition = packed record //sizeof = 0x224
base_CEntityCondition:CEntityCondition;
//offset:0x140
m_condition_flags:cardinal;
m_object:pointer;
m_death_effector:pointer;
//offset:0x14c
m_curr_medicine_influence:SMedicineInfluenceValues;
//offset:0x170
m_fAlcohol:single;
m_fV_Alcohol:single;
m_fSatiety:single;
m_fV_Satiety:single;
m_fV_SatietyPower:single;
m_fV_SatietyHealth:single;
m_fSatietyCritical:single;
m_fPowerLeakSpeed:single;
//offset:0x190
m_fJumpPower:single;
m_fStandPower:single;
m_fWalkPower:single;
m_fJumpWeightPower:single;
m_fWalkWeightPower:single;
m_fOverweightWalkK:single;
m_fOverweightJumpK:single;
m_fAccelK:single;
m_fSprintK:single;
m_MaxWalkWeight:single;
//offset:0x1b8
m_zone_max_power: array [0..4] of single;
m_zone_danger: array [0..4] of single;
//offset:0x1e0
m_f_time_affected:single;
m_max_power_restore_speed:single;
m_max_wound_protection:single;
m_max_fire_wound_protection:single;
//offset:0x1f0
m_bLimping:byte; {boolean}
m_bCantWalk:byte; {boolean}
m_bCantSprint:byte; {boolean}
_unused1:byte;
//offset:0x1f4
m_fLimpingPowerBegin:single;
m_fLimpingPowerEnd:single;
m_fCantWalkPowerBegin:single;
m_fCantWalkPowerEnd:single;
//offset:0x214
m_fCantSprintPowerBegin:single;
m_fCantSprintPowerEnd:single;
m_fLimpingHealthBegin:single;
m_fLimpingHealthEnd:single;
m_use_sound:pointer;
end;
pCActorCondition = ^CActorCondition;
function GetActor():pointer; stdcall;
function GetActorIfAlive():pointer; stdcall;
function GetActorTargetSlot():integer; stdcall;
function GetActorActiveSlot():integer; stdcall;
function GetActorInventory(act:pointer):pCInventory; stdcall;
//äëÿ áûñòðîãî èñïîëüçîâàíèÿ
function GetActorPreviousSlot():integer; stdcall;
procedure RestoreLastActorDetector(); stdcall;
function GetActorActionState(stalker:pointer; mask:cardinal; state:cardinal=$594):boolean; stdcall;
function GetActorActionStateInt(stalker:pointer; mask:cardinal; state:cardinal=$594):integer; stdcall;
procedure CreateObjectToActor(section:PChar); stdcall;
function IsHolderInSprintState(wpn:pointer):boolean; stdcall; //ðàáîòàåò òîëüêî äëÿ àêòîðà, äëÿ äðóãèõ âñåãäà âåðíåò false!
function IsHolderHasActiveDetector(wpn:pointer):boolean; stdcall;
function IsHolderInAimState(wpn:pointer):boolean;stdcall;
procedure SetActorActionState(stalker:pointer; mask:cardinal; set_value:boolean; state:cardinal=$594); stdcall;
function GetActorActiveItem():pointer; stdcall;
function ItemInSlot(act:pointer; slot:integer):pointer; stdcall;
procedure DropItem(act:pointer; item:pointer); stdcall;
function Init():boolean; stdcall;
function CheckActorWeaponAvailabilityWithInform(wpn:pointer):boolean;
procedure SetActorKeyRepeatFlag(mask:cardinal; state:boolean; ignore_suicide:boolean=false);
function GetActorKeyRepeatFlag(mask:cardinal):boolean;
procedure ClearActorKeyRepeatFlags();
procedure ResetActorFlags(act:pointer);
procedure UpdateSlots(act:pointer);
procedure UpdateBelt(act:pointer);
procedure UpdateFOV(act:pointer);
function GetSlotOfActorHUDItem(act:pointer; itm:pointer):integer; stdcall;
procedure ActivateActorSlot(slot:cardinal); stdcall;
procedure ActivateActorSlot__CInventory(slot:word; forced:boolean); stdcall;
function GetActorSlotBlockedCounter(slot:cardinal):cardinal; stdcall;
procedure SetActorSlotBlockedCounter(slot:cardinal; cnt:byte); stdcall;
procedure ChangeSlotsBlockStatus(block:boolean); stdcall;
function IsHandJitter(itm:pointer):boolean; stdcall;
procedure SetHandsJitterTime(time:cardinal); stdcall;
function GetHandJitterScale(itm:pointer):single; stdcall;
procedure SetFOV(fov:single); stdcall;
function GetFOV():single; stdcall;
procedure SetHudFOV(fov:single); stdcall;
function CRenderDevice__GetCamPos():pointer;stdcall;
function CRenderDevice__GetCamDir():pointer;stdcall;
function CRenderDevice__GetCamTop():pointer;stdcall;
function CRenderDevice__GetCamRight():pointer;stdcall;
procedure CorrectDirFromWorldToHud(dir:pFVector3; pos:pFVector3; k:single); stdcall;
function GetTargetDist():single;stdcall;
function GetActorThirst():single;stdcall;
procedure SwitchLefthandedTorch(status:boolean); stdcall;
procedure RecreateLefthandedTorch(params_section:PChar; det:pointer); stdcall;
function GetLefthandedTorchLinkedDetector():pointer; stdcall;
function GetLefthandedTorchParams():lefthanded_torchlight_params; stdcall;
procedure KillActor(actor:pointer; who:pointer); stdcall;
procedure CEntity__KillEntity(this:pointer; who:word); stdcall;
procedure CActor__set_inventory_disabled(this:pointer; status:boolean); stdcall;
function CActor__get_inventory_disabled(this:pointer):boolean; stdcall;
function CInventory__CalcTotalWeight(this:pointer):single; stdcall;
function CInventory__BeltWidth(this:pointer):integer; stdcall;
function CInventoryOwner__GetInventory(this:pointer):pCInventory; stdcall;
procedure SetDisableInputStatus(status:boolean); stdcall;
procedure HeadlampCallback(wpn:pointer; param:integer); stdcall;
procedure NVCallback(wpn:pointer; param:integer); stdcall;
procedure KickCallback(wpn:pointer; param:integer); stdcall;
procedure SetActorActionCallback(cb:TAnimationEffector);
function GetActorActionCallback():TAnimationEffector;
function IsActorActionAnimatorAutoshow():boolean;
procedure add_pp_effector(fn:pchar; id:integer; cyclic:boolean); stdcall;
procedure set_pp_effector_factor2(id:integer; f:single); stdcall;
procedure set_pp_effector_factor(id:integer; f:single; f_sp:single); stdcall;
procedure remove_pp_effector(id:integer); stdcall;
function GetActorHealth(act:pointer):single; stdcall;
function GetActorStamina(act:pointer):single; stdcall;
procedure SetActorStamina(act:pointer; val:single); stdcall;
function GetCameraManager():pointer; stdcall;
function CCameraManager__GetCamEffector(index:cardinal):pointer; stdcall;
procedure CCameraManager__RemoveCamEffector(index:cardinal); stdcall;
function GetPDAJoystickAnimationModifier():string;
procedure CActor__OnKeyboardPress_initiate(dik:cardinal); stdcall;
procedure PerformDrop(act:pointer); stdcall;
procedure ResetChangedGrenade();
procedure SetChangedGrenade(itm:pointer);
function GetEntityDirection(e:pointer):pFVector3; stdcall;
function GetEntityPosition(e:pointer):pFVector3; stdcall;
function IsPickupMode():boolean; stdcall;
function IsPDAShowToZoomNow():boolean;
function GetBoosterFromConditions(cond:pCEntityCondition; booster_type:cardinal):pSBooster; stdcall;
function GetActorConditions(act:pointer):pCActorCondition; stdcall;
function CEntityCondition__BleedingSpeed_reimpl(pcond:pCEntityCondition; hit_type_mask:integer = -1):single; stdcall;
procedure CEntityCondition__ChangeBleeding_custom(cond:pCEntityCondition; percent:single; hit_type_mask:integer = -1); stdcall;
function IsItemActionAnimator(itm:pointer):boolean; stdcall;
procedure PlanActorKickAnimator(kick_types_section:string);
procedure OnInventoryShowAttempt(); stdcall;
function IsTacticHudInstalled():boolean; stdcall;
const
eBoostHpRestore:cardinal=0;
eBoostPowerRestore:cardinal=1;
eBoostRadiationRestore:cardinal=2;
eBoostBleedingRestore:cardinal=3;
eBoostMaxWeight:cardinal=4;
eBoostRadiationProtection:cardinal=5;
eBoostTelepaticProtection:cardinal=6;
eBoostChemicalBurnProtection:cardinal=7;
eBoostBurnImmunity:cardinal=8;
eBoostShockImmunity:cardinal=9;
eBoostRadiationImmunity:cardinal=10;
eBoostTelepaticImmunity:cardinal=11;
eBoostChemicalBurnImmunity:cardinal=12;
eBoostExplImmunity:cardinal=13;
eBoostStrikeImmunity:cardinal=14;
eBoostFireWoundImmunity:cardinal=15;
eBoostWoundImmunity:cardinal=16;
var
_is_pda_lookout_mode:boolean; //çà ÷òî îòâå÷àåò ìûøü: îáçîð èëè êóðñîð
psMouseSens:psingle;
psMouseSensScale:psingle;
NET_Jump:psingle;
const
KNIFE_SLOT:byte=1;
GRENADE_SLOT:byte=4;
OUTFIT_SLOT:byte=7;
DETECTOR_SLOT:byte=9;
TORCH_SLOT:byte=10;
HELMET_SLOT:byte=12;
implementation
uses Messenger, BaseGameData, HudItemUtils, Misc, DetectorUtils, sysutils, UIUtils, KeyUtils, gunsl_config, WeaponEvents, Throwable, dynamic_caster, WeaponUpdate, ActorDOF, WeaponInertion, strutils, Math, collimator, xr_BoneUtils, ControllerMonster, Level, ScriptFunctors, Crows, LensDoubleRender, xr_strings, RayPick, materials;
type
TCursorDirection = (Idle, Up, Down, Left, Right, UpLeft, DownLeft, DownRight, UpRight, Click);
TCursorState = packed record
last_moving_time:cardinal;
last_click_time:cardinal;
dir_accumulator:FVector2;
current_dir:TCursorDirection;
end;
var
_keyflags:cardinal;
_last_act_slot:integer;
_prev_act_slot:integer;
_jitter_time_remains:cardinal;
_thirst_value:single;
{$ifdef USE_SCRIPT_USABLE_HUDITEMS}
_was_unprocessed_use_of_usable_huditem:boolean;
{$endif}
_lefthanded_torch:lefthanded_torchlight_params;
_torch_linked_detector:pointer;
_last_update_time:cardinal;
_action_animator_callback:TAnimationEffector;
_action_animator_param:integer;
_action_ppe:integer;
_action_animator_autoshow:boolean;
_sprint_tiredness:single; //êàê äîëãî ìû áåæàëè
_was_pda_animator_spawned:boolean;
_pda_cursor_state:TCursorState;
_changed_grenade:pointer;
_actor_hands_length:single;
_hud_update_sect:string;
_slot_to_restore_after_outfit_change:integer;
_last_mouse_coord:MouseCoord;
_need_pda_zoom:boolean;
_last_pda_zoom_state:boolean;
_pda_blowout_anim_started:boolean;
_planned_kick_animator:string;
_need_fire_particle:boolean;
//-------------------------------------------------------------------------------------------------------------
procedure player_hud__load_fixpatched(); stdcall;
asm
sub esp, 8
push esi
push edi
mov edi, xrgame_addr
add edi, $2fecf5
jmp edi
end;
procedure player_hud__load(sect:pshared_str); stdcall;
asm
mov ecx, xrgame_addr
mov ecx, [ecx+$64f0e4] //g_player_hud
push sect
call player_hud__load_fixpatched
end;
procedure SetHudReloadRequest(sect:pshared_str); stdcall;
begin
R_ASSERT(sect<>nil, 'sect == nil', 'SetHudReloadRequest');
_hud_update_sect:=get_string_value(sect);
end;
procedure player_hud__onloadrequest(); stdcall;
asm
mov eax, [esp+4]
pushad
call GetActor
test eax, eax
popad
jne @registerrequest
// åñëè àêòîðà íå ñóùåñòâóåò - íóæíî óñòàíîâèòü õóä
pushad
push eax
call player_hud__load
popad
jmp @finish
@registerrequest:
// Åñëè àêòîð ñóùåñòâóåò - çàðåãèñòðèðóåì "çàïðîñ" íà ñìåíó õóäà
pushad
push eax
call SetHudReloadRequest
popad
@finish:
// áîëüøå íè÷åãî íå äåëàåì
ret 4
end;
//-------------------------------------------------------------------------------------------------------------
procedure SetChangedGrenade(itm:pointer);
begin
_changed_grenade:=itm;
end;
procedure ResetChangedGrenade();
begin
_changed_grenade:=nil;
end;
procedure ProcessChangedGrenade(act:pointer);
begin
if _changed_grenade <> nil then begin
virtual_Action(_changed_grenade, kWPN_NEXT, kActPress);
end;
end;
procedure PerformDrop(act:pointer); stdcall;
asm
pushad
mov eax, act
add eax, $2c8
mov eax, [eax+$1c]
push $02 // CMD_STOP
push $27 // kDROP
mov ecx, eax
mov ebx, xrgame_addr
add ebx, $2a9640
call ebx // CInventory::Action
test al, al
jne @finish
mov ecx, act
mov edx, [ecx]
mov eax, [edx+$28C]
call eax
@finish:
popad
end;
procedure PerformDropFromActorHands(); stdcall;
var
act, det:pointer;
begin
act:=GetActorIfAlive();
if act=nil then exit;
det:=GetActiveDetector(act);
if det<>nil then begin
DropItem(act, det);
end;
PerformDrop(act);
end;
//-------------------------------------------------------------------------------------------------------------
procedure CTorch__Switch(CTorch:pointer; status:boolean);stdcall;
asm
pushad
movzx eax, status
push eax
mov ecx, CTorch
mov eax, xrgame_addr
add eax, $2f13f0
call eax
popad
end;
function IsTorchSwitchedOn(CTorch:pointer):boolean; stdcall;
asm
push eax
mov eax, CTorch
mov al, [eax+$2FC]
mov @result, al
pop eax
end;
procedure CTorch__StopNvEffector(CTorch:pointer; speed:single; use_sounds:boolean);stdcall;
asm
pushad
movzx eax, use_sounds
push eax
mov ebx, speed
push ebx
mov ecx,CTorch
mov ecx, [ecx+$31c]
mov eax, xrgame_addr
add eax, $2f1080
call eax
popad
end;
procedure CTorch__SwitchNightVision(CTorch:pointer; status:boolean; use_sounds:boolean);stdcall;
asm
pushad
movzx eax, use_sounds
push eax
movzx eax, status
push eax
mov ecx, CTorch
mov eax, xrgame_addr
add eax, $2f26d0
call eax
popad
end;
function IsItemAllowsUsingTorch(itm:pointer):boolean; stdcall;
begin
result:=false;
if itm = nil then exit;
result:=game_ini_r_bool_def(GetSection(itm), 'torch_available', false);
result:=FindBoolValueInUpgradesDef(itm, 'torch_available', result, true);
end;
function CanUseTorch(CTorch:pointer):boolean; stdcall;
var
act, outfit, helmet:pointer;
begin
result:=true;
act:=GetActor();
if (act=nil) or (GetOwner(CTorch)<>act) then exit;
helmet := ItemInSlot(act, HELMET_SLOT);
outfit := ItemInSlot(act, OUTFIT_SLOT);
result := IsItemAllowsUsingTorch(helmet) or IsItemAllowsUsingTorch(outfit);
end;
//--------------------------------------------------------------------------------------------------
function IsNVSwitchedOn(CTorch:pointer):boolean; stdcall;
asm
mov eax, CTorch
movzx eax, byte ptr [eax+$319]
end;
function IsNVPostprocessOn(CTorch:pointer):boolean; stdcall;
asm
mov @result, 0
pushad
mov ecx, CTorch
cmp ecx, 0
je @finish
mov eax, [ecx+$31c]
cmp eax, 0
je @finish
mov eax, [eax] //m_pActor
cmp eax, 0
je @finish
mov eax, [eax+$544]
push $37
mov ecx, eax
mov eax, xrgame_addr
call [eax+$512D80] //CCameraManager::GetPPEffector
test eax, eax
je @finish
mov @result, 1
@finish:
popad
end;
function IsHelmetHasNV(CHelmet:pointer):boolean; stdcall;
asm
mov @result, 0
mov eax, CHelmet
cmp eax, 0
je @finish
mov eax, [eax+$2e4]
cmp eax, 0
je @finish
cmp [eax+4], 0
je @finish
mov @result, 1
@finish:
end;
function IsOutfitHasNV(CCustomOutfit:pointer):boolean; stdcall;
asm
mov @result, 0
mov eax, CCustomOutfit
cmp eax, 0
je @finish
mov eax, [eax+$348]
cmp eax, 0
je @finish
cmp [eax+4], 0
je @finish
mov @result, 1
@finish:
end;
function CanUseNV(CTorch:pointer):boolean; stdcall;
var
act, helm, outfit:pointer;
begin
result:=false;
act:=GetActor();
if (act=nil) or (GetOwner(CTorch)<>act) then exit;
helm:=ItemInSlot(act, HELMET_SLOT);
outfit:=ItemInSlot(act, OUTFIT_SLOT);
if helm<>nil then helm:=dynamic_cast(helm, 0, RTTI_CInventoryItem, RTTI_CHelmet, false);
if outfit<>nil then outfit:=dynamic_cast(outfit, 0, RTTI_CInventoryItem, RTTI_CCustomOutfit, false);
result:= IsHelmetHasNV(helm) or IsOutfitHasNV(outfit);
end;
procedure OnOutfitOrHelmInRuck(CTorch:pointer); stdcall;
begin
if not CanUseTorch(CTorch) then begin
CTorch__Switch(CTorch, false);
end;
end;
procedure OnOutfitOrHelmInRuck_Patch(); stdcall;
asm
pushad
push ecx
call OnOutfitOrHelmInRuck
popad
push 1
push 0
push ecx
call CTorch__SwitchNightVision
ret 8
end;
procedure CTorch__Switch_Patch(); stdcall;
asm
pushad
push ecx
call CanUseTorch
cmp al, 1
popad
je @finish
//íåëüçÿ ïîëüçîâàòüñÿ ôîíàðåì! âûñòàâëÿåì àðãóìåíò ñòàòóñà â 0
xor ebx, ebx
mov [esp+$14], 0
@finish:
lea edi, [esi+$e8]
end;
function IsItemActionAnimator(itm:pointer):boolean; stdcall;
begin
result:=false;
if itm = nil then exit;
result:=game_ini_r_bool_def(GetSection(itm), 'action_animator', false)
end;
function OnActorSwithesSmth(restrictor_config_param:PChar; animator_item_section:PChar; anm_name:PChar; snd_label:PChar; key_repeat:cardinal; callback:TAnimationEffector; callback_param:integer):boolean; stdcall;
var
buf:WpnBuf;
wpn, act, det:pointer;
res:boolean;
curanm:PChar;
slot:integer;
begin
result:=false;
act:=GetActor();
if act=nil then exit;
wpn:=GetActorActiveItem();
det:=GetActiveDetector(act);
if (det<>nil) and (GetCurrentState(det)<>EHudStates__eIdle) then begin
exit;
end;
if (wpn=nil) or (restrictor_config_param=nil) or FindBoolValueInUpgradesDef(wpn, restrictor_config_param, game_ini_r_bool_def(GetSection(wpn), restrictor_config_param, false), true) then begin
if not game_ini_r_bool_def(animator_item_section, 'action_animator', false) then begin
log('Section ['+animator_item_section+'] defined as action animator in [gunslinger_base], but key action_animator is false or does not exist!', true);
if IsDebug then Messenger.SendMessage('Action animator: invalid configuration, see log!');
end;
// log('spawn scheme');
//åñëè îðóæèå åñòü è îíî çàíÿòî - óõîäèì
if (wpn<>nil) then begin
buf:=GetBuffer(wpn);
if (buf<>nil) and not Weapon_SetKeyRepeatFlagIfNeeded(wpn, key_repeat) then begin
exit;
end else if (GetCurrentState(wpn)<>EHudStates__eIdle) then begin
exit;
end;
end;
// log('Check');
slot:=game_ini_r_int_def(animator_item_section, 'slot', 0)+1;
if ItemInSlot(act, slot)<>nil then begin
exit;
end;
wpn:= pointer(cardinal(act)-$e8); //ïñåâäîîðóæèå :)
// log('spawn');
CALifeSimulator__spawn_item2(animator_item_section, GetPosition(wpn), GetLevelVertexID(wpn), GetGameVertexID(wpn), GetID(wpn));
if GetActorActiveSlot()<>0 then begin
//õàê - òàê êàê ïåðâîå íå ìîæåò àêòèâèðîâàòü ñëîò, â êîòîðîì íè÷åãî íåò, à âòîðîå êîñÿ÷íî ñêðûâàåò ïðåäìåò ñ äåòåêòîðîì
//åñëè æå â ðóêàõ íè÷åãî íåò - àêòèâàöèÿ ñëîòà èäåò àâòîìàòîì
ActivateActorSlot__CInventory(0, false);
ActivateActorSlot(slot);
end;
_action_animator_callback:=callback;
_action_animator_param:=callback_param;
_action_animator_autoshow:=true;
result:=true;
end else begin
buf:=GetBuffer(wpn);
if (buf<>nil) then begin
//ïðîñòî çàïóñêàåì àíèìó ÷åðåç áóôåð
res:=Weapon_SetKeyRepeatFlagIfNeeded(wpn, key_repeat);
if res and WeaponAdditionalBuffer.PlayCustomAnimStatic(wpn, anm_name, snd_label) then begin
curanm:=GetActualCurrentAnim(wpn);
StartCompanionAnimIfNeeded(rightstr(curanm, length(curanm)-4), wpn, false);
MakeLockByConfigParam(wpn, GetHUDSection(wpn), PChar('lock_time_start_'+curanm), false, callback, callback_param);
_action_animator_callback:=nil;
_action_animator_param:=0;
_action_animator_autoshow:=false;
result:=true;
end;
end else begin
//SetPending(true) è âûçîâ àíèìàöèè, çàòåì â OnAnimationEnd SetPending(false)
if not IsPending(wpn) and (GetCurrentState(wpn)=EHudStates__eIdle) then begin
if GetActorActionState(act, actSprint, mstate_REAL) or GetActorActionState(act, actModDetectorSprintStarted, mstate_REAL) or GetActorActionState(act, actModSprintStarted, mstate_REAL) then begin
SetActorActionState(act, actModSprintStarted, false);
SetActorActionState(act, actModSprintStarted, false, mState_WISHFUL);
// result:=false;
// exit;
end;
StartPending(wpn);
PlayHudAnim(wpn, anm_name, true);
CHudItem_Play_Snd(wpn, snd_label);
StartCompanionAnimIfNeeded(rightstr(anm_name, length(anm_name)-4), wpn, false);
_action_animator_callback:=callback;
_action_animator_param:=callback_param;
_action_animator_autoshow:=false;
result:=true;
end;
end;
end;
end;
//Action-animator callbacks-----------------------------------------------------------------------------------------
procedure HeadlampCallback(wpn:pointer; param:integer); stdcall;
var
CTorch:pointer;
act:pointer;
buf:WpnBuf;
begin
act:=GetActor();
if act=nil then exit;
CTorch:=ItemInSlot(act, TORCH_SLOT);
if CTorch=nil then exit;
CTorch__Switch(CTorch, param>0);
// log ('headlamp: '+booltostr(param>0, true));
if wpn=nil then exit;
buf:=GetBuffer(wpn);
if (buf<>nil) then MakeLockByConfigParam(wpn, GetHUDSection(wpn), PChar('lock_time_end_'+GetActualCurrentAnim(wpn)));
end;
procedure NVCallback(wpn:pointer; param:integer); stdcall;
var
CTorch:pointer;
act:pointer;
buf:WpnBuf;
begin
act:=GetActor();
if act=nil then exit;
CTorch:=ItemInSlot(act, TORCH_SLOT);
if CTorch=nil then exit;
CTorch__SwitchNightVision(CTorch, param>0, true);
if wpn=nil then exit;
buf:=GetBuffer(wpn);
if (buf<>nil) then MakeLockByConfigParam(wpn, GetHUDSection(wpn), PChar('lock_time_end_'+GetActualCurrentAnim(wpn)));
end;
procedure KickCallback(wpn:pointer; param:integer); stdcall;
var
act:pointer;
buf:WpnBuf;
begin
act:=GetActor();
if act=nil then exit;
if wpn=nil then exit;
buf:=GetBuffer(wpn);
MakeWeaponKick(CRenderDevice__GetCamPos(), CRenderDevice__GetCamDir(), wpn);
if (buf<>nil) then MakeLockByConfigParam(wpn, GetHUDSection(wpn), PChar('lock_time_end_'+GetActualCurrentAnim(wpn)));
end;
procedure FakeCallback(wpn:pointer; param:integer); stdcall;
begin
end;
//-----------------------------------------------------------------------------------------------------------
procedure OnActorSwithesNV(itm:pointer); stdcall;
var
modifier:string;
wpn:pointer;
begin
if IsActorControlled() or not (CanUseNV(itm)) then exit;
wpn:=GetActorActiveItem();
if (wpn<>nil) and IsAimNow(wpn) then begin
if not game_ini_r_bool_def(GetHUDSection(wpn), 'can_use_nv_when_aim', false) then exit;
modifier:='_aim' ;
end else begin
modifier:='';
end;
if IsNVSwitchedOn(itm) then begin
OnActorSwithesSmth('disable_nv_anim', GetNVDisableAnimator(), PChar('anm_nv_off'+modifier), 'sndNVOff', kfNIGHTVISION, NVCallback, 0);
end else begin
OnActorSwithesSmth('disable_nv_anim', GetNVEnableAnimator(), PChar('anm_nv_on'+modifier), 'sndNVOn', kfNIGHTVISION, NVCallback, 1);
end;
end;
procedure OnActorSwithesTorch(itm:pointer); stdcall;
var
modifier:string;
wpn:pointer;
snd:string;
begin
if IsActorControlled() or not CanUseTorch(itm) then exit;
wpn:=GetActorActiveItem();
if (wpn<>nil) and IsAimNow(wpn) then begin
if not game_ini_r_bool_def(GetHUDSection(wpn), 'can_use_torch_when_aim', false) then exit;
modifier:='_aim' ;
end else begin
modifier:='';
end;
if IsTorchSwitchedOn(itm) then begin
OnActorSwithesSmth('disable_headlamp_anim', GetHeadlampDisableAnimator(), PChar('anm_headlamp_off'+modifier), 'sndHeadlampOff', kfHEADLAMP, HeadlampCallback, 0);
end else begin
OnActorSwithesSmth('disable_headlamp_anim', GetHeadlampEnableAnimator(), PChar('anm_headlamp_on'+modifier), 'sndHeadlampOn', kfHEADLAMP, HeadlampCallback, 1);
end;
end;