-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_converter.lua
More file actions
1486 lines (1348 loc) · 48.6 KB
/
Copy pathscript_converter.lua
File metadata and controls
1486 lines (1348 loc) · 48.6 KB
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
--
-- Helper functions
--
-- local function print_tabs(indent)
-- indent = indent or 1
-- _log_newlines_temp = true
-- local _, output = string.rep("\t", indent)
-- _log(output)
-- end
local function print_tabs(indent)
indent = indent or 1
for _ = 1, indent do
_log_newlines_temp = true
_log("\t")
end
end
local function _log_with_indent(indent, ...)
print_tabs(indent)
_log(...)
end
local function get_delay(delay)
if not delay or type(delay) == "number" and delay <= 0 then
return ""
end
return string.format("\t(DELAY %s)", tostring(delay))
end
---@param element table Element object
---@param delay number|boolean? execution delay
---@param indent number?
---@param short boolean?
local function print_element(element, delay, indent, short)
print_tabs(indent)
local header = (short and "") or "Execute element "
local output = string.format(
"%s'%s' [%s] %d from %s%s",
header,
element.name,
element.group,
element.id,
element.event,
get_delay(delay)
)
_log(output)
end
---converts a vector object into a printable string
local function vector_string(vector)
return string.format("(%s, %s, %s)", tostring(vector.x), tostring(vector.y), tostring(vector.z))
end
---converts a rotation object into a printable string
local function rotation_string(rotation)
return string.format(
"(%s, %s, %s)",
tostring(rotation:roll()),
tostring(rotation:pitch()),
tostring(rotation:yaw())
)
end
---@param values string|table Id or table of elements to execute
---@param indent number?
local function perform_element(values, indent)
indent = indent or 1
local execute = type(values) == "table"
local element = elements[execute and values.id or values]
local delay = false
if execute and values.delay > 0 then
delay = values.delay
end
if inline[element.group] then
inline[element.group](element, delay, indent)
return
end
print_element(element, delay, indent)
end
local function print_execution_list(list, indent)
if type(list) ~= "table" then
return
end
-- print_tabs(indent)
for _, values in pairs(list) do
perform_element(values, indent)
end
end
local function print_execution_list_no_recursion(list, group, path, indent)
if type(list) ~= "table" then
return
end
for _, values in pairs(list) do
if elements[values.id].group == group then
inline[group](elements[values.id], values.delay > 0 and values.delay or false, indent, path)
else
perform_element(values, indent)
end
end
end
local print_raw_list = alt()
local print_compact_list = shift()
local module = D and D:module("mission_dumper")
if module then
local tag = print_raw_list and "raw" or print_compact_list and "compact" or "full"
local level_id = tablex.get(Global.game_settings, "level_id") or "apartment"
local current_level = tablex.get({
hospital = "l4d",
heat_street = "street",
diamond_heist = "diamondheist",
slaughter_house = "slaughterhouse",
}, level_id) or level_id
local path = string.format(
"%slevels [%s]/%s_%s.txt",
module:path(),
tag,
current_level,
print_raw_list and "original" or tag
)
_log_global_handle = io.open(path, "w+")
else
_log_global_handle = io.open("mods/log.txt", "w+")
end
local scripts = managers.mission._scripts
if print_raw_list then
_log(scripts)
return
end
elements = {}
unit_ids = {}
-- We keep a stack (FIFO) of (non-inlined) elements to handle
-- We start with the startup script(s)
-- We keep another list to avoid dupes
local elements_to_do = {}
local elements_done = {}
-- Elements which can be inlined into usually at most a few lines
inline = {
["ElementPlayerSpawner"] = function(element, delay, indent)
local values = element.values
local output = string.format(
"Create player spawn at position %s with rotation %s%s",
vector_string(values.position),
rotation_string(values.rotation),
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementFleePoint"] = function(element, delay, indent)
local values = element.values
local output =
string.format("Create flee point at position %s%s", vector_string(values.position), get_delay(delay))
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementAIGraph"] = function(element, delay, indent)
local values = element.values
print_tabs(indent)
local operation = values.operation == "allow_access" and "Allow" or "Forbid"
local output =
string.format("%s AI nav sections %s%s", operation, table.concat(values.graph_ids, ", "), get_delay(delay))
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementSpawnEnemyDummy"] = function(element, delay, indent)
local values = element.values
local output = string.format(
"Spawn enemy unit {%s} at position %s with rotation %s%s",
values.enemy,
vector_string(values.position),
rotation_string(values.rotation),
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementSpawnCivilian"] = function(element, delay, indent)
local values = element.values
local output = string.format(
"Spawn civilian unit {%s} at position %s with rotation %s%s",
values.enemy,
vector_string(values.position),
rotation_string(values.rotation),
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementActivateScript"] = function(element, delay, indent)
local values = element.values
local output = string.format("Activate script '%s'%s", values.activate_script, get_delay(delay))
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementSpecialObjective"] = function(element, delay, indent)
local values = element.values
local target = values.use_instigator and "instigator" or values.ai_group
local delay_str = delay and ("\t(DELAY " .. delay .. ")") or ""
local action_str = (values.so_action ~= "none") and (" with action " .. values.so_action) or ""
local output = ""
if values.is_navigation_link then
output = string.format(
"Create navigation link for %s from position %s to %s%s%s",
target,
vector_string(values.position),
vector_string(values.search_position),
action_str,
delay_str
)
else
local radius_str = (values.search_distance > 0) and (" with radius " .. values.search_distance) or ""
output = string.format(
"Create objective for %s around position %s%s%s%s",
target,
vector_string(values.search_position),
radius_str,
action_str,
delay_str
)
end
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementDebug"] = function(element, delay, indent, path)
path = path or {}
if path[element.id] then
_log_with_indent(indent, "[Loop previous ElementDebug elements]")
return
end
path[element.id] = true
local delay_str = get_delay(delay)
local output = string.format("Print debug string '%s'%s", element.values.debug_string, delay_str)
_log_with_indent(indent, output)
for _, values in pairs(element.values.on_executed) do
if elements[values.id].group == "ElementDebug" then
inline["ElementDebug"](elements[values.id], values.delay > 0 and values.delay, indent, path)
else
perform_element(values, indent)
end
end
end,
["ElementDialogue"] = function(element, delay, indent, path)
path = path or {}
if path[element.id] then
_log_with_indent(indent, "[Loop previous ElementDialogue elements]")
return
end
path[element.id] = true
local values = element.values
local output = string.format("Play dialogue '%s'%s", values.dialogue, get_delay(delay))
_log_with_indent(indent, output)
for _, data in pairs(values.on_executed) do
if elements[data.id].group == "ElementDialogue" then
inline["ElementDialogue"](elements[data.id], data.delay > 0 and data.delay, indent, path)
else
perform_element(data, indent)
end
end
end,
["ElementEnemyPreferedAdd"] = function(element, delay, indent)
local delay_str = delay and ("\t(DELAY " .. delay .. ")") or ""
if delay then
_log_with_indent(indent, string.format("Perform '%s': %s", element.name, delay_str))
end
local sub_indent = delay and (indent + 1) or indent
for _, point in pairs(element._raw._group_data.spawn_points or {}) do
local enemy = point._values.enemy
local action = point._values.spawn_action
local position = vector_string(point._values.position)
_log_with_indent(
sub_indent,
string.format("Add preferred spawn point for {%s} with action %s at %s", enemy, action, position)
)
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementEnemyPreferedRemove"] = function(element, delay, indent)
local values = element.values
for _, id in pairs(values.elements or {}) do
local name = elements[id] and elements[id].name or ("<unknown id: " .. tostring(id) .. ">")
local output =
string.format("Remove all preferred spawn points associated with '%s' %s", name, get_delay(delay))
_log_with_indent(indent, output)
end
print_execution_list(values.on_executed, indent)
end,
["ElementPlaySound"] = function(element, delay, indent)
local values = element.values
local delay_str = get_delay(delay)
if #values.elements > 0 then
_log_with_indent(indent, string.format("Play sound '%s' from units: %s", values.sound_event, delay_str))
for _, id in pairs(values.elements or {}) do
local do_ele = elements[id]
local enemy = do_ele and do_ele.values and do_ele.values.enemy or "<unknown>"
local name = do_ele and do_ele.name or ("<unknown id: " .. tostring(id) .. ">")
_log_with_indent(indent + 1, string.format("- {%s} from element '%s'", enemy, name))
end
else
_log_with_indent(indent, string.format("Play sound '%s'%s", values.sound_event, delay_str))
end
print_execution_list(values.on_executed or {}, indent)
end,
["ElementFakeAssaultState"] = function(element, delay, indent)
local values = element.values
local state = values.state and "Enable" or "Disable"
local output = string.format("%s fake assault state%s", state, get_delay(delay))
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementTeammateComment"] = function(element, delay, indent, path)
path = path or {}
if path[element.id] then
_log_with_indent(indent, "[Loop previous ElementTeammateComment elements]")
return
end
path[element.id] = true
local values = element.values
local output = string.format(
"Make teammates%s say '%s'%s",
values.use_instigator and " close to instigator" or "",
values.comment,
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list_no_recursion(values.on_executed, element.group, path, indent)
end,
["ElementToggle"] = function(element, delay, indent)
local values = element.values
for _, id in pairs(values.elements) do
local do_ele = elements[id]
if do_ele.group == "ElementWaypoint" then
inline["ElementWaypoint"](do_ele, false, delay and indent + 1 or indent, element.values.toggle == "off")
else
local output = string.format(
"Toggle %s element '%s' [%s] %s from %s%s",
values.toggle:upper(),
do_ele.name,
do_ele.group,
do_ele.id,
do_ele.event,
get_delay(delay)
)
_log_with_indent(indent, output)
end
end
print_execution_list(values.on_executed, indent)
end,
["ElementMoney"] = function(element, delay, indent)
local values = element.values
local size = tweak_data.experience_manager.actions[element.values.action]
local points = tweak_data.experience_manager.values[size]
local output = string.format(
"Award players money/experience for action '%s' which is worth %d points",
values.action,
points,
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementAIRemove"] = function(element, delay, indent)
local values = element.values
local delay_str = get_delay(delay)
if values.use_instigator then
_log_with_indent(indent, "Remove/Kill AI instigator from the level" .. delay_str)
else
if delay then
_log_with_indent(indent, string.format("Perform '%s':%s", element.name, delay_str))
end
local sub_indent = delay and (indent + 1) or indent
for _, id in pairs(values.elements or {}) do
local do_ele = elements[id]
local enemy = do_ele and do_ele.values and do_ele.values.enemy or "<unknown>"
local name = do_ele and do_ele.name or ("<unknown id: " .. tostring(id) .. ">")
_log_with_indent(sub_indent, string.format("Remove/Kill unit {%s} from element '%s'", enemy, name))
end
end
print_execution_list(values.on_executed, indent)
end,
["ElementObjective"] = function(element, delay, indent)
local values = element.values
local delay_str = delay and ("\t(DELAY " .. delay .. ")") or ""
local state = values.state:gsub("^%l", string.upper)
local sub_obj = (values.sub_objective ~= "none") and (" with sub-objective '" .. values.sub_objective .. "'")
or ""
local position = vector_string(values.position)
local output = string.format(
"%s objective '%s'%s at position %s %s",
state,
values.objective,
sub_obj,
position,
delay_str
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementWaypoint"] = function(element, delay, indent, remove)
local values = element.values
local delay_str = get_delay(delay)
local action = remove and "Remove" or "Add"
local location_phrase = remove and "from" or "at"
local text = managers.localization:text(values.text_id)
local position = vector_string(values.position)
_log_with_indent(
indent,
string.format(
"%s waypoint with text '%s' and icon %s %s %s %s",
action,
text,
values.icon,
location_phrase,
position,
delay_str
)
)
if remove then
return
end
print_execution_list(values.on_executed, indent)
end,
["ElementDangerZone"] = function(element, delay, indent)
local values = element.values
_log_with_indent(indent, string.format("Set danger zone level to %d%s", values.level, get_delay(delay)))
print_execution_list(values.on_executed, indent)
end,
["ElementDisableUnit"] = function(element, delay, indent)
local values = element.values
local delay_str = get_delay(delay)
if #values.unit_ids == 1 then
local id = values.unit_ids[1]
local unit = unit_ids[id]
local name = unit and unit.name or "<unknown>"
local pos = unit and vector_string(unit.position) or "<no position>"
_log_with_indent(indent, string.format("Disable unit %s {%s} at %s %s", tostring(id), name, pos, delay_str))
print_execution_list(values.on_executed, indent)
else
if delay then
_log_with_indent(indent, string.format("Perform '%s': %s", element.name, delay_str))
end
local sub_tabs = delay and (indent + 1) or indent
for _, id in pairs(values.unit_ids or {}) do
local unit = unit_ids[id]
local name = unit and unit.name or "<unknown>"
local pos = unit and vector_string(unit.position) or "<no position>"
_log_with_indent(sub_tabs, string.format("Disable unit %s {%s} at %s", tostring(id), name, pos))
end
print_execution_list(values.on_executed, sub_tabs)
end
end,
["ElementBlurZone"] = function(element, delay, indent)
local values = element.values
local output = string.format(
"Set blurzone to mode %s with height %s and radius %s at %s%s",
values.mode,
tostring(values.height),
tostring(values.radius),
vector_string(values.position),
get_delay(delay)
)
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementDifficultyLevelCheck"] = function(element, delay, indent)
local values = element.values
local difficulty_map = {
easy = "Easy",
normal = "Normal",
hard = "Hard",
overkill = "Overkill",
overkill_145 = "Overkill 145+",
overkill_193 = "Overkill 193+",
}
local label = difficulty_map[values.difficulty] or values.difficulty
if values.difficulty == "overkill" then
local overkill_or_above = {
difficulty_map["overkill"],
difficulty_map["overkill_145"],
-- difficulty_map["overkill_193"],
}
label = string.format("{%s}", table.concat(overkill_or_above, ", "))
end
_log_with_indent(indent, "If difficulty is " .. label .. " then perform:" .. get_delay(delay))
print_execution_list(values.on_executed, indent + 1)
end,
["ElementMaskFilter"] = function(element, delay, indent)
local values = element.values
local output
if values.mask == "none" then
output = "Remove any applied mask filter" .. get_delay(delay)
else
output = string.format("Change mask filter to '%s'%s", values.mask, get_delay(delay))
end
_log_with_indent(indent, output)
print_execution_list(values.on_executed, indent)
end,
["ElementScenarioEvent"] = function(element, delay, indent)
local values = element.values
local delay_str = get_delay(delay)
local plural = values.amount == 1 and "" or "s"
local msg = string.format(
"%.0f%% base chance with %.0f%% increase to use spawn event with task '%s' %d time%s at position %s%s",
values.base_chance * 100,
values.chance_inc * 100,
values.task,
values.amount,
plural,
vector_string(values.position),
delay_str
)
_log_with_indent(indent, msg)
print_execution_list(values.on_executed, indent)
end,
["ElementOperator"] = function(ele, delay, tabs)
if delay then
_log_with_indent(tabs, "Perform '" .. ele.name .. "':" .. (delay and " \t(DELAY " .. delay .. ")" or ""))
end
for _, id in pairs(ele.values.elements) do
local do_ele = elements[id]
if do_ele.group == "ElementWaypoint" then
inline["ElementWaypoint"](do_ele, false, delay and tabs + 1 or tabs, ele.values.operation == "remove")
else
_log_with_indent(
delay and tabs + 1 or tabs,
(ele.values.operation:gsub("^%l", string.upper))
.. " element '"
.. do_ele.name
.. "' ["
.. do_ele.group
.. "] "
.. do_ele.id
.. " from "
.. do_ele.event
)
end
end
for _, vals in pairs(ele.values.on_executed) do
perform_element(vals, tabs)
end
end,
["ElementAiGlobalEvent"] = function(ele, delay, tabs)
local output = string.format("Trigger global AI event '%s'%s", ele.values.event, get_delay(delay))
_log_with_indent(tabs, output)
print_execution_list(ele.values.on_executed, tabs)
end,
["ElementLogicChance"] = function(element, delay, indent)
-- NOTE: This element should not actually be inlined when compared to the other elements
-- But, since [ElementLogicChanceOperator] gets used so sparingly, making this inlined greatly improves readability
local output =
string.format("Roll the dice with %d%% chance to succeed.%s", element.values.chance, get_delay(delay))
_log_with_indent(indent, output)
local fails = {}
local successes = {}
-- Add on_executed vals as successes by default
for _, vals in pairs(element.values.on_executed or {}) do
table.insert(successes, vals)
end
-- Process raw triggers
for id, vals in pairs(element._raw._triggers or {}) do
if vals.outcome == "success" then
table.insert(successes, id)
elseif vals.outcome == "fail" then
table.insert(fails, id)
end
end
if #successes > 0 then
_log_with_indent(indent, "On success, perform:")
print_execution_list(successes, indent + 1)
end
if #fails > 0 then
_log_with_indent(indent, "On failure, perform:")
print_execution_list(fails, indent + 1)
end
end,
["ElementRandom"] = function(element, delay, indent)
local values = element.values
local output =
string.format("Execute at random %d of the following elements:%s", values.amount, get_delay(delay))
_log_with_indent(indent, output)
for i, data in ipairs(values.on_executed or {}) do
local do_ele = elements[data.id]
local delay_str = get_delay(data.delay)
_log_with_indent(
indent + 1,
string.format(
"%d) '%s' [%s] %d from %s%s",
i,
do_ele.name,
do_ele.group,
do_ele.id,
do_ele.event,
delay_str
)
)
end
end,
["ElementUnitSequence"] = function(element, delay, indent)
if delay then
_log_with_indent(indent, string.format("Perform '%s': %s", element.name, get_delay(delay)))
end
for _, vals in pairs(element.values.trigger_list) do
local id = vals.notify_unit_id
local unit = unit_ids[id]
if vals.name == "run_sequence" then
local delay_str = tonumber(vals.time) > 0 and get_delay(vals.time) or ""
_log_with_indent(
delay and indent + 1 or indent,
string.format(
"Run sequence '%s' on unit %s {%s} at %s %s",
vals.notify_unit_sequence,
id,
unit.name,
vector_string(unit.position),
delay_str
)
-- string.format("Run sequence '%s' on unit {%s} at %s%s", vals.notify_unit_sequence, unit.name, vector_string(unit.position), delay_str)
)
end
end
print_execution_list(element.values.on_executed, delay and indent + 1 or indent)
end,
["ElementFilter"] = function(element, delay, indent)
local values = element.values
local output = {}
local difficulties = {}
if values.difficulty_easy then
table.insert(difficulties, "Easy")
end
if values.difficulty_normal then
table.insert(difficulties, "Normal")
end
if values.difficulty_hard then
table.insert(difficulties, "Hard")
end
if values.difficulty_overkill then
table.insert(difficulties, "Overkill")
end
if values.difficulty_overkill_145 then
table.insert(difficulties, "Overkill 145+")
end
if values.difficulty_overkill_193 then
table.insert(difficulties, "Overkill 193+")
end -- custom difficulty
if #difficulties > 0 then
table.insert(output, string.format("the difficulty is {%s}", table.concat(difficulties, ", ")))
end
local players = {}
if values.player_1 then
table.insert(players, "1")
end
if values.player_2 then
table.insert(players, "2")
end
if values.player_3 then
table.insert(players, "3")
end
if values.player_4 then
table.insert(players, "4")
end
if #players > 0 then
table.insert(output, string.format("the player count is {%s}", table.concat(players, ", ")))
end
local platforms = {}
if values.platform_win32 then
table.insert(platforms, "WIN32")
end
if values.platform_ps3 then
table.insert(platforms, "PS3")
end
if #platforms > 0 then
table.insert(output, string.format("the platform is {%s}", table.concat(platforms, ", ")))
end
local modes = {}
-- mode is only checked if both are not nil
if values.mode_assault ~= nil and values.mode_control ~= nil then
if values.mode_assault then
table.insert(modes, "assault")
end
if values.mode_control then
table.insert(modes, "control")
end
if #modes > 0 then
table.insert(output, string.format("mode is {%s}", table.concat(modes, ", ")))
end
end
-- Final output
if #output == 0 then
_log_with_indent(indent, "Filter is active, but no conditions are set." .. get_delay(delay))
else
_log_with_indent(indent, "If " .. table.concat(output, " and ") .. " then perform:" .. get_delay(delay))
end
print_execution_list(values.on_executed, indent + 1)
end,
["ElementSpawnEnemyGroup"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format(
"Spawn %d enemies in %s %s",
element.values.amount,
element.values.random and "randomly picked spawn points from:" or "the following spawn points:",
get_delay(delay)
)
)
for id, point in pairs(element._raw._group_data.spawn_points) do
_log_with_indent(
indent + 1,
string.format("%s) {%s} at %s", id, point._values.enemy, vector_string(point._values.position))
)
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementSpawnCivilianGroup"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format(
"Spawn %d civilians in %s %s",
element.values.amount,
element.values.random and "randomly picked spawn points from:" or "the following spawn points:",
get_delay(delay)
)
)
for id, point in pairs(element._raw._group_data.spawn_points) do
_log_with_indent(
indent + 1,
string.format("%s) {%s} at %s", id, point._values.enemy, vector_string(point._values.position))
)
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementAwardAchievment"] = function(element, delay, indent)
local achiev = element.values.achievment
local name = managers.challenges._challenges_map[achiev]
local display = name and string.format("Award achievement '%s'", managers.localization:text(name.title_id))
or string.format(
"Award achievement '%s'\t(achievement doesn't exist anymore, probably removed but forgot to edit the map)",
achiev
)
_log_with_indent(indent, string.format("%s %s", display, get_delay(delay)))
print_execution_list(element.values.on_executed, indent)
end,
["ElementCharacterOutline"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format(
"Enable outline for all civilians that have the property 'outline_on_discover' %s",
get_delay(delay)
)
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementCounterReset"] = function(element, delay, indent)
if delay then
_log_with_indent(indent, string.format("Perform '%s': %s", element.name, get_delay(delay)))
end
for _, id in pairs(element.values.elements) do
local name = elements[id] and elements[id].name or ("ID " .. tostring(id))
_log_with_indent(
delay and indent + 1 or indent,
string.format("Reset counter '%s' with counter target %s", name, element.values.counter_target)
)
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementDifficulty"] = function(element, delay, indent)
_log_with_indent(indent, string.format("Set difficulty to %s %s", element.values.difficulty, get_delay(delay)))
print_execution_list(element.values.on_executed, indent)
end,
["ElementDropinState"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format("%s drop-in for players %s", element.values.state and "Enable" or "Disable", get_delay(delay))
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementEquipment"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format(
"Give instigator %d of equipment '%s' %s",
element.values.amount,
element.values.equipment,
get_delay(delay)
)
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementExecuteInOtherMission"] = function(element, delay, indent)
if delay then
_log_with_indent(indent, string.format("Perform '%s': %s", element.name, get_delay(delay)))
end
print_execution_list(element.values.on_executed, delay and indent + 1 or indent)
end,
["ElementFeedback"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format(
"Cause screen shake with%s camera shake and with%s rumble %s",
element.values.use_camera_shake and "" or "out",
element.values.use_rumble and "" or "out",
get_delay(delay)
)
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementHint"] = function(element, delay, indent)
local hint = managers.localization:text(managers.hint:hint(element.values.hint_id).text_id)
_log_with_indent(indent, string.format("Show hint '%s'%s", hint, get_delay(delay)))
print_execution_list(element.values.on_executed, indent)
end,
["ElementKillZone"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format("Create killzone for instigator of damage type '%s'%s", element.values.type, get_delay(delay))
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementLogicChanceOperator"] = function(element, delay, indent)
if delay then
_log_with_indent(indent, string.format("Perform '%s':%s", element.name, get_delay(delay)))
end
local sub_indent = delay and indent + 1 or indent
for _, id in pairs(element.values.elements) do
local target = elements[id].name
local op = element.values.operation
local chance = element.values.chance
if op == "add_chance" then
_log_with_indent(
sub_indent,
string.format("Add chance of %s%% to the logic chance element '%s'", chance, target)
)
elseif op == "subtract_chance" then
_log_with_indent(
sub_indent,
string.format("Subtract chance of %s%% to the logic chance element '%s'", chance, target)
)
elseif op == "reset" then
_log_with_indent(sub_indent, string.format("Reset chance of the logic chance element '%s'", target))
elseif op == "set_chance" then
_log_with_indent(
sub_indent,
string.format("Set the chance of the logic chance element '%s' to %s%%", target, chance)
)
end
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementMissionEnd"] = function(element, delay, indent)
_log_with_indent(
indent,
string.format("End the current level/mission with state '%s'%s", element.values.state, get_delay(delay))
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementPlayEffect"] = function(element, delay, indent)
local position = element.values.screen_space and "on player HUD" or "at position " .. element.values.position
_log_with_indent(
indent,
string.format("Play effect {%s} %s%s", element.values.effect, position, get_delay(delay))
)
print_execution_list(element.values.on_executed, indent)
end,
["ElementStopEffect"] = function(element, delay, indent)
if delay then
_log_with_indent(indent, string.format("Perform '%s':%s", element.name, get_delay(delay)))
end
local sub_indent = delay and indent + 1 or indent
for _, id in pairs(element.values.elements) do
local effect = elements[id].values.effect
local fade = element.values.operation == "fade_kill" and " with fade-out" or ""
_log_with_indent(sub_indent, string.format("Stop effect {%s}%s", effect, fade))
end
print_execution_list(element.values.on_executed, indent)
end,
["ElementPlayerState"] = function(element, delay, indent)
_log_with_indent(indent, string.format("Change player state to '%s'%s", element.values.state, get_delay(delay)))
print_execution_list(element.values.on_executed, indent)
end,
["ElementPointOfNoReturn"] = function(element, delay, indent)
_log_with_indent(indent, string.format("Enable 'Point Of No Return' timer:%s", get_delay(delay)))
_log_with_indent(
indent + 1,
string.format("If difficulty is 'Easy' then set timer to %s seconds", element.values.time_easy)
)
_log_with_indent(
indent + 1,
string.format("If difficulty is 'Normal' then set timer to %s seconds", element.values.time_normal)
)
_log_with_indent(
indent + 1,
string.format("If difficulty is 'Hard' then set timer to %s seconds", element.values.time_hard)
)
_log_with_indent(
indent + 1,
string.format("If difficulty is 'Overkill' then set timer to %s seconds", element.values.time_overkill)
)
_log_with_indent(
indent + 1,
string.format(
"If difficulty is 'Overkill 145+' then set timer to %s seconds",
element.values.time_overkill_145
)
)
print_execution_list(element.values.on_executed, indent)