forked from gunslingermod/gunslinger_wpnpatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeaponUpdate.pas
1122 lines (964 loc) · 43.3 KB
/
WeaponUpdate.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 WeaponUpdate;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
function Init:boolean;
procedure ReassignWorldAnims(wpn:pointer); stdcall;
procedure CWeapon__ModUpdate(wpn:pointer); stdcall;
procedure ProcessAmmo(wpn: pointer; forced:boolean=false);
implementation
uses Messenger, BaseGameData, MatVectors, Misc, HudItemUtils, LightUtils, sysutils, WeaponAdditionalBuffer, WeaponEvents, ActorUtils, strutils, math, gunsl_config, ConsoleUtils, xr_BoneUtils, ActorDOF, dynamic_caster, RayPick, xr_ScriptParticles, xr_Cartridge, ControllerMonster, UIUtils, xr_RocketLauncher, KeyUtils;
function NeedUpdateBonesCheck(wpn:pointer):boolean;
var
buf:WpnBuf;
new_conds:upgrades_process_condition;
begin
result:=true;
buf:=GetBuffer(wpn);
if buf = nil then exit;
new_conds.force:=false;
new_conds.upgrades_count:=GetInstalledUpgradesCount(wpn);
new_conds.gl_attached:=IsGLAttached(wpn);
new_conds.gl_enabled:=IsGrenadeMode(wpn);
new_conds.silencer_attached:=IsSilencerAttached(wpn);
new_conds.scope_sect:=nil;
if IsScopeAttached(wpn) then begin
new_conds.scope_sect:=GetCurrentScopeSection(wpn);
end;
new_conds.ammo_type:=GetAmmoTypeIndex(wpn, false);
new_conds.ammo_count:=GetCurrentAmmoCount(wpn);
new_conds.firemode:=CurrentQueueSize(wpn);
new_conds.state:=GetCurrentState(wpn);
if buf.upgrades_procesing_conditions.force then begin
result:=true;
end else begin
result:= (new_conds.upgrades_count <> buf.upgrades_procesing_conditions.upgrades_count) or
(new_conds.gl_attached <> buf.upgrades_procesing_conditions.gl_attached) or
(new_conds.gl_enabled <> buf.upgrades_procesing_conditions.gl_enabled) or
(new_conds.silencer_attached <> buf.upgrades_procesing_conditions.silencer_attached) or
(new_conds.scope_sect <> buf.upgrades_procesing_conditions.scope_sect) or
(new_conds.ammo_type <> buf.upgrades_procesing_conditions.ammo_type) or
(new_conds.ammo_count <> buf.upgrades_procesing_conditions.ammo_count) or
(new_conds.firemode <> buf.upgrades_procesing_conditions.firemode) or
(new_conds.state <> buf.upgrades_procesing_conditions.state);
end;
if result then begin
buf.upgrades_procesing_conditions:=new_conds;
end;
end;
procedure ProcessLaserdot(wpn:pointer);
var
buf:WpnBuf;
laserdot_data:laserdot_params;
dotpos, dotdir, zerovec, viewdir, viewpos, tmp, bonedir:FVector3;
dist:single;
HID:pointer;
b:boolean;
time:cardinal;
lb:conditional_breaking_params;
probability, probability2:single;
max_problems_cnt:single;
begin
buf:=GetBuffer(wpn);
if not buf.IsLaserInstalled() then exit;
zerovec.x:=0;
zerovec.y:=0;
zerovec.z:=0;
laserdot_data:=buf.GetLaserDotData();
//åñëè â ñîáñòâåííîñòè ÍÏÑà è â êîíñîëè âûñòàâëåíî íå èñïîëüçîâàòü ëàçåð - îòêëþ÷èì
if (GetOwner(wpn)<>nil) and (GetOwner(wpn)<>GetActor()) and not IsNPCLasers()then begin
buf.SetLaserEnabledStatus(false);
end;
if buf.IsLaserEnabled() then begin
if not game_ini_r_bool_def(GetHUDSection(wpn), 'disable_laserdot_when_gl_enabled', false) then begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, true);
end else begin
//ïîäñòâîë ïðè ïðèöåëèâàíèè ìîæåò ïåðåêðûâàòü ËÖÓ - òîãäà âûêëþ÷àåì ïîñëåäíèé
if leftstr(GetActualCurrentAnim(wpn), length('anm_switch'))='anm_switch' then begin
if rightstr(GetActualCurrentAnim(wpn), 2)='_g' then
time:=GetTimeDeltaSafe(GetAnimTimeState(wpn, ANM_TIME_START), GetAnimTimeState(wpn, ANM_TIME_CUR))
else
time:=GetTimeDeltaSafe(GetAnimTimeState(wpn, ANM_TIME_CUR), GetAnimTimeState(wpn, ANM_TIME_END));
if time>game_ini_r_int_def(GetHUDSection(wpn), PChar('laser_switch_time_'+GetActualCurrentAnim(wpn)), 0) then begin
if game_ini_r_bool_def(GetHUDSection(wpn), 'disable_laserray_when_gl_enabled', false) then begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, false);
end;
buf.StopLaserdotParticle();
exit;
end else begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, true);
end;
end else if IsGrenadeMode(wpn) then begin
if game_ini_r_bool_def(GetHUDSection(wpn), 'disable_laserray_when_gl_enabled', false) then begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, false);
end else begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, true);
end;
buf.StopLaserdotParticle();
exit;
end else begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, true);
end;
end;
end else begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, false);
buf.StopLaserdotParticle();
exit;
end;
lb:=buf.GetLaserBreakingParams();
max_problems_cnt := buf.GetLaserProblemsLevel(); //óðîâåíü ïîìåõ, âûøå êîòîðîãî îòðóáèòñÿ ëàçåð
if GetCurrentCondition(wpn)<lb.end_condition then begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, false);
buf.StopLaserdotParticle();
exit;
end else if (GetCurrentCondition(wpn)<lb.start_condition) or ( (max_problems_cnt>0) and ( CurrentElectronicsProblemsCnt() >= max_problems_cnt) ) then begin
if ( TargetElectronicsProblemsCnt() >= max_problems_cnt ) then begin
probability:=1;
end else if (lb.start_condition = lb.end_condition) then begin
probability := lb.start_condition;
end else begin
probability := lb.start_probability+(lb.start_condition-GetCurrentCondition(wpn))* (1-lb.start_probability)/(lb.start_condition-lb.end_condition);
end;
if random<probability then begin
SetWeaponMultipleBonesStatus(wpn, laserdot_data.ray_bones, false);
buf.StopLaserdotParticle();
exit;
end;
end;
HID :=CHudItem__HudItemData(wpn);
if (HID<>nil) and (GetActorActiveItem()=wpn)then begin // and (not IsDemoRecord()) then begin
//1st person view
if (IsAimNow(wpn) or IsHolderInAimState(wpn)) and (not IsGrenadeMode(wpn)) then begin
//â ðåæèìå ïðèöåëèâàíèÿ ïðèâÿçûâàåìñÿ ê êàìåðå - èíà÷å ïðè íàñòðîéêå ïðèöåëèâàíèÿ ó îðóæèÿ áóäåì ïðîâîäèòü ïðÿìóþ ÷åðåç 3 òî÷êè :(
viewdir:=FVector3_copyfromengine(CRenderDevice__GetCamDir());
viewpos:=FVector3_copyfromengine(CRenderDevice__GetCamPos());
attachable_hud_item__GetBoneOffsetPosDir(HID, laserdot_data.bone_name, @dotpos, @dotdir, @laserdot_data.offset);
v_sub(@viewdir, @dotdir); //ñ÷èòàåì ðàçíîñòíûé âåêòîð íàïðàâëåíèÿ
v_mul(@viewdir, GetAimFactor(wpn)-1.0); //âåëè÷èíà äîáàâêè çàâèñèò îò òîãî, íàñêîëüêî ñèëüíî ìû âîøëè â ðåæèì ïðèöåëà
dotdir:=FVector3_copyfromengine(CRenderDevice__GetCamDir());
v_add(@dotdir, @viewdir);
v_normalize(@dotdir);
v_sub(@viewpos, @dotpos);
v_mul(@viewpos, GetAimFactor(wpn)-1.0);
dotpos:=FVector3_copyfromengine(CRenderDevice__GetCamPos());
v_add(@dotpos, @viewpos);
end else begin
attachable_hud_item__GetBoneOffsetPosDir(HID, laserdot_data.bone_name, @dotpos, @dotdir, @laserdot_data.offset);
bonedir:=dotdir;
//ïûòàåìñÿ ñêîððåêòèðîâàòü ðàçíîñòü ÔÎÂ õóäà è ìèðà
tmp:=FVector3_copyfromengine(CRenderDevice__GetCamDir());
CorrectDirFromWorldToHud(@dotdir, @dotpos, game_ini_r_single_def(GetHUDSection(wpn), 'hud_recalc_koef', 1.0));
end;
dist:=TraceAsView(@dotpos, @dotdir, dynamic_cast(GetActor(), 0, RTTI_CActor, RTTI_CObject, false))*0.99;
if laserdot_data.always_world then begin
b:=false;
end else if laserdot_data.always_hud then begin
b:=true;
end else begin
viewdir:=FVector3_copyfromengine(CRenderDevice__GetCamDir());
b:=(GetAngleCos(@viewdir, @dotdir)<laserdot_data.hud_treshold);
end;
if (not IsLaserdotCorrection()) then dist:=dist*0.85;
dotpos.x:=dotpos.x+dotdir.x*dist;
dotpos.y:=dotpos.y+dotdir.y*dist;
dotpos.z:=dotpos.z+dotdir.z*dist;
buf.PlayLaserdotParticle(@dotpos, dist, true, b);
buf.SetLaserDotParticleHudStatus(b);
end else if (GetOwner(wpn)=GetActor()) and (GetActorActiveItem()=wpn) then begin
viewpos:=laserdot_data.world_offset;
transform_tiny(GetXFORM(wpn), @dotpos, @viewpos);
dotdir:=GetLastFD(wpn);
dist:=TraceAsView(@dotpos, @dotdir, dynamic_cast(wpn, 0, RTTI_CWeapon, RTTI_CObject, false))*0.99;
dotpos.x:=dotpos.x+dotdir.x*dist;
dotpos.y:=dotpos.y+dotdir.y*dist;
dotpos.z:=dotpos.z+dotdir.z*dist;
buf.PlayLaserdotParticle(@dotpos, dist, false, false);
buf.SetLaserDotParticleHudStatus(false);
//messenger.SendMessage(PChar(inttohex(cardinal(wpn),8)));
end else begin
buf.StopLaserdotParticle();
end;
end;
function GetOrdinalAmmoType(wpn:pointer):byte; stdcall;
begin
if game_ini_r_bool_def(GetHUDSection(wpn), 'ammo_params_use_last_cartridge_type', false) and (GetAmmoInMagCount(wpn)>0) then begin
//åñëè óêàçàí ýòîò ïàðàìåòð, òî â îñòàëüíûõ ðåæèìàõ çà òèï ñåêöèè îòâå÷àåò òèï ïîñëåäíåãî ïàòðîíà
result:=GetCartridgeType(GetCartridgeFromMagVector(wpn, GetAmmoInMagCount(wpn)-1));
end else begin
result:=GetAmmoTypeIndex(wpn, IsGrenadeMode(wpn));
end;
end;
function GetGlAmmotype(wpn:pointer):byte; stdcall;
begin
result:=GetAmmoTypeIndex(wpn, not IsGrenadeMode(wpn));
end;
procedure ProcessAmmoAdv(wpn: pointer; forced:boolean=false);
var
hud_sect:PChar;
bones_sect:PChar;
bones:PChar;
cnt, ammotype:integer;
sect_w_ammotype:string;
g_b:boolean;
begin
hud_sect:=GetHUDSection(wpn);
g_b:=IsGrenadeMode(wpn);
if (not g_b) and (GetCurrentState(wpn)=cardinal(EWeaponStates__eFire)) and not forced and game_ini_r_bool_def(hud_sect, 'ammo_params_toggle_shooting', false) then begin
//âî âðåìÿ ñòðåëüáû íå ïðîèçâîäèòü îáíîâëåíèå êîñòåé - íóæíî äëÿ êîððåêòíûõ ãèëüç ó äðîáîâèêîâ
exit;
end;
cnt:=GetAmmoInMagCount(wpn);
if g_b then begin
//Îðóæèå â ðåæèìå ñòðåëüáû ïîäñòâîëîì
ammotype:=GetOrdinalAmmoType(wpn);
end else if (GetCurrentState(wpn)=cardinal(EWeaponStates__eReload)) then begin
if IsWeaponJammed(wpn) then begin
//èäåò ðàñêëèí
ammotype:=GetOrdinalAmmoType(wpn);
end else if IsTriStateReload(wpn) then begin
//èäåò ïåðåçàðÿäêà ïî òèïó äðîáîâèêà
ammotype:=GetAmmoTypeToReload(wpn);
cnt:=cnt+1;
end else begin
//èäåò îáû÷íàÿ ïåðåçàðÿäêà
//ïàòðîí â ïàòðîííèêå ìîæåò áûòü ñòàðîãî òèïà! ó÷èòûâàåì ýòî
//îáíîâëåíèå ñèíõðîííî ñî ñ÷åò÷èêîì
ammotype:=GetAmmoTypeIndex(wpn, g_b);
//Õàê äëÿ íåïðàâèëüíî çààíèìèðîâàííûõ ìîäåëåé âðîäå ñàéãè - ïðè îáû÷íûõ ðåëîàäàõ íàì ìîæåò ïîòðåáîâàòüñÿ îòîáðàæàòü â ìàãàçèíå íà îäèí ïàòðîí ÌÅÍÜØÅ
//÷åì â ðåàëüíîñòè - îíè íå ó÷èòûâàþò ïàòðîí â ïàòðîííèêå! Ïîýòîìó åñëè íà ñ÷åò÷èêå 1, è ìû æìåì ðåëîàä, â ìàãàçèíå áóäåò "ëèøíèé" ïàòðîí! Õîòÿ ìàãàçèí êàê ðàç äîëæåí áûòü ïóñò
if game_ini_r_bool_def(hud_sect, 'minus_ammo_in_usual_reloads', false) and (cnt >= 1) and (Pos('_empty', GetActualCurrentAnim(wpn))=0) then begin
cnt:=cnt-1;
end;
end
end else begin
//íå â ñîñòîÿíèè ïåðåçàðÿäêè, ïîäñòâîë âûêëþ÷åí
ammotype:=GetOrdinalAmmotype(wpn);
//Õàê äëÿ íåïðàâèëüíî çààíèìèðîâàííûõ ìîäåëåé, íå ó÷èòûâàþùèõ ïàòðîí â ïàòðîííèêå - íàì ìîæåò ïîòðåáîâàòüñÿ îòîáðàæàòü â ìàãàçèíå íà îäèí ïàòðîí ÌÅÍÜØÅ
if game_ini_r_bool_def(hud_sect, 'minus_ammo_in_bore', false) and (cnt >= 1) and (leftstr(GetActualCurrentAnim(wpn), length('anm_bore'))='anm_bore') then begin
cnt:=cnt-1;
end;
end;
bones_sect:=nil;
sect_w_ammotype:='ammo_params_section_'+inttostr(ammotype);
if game_ini_line_exist(hud_sect, PChar(sect_w_ammotype)) then begin
bones_sect:= game_ini_read_string(hud_sect, PChar(sect_w_ammotype));
end else if game_ini_line_exist(hud_sect, 'ammo_params_section') then begin
bones_sect:= game_ini_read_string(hud_sect, 'ammo_params_section');
end;
if bones_sect<>nil then begin
if (IsWeaponJammed(wpn) and game_ini_line_exist(bones_sect, 'additional_ammo_bone_when_jammed') and game_ini_r_bool(bones_sect, 'additional_ammo_bone_when_jammed')) then
cnt:=cnt+1;
//ñêðûâàåì âñå
bones:= game_ini_read_string(bones_sect, 'all_bones');
SetWeaponMultipleBonesStatus(wpn, bones, false);
//îòîáðàæàåì íóæíûå
if game_ini_line_exist(bones_sect, PChar('configuration_'+inttostr(cnt))) then begin
bones:= game_ini_read_string(bones_sect, PChar('configuration_'+inttostr(cnt)));
SetWeaponMultipleBonesStatus(wpn, bones, true);
end;
end;
end;
procedure ProcessAmmoGL(wpn: pointer; forced:boolean=false);
var
hud_sect, bones_sect, bones:PChar;
ammotype, cnt:integer;
sect_w_ammotype:string;
g_m:boolean;
begin
if (GetGLStatus(wpn)=0) then exit;
g_m:=IsGrenadeMode(wpn);
hud_sect:=GetHUDSection(wpn);
cnt:=GetAmmoInGLCount(wpn);
if g_m and (GetCurrentState(wpn)=cardinal(EWeaponStates__eReload)) then begin
if cnt = 0 then begin
//Òóò íóæíî èñïîëüçîâàòü èìåííî GetAmmoTypeToReload, à íå GetGlAmmoType, èíà÷å ïðè ñìåíå òèïà ãðàíàòû ïîñëå âûñòðåëà ñõåìà íå ïðîñå÷åò, ÷òî íóæíî èçìåíèòü ñêèí, è îòðèñóåò ãðåíó äðóãîãî òèïà
ammotype:=GetAmmoTypeToReload(wpn);
cnt:=1;
end else begin
//Î÷åâèäíî, ñìåíà òèïà - à â ñëó÷àå, êîãäà ãðàíàòà âûòàñêèâàåòñÿ âèçóàëüíî, â íà÷àëå ñìåíû òèïà íåîáõîäèìî ïîêàçûâàòü ñòàðûé òèï
ammotype:=GetGlAmmoType(wpn);
end;
end else begin
ammotype:=GetGlAmmoType(wpn);
end;
bones_sect:=nil;
sect_w_ammotype:='gl_ammo_params_section_'+inttostr(ammotype);
if game_ini_line_exist(hud_sect, PChar(sect_w_ammotype)) then begin
bones_sect:= game_ini_read_string(hud_sect, PChar(sect_w_ammotype));
end else if game_ini_line_exist(hud_sect, 'gl_ammo_params_section') then begin
bones_sect:= game_ini_read_string(hud_sect, 'gl_ammo_params_section');
end;
if bones_sect<>nil then begin
//ñêðûâàåì âñå
bones:= game_ini_read_string(bones_sect, 'all_bones');
SetWeaponMultipleBonesStatus(wpn, bones, false);
//îòîáðàæàåì íóæíûå
if game_ini_line_exist(bones_sect, PChar('configuration_'+inttostr(cnt))) then begin
bones:= game_ini_read_string(bones_sect, PChar('configuration_'+inttostr(cnt)));
SetWeaponMultipleBonesStatus(wpn, bones, true);
end;
end;
end;
procedure ProcessAmmo(wpn: pointer; forced:boolean=false);
var hud_sect:PChar;
prefix, prefix_hide, prefix_var:string;
i:integer;
start_index, finish_index, limitator:integer;
begin
hud_sect:=GetHUDSection(wpn);
if game_ini_r_bool_def(hud_sect, 'use_advanced_ammo_bones', false) then begin
ProcessAmmoAdv(wpn, forced);
exit;
end;
if not game_ini_r_bool_def(hud_sect, 'use_ammo_bones', false) then exit;
prefix:= game_ini_read_string(hud_sect, 'ammo_bones_prefix');
prefix_hide:=game_ini_read_string_def(hud_sect, 'ammo_hide_bones_prefix', '');
prefix_var:=game_ini_read_string_def(hud_sect, 'ammo_var_bones_prefix', '');
start_index:=game_ini_r_int_def(hud_sect, 'start_ammo_bone_index', 0);
limitator:=game_ini_r_int_def(hud_sect, 'end_ammo_bone_index', 0);
finish_index:=start_index+GetAmmoInMagCount(wpn)-1;
if IsWeaponJammed(wpn) and game_ini_line_exist(hud_sect, 'additional_ammo_bone_when_jammed') and game_ini_r_bool(hud_sect, 'additional_ammo_bone_when_jammed') then
finish_index:=finish_index+1;
if game_ini_line_exist(hud_sect, 'ammo_divisor_up') then
finish_index:=ceil(finish_index/game_ini_r_int_def(hud_sect, 'ammo_divisor_up', 1))
else if game_ini_line_exist(hud_sect, 'ammo_divisor_down') then
finish_index:=floor(finish_index/game_ini_r_int_def(hud_sect, 'ammo_divisor_down', 1));
if finish_index>limitator then finish_index:=limitator;
// if wpn=GetActorActiveItem() then SendMessage(PChar(inttostr(start_index)+' '+PChar(inttostr(finish_index))+' '+PChar(inttostr(limitator))));
for i:=start_index to finish_index do begin
SetWeaponModelBoneStatus(wpn, PChar(prefix+inttostr(i)), true);
if length(prefix_hide) > 0 then begin
SetWeaponModelBoneStatus(wpn, PChar(prefix_hide+inttostr(i)), false);
end;
end;
for i:= finish_index+1 to limitator do begin
SetWeaponModelBoneStatus(wpn, PChar(prefix+inttostr(i)), false);
if length(prefix_hide) > 0 then begin
SetWeaponModelBoneStatus(wpn, PChar(prefix_hide+inttostr(i)), true);
end;
end;
if (length(prefix_var) > 0) then begin
for i:= start_index-1 to limitator do begin
SetWeaponModelBoneStatus(wpn, PChar(prefix_var+inttostr(i)), i=finish_index);
end;
end;
end;
procedure HideOneUpgradeLevel(wpn:pointer; up_gr_section:pchar); stdcall;
var
up_sect:PChar;
up_group:string;
tmp:string;
all_subelements, element:string;
begin
all_subelements:=game_ini_read_string(up_gr_section, 'elements');
while (GetNextSubStr(all_subelements, element, ',')) do begin
//Îáðàáîòàåì âåòêè, êîòîðûå îòêðûâàåò äàííûé àïãðåéä
if game_ini_line_exist(PChar(element), 'effects') then begin
up_group:=game_ini_read_string(PChar(element), 'effects');
while (GetNextSubStr(up_group, tmp, ',')) do begin
HideOneUpgradeLevel(wpn, PChar(tmp));
end;
end;
//Òåïåðü ïîñìîòðèì, êàêèå êîñòè íàäî îòîáðàæàòü, êîãäà äàííûé àïãðåéä óñòàíîâëåí
up_sect:=game_ini_read_string(PChar(element), 'section');
if game_ini_line_exist(up_sect, 'show_bones') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(up_sect, 'show_bones'), false);
end;
end;
function GetFiremodeSuffix(wpn:pointer):string; stdcall;
var
firemode:integer;
begin
firemode:=CurrentQueueSize(wpn);
if firemode<0 then begin
result:='_a';
end else begin
result:='_'+inttostr(firemode);
end;
end;
procedure ProcessFiremode(wpn:pointer); stdcall;
var
hud_sect:PAnsiChar;
firemode_mark:string;
begin
hud_sect:=GetHUDSection(wpn);
if game_ini_line_exist(hud_sect, 'firemode_bones_total') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(hud_sect, 'firemode_bones_total'), false);
firemode_mark:='firemode_bones'+GetFiremodeSuffix(wpn);
if game_ini_line_exist(hud_sect, PAnsiChar(firemode_mark)) then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(hud_sect, PAnsiChar(firemode_mark)), true);
end;
type
UpgradeProcessResults = packed record
hud_overriden:boolean;
visual_overriden:boolean;
end;
function ProcessUpgrade(wpn:pointer):UpgradeProcessResults; stdcall;
var all_upgrades:string;
section:PChar;
new_hud_sect, old_hud_sect:PAnsiChar;
up_gr_sect:string;
i:integer;
buf:WpnBuf;
lens_params:lens_zoom_params;
t_dt:single;
gl_status:cardinal;
gl_enabled:boolean;
begin
result.hud_overriden:=false;
result.visual_overriden:=false;
section:=GetSection(wpn);
buf:=GetBuffer(wpn);
gl_status:=GetGLStatus(wpn);
gl_enabled:=(gl_status>0) and IsGrenadeMode(wpn);
//Ñêðîåì âñå êîñòè, êîòîðûå íàäî ñêðûòü, èñõîäÿ èç äàííûõ ñåêöèè îðóæèÿ
if game_ini_line_exist(section, 'def_hide_bones') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'def_hide_bones'), false);
if game_ini_line_exist(section, 'def_show_bones') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'def_show_bones'), true);
if gl_enabled and game_ini_line_exist(section, 'def_hide_bones_grenade') and not (leftstr(GetActualCurrentAnim(wpn), length('anm_switch'))='anm_switch') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'def_hide_bones_grenade'), false);
//Ïðî÷èòàåì ñåêöèè âñåõ äîñòóïíûõ àïîâ èç êîíôèãà
if game_ini_line_exist(section, 'upgrades') then begin
all_upgrades:=game_ini_read_string(section, 'upgrades');
//Ïåðåáåðåì èõ âñå
while (GetNextSubStr(all_upgrades, up_gr_sect, ',')) do begin
HideOneUpgradeLevel(wpn, PChar(up_gr_sect));
end;
//Ïîñìîòðèì, êàêèå àïãðåéäû óæå óñòàíîâëåíû, è îòîáðàçèì èõ
for i:=0 to GetInstalledUpgradesCount(wpn)-1 do begin
section:=GetInstalledUpgradeSection(wpn, i);
section:=game_ini_read_string(section, 'section');
if game_ini_line_exist(section, 'hide_bones') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones'), false);
if game_ini_line_exist(section, 'hud') then begin
old_hud_sect:=GetHUDSection(wpn);
new_hud_sect:=old_hud_sect;
if IsSilencerAttached(wpn) and game_ini_r_bool_def(section, 'hud_when_silencer_is_attached', false) then begin
new_hud_sect:=game_ini_read_string(section, 'hud_silencer');
result.hud_overriden:=true;
end else if (GetGLStatus(wpn) = 2) and IsGLAttached(wpn) and game_ini_r_bool_def(section, 'hud_when_gl_is_attached', false) then begin
new_hud_sect:= game_ini_read_string(section, 'hud_gl');
result.hud_overriden:=true;
end else if IsScopeAttached(wpn) and game_ini_r_bool_def(section, 'hud_when_scope_is_attached', false) then begin
new_hud_sect:=game_ini_read_string(section, 'hud_scope');
result.hud_overriden:=true;
end else begin
new_hud_sect:=game_ini_read_string(section, 'hud');
if new_hud_sect = 'skip_reassign' then begin
new_hud_sect:=old_hud_sect;
end else begin
result.hud_overriden:=true;
end;
end;
if new_hud_sect<>old_hud_sect then begin
SetHUDSection(wpn, new_hud_sect);
end;
end;
if game_ini_line_exist(section, 'visual') then begin
result.visual_overriden:=true;
SetWpnVisual(wpn, game_ini_read_string(section, 'visual'));
end;
if (buf<>nil) and not buf.IsLaserInstalled() and game_ini_r_bool_def(section, 'laser_installed', false) then begin
buf.InstallLaser(section);
end;
if (buf<>nil) and not buf.IsTorchInstalled() and game_ini_r_bool_def(section, 'torch_installed', false) then begin
buf.InstallTorch(section);
end;
if (buf<>nil) and not buf.NeedPermanentLensRendering() and game_ini_r_bool_def(section, 'permanent_lens_render', false) then begin
buf.SetPermanentLensRenderingStatus(true);
end;
if (buf<>nil) then begin
lens_params:=buf.GetLensParams();
t_dt:=game_ini_r_single_def(section, 'lens_factor_levels_count', 0);
if t_dt <> 0 then begin
lens_params.delta:=1.0/t_dt;
end;
lens_params.factor_min:=game_ini_r_single_def(section, 'min_lens_factor', lens_params.factor_min);
lens_params.factor_max:=game_ini_r_single_def(section, 'max_lens_factor', lens_params.factor_max);
lens_params.speed:=game_ini_r_single_def(section, 'lens_speed', lens_params.speed);
lens_params.gyro_period:=game_ini_r_single_def(section, 'lens_gyro_sound_period', lens_params.gyro_period);
buf.SetLensParams(lens_params);
end;
if game_ini_line_exist(section, 'flame_particles') then begin
ChangeParticles(wpn, game_ini_read_string(section, 'flame_particles'), CWEAPON_FLAME_PARTICLES);
if not IsSilencerAttached(wpn) then ChangeParticles(wpn, game_ini_read_string(section, 'flame_particles'), CWEAPON_FLAME_PARTICLES_CURRENT);
end;
if game_ini_line_exist(section, 'smoke_particles') then begin
ChangeParticles(wpn, game_ini_read_string(section, 'smoke_particles'), CWEAPON_SMOKE_PARTICLES);
if not IsSilencerAttached(wpn) then ChangeParticles(wpn, game_ini_read_string(section, 'smoke_particles'), CWEAPON_SMOKE_PARTICLES_CURRENT);
end;
if game_ini_line_exist(section, 'shell_particles') then ChangeParticles(wpn, game_ini_read_string(section, 'shell_particles'), CWEAPON_SHELL_PARTICLES);
if game_ini_line_exist(section, 'actor_camera_speed_factor') then begin
buf.SetCameraSpeed(GetCamSpeedDef()*game_ini_r_single(section, 'actor_camera_speed_factor'));
end;
end;
for i:=0 to GetInstalledUpgradesCount(wpn)-1 do begin
section:=GetInstalledUpgradeSection(wpn, i);
section:=game_ini_read_string(section, 'section');
if game_ini_line_exist(section, 'show_bones') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'show_bones'), true);
//äëÿ ñîêðûòèÿ êîñòåé, îòâå÷àþùèõ çà ïðåäûäóùèå àïû âåòêè
if game_ini_line_exist(section, 'hide_bones_override') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones_override'), false);
if (IsSilencerAttached(wpn)) then begin
if game_ini_line_exist(section, 'hide_bones_override_when_silencer_attached') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones_override_when_silencer_attached'), false);
end;
if (IsScopeAttached(wpn)) then begin
if game_ini_line_exist(section, 'hide_bones_override_when_scope_attached') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones_override_when_scope_attached'), false);
end;
if ((gl_status=1) or ((gl_status=2) and IsGLAttached(wpn)) ) then begin
if game_ini_line_exist(section, 'hide_bones_override_when_gl_attached') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones_override_when_gl_attached'), false);
end;
if gl_enabled and not (leftstr(GetActualCurrentAnim(wpn), length('anm_switch'))='anm_switch') then begin
if game_ini_line_exist(section, 'hide_bones_override_grenade') then SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'hide_bones_override_grenade'), false);
end;
end;
end;
section:=GetSection(wpn);
if ((gl_status=1) or ((gl_status=2) and IsGLAttached(wpn)) ) then begin
if game_ini_line_exist(section, 'def_hide_bones_override_when_gl_attached') then begin
SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(section, 'def_hide_bones_override_when_gl_attached'), false);
end;
end;
end;
procedure ProcessScope(wpn:pointer); stdcall;
var
tmp:string;
status:boolean;
cur_index, i:integer;
total_scope_cnt:cardinal;
begin
if IsScopeAttached(wpn) and (GetScopeStatus(wpn)=2) then cur_index:=GetCurrentScopeIndex(wpn) else cur_index:=-1;
total_scope_cnt:=GetScopesCount(wpn);
for i:=0 to total_scope_cnt-1 do begin
tmp:=GetScopeSection(wpn, i);
if i=cur_index then status:=true else status:=false;
if game_ini_line_exist(PChar(tmp), 'bones') then begin;
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(PChar(tmp), 'bones'), status);
end;
if game_ini_line_exist(PChar(tmp), 'hide_bones') then begin
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(PChar(tmp), 'hide_bones'), not status);
end;
end;
if (cur_index>=0) then begin
tmp:=GetScopeSection(wpn, cur_index);
if game_ini_line_exist(PChar(tmp), 'overriding_hide_bones') then begin
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(PChar(tmp), 'overriding_hide_bones'), false);
end;
if game_ini_line_exist(PChar(tmp), 'overriding_show_bones') then begin
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(PChar(tmp), 'overriding_show_bones'), true);
end;
end else begin
tmp:=GetSection(wpn);
if game_ini_line_exist(PChar(tmp), 'no_scope_overriding_hide_bones') then begin
SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(PChar(tmp), 'no_scope_overriding_hide_bones'), false);
end;
if game_ini_line_exist(PChar(tmp), 'no_scope_overriding_show_bones') then begin
SetWeaponMultipleBonesStatus(wpn, game_ini_read_string(PChar(tmp), 'no_scope_overriding_show_bones'), true);
end;
end;
end;
procedure AddSuffixIfStringExist(sect:PChar; suffix:PChar; var anm:string);
var
newanm:string;
begin
newanm := anm + suffix;
if (length(game_ini_read_string_def(sect, PChar(newanm), '')) > 0) then begin
anm := newanm;
end;
end;
procedure ReassignWorldAnims(wpn:pointer); stdcall;
var
sect:PChar;
anm:string;
state:cardinal;
bmixin:boolean;
begin
state:=cardinal(GetNextState(wpn));
if (not GetAnimForceReassignStatus(wpn)) then exit;
sect:=GetSection(wpn);
if not game_ini_r_bool_def(sect, 'use_world_anims', false) then exit;
bmixin:=true;
if state=EHudStates__eIdle then begin
anm:='wanm_idle';
end else if state=EHudStates__eShowing then begin
anm:='wanm_draw'
end else if state=EHudStates__eHiding then begin
anm:='wanm_holster';
end else if state=EWeaponStates__eFire then begin
anm:='wanm_shoot';
if GetAmmoInMagCount(wpn)<=0 then begin
AddSuffixIfStringExist(sect, '_last', anm);
end;
end else if state=EWeaponStates__eReload then begin
anm:='wanm_reload';
end else begin
anm:='wanm_idle';
end;
if (length(game_ini_read_string_def(sect, PChar(anm), '')) = 0) then begin
anm:='wanm_idle';
end;
if IsWeaponJammed(wpn) then begin
AddSuffixIfStringExist(sect, '_jammed', anm);
end else if (GetAmmoInMagCount(wpn)<=0) and (state<>EWeaponStates__eFire) then begin
AddSuffixIfStringExist(sect, '_empty', anm);
end;
AddSuffixIfStringExist(sect,PChar(GetFiremodeSuffix(wpn)), anm);
if IsGrenadeMode(wpn) then begin
AddSuffixIfStringExist(sect, '_g', anm);
end else if (GetGLStatus(wpn)=1) or ((GetGLStatus(wpn)=2) and IsGLAttached(wpn)) then begin
AddSuffixIfStringExist(sect, '_w_gl', anm);
end;
PlayCycle(wpn, game_ini_read_string(sect,PChar(anm)), bmixin);
SetAnimForceReassignStatus(wpn, false);
end;
function CastToCWeapon(CObject:pointer):pointer; stdcall;
begin
result:=dynamic_cast(CObject, 0, RTTI_CObject, RTTI_CWeapon, false);
end;
procedure CheckRLHasActiveRocket(wpn:pointer; rl:pointer); stdcall;
var
n, p:FVector3;
sect:PChar;
cond, start_tr, end_tr,start_prob, end_prob:single;
is_expl:boolean;
r:pCCustomRocket;
act:pointer;
is_act_own:boolean;
begin
act:=GetActor();
is_act_own:=(act<>nil) and (act=GetOwner(wpn));
if GetRocketsCount(rl)>0 then begin
if (not IsActionProcessing(wpn) or (is_act_own and IsActorControlled())) and (GetAmmoInMagCount(wpn)>0) then begin
sect:=GetSection(wpn);
start_tr:=game_ini_r_single_def(sect, 'rocket_misfunc_start_condition', 0);
end_tr:=game_ini_r_single_def(sect, 'rocket_misfunc_end_condition', 0);
start_prob:=game_ini_r_single_def(sect, 'rocket_misfunc_start_probability', 0);
end_prob:=game_ini_r_single_def(sect, 'rocket_misfunc_end_probability', 0);
cond:=GetCurrentCondition(wpn);
if (GetOwner(wpn)<>GetActor()) or (cond>start_tr) or (start_tr=end_tr) then begin
is_expl:=false;
end else if cond<end_tr then begin
is_expl:= random < end_prob;
end else begin
is_expl:= random < start_prob+(end_prob-start_prob)*(start_tr-cond)/(start_tr-end_tr);
end;
if (IsActorControlled() and is_act_own) or is_expl then begin
p:=FVector3_copyfromengine(GetPosition(wpn));
n.x:=0;
n.y:=1;
n.z:=0;
r:=GetRocket(rl, 0);
DetachRocket(rl, GetCObjectID(r), true);
virtual_CCustomRocket__Contact(r, @p, @n);
UnloadRockets(rl);
virtual_CWeaponMagazined__UnloadMagazine(wpn, false);
end else begin
virtual_Action(wpn, kWPN_FIRE, kActPress);
end;
end else begin
UnloadRockets(rl);
end;
end;
end;
procedure CWeapon__ModUpdate(wpn:pointer); stdcall;
var
buf:WpnBuf;
sect:PChar;
offset:integer;
slot, prevslot:integer;
probability, probability2:single;
collim_problems_cnt:single;
bp:conditional_breaking_params;
last_rec_time:cardinal;
lens_recoil:FVector3;
val, len:single;
rl:pCRocketLauncher;
gl_ammocnt, gl_ammotype:byte;
so:pointer;
need_bones_recheck:boolean;
k:single;
upgrade_results:UpgradeProcessResults;
cur_hud_sect, new_hud_sect:PAnsiChar;
cb:TAnimationEffector;
const
EPS:single = 0.0001;
begin
so:=get_server_object_by_id(GetID(wpn));
if so=nil then exit;
sect:=GetSection(wpn);
rl:=dynamic_cast(wpn, 0, RTTI_CWeapon, RTTI_CWeaponMagazinedWGrenade, false);
if (rl<>nil) then begin
rl:=dynamic_cast(wpn, 0, RTTI_CWeapon, RTTI_CRocketLauncher, false);
if GetRocketsCount(rl)>0 then begin
CWeaponMagazinedWGrenade__LaunchGrenade(wpn); // íå rl - ôóíêöèÿ æäåò CWeaponMagazinedWGrenade!
end;
//[bug] áàã - îòñóòñòâóåò âûñòàâëåíèå a_elapsed_grenades â àïäåéò-ïàêåòå, èç-çà ÷åãî ãðåíû ïðîãðóæàþòñÿ íåêîððåêòíî. Ïî-õîðîøåìó, íàäî ïðàâèòü íå òàê òîïîðíî, à ìîäèôèöèðîâàíèåì ìåòîäîâ ýêñïîðòà è èìïîðòà íåòïàêåòîâ
gl_ammocnt:=GetAmmoInGLCount(wpn);
if gl_ammocnt>0 then begin
gl_ammotype:=GetCartridgeType(GetGrenadeCartridgeFromGLVector(wpn, gl_ammocnt-1));
end else begin
gl_ammotype:=GetAmmoTypeIndex(wpn, not IsGrenadeMode(wpn))
end;
pbyte(cardinal(so)+$1A8)^:=(gl_ammotype shl 6) + (gl_ammocnt and $3F);
end else begin
rl:=dynamic_cast(wpn, 0, RTTI_CWeapon, RTTI_CRocketLauncher, false);
if (rl<>nil) then begin
CheckRLHasActiveRocket(wpn, rl);
end;
end;
if IsItemActionAnimator(wpn) then begin
if (wpn=GetActorActiveItem()) then begin
if (GetCurrentState(wpn)=EHudStates__eShowing) then begin
if (GetActorTargetSlot()=GetActorActiveSlot()) and not game_ini_r_bool_def(sect, 'disable_autochange_slot', false) then begin
prevslot:=GetActorPreviousSlot();
// log ('activating '+inttostr(prevslot)+', state='+inttostr(GetCurrentState(wpn)));
if (prevslot>=0) and (prevslot<>GetActorActiveSlot()) and (ItemInSlot(GetActor, prevslot)<>nil) then
ActivateActorSlot(prevslot)
else
ActivateActorSlot(0);
end;
end else begin
// log(inttostr(GetCurrentState(wpn)));
cb:=GetActorActionCallback();
if (GetActorTargetSlot()=GetActorActiveSlot()) and ((GetCurrentState(wpn)<>EHudStates__eIdle)) and IsActorActionAnimatorAutoshow() and ((@cb<>nil) or not game_ini_r_bool_def(sect, 'disable_autochange_slot', false)) then begin
virtual_CHudItem_SwitchState(wpn, EHudStates__eShowing);
end;
end;
end else begin
if (GetActor=nil) or (GetOwner(wpn)<>GetActor()) then begin
alife_release(get_server_object_by_id(GetID(wpn)));
end else begin
slot:=game_ini_r_int_def(sect, 'slot', 0)+1;
// log('release candidate');
if (GetActorTargetSlot() <> slot) then begin
// log('released');
alife_release(get_server_object_by_id(GetID(wpn)));
RestoreLastActorDetector();
end;
end;
end;
end;
if (GetActorActiveItem=wpn) and DOFChanged() and (not IsAimNow(wpn)) and (not IsHolderInAimState(wpn)) and (GetAnimTimeState(wpn, ANM_TIME_CUR)>0) then begin
offset:=ReadActionDOFTimeOffset(wpn, GetActualCurrentAnim(wpn));
if (offset>0) then begin
if GetTimeDeltaSafe(GetAnimTimeState(wpn, ANM_TIME_START), GetAnimTimeState(wpn, ANM_TIME_CUR))>cardinal(offset) then begin
ResetDOF(ReadActionDOFSpeed_Out(wpn, GetActualCurrentAnim(wpn)));
end;
end else if (offset<0) then begin
if GetTimeDeltaSafe(GetAnimTimeState(wpn, ANM_TIME_CUR), GetAnimTimeState(wpn, ANM_TIME_END))<cardinal(-1*offset) then begin
ResetDOF(ReadActionDOFSpeed_Out(wpn, GetActualCurrentAnim(wpn)));
end;
end;
end;
//àïäåéò áóôåðà
buf:=WeaponAdditionalBuffer.GetBuffer(wpn);
if buf<>nil then begin
if not buf.Update then Log('Failed to update wpn: '+inttohex(cardinal(wpn), 8));
if not buf.IsLaserInstalled() and game_ini_r_bool_def(sect, 'laser_installed', false) then begin
buf.InstallLaser(sect)
end;
if not buf.IsTorchInstalled() and game_ini_r_bool_def(sect, 'torch_installed', false) then begin
buf.InstallTorch(sect)
end;
if (game_ini_line_exist(sect, 'collimator_sights_bones')) then begin
bp:=buf.GetCollimatorBreakingParams();
if ((GetAimFactor(wpn)>0) and (buf.IsLastZoomAlter() or (buf.GetAlterZoomDirectSwitchMixupFactor() > EPS)) and game_ini_r_bool_def(sect,'hide_collimator_sights_in_alter_zoom', true)) or (GetCurrentCondition(wpn)<bp.end_condition) then begin
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(sect, 'collimator_sights_bones'), false);
end else if (GetCurrentCondition(wpn)<bp.start_condition) or ( CurrentElectronicsProblemsCnt() > 0 ) then begin
if (bp.start_condition=bp.end_condition) then begin
probability := bp.end_condition;
end else begin
probability := bp.start_probability+(bp.start_condition-GetCurrentCondition(wpn))* (1-bp.start_probability)/(bp.start_condition-bp.end_condition);
end;
collim_problems_cnt := buf.GetCollimatorProblemsLevel();
if ( CurrentElectronicsProblemsCnt() > 0 ) and ( collim_problems_cnt > 0) then begin
if CurrentElectronicsProblemsCnt() >= collim_problems_cnt then begin
probability := 1;
end else begin
probability2 := CurrentElectronicsProblemsCnt() / collim_problems_cnt;
if probability2 > probability then begin
probability:= probability2;
end;
end;
end;
SetWeaponMultipleBonesStatus(
wpn,
game_ini_read_string(sect, 'collimator_sights_bones'),
not (random<probability)
);
end else begin
SetWeaponMultipleBonesStatus(wpn,game_ini_read_string(sect, 'collimator_sights_bones'), true);
end;
end;
end;
if ((GetActor()=nil) or (GetOwner(wpn)<>GetActor())) or (GetActorActiveItem()<>wpn) then begin
if IsExplosed(wpn) then OnWeaponExplode_AfterAnim(wpn, 0);
if leftstr(GetCurAnim(wpn), length('anm_attach_scope_'))='anm_attach_scope_' then DetachAddon(wpn, 1);
if leftstr(GetCurAnim(wpn), length('anm_attach_gl'))='anm_attach_gl' then DetachAddon(wpn, 2);
if leftstr(GetCurAnim(wpn), length('anm_attach_sil'))='anm_attach_sil' then DetachAddon(wpn, 4);
end;
if (GetOwner(wpn)=nil) or (dynamic_cast(GetOwner(wpn), 0, RTTI_CObject, RTTI_CEntityAlive, false) <> nil) then begin
// Îïòèìèçàöèÿ - âûïîëíÿåì èëè íå âûïîëíÿåì âñå äåéñòâèÿ ïà÷êîé, ÷òîáû íå ïîëó÷èëîñü ðàññèíõðîíà.
if IsHardUpdates() then begin
k:=2;
end else begin
k:=1;
end;
need_bones_recheck:=NeedUpdateBonesCheck(wpn);
if need_bones_recheck or ((GetOwner(wpn)=GetActor()) and (GetActor()<>nil) and (GetCurrentFrame() mod 10 = 0) ) then begin
//Îáðàáîòàåì óñòàíîâëåííûå àïãðåéäû
upgrade_results:=ProcessUpgrade(wpn);
if (GetInstalledUpgradesCount(wpn)>0) and (not upgrade_results.hud_overriden) then begin
cur_hud_sect:=GetHUDSection(wpn);
new_hud_sect:=cur_hud_sect;
if IsSilencerAttached(wpn) and game_ini_r_bool_def(sect, 'hud_when_silencer_is_attached', false) then begin
if buf<>nil then begin
new_hud_sect:=buf.GetDefaultHudSectionSil();
end else begin
new_hud_sect:=game_ini_read_string(sect, 'hud_silencer');
end;
end else if (GetGLStatus(wpn) = 2) and IsGLAttached(wpn) and game_ini_r_bool_def(sect, 'hud_when_gl_is_attached', false) then begin
if buf<>nil then begin
new_hud_sect:=buf.GetDefaultHudSectionGL();
end else begin
new_hud_sect:=game_ini_read_string(sect, 'hud_gl');
end;
end else if IsScopeAttached(wpn) and game_ini_r_bool_def(sect, 'hud_when_scope_is_attached', false) then begin
if buf<>nil then begin
new_hud_sect:=buf.GetDefaultHudSectionScope();
end else begin
new_hud_sect:=game_ini_read_string(sect, 'hud_scope');
end;
end else begin
if buf<>nil then begin
new_hud_sect:=buf.GetDefaultHudSection();
end else begin
new_hud_sect:=game_ini_read_string(sect, 'hud');
end;
end;
if cur_hud_sect <> new_hud_sect then begin
SetHUDSection(wpn, new_hud_sect);
end;
end;
//Òåïåðü îòîáðàçèì óñòàíîâëåííûé ïðèöåë
ProcessScope(wpn);
//Ðàçáåðåìñÿ ñ âèçóàëèçàöèåé ïàòðîíîâ
ProcessAmmo(wpn);
ProcessAmmoGL(wpn);
//Âèçóàëèçàöèÿ ðåæèìà îãíÿ
ProcessFiremode(wpn);
end;
//àíèìû îò 3-ãî ëèöà
ReassignWorldAnims(wpn);
end;
if (buf<>nil) then begin
ProcessLaserDot(wpn);
end;
if (buf<>nil) then begin
buf.UpdateTorch();
end;
end;
{procedure CWeapon__UpdateCL_Patch();stdcall;
asm
pushad
push esi
call CWeapon__ModUpdate
popad
mov eax, [esi+$338]
end;}