-
-
Notifications
You must be signed in to change notification settings - Fork 990
/
2p_Dark_Forecast.cfg
1411 lines (1308 loc) · 43.8 KB
/
2p_Dark_Forecast.cfg
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
#textdomain wesnoth-multiplayer
[multiplayer]
id=multiplayer_2p_Dark_Forecast
name= _ "2p — Dark Forecast (Survival)"
description= _ "Dark Forecast is a survival scenario for solitaire or two-player team-based play against randomly-spawned AI units. Victory is achieved by surviving and defeating all enemy waves. During the course of play, the terrain will change based on random weather effects.
Note: You need to use the default map settings for the scenario to work right."
turns="45"
experience_modifier="100"
map_data="{multiplayer/maps/Dark_Forecast.map}"
victory_when_enemies_defeated=no
define=MULTIPLAYER_2P_DARK_FORECAST_LOAD
#ifdef MULTIPLAYER_2P_DARK_FORECAST_LOAD
#define RANDOMIZE NUMBER
{VARIABLE_OP random rand 1..{NUMBER}}
#enddef
#define RANDOMIZE_INDEX NUMBER
{VARIABLE_OP random rand 1..{NUMBER}}
{VARIABLE_OP random sub 1}
#enddef
#define PLACE_SPAWN_GROUP X Y
{VARIABLE spawn_x {X}}
{VARIABLE spawn_y {Y}}
[if]
[variable]
name=spawn_x
equals="random"
[/variable]
[then]
{RANDOMIZE $location}
[store_locations]
variable=locs
[and]
x=$spawn_place[$random].x
y=$spawn_place[$random].y
radius=1
[/and]
# Avoid border hexes; we cannot spawn there.
[and]
x=1-16
y=8-22
[/and]
[/store_locations]
{RANDOMIZE_INDEX $locs.length}
{VARIABLE spawn_x $locs[$random].x}
{VARIABLE spawn_y $locs[$random].y}
{CLEAR_VARIABLE locs}
[/then]
[/if]
[store_unit]
variable=spawns
kill=yes
[filter]
canrecruit=no
side=1,2
[not]
x=1-15
y=8-22
[/not]
[/filter]
[/store_unit]
{FOREACH spawns id}
# store the original max_moves so they can be restored later
{VARIABLE spawns[$id].variables.original_max_moves $spawns[$id].max_moves}
# give the unit only a third of its normal max movement for now
{VARIABLE_OP spawns[$id].max_moves multiply 0.33}
{VARIABLE_OP spawns[$id].max_moves add 1}
{VARIABLE spawns[$id].side $timid_ai_side}
{VARIABLE spawns[$id].generate_name yes}
{VARIABLE spawns[$id].status.slowed yes}
{CLEAR_VARIABLE spawns[$id].name}
[unstore_unit]
variable=spawns[$id]
[/unstore_unit]
[object]
silent=yes
duration=forever
[filter]
x,y=$spawns[$id].x,$spawns[$id].y
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
flat=1
sand=2
forest=2
impassable=3
unwalkable=3
deep_water=3
[/movement_costs]
[/effect]
[/object]
{NEXT id}
{CLEAR_VARIABLE spawns}
[store_unit]
variable=spawns
kill=yes
[filter]
canrecruit=no
side=1,2
[not]
x=1-15
y=8-22
[/not]
[/filter]
[/store_unit]
{VARIABLE msg "Spawning: "}
{FOREACH spawns id}
{VARIABLE spawns[$id].x $spawn_x}
{VARIABLE spawns[$id].y $spawn_y}
{VARIABLE_OP spawns[$id].facing rand "sw,se,se"}
{VARIABLE msg "$msg
$spawns[$id].type"}
[if]
[variable]
name=unit_name
equals="none"
[/variable]
[else]
{VARIABLE spawns[$id].name $unit_name}
[/else]
[/if]
[unstore_unit]
variable=spawns[$id]
find_vacant=yes
animate=yes
[/unstore_unit]
{NEXT id}
{CLEAR_VARIABLE spawns}
### DEBUG
#{VARIABLE msg "$msg
#
#total cost: $total_cost"}
#[message]
# speaker=narrator
# message=$msg
#[/message]
#enddef
# copies the units over from FROM_SIDE to TO_SIDE
# and removes all temporary limitations of movement_type and max_moves
#define ADJUST_AGGRESSION FROM_SIDE TO_SIDE
[if]
[have_unit]
side={FROM_SIDE}
[/have_unit]
[then]
[store_unit]
variable=ai_unit
kill=yes
[filter]
side={FROM_SIDE}
[/filter]
[/store_unit]
{FOREACH ai_unit id}
{VARIABLE ai_unit[$id].side {TO_SIDE}}
{CLEAR_VARIABLE ai_unit[$id].movement_costs}
{VARIABLE ai_unit[$id].max_moves $ai_unit[$id].variables.original_max_moves}
[unstore_unit]
variable=ai_unit[$id]
find_vacant=no
[/unstore_unit]
{NEXT id}
{CLEAR_VARIABLE ai_unit}
[/then]
[/if]
#enddef
#define SPAWN_UNIT SIDE TYPE ID TIER_NUMBER NUMBER
{VARIABLE y "$(21-{NUMBER})"} # 10 + 11 - NUMBER
{VARIABLE x 18}
{VARIABLE this_tier {TIER_NUMBER}}
[if]
[variable]
name=this_tier
greater_than=1
[/variable]
[then]
{VARIABLE x 19}
[/then]
[/if]
[unit]
type={TYPE}
side={SIDE}
x=$x
y=$y
role=new_unit{TIER_NUMBER}
random_traits=no
name="none"
to_variable=new_unit
[/unit]
{VARIABLE_OP gold sub $new_unit.cost}
### DEBUG
{VARIABLE_OP total_cost add $new_unit.cost}
[if]
[variable]
name=min_cost
greater_than=$new_unit.cost
[/variable]
[then]
{VARIABLE min_cost $new_unit.cost}
[/then]
[/if]
{VARIABLE_OP max_units sub 1}
{VARIABLE new_unit.variables.spawn_id {ID}}
{VARIABLE new_unit.role new_spawn{TIER_NUMBER}}
[unstore_unit]
variable=new_unit
[/unstore_unit]
{CLEAR_VARIABLE new_unit}
#enddef
#define ADJUST_UNIT_LEVEL SIDE TIER_NUMBER
{VARIABLE next_tier {TIER_NUMBER}}
{VARIABLE_OP next_tier add 1}
{VARIABLE next_role "new_spawn$next_tier"}
[store_unit]
kill=yes
variable=new_spawn
[filter]
side={SIDE}
role=new_spawn{TIER_NUMBER}
[/filter]
[/store_unit]
{FOREACH new_spawn unit_id}
{VARIABLE spawn_id $new_spawn[$unit_id].variables.spawn_id}
{VARIABLE previous_cost $new_spawn.cost}
{VARIABLE upgrade_var main_spawns[$group_id].spawn_type[$spawn_id].up{TIER_NUMBER}}
{VARIABLE_OP advanceto to_variable $upgrade_var}
[if]
[variable]
name=advanceto
not_equals=null
[/variable]
[variable]
name=advanceto
not_equals=none
[/variable]
[then]
[if]
[variable]
name=advanceto
equals=more
[/variable]
[then]
{VARIABLE upgrade_cost $new_spawn[$unit_id].cost}
# add 2 gold to cost
{VARIABLE_OP upgrade_cost add 2}
{VARIABLE advanceto $new_spawn[$unit_id].type}
[if]
[variable]
name=gold
greater_than_equal_to=$upgrade_cost
[/variable]
[then]
{VARIABLE_OP gold sub $upgrade_cost}
### DEBUG
{VARIABLE_OP total_cost add $upgrade_cost}
{SPAWN_UNIT {SIDE} $advanceto $spawn_id $next_role $max_units}
{VARIABLE new_spawn[$unit_id].role $next_role}
[/then]
[/if]
[/then]
[else]
[unit]
side={SIDE}
type=$advanceto
random_traits=no
name="none"
x=20
y=22
to_variable=advancement
[/unit]
{VARIABLE upgrade_cost $advancement.cost}
{VARIABLE_OP upgrade_cost sub $previous_cost}
# 25% surcharge
{VARIABLE_OP upgrade_cost multiply 1.25}
{CLEAR_VARIABLE advancement}
[if]
[variable]
name=gold
greater_than_equal_to=$upgrade_cost
[/variable]
[then]
{VARIABLE_OP gold sub $upgrade_cost}
### DEBUG
{VARIABLE_OP total_cost add $upgrade_cost}
{VARIABLE new_spawn[$unit_id].role $next_role}
{VARIABLE somehack_type $advanceto}
{VARIABLE use_somehack yes}
[/then]
[/if]
[/else]
[/if]
[/then]
[/if]
[if]
[variable]
name=use_somehack
boolean_equals=yes
[/variable]
[then]
[unit]
type=$somehack_type
side={SIDE}
x=$new_spawn[$unit_id].x
y=$new_spawn[$unit_id].y
role=new_unit{TIER_NUMBER}
random_traits=no
name="none"
[/unit]
{VARIABLE use_somehack no}
[/then]
[else]
[unstore_unit]
variable=new_spawn[$unit_id]
find_vacant=yes
[/unstore_unit]
[/else]
[/if]
{NEXT unit_id}
{CLEAR_VARIABLE new_spawn}
#enddef
#define CLEAR_SPAWN_GROUP NUMBER
{CLEAR_VARIABLE main_spawns[{NUMBER}]}
{VARIABLE_OP main_group sub 1}
#enddef
#define VICTORY_CHECK
[event]
name=die
[filter]
side=1
[/filter]
[filter_condition]
[not]
[have_unit]
side=1,2
x=1-15
y=8-22
[/have_unit]
[/not]
[/filter_condition]
[music]
name=victory.ogg
play_once=yes
immediate=yes
[/music]
[message]
speaker=narrator
message= _"The screams and pleas for mercy are finally silenced, as you remove your blood soaked blade from the last of the rebels. There will be no more resistance from the local scum. Your reign has finally earned stability."
image=wesnoth-icon.png
[/message]
[endlevel]
result=victory
[/endlevel]
[/event]
#enddef
#define FINAL_SPAWN
[if]
[variable]
name=fixed_groups_left
greater_than=0
[/variable]
[then]
{VARIABLE_OP fixed_id rand "1..$fixed_group"}
{VARIABLE size $fixed_spawns[$fixed_id].spawn_number}
[while]
[variable]
name=size
less_than=1
[/variable]
[do]
{VARIABLE_OP fixed_id add 1}
[if]
[variable]
name=fixed_id
greater_than=$fixed_group
[/variable]
[then]
{VARIABLE fixed_id 1}
[/then]
[/if]
{VARIABLE size $fixed_spawns[$fixed_id].spawn_number}
[/do]
[/while]
{VARIABLE id 1}
{VARIABLE y 9}
[while]
[variable]
name=id
less_than_equal_to=$size
[/variable]
[do]
{VARIABLE type $fixed_spawns[$fixed_id].spawn_type[$id].type}
[unit]
type=$type
side=2
x=18
y=$y
random_traits=no
name="none"
[/unit]
{VARIABLE_OP y add 1}
{VARIABLE_OP id add 1}
[/do]
[/while]
{PLACE_SPAWN_GROUP $fixed_spawns[$fixed_id].x $fixed_spawns[$fixed_id].y}
{VARIABLE fixed_spawns[$fixed_id].spawn_number 0}
{VARIABLE_OP fixed_groups_left sub 1}
[/then]
[/if]
#enddef
#define REGULAR_RANDOM_SPAWNS SIDE INTERVAL_NUMBER SPAWN_NUMBER BASE_GOLD_AMOUNT GOLD_INCREMENT UNITS_AMOUNT GOLD_PER_UNIT_AMOUNT
# Calculate how many timed_spawn[] entries to define.
[if]
[variable]
name=main_group
less_then={SPAWN_NUMBER}
[/variable]
[then]
{VARIABLE spawn_limit $main_group}
[/then]
[else]
{VARIABLE spawn_limit {SPAWN_NUMBER}}
[/else]
[/if]
{VARIABLE spawn_id 0}
[while]
[variable]
name=spawn_id
less_than=$spawn_limit
[/variable]
[do]
{VARIABLE turns $spawn_id}
{VARIABLE_OP turns multiply {INTERVAL_NUMBER}}
{VARIABLE_OP turns add 3}
{VARIABLE_OP spawn_id add 1} # Loop control variable increment.
{VARIABLE gold {BASE_GOLD_AMOUNT}}
{VARIABLE gold_turns $turns}
{VARIABLE_OP gold_turns sub 3}
{VARIABLE_OP gold_turns multiply {GOLD_INCREMENT}}
{VARIABLE_OP gold add $gold_turns}
# regular spawns
[if]
[variable]
name=spawn_id
greater_than=1
[/variable]
[then]
{VARIABLE units $gold_turns}
# add a random amount of the basic gold
{RANDOMIZE {BASE_GOLD_AMOUNT}}
{VARIABLE gold1 $random}
{RANDOMIZE {BASE_GOLD_AMOUNT}}
[if]
[variable]
name=gold1
less_than=random
[/variable]
[then]
{VARIABLE random $gold1}
[/then]
[/if]
{CLEAR_VARIABLE gold1}
{VARIABLE_OP units add $random}
{VARIABLE unit_increment {GOLD_PER_UNIT_AMOUNT}}
{VARIABLE unit_turns $turns}
{VARIABLE_OP unit_turns divide 1.5}
{VARIABLE_OP unit_increment add $unit_turns}
{VARIABLE_OP units divide $unit_increment}
### DEBUG
{VARIABLE unit_increment $units}
### END DEBUG
{VARIABLE_OP units add {UNITS_AMOUNT}}
{VARIABLE_OP random rand -1..2}
{VARIABLE_OP units add $random}
{RANDOMIZE 5}
[if]
[variable]
name=random
numerical_equals=1
[/variable]
[then]
{VARIABLE_OP units sub 1}
[/then]
[/if]
{VARIABLE_OP random rand -1..1}
{VARIABLE_OP turns add $random}
[/then]
[else]
{VARIABLE units {UNITS_AMOUNT}}
{VARIABLE_OP units add 1}
### DEBUG
{VARIABLE unit_increment 0}
### END DEBUG
[/else]
[/if]
{VARIABLE timed_spawn[$spawn_id].units $units}
{VARIABLE timed_spawn[$spawn_id].turn $turns}
{VARIABLE timed_spawn[$spawn_id].gold $gold}
### DEBUG
{VARIABLE timed_spawn[$spawn_id].units_added $unit_increment}
### END DEBUG
[/do]
[/while]
{CLEAR_VARIABLE spawn_limit}
{VARIABLE final_turns "$timed_spawn[{SPAWN_NUMBER}].turn"}
{VARIABLE_OP final_turns add 40}
{VARIABLE_OP final_turns divide 2}
{VARIABLE_OP final_turns round 0}
{VARIABLE fixed_groups_left $fixed_group}
{VARIABLE trigger_index 1}
# reduce gold and units for spawns
# after the final spawn
{VARIABLE spawn_id 0}
{VARIABLE end_spawn 0}
[while]
[variable]
name=spawn_id
less_than=$timed_spawn.length
[/variable]
[do]
[if]
[variable]
name=timed_spawn[$spawn_id].turn
greater_than_equal_to=$final_turns
[/variable]
[then]
{VARIABLE_OP timed_spawn[$spawn_id].gold divide "$($end_spawn+3)"}
{VARIABLE_OP timed_spawn[$spawn_id].units divide "$($end_spawn+4)"}
[if]
# two spawns added to the final
[variable]
name=end_spawn
greater_than=1
[/variable]
[then]
{VARIABLE timed_spawn[$spawn_id].turn -1}
[/then]
[else]
{VARIABLE_OP end_spawn add 1}
[/else]
[/if]
[/then]
[/if]
{VARIABLE_OP spawn_id add 1}
[/do]
[/while]
[event]
name=new turn
first_time_only=no
[filter_condition]
[variable]
name=turn_number
greater_than=2
[/variable]
[variable]
name=turn_number
numerical_equals=$timed_spawn[$trigger_index].turn
[/variable]
[/filter_condition]
# normal spawn
{VARIABLE gold $timed_spawn[$trigger_index].gold}
{VARIABLE max_units $timed_spawn[$trigger_index].units}
{VARIABLE min_cost 100}
{VARIABLE_OP trigger_index add 1}
### DEBUG
{VARIABLE total_cost 0}
{VARIABLE_OP group_id rand 1..$main_group}
{VARIABLE size $main_spawns[$group_id].spawn_number}
[while]
[variable]
name=gold
greater_than=0
[/variable]
[variable]
name=max_units
greater_than=0
[/variable]
[do]
{RANDOMIZE $size}
[if]
[variable]
name=random
greater_than=0
[/variable]
[then]
{VARIABLE type $main_spawns[$group_id].spawn_type[$random].type}
{SPAWN_UNIT {SIDE} $type $random 1 $max_units}
[/then]
[else]
# fallback for invalid/cleared spawn groups
{VARIABLE gold 0}
[/else]
[/if]
[/do]
[/while]
{ADJUST_UNIT_LEVEL {SIDE} 1}
{ADJUST_UNIT_LEVEL {SIDE} 2}
{ADJUST_UNIT_LEVEL {SIDE} 3}
# spend remainder
{VARIABLE extra_units 3}
[while]
[variable]
name=gold
greater_than_equal_to=$min_cost
[/variable]
[variable]
name=extra_units
greater_than=0
[/variable]
[do]
{RANDOMIZE $size}
[if]
[variable]
name=random
greater_than=0
[/variable]
[then]
{VARIABLE type $main_spawns[$group_id].spawn_type[$random].type}
{SPAWN_UNIT {SIDE} $type $random 5 $max_units}
{VARIABLE_OP extra_units sub 1}
[/then]
[else]
# fallback for invalid/cleared spawn groups
{VARIABLE gold 0}
[/else]
[/if]
[/do]
[/while]
{PLACE_SPAWN_GROUP $main_spawns[$group_id].x $main_spawns[$group_id].y}
{CLEAR_SPAWN_GROUP $group_id}
[music]
name=frantic.ogg
ms_before=300
play_once=yes
immediate=yes
[/music]
[/event]
# the event extending the turn limit
# (This is so the player does not know exactly when the final spawn will occur?)
[event]
name=turn_44
id=Dark_Forecast_Turn_Limit_Extension_Starter
[event]
name=new_turn
id=Dark_Forecast_Turn_Limit_Extension
first_time_only=no
# Add a turn.
[modify_turns]
add=1
[/modify_turns]
[/event]
[/event]
# the event firing final spawns
[event]
name=turn_$final_turns
[music]
name=battle.ogg
ms_before=200
immediate=yes
append=yes
[/music]
{FINAL_SPAWN}
[modify_turns]
value="$($turn_number + 12)"
[/modify_turns]
[message]
side=3,4
canrecruit=yes
message= _ "The last and most powerful of these creatures are almost upon us. I feel that if we can finish them off in time, we shall be victorious."
[/message]
# Define the victory condition.
{VICTORY_CHECK}
# Stop the turn limit extension.
[event]
id=Dark_Forecast_Turn_Limit_Extension_Starter
remove=yes
[/event]
[event]
id=Dark_Forecast_Turn_Limit_Extension
remove=yes
[/event]
# More final spawns in later turns:
{VARIABLE_OP next_final_spawn rand 2..3}
{VARIABLE_OP next_final_spawn add $turn_number}
[event]
name=turn_$next_final_spawn
first_time_only=no
{FINAL_SPAWN}
{RANDOMIZE 2}
{VARIABLE_OP next_final_spawn add $random}
[/event]
[/event]
#enddef
# X_VALUE is either an X coordinate (for fixed spawn position)
# or "random" for a random location
# chosen from the spawn_place array
# set in DEFINE_SPAWN_LOCATION
# (in the latter case Y_VALUE is ignored)
#define DEFINE_MAIN_GROUP X_VALUE Y_VALUE
{VARIABLE spawn_id 0}
{VARIABLE_OP main_group add 1}
{VARIABLE main_spawns[$main_group].x {X_VALUE}}
{VARIABLE main_spawns[$main_group].y {Y_VALUE}}
#enddef
#define ADD_MAIN_SPAWN TYPE UP1_VALUE UP2_VALUE UP3_VALUE
{VARIABLE_OP spawn_id add 1}
{VARIABLE main_spawns[$main_group].spawn_type[$spawn_id].type {TYPE}}
{VARIABLE main_spawns[$main_group].spawn_type[$spawn_id].up1 {UP1_VALUE}}
{VARIABLE main_spawns[$main_group].spawn_type[$spawn_id].up2 {UP2_VALUE}}
{VARIABLE main_spawns[$main_group].spawn_type[$spawn_id].up3 {UP3_VALUE}}
{VARIABLE main_spawns[$main_group].spawn_number $spawn_id}
#enddef
#define DEFINE_SPAWN_LOCATION X_SPAN Y_SPAN
{VARIABLE_OP location add 1}
{VARIABLE spawn_place[$location].x {X_SPAN}}
{VARIABLE spawn_place[$location].y {Y_SPAN}}
#enddef
#define DEFINE_FIXED_GROUP X Y
{VARIABLE spawn_id 0}
{VARIABLE_OP fixed_group add 1}
{VARIABLE fixed_spawns[$fixed_group].x {X}}
{VARIABLE fixed_spawns[$fixed_group].y {Y}}
#enddef
#define ADD_FIXED_SPAWN TYPE
{VARIABLE_OP spawn_id add 1}
{VARIABLE fixed_spawns[$fixed_group].spawn_type[$spawn_id].type {TYPE}}
{VARIABLE fixed_spawns[$fixed_group].spawn_number $spawn_id}
#enddef
#define SET_TIMID_AI_AND_BOLD_AI TIMID_SIDE BOLD_SIDE
{VARIABLE timid_ai_side {TIMID_SIDE}}
{VARIABLE bold_ai_side {BOLD_SIDE}}
[event]
name=side turn
first_time_only=no
[if]
[variable]
name=side_number
greater_than=$timid_ai_side
[/variable]
[then]
{ADJUST_AGGRESSION $timid_ai_side $bold_ai_side}
[/then]
[/if]
[/event]
#enddef
#define WEATHER_EVENT_AT TURN WEATHER_VALUE
{VARIABLE_OP weather_events add 1}
{VARIABLE weather_event[$weather_events].turn {TURN}}
{VARIABLE weather_event[$weather_events].weather {WEATHER_VALUE}}
{RANDOMIZE 2}
{VARIABLE_OP turn add $random}
{VARIABLE_OP weather[{WEATHER_VALUE}].turns sub $random}
{VARIABLE max_turns 2}
{VARIABLE w_id {WEATHER_VALUE}}
[if]
[variable]
name=w_id
numerical_equals=0
[/variable]
[then]
{VARIABLE max_turns 1}
[/then]
[/if]
[while]
[variable]
name=max_turns
greater_than=0
[/variable]
[variable]
name=weather[{WEATHER_VALUE}].turns
greater_than=1
[/variable]
[do]
{RANDOMIZE 2}
[if]
[variable]
name=random
less_than=2
[/variable]
[then]
{VARIABLE_OP turn add $random}
{VARIABLE_OP max_turns sub $random}
{VARIABLE_OP weather[{WEATHER_VALUE}].turns sub $random}
[/then]
[else]
# stop incrementing
{VARIABLE max_turns 0}
[/else]
[/if]
[/do]
[/while]
{CLEAR_VARIABLE w_id}
#enddef
#define WEATHER_MAP NAME
[terrain_mask]
mask={NAME}
x=1
y=1
[/terrain_mask]
#enddef
#define WEATHER_ALERT TEXT RED GREEN BLUE
[print]
text= {TEXT}
duration=120
size=26
red={RED}
green={GREEN}
blue={BLUE}
[/print]
#enddef
#define ADJUST_WEATHER VAR
[switch]
variable={VAR}
[case]
value=4
# second snow
{WEATHER_MAP "{multiplayer/maps/Dark_Forecast_secondsnow.mask}"}
[sound]
name=bat-flapping.wav
[/sound]
{WEATHER_ALERT _"Heavy Snowfall" 224 255 251}
[/case]
[case]
value=3
# first snow
{WEATHER_MAP "{multiplayer/maps/Dark_Forecast_firstsnow.mask}"}
[sound]
name=wail.wav
[/sound]
{WEATHER_ALERT _"Snowfall" 229 243 241}
[/case]
[case]
value=2
# heavy rains
{WEATHER_MAP "{multiplayer/maps/Dark_Forecast_rain.mask}"}
[sound]
name=magic-faeriefire-miss.ogg
[/sound]
[delay]
time=250
[/delay]
[sound]
name=ambient/ship.ogg
[/sound]
{WEATHER_ALERT _"Heavy Rains" 174 220 255}
[/case]
[case]
value=1
# drought
{WEATHER_MAP "{multiplayer/maps/Dark_Forecast_drought.mask}"}
[sound]
name=gryphon-shriek-1.ogg
[/sound]
{WEATHER_ALERT _"Drought" 251 231 171}
[/case]
[else]
# clear weather
{WEATHER_MAP "{multiplayer/maps/Dark_Forecast_basic.mask}"}
[sound]
name=magic-holy-miss-2.ogg
[/sound]
{WEATHER_ALERT _"Clear Weather" 221 253 171}
[/else]
[/switch]
#enddef
#define INIT_WEATHER
{VARIABLE weather[0].turns 22}
{VARIABLE weather[0].name "Clear"}
{VARIABLE weather[1].turns 10}
{VARIABLE weather[1].name "Drought"}
{VARIABLE weather[2].turns 12}
{VARIABLE weather[2].name "Heavy Rain"}
{VARIABLE weather[3].turns 9}
{VARIABLE weather[3].name "Snowfall"}
{VARIABLE weather[4].turns 6}
{VARIABLE weather[4].name "Heavy Snowfall"}
{VARIABLE next_weather 1}
{VARIABLE weather_events 0}
# Enforce limits on turns spent in each weather pattern.
{VARIABLE_OP turn rand 4..6}
[while]
[variable]
name=turn
less_than=55
[/variable]
[do]
{VARIABLE_OP id rand 1..3}
{VARIABLE check 3}
[while]
[variable]
name=weather[$id].turns
less_than=1
[/variable]
[variable]
name=check
greater_than=0
[/variable]
[do]
# Cycle to the next weather, excluding clear and heavy snow.
{VARIABLE id "$($id % 3 + 1)"}
# Prevent infinite recursion.
{VARIABLE_OP check sub 1}
[/do]
[/while]
{WEATHER_EVENT_AT $turn $id}
# check for second snow
[if]
[variable]
name=id
numerical_equals=3
[/variable]
[variable]
name=weather[4].turns
greater_than=0
[/variable]
[then]
# Second snow happens half the time.
{RANDOMIZE 2}
[if]
[variable]
name=random
equals=1
[/variable]
[then]
{WEATHER_EVENT_AT $turn 4}
[/then]
[/if]
[/then]
[/if]
# Go back to clear weather.
{WEATHER_EVENT_AT $turn 0}
[/do]
[/while]
[event]
name=side 3 turn
first_time_only=no
[filter_condition]
[variable]
name=turn_number
greater_than_equal_to=$weather_event[$next_weather].turn
[/variable]
[/filter_condition]
{ADJUST_WEATHER weather_event[$next_weather].weather}
{VARIABLE_OP next_weather add 1}