-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgunsl_config.pas
1801 lines (1443 loc) · 62.5 KB
/
gunsl_config.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 gunsl_config;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
uses MatVectors;
type weapon_inertion_params = record
pitch_offset_r:single;
pitch_offset_n:single;
pitch_offset_d:single;
origin_offset:single;
speed:single;
end;
type landing_params = record
offset_landing:single;
offset_landing2:single;
time_landing:cardinal;
time_landing2:cardinal;
cam_speed_factor:single;
cam_speed_factor2:single;
pow_factor:single;
pow_factor2:single;
time_finish_landing:cardinal;
pow_finish_landing_factor:single;
cam_speed_finish_landing_factor:single;
end;
type jitter_params = record
pos_amplitude:single;
rot_amplitude:single;
end;
type lookout_params = record
speed:single;
ampl_k:single;
dx_pow:single;
end;
type phantoms_params = record
min_cnt:cardinal;
max_cnt:cardinal;
min_radius:single;
max_radius:single;
end;
type actor_tiredness_params = record
min_tiredness:single;
base_speed_idle:single;
base_speed_idle_aim:single;
base_speed_idle_moving:single;
base_speed_idle_slow:single;
base_speed_idle_crouch:single;
base_speed_idle_crouch_slow:single;
base_speed_idle_aim_moving:single;
base_speed_idle_slow_moving:single;
base_speed_idle_crouch_moving:single;
base_speed_idle_crouch_slow_moving:single;
max_speed_idle:single;
max_speed_idle_aim:single;
max_speed_idle_moving:single;
max_speed_idle_slow:single;
max_speed_idle_crouch:single;
max_speed_idle_crouch_slow:single;
max_speed_idle_aim_moving:single;
max_speed_idle_slow_moving:single;
max_speed_idle_crouch_moving:single;
max_speed_idle_crouch_slow_moving:single;
increment_per_second:single;
decrement_per_second:single;
end;
type controller_feel_params = record
min_dist:single;
max_dist:single;
end;
type controller_psiunblock_params = record
min_dist:single;
min_dist_prob:single;
max_dist:single;
max_dist_prob:single;
end;
type controller_mouse_control_params = record
min_sense_scale:single;
max_sense_scale:single;
min_offset:integer;
max_offset:integer;
keyboard_move_k:single;
end;
type burer_superstamina_hit_params = record
distance:single;
stamina_decrease:single;
minimal_stamina:single;
minimal_stamina_health:single;
power:single;
impulse:single;
hit_type:cardinal;
force_hide_items_prob:single;
condition_dec_min:single;
condition_dec_max:single;
end;
type burer_fly_params = record
enabled:boolean;
max_dist:single;
critical_dist:single;
preferred_dist:single;
preferred_height:single;
impulse:single;
cooldown_period:cardinal;
visibility_period:cardinal;
max_time:cardinal;
vertical_accel:single;
end;
type burer_teleweapon_params = record
impulse:single;
allowed_angle:single;
min_shoot_time:integer;
max_shoot_time:integer;
shot_probability:single;
end;
type weapon_physics_damage_params = packed record
treshold:single;
speed:single;
end;
type monster_item_drop_params = packed record
min_condition_decrease:single;
max_condition_decrease:single;
stamina_hit_k:single;
unconditional_weapon_drop_dist:single;
mouse_x_min:single;
mouse_x_max:single;
mouse_y_min:single;
mouse_y_max:single;
end;
type giant_threaten_params = record
item_drop:monster_item_drop_params;
low_delay_height_delta:single;
low_delay_distance:single;
low_delay_time:cardinal;
std_to_low_delay_time:cardinal;
end;
type bobbing_effector_param = packed record
amplitude:single;
speed:single;
end;
type bobbing_effector_params = packed record
sprint:bobbing_effector_param;
zoom_limp:bobbing_effector_param;
limp:bobbing_effector_param;
zoom_slow_crouch:bobbing_effector_param;
slow_crouch:bobbing_effector_param;
zoom_crouch:bobbing_effector_param;
crouch:bobbing_effector_param;
zoom_walk:bobbing_effector_param;
walk:bobbing_effector_param;
zoom_run:bobbing_effector_param;
run:bobbing_effector_param;
amplitude_delta:single;
end;
function Init:boolean;
const
gd_novice:cardinal=0;
gd_stalker:cardinal=1;
gd_veteran:cardinal=2;
gd_master:cardinal=3;
GUNSL_BASE_SECTION:PChar='gunslinger_base';
GUNSL_BONE_OVERRIDES_SECTION='gunslinger_visual_bone_mass_overrides';
//------------------------------Îáùèå ôóíêöèè ðàáîòû ñ èãðîâûìè êîíôèãàìè---------------------------------
function game_ini_read_string_by_object_string(section:pointer; key:PChar):PChar;stdcall;
function game_ini_read_string(section:PChar; key:PChar):PChar;stdcall;
function game_ini_read_string_def(section:PChar; key:PChar; def:PChar):PChar;stdcall;
function game_ini_read_vector3_def(section:PChar; key:PChar; def:pfvector3):FVector3;stdcall;
function game_ini_line_exist(section:PChar; key:PChar):boolean;stdcall;
function game_ini_r_single_def(section:PChar; key:PChar; def:single; is_default:pboolean=nil):single;stdcall;
function game_ini_r_single(section:PChar; key:PChar):single;stdcall;
function game_ini_r_bool(section:PChar; key:PChar):boolean;stdcall;
function game_ini_r_bool_def(section:PChar; key:PChar; def:boolean; is_default:pboolean=nil):boolean;stdcall;
function game_ini_r_int_def(section:PChar; key:PChar; def:integer; is_default:pboolean=nil):integer; stdcall;
function game_ini_r_line(section:PChar; idx:integer; n:PPAnsiChar; v:PPAnsiChar):boolean;stdcall;
function translate(text:PChar):PChar;stdcall;
type cached_cfg_param_float = packed record
last_section:string;
value:single;
is_default:boolean;
end;
function GetCachedCfgParamFloatDef(var cached:cached_cfg_param_float; section:string; key:string; def:single):single;
type cached_cfg_param_bool = packed record
last_section:string;
value:boolean;
is_default:boolean;
end;
function GetCachedCfgParamBoolDef(var cached:cached_cfg_param_bool; section:string; key:string; def:boolean):boolean;
//---------------------------ñïåöèôè÷åñêèå ôóíêöèè êîíôèãóðàöèè ãàíñà--------------------------------------
function IsSprintOnHoldEnabled():boolean; stdcall;
function IsDebug():boolean; stdcall;
function GetBaseFOV():single; stdcall;
function GetBaseHudFOV():single; stdcall;
function GetCurrentDifficulty():cardinal; stdcall;
function GetDefaultActionDOF():FVector3; stdcall;
function GetDefaultZoomDOF():FVector3; stdcall;
function IsDynamicDOF():boolean; stdcall;
function GetDefaultDOFSpeed():single; stdcall;
function GetDefaultDOFSpeed_In():single; stdcall;
function GetDefaultDOFSpeed_Out():single; stdcall;
function GetDefaultDOFTimeOffset():single;
function IsConstZoomDOF():boolean; stdcall;
function IsDofEnabled():boolean; stdcall;
function IsLaserdotCorrection():boolean; stdcall;
function IsNPCLasers():boolean; stdcall;
function IsRealBallistics():boolean; stdcall;
function IsWeaponmoveEnabled():boolean; stdcall;
function IsCollimAimEnabled():boolean; stdcall;
function GetStdInertion(aim:boolean):weapon_inertion_params;
function GetCamSpeedDef():single;
function GetCamSpeedPow():single;
function GetCamLandingParams():landing_params;
function GetControllerTime():cardinal; stdcall;
function GetControllerPrepareTime():cardinal; stdcall;
function GetControllerBlockedTime():cardinal; stdcall;
function GetShockTime():cardinal; stdcall;
function GetMaxJitterHealth():single; stdcall;
function GetControllerFeelParams():controller_feel_params; stdcall;
function GetControllerQueueStopProb():single; stdcall;
function GetControllerPsiUnblockProb():controller_psiunblock_params; stdcall;
function GetControllerMouseControlParams():controller_mouse_control_params; stdcall;
function GetControlledActorSpeedKoef():single; stdcall;
function GetBaseJitterParams():jitter_params; stdcall;
function GetCurJitterParams(hud_sect:PChar):jitter_params; stdcall;
function GetControllerPhantomsParams():phantoms_params; stdcall;
function GetMaxCorpseWeight():single; stdcall;
function IsCorpseCollisionEnabled():boolean; stdcall;
function GetActorMaxBreathHealth():single; stdcall;
function GetActorBreathHealthSndDelta():single; stdcall;
function GetHeadlampEnableAnimator():PChar;
function GetHeadlampDisableAnimator():PChar;
function GetNVEnableAnimator():PChar;
function GetNVDisableAnimator():PChar;
function GetBurnAnimator():PChar;
function GetKickAnimator():PChar;
function GetPDAShowAnimator():PChar;
function GetPDAScreen_kx():single; stdcall;
function GetPDAUpdatePeriod():cardinal; stdcall;
function IsFastPdaZoom():boolean; stdcall;
function IsSavePdaZoomState():boolean; stdcall;
function IsAlterZoomClickSwitchScheme():boolean; stdcall;
function GetInventoryShowAnimator():PChar;
function GetLensRenderFactor():cardinal; stdcall;
function IsLensEnabled():boolean;
function IsForcedLens:boolean; stdcall;
function IsSndUnlock:boolean; stdcall;
function IsDynamicUpdrate():boolean; stdcall;
function GetModVer():PChar; stdcall;
function GetSaveVer():PChar; stdcall;
function GetAddonName():PChar; stdcall;
function GetQuickUseScriptFunctorName():PChar; stdcall;
function GetNvMaskUpdateFunctorName():PChar; stdcall;
function IsAnimatedAddons():boolean; stdcall;
function IsMandatoryAnimatedUnloadMag():boolean; stdcall;
function IsVSyncEnabled():boolean; stdcall;
function IsSoundPatchNeeded():boolean; stdcall;
function GetBaseLookoutParams():lookout_params; stdcall;
function GetWeaponTorchTreasureDist():single; stdcall;
function GetHeadlampTreasureDist():single; stdcall;
function GetLefthandedTorchTreasureDist():single; stdcall;
function GetLightPalevoDist():single; stdcall;
function GetLightSeeDist():single; stdcall;
function GetBurerSuperstaminaHitParams():burer_superstamina_hit_params;
function GetBurerForceantiaimDist():single; stdcall;
function GetBurerForceshieldDist():single; stdcall;
function GetBurerShieldedRiskyFactor():single; stdcall;
function GetBurerMinGrenTimer():cardinal; stdcall;
function GetBurerCriticalGrenTimer():cardinal; stdcall;
function GetBurerTeleweaponShotParams():burer_teleweapon_params; stdcall;
function GetBurerForceTeleFireMinDelta():cardinal; stdcall;
function GetWeaponPhysicsDamageParams():weapon_physics_damage_params;
function GetBoneNameForBurerTeleFire():PAnsiChar; stdcall;
function GetBurerGraviImpulseForActor():single; stdcall;
function GetBurerFlyParams():burer_fly_params;
function GetSkipFireAllProbability():single; stdcall;
function GetBurerAimShieldDelay():cardinal; stdcall;
function GetBurerSelfKickWindowTime():integer; stdcall;
function IsBurerKnifeSelfKick():boolean; stdcall;
function GetOverriddenBoneMassForVisual(visual:PAnsiChar; def:single):single; stdcall;
function GetHudSoundVolume():single;
function GetUpgradeMenuPointOffsetX(need_16x9:boolean):integer;
function GetBoarHitParams():monster_item_drop_params;
function GetPseudogiantHitParams():monster_item_drop_params;
function GetPseudogiantThreatenParams():giant_threaten_params;
function GetActorFallHitKoef():single;
function GetActorBurnRestoreSpeed():single;
function GetMaterialBurnRestoreSpeed(material:string):single;
function GetBobbingEffectorParams():bobbing_effector_params;
function IsShadersCacheNeeded():boolean;
var
g_pickup_distance:single;
implementation
uses BaseGameData, sysutils, ConsoleUtils, ActorUtils, DetectorUtils, math, uiutils, xr_strings, fs;
var
std_inertion:weapon_inertion_params;
aim_inertion:weapon_inertion_params;
fov:single;
hud_fov:single;
def_zoom_dof:FVector3;
def_act_dof:FVector3;
dof_def_speed:single;
dof_def_speed_in:single;
dof_def_speed_out:single;
dof_def_timeoffset:single;
_weaponmove_enabled:boolean;
_collimaim_enabled:boolean;
_controller_time:cardinal;
_controller_prepare_time:cardinal;
_controller_blocked_time:cardinal;
_controller_queue_stop_prob:single;
_controller_psiunblock_params:controller_psiunblock_params;
_controller_phantoms:phantoms_params;
_controller_feel:controller_feel_params;
_controller_mouse_control_params:controller_mouse_control_params;
_actor_shocked_time:cardinal;
_max_corpse_weight:single;
_enable_corpse_collision:boolean;
_controlled_actor_speed_koef:single;
_max_jitter_health:single;
_actor_max_breath_health:single;
_actor_breath_health_snddelta:single;
_headlamp_enable_animator_section:PChar;
_nv_enable_animator_section:PChar;
_headlamp_disable_animator_section:PChar;
_nv_disable_animator_section:PChar;
_burn_animator_section:PChar;
_kick_animator:PChar;
_pda_show_animator:PChar;
_inventory_show_animator:PChar;
_quickuse_functor:PChar;
_nv_mask_update_functor:PChar;
_is_animated_addons:boolean;
_is_mandatory_animated_unload_mag:boolean;
_std_tiredness_params:actor_tiredness_params;
_mod_ver:PChar;
_save_ver:PChar;
_addon_name:PChar;
psDeviceFlags:pointer;
g_upgrades_log:pointer;
_pda_screen_kx:single;
_pda_update_period:cardinal;
_lookout_params:lookout_params;
_weapon_torch_treasure_dist:single;
_headlamp_treasure_dist:single;
_lefthanded_torch_treasure_dist:single;
_light_palevo_dist:single;
_light_see_dist:single;
_burer_forceantiaim_dist:single;
_burer_forceshield_dist:single;
_burer_shielded_risky_factor:single;
_burer_min_gren_timer:cardinal;
_burer_critical_gren_timer:cardinal;
_burer_forcetelefire_min_delta:cardinal;
_burer_gravi_impulse_for_actor:single;
_burer_fly_params:burer_fly_params;
_burer_skipfireall_prob:single;
_burer_aim_shield_delay_const:cardinal;
_burer_aim_shield_delay_random:cardinal;
_burer_selfkick_window_time:integer;
_burer_superstaminahit_params:burer_superstamina_hit_params;
_burer_teleweapon_params:burer_teleweapon_params;
_weapon_physics_damage_params:weapon_physics_damage_params;
_upgrade_menu_points_offset_x:integer;
_upgrade_menu_points_offset_x_16x9:integer;
_boar_hit_params:monster_item_drop_params;
_pseudogiant_hit_params:monster_item_drop_params;
_pseudogiant_threaten_params:giant_threaten_params;
_actor_fall_hit_koef:single;
_actor_burn_restore_speed:single;
_bobbing_effector_params:bobbing_effector_params;
_burn_restore_materials:string;
_burn_restore_material_speed:single;
//äàííûå êîíñîëüíûõ êîìàíä
//áóëåâñêèå ôëàãè
_console_bool_flags:cardinal;
_max_actor_cam_speed:single;
_actor_cam_pow:single;
_cam_landing:landing_params;
_jitter:jitter_params;
_lens_render_factor:cardinal;
_lens_enabled:boolean;
_hud_sound_volume:single;
//Ñàìè êîíñîëüíûå êîìàíäû
CCC_dyndof:CCC_Mask;
CCC_constzoomdof:CCC_Mask;
CCC_laserdotdistcorrection:CCC_Mask;
CCC_npclasers:CCC_Mask;
CCC_realballistics:CCC_Mask;
CCC_lens_render_factor:CCC_Integer;
CCC_lens_enabled:CCC_Mask;
CCC_force_lense:CCC_Mask;
CCC_unlock_snd:CCC_Mask;
CCC_dynamic_updrate:CCC_Mask;
//âûðåçàííûå äâèæêîâûå êîíñîëüíûå êîìàíäû
CCC_mt_sound:CCC_Mask;
CCC_mt_physics:CCC_Mask;
CCC_mt_network:CCC_Mask;
CCC_rs_wireframe:CCC_Mask;
CCC_rs_clear_bb:CCC_Mask;
CCC_rs_occlusion:CCC_Mask;
CCC_rs_detail:CCC_Mask;
CCC_rs_render_statics:CCC_Mask;
CCC_rs_render_dynamics:CCC_Mask;
CCC_rs_occ_draw:CCC_Mask;
CCC_rs_occ_stats:CCC_Mask;
CCC_rs_disable_objects_as_crows:CCC_Mask;
CCC_fov:CCC_Float;
CCC_snd_hud_volume:CCC_Float;
CCC_upgrades_log:CCC_Integer;
CCC_pdaautozoom:CCC_Mask;
CCC_savezoomstate:CCC_Mask;
CCC_alterzoomclickswitch:CCC_Mask;
_shader_cache_needed:boolean;
//ìàñêè äëÿ ôëàãîâ
const
_mask_dyndof:cardinal=$1;
_mask_constzoomdof:cardinal=$2;
_mask_laserdotcorrection:cardinal=$4;
_mask_npclasers:cardinal=$8;
_mask_realballistics:cardinal=$10;
_mask_forcelense:cardinal=$20;
_mask_unlocksnd:cardinal=$40;
_mask_lens_enabled:cardinal=$80;
_mask_dynupdrate:cardinal=$100;
_mask_pdaautozoom:cardinal=$200;
_mask_pdasavezoomstate:cardinal=$400;
_mask_alterzoomclickswitch:cardinal=$800;
//--------------------------------------------------Îáùèå âåùè---------------------------------------------------
function GetGameIni():pointer;stdcall;
begin
asm
mov eax, xrgame_addr
mov eax, [eax+$5127E8]
mov eax, [eax]
mov @result, eax
end;
end;
function game_ini_line_exist(section:PChar; key:PChar):boolean;stdcall;
asm
pushad
pushfd
push key
push section
call GetGameIni
mov ecx, eax
mov eax, xrCore_addr
add eax, $182D0
call eax
mov @result, al
popfd
popad
end;
function game_ini_r_bool_int(section:PChar; key:PChar):boolean;stdcall;
asm
pushad
pushfd
push key
push section
call GetGameIni
mov ecx, eax
mov eax, xrCore_addr
add eax, $18970
call eax
mov @result, al
popfd
popad
end;
function game_ini_r_bool(section:PChar; key:PChar):boolean;stdcall;
begin
{$ifdef LOG_RAW_CONFIG_ACCESS}
Log('game_ini_r_bool: ' + key + ', ' + section);
{$endif}
result:=game_ini_r_bool_int(section, key);
end;
function game_ini_read_string_int(section:PChar; key:PChar):PChar;stdcall;
asm
pushad
pushfd
push key
push section
call GetGameIni
mov ecx, eax
mov eax, xrCore_addr
add eax, $18530
call eax
mov @result, eax
popfd
popad
end;
function game_ini_read_string(section:PChar; key:PChar):PChar;stdcall;
begin
{$ifdef LOG_RAW_CONFIG_ACCESS}
Log('game_ini_read_string: ' + key + ', ' + section);
{$endif}
result:=game_ini_read_string_int(section, key);
end;
function game_ini_read_string_def(section:PChar; key:PChar; def:PChar):PChar;stdcall;
begin
result:=def;
if game_ini_line_exist(section, key) then begin
result:=game_ini_read_string(section, key);
end;
end;
function game_ini_read_string_by_object_string(section:pointer; key:PChar):PChar;stdcall;
asm
pushad
pushfd
push key
push section
call GetGameIni
mov ecx, eax
mov eax, xrCore_addr
add eax, $2BE0
call eax
mov @result, eax
popfd
popad
end;
function game_ini_r_bool_def(section:PChar; key:PChar; def:boolean; is_default:pboolean):boolean;stdcall;
begin
if game_ini_line_exist(section, key) then begin
result:=game_ini_r_bool(section, key);
if is_default<>nil then is_default^:=false;
end else begin
result:=def;
if is_default<>nil then is_default^:=true;
end;
end;
function game_ini_r_int_def(section:PChar; key:PChar; def:integer; is_default:pboolean):integer; stdcall;
begin
if game_ini_line_exist(section, key) then begin
result:=strtointdef(game_ini_read_string(section, key), def);
if is_default<>nil then is_default^:=false;
end else begin
result:=def;
if is_default<>nil then is_default^:=true;
end;
end;
function game_ini_r_single(section:PChar; key:PChar):single;stdcall;
begin
result:= strtofloatdef(game_ini_read_string(section, key),0);
end;
function game_ini_r_single_def(section:PChar; key:PChar; def:single; is_default:pboolean):single; stdcall;
begin
if game_ini_line_exist(section, key) then begin
result:=game_ini_r_single(section, key);
if is_default<>nil then is_default^:=false;
end else begin
result:=def;
if is_default<>nil then is_default^:=true;
end;
end;
function game_ini_read_vector3_def(section:PChar; key:PChar; def:pfvector3):FVector3;stdcall;
var
tmp, coord:string;
begin
if game_ini_line_exist(section, key) then begin
tmp:=game_ini_read_string(section, key);
GetNextSubStr(tmp, coord, ',');
result.x:=strtofloatdef(coord, 0);
GetNextSubStr(tmp, coord, ',');
result.y:=strtofloatdef(coord, 0);
GetNextSubStr(tmp, coord, ',');
result.z:=strtofloatdef(coord, 0);
end else
result:=def^;
end;
function game_ini_r_line(section:PChar; idx:integer; n:PPAnsiChar; v:PPAnsiChar):boolean;stdcall;
asm
pushad
pushfd
push v
push n
push idx
push section
call GetGameIni
mov ecx, eax
mov eax, xrCore_addr
add eax, $18A40
call eax
mov @result, al
popfd
popad
end;
function translate(text:PChar):PChar;stdcall;
asm
pushad
mov eax, xrgame_addr
add eax, $23d4f0
push text
call eax
mov @result, eax
add esp, 4
popad
end;
function GetCachedCfgParamFloatDef(var cached:cached_cfg_param_float; section:string; key:string; def:single):single;
begin
if (length(cached.last_section)=length(section)) and (cached.last_section = section) then begin
if cached.is_default then begin
result:=def;
end else begin
result:=cached.value;
end;
end else begin
result:=game_ini_r_single_def(PAnsiChar(section), PAnsiChar(key), def, @cached.is_default);
cached.last_section:=section;
cached.value:=result;
end;
end;
function GetCachedCfgParamBoolDef(var cached:cached_cfg_param_bool; section:string; key:string; def:boolean):boolean;
begin
if (length(cached.last_section)=length(section)) and (cached.last_section = section) then begin
if cached.is_default then begin
result:=def;
end else begin
result:=cached.value;
end;
end else begin
result:=game_ini_r_bool_def(PAnsiChar(section), PAnsiChar(key), def, @cached.is_default);
cached.last_section:=section;
cached.value:=result;
end;
end;
//--------------------------------------------------Ãàíñ---------------------------------------------------------
function IsSprintOnHoldEnabled():boolean; stdcall;
begin
result:=true;
end;
function IsDebug():boolean; stdcall;
begin
result:=true;
end;
function GetBaseFOV():single; stdcall;
begin
result:=fov;
end;
function GetBaseHudFOV():single; stdcall;
begin
result:=hud_fov;
end;
function GetCurrentDifficulty():cardinal; stdcall;
begin
asm
mov eax, xrgame_addr
mov eax, [eax+$63bc54]
mov @result, eax
end;
end;
function IsDynamicDOF():boolean; stdcall;
begin
result:=IsDofEnabled() and ((_console_bool_flags and _mask_dyndof)>0);
end;
function IsConstZoomDOF():boolean; stdcall;
begin
result:=((_console_bool_flags and _mask_constzoomdof)>0);
end;
function IsLaserdotCorrection():boolean; stdcall;
begin
result:=((_console_bool_flags and _mask_laserdotcorrection)>0);
end;
function IsSoundPatchNeeded():boolean; stdcall;
begin
result:=game_ini_r_bool_def(GUNSL_BASE_SECTION, 'patch_weapon_sounds', true);
end;
function IsNPCLasers():boolean; stdcall;
begin
result:=((_console_bool_flags and _mask_npclasers)>0);
end;
function IsRealBallistics():boolean; stdcall;
begin
result:=((_console_bool_flags and _mask_realballistics)>0);
end;
function GetDefaultActionDOF():FVector3; stdcall;
begin
result:=def_act_dof;
end;
function GetDefaultZoomDOF():FVector3; stdcall;
begin
result:=def_zoom_dof;
end;
function GetDefaultDOFSpeed():single; stdcall;
begin
result:=dof_def_speed;
end;
function GetDefaultDOFSpeed_In():single; stdcall;
begin
result:=dof_def_speed_in;
end;
function GetDefaultDOFSpeed_Out():single; stdcall;
begin
result:=dof_def_speed_out;
end;
function GetDefaultDOFTimeOffset():single;
begin
result:=dof_def_timeoffset;
end;
function IsDofEnabled():boolean; stdcall;
var
addr:cardinal;
val:cardinal;
const
r2_dof_enable:cardinal = $800000;
begin
if xrRender_R1_addr>0 then
addr:=xrRender_R1_addr+$A4728
else if xrRender_R2_addr>0 then
addr:=xrRender_R2_addr+$CB9C8
else if xrRender_R3_addr>0 then
addr:=xrRender_R3_addr+$E7C4C
else if xrRender_R4_addr>0 then
addr:=xrRender_R4_addr+$F4C54;
asm
mov eax, addr
mov eax, [eax]
mov val, eax
end;
result:=((val and r2_dof_enable)>0);
end;
procedure InjectReaderToSystemIni(r:pIReader; path:PAnsiChar);stdcall;
asm
pushad
mov eax, xrcore_addr
mov ecx, [eax+$be91c] // xrCore.pSettings
lea ebx, [eax+$171f0]
push 0
push 0
push path
push r
call ebx
popad
end;
function IterateInjectionsFiles():boolean;
var
path:string_path;
fname:string;
flist:FileList;
i, cnt:cardinal;
r:pIReader;
begin
result:=false;
fs_update_path(path, '$game_config$', 'injections\system\');
fs_file_list_open(@flist, path, FS_ListFiles+FS_RootOnly);
cnt:=fs_file_list_count(@flist);
log('Config injections count = '+inttostr(cnt));
if cnt > 0 then begin
for i:=0 to cnt-1 do begin
fname:=fs_file_list_get_item(@flist, i);
log('Injecting config file '+fname);
fname:=path+fname;
fs_r_open(@r, PAnsiChar(fname));
if r <> nil then begin
InjectReaderToSystemIni(r, path);
fs_r_close(@r);
end;
end;
end;
fs_file_list_close(@flist);
result:=true;
end;
function EnableConfigsInjections():boolean;
begin
result:=false;
//1. Let's disable 'Duplicate section' asserts in CInifile::Load
if not nop_code(xrCore_addr+$175c2, 1, chr($eb)) then exit;
if not nop_code(xrCore_addr+$17e5f, 1, chr($eb)) then exit;
//2. Iterate all injections configs
if not IterateInjectionsFiles() then exit;
//3. Enable disabled asserts
if not nop_code(xrCore_addr+$175c2, 1, chr($74)) then exit;
if not nop_code(xrCore_addr+$17e5f, 1, chr($74)) then exit;
result:=true;
end;
function FixConsoleCommandsValues():boolean;
var
i, cnt:integer;
param, val:PAnsiChar;
fix_result:ConsoleCommandFixResult;
const
FIX_SECTION:PAnsiChar = 'gunslinger_fixed_commands';
begin
result:=false;
i:=0;
cnt:=0;
while game_ini_r_line(FIX_SECTION, i, @param, @val) do begin
fix_result:=FixConsoleCommandValue(param, val);
if fix_result<>CONSOLE_FIX_RESULT_SUCCESS then begin
Log('Can''t fix "'+param+'" to "'+val+'" - '+ConsoleCommandFixResultToString(fix_result), true);
end else begin
cnt:=cnt+1;
end;
i:=i+1;
end;
Log('Fixed commands count: '+inttostr(cnt));
result:=true;
end;
function ReadBobbingEffectorParams():boolean;
const
SECT:PChar='bobbing_effector';
begin
result:=false;
_bobbing_effector_params.sprint.amplitude:=game_ini_r_single_def(SECT, 'sprint_amplitude', 0);
_bobbing_effector_params.sprint.speed:=game_ini_r_single_def(SECT, 'sprint_speed', 0);
_bobbing_effector_params.zoom_limp.amplitude:=game_ini_r_single_def(SECT, 'zoom_limp_amplitude', 0);
_bobbing_effector_params.zoom_limp.speed:=game_ini_r_single_def(SECT, 'zoom_limp_speed', 0);
_bobbing_effector_params.limp.amplitude:=game_ini_r_single_def(SECT, 'limp_amplitude', 0);
_bobbing_effector_params.limp.speed:=game_ini_r_single_def(SECT, 'limp_speed', 0);
_bobbing_effector_params.zoom_slow_crouch.amplitude:=game_ini_r_single_def(SECT, 'zoom_slow_crouch_amplitude', 0);
_bobbing_effector_params.zoom_slow_crouch.speed:=game_ini_r_single_def(SECT, 'zoom_slow_crouch_speed', 0);
_bobbing_effector_params.slow_crouch.amplitude:=game_ini_r_single_def(SECT, 'slow_crouch_amplitude', 0);
_bobbing_effector_params.slow_crouch.speed:=game_ini_r_single_def(SECT, 'slow_crouch_speed', 0);
_bobbing_effector_params.zoom_crouch.amplitude:=game_ini_r_single_def(SECT, 'zoom_crouch_amplitude', 0);
_bobbing_effector_params.zoom_crouch.speed:=game_ini_r_single_def(SECT, 'zoom_crouch_speed', 0);
_bobbing_effector_params.crouch.amplitude:=game_ini_r_single_def(SECT, 'crouch_amplitude', 0);