This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
/
dsh.script
2706 lines (2324 loc) · 70.8 KB
/
dsh.script
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
-- -*- mode: lua; coding: windows-1251-dos -*-
-- â ýòèõ ñëîòàõ ìîãóò íàõîäèòüñÿ ïèñòîëåòû è îáðåçû
small_wpn_slots = {
[ 1 ] = true,
[ 8 ] = true,
}
function attach( sm )
sm:subscribe({ signal = "on_before_spawn", fun = this.on_before_spawn })
sm:subscribe({ signal = "on_destroy", fun = this.on_destroy })
sm:subscribe({ signal = "on_save", fun = this.on_save })
sm:subscribe({ signal = "on_spawn", fun = this.on_spawn })
end
function init()
event( "se_monster:on_before_register" ):register( this.se_on_before_register )
event( "se_stalker:on_before_register" ):register( this.se_on_before_register )
end
function on_before_spawn()
local build = ogse.load_var_safe( "dsh.build" )
log2(
"[%s]: [%s] loaded build: %s",
script_name(), get_string_wq( "dsh.build", "build" ), tostring( build )
)
db.actor:disable_info_portion( "biznes_remove_special_item" )
if is_input_time_inactivated() then
level.disable_input()
else
level.enable_input()
end
end
function unbind_debug_keys()
cmd( "unbind cam_2" )
cmd( "unbind_sec cam_2" )
end
function on_spawn()
if not dsh_cfg.get_data().debug_mode then
for _, k in ipairs({ "g_god", "g_unlimitedammo" }) do
cmd( k, "off" )
end
for _, k in ipairs({
"bind", "demo_record", "g_god", "g_unlimitedammo", "jump_to_level"
}) do
get_console():disable_command( k )
end
unbind_debug_keys()
ogse_signals.get_mgr():subscribe({
signal = "on_mm_return_game", fun = this.unbind_debug_keys
})
end
end
function on_save()
ogse.save_var( "dsh.build", get_string_wq( "dsh.build", "build" ), "string" )
end
class "timeout_timer" ( ogse_qt.quick_timer )
function timeout_timer:__init( delay, fun, ... ) super( delay )
self.fun = fun
self.args = { ... }
end
function timeout_timer:taction()
self.fun( unpack( self.args ) )
end
function timeout( ... )
local t = timeout_timer( ... )
local d = debug.getinfo( 2, "S" )
if d then
t:set_script_name( d.source )
end
t:start()
return t
end
class "condition_timer" ( ogse_qt.quick_timer )
function condition_timer:__init( fun1, fun2, fun3 )
self.fun1 = fun1
self.fun2 = fun2
self.fun3 = fun3
end
function condition_timer:condition()
return self.fun1( self )
end
function condition_timer:action()
self.fun2( self )
end
function condition_timer:update()
if self.fun3 then self.fun3( self ) end
end
function wait_condition( ... )
local t = condition_timer( ... )
local d = debug.getinfo( 2, "S" )
if d then
t:set_script_name( d.source )
end
t:start()
return t
end
class "exec_on_update_timer" ( ogse_qt.quick_timer )
function exec_on_update_timer:__init( fun, ... )
self.fun = fun
self.args = { ... }
end
function exec_on_update_timer:condition()
return not ogse_sleep_mgr.is_sleep_active()
end
function exec_on_update_timer:action()
self.fun( unpack( self.args ) )
end
function exec_on_update( ... )
local t = exec_on_update_timer( ... )
local d = debug.getinfo( 2, "S" )
if d then
t:set_script_name( d.source )
end
t:start()
return t
end
function set_condition( item, cond )
item:set_condition( cond )
end
-- http://www.amk-team.ru/forum/index.php?showtopic=6458&p=937442
--
-- local lname = level.name()
-- local lvtab = GetLevelVertexes( lname )
-- local lvx = math.max( unpack( lvtab ) )
-- local lv = math_random( 1, lvx )
--
-- local gvtab = GetGameVertexes( lname )
-- local gv_min = math.min( unpack( gvtab ) )
-- local gv_max = math.max( unpack( gvtab ) )
--
function GetLevelVertexes( level )
local lvtab ={}
local i = 0
while game_graph():valid_vertex_id( i ) do
local lv = game_graph():vertex( i ):level_vertex_id()
local ln = alife():level_name( game_graph():vertex( i ):level_id() )
if not lvtab[ ln ] then
lvtab[ ln ] = {}
end
table.insert( lvtab[ ln ], lv )
i = i + 1
end
return lvtab[ level ]
end
function GetGameVertexes( level )
local gvtab ={}
local i = 0
while game_graph():valid_vertex_id( i ) do
local ln = alife():level_name( game_graph():vertex( i ):level_id() )
if not gvtab[ ln ] then
gvtab[ ln ] = {}
end
table.insert( gvtab[ ln ], i )
i = i + 1
end
return gvtab[ level ]
end
function is_enemy_around()
for id in pairs( db.creature ) do
if id then
local obj = level.object_by_id( id )
if obj and obj:is_custom_monster() and obj:alive() then
local is_stalker = IsStalker(obj)
local dist = obj:position():distance_to( db.actor:position() )
local is_enemy_to_actor =
ogse.get_npc_relation( obj, db.actor ) == "enemy"
if
( ( is_stalker and is_enemy_to_actor ) or IsMonster( obj ) )
and
( dist < 5 or obj:see( db.actor ) )
then
return true
end
end
end
end
return false
end
function remove_quotes( s )
local s2 = string.gsub( s, "[«»\"\']", "" )
return s2
end
function strip_quotes( s )
return string.gsub( s, "^%s*[«»\"\']+%s*(.+)%s*[«»\"\']+%s*$", "%1" )
end
function is_artefact( sect )
if sys_ini:line_exist( sect, "dsh_is_artefact" ) then
return get_bool( sect, "dsh_is_artefact" )
end
return string.find( sect, "af_", 1, true )
end
-- Ñïèñîê àðòåôàêòîâ, êîòîðûå ìîæíî ñâàðèòü.
function get_creatable_arts()
local arts = {}
for anomaly, info in pairs( amk_mod.anom_recept_komp.anomalii ) do
for info_key, recept in pairs( info.recepti ) do
if
recept.cel and recept.komp
and not ( recept.remove_anomaly or recept.storyline )
then
local targets = {}
local parts = {}
for k, _ in pairs( recept.cel ) do
ASSERT( not recept.komp[ k ], "found cel %s in komp", k )
table.insert( targets, k )
end
for k, _ in pairs( recept.komp ) do
ASSERT( not recept.cel[ k ], "found komp %s in cel", k )
table.insert( parts, k )
end
if
table.getn( targets ) == 1
and is_artefact( targets[ 1 ] )
and table.getn( parts ) > 0
then
local tgt = targets[ 1 ]
arts[ tgt ] = {
[ "next" ] = {},
[ "prev" ] = parts,
}
end
end
end
end
return arts
end
function get_art_levels()
local arts = {}
for k, v in pairs( get_creatable_arts() ) do
if table.getn( v.prev ) == 1 then
arts[ k ] = v
end
end
for af, data in pairs( arts ) do
local next_arts = { af }
local process = { data.prev[ 1 ] }
while table.getn( process ) > 0 do
local af_prev = table.remove( process, 1 )
ASSERT( af ~= af_prev, "loop found: %s == %s", af, af_prev )
if arts[ af_prev ] then
if table.getn( arts[ af_prev ].next ) < table.getn( next_arts ) then
arts[ af_prev ].next = {}
for _, k in ipairs( next_arts ) do
table.insert( arts[ af_prev ].next, k )
end
end
table.insert( next_arts, 1, af_prev )
table.insert( process, arts[ af_prev ].prev[ 1 ] )
table.insert( data.prev, arts[ af_prev ].prev[ 1 ] )
end
end
end
-- Äëÿ Ñèìáèîíà ñäåëàíî èñêëþ÷åíèå. Ò.ê. îí íå ÿâëÿåòñÿ ìîäèôèêàöèåé
-- êàêîãî-òî îäíîãî àðòåôàêòà, îí áóäåò ñ÷èòàòüñÿ àðòåôàêòîì ïåðâîãî
-- óðîâíÿ. Ïîýòîìó, ïðèíóäèòåëüíî ñäåëàþ åãî àðòåôàêòîì òðåòüåãî
-- óðîâíÿ.
if not arts[ "af_simbion" ] then
arts[ "af_simbion" ] = {
[ "next" ] = { "af_arhara_globus" },
[ "prev" ] = { "", "" },
}
end
return arts
end
function get_inv_item_weight( obj )
return obj:get_inventory_item().inv_weight
end
function set_inv_item_weight( obj, weight )
obj:get_inventory_item().inv_weight = weight
end
function change_inv_item_weight( id, weight, abs_weight )
local obj = level.object_by_id( id )
if obj then
if abs_weight then
set_inv_item_weight( obj, weight )
else
local cur_weight = get_inv_item_weight( obj )
set_inv_item_weight( obj, cur_weight + weight )
end
end
end
function actor_get_art_nsimpliest( n )
local arts = {}
db.actor:iterate_inventory(
function( npc, obj )
if get_bool( obj:section(), "dsh.simpliest_art", false ) then
if db.actor:is_in_ruck( obj ) then
table.insert( arts, obj )
end
end
end,
db.actor
)
if table.getn( arts ) >= n then
return arts
end
end
function actor_has_art_nsimpliest( n )
if actor_get_art_nsimpliest( n ) then return true else return false end
end
function actor_give_art_nsimpliest( n )
local arts = actor_get_art_nsimpliest( n )
if arts then
for i = 1, n do
local obj = table.remove( arts, 1 )
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
end
function actor_has_art_simpliest()
if actor_get_art_nsimpliest( 1 ) then return true else return false end
end
function actor_give_art_simpliest()
return actor_give_art_nsimpliest( 1 )
end
function is_zone_bio_art( obj )
local props = db.artefacts[ obj:id() ]
ASSERT( props, "not found in db.artefacts: %s", obj:name() )
return not props.handmade
end
function actor_get_art_nsimpliest_bio( n )
local arts = actor_get_art_nsimpliest( n )
if arts then
local bio = {}
for _, obj in ipairs( arts ) do
if is_zone_bio_art( obj ) then
table.insert( bio, obj )
end
end
if table.getn( bio ) >= n then
return bio
end
end
end
function actor_has_art_nsimpliest_bio( n )
if actor_get_art_nsimpliest_bio( n ) then return true else return false end
end
function actor_give_art_nsimpliest_bio( n )
local arts = actor_get_art_nsimpliest_bio( n )
if arts then
for i = 1, n do
local obj = table.remove( arts, 1 )
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
end
function actor_has_art_simpliest_bio()
return actor_has_art_nsimpliest_bio( 1 )
end
function actor_give_art_simpliest_bio()
return actor_give_art_nsimpliest_bio( 1 )
end
function actor_has_art_2simpliest_bio()
return actor_has_art_nsimpliest_bio( 2 )
end
function actor_give_art_2simpliest_bio()
return actor_give_art_nsimpliest_bio( 2 )
end
function actor_has_art_3simpliest_bio()
return actor_has_art_nsimpliest_bio( 3 )
end
function actor_give_art_3simpliest_bio()
return actor_give_art_nsimpliest_bio( 3 )
end
function actor_get_art_nl0( n )
local arts = {}
for k, v in pairs( get_art_levels() ) do
if table.getn( v.prev ) == 1 and table.getn( v.next ) > 0 then
amk_utils.inventory_iterate_section(
v.prev[ 1 ],
function( obj )
if db.actor:is_in_ruck( obj ) then
table.insert( arts, obj )
end
end
)
end
end
if table.getn( arts ) >= n then return arts end
end
function actor_has_art_nl0( n )
if actor_get_art_nl0( n ) then return true else return false end
end
function actor_give_art_nl0( n )
local arts = actor_get_art_nl0( n )
if arts then
for i = 1, n do
local obj = table.remove( arts, 1 )
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
end
function actor_has_art_l0()
return actor_has_art_nl0( 1 )
end
function actor_give_art_l0()
return actor_give_art_nl0( 1 )
end
function actor_get_art_nl0_bio( n )
local arts = actor_get_art_nl0( n )
if arts then
local bio = {}
for _, obj in ipairs( arts ) do
if is_zone_bio_art( obj ) then
table.insert( bio, obj )
end
end
if table.getn( bio ) >= n then
return bio
end
end
end
function actor_has_art_nl0_bio( n )
if actor_get_art_nl0_bio( n ) then return true else return false end
end
function actor_give_art_nl0_bio( n )
local arts = actor_get_art_nl0_bio( n )
if arts then
for i = 1, n do
local obj = table.remove( arts, 1 )
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
end
function actor_has_art_l0_bio()
return actor_has_art_nl0_bio( 1 )
end
function actor_give_art_l0_bio()
return actor_give_art_nl0_bio( 1 )
end
function actor_has_art_2l0_bio()
return actor_has_art_nl0_bio( 2 )
end
function actor_give_art_2l0_bio()
return actor_give_art_nl0_bio( 2 )
end
function actor_has_art_3l0_bio()
return actor_has_art_nl0_bio( 3 )
end
function actor_give_art_3l0_bio()
return actor_give_art_nl0_bio( 3 )
end
function actor_get_art_check( f )
for k, v in pairs( get_art_levels() ) do
local found
amk_utils.inventory_iterate_section(
k,
function( obj )
if f( v, obj ) and db.actor:is_in_ruck( obj ) then
found = obj
return true
end
end
)
if found then return found end
end
end
function actor_get_art_abs()
return actor_get_art_check(
function( art )
return ( table.getn( art.prev ) > 0 and table.getn( art.next ) == 0 )
end
)
end
function actor_has_art_abs()
if actor_get_art_abs() then return true else return false end
end
function actor_give_art_abs()
local obj = actor_get_art_abs()
if obj then
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
function actor_get_art_ln( level )
return actor_get_art_check(
function( art )
return ( table.getn( art.prev ) == level and table.getn( art.next ) > 0 )
end
)
end
function actor_has_art_l1()
if actor_get_art_ln( 1 ) then return true else return false end
end
function actor_give_art_l1()
local obj = actor_get_art_ln( 1 )
if obj then
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
function actor_has_art_l2()
if actor_get_art_ln( 2 ) then return true else return false end
end
function actor_give_art_l2()
local obj = actor_get_art_ln( 2 )
if obj then
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
function actor_has_art_l3()
if actor_get_art_ln( 3 ) then return true else return false end
end
function actor_give_art_l3()
local obj = actor_get_art_ln( 3 )
if obj then
ogse.remove_item_from_inventory( obj )
news_manager.relocate_item( db.actor, "out", obj:section() )
end
end
-- Çàñïàóíèòü íà ÀÒÏ àðòåôàêòû, êîòîðûå òðåáóåò Êàëèíèí, ÷òî áû ðàññêàçàòü î
-- ïåðåõîäå íà Ñâàëêó.
function spawn_arts_for_kalinin()
local arts = {
"af_dummy_glassbeads", -- ìàìèíû áóñû
"af_electra_moonlight", -- ëóííûé ñâåò
"af_electra_flash", -- âñïûøêà
}
local radius = 200
for _, sect in ipairs( arts ) do
local prop = amk_utils.get_item_props( sect )
if prop.has_af_dyn then
sect = amk_anoms.make_dyn_art_sect( sect )
end
local sobj
while not sobj do
sobj = amk_anoms.generate_art(
level.name(), sect, function( maybe_pos )
if db.actor:position():distance_to( maybe_pos ) < radius then
return false
else
return true
end
end
)
end
end
end
local is_creating_free_mob = false
function se_on_before_register( e )
if is_creating_free_mob then
set_none_smart_terrain( e.sobj )
is_creating_free_mob = false
end
end
function set_none_smart_terrain( sobj )
local pk = get_netpk( sobj, 1 )
ASSERT( ( pk and pk:isOk() ), "can't read netpacket of %s", sobj:name() )
local data = pk:get()
local cd = data.custom_data:getTable()
if cd.smart_terrains then
for k, _ in pairs( cd.smart_terrains ) do
return
end
end
cd.smart_terrains = {
[ "none" ] = "true",
}
data.custom_data:set( cd )
pk:set( data )
end
-- Ñîçäàòü ñâîáîäíîãî ìîáà, êîòîðîãî íå çàòÿíåò â êàêîé-íèáóäü ãóëàã.
function create_free_mob( ... )
is_creating_free_mob = true
local sobj = alife():create( ... )
ASSERT(
is_creating_free_mob == false,
"[%s]: found is_creating_free_mob after %s", script_name(), sobj:name()
)
return sobj
end
function create_free_monster( ... )
return create_free_mob( ... )
end
function create_free_npc( ... )
return create_free_mob( ... )
end
function actor_has_cnt_items( looking_sect, check_cnt_func )
local cnt = 0
for i = 0, db.actor:object_count() - 1 do
local obj = db.actor:object( i )
local sect = obj:section()
if looking_sect == sect then
local ttl = dsh_item_ttl.get_ttl_info( sect )
if ( not ttl.ttl ) or obj:condition() > 0 then
cnt = cnt + 1
if check_cnt_func( cnt ) then return true end
end
end
end
return false
end
function actor_has_conserva_ge_4()
return actor_has_cnt_items(
"conserva", function( cnt ) return cnt >= 4 end
)
end
function actor_change_items( give_sect, give_num, take_sect, take_num )
local give_objs = {}
for i = 0, db.actor:object_count() - 1 do
local obj = db.actor:object( i )
local sect = obj:section()
if sect == give_sect then
local ttl = dsh_item_ttl.get_ttl_info( sect )
if ( not ttl.ttl ) or obj:condition() > 0 then
table.insert( give_objs, obj )
end
end
end
local base_cnt = math.floor( table.getn( give_objs ) / give_num )
local add_cnt = base_cnt * take_num
local del_cnt = base_cnt * give_num
if del_cnt > 0 then
for _, obj in ipairs( give_objs ) do
ogse.remove_item_from_inventory( obj )
del_cnt = del_cnt - 1
if del_cnt == 0 then break end
end
news_manager.relocate_item( db.actor, "out", give_sect )
end
if add_cnt > 0 then
for i = 1, add_cnt do
ogse.spawn_item_in_inv( take_sect )
end
news_manager.relocate_item( db.actor, "in", take_sect )
end
end
function actor_change_2conserva_1vodka()
actor_change_items( "conserva", 2, "vodka", 1 )
end
function actor_has_energy_drink_ge_6()
return actor_has_cnt_items(
"energy_drink", function( cnt ) return cnt >= 6 end
)
end
function actor_change_3energy_drink_1repair_item_outfit()
actor_change_items( "energy_drink", 3, "repair_item_outfit", 1 )
end
function actor_has_bread_ge_10()
return actor_has_cnt_items(
"bread", function( cnt ) return cnt >= 10 end
)
end
function actor_change_5bread_1repair_item_weapon()
actor_change_items( "bread", 5, "repair_item_weapon", 1 )
end
function actor_change_5bread_1grenade_f1()
actor_change_items( "bread", 5, "grenade_f1", 1 )
end
function actor_has_vodka_ge_2()
return actor_has_cnt_items(
"vodka", function( cnt ) return cnt >= 2 end
)
end
function actor_has_vodka_ge_4()
return actor_has_cnt_items(
"vodka", function( cnt ) return cnt >= 4 end
)
end
function actor_change_1vodka_2medkit_army()
actor_change_items( "vodka", 1, "medkit_army", 2 )
end
function actor_change_2vodka_1medkit_army()
actor_change_items( "vodka", 2, "medkit_army", 1 )
end
function actor_change_1vodka_1grenade_f1()
actor_change_items( "vodka", 1, "grenade_f1", 1 )
end
function actor_change_2vodka_1grenade_f1()
actor_change_items( "vodka", 2, "grenade_f1", 1 )
end
function actor_has_kolbasa_ge_2()
return actor_has_cnt_items(
"kolbasa", function( cnt ) return cnt >= 2 end
)
end
function actor_has_kolbasa_ge_4()
return actor_has_cnt_items(
"kolbasa", function( cnt ) return cnt >= 4 end
)
end
function actor_has_kolbasa_ge_8()
return actor_has_cnt_items(
"kolbasa", function( cnt ) return cnt >= 8 end
)
end
function actor_change_1kolbasa_1medkit()
actor_change_items( "kolbasa", 1, "medkit", 1 )
end
function actor_change_2kolbasa_1grenade_rgd()
actor_change_items( "kolbasa", 2, "grenade_rgd5", 1 )
end
function actor_change_4kolbasa_1grenade_rgd()
actor_change_items( "kolbasa", 4, "grenade_rgd5", 1 )
end
-- Ïðîâåðèòü ðàññòîÿíèå îò ãóëàãà äî ÃÃ, åñëè ìåíüøå.
function gulag_distance_to_actor_lt( gulag_name, check_dist )
if db.zone_by_name[ gulag_name ] then
local sobj = alife():object( gulag_name )
if sobj then
local obj = level.object_by_id( sobj.id )
if obj then
local dist = obj:position():distance_to( db.actor:position() )
return dist < check_dist
end
end
end
return false
end
-- Ïðîâåðêà, ìîãóò ëè ìóòàíòû íà ÀÑ íà÷èíàòü ðåéä íà Áàðüåð. Íóæíà äëÿ
-- òîãî, ÷òî áû íàïàäåíèå íà÷èíàëîñü íå ðàíüøå, ÷åì èãðîê äîéäåò äî
-- Áàðüåðà. Ñ óâåëè÷åííûì àëàéôîì âñå ýòî íà÷èíàåòñÿ ñëèøêîì ðàíî.
function lets_mil_monster_begin()
return gulag_distance_to_actor_lt( "mil_monster", 250 )
end
local mobs_smart_terrain = {}
function remember_mobs_smart_terrain( id, sobj, remember )
if remember then
mobs_smart_terrain[ id ] = sobj.id
else
mobs_smart_terrain[ id ] = nil
end
end
function is_free_logic_mob( sobj )
local strn_id
if sobj.smart_terrain_id then
strn_id = sobj:smart_terrain_id()
else
strn_id = 65535
end
if strn_id == 65535 then
return mobs_smart_terrain[ sobj.id ]
end
return nil
end
function bar_priemnik_off()
return ogse.save_var( "bar_priemnik.quiet", true, "bool" )
end
function bar_priemnik_on()
return ogse.delete_var( "bar_priemnik.quiet" )
end
local ini_file_cache = {}
function cached_ini_file( fname )
if not ini_file_cache[ fname ] then
ini_file_cache[ fname ] = ini_file( fname )
end
return ini_file_cache[ fname ]
end
function start_gtimerDHMS( name, d, h, m, s, fname, ... )
return ogse_st_mgr.delayed_fun_start( name )
:set_gdelayDHMS( d, h, m, s )
:init( fname, ... )
:start()
end
function begin_af_transform( d, h, m, t )
local result = {}
for k, v in pairs( t.result ) do
if dsh.is_artefact( k ) and not t.remove_anomaly then
local prop = amk_utils.get_item_props( k )
if prop.has_af_dyn then
local rand_goods = math.floor(
math.log( handmade_arts_cnt() / 1.7 )
) + 1
if rand_goods > 5 then rand_goods = 5 end
local rand_dyn = get_next_random(
"dsh.begin_af_transform.rand_dyn", rand_goods
)
k = k .. "_dyn" .. rand_dyn .. "d"
end
end
table.insert( result, k )
end
local from_komp = {}
for k, v in pairs( t.komp ) do
table.insert( from_komp, k )
end
start_gtimerDHMS(
nil, d, h, m, 0,
"dsh.end_af_transform",
table.concat( result, "," ),
t.udacha,
t.pos.x, t.pos.y, t.pos.z, t.gv, t.lv,
t.info_portion,
table.concat( from_komp, "," ),
t.remove_anomaly,
t.remove_anomaly_id,
level.name()
)
if table.getn( result ) > 0 and t.udacha and not t.remove_anomaly then
local cnt = ogse.load_var( "dsh.begin_af_transform.cnt", 0 )
ogse.save_var( "dsh.begin_af_transform.cnt", cnt + 1, "u32" )
local tname = "dsh.begin_af_transform.cnt.reset"
if ogse_st_mgr.timer_exists( tname ) then
ogse_st_mgr.get_timer( tname ):stop()
end
ogse_st_mgr.delayed_fun_start( tname )
:set_gdelayDHMS( d, h + math.random( 20 ), m, 0 )
:init( "dsh.reset_af_transform_cnt" )
:start()
end
end
function reset_af_transform_cnt()
ogse.delete_var( "dsh.begin_af_transform.cnt" )
end
function end_af_transform( result, udacha, x, y, z, gv, lv, info, komp, rm_anom, rm_anom_id, lname )
local t = {
[ "udacha" ] = udacha,
[ "pos" ] = {
[ "x" ] = tonumber( x ),
[ "y" ] = tonumber( y ),
[ "z" ] = tonumber( z ),
},
[ "gv" ] = tonumber( gv ),
[ "lv" ] = tonumber( lv ),
[ "info_portion" ] = info,
[ "remove_anomaly" ] = rm_anom,
[ "remove_anomaly_id" ] = tonumber( rm_anom_id ),
[ "lname" ] = lname,
}
if result then
t.result = split_comma_separated_list( result )
else
t.result = {}
end
if komp then
t.komp = split_comma_separated_list( komp )
else
t.komp = {}
end
local rand_goods = math.floor( math.log( handmade_arts_cnt() / 1.7 ) )
if rand_goods > 4 then rand_goods = 4 end
local sobj = amk_mod.af_transform_universal_end( t )
if sobj and udacha and not rm_anom then
sobj = alife():object( sobj.id )
local cnt = ogse.load_var( "dsh.begin_af_transform.cnt", 1 )
local rnd = get_next_random( "dsh.end_af_transform.rnd" )
local iitem = sobj:get_inventory_item()