/
module_mission_templates.py
1381 lines (1268 loc) · 65.6 KB
/
module_mission_templates.py
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
from header_common import *
from header_operations import *
from header_mission_templates import *
from header_animations import *
from header_sounds import *
from header_music import *
from header_items import *
from module_constants import *
import header_debug as dbg
import header_lazy_evaluation as lazy
####################################################################################################################
# Each mission-template is a tuple that contains the following fields:
# 1) Mission-template id (string): used for referencing mission-templates in other files.
# The prefix mt_ is automatically added before each mission-template id.
# 2) Mission-template flags (int): See header_mission-templates.py for a list of available flags.
# 3) Mission-type (int): Which mission types this mission template matches.
# For mission-types to be used with the default party-meeting system,
# this should be 'charge' or 'charge_with_ally' otherwise must be -1.
# 4) Mission description text (string).
#
# 5) List of spawn records (list): Each spawn record is a tuple that contains the following fields:
# 5.1) Entry point number: Troops spawned from this spawn record will use this entry.
# 5.2) Spawn flags.
# 5.3) Alter flags: which equipment will be overriden.
# 5.4) AI flags.
# 5.5) Number of troops to spawn.
# 5.6) List of equipment to add to troops spawned from here (maximum 8).
#
# 6) List of triggers (list): Each trigger contains the following fields:
# 6.1) Check interval: How frequently this trigger will be checked. Also used for special triggers listed in header_triggers.py.
# 6.2) Delay interval: Time to wait before applying the consequences of the trigger after its conditions have been evaluated as true.
# 6.3) Re-arm interval. How much time must pass after applying the consequences of the trigger for the trigger to become active again.
# You can put the constant ti_once here to make sure that the trigger never becomes active again after it fires once.
# 6.4) Conditions block (list), must be a valid operation block. Every time the trigger is checked, this block will be executed.
# If the conditions block returns true or is empty, the consequences block will be executed.
# 6.5) Consequences block (list), must be a valid operation block. Executed only if the conditions block succeeded.
####################################################################################################################
spawn_points_0_99 = [
(0,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(1,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(2,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(3,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(4,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(5,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(6,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(7,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(8,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(9,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(10,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(11,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(12,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(13,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(14,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(15,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(16,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(17,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(18,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(19,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(20,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(21,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(22,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(23,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(24,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(25,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(26,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(27,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(28,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(29,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(30,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(31,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(32,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(33,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(34,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(35,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(36,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(37,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(38,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(39,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(40,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(41,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(42,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(43,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(44,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(45,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(46,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(47,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(48,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(49,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(50,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(51,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(52,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(53,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(54,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(55,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(56,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(57,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(58,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(59,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(60,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(61,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(62,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(63,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(64,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(65,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(66,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(67,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(68,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(69,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(70,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(71,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(72,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(73,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(74,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(75,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(76,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(77,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(78,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(79,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(80,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(81,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(82,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(83,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(84,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(85,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(86,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(87,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(88,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(89,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(90,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(91,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(92,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(93,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(94,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(95,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(96,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(97,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(98,mtef_visitor_source,0,aif_start_alarmed,1,[]),
(99,mtef_visitor_source,0,aif_start_alarmed,1,[]),
]
before_mission_start_setup = (ti_before_mission_start, 0, 0, [], # set up basic mission and scene values
[(server_set_friendly_fire, 1),
(server_set_melee_friendly_fire, 1),
(server_set_friendly_fire_damage_self_ratio, 0),
(server_set_friendly_fire_damage_friend_ratio, 100),
(try_begin),
(eq, "$g_game_type", "mt_multiplayer_dm"),
(multiplayer_make_everyone_enemy),#necessary to hide the white name labels on the middle
(else_try),
(team_set_relation, team_default, team_default, -1),
(team_set_relation, team_default, team_spawn_invulnerable, 0),
(team_set_relation, team_spawn_invulnerable, team_default, 0),
(team_set_relation, team_spawn_invulnerable, team_spawn_invulnerable, 0),
(try_end),
(call_script, "script_initialize_scene_globals"),
(call_script, "script_scene_set_day_time"),
(call_script, "script_scene_setup_factions_castles"),
(call_script, "script_setup_all_linked_scene_props"),
(try_begin),
(multiplayer_is_server),
(call_script, "script_setup_castle_money_chests"),
(else_try),
(call_script, "script_load_profile_options"),
(try_end),
(assign, "$skybox_current", -1),
(assign, "$g_last_lighting_update_time", -1),
(try_begin),
(lt, "$g_day_duration", 1),
(assign, "$g_day_duration", hours(0.5)),
(store_div, "$g_in_game_hour_in_seconds", "$g_day_duration", 24),
(try_end),
(try_begin),
(lt, "$g_skybox_scale", 1),
(assign, "$g_skybox_scale", skybox_scale),
(try_end),
])
after_mission_start_setup = (ti_after_mission_start, 0, 0, [], # spawn and move certain things after most other set up is done
[(set_spawn_effector_scene_prop_kind, 0, -1),
(set_spawn_effector_scene_prop_kind, 1, -1),
(assign, "$g_preset_message_display_enabled", 0),
(multiplayer_is_server),
(assign, "$g_next_scene", -1),
(call_script, "script_setup_ship_collision_props"),
(call_script, "script_setup_scene_props_after_mission_start"),
(init_position, pos1),
(set_spawn_position, pos1), # spawn a respawn position marker scene prop for each possible player
(server_get_max_num_players, "$g_spawn_marker_count"),
(val_add, "$g_spawn_marker_count", 1),
(try_for_range, ":unused", 0, "$g_spawn_marker_count"),
(spawn_scene_prop, "spr_code_spawn_marker"),
(try_end),
(assign, "$g_spawned_bot_count", 0),
(call_script, "script_check_name_server"),
(try_for_range, ":faction_id", castle_factions_begin, factions_end),
(try_for_range, ":target_faction_id", castle_factions_begin, factions_end),
(neq, ":faction_id", ":target_faction_id"),
(call_script, "script_cf_faction_change_relation", ":faction_id", ":target_faction_id", 1),
(try_end),
(try_end),
#Spawn SRP Skyboxes if wanted
(try_begin),
(eq, "$g_day_night_cycle_enabled", 1),
(multiplayer_is_server),
(call_script, "script_skybox_spawn_all"),
(try_end),
])
player_joined = (ti_server_player_joined, 0, 0, [], # server: handle connecting players
[(store_trigger_param_1, ":player_id"),
(call_script, "script_setup_player_joined", ":player_id"),
(call_script, "script_player_check_name", ":player_id"),
(call_script, "script_update_ghost_mode_rule", ":player_id"),
(call_script, "script_apply_mute", ":player_id", "$g_mute_all_players"),
])
player_exit = (ti_on_player_exit, 0, 0, [], # server: save player values on exit
[(store_trigger_param_1, ":player_id"),
(call_script, "script_cf_save_player_exit", ":player_id"),
(str_store_player_username, s1, ":player_id"),
(player_get_unique_id, reg0, ":player_id"),
(server_add_message_to_log, "str_s1_has_left_the_game_with_id_reg0"),
(call_script, "script_log_equipment", ":player_id"),
])
agent_spawn = (ti_on_agent_spawn, 0, 0, [], # server and clients: set up new agents after they spawn
[(store_trigger_param_1, ":agent_id"),
(call_script, "script_on_agent_spawned", ":agent_id"),
(call_script, "script_death_cam_off", ":agent_id"),
(try_begin),
(multiplayer_is_server),
(neg|agent_is_non_player, ":agent_id"),
(agent_get_player_id, ":player_id", ":agent_id"),
(player_get_slot, ":first_spawn_occured", ":player_id", slot_player_first_spawn_occured),
(neq, ":first_spawn_occured", 1),
(player_set_slot, ":player_id", slot_player_first_spawn_occured, 1),
(try_begin),
(this_or_next|player_slot_eq, ":player_id", slot_player_is_lord, 1),
(player_slot_eq, ":player_id", slot_player_is_marshal, 1),
(call_script, "script_synchronize_lord_or_marshal", ":player_id"),
(try_end),
(call_script, "script_log_equipment", ":player_id"),
(call_script, "script_setup_singings", ":player_id"),
(try_end),
(try_begin),
(multiplayer_is_server),
(neg|agent_is_non_player, ":agent_id"),
(agent_get_player_id, ":player_id", ":agent_id"),
(player_get_slot, ":faction_id", ":player_id", slot_player_faction_id),
(faction_slot_eq, ":faction_id", slot_faction_is_active, 0),
(call_script, "script_change_faction", ":player_id", "fac_commoners", change_faction_type_no_respawn),
(call_script, "script_player_set_worse_respawn_troop", ":player_id", "trp_peasant"),
(multiplayer_send_3_int_to_player, ":player_id", server_event_preset_message, "str_inactive_faction_change", preset_message_chat_log|preset_message_red, ":faction_id"),
(try_end),
])
agent_killed = (ti_on_agent_killed_or_wounded, 0, 0, [], # server and clients: handle messages, score, loot, and more after agents die
[(store_trigger_param_1, ":dead_agent_id"),
(store_trigger_param_2, ":killer_agent_id"),
(try_begin), # put person in other team is spectator is disabled to prevent player click through
(agent_get_player_id, ":player_id", ":dead_agent_id"),
(player_is_active, ":player_id"),
(try_begin),
(server_get_ghost_mode, ":spectator_is_enabled"),
(ge, ":spectator_is_enabled", 2),
(neg | player_is_admin, ":player_id"),
(player_set_team_no, ":player_id", 3),
(try_end),
(try_end),
(call_script, "script_client_check_show_respawn_time_counter", ":dead_agent_id"),
(call_script, "script_death_cam", ":dead_agent_id"),
(call_script, "script_apply_consequences_for_agent_death", ":dead_agent_id", ":killer_agent_id"),
(multiplayer_is_server),
(call_script, "script_setup_agent_for_respawn", ":dead_agent_id"),
(call_script, "script_check_animal_killed", ":dead_agent_id", ":killer_agent_id"),
(call_script, "script_check_spawn_bots", ":dead_agent_id"),
])
agent_hit = (ti_on_agent_hit, 0, 0, [], # server: apply extra scripted effects for special weapons, hitting animals, and when overloaded by armor
[(store_trigger_param_1, ":attacked_agent_id"),
(store_trigger_param_2, ":attacker_agent_id"),
(store_trigger_param_3, ":damage_dealt"),
(try_begin), # check if damage should bleed through the armor due to unmet requirements
(agent_slot_ge, ":attacked_agent_id", slot_agent_armor_damage_through, 5),
(agent_get_slot, ":damage_through_multiplier", ":attacked_agent_id", slot_agent_armor_damage_through),
(gt, reg0, -1),
(item_get_slot, ":damage_through", reg0, slot_item_max_raw_damage),
(val_mul, ":damage_through", ":damage_through_multiplier"),
(val_div, ":damage_through", 100),
(gt, ":damage_through", ":damage_dealt"),
(store_random_in_range, ":damage_through", ":damage_dealt", ":damage_through"),
(set_trigger_result, ":damage_through"),
(try_end),
(try_begin),
(agent_slot_ge, ":attacked_agent_id", slot_agent_animal_birth_time, 1),
(call_script, "script_animal_hit", ":attacked_agent_id", ":attacker_agent_id", ":damage_dealt", reg0),
(try_end),
(try_begin),
(is_between, reg0, scripted_items_begin, scripted_items_end),
(call_script, "script_agent_hit_with_scripted_item", ":attacked_agent_id", ":attacker_agent_id", ":damage_dealt", reg0),
(try_end),
(try_begin),
(eq, reg0, "itm_baton"),
(set_trigger_result, 0),
(neg|agent_is_non_player, ":attacked_agent_id"),
(agent_set_animation, ":attacked_agent_id", "anim_strike_fall_back_rise", 0),
(agent_get_player_id, ":player_id", ":attacked_agent_id"),
(player_get_gender, ":gender", ":player_id"),
(try_begin),
(gt, ":gender", 0),#woman
(agent_play_sound, ":attacked_agent_id", "snd_woman_hit"),
(else_try),
(agent_play_sound, ":attacked_agent_id", "snd_man_hit"),
(try_end),
(try_end),
(try_begin),
(neg|agent_is_non_player, ":attacked_agent_id"),
(agent_get_player_id, ":player_id", ":attacked_agent_id"),
(call_script, "script_toggle_walk", ":player_id", 1, 0),
(try_end),
(call_script, "script_log_hit", ":attacked_agent_id", ":attacker_agent_id", ":damage_dealt", reg0, 0),
])
item_picked_up = (ti_on_item_picked_up, 0, 0, [], # handle agents picking up an item
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":item_id"),
(store_trigger_param_3, ":instance_id"),
(call_script, "script_agent_calculate_stat_modifiers_for_item", ":agent_id", ":item_id", 1, 1),
(multiplayer_is_server),
(call_script, "script_check_on_item_picked_up", ":agent_id", ":item_id", ":instance_id"),
])
item_dropped = (ti_on_item_dropped, 0, 0, [], # handle agents dropping an item
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":item_id"),
(store_trigger_param_3, ":instance_id"),
(call_script, "script_agent_calculate_stat_modifiers_for_item", ":agent_id", ":item_id", 0, 1),
(multiplayer_is_server),
(call_script, "script_check_on_item_dropped", ":agent_id", ":item_id", ":instance_id", 0),
])
item_wielded = (ti_on_item_wielded, 0, 0, [], # handle agents wielding an item
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":item_id"),
(call_script, "script_agent_calculate_stat_modifiers_for_item", ":agent_id", ":item_id", 1, 1),
(call_script, "script_check_wielding_during_position_animation", ":agent_id", ":item_id"),
])
item_unwielded = (ti_on_item_unwielded, 0, 0, [], # handle agents un-wielding an item
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":item_id"),
(call_script, "script_agent_calculate_stat_modifiers_for_item", ":agent_id", ":item_id", 0, 1),
])
agent_mount = (ti_on_agent_mount, 0, 0, [], # server: check speed factor and attached carts when agents mount a horse
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":horse_agent_id"),
(agent_set_slot, ":horse_agent_id", slot_agent_horse_last_rider, ":agent_id"),
(agent_set_slot, ":agent_id", slot_agent_last_horse_ridden, ":horse_agent_id"),
(multiplayer_is_server),
(call_script, "script_check_agent_horse_speed_factor", ":agent_id", ":horse_agent_id", 0),
(try_begin),
(call_script, "script_cf_attach_cart", ":agent_id", -1, ":agent_id"),
(try_end),
(agent_get_player_id, ":player_id", ":agent_id"),
(str_store_player_username, s0, ":player_id"),
(agent_get_item_id, ":horse_item_id", ":horse_agent_id"),
(str_store_item_name, s1, ":horse_item_id"),
#Alter mount/dismount logs to show the agent_id of the mount
(assign, reg31, ":horse_agent_id"),
(server_add_message_to_log, "str_s0_has_mounted_a_s1"),
])
agent_dismount = (ti_on_agent_dismount, 0, 0, [], # server: make horses stand still after being dismounted from
[(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":horse_agent_id"),
(agent_set_slot, ":horse_agent_id", slot_agent_horse_last_rider, ":agent_id"),
(agent_set_slot, ":agent_id", slot_agent_last_horse_ridden, ":horse_agent_id"),
(multiplayer_is_server),
(agent_get_position, pos1, ":horse_agent_id"),
(agent_set_scripted_destination, ":horse_agent_id", pos1, 0),
(agent_get_player_id, ":player_id", ":agent_id"),
(str_store_player_username, s0, ":player_id"),
(agent_get_item_id, ":horse_item_id", ":horse_agent_id"),
(str_store_item_name, s1, ":horse_item_id"),
#Alter mount/dismount logs to show the agent_id of the mount
(assign, reg31, ":horse_agent_id"),
(server_add_message_to_log, "str_s0_has_dismounted_a_s1"),
])
instrument_check = (2, 0, 0, [], # server: handle agents playing instruments
[(multiplayer_is_server),
(call_script, "script_cf_check_musical_instrument"),
])
instrument_killed = (ti_on_agent_killed_or_wounded, 0, 0, [], # handle instruments
[(store_trigger_param_1, ":dead_agent_id"),
(call_script, "script_client_stop_playing_musical_instrument", ":dead_agent_id"),
])
instrument_unwielded = (ti_on_item_unwielded, 0, 0, [], # handle instruments
[(store_trigger_param_1, ":agent_id"),
(call_script, "script_cf_stop_playing_musical_instrument", ":agent_id"),
(eq,reg20,1),
(call_script, "script_client_stop_playing_musical_instrument", ":agent_id"),
])
instrument_dropped = (ti_on_item_dropped, 0, 0, [], # handle instruments
[(store_trigger_param_1, ":agent_id"),
(call_script, "script_cf_stop_playing_musical_instrument", ":agent_id"),
(eq,reg20,1),
(call_script, "script_client_stop_playing_musical_instrument", ":agent_id"),
])
instrument_with_sheild_wield = (ti_on_item_wielded, 0, 0, [], # handle instruments
[(store_trigger_param_1, ":agent_id"),
(agent_get_wielded_item, ":r_item_id", ":agent_id", 0),
(this_or_next|eq, ":r_item_id", "itm_lute"),
(eq, ":r_item_id", "itm_lyre"),
(agent_get_wielded_item, ":item_id", ":agent_id", 1),
(gt, ":item_id", all_items_begin),
(item_get_type, ":item_type", ":item_id"),
(eq, ":item_type", itp_type_shield),
(agent_set_wielded_item, ":agent_id", -1),
(agent_set_wielded_item, ":agent_id", ":r_item_id"),
])
instrument_with_sheild_pickup = (ti_on_item_picked_up, 0, 0, [], # handle instruments
[(store_trigger_param_1, ":agent_id"),
(agent_get_wielded_item, ":r_item_id", ":agent_id", 0),
(this_or_next|eq, ":r_item_id", "itm_lute"),
(eq, ":r_item_id", "itm_lyre"),
(agent_get_wielded_item, ":item_id", ":agent_id", 1),
(gt, ":item_id", all_items_begin),
(item_get_type, ":item_type", ":item_id"),
(eq, ":item_type", itp_type_shield),
(agent_set_wielded_item, ":agent_id", -1),
(agent_set_wielded_item, ":agent_id", ":r_item_id"),
])
player_check_loop = (0, 0, 0.5, # server: check all players to see if any need agents spawned, also periodically lowering outlaw ratings
[(multiplayer_is_server),
(store_mission_timer_a, ":time"),
(get_max_players, ":max_players"),
(assign, ":loop_end", ":max_players"),
(try_for_range, ":player_id", "$g_loop_player_id", ":loop_end"), # continue from the last player id checked
(player_is_active, ":player_id"),
(player_get_slot, ":kick_at_time", ":player_id", slot_player_kick_at_time),
(try_begin), # kick after an interval if rejected by the name server
(gt, ":kick_at_time", 0),
(try_begin),
(ge, ":time", ":kick_at_time"),
(kick_player, ":player_id"),
(try_end),
(else_try),
(try_begin),
(this_or_next|player_slot_eq, ":player_id", slot_player_spawn_state, player_spawn_state_dead),
(player_slot_eq, ":player_id", slot_player_spawn_state, player_spawn_state_invulnerable),
(call_script, "script_cf_player_check_spawn_agent", ":player_id"),
(assign, ":loop_end", -1), # if the spawn checks were run, end the loop to give other triggers a chance to run, then immediately continue
(store_add, "$g_loop_player_id", ":player_id", 1),
(try_end),
(try_begin),
(eq, "$g_loop_player_check_outlaw", 1),
(player_get_slot, ":outlaw_rating", ":player_id", slot_player_outlaw_rating),
(try_begin),
(gt, ":outlaw_rating", 0),
(val_sub, ":outlaw_rating", 1),
(player_set_slot, ":player_id", slot_player_outlaw_rating, ":outlaw_rating"),
(multiplayer_send_3_int_to_player, ":player_id", server_event_player_set_slot, ":player_id", slot_player_outlaw_rating, ":outlaw_rating"),
(try_end),
(try_end),
(try_begin),
(player_is_active, ":player_id"),
(player_get_slot, ":suicide_at_time", ":player_id", slot_player_commit_suicide_time),
(try_begin),
(gt, ":suicide_at_time", 0),
(try_begin),
(ge, ":time", ":suicide_at_time"),
(player_get_agent_id, ":agent_id", ":player_id"),
(agent_deliver_damage_to_agent, ":agent_id", ":agent_id", 500),
(str_store_player_username, s1, ":player_id"),
(server_add_message_to_log, "str_log_s1_committed_suicide"),
(player_set_slot, ":player_id", slot_player_commit_suicide_time, 0),
(try_end),
(try_end),
(try_end),
(try_end),
(try_end),
(eq, ":loop_end", ":max_players"), # if all players were checked, the trigger will succeed and wait the rearm interval before checking again
(assign, "$g_loop_player_id", 1), # go back to the start (player id 0 is the server)
(try_begin), # only decrease outlaw ratings at certain intervals, not every time
(ge, ":time", "$g_loop_player_check_outlaw_time"),
(val_add, "$g_loop_player_check_outlaw_time", loop_player_check_outlaw_interval),
(assign, "$g_loop_player_check_outlaw", 1),
(else_try),
(assign, "$g_loop_player_check_outlaw", 0),
(try_end),
], [])
agent_check_loop = (0, 0, 0.5, # server: loop over all agents, doing all common repetitive checks together for each agent, to minimize the penalty of using try_for_agents
[(multiplayer_is_server),
(try_begin), # if the loop was not restarted
(gt, "$g_loop_agent_last_checked", -2),
(assign, ":agent_id", -1),
(try_for_agents, ":loop_agent_id"), # find the next agent id greater than the previous checked
(eq, ":agent_id", -1),
(gt, ":loop_agent_id", "$g_loop_agent_last_checked"),
(assign, ":agent_id", ":loop_agent_id"),
(try_end),
(try_begin),
(gt, ":agent_id", -1), # if a next agent id was found
(assign, "$g_loop_agent_last_checked", ":agent_id"),
(call_script, "script_check_agent_drowning", ":agent_id"),
(try_begin),
(eq, "$g_loop_horse_check", 1),
(try_begin),
(neg|agent_is_human, ":agent_id"),
(call_script, "script_check_remove_lost_horse", ":agent_id"),
(else_try),
(call_script, "script_agent_remove_empty_ammo_stacks", ":agent_id"),
(try_end),
(try_end),
(try_begin),
(eq, "$g_loop_health_check", 1),
(call_script, "script_check_agent_health", ":agent_id"),
(try_end),
(else_try),
(assign, "$g_loop_agent_last_checked", -2),
(try_end),
(else_try), # setting up to restart the loop
(store_mission_timer_a, ":time"),
(try_begin),
(ge, ":time", "$g_loop_agent_check_time"),
(val_add, "$g_loop_agent_check_time", loop_agent_check_interval),
(assign, "$g_loop_agent_last_checked", -1), # set to an invalid low agent id to start
(try_begin),
(ge, ":time", "$g_loop_horse_check_time"),
(val_add, "$g_loop_horse_check_time", loop_horse_check_interval),
(assign, "$g_loop_horse_check", 1),
(else_try),
(assign, "$g_loop_horse_check", 0),
(try_end),
(try_begin),
(ge, ":time", "$g_loop_health_check_time"),
(val_add, "$g_loop_health_check_time", loop_health_check_interval),
(assign, "$g_loop_health_check", 1),
(else_try),
(assign, "$g_loop_health_check", 0),
(try_end),
(try_end),
(try_end),
(eq, "$g_loop_agent_last_checked", -2), # at the end of the loop, the trigger succeeds to wait the rearm interval before restarting
], [])
agent_check_attack_loop = (0, 0, 0.2, [], # server: repeatedly check all agents for attacking with a weapon they can't use - should be kept as simple as possible
[(multiplayer_is_server),
(try_for_agents, ":agent_id"),
(agent_slot_eq, ":agent_id", slot_agent_cannot_attack, 1),
(agent_get_attack_action, ":action", ":agent_id"),
(is_between, ":action", 1, 7), # if the agent attack action is anything except "free" or "cancelling attack", unwield the weapon
(agent_set_wielded_item, ":agent_id", -1),
(try_end),
])
ship_movement_loop = (0, 0, 0.1, # server: update ship movement animations approximately every second
[(try_begin),
(multiplayer_is_server),
(troop_get_slot, ":ship_array_end", "trp_ship_array", slot_ship_array_count),
(gt, ":ship_array_end", 0),
(try_begin), # after running the script for a moving ship, end the loop to allow other triggers to run, then immediately continue the loop
(ge, "$g_loop_ship_to_check", slot_ship_array_begin),
(val_add, ":ship_array_end", slot_ship_array_begin),
(assign, ":loop_end", ":ship_array_end"),
(try_for_range, ":ship_slot", "$g_loop_ship_to_check", ":loop_end"),
(troop_get_slot, ":hull_instance_id", "trp_ship_array", ":ship_slot"),
(scene_prop_slot_eq, ":hull_instance_id", slot_scene_prop_state, scene_prop_state_active),
(try_begin), # if all possible movement slots make the ship stationary, skip
(scene_prop_slot_eq, ":hull_instance_id", slot_scene_prop_position, 0),
(scene_prop_slot_eq, ":hull_instance_id", slot_scene_prop_target_position, 0),
(scene_prop_get_slot, ":ramp_instance_id", ":hull_instance_id", slot_scene_prop_linked_ramp),
(try_begin),
(neq, ":ramp_instance_id", -1),
(scene_prop_get_slot, ":ramp_position", ":ramp_instance_id", slot_scene_prop_position),
(scene_prop_slot_eq, ":ramp_instance_id", slot_scene_prop_target_position, ":ramp_position"),
(assign, ":ramp_instance_id", -1),
(try_end),
(eq, ":ramp_instance_id", -1),
(else_try), # otherwise, move the ship
(call_script, "script_move_ship", ":hull_instance_id"),
(assign, ":loop_end", -1),
(try_end),
(try_end),
(store_add, "$g_loop_ship_to_check", ":ship_slot", 1),
(try_begin),
(ge, "$g_loop_ship_to_check", ":ship_array_end"),
(assign, "$g_loop_ship_to_check", -1),
(try_end),
(else_try),
(store_mission_timer_a, ":time"),
(try_begin), # recheck the time every 0.1 seconds, but only move the ships every 1 second, so small extra delays in the trigger timer don't accumulate
(ge, ":time", "$g_loop_ship_check_time"),
(val_add, "$g_loop_ship_check_time", 1),
(val_sub, ":time", 1),
(val_max, "$g_loop_ship_check_time", ":time"),
(assign, "$g_loop_ship_to_check", slot_ship_array_begin),
(try_end),
(try_end),
(try_end),
(this_or_next|eq, "$g_loop_ship_to_check", -1),
(this_or_next|neg|multiplayer_is_server),
(eq, ":ship_array_end", 0),
], [])
resource_regrow_check = (10, 0, 0, [], # server: call the script to regrow a removed scene prop after the required time
[(multiplayer_is_server),
(troop_get_slot, ":resources_count", "trp_removed_scene_props", slot_array_count),
(gt, ":resources_count", 0),
(val_add, ":resources_count", slot_array_begin),
(try_for_range, ":resource_slot", slot_array_begin, ":resources_count"), # loop over all scene props added to the removed list
(troop_get_slot, ":instance_id", "trp_removed_scene_props", ":resource_slot"),
(le, ":instance_id", 0),
(else_try),
(scene_prop_get_slot, ":regrow_script", ":instance_id", slot_scene_prop_regrow_script),
(eq, ":regrow_script", 0),
(neg|scene_prop_slot_eq, ":instance_id", slot_scene_prop_state, scene_prop_state_hidden),
(troop_set_slot, "trp_removed_scene_props", ":resource_slot", -1),
(else_try),
(scene_prop_get_slot, ":regen_time", ":instance_id", slot_scene_prop_state_time),
(store_mission_timer_a, ":time"),
(ge, ":time", ":regen_time"), # if the regeneration time is passed, remove from the list and call the stored script
(troop_set_slot, "trp_removed_scene_props", ":resource_slot", -1),
(try_begin),
(eq, ":regrow_script", 0),
(call_script, "script_regrow_resource", ":instance_id"),
(else_try),
(call_script, ":regrow_script", ":instance_id"),
(try_end),
(try_end),
])
polls_check = (2, 0, 0, [], # server: regularly check to see if any polls have ended
[(multiplayer_is_server),
(call_script, "script_check_polls_ended"),
])
game_ended_check = (1, 5, 0, # server: check for game end from victory or an admin scene change
[(multiplayer_is_server),
(eq, "$g_game_ended", 0),
(store_mission_timer_a, ":current_time"),
(store_mul, ":game_end_time", "$g_game_time_limit", 60),
(try_begin), # check for the victory condition
(call_script, "script_cf_victory_condition_met"),
(assign, ":faction_id", reg0),
(try_begin), # if only just met, store the time when the game could end
(le, "$g_victory_condition_time", 0),
(store_mul, "$g_victory_condition_time", "$g_victory_condition", 60),
(val_add, "$g_victory_condition_time", ":current_time"),
(else_try),
(gt, "$g_victory_condition_time", 0),
(this_or_next|ge, ":current_time", "$g_victory_condition_time"), # if the victory condition has held for the required time, end the game
(ge, ":current_time", ":game_end_time"),
(get_max_players, ":max_players"),
(try_for_range, ":player_id", 1, ":max_players"),
(player_is_active, ":player_id"),
(multiplayer_send_3_int_to_player, ":player_id", server_event_preset_message, "str_s1_reign_supreme", preset_message_faction|preset_message_big|preset_message_log, ":faction_id"),
(try_end),
(assign, "$g_game_ended", 1),
(try_end),
(else_try), # reset the victory condition timer
(assign, "$g_victory_condition_time", 0),
(try_end),
(this_or_next|eq, "$g_game_ended", 1),
(this_or_next|is_between, "$g_next_scene", scenes_begin, scenes_end), # end the mission if an admin changes the scene
(ge, ":current_time", ":game_end_time"),
(assign, "$g_game_ended", 1),
],
[(try_begin), # after the delay, start the next mission
(neg|is_between, "$g_next_game_type", game_type_mission_templates_begin, game_type_mission_templates_end),
(assign, "$g_next_game_type", game_type_mission_templates_begin),
(try_end),
(assign, ":started_manually", 1),
(try_begin),
(neg|is_between, "$g_next_scene", scenes_begin, scenes_end),
(assign, "$g_next_scene", scenes_begin),
(assign, ":started_manually", 0),
(try_end),
(start_multiplayer_mission, "$g_next_game_type", "$g_next_scene", ":started_manually"),
(call_script, "script_game_set_multiplayer_mission_end"),
])
draw_initial_banners = (0, 0, ti_once, [], # server: calculate and draw all castle banners at mission start
[(multiplayer_is_server),
(call_script, "script_redraw_castle_banners", redraw_all_banners, -1),
])
fill_chests_starting_inventory = (8, 0, ti_once, [], # server: wait so the pseudo random number generator can get some entropy
[(multiplayer_is_server),
(eq, random_gear_in_chests, 1),
(call_script, "script_scene_fill_chests_starting_inventory"),
])
fire_place_check = (1, 0, 60, # server: wait 1 second between checks of fire heaps, then 60 seconds after all have been checked
[(multiplayer_is_server),
(scene_prop_get_instance, ":instance_id", "spr_pw_fire_wood_heap", "$g_fire_place_instance_no"),
(call_script, "script_fire_place_burn", ":instance_id"),
(val_add, "$g_fire_place_instance_no", 1),
(scene_prop_get_num_instances, ":num_instances", "spr_pw_fire_wood_heap"),
(try_begin),
(ge, "$g_fire_place_instance_no", ":num_instances"),
(assign, "$g_fire_place_instance_no", 0),
(try_end),
(eq, "$g_fire_place_instance_no", 0),
], [])
fish_school_loop = (0.1, 0, 30, # server: wait 0.1 seconds between checks of fish schools, then 30 seconds after all have been checked
[(multiplayer_is_server),
(try_begin),
(scene_prop_get_instance, ":instance_id", "spr_pw_fish_school", "$g_fish_school_instance_no"),
(call_script, "script_move_fish_school", ":instance_id"),
(val_add, "$g_fish_school_instance_no", 1),
(else_try), # at the loop end, check all nets as well
(assign, "$g_fish_school_instance_no", 0),
(call_script, "script_check_fishing_nets"),
(try_end),
(eq, "$g_fish_school_instance_no", 0),
], [])
herd_leader_movement_loop = (5, 0, 0, [], # server: check all animal herd leaders to see if any are ready to move
[(multiplayer_is_server),
(le, "$g_loop_animal_herd_begin", 0), # not currently moving a herd
(scene_spawned_item_get_num_instances, ":herds_end", "itm_animal_herd_manager"),
(try_begin),
(ge, "$g_loop_animal_herd_to_move", ":herds_end"),
(assign, "$g_loop_animal_herd_to_move", 0),
(try_end),
(store_mission_timer_a, ":time"), # loop over next herd managers to check if any are ready to move
(try_for_range, "$g_loop_animal_herd_to_move", "$g_loop_animal_herd_to_move", ":herds_end"),
(scene_spawned_item_get_instance, ":herd_manager", "itm_animal_herd_manager", "$g_loop_animal_herd_to_move"),
(assign, "$g_loop_animal_herd_leader", -1),
(scene_prop_get_slot, ":adult_item_id", ":herd_manager", slot_animal_herd_manager_adult_item_id),
(item_get_slot, ":loop_end", ":adult_item_id", slot_item_animal_max_in_herd),
(try_for_range, ":herd_slot", 0, ":loop_end"), # loop over animals in the herd
(scene_prop_get_slot, ":herd_agent_id", ":herd_manager", ":herd_slot"),
(gt, ":herd_agent_id", -1),
(try_begin),
(agent_is_active, ":herd_agent_id"),
(agent_get_item_id, ":herd_item_id", ":herd_agent_id"),
(agent_slot_eq, ":herd_agent_id", slot_agent_animal_herd_manager, ":herd_manager"),
(gt, ":herd_item_id", -1),
(item_slot_eq, ":herd_item_id", slot_item_animal_adult_item_id, ":adult_item_id"),
(try_begin), # if the leader has been found, set the times for the followers to move
(neq, "$g_loop_animal_herd_leader", -1),
(store_random_in_range, ":move_time", 0, 6),
(val_add, ":move_time", ":time"),
(agent_set_slot, ":herd_agent_id", slot_agent_animal_move_time, ":move_time"),
(else_try), # the first valid animal found is the leader: start the movement if the set time is met
(assign, "$g_loop_animal_herd_leader", ":herd_agent_id"),
(neg|agent_slot_ge, ":herd_agent_id", slot_agent_animal_move_time, ":time"),
(assign, ":herds_end", -1), # break out of the herd manager checking loop after the animal loop is finished
(store_add, "$g_loop_animal_herd_begin", ":herd_slot", 1),
(store_random_in_range, ":move_time", 5, 31), # set the next move time
(val_add, ":move_time", ":time"),
(agent_set_slot, "$g_loop_animal_herd_leader", slot_agent_animal_move_time, ":move_time"),
(call_script, "script_animal_move", "$g_loop_animal_herd_leader", "$g_loop_animal_herd_leader"), # move the leader
(else_try), # if the leader movement time is not met, skip to the next herd manager to check
(assign, ":loop_end", -1),
(try_end),
(else_try), # if the animal or agent id is not valid, remove it from the herd manager
(scene_prop_set_slot, ":herd_manager", ":herd_slot", -1),
(agent_is_active, ":herd_agent_id"),
(le, ":herd_item_id", -1),
(agent_set_slot, ":herd_agent_id", slot_agent_animal_herd_manager, -1),
(try_end),
(try_end),
(try_begin), # if no valid animals are found, remove the herd manager
(eq, "$g_loop_animal_herd_leader", -1),
(scene_prop_set_prune_time, ":herd_manager", 1),
(try_end),
(try_end),
])
herd_follower_movement_loop = (0.5, 0, 0, [], # server: when currently moving a herd, check the follower animals for any ready to move
[(multiplayer_is_server),
(gt, "$g_loop_animal_herd_begin", 0), # currently moving a herd
(try_begin), # if the herd leader and manager are valid
(agent_is_active, "$g_loop_animal_herd_leader"),
(scene_spawned_item_get_instance, ":herd_manager", "itm_animal_herd_manager", "$g_loop_animal_herd_to_move"),
(store_mission_timer_a, ":time"),
(scene_prop_get_slot, ":adult_item_id", ":herd_manager", slot_animal_herd_manager_adult_item_id),
(item_get_slot, ":loop_end", ":adult_item_id", slot_item_animal_max_in_herd),
(assign, ":remaining_to_move", 0),
(try_for_range, ":herd_slot", "$g_loop_animal_herd_begin", ":loop_end"), # loop over the followers to check if any are ready to move
(scene_prop_get_slot, ":herd_agent_id", ":herd_manager", ":herd_slot"),
(agent_is_active, ":herd_agent_id"),
(agent_get_slot, ":move_time", ":herd_agent_id", slot_agent_animal_move_time),
(gt, ":move_time", 0),
(try_begin),
(ge, ":time", ":move_time"),
(agent_set_slot, ":herd_agent_id", slot_agent_animal_move_time, 0),
(call_script, "script_animal_move", ":herd_agent_id", "$g_loop_animal_herd_leader"),
(else_try),
(val_add, ":remaining_to_move", 1),
(try_end),
(try_end),
(gt, ":remaining_to_move", 0), # if any followers are still waiting
(else_try), # otherwise, go back to the herd manager checking loop
(assign, "$g_loop_animal_herd_begin", 0),
(val_add, "$g_loop_animal_herd_to_move", 1),
(try_end),
])
herd_animal_count_check = (300, 0, 0, [], # server: periodically update the global count of herd animals - rare conditions seemed to make this value incorrect over time
[(multiplayer_is_server),
(assign, "$g_herd_animal_count", 0),
(try_for_agents, ":agent_id"),
(agent_slot_ge, ":agent_id", slot_agent_animal_birth_time, 1),
(val_add, "$g_herd_animal_count", 1),
(try_end),
])
herd_animal_spawn_check = (60, 0, 0, [], # server: check all herd animal spawners to see if any are ready to activate
[(multiplayer_is_server),
(try_begin), # if the maximum number of herd animals in the server is not reached, check the spawners
(lt, "$g_herd_animal_count", "$g_max_herd_animal_count"),
(scene_prop_get_instance, ":instance_id", "spr_pw_herd_animal_spawn", "$g_herd_animal_spawn_instance_no"),
(val_add, "$g_herd_animal_spawn_instance_no", 1),
(scene_prop_get_slot, ":spawn_time", ":instance_id", slot_scene_prop_state_time),
(store_mission_timer_a, ":time"),
(try_begin), # if the spawning time has been reached
(gt, ":time", ":spawn_time"),
(prop_instance_get_variation_id_2, ":next_spawn_time", ":instance_id"),
(try_begin), # if the spawn interval value is not set, get a random time between 1 and 4 hours
(lt, ":next_spawn_time", 1),
(store_random_in_range, ":next_spawn_time", 3600, 24001),
(else_try), # otherwise, convert it to hours and apply a random adjustment between +/- 20%
(val_mul, ":next_spawn_time", 3600),
(store_random_in_range, ":random_adjustment", 80, 121),
(val_mul, ":next_spawn_time", ":random_adjustment"),
(val_div, ":next_spawn_time", 100),
(try_end),
(scene_prop_set_slot, ":instance_id", slot_scene_prop_state_time, ":next_spawn_time"),
(gt, ":spawn_time", 0), # if not mission start
(prop_instance_get_variation_id, ":animal_item_id", ":instance_id"),
(try_begin), # use the animal type if set
(val_add, ":animal_item_id", herd_animal_items_begin),
(val_sub, ":animal_item_id", 1),
(is_between, ":animal_item_id", herd_animal_items_begin, herd_animal_items_end),
(else_try), # otherwise get a random herd animal
(store_random_in_range, ":animal_item_id", herd_animal_items_begin, herd_animal_items_end),
(try_end),
(prop_instance_get_position, pos1, ":instance_id"),
(call_script, "script_cf_spawn_herd_animal", ":animal_item_id", -1),
(try_end),
(else_try),
(assign, "$g_herd_animal_spawn_instance_no", 0),
(try_end),
])
weather_situation_check = (loop_weather_adjust_interval, 0, 0, [], # server: adjust the weather systems in the scene
[(multiplayer_is_server),
(call_script, "script_scene_adjust_weather_situation"),
])
escape_pressed = (ti_escape_pressed, 0, 0, [], # clients: show escape menu
[(call_script, "script_cf_no_input_presentation_active"),
(start_presentation, "prsnt_escape_menu"),
])
tab_pressed = (ti_tab_pressed, 0, 0, [], # clients: show player stats chart when that control is pressed (not necessarily tab)
[(call_script, "script_cf_no_input_presentation_active"),
(neg|is_presentation_active, "prsnt_tabbed_stats_chart"),
(assign, "$g_stats_chart_opened_manually", 1),
(start_presentation, "prsnt_tabbed_stats_chart"),
])
static_presentations_setup = (ti_battle_window_opened, 0, 0, [], # clients: called after connecting and when returning from the log window (which clears all presentations)
[(try_begin),
(eq, "$g_display_agent_labels", 1),
(start_presentation, "prsnt_display_agent_labels"),
(try_end),
(try_begin),
(eq, "$g_display_chat_overlay", 1),
(start_presentation, "prsnt_chat_overlay"),
(try_end),
(try_begin),
(gt, "$g_respawn_start_time", 0),
(start_presentation, "prsnt_respawn_time_counter"),
(try_end),
(try_begin),
(neq, "$g_game_type", "mt_no_money"),
(start_presentation, "prsnt_gold"),
(try_end),
(start_presentation, "prsnt_food_bar"),
(start_presentation, "prsnt_scene_prop_hit_points_bar"),
(try_begin), # if an inventory was being accessed before the presentations were cleared, notify the server to stop sending updates
(gt, "$g_show_inventory_instance_id", 0),
(assign, "$g_show_inventory_instance_id", 0),
(multiplayer_send_message_to_server, client_event_transfer_inventory),
(try_end),
])
action_menu_pressed = (0, 0, 0, [], # clients: show action menu while that control is held down
[(game_key_clicked, gk_action_menu),
(call_script, "script_cf_no_input_presentation_active"),
(neg|is_presentation_active, "prsnt_action_menu"),
(start_presentation, "prsnt_action_menu"),
])
target_agent_pressed = (0, 0.3, 0, # clients: allow aiming at other agents or corpses to select them
[(game_key_is_down, gk_target_agent),
(call_script, "script_cf_no_input_presentation_active"),
(multiplayer_get_my_player, ":player_id"),
(player_is_active, ":player_id"),
(try_begin), # if shift is down, select live agents while the control is held down
(this_or_next|key_is_down, key_left_shift),
(key_is_down, key_right_shift),
(call_script, "script_select_target_agent"),
(assign, "$g_targeting_corpses", 0),
(else_try), # otherwise select corpses, running the loot script when the control is released
(call_script, "script_select_target_corpse"),
(assign, "$g_targeting_corpses", 1),
(try_end),
],
[(eq, "$g_targeting_corpses", 1),
(neg|game_key_is_down, gk_target_agent),
(call_script, "script_loot_target_corpse"),
])
chat_overlay_toggled = (0, 0, 0, [], # clients: toggle the overlay for local or faction chat
[(key_clicked, key_f10),
(call_script, "script_cf_no_input_presentation_active"),
(try_begin),
(neg|is_presentation_active, "prsnt_chat_overlay"),
(assign, "$g_display_chat_overlay", 1),
(start_presentation, "prsnt_chat_overlay"),
(else_try),
(assign, "$g_display_chat_overlay", 0),
(try_end),
])
chat_resend_check = (0.3, 0.3, 0, [(troop_slot_eq, "trp_last_chat_message", slot_last_chat_message_not_recieved, 1)], # clients: try to resend lost chat mesages
[(troop_slot_eq, "trp_last_chat_message", slot_last_chat_message_not_recieved, 1), # if the server has not confirmed receiving the last chat message for at least 0.3 seconds
(troop_get_slot, ":event", "trp_last_chat_message", slot_last_chat_message_event_type), # resend the chat type and string
(try_begin),
(gt, ":event", net_chat_event_mask),
(multiplayer_send_int_to_server, client_event_chat_message_type, ":event"),
(try_end),
(val_and, ":event", net_chat_event_mask),
(str_store_troop_name, s0, "trp_last_chat_message"),
(multiplayer_send_string_to_server, ":event", s0),
])
local_chat_pressed = (0, 0.05, 0, [(game_key_clicked, gk_local_chat),(call_script, "script_cf_no_input_presentation_active")], # clients: local chat entry box
[(assign, "$g_chat_box_string_id", "str_send_message_to_players_nearby"),
(assign, "$g_chat_box_event_type", chat_event_type_local),
(start_presentation, "prsnt_chat_box"),
])
faction_chat_pressed = (0, 0.05, 0, [(game_key_clicked, gk_faction_chat),(call_script, "script_cf_no_input_presentation_active")], # clients: faction chat entry box
[(multiplayer_get_my_player, ":player_id"),
(player_get_slot, ":faction_id", ":player_id", slot_player_faction_id),
(is_between, ":faction_id", chat_factions_begin, factions_end),
(str_store_faction_name, s11, ":faction_id"),
(assign, "$g_chat_box_string_id", "str_send_message_to_the_s11"),
(assign, "$g_chat_box_event_type", chat_event_type_faction),
(start_presentation, "prsnt_chat_box"),
])
admin_chat_pressed = (0, 0.05, 0, [(game_key_clicked, gk_admin_chat),(call_script, "script_cf_no_input_presentation_active")], # clients: admin chat entry box
[(try_begin), # for admins, allow sending only to a targeted player
(multiplayer_get_my_player, ":player_id"),
(player_is_admin, ":player_id"),
(assign, "$g_chat_box_player_string_id", "str_send_admin_message_to_s1"),
(else_try),
(assign, "$g_chat_box_player_string_id", 0),
(try_end),
(assign, "$g_chat_box_string_id", "str_send_admin_message"),