Skip to content

Commit

Permalink
wml cleanups, add terrain= attribute to [random_placement] loc
Browse files Browse the repository at this point in the history
replacing some [while] with [repeat] or [random_placement]

Adding  terrain= attribute to the variable generated by [random_placement] this mkaes it easier to use [random_placement] as a replacement for [store_locations] + [while] since [store_locations] also generates the [terrain] attribute:
  • Loading branch information
gfgtdf committed Dec 10, 2016
1 parent 3c498eb commit a53090d
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 263 deletions.
26 changes: 3 additions & 23 deletions data/campaigns/Dead_Water/scenarios/01_Invasion.cfg
Expand Up @@ -543,23 +543,8 @@
[/if]

# Get the number of zombies from the list of numbers:
[set_variable]
name=index
value=$($number_of_captured_villages % 5)
[/set_variable]
[set_variable]
name=number_of_zombies
value=$zombie_number_pattern[ $($number_of_captured_villages % 5) ].number
[/set_variable]
#{DEBUG_MSG zombie_number_pattern[$index]

# Now place the zombies. For each one,
# decrease the number until it reaches 0
[while]
[variable]
name=number_of_zombies
greater_than=0
[/variable]
[repeat]
times=$zombie_number_pattern[ $($number_of_captured_villages % 5) ].number
[do]
#ifdef HARD
[if]
Expand Down Expand Up @@ -591,13 +576,8 @@
attacks_left=0
animate=yes
[/unit]

[set_variable]
name=number_of_zombies
sub=1
[/set_variable]
[/do]
[/while]
[/repeat]

[set_variable]
name=number_of_captured_villages
Expand Down
178 changes: 50 additions & 128 deletions data/campaigns/Descent_Into_Darkness/scenarios/08_A_Small_Favor2.cfg
Expand Up @@ -128,23 +128,6 @@
random_traits=no
[/unit]

# Place manor guards in hallways at random locations
[store_locations]
terrain=Iwr
[not]
x,y=20,20
radius=6
[/not]
[not]
x=1-5
y=1-5
[/not]
[not]
[filter][/filter]
[/not]
variable=possible_guard_locations
[/store_locations]

[set_variables]
name=guardtypetable
[value]
Expand All @@ -170,66 +153,30 @@
[/value]
[/set_variables]

{VARIABLE guardtypetable_i 0}
{VARIABLE guards_to_place 8}

[while]
[variable]
name=guards_to_place
greater_than=0
[/variable]

[do]
{RANDOM 1..$possible_guard_locations.length}
{VARIABLE_OP random sub 1}

{NAMED_NOTRAIT_UNIT 2 $guardtypetable[$guardtypetable_i].type $possible_guard_locations[$random].x $possible_guard_locations[$random].y () (_ "Guard")} {GUARDIAN}

[store_locations]
find_in=possible_guard_locations
[not]
x,y=$possible_guard_locations[$random].x,$possible_guard_locations[$random].y
radius=4
[/not]
variable=possible_guard_locations
[/store_locations]

{VARIABLE_OP guardtypetable_i add 1}

[if]
[variable]
name=guardtypetable_i
numerical_equals=$guardtypetable.length
[/variable]

[then]
{VARIABLE guardtypetable_i 0}
[/then]
[/if]

{VARIABLE_OP guards_to_place sub 1}
[/do]
[/while]

{CLEAR_VARIABLE guardtypetable,guardtypetable_i,possible_guard_locations}

[store_locations]
terrain=Iwr
[not]
x,y=20,20
radius=6
[/not]
[not]
x=1-5
y=1-5
[/not]
[not]
[filter_adjacent_location]
terrain=!,Iwr
[/filter_adjacent_location]
[/not]
variable=possible_mage_locations
[/store_locations]
[random_placement]
num_items=8
variable=loc
min_distance=4
[filter_location]
terrain=Iwr
[not]
x,y=20,20
radius=6
[/not]
[not]
x=1-5
y=1-5
[/not]
[not]
[filter][/filter]
[/not]
[/filter_location]
[command]
{NAMED_NOTRAIT_UNIT 2 $guardtypetable[$($loc.n % $guardtypetable.length)].type $loc.x $loc.y () (_ "Guard")} {GUARDIAN}
[/command]
[/random_placement]

{CLEAR_VARIABLE guardtypetable}

[set_variables]
name=magetypetable
Expand Down Expand Up @@ -258,57 +205,32 @@
#endif
[/set_variables]

{VARIABLE magetypetable_i 0}

#ifdef EASY
{VARIABLE mages_to_place 12}
#endif
#ifdef NORMAL
{VARIABLE mages_to_place 14}
#endif
#ifdef HARD
{VARIABLE mages_to_place 16}
#endif

[while]
[variable]
name=mages_to_place
greater_than=0
[/variable]

[do]
{RANDOM 1..$possible_mage_locations.length}
{VARIABLE_OP random sub 1}

{GENERIC_UNIT 2 $magetypetable[$magetypetable_i].type $possible_mage_locations[$random].x $possible_mage_locations[$random].y}

[store_locations]
find_in=possible_mage_locations
[not]
x,y=$possible_mage_locations[$random].x,$possible_mage_locations[$random].y
radius=2
[/not]
variable=possible_mage_locations
[/store_locations]

{VARIABLE_OP magetypetable_i add 1}

[if]
[variable]
name=magetypetable_i
numerical_equals=$magetypetable.length
[/variable]

[then]
{VARIABLE magetypetable_i 0}
[/then]
[/if]

{VARIABLE_OP mages_to_place sub 1}
[/do]
[/while]

{CLEAR_VARIABLE magetypetable,magetypetable_i,possible_mage_locations}
[random_placement]
num_items={ON_DIFFICULTY 12 14 16}
variable=loc
min_distance=2
[filter_location]
terrain=Iwr
[not]
x,y=20,20
radius=6
[/not]
[not]
x=1-5
y=1-5
[/not]
[not]
[filter_adjacent_location]
terrain=!,Iwr
[/filter_adjacent_location]
[/not]
[/filter_location]
[command]
{GENERIC_UNIT 2 $magetypetable[$($loc.n % $magetypetable.length)].type $loc.x $loc.y}
[/command]
[/random_placement]

{CLEAR_VARIABLE magetypetable}

[recall]
id=Darken Volk
Expand Down
15 changes: 4 additions & 11 deletions data/campaigns/Eastern_Invasion/scenarios/17a_The_Duel.cfg
Expand Up @@ -189,21 +189,15 @@ At the end of your first turn, your keep will disappear, and you must battle wit
name=summon
first_time_only=no

{VARIABLE i 0}

[animate_unit]
[filter]
id=Mal-Ravanal
[/filter]
flag=summon
[/animate_unit]

[while]
[variable]
name=i
less_than=3
[/variable]

[repeat]
times=3
[do]
#ifdef EASY
{VARIABLE_OP new_summon_type rand "Bone Shooter,Bone Shooter,Revenant,Revenant,Necrophage,Necrophage,Wraith"}
Expand Down Expand Up @@ -238,10 +232,9 @@ At the end of your first turn, your keep will disappear, and you must battle wit
animate=yes
[/unit]

{VARIABLE_OP i add 1}
[/do]
[/while]
{CLEAR_VARIABLE new_summon_type,new_summon_locations,i,loci}
[/repeat]
{CLEAR_VARIABLE new_summon_type,new_summon_locations,loci}

[fire_event]
name=summon_explanation
Expand Down
56 changes: 15 additions & 41 deletions data/campaigns/Heir_To_The_Throne/scenarios/12_Northern_Winter.cfg
Expand Up @@ -220,34 +220,19 @@
first_time_only=no
delayed_variable_substitution=yes

[store_locations]
terrain=Gs,Gd,Co,Ko,Re,Rb,Gll^Fp,Gll^Fmw,Gll^Fdw,Gd^Vo,Gd^Vc,Hhd^Vo ,Hhd^Vc
[random_placement]
num_items="size / ($turn_limit - $turn_number)"
variable=loc
allow_less=yes

[filter_location]
terrain=Gs,Gd,Co,Ko,Re,Rb,Gll^Fp,Gll^Fmw,Gll^Fdw,Gd^Vo,Gd^Vc,Hhd^Vo ,Hhd^Vc
[/filter_location]

variable=non_snowy_locs
[/store_locations]

{VARIABLE turns_left $turn_limit}
{VARIABLE_OP turns_left sub $turn_number}

{VARIABLE num_of_falling_snow $non_snowy_locs.length}
{VARIABLE_OP num_of_falling_snow divide $turns_left}

# {DEBUG_MSG "stored $non_snowy_locs.length non-snowy locs, putting snow on $num_of_falling_snow"}

{VARIABLE i 0}

[while]
[variable]
name=i
less_than=$num_of_falling_snow
[/variable]

[do]
{RANDOM "1..$non_snowy_locs.length"}
{VARIABLE_OP random sub 1}
[command]

[switch]
variable=non_snowy_locs[$random].terrain
variable=loc.terrain

[case]
value=Gs
Expand Down Expand Up @@ -329,30 +314,19 @@

# just a fallback in case something goes wrong
[else]
{VARIABLE terrain $non_snowy_locs[$random].terrain}
{VARIABLE terrain $loc.terrain}
[/else]
[/switch]

[terrain]
x,y=$non_snowy_locs[$random].x,$non_snowy_locs[$random].y
x,y=$loc.x,$loc.y
terrain=$terrain
[/terrain]

[store_locations]
find_in=non_snowy_locs

[not]
x,y=$non_snowy_locs[$random].x,$non_snowy_locs[$random].y
[/not]

variable=non_snowy_locs
[/store_locations]

{VARIABLE_OP i add 1}
[/do]
[/while]
[/command]
[/random_placement]

{CLEAR_VARIABLE non_snowy_locs,i,num_of_falling_snow,random,terrain,turns_left}
{CLEAR_VARIABLE terrain}
[/event]
[/event]

Expand Down

0 comments on commit a53090d

Please sign in to comment.