Give wmlindent a capability to declare indenters.

Pre-declare {FOREACH and {NEXT.

Write declarations in the one place they're presently needed, Sceptre of Fire.

Reindent the data tree accordingly.

This partly addresses the feature request in bug #12180.
This commit is contained in:
Eric S. Raymond 2008-08-28 20:19:50 +00:00
parent c133efea6e
commit 08f09eda6f
46 changed files with 1571 additions and 1530 deletions

View file

@ -171,11 +171,11 @@
[/store_locations]
{FOREACH lowland_hex i}
[remove_shroud]
side=1
x=$lowland_hex[$i].x
y=$lowland_hex[$i].y
[/remove_shroud]
[remove_shroud]
side=1
x=$lowland_hex[$i].x
y=$lowland_hex[$i].y
[/remove_shroud]
{NEXT i}
{CLEAR_VARIABLE lowland_hex}

View file

@ -289,20 +289,20 @@ This enemy is too strong for you to defeat alone. Use mounted units, and Linaera
kill=yes
[/store_unit]
{FOREACH linaeras_side i}
{VARIABLE linaeras_side[$i].side 1}
[if]
[variable]
name=linaeras_side[$i].id
equals=Linaera
[/variable]
[then]
{VARIABLE linaeras_side[$i].canrecruit 0}
{VARIABLE linaeras_side[$i].overlays "misc/hero-icon.png"}
[/then]
[/if]
[unstore_unit]
variable=linaeras_side[$i]
[/unstore_unit]
{VARIABLE linaeras_side[$i].side 1}
[if]
[variable]
name=linaeras_side[$i].id
equals=Linaera
[/variable]
[then]
{VARIABLE linaeras_side[$i].canrecruit 0}
{VARIABLE linaeras_side[$i].overlays "misc/hero-icon.png"}
[/then]
[/if]
[unstore_unit]
variable=linaeras_side[$i]
[/unstore_unit]
{NEXT i}
[/event]

View file

@ -353,9 +353,9 @@
[/store_villages]
{FOREACH villages i}
{VARIABLE_OP village_var format "village_$villages[$i].x|_$villages[$i].y|_cleared"}
{VARIABLE_OP village_var format "village_$villages[$i].x|_$villages[$i].y|_cleared"}
{CLEAR_VARIABLE $village_var}
{CLEAR_VARIABLE $village_var}
{NEXT i}
{CLEAR_VARIABLE villages}

View file

@ -198,47 +198,47 @@
[/store_locations]
{FOREACH breaking_ice i}
[terrain]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
terrain=Wo
[/terrain]
[removeitem]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
image=misc/weakened-ice.png
[/removeitem]
[redraw]
[/redraw]
[kill]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
animate=yes
fire_event=yes
[/kill]
[if]
[have_unit]
[terrain]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
race=undead
[/have_unit]
terrain=Wo
[/terrain]
[then]
[message]
speaker=narrator
message=_ "The weak ice gives way beneath the undead creature, who becomes mired in the thick mud at the lake's bottom."
image=wesnoth-icon.png
[/message]
[/then]
[removeitem]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
image=misc/weakened-ice.png
[/removeitem]
[else]
[message]
speaker=narrator
message=_ "The weak ice gives way beneath the heavy warrior, who drowns in the frigid mountain waters."
image=wesnoth-icon.png
[/message]
[/else]
[/if]
[redraw]
[/redraw]
[kill]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
animate=yes
fire_event=yes
[/kill]
[if]
[have_unit]
x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
race=undead
[/have_unit]
[then]
[message]
speaker=narrator
message=_ "The weak ice gives way beneath the undead creature, who becomes mired in the thick mud at the lake's bottom."
image=wesnoth-icon.png
[/message]
[/then]
[else]
[message]
speaker=narrator
message=_ "The weak ice gives way beneath the heavy warrior, who drowns in the frigid mountain waters."
image=wesnoth-icon.png
[/message]
[/else]
[/if]
{NEXT i}
[store_locations]
@ -260,10 +260,10 @@
[/store_locations]
{FOREACH weakened_ice i}
[item]
x,y=$weakened_ice[$i].x,$weakened_ice[$i].y
image=misc/weakened-ice.png
[/item]
[item]
x,y=$weakened_ice[$i].x,$weakened_ice[$i].y
image=misc/weakened-ice.png
[/item]
{NEXT i}
{CLEAR_VARIABLE breaking_ice}

View file

@ -339,16 +339,16 @@
[/store_unit]
{FOREACH units_inside_manor i}
{VARIABLE units_inside_manor[$i].upkeep loyal}
{VARIABLE units_inside_manor[$i].upkeep loyal}
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
[recall]
id=$units_inside_manor[$i].id
[/recall]
[recall]
id=$units_inside_manor[$i].id
[/recall]
{NEXT i}
{CLEAR_VARIABLE units_inside_manor}

View file

@ -161,16 +161,16 @@
[/store_unit]
{FOREACH units_inside_manor i}
{VARIABLE units_inside_manor[$i].upkeep loyal}
{VARIABLE units_inside_manor[$i].upkeep loyal}
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
[recall]
id=$units_inside_manor[$i].id
[/recall]
[recall]
id=$units_inside_manor[$i].id
[/recall]
{NEXT i}
{CLEAR_VARIABLE units_inside_manor}

View file

@ -136,12 +136,12 @@
[/store_unit]
{FOREACH units_inside_manor i}
{VARIABLE units_inside_manor[$i].upkeep full}
{VARIABLE units_inside_manor[$i].upkeep full}
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=units_inside_manor[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE units_inside_manor}

View file

@ -463,9 +463,9 @@
#define RESTORE_RECALL_LIST
{FOREACH iotd_recall_store i}
[unstore_unit]
variable=iotd_recall_store[$i]
[/unstore_unit]
[unstore_unit]
variable=iotd_recall_store[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE iotd_recall_store}
#enddef

View file

@ -269,10 +269,10 @@
[/filter]
[/store_unit]
{FOREACH gryphon_store i}
{VARIABLE gryphon_store[$i].type Gryphon}
[unstore_unit]
variable=gryphon_store[$i]
[/unstore_unit]
{VARIABLE gryphon_store[$i].type Gryphon}
[unstore_unit]
variable=gryphon_store[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE gryphon_store}
#
@ -331,20 +331,20 @@
[/filter]
[/store_unit]
{FOREACH gryphon_store i}
{VARIABLE_OP temp_x format $gryphon_store[$i].x}
{VARIABLE_OP temp_y format $gryphon_store[$i].y}
{VARIABLE_OP range_x format ("$temp_x|, $destination_x")}
{VARIABLE_OP range_y format ("$temp_y|, $destination_y")}
[kill]
x=$temp_x
y=$temp_y
[/kill]
[move_unit_fake]
type=Gryphon
side=3
x=$range_x
y=$range_y
[/move_unit_fake]
{VARIABLE_OP temp_x format $gryphon_store[$i].x}
{VARIABLE_OP temp_y format $gryphon_store[$i].y}
{VARIABLE_OP range_x format ("$temp_x|, $destination_x")}
{VARIABLE_OP range_y format ("$temp_y|, $destination_y")}
[kill]
x=$temp_x
y=$temp_y
[/kill]
[move_unit_fake]
type=Gryphon
side=3
x=$range_x
y=$range_y
[/move_unit_fake]
{NEXT i}
{CLEAR_VARIABLE konrad_store}
{CLEAR_VARIABLE gryphon_store}
@ -476,13 +476,13 @@
[/filter]
[/store_unit]
{FOREACH sleepy_gryphon_store i}
{VARIABLE_OP x_temp format $sleepy_gryphon_store[$i].x}
{VARIABLE_OP y_temp format $sleepy_gryphon_store[$i].y}
{VARIABLE sleepy_gryphon_store[$i].goto_x x_temp}
{VARIABLE sleepy_gryphon_store[$i].goto_y y_temp}
[unstore_unit]
variable=sleepy_gryphon_store[$i]
[/unstore_unit]
{VARIABLE_OP x_temp format $sleepy_gryphon_store[$i].x}
{VARIABLE_OP y_temp format $sleepy_gryphon_store[$i].y}
{VARIABLE sleepy_gryphon_store[$i].goto_x x_temp}
{VARIABLE sleepy_gryphon_store[$i].goto_y y_temp}
[unstore_unit]
variable=sleepy_gryphon_store[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE sleepy_gryphon_store}
{CLEAR_VARIABLE x_temp}

View file

@ -189,11 +189,11 @@
variable=scepter_vicinity
[/store_locations]
{FOREACH scepter_vicinity i}
[terrain]
x=$scepter_vicinity[$i].x
y=$scepter_vicinity[$i].y
terrain=Uu
[/terrain]
[terrain]
x=$scepter_vicinity[$i].x
y=$scepter_vicinity[$i].y
terrain=Uu
[/terrain]
{NEXT i}
[terrain]
x=$scepter_x

View file

@ -467,10 +467,10 @@ Soooo... It is you who sent your subordinates to attack us. Now when we've destr
[/store_locations]
{FOREACH temp_starting_villages_area i}
[capture_village]
side=2
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
[capture_village]
side=2
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE temp_starting_villages_area}
@ -489,10 +489,10 @@ Soooo... It is you who sent your subordinates to attack us. Now when we've destr
[/store_locations]
{FOREACH temp_starting_villages_area i}
[capture_village]
side=2
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
[capture_village]
side=2
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE temp_starting_villages_area}

View file

@ -609,11 +609,11 @@ _f, _f, _f, _f, _f, _f, Re, _f, _f, _f, _f, _f,
[/variable]
[then]
{FOREACH good_floor i}
[terrain]
x=$good_floor[$i].x
y=$good_floor[$i].y
terrain=Ql
[/terrain]
[terrain]
x=$good_floor[$i].x
y=$good_floor[$i].y
terrain=Ql
[/terrain]
{NEXT i}
[store_locations]
variable=lava_body

View file

@ -256,11 +256,11 @@
[/store_unit]
{FOREACH stored_changers i}
{VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}
{VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
{NEXT i}
{CHG_TYPE side,type=3,Spearman Skeleton chaotic}
@ -293,11 +293,11 @@
[/store_unit]
{FOREACH stored_changers i}
{VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}
{VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_changers}
@ -343,11 +343,11 @@
[/store_unit]
{FOREACH stored_changers i}
{VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}
{VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
{NEXT i}
{CHG_TYPE side,type=3,Skeleton Spearman lawful}
@ -380,11 +380,11 @@
[/store_unit]
{FOREACH stored_changers i}
{VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}
{VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_changers[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_changers}

View file

@ -628,12 +628,12 @@
[/store_unit]
{FOREACH side_2_units_nearby i}
{VARIABLE side_2_units_nearby[$i].side 3}
{VARIABLE side_2_units_nearby[$i].side 3}
[unstore_unit]
variable=side_2_units_nearby[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=side_2_units_nearby[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE side_2_units_nearby}

View file

@ -23,18 +23,18 @@
[/store_unit]
{FOREACH chgtype_store i}
[set_variable]
name=chgtype_store[$i].type
value={VALUE}
[/set_variable]
[set_variable]
name=chgtype_store[$i].alignment
value={ALIGN}
[/set_variable]
[set_variable]
name=chgtype_store[$i].type
value={VALUE}
[/set_variable]
[set_variable]
name=chgtype_store[$i].alignment
value={ALIGN}
[/set_variable]
[unstore_unit]
variable=chgtype_store[$i]
[/unstore_unit]
[unstore_unit]
variable=chgtype_store[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE chgtype_store}

View file

@ -298,12 +298,12 @@
side=1
[/kill]
{FOREACH dwarves i}
{VARIABLE dwarves[$i].x "recall"}
{VARIABLE dwarves[$i].y "recall"}
{VARIABLE dwarves[$i].x "recall"}
{VARIABLE dwarves[$i].y "recall"}
[unstore_unit]
variable=dwarves[$i]
[/unstore_unit]
[unstore_unit]
variable=dwarves[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE dwarves}
{CLEAR_VARIABLE stored_Rugnur_side}

View file

@ -640,13 +640,13 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
fire_event=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
fire_event=yes
[/kill]
{NEXT_FORMAT i}
[clear_variable]
name=lavadead
[/clear_variable]
@ -712,12 +712,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava 4
[terrain_mask]
x,y=1,1
@ -737,12 +737,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava 5
[terrain_mask]
x,y=1,1
@ -762,12 +762,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava 6
[terrain_mask]
x,y=1,1
@ -787,12 +787,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava 7
[terrain_mask]
x,y=1,1
@ -812,12 +812,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#and then you win
[endlevel]
result=continue_no_save
@ -870,12 +870,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava 9
[terrain_mask]
x,y=1,1
@ -895,12 +895,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#lava final
[terrain_mask]
x,y=1,1
@ -920,12 +920,12 @@
variable=lavadead
[/store_locations]
{FOREACH_FORMAT lavadead i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT i}
[kill]
x=$lavadead_i_x
y=$lavadead_i_y
animate=yes
[/kill]
{NEXT_FORMAT i}
#clear the variable
[clear_variable]
name=lavadead

View file

@ -96,12 +96,21 @@
[/set_variable]
#enddef
#wmlindent: start ignoring
#define FOREACH_FORMAT VARIABLE TEMP_VARIABLE
{FOREACH {VARIABLE} {TEMP_VARIABLE}}
{FORMAT {VARIABLE} {TEMP_VARIABLE} x}
{FORMAT {VARIABLE} {TEMP_VARIABLE} y}
#enddef
#define NEXT_FORMAT VARIABLE
{NEXT VARIABLE}
#enddef
#wmlindent: stop ignoring
# wmlindent: opener "{FOREACH_FORMAT "
# wmlindent: closer "{NEXT_FORMAT "
#define ROLEMACRO X
[role]
role=temp{X}

View file

@ -353,48 +353,48 @@
[/store_unit]
{FOREACH stored_transports i}
[store_locations]
x=14-28
y=14-29
terrain=Ww
[store_locations]
x=14-28
y=14-29
terrain=Ww
[filter_adjacent_location]
terrain=Ds,*^Bw*
[/filter_adjacent_location]
[filter_adjacent_location]
terrain=Ds,*^Bw*
[/filter_adjacent_location]
[not]
find_in=already_picked_transport_destination_surroundings
[/not]
[not]
find_in=already_picked_transport_destination_surroundings
[/not]
variable=possible_transport_destinations
[/store_locations]
variable=possible_transport_destinations
[/store_locations]
{VARIABLE_OP transport_destination_index random "1..$possible_transport_destinations.length"}
{VARIABLE_OP transport_destination_index add -1}
{VARIABLE_OP transport_destination_index random "1..$possible_transport_destinations.length"}
{VARIABLE_OP transport_destination_index add -1}
{VARIABLE stored_transports[$i].variables.destination_x $possible_transport_destinations[$transport_destination_index].x}
{VARIABLE stored_transports[$i].variables.destination_y $possible_transport_destinations[$transport_destination_index].y}
{VARIABLE stored_transports[$i].variables.destination_set yes}
{VARIABLE stored_transports[$i].variables.destination_x $possible_transport_destinations[$transport_destination_index].x}
{VARIABLE stored_transports[$i].variables.destination_y $possible_transport_destinations[$transport_destination_index].y}
{VARIABLE stored_transports[$i].variables.destination_set yes}
[store_locations]
x=$stored_transports[$i].variables.destination_x
y=$stored_transports[$i].variables.destination_y
radius=2
[store_locations]
x=$stored_transports[$i].variables.destination_x
y=$stored_transports[$i].variables.destination_y
radius=2
[filter_radius]
terrain=Ww,Ds,*^Bw*
[/filter_radius]
[filter_radius]
terrain=Ww,Ds,*^Bw*
[/filter_radius]
[or]
find_in=already_picked_transport_destination_surroundings
[/or]
[or]
find_in=already_picked_transport_destination_surroundings
[/or]
variable=already_picked_transport_destination_surroundings
[/store_locations]
variable=already_picked_transport_destination_surroundings
[/store_locations]
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
{NEXT i}
[store_unit]
@ -416,12 +416,12 @@
[/store_unit]
{FOREACH stored_transports i}
{VARIABLE stored_transports[$i].goto_x $stored_transports[$i].variables.destination_x}
{VARIABLE stored_transports[$i].goto_y $stored_transports[$i].variables.destination_y}
{VARIABLE stored_transports[$i].goto_x $stored_transports[$i].variables.destination_x}
{VARIABLE stored_transports[$i].goto_y $stored_transports[$i].variables.destination_y}
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
{NEXT i}
[store_unit]
@ -441,11 +441,11 @@
[/store_unit]
{FOREACH stored_transports i}
{VARIABLE stored_transports[$i].moves 0}
{VARIABLE stored_transports[$i].moves 0}
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_transports[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_transports}

View file

@ -296,28 +296,28 @@
[/kill]
{FOREACH exploding_hexes i}
[sound]
name=explosion.ogg
[/sound]
[sound]
name=explosion.ogg
[/sound]
[item]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
halo=projectiles/fire-burst-small-1.png:50,projectiles/fire-burst-small-2.png:50,projectiles/fire-burst-small-3.png:50,projectiles/fire-burst-small-4.png:50,projectiles/fire-burst-small-5.png:50,projectiles/fire-burst-small-6.png:50,projectiles/fire-burst-small-7.png:50,projectiles/fire-burst-small-8.png:50,misc/blank-hex.png:1000000
[/item]
[item]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
halo=projectiles/fire-burst-small-1.png:50,projectiles/fire-burst-small-2.png:50,projectiles/fire-burst-small-3.png:50,projectiles/fire-burst-small-4.png:50,projectiles/fire-burst-small-5.png:50,projectiles/fire-burst-small-6.png:50,projectiles/fire-burst-small-7.png:50,projectiles/fire-burst-small-8.png:50,misc/blank-hex.png:1000000
[/item]
[kill]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
animate=yes
fire_event=yes
[/kill]
[kill]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
animate=yes
fire_event=yes
[/kill]
[terrain]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
terrain=Ww
[/terrain]
[terrain]
x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
terrain=Ww
[/terrain]
[redraw]
[/redraw]
[redraw]
[/redraw]
{NEXT i}
[kill]

View file

@ -479,11 +479,11 @@
[/unstore_unit]
{FOREACH stored_trolls i}
{VARIABLE stored_trolls[$i].side 4}
{VARIABLE stored_trolls[$i].side 4}
[unstore_unit]
variable=stored_trolls[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_trolls[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_Gruu,stored_trolls}

View file

@ -325,13 +325,13 @@
[/store_unit]
{FOREACH great_horde_units i}
{VARIABLE great_horde_units[$i].upkeep $great_horde_units[$i].level}
{VARIABLE_OP great_horde_units[$i].upkeep add -1}
{VARIABLE great_horde_units[$i].variables.great_horde_upkeep_mod_applied yes}
{VARIABLE great_horde_units[$i].upkeep $great_horde_units[$i].level}
{VARIABLE_OP great_horde_units[$i].upkeep add -1}
{VARIABLE great_horde_units[$i].variables.great_horde_upkeep_mod_applied yes}
[unstore_unit]
variable=great_horde_units[$i]
[/unstore_unit]
[unstore_unit]
variable=great_horde_units[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE great_horde_units}

View file

@ -181,16 +181,16 @@
[/store_unit]
{FOREACH stored_Haldric.modifications.object i}
[if]
[variable]
name=stored_Haldric.modifications.object[$i].id
equals=ruby_of_fire
[/variable]
[if]
[variable]
name=stored_Haldric.modifications.object[$i].id
equals=ruby_of_fire
[/variable]
[then]
{CLEAR_VARIABLE stored_Haldric.modifications.object[$i]}
[/then]
[/if]
[then]
{CLEAR_VARIABLE stored_Haldric.modifications.object[$i]}
[/then]
[/if]
{NEXT i}
[unstore_unit]

View file

@ -479,10 +479,10 @@
[/store_villages]
{FOREACH side_2_villages i}
[capture_village]
side=1
x,y=$side_2_villages[$i].x,$side_2_villages[$i].y
[/capture_village]
[capture_village]
side=1
x,y=$side_2_villages[$i].x,$side_2_villages[$i].y
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE side_2_villages}

View file

@ -485,9 +485,9 @@
[/unstore_unit]
{FOREACH stored_elvish_bodyguards i}
[unstore_unit]
variable=stored_elvish_bodyguards[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_elvish_bodyguards[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_Deoran}

View file

@ -173,23 +173,23 @@
{VARIABLE best_score 0}
{VARIABLE best_unit -1}
{FOREACH swordsman i}
{VARIABLE dam $swordsman[$i].attack[0].damage}
{VARIABLE_OP dam multiply $swordsman[$i].attack[0].number}
{VARIABLE xp $swordsman[$i].experience}
{VARIABLE_OP xp divide 4}
{VARIABLE_OP dam add xp}
{RANDOM 0..6}
{VARIABLE_OP dam add $random}
[if]
[variable]
name=dam
greater_than=$best_score
[/variable]
[then]
{VARIABLE best_score $dam}
{VARIABLE best_unit $i}
[/then]
[/if]
{VARIABLE dam $swordsman[$i].attack[0].damage}
{VARIABLE_OP dam multiply $swordsman[$i].attack[0].number}
{VARIABLE xp $swordsman[$i].experience}
{VARIABLE_OP xp divide 4}
{VARIABLE_OP dam add xp}
{RANDOM 0..6}
{VARIABLE_OP dam add $random}
[if]
[variable]
name=dam
greater_than=$best_score
[/variable]
[then]
{VARIABLE best_score $dam}
{VARIABLE best_unit $i}
[/then]
[/if]
{NEXT i}
[recall]
id=$swordsman[$best_unit].id
@ -228,23 +228,23 @@
{VARIABLE best_score 0}
{VARIABLE best_unit -1}
{FOREACH archer i}
{VARIABLE dam $archer[$i].attack[1].damage}
{VARIABLE_OP dam multiply $archer[$i].attack[1].number}
{VARIABLE xp $archer[$i].experience}
{VARIABLE_OP xp divide 4}
{VARIABLE_OP dam add xp}
{RANDOM 0..6}
{VARIABLE_OP dam add $random}
[if]
[variable]
name=dam
greater_than=$best_score
[/variable]
[then]
{VARIABLE best_score $dam}
{VARIABLE best_unit $i}
[/then]
[/if]
{VARIABLE dam $archer[$i].attack[1].damage}
{VARIABLE_OP dam multiply $archer[$i].attack[1].number}
{VARIABLE xp $archer[$i].experience}
{VARIABLE_OP xp divide 4}
{VARIABLE_OP dam add xp}
{RANDOM 0..6}
{VARIABLE_OP dam add $random}
[if]
[variable]
name=dam
greater_than=$best_score
[/variable]
[then]
{VARIABLE best_score $dam}
{VARIABLE best_unit $i}
[/then]
[/if]
{NEXT i}
[recall]
id=$archer[$best_unit].id
@ -468,7 +468,7 @@
terrain=Rp
[/store_locations]
{FOREACH secret_path i}
{MODIFY_TERRAIN Gs^Fp $secret_path[$i].x $secret_path[$i].y}
{MODIFY_TERRAIN Gs^Fp $secret_path[$i].x $secret_path[$i].y}
{NEXT i}
# Rd -> Gg covered by forest
@ -477,7 +477,7 @@
terrain=Rd
[/store_locations]
{FOREACH secret_track i}
{MODIFY_TERRAIN Gs^Fp $secret_track[$i].x $secret_track[$i].y}
{MODIFY_TERRAIN Gs^Fp $secret_track[$i].x $secret_track[$i].y}
{NEXT i}
# urza dialogue variables
@ -528,7 +528,7 @@
[/and]
[/store_locations]
{FOREACH uncover i}
{MODIFY_TERRAIN Re $uncover[$i].x $uncover[$i].y}
{MODIFY_TERRAIN Re $uncover[$i].x $uncover[$i].y}
{NEXT i}
[store_locations]
variable=uncover
@ -540,7 +540,7 @@
[/and]
[/store_locations]
{FOREACH uncover i}
{MODIFY_TERRAIN Gg $uncover[$i].x $uncover[$i].y}
{MODIFY_TERRAIN Gg $uncover[$i].x $uncover[$i].y}
{NEXT i}
# check if a new dialogue part is needed

View file

@ -456,10 +456,10 @@
{MODIFY_UNIT side=4 side 5}
{FOREACH side_4_villages i}
[capture_village]
x,y=$side_4_villages[$i].x,$side_4_villages[$i].y
side=5
[/capture_village]
[capture_village]
x,y=$side_4_villages[$i].x,$side_4_villages[$i].y
side=5
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE stored_side_4}

View file

@ -290,12 +290,12 @@
[/unstore_unit]
{FOREACH stored_Sir_Gerrick_army i}
{VARIABLE stored_Sir_Gerrick_army[$i].x "recall"}
{VARIABLE stored_Sir_Gerrick_army[$i].y "recall"}
{VARIABLE stored_Sir_Gerrick_army[$i].x "recall"}
{VARIABLE stored_Sir_Gerrick_army[$i].y "recall"}
[unstore_unit]
variable=stored_Sir_Gerrick_army[$i]
[/unstore_unit]
[unstore_unit]
variable=stored_Sir_Gerrick_army[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_Sir_Gerrick_army}

View file

@ -359,13 +359,13 @@
[/filter]
[/store_unit]
{FOREACH enemy i}
{VARIABLE enemy[$i].variables.dehydration {THIRST_NUMBER}}
{VARIABLE enemy[$i].variables.full_hitpoints $enemy[$i].hitpoints}
{VARIABLE enemy[$i].variables.max_hitpoints $enemy[$i].max_hitpoints}
[unstore_unit]
variable=enemy[$i]
find_vacant=no
[/unstore_unit]
{VARIABLE enemy[$i].variables.dehydration {THIRST_NUMBER}}
{VARIABLE enemy[$i].variables.full_hitpoints $enemy[$i].hitpoints}
{VARIABLE enemy[$i].variables.max_hitpoints $enemy[$i].max_hitpoints}
[unstore_unit]
variable=enemy[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
#enddef
@ -378,32 +378,32 @@
[/filter]
[/store_unit]
{FOREACH enemy i}
{CLEAR_VARIABLE enemy[$i].ai_special}
[unit]
side={SIDE}
type=$enemy[$i].type
name=$enemy[$i].name
facing=$enemy[$i].facing
gender=$enemy[$i].gender
x=$enemy[$i].x
y=$enemy[$i].y
hitpoints=$enemy[$i].hitpoints
random_traits=no
canrecruit=$enemy[$i].canrecruit
experience=$enemy[$i].experience
role=$enemy[$i].role
moves=$enemy[$i].moves
attacks_left=$enemy[$i].attacks_left
[status]
slowed=$enemy[$i].status.slowed
poisoned=$enemy[$i].status.poisoned
[/status]
[variables]
dehydrated=$enemy[$i].variables.dehydrated
full_hitpoints=$enemy[$i].variables.full_hitpoints
max_hitpoints=$enemy[$i].variables.max_hitpoints
[/variables]
[/unit]
{CLEAR_VARIABLE enemy[$i].ai_special}
[unit]
side={SIDE}
type=$enemy[$i].type
name=$enemy[$i].name
facing=$enemy[$i].facing
gender=$enemy[$i].gender
x=$enemy[$i].x
y=$enemy[$i].y
hitpoints=$enemy[$i].hitpoints
random_traits=no
canrecruit=$enemy[$i].canrecruit
experience=$enemy[$i].experience
role=$enemy[$i].role
moves=$enemy[$i].moves
attacks_left=$enemy[$i].attacks_left
[status]
slowed=$enemy[$i].status.slowed
poisoned=$enemy[$i].status.poisoned
[/status]
[variables]
dehydrated=$enemy[$i].variables.dehydrated
full_hitpoints=$enemy[$i].variables.full_hitpoints
max_hitpoints=$enemy[$i].variables.max_hitpoints
[/variables]
[/unit]
{NEXT i}
#enddef
@ -425,178 +425,178 @@
#define APPLY_HYDRATION_EFFECT EFFECT_NUMBER
{FOREACH affected_unit i}
{VARIABLE effect {EFFECT_NUMBER}}
{VARIABLE thirst $affected_unit[$i].variables.dehydration}
{VARIABLE hp_to_regain 0}
# are we dehydrating or rehydrating?
[if]
[variable]
name=effect
greater_than=0
[/variable]
[then]
{VARIABLE_OP thirst add 1}
{VARIABLE green -30}
{VARIABLE_OP green multiply $thirst}
{VARIABLE_OP green add 280}
{VARIABLE effect {EFFECT_NUMBER}}
{VARIABLE thirst $affected_unit[$i].variables.dehydration}
{VARIABLE hp_to_regain 0}
# are we dehydrating or rehydrating?
[if]
[variable]
name=effect
greater_than=0
[/variable]
[then]
{VARIABLE_OP thirst add 1}
{VARIABLE green -30}
{VARIABLE_OP green multiply $thirst}
{VARIABLE_OP green add 280}
[if]
[variable]
name=green
less_than=0
[/variable]
[then]
{VARIABLE green 0}
[/then]
[/if]
{VARIABLE red 250}
{VARIABLE blue 52}
[/then]
[else]
# rehydrate
{VARIABLE hp_to_regain $thirst}
{VARIABLE_OP hp_to_regain multiply 2}
{VARIABLE red 170}
{VARIABLE green 230}
{VARIABLE blue 245}
[if]
[variable]
name=hp_to_regain
#ifdef EASY
greater_than=8
#else
greater_than=4
#endif
[/variable]
[then]
#ifdef EASY
{VARIABLE hp_to_regain 8}
#else
{VARIABLE hp_to_regain 4}
#endif
[/then]
[/if]
# make rehydrate silent if the unit isn't
# suffering dehydration
[if]
[variable]
name=thirst
less_than=1
[/variable]
[then]
{VARIABLE effect 0}
[/then]
[/if]
{VARIABLE thirst 0}
[/else]
[/if]
# modify attacks
{FOREACH affected_unit[$i].attack j}
[if]
[variable]
name=green
less_than=0
name=affected_unit[$i].attack[$j].range
equals=melee
[/variable]
[then]
{VARIABLE green 0}
{VARIABLE damage_multiplier 10}
[/then]
[else]
{VARIABLE damage_multiplier 20}
[/else]
[/if]
{VARIABLE red 250}
{VARIABLE blue 52}
[/then]
[else]
# rehydrate
{VARIABLE hp_to_regain $thirst}
{VARIABLE_OP hp_to_regain multiply 2}
{VARIABLE red 170}
{VARIABLE green 230}
{VARIABLE blue 245}
{VARIABLE damage_divisor $damage_multiplier}
{VARIABLE_OP damage_multiplier add -$thirst}
# store real_damage
[if]
[variable]
name=hp_to_regain
#ifdef EASY
greater_than=8
#else
greater_than=4
#endif
name=affected_unit[$i].attack[$j].real_damage
greater_than=0
[/variable]
[then]
#ifdef EASY
{VARIABLE hp_to_regain 8}
#else
{VARIABLE hp_to_regain 4}
#endif
[/then]
[else]
{VARIABLE affected_unit[$i].attack[$j].real_damage $affected_unit[$i].attack[$j].damage}
[/else]
[/if]
# make rehydrate silent if the unit isn't
# suffering dehydration
{VARIABLE new_damage $affected_unit[$i].attack[$j].real_damage}
{VARIABLE_OP new_damage multiply $damage_multiplier}
{VARIABLE_OP new_damage divide $damage_divisor}
[if]
[variable]
name=thirst
name=new_damage
less_than=1
[/variable]
[then]
{VARIABLE effect 0}
{VARIABLE new_damage 1}
[/then]
[/if]
{VARIABLE thirst 0}
[/else]
[/if]
# modify attacks
{FOREACH affected_unit[$i].attack j}
[if]
[variable]
name=affected_unit[$i].attack[$j].range
equals=melee
[/variable]
[then]
{VARIABLE damage_multiplier 10}
[/then]
[else]
{VARIABLE damage_multiplier 20}
[/else]
[/if]
{VARIABLE damage_divisor $damage_multiplier}
{VARIABLE_OP damage_multiplier add -$thirst}
# store real_damage
[if]
[variable]
name=affected_unit[$i].attack[$j].real_damage
greater_than=0
[/variable]
[else]
{VARIABLE affected_unit[$i].attack[$j].real_damage $affected_unit[$i].attack[$j].damage}
[/else]
[/if]
{VARIABLE new_damage $affected_unit[$i].attack[$j].real_damage}
{VARIABLE_OP new_damage multiply $damage_multiplier}
{VARIABLE_OP new_damage divide $damage_divisor}
[if]
[variable]
name=new_damage
less_than=1
[/variable]
[then]
{VARIABLE new_damage 1}
[/then]
[/if]
{VARIABLE affected_unit[$i].attack[$j].damage $new_damage}
{NEXT j}
# adjust current hp
[if]
[variable]
name=thirst
greater_than=0
[/variable]
[then]
{VARIABLE_OP affected_unit[$i].hitpoints add -$dehydration_loss}
{VARIABLE_OP affected_unit[$i].max_hitpoints add -$dehydration_loss}
{VARIABLE affected_unit[$i].variables.dehydration $thirst}
[/then]
[else]
{VARIABLE affected_unit[$i].attack[$j].damage $new_damage}
{NEXT j}
# adjust current hp
[if]
[variable]
name=thirst
greater_than=0
[/variable]
[then]
{VARIABLE_OP affected_unit[$i].hitpoints add -$dehydration_loss}
{VARIABLE_OP affected_unit[$i].max_hitpoints add -$dehydration_loss}
{VARIABLE affected_unit[$i].variables.dehydration $thirst}
[/then]
[else]
#ifdef HARD
#else
{VARIABLE_OP affected_unit[$i].hitpoints add $hp_to_regain}
{VARIABLE_OP affected_unit[$i].hitpoints add $hp_to_regain}
#endif
{VARIABLE affected_unit[$i].max_hitpoints $affected_unit[$i].variables.max_hitpoints}
{VARIABLE affected_unit[$i].variables.dehydration 0}
[/else]
[/if]
{VARIABLE hp_check $affected_unit[$i].hitpoints}
# check hp
[if]
[variable]
name=hp_check
less_than=1
[/variable]
[then]
{VARIABLE affected_unit[$i].hitpoints 1}
[/then]
[/if]
[if]
[variable]
name=effect
greater_than=0
[/variable]
[then]
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
red,green,blue=$red,$green,$blue
text= _ "thirst"
[/unstore_unit]
[/then]
[else]
[if]
[variable]
name=effect
not_equals=0
[/variable]
[then]
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
red,green,blue=$red,$green,$blue
text= _ "refreshed"
[/unstore_unit]
[/then]
[else]
# silent unstore
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
[/unstore_unit]
[/else]
[/if]
[/else]
[/if]
{VARIABLE affected_unit[$i].max_hitpoints $affected_unit[$i].variables.max_hitpoints}
{VARIABLE affected_unit[$i].variables.dehydration 0}
[/else]
[/if]
{VARIABLE hp_check $affected_unit[$i].hitpoints}
# check hp
[if]
[variable]
name=hp_check
less_than=1
[/variable]
[then]
{VARIABLE affected_unit[$i].hitpoints 1}
[/then]
[/if]
[if]
[variable]
name=effect
greater_than=0
[/variable]
[then]
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
red,green,blue=$red,$green,$blue
text= _ "thirst"
[/unstore_unit]
[/then]
[else]
[if]
[variable]
name=effect
not_equals=0
[/variable]
[then]
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
red,green,blue=$red,$green,$blue
text= _ "refreshed"
[/unstore_unit]
[/then]
[else]
# silent unstore
[unstore_unit]
variable=affected_unit[$i]
find_vacant=no
[/unstore_unit]
[/else]
[/if]
[/else]
[/if]
{NEXT i}
{CLEAR_VARIABLE hp_check}
{CLEAR_VARIABLE thirst}
@ -2011,13 +2011,13 @@
[/filter]
[/store_unit]
{FOREACH player_unit i}
{VARIABLE player_unit[$i].variables.full_hitpoints $player_unit[$i].hitpoints}
{VARIABLE player_unit[$i].variables.max_hitpoints $player_unit[$i].max_hitpoints}
{VARIABLE player_unit[$i].variables.dehydration 0}
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{VARIABLE player_unit[$i].variables.full_hitpoints $player_unit[$i].hitpoints}
{VARIABLE player_unit[$i].variables.max_hitpoints $player_unit[$i].max_hitpoints}
{VARIABLE player_unit[$i].variables.dehydration 0}
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[/event]
@ -2076,22 +2076,22 @@
[/filter]
[/store_unit]
{FOREACH player_unit i}
{VARIABLE thirst $player_unit[$i].variables.dehydration}
[if]
[variable]
name=thirst
greater_than=0
[/variable]
[then]
{VARIABLE_OP thirst multiply -$dehydration_loss}
{VARIABLE_OP thirst add $player_unit[$i].variables.max_hitpoints}
{VARIABLE player_unit[$i].max_hitpoints $thirst}
[/then]
[/if]
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{VARIABLE thirst $player_unit[$i].variables.dehydration}
[if]
[variable]
name=thirst
greater_than=0
[/variable]
[then]
{VARIABLE_OP thirst multiply -$dehydration_loss}
{VARIABLE_OP thirst add $player_unit[$i].variables.max_hitpoints}
{VARIABLE player_unit[$i].max_hitpoints $thirst}
[/then]
[/if]
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[/then]
[/if]
@ -2112,20 +2112,20 @@
[/filter]
[/store_unit]
{FOREACH player_unit i}
{VARIABLE hp_check $player_unit[$i].variables.max_hitpoints}
[if]
[variable]
name=hp_check
greater_than=0
[/variable]
[then]
{VARIABLE player_unit[$i].max_hitpoints $hp_check}
[/then]
[/if]
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{VARIABLE hp_check $player_unit[$i].variables.max_hitpoints}
[if]
[variable]
name=hp_check
greater_than=0
[/variable]
[then]
{VARIABLE player_unit[$i].max_hitpoints $hp_check}
[/then]
[/if]
[unstore_unit]
variable=player_unit[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[/event]
[/event]
@ -2146,13 +2146,13 @@
# silent rehydration
{APPLY_HYDRATION_EFFECT 0}
{FOREACH affected_unit i}
{CLEAR_VARIABLE affected_unit[$i].variables.full_hitpoints}
{CLEAR_VARIABLE affected_unit[$i].variables.max_hitpoints}
{CLEAR_VARIABLE affected_unit[$i].variables.dehydration}
[unstore_unit]
find_vacant=no
variable=affected_unit[$i]
[/unstore_unit]
{CLEAR_VARIABLE affected_unit[$i].variables.full_hitpoints}
{CLEAR_VARIABLE affected_unit[$i].variables.max_hitpoints}
{CLEAR_VARIABLE affected_unit[$i].variables.dehydration}
[unstore_unit]
find_vacant=no
variable=affected_unit[$i]
[/unstore_unit]
{NEXT i}
[if]

View file

@ -1041,62 +1041,62 @@
[/store_locations]
{VARIABLE i 0}
{FOREACH lava_hex i}
[store_unit]
[filter]
x,y=$lava_hex[$i].x,$lava_hex[$i].y
[/filter]
variable=unit_on_lava
[/store_unit]
# this code makes sure Kaleh stays unslowed
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
[variable]
name=unit_on_lava.id
equals=Kaleh
[/variable]
[then]
[set_variable]
name=unit_on_lava.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
[store_unit]
[filter]
x,y=$lava_hex[$i].x,$lava_hex[$i].y
[/filter]
variable=unit_on_lava
[/store_unit]
# this code makes sure Kaleh stays unslowed
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
[variable]
name=unit_on_lava.id
equals=Kaleh
[/variable]
[then]
[set_variable]
name=unit_on_lava.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
{VARIABLE heat_offset $heat_damage}
{VARIABLE_OP heat_offset multiply -1}
{VARIABLE damage_recived $lava_damage}
{VARIABLE_OP damage_recived add $heat_offset}
{CLEAR_VARIABLE heat_offset}
{VARIABLE heat_offset $heat_damage}
{VARIABLE_OP heat_offset multiply -1}
{VARIABLE damage_recived $lava_damage}
{VARIABLE_OP damage_recived add $heat_offset}
{CLEAR_VARIABLE heat_offset}
{VARIABLE_OP unit_on_lava.hitpoints add $damage_recived}
{VARIABLE damage_msg $damage_recived}
{VARIABLE_OP damage_msg multiply -1}
{CLEAR_VARIABLE damage_recived}
# if unitstats.hitpoints is < 1, unstore unit and kill it,
# else just unstore it
[unstore_unit]
variable=unit_on_lava
text=$damage_msg
{COLOR_HARM}
[/unstore_unit]
[if]
[variable]
name=unit_on_lava.hitpoints
less_than=1
[/variable]
[then]
[kill]
id=$unit_on_lava.id
fire_event=yes
animate=yes
[/kill]
[/then]
[/if]
{CLEAR_VARIABLE unit_on_lava}
{CLEAR_VARIABLE damage_msg}
{VARIABLE_OP unit_on_lava.hitpoints add $damage_recived}
{VARIABLE damage_msg $damage_recived}
{VARIABLE_OP damage_msg multiply -1}
{CLEAR_VARIABLE damage_recived}
# if unitstats.hitpoints is < 1, unstore unit and kill it,
# else just unstore it
[unstore_unit]
variable=unit_on_lava
text=$damage_msg
{COLOR_HARM}
[/unstore_unit]
[if]
[variable]
name=unit_on_lava.hitpoints
less_than=1
[/variable]
[then]
[kill]
id=$unit_on_lava.id
fire_event=yes
animate=yes
[/kill]
[/then]
[/if]
{CLEAR_VARIABLE unit_on_lava}
{CLEAR_VARIABLE damage_msg}
{NEXT i}
{CLEAR_VARIABLE lava_hex}
@ -1131,82 +1131,80 @@
[/store_locations]
{FOREACH locs i}
[set_variable]
name=temp_x
to_variable=locs[$i].x
[/set_variable]
[set_variable]
name=temp_x
to_variable=locs[$i].x
[/set_variable]
[set_variable]
name=temp_y
to_variable=locs[$i].y
[/set_variable]
[set_variable]
name=temp_y
to_variable=locs[$i].y
[/set_variable]
[store_unit]
[filter]
x,y=$temp_x,$temp_y
[/filter]
variable=unitstats
[/store_unit]
[store_unit]
[filter]
x,y=$temp_x,$temp_y
[/filter]
variable=unitstats
[/store_unit]
# this code makes sure Kaleh stays unslowed
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
# this code makes sure Kaleh stays unslowed
[if]
[variable]
name=unslow_kaleh
numerical_equals=1
[/variable]
[variable]
name=unitstats.id
equals=Kaleh
[/variable]
[variable]
name=unitstats.id
equals=Kaleh
[/variable]
[then]
[set_variable]
name=unitstats.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
[then]
[set_variable]
name=unitstats.status.slowed
value="off"
[/set_variable]
[/then]
[/if]
[set_variable]
name=unitstats.hitpoints
add=$heat_damage
[/set_variable]
[set_variable]
name=damage_msg
format=$heat_damage
[/set_variable]
[set_variable]
name=damage_msg
multiply=-1
[/set_variable]
#if unitstats.hitpoints is < 1, then set hitpoints to 1
[if]
[variable]
[set_variable]
name=unitstats.hitpoints
less_than=1
[/variable]
add=$heat_damage
[/set_variable]
[then]
[set_variable]
[set_variable]
name=damage_msg
format=$heat_damage
[/set_variable]
[set_variable]
name=damage_msg
multiply=-1
[/set_variable]
#if unitstats.hitpoints is < 1, then set hitpoints to 1
[if]
[variable]
name=unitstats.hitpoints
value=1
[/set_variable]
[/then]
[/if]
less_than=1
[/variable]
[unstore_unit]
text=$damage_msg
{COLOR_HARM}
variable=unitstats
[/unstore_unit]
[then]
[set_variable]
name=unitstats.hitpoints
value=1
[/set_variable]
[/then]
[/if]
{CLEAR_VARIABLE unitstats}
[unstore_unit]
text=$damage_msg
{COLOR_HARM}
variable=unitstats
[/unstore_unit]
{CLEAR_VARIABLE unitstats}
{NEXT i}
{CLEAR_VARIABLE locs}

View file

@ -5759,22 +5759,20 @@
[/store_locations]
{FOREACH shallowwater_loc i}
[set_variable]
name=water_x
to_variable=shallowwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_x
to_variable=shallowwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_y
to_variable=shallowwater_loc[$i].y
[/set_variable]
[terrain]
terrain=Ai
x,y=$water_x,$water_y
[/terrain]
[set_variable]
name=water_y
to_variable=shallowwater_loc[$i].y
[/set_variable]
[terrain]
terrain=Ai
x,y=$water_x,$water_y
[/terrain]
{NEXT i}
{CLEAR_VARIABLE shallowwater_loc}
@ -5791,47 +5789,43 @@
[/store_locations]
{FOREACH ice_loc i}
[set_variable]
name=coord_x
to_variable=ice_loc[$i].x
[/set_variable]
[set_variable]
name=coord_x
to_variable=ice_loc[$i].x
[/set_variable]
[set_variable]
name=coord_y
to_variable=ice_loc[$i].y
[/set_variable]
[set_variable]
name=coord_y
to_variable=ice_loc[$i].y
[/set_variable]
# find adjacent hex with cave floor or dirt
# find adjacent hex with cave floor or dirt
[store_locations]
[filter_adjacent_location]
x=$coord_x
y=$coord_y
[/filter_adjacent_location]
terrain=Uu, Re, Uu^Vu, Ce, Ke, Ch, Rr, Qxu, Uh, Uu^Uf, Ryd
variable=hex_loc
[/store_locations]
[store_locations]
[filter_adjacent_location]
x=$coord_x
y=$coord_y
[/filter_adjacent_location]
terrain=Uu, Re, Uu^Vu, Ce, Ke, Ch, Rr, Qxu, Uh, Uu^Uf, Ryd
variable=hex_loc
[/store_locations]
{FOREACH hex_loc j}
[set_variable]
name=water_x
to_variable=hex_loc[$j].x
[/set_variable]
{FOREACH hex_loc j}
[set_variable]
name=water_x
to_variable=hex_loc[$j].x
[/set_variable]
[set_variable]
name=water_y
to_variable=hex_loc[$j].y
[/set_variable]
[terrain]
terrain=Ww
x,y=$water_x,$water_y
[/terrain]
{NEXT j}
[set_variable]
name=water_y
to_variable=hex_loc[$j].y
[/set_variable]
[terrain]
terrain=Ww
x,y=$water_x,$water_y
[/terrain]
{NEXT j}
{NEXT i}
{CLEAR_VARIABLE ice_loc}
@ -5844,22 +5838,20 @@
[/store_locations]
{FOREACH shallowwater_loc i}
[set_variable]
name=water_x
to_variable=shallowwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_x
to_variable=shallowwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_y
to_variable=shallowwater_loc[$i].y
[/set_variable]
[terrain]
terrain=Wo
x,y=$water_x,$water_y
[/terrain]
[set_variable]
name=water_y
to_variable=shallowwater_loc[$i].y
[/set_variable]
[terrain]
terrain=Wo
x,y=$water_x,$water_y
[/terrain]
{NEXT i}
# 4. kill any unit in deep water, destroy any items in deep water
@ -5870,101 +5862,99 @@
[/store_locations]
{FOREACH deepwater_loc i}
[set_variable]
name=water_x
to_variable=deepwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_x
to_variable=deepwater_loc[$i].x
[/set_variable]
[set_variable]
name=water_y
to_variable=deepwater_loc[$i].y
[/set_variable]
[set_variable]
name=water_y
to_variable=deepwater_loc[$i].y
[/set_variable]
#destroy any items in deep water
[removeitem]
x,y=$water_x,$water_y
[/removeitem]
#destroy any items in deep water
[removeitem]
x,y=$water_x,$water_y
[/removeitem]
# If unit side is not 3 then kill unit. (side 3is undead who can't drown)
# Also if unit side is 1 then display death message: "I'm drowning!"
# If unit side is not 3 then kill unit. (side 3is undead who can't drown)
# Also if unit side is 1 then display death message: "I'm drowning!"
[store_locations]
x,y=$water_x,$water_y
[filter]
side=1,2,4,5,6,7,8,9
[/filter]
variable=victim_side
[/store_locations]
[store_locations]
x,y=$water_x,$water_y
[filter]
side=1,2,4,5,6,7,8,9
[/filter]
variable=victim_side
[/store_locations]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[then]
[store_locations]
x,y=$water_x,$water_y
[filter]
side=1
[/filter]
variable=victim_side
[/store_locations]
[then]
[store_locations]
x,y=$water_x,$water_y
[filter]
side=1
[/filter]
variable=victim_side
[/store_locations]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[then]
[message]
x,y=$water_x,$water_y
message= _ "Help, I'm drowning!"
[/message]
[/then]
[/if]
[then]
[message]
x,y=$water_x,$water_y
message= _ "Help, I'm drowning!"
[/message]
[/then]
[/if]
# if it is a human that drowned, set the flag
# flag is used for death event of 3 human spelunkers, to display
# alternate death message if the last of them dies from drowning
[store_locations]
x,y=$water_x,$water_y
[filter]
side=2
[/filter]
variable=victim_side
[/store_locations]
# if it is a human that drowned, set the flag
# flag is used for death event of 3 human spelunkers, to display
# alternate death message if the last of them dies from drowning
[store_locations]
x,y=$water_x,$water_y
[filter]
side=2
[/filter]
variable=victim_side
[/store_locations]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[if]
[variable]
name=victim_side.length
numerical_equals=1
[/variable]
[then]
[set_variable]
name=human_drowned
value=1
[/set_variable]
[/then]
[/if]
[then]
[set_variable]
name=human_drowned
value=1
[/set_variable]
[/then]
[/if]
[kill]
x,y=$water_x,$water_y
animate=no
fire_event=yes
[/kill]
#clear the flag
[set_variable]
name=human_drowned
value=0
[/set_variable]
[/then]
[/if]
[kill]
x,y=$water_x,$water_y
animate=no
fire_event=yes
[/kill]
#clear the flag
[set_variable]
name=human_drowned
value=0
[/set_variable]
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE deepwater_loc}

View file

@ -40,115 +40,113 @@
# And use foreach macro, that simulates an loop walking over an array from beginning to end.
{FOREACH outer_villages i}
# In this way for each village we declare an capture event
[event]
name=capture
delayed_variable_substitution=no
# That triggers for both side 1 and 3 on a village of coordinates x,y
[filter]
side=1,3
x=$outer_villages[$i].x
y=$outer_villages[$i].y
[/filter]
# In this way for each village we declare an capture event
[event]
name=capture
delayed_variable_substitution=no
# That triggers for both side 1 and 3 on a village of coordinates x,y
[filter]
side=1,3
x=$outer_villages[$i].x
y=$outer_villages[$i].y
[/filter]
# Now depending on which side captured the village there will be different outcomes.
[if]
# When unit capturing village belongs to a player
[variable]
name=unit.side
equals=1
[/variable]
[then]
# We generate a random number between 1 and 100
{VARIABLE_OP fate random 1..100}
# And check if it's lower than a treshold of finding an unit that's dependent on diffficulty level
# 60% on easy, 50% on normal, 40% on hard. We use preprocesor to choose apropriate chance
[if]
[variable]
name=fate
# Now depending on which side captured the village there will be different outcomes.
[if]
# When unit capturing village belongs to a player
[variable]
name=unit.side
equals=1
[/variable]
[then]
# We generate a random number between 1 and 100
{VARIABLE_OP fate random 1..100}
# And check if it's lower than a treshold of finding an unit that's dependent on diffficulty level
# 60% on easy, 50% on normal, 40% on hard. We use preprocesor to choose apropriate chance
[if]
[variable]
name=fate
#ifdef EASY
less_than_equal_to=60
less_than_equal_to=60
#endif
#ifdef NORMAL
less_than_equal_to=50
less_than_equal_to=50
#endif
#ifdef HARD
less_than_equal_to=40
less_than_equal_to=40
#endif
[/variable]
[then]
# So the RNG smiled upon the player, time to pick an random elf from pool we prepared in scenario_start
# but we have keep drawing until we hit a nonblank record, since some of them will be cleared already
# so we prepare a loop that's going to run until our check on random variable evaluates to ture.
# For this we need to set random to a value that will evaluate as false to guarantee at least one loop pass.
{VARIABLE fate $|elf_pool_counter}
[/variable]
[then]
# So the RNG smiled upon the player, time to pick an random elf from pool we prepared in scenario_start
# but we have keep drawing until we hit a nonblank record, since some of them will be cleared already
# so we prepare a loop that's going to run until our check on random variable evaluates to ture.
# For this we need to set random to a value that will evaluate as false to guarantee at least one loop pass.
{VARIABLE fate $|elf_pool_counter}
[while]
[variable]
name=fate
equals=$elf_pool_counter
[/variable]
[do]
# Now we can draw an elf. It's important to remember that even though we have $elf_pool_counter
# units, they are indexed from 0 so we need to substract 1 from drawn number
{VARIABLE_OP fate random 1..$|elf_pool_counter}
{VARIABLE_OP fate add -1}
# Create an unit with data drawn and place it on an empty hex by the village, since he village itself is occupied
[if]
[variable]
name=flagset[$fate].flag
equals=set
[/variable]
[then]
{VARIABLE fate $|elf_pool_counter}
[/then]
[else]
{VARIABLE flagset[$|fate].flag set}
{LOYAL_UNIT 1 $|elf_pool[$|fate].type $|x1 $|y1 $|elf_pool[$|fate].id $|elf_pool[$|fate].name}
[/else]
[/if]
[/do]
[/while]
[while]
[variable]
name=fate
equals=$elf_pool_counter
[/variable]
[do]
# Now we can draw an elf. It's important to remember that even though we have $elf_pool_counter
# units, they are indexed from 0 so we need to substract 1 from drawn number
{VARIABLE_OP fate random 1..$|elf_pool_counter}
{VARIABLE_OP fate add -1}
# Create an unit with data drawn and place it on an empty hex by the village, since he village itself is occupied
[if]
[variable]
name=flagset[$fate].flag
equals=set
[/variable]
[then]
{VARIABLE fate $|elf_pool_counter}
[/then]
[else]
{VARIABLE flagset[$|fate].flag set}
{LOYAL_UNIT 1 $|elf_pool[$|fate].type $|x1 $|y1 $|elf_pool[$|fate].id $|elf_pool[$|fate].name}
[/else]
[/if]
[/do]
[/while]
# When done remove uniit from the pool
{CLEAR_VARIABLE elf_pool[$|fate]}
# When done remove uniit from the pool
{CLEAR_VARIABLE elf_pool[$|fate]}
# And write joyful message
# And write joyful message
[message]
speaker=unit
message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
[/message]
[/then]
# And when RNG plays hard ball we need to inform the player he's out of luck
[else]
[message]
speaker=unit
message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
[/message]
[/else]
[/if]
[/then]
# When the unit belongs to the bad guy... Tough luck, there is actualy no bonus from that now, so we just set up another event
# this time for player only for the time he recaptures the village.
[else]
[event]
name=capture
[filter]
side=1
x=$x1
y=$y1
[/filter]
[message]
speaker=unit
message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
[/message]
[/then]
# And when RNG plays hard ball we need to inform the player he's out of luck
[else]
[message]
speaker=unit
message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
[/message]
[/else]
[/if]
[/then]
# When the unit belongs to the bad guy... Tough luck, there is actualy no bonus from that now, so we just set up another event
# this time for player only for the time he recaptures the village.
[else]
[event]
name=capture
[filter]
side=1
x=$x1
y=$y1
[/filter]
[message]
speaker=unit
message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
[/message]
[/event]
[/else]
[/if]
[/event]
[/event]
[/else]
[/if]
[/event]
{NEXT i}
{CLEAR_VARIABLE i}
@ -163,29 +161,29 @@
{VARIABLE i 0}
{FOREACH elf_pool i}
[if]
[variable]
name=elf_pool[$i].type
not_equals=$empty
[/variable]
[then]
[unit]
side=1
type=$elf_pool[$random].type
id=$elf_pool[$random].id
name=$elf_pool[$random].name
gender=$elf_pool[$random].gender
x=$x1
y=$y1
animate=yes
[if]
[variable]
name=elf_pool[$i].type
not_equals=$empty
[/variable]
[then]
[unit]
side=1
type=$elf_pool[$random].type
id=$elf_pool[$random].id
name=$elf_pool[$random].name
gender=$elf_pool[$random].gender
x=$x1
y=$y1
animate=yes
#ifdef EASY
[modifications]
{TRAIT_LOYAL}
[/modifications]
[modifications]
{TRAIT_LOYAL}
[/modifications]
#endif
[/unit]
[/then]
[/if]
[/unit]
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE elf_pool}
{CLEAR_VARIABLE elf_pool_counter}

View file

@ -225,13 +225,13 @@
{VARIABLE i 0}
#ifdef HARD
{FOREACH azkotep_casaulties i}
{VARIABLE azkotep_casaulties[$i].unit.side 2}
[unstore_unit]
variable=azkotep_casaulties[$i].unit
x=21
y=24
find_vacant=yes
[/unstore_unit]
{VARIABLE azkotep_casaulties[$i].unit.side 2}
[unstore_unit]
variable=azkotep_casaulties[$i].unit
x=21
y=24
find_vacant=yes
[/unstore_unit]
{NEXT i}
#else
[while]
@ -390,13 +390,13 @@
{VARIABLE i 0}
#ifdef HARD
{FOREACH ystara_casaulties i}
{VARIABLE ystara_casaulties[$i].side 3}
[unstore_unit]
variable=ystara_casaulties[$i].unit
x=23
y=6
find_vacant=yes
[/unstore_unit]
{VARIABLE ystara_casaulties[$i].side 3}
[unstore_unit]
variable=ystara_casaulties[$i].unit
x=23
y=6
find_vacant=yes
[/unstore_unit]
{NEXT i}
#else
[while]
@ -667,13 +667,13 @@
{VARIABLE i 0}
#ifdef HARD
{FOREACH ystara_casaulties i}
{VARIABLE ystara_casaulties[$i].unit.side 3}
[unstore_unit]
variable=ystara_casaulties[$i].unit
x=23
y=6
find_vacant=yes
[/unstore_unit]
{VARIABLE ystara_casaulties[$i].unit.side 3}
[unstore_unit]
variable=ystara_casaulties[$i].unit
x=23
y=6
find_vacant=yes
[/unstore_unit]
{NEXT i}
#else
[while]
@ -957,13 +957,13 @@
{VARIABLE i 0}
#ifdef HARD
{FOREACH azkotep_casaulties i}
{VARIABLE azkotep_casaulties[$i].unit.side 2}
[unstore_unit]
variable=azkotep_casaulties[$i].unit
x=21
y=24
find_vacant=yes
[/unstore_unit]
{VARIABLE azkotep_casaulties[$i].unit.side 2}
[unstore_unit]
variable=azkotep_casaulties[$i].unit
x=21
y=24
find_vacant=yes
[/unstore_unit]
{NEXT i}
#else
[while]

View file

@ -25,23 +25,23 @@
{VARIABLE i 0}
{FOREACH tents i}
{RANDOM 0..100}
{VARIABLE_OP random add -tents[i].y}
[if]
[variable]
name=random
less_than=$rally_chance
[/variable]
{RANDOM 0..100}
{VARIABLE_OP random add -tents[i].y}
[if]
[variable]
name=random
less_than=$rally_chance
[/variable]
[then]
[recall]
side=1
x=$tents[$i].x
y=$tents[$i].y
[/recall]
{VARIABLE_OP rally_chance add -3}
[/then]
[/if]
[then]
[recall]
side=1
x=$tents[$i].x
y=$tents[$i].y
[/recall]
{VARIABLE_OP rally_chance add -3}
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE tents}
{CLEAR_VARIABLE i}

View file

@ -26,11 +26,11 @@
[/filter]
[/store_unit]
{FOREACH player_unit i}
{VARIABLE player_unit[$i].upkeep "full"}
{VARIABLE player_unit[$i].morale ""}
[unstore_unit]
variable=player_unit[$i]
[/unstore_unit]
{VARIABLE player_unit[$i].upkeep "full"}
{VARIABLE player_unit[$i].morale ""}
[unstore_unit]
variable=player_unit[$i]
[/unstore_unit]
{NEXT i}
[store_unit]
variable=player_unit
@ -43,11 +43,11 @@
[/filter]
[/store_unit]
{FOREACH player_unit i}
{VARIABLE player_unit[$i].upkeep "loyal"}
{VARIABLE player_unit[$i].morale "loyalized"}
[unstore_unit]
variable=player_unit[$i]
[/unstore_unit]
{VARIABLE player_unit[$i].upkeep "loyal"}
{VARIABLE player_unit[$i].morale "loyalized"}
[unstore_unit]
variable=player_unit[$i]
[/unstore_unit]
{NEXT i}
[allow_undo]
[/allow_undo]
@ -103,21 +103,21 @@
[/filter]
[/store_unit]
{FOREACH zoc_unit i}
{VARIABLE zoc_unit[$i].role ""}
[unstore_unit]
variable=zoc_unit[$i]
[/unstore_unit]
[object]
silent=yes
[filter]
x=$zoc_unit[$i].x
y=$zoc_unit[$i].y
[/filter]
[effect]
apply_to=zoc
value=1
[/effect]
[/object]
{VARIABLE zoc_unit[$i].role ""}
[unstore_unit]
variable=zoc_unit[$i]
[/unstore_unit]
[object]
silent=yes
[filter]
x=$zoc_unit[$i].x
y=$zoc_unit[$i].y
[/filter]
[effect]
apply_to=zoc
value=1
[/effect]
[/object]
{NEXT i}
[/event]
# upgrade leadership event

View file

@ -173,15 +173,15 @@ multiply=-1
kill=no
[/store_unit]
{FOREACH UNIT_OVERLAY_store UNIT_OVERLAY_i}
{VARIABLE_OP UNIT_OVERLAY_tempx format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].x}
{VARIABLE_OP UNIT_OVERLAY_tempy format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].y}
[unit_overlay]
x=$UNIT_OVERLAY_tempx
y=$UNIT_OVERLAY_tempy
image={IMAGE}
[/unit_overlay]
{VARIABLE_OP UNIT_OVERLAY_tempx format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].x}
{VARIABLE_OP UNIT_OVERLAY_tempy format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].y}
[unit_overlay]
x=$UNIT_OVERLAY_tempx
y=$UNIT_OVERLAY_tempy
image={IMAGE}
[/unit_overlay]
{NEXT UNIT_OVERLAY_i}
{CLEAR_VARIABLE UNIT_OVERLAY_store}
#enddef
@ -195,15 +195,15 @@ multiply=-1
kill=no
[/store_unit]
{FOREACH UNIT_OVERLAY_store UNIT_OVERLAY_i}
{VARIABLE_OP UNIT_OVERLAY_tempx format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].x}
{VARIABLE_OP UNIT_OVERLAY_tempy format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].y}
[remove_unit_overlay]
x=$UNIT_OVERLAY_tempx
y=$UNIT_OVERLAY_tempy
image={IMAGE}
[/remove_unit_overlay]
{VARIABLE_OP UNIT_OVERLAY_tempx format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].x}
{VARIABLE_OP UNIT_OVERLAY_tempy format
$UNIT_OVERLAY_store[$UNIT_OVERLAY_i].y}
[remove_unit_overlay]
x=$UNIT_OVERLAY_tempx
y=$UNIT_OVERLAY_tempy
image={IMAGE}
[/remove_unit_overlay]
{NEXT UNIT_OVERLAY_i}
{CLEAR_VARIABLE UNIT_OVERLAY_store}
#enddef

View file

@ -149,15 +149,15 @@
[then]
{VARIABLE commented 0}
{FOREACH galdrad_comments i}
[if]
[variable]
name=galdrad_comments[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE commented 1}
[/then]
[/if]
[if]
[variable]
name=galdrad_comments[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE commented 1}
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE i}
@ -197,15 +197,15 @@
# does not seem to find it the second time. Some internal bug?
{FOREACH unit_complained i}
[if]
[variable]
name=unit_complained[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE complained 1}
[/then]
[/if]
[if]
[variable]
name=unit_complained[$i].id
equals=${NAME}.id
[/variable]
[then]
{VARIABLE complained 1}
[/then]
[/if]
{NEXT i}
[if]
@ -469,42 +469,42 @@ One Elvish Shaman")}
{VARIABLE recall_xp1 0}
{VARIABLE recall_xp2 0}
{FOREACH recall i}
{VARIABLE temp_xp $recall[$i].experience}
{VARIABLE_OP temp_xp add $recall[$i].variables.previous_xp}
[if]
[variable]
name=temp_xp
greater_than=$recall_xp1
[/variable]
[then]
# Move anything from slot 1 to slot 2
[if]
[variable]
name=recall_xp1
greater_than=0
[/variable]
[then]
{VARIABLE_OP recall_i2 format $recall_i1}
{VARIABLE_OP recall_xp2 format $recall_xp1}
[/then]
[/if]
{VARIABLE temp_xp $recall[$i].experience}
{VARIABLE_OP temp_xp add $recall[$i].variables.previous_xp}
[if]
[variable]
name=temp_xp
greater_than=$recall_xp1
[/variable]
[then]
# Move anything from slot 1 to slot 2
[if]
[variable]
name=recall_xp1
greater_than=0
[/variable]
[then]
{VARIABLE_OP recall_i2 format $recall_i1}
{VARIABLE_OP recall_xp2 format $recall_xp1}
[/then]
[/if]
{VARIABLE_OP recall_i1 format $i}
{VARIABLE_OP recall_xp1 format $temp_xp}
[/then]
[else]
[if]
[variable]
name=temp_xp
greater_than=$recall_xp2
[/variable]
[then]
{VARIABLE_OP recall_i2 format $i}
{VARIABLE_OP recall_xp2 format $temp_xp}
[/then]
[/if]
[/else]
[/if]
{VARIABLE_OP recall_i1 format $i}
{VARIABLE_OP recall_xp1 format $temp_xp}
[/then]
[else]
[if]
[variable]
name=temp_xp
greater_than=$recall_xp2
[/variable]
[then]
{VARIABLE_OP recall_i2 format $i}
{VARIABLE_OP recall_xp2 format $temp_xp}
[/then]
[/if]
[/else]
[/if]
{NEXT i}
{CLEAR_VARIABLE i}

View file

@ -60,21 +60,21 @@
[/scroll_to]
{FOREACH HIGHLIGHT_UNIT_temp i}
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
{NEXT i}
[redraw][/redraw]
[delay]
time=300
[/delay]
{FOREACH HIGHLIGHT_UNIT_temp i}
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[redraw][/redraw]
[delay]
@ -82,21 +82,21 @@
[/delay]
{FOREACH HIGHLIGHT_UNIT_temp i}
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
{NEXT i}
[redraw][/redraw]
[delay]
time=300
[/delay]
{FOREACH HIGHLIGHT_UNIT_temp i}
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[redraw][/redraw]
[delay]
@ -104,21 +104,21 @@
[/delay]
{FOREACH HIGHLIGHT_UNIT_temp i}
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
[kill]
x,y=$HIGHLIGHT_UNIT_temp[$i].x,$HIGHLIGHT_UNIT_temp[$i].y
fire_event=no
animate=no
[/kill]
{NEXT i}
[redraw][/redraw]
[delay]
time=300
[/delay]
{FOREACH HIGHLIGHT_UNIT_temp i}
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=HIGHLIGHT_UNIT_temp[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
[redraw][/redraw]
[delay]

View file

@ -147,29 +147,29 @@
[/filter]
{FOREACH side_{SIDE}_limited_recruits i}
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].type
equals=$unit.type
[/variable]
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].type
equals=$unit.type
[/variable]
[then]
{VARIABLE_OP side_{SIDE}_limited_recruits[$i].number_recruited add 1}
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].number_recruited
greater_than_equal_to={LIMIT_NUMBER}
[/variable]
[then]
{VARIABLE_OP side_{SIDE}_limited_recruits[$i].number_recruited add 1}
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].number_recruited
greater_than_equal_to={LIMIT_NUMBER}
[/variable]
[then]
[disallow_recruit]
side={SIDE}
type={TYPE}
[/disallow_recruit]
[/then]
[/if]
[/then]
[/if]
[then]
[disallow_recruit]
side={SIDE}
type={TYPE}
[/disallow_recruit]
[/then]
[/if]
[/then]
[/if]
{NEXT i}
[/event]
#enddef

View file

@ -153,27 +153,27 @@
[/set_variable]
{FOREACH ADVANCE_UNIT_store i}
[if]
[variable]
name=advanceto_len
greater_than=0
[/variable]
[then]
[set_variable]
name=ADVANCE_UNIT_store[$i].advances_to
value={ADVANCETO}
[/set_variable]
[/then]
[/if]
[set_variable]
name=ADVANCE_UNIT_store[$i].experience
value=$ADVANCE_UNIT_store[$i].max_experience
[/set_variable]
[unstore_unit]
variable=ADVANCE_UNIT_store[$i]
find_vacant=no
advance=true
[/unstore_unit]
[if]
[variable]
name=advanceto_len
greater_than=0
[/variable]
[then]
[set_variable]
name=ADVANCE_UNIT_store[$i].advances_to
value={ADVANCETO}
[/set_variable]
[/then]
[/if]
[set_variable]
name=ADVANCE_UNIT_store[$i].experience
value=$ADVANCE_UNIT_store[$i].max_experience
[/set_variable]
[unstore_unit]
variable=ADVANCE_UNIT_store[$i]
find_vacant=no
advance=true
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE ADVANCE_UNIT_store}
{CLEAR_VARIABLE advanceto_len}
@ -193,42 +193,42 @@
[/store_unit]
{ADVANCE_UNIT ({T_FILTER}) ({TRANSFORMTO}) }
{FOREACH TU_store i}
[store_unit]
[filter]
x,y=$TU_store[$i].x,$TU_store[$i].y
[/filter]
variable=TUrestore_store
kill=yes
[/store_unit]
[set_variables]
name=TUrestore_store
mode=merge
[value]
hitpoints=$TU_store[$i].hitpoints
experience=$TU_store[$i].experience
[insert_tag]
name=status
variable=TU_store[$i].status
[/insert_tag]
[/value]
[/set_variables]
[if]
[variable]
name=TUrestore_store.status.not_living
boolean_equals=true
[/variable]
[then]
[clear_variable]
name=TUrestore_store.status.poisoned
[/clear_variable]
[/then]
[/if]
[unstore_unit]
variable=TUrestore_store
find_vacant=no
advance=false
[/unstore_unit]
{CLEAR_VARIABLE TUrestore_store}
[store_unit]
[filter]
x,y=$TU_store[$i].x,$TU_store[$i].y
[/filter]
variable=TUrestore_store
kill=yes
[/store_unit]
[set_variables]
name=TUrestore_store
mode=merge
[value]
hitpoints=$TU_store[$i].hitpoints
experience=$TU_store[$i].experience
[insert_tag]
name=status
variable=TU_store[$i].status
[/insert_tag]
[/value]
[/set_variables]
[if]
[variable]
name=TUrestore_store.status.not_living
boolean_equals=true
[/variable]
[then]
[clear_variable]
name=TUrestore_store.status.poisoned
[/clear_variable]
[/then]
[/if]
[unstore_unit]
variable=TUrestore_store
find_vacant=no
advance=false
[/unstore_unit]
{CLEAR_VARIABLE TUrestore_store}
{NEXT i}
{CLEAR_VARIABLE TU_store}
#enddef

View file

@ -102,6 +102,9 @@
#enddef
# wmlindent: stop ignoring
# wmlindent: opener "{FOREACH "
# wmlindent: closer "{NEXT "
#define REPEAT NUMBER BODY_WML
{VARIABLE REPEAT_i 0}
@ -147,15 +150,15 @@
[/store_unit]
{FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
[set_variable]
name=MODIFY_UNIT_store[$MODIFY_UNIT_i].{VAR}
value={VALUE}
[/set_variable]
[set_variable]
name=MODIFY_UNIT_store[$MODIFY_UNIT_i].{VAR}
value={VALUE}
[/set_variable]
[unstore_unit]
variable=MODIFY_UNIT_store[$MODIFY_UNIT_i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=MODIFY_UNIT_store[$MODIFY_UNIT_i]
find_vacant=no
[/unstore_unit]
{NEXT MODIFY_UNIT_i}
{CLEAR_VARIABLE MODIFY_UNIT_store}
@ -310,14 +313,14 @@
[/store_unit]
{FOREACH FULL_HEAL_temp FULL_HEAL_i}
[set_variable]
name=FULL_HEAL_temp[$FULL_HEAL_i].hitpoints
value=$FULL_HEAL_temp[$FULL_HEAL_i].max_hitpoints
[/set_variable]
[unstore_unit]
find_vacant=no
variable=FULL_HEAL_temp[$FULL_HEAL_i]
[/unstore_unit]
[set_variable]
name=FULL_HEAL_temp[$FULL_HEAL_i].hitpoints
value=$FULL_HEAL_temp[$FULL_HEAL_i].max_hitpoints
[/set_variable]
[unstore_unit]
find_vacant=no
variable=FULL_HEAL_temp[$FULL_HEAL_i]
[/unstore_unit]
{NEXT FULL_HEAL_i}
{CLEAR_VARIABLE FULL_HEAL_temp}
@ -352,13 +355,13 @@
[/store_unit]
{FOREACH PUT_TO_RECALL_LIST_temp i}
{VARIABLE PUT_TO_RECALL_LIST_temp[$i].x "recall"}
{VARIABLE PUT_TO_RECALL_LIST_temp[$i].y "recall"}
{VARIABLE PUT_TO_RECALL_LIST_temp[$i].x "recall"}
{VARIABLE PUT_TO_RECALL_LIST_temp[$i].y "recall"}
[unstore_unit]
variable=PUT_TO_RECALL_LIST_temp[$i]
find_vacant=no
[/unstore_unit]
[unstore_unit]
variable=PUT_TO_RECALL_LIST_temp[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
#enddef
@ -382,10 +385,10 @@
[/store_locations]
{FOREACH temp_starting_villages i}
[capture_village]
side={SIDE}
x,y=$temp_starting_villages[$i].x,$temp_starting_villages[$i].y
[/capture_village]
[capture_village]
side={SIDE}
x,y=$temp_starting_villages[$i].x,$temp_starting_villages[$i].y
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE temp_starting_villages}
@ -407,10 +410,10 @@
[/store_locations]
{FOREACH temp_starting_villages_area i}
[capture_village]
side={SIDE}
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
[capture_village]
side={SIDE}
x,y=$temp_starting_villages_area[$i].x,$temp_starting_villages_area[$i].y
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE temp_starting_villages_area}
@ -427,10 +430,10 @@
[/store_villages]
{FOREACH TRANSFER_VILLAGE_OWNERSHIP_villages TRANSFER_VILLAGE_OWNERSHIP_i}
[capture_village]
x,y=$TRANSFER_VILLAGE_OWNERSHIP_villages[$TRANSFER_VILLAGE_OWNERSHIP_i].x,$TRANSFER_VILLAGE_OWNERSHIP_villages[$TRANSFER_VILLAGE_OWNERSHIP_i].y
side={TO_SIDE}
[/capture_village]
[capture_village]
x,y=$TRANSFER_VILLAGE_OWNERSHIP_villages[$TRANSFER_VILLAGE_OWNERSHIP_i].x,$TRANSFER_VILLAGE_OWNERSHIP_villages[$TRANSFER_VILLAGE_OWNERSHIP_i].y
side={TO_SIDE}
[/capture_village]
{NEXT TRANSFER_VILLAGE_OWNERSHIP_i}
{CLEAR_VARIABLE TRANSFER_VILLAGE_OWNERSHIP_villages}

View file

@ -56,42 +56,42 @@
[/filter]
[/store_unit]
{FOREACH spawns id}
{VARIABLE movement $spawns[$id].max_moves}
{VARIABLE_OP movement multiply 0.33}
{VARIABLE_OP movement add 1}
{VARIABLE unit_name $spawns[$id].name}
[unit]
side=$timid_ai_side
type=$spawns[$id].type
x=$spawns[$id].x
y=$spawns[$id].y
generate_name=yes
random_traits=no
[modifications]
[object]
[effect]
apply_to=movement
set=$movement
[/effect]
[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]
[/modifications]
[status]
poisoned="no"
slowed="on"
[/status]
[/unit]
{VARIABLE movement $spawns[$id].max_moves}
{VARIABLE_OP movement multiply 0.33}
{VARIABLE_OP movement add 1}
{VARIABLE unit_name $spawns[$id].name}
[unit]
side=$timid_ai_side
type=$spawns[$id].type
x=$spawns[$id].x
y=$spawns[$id].y
generate_name=yes
random_traits=no
[modifications]
[object]
[effect]
apply_to=movement
set=$movement
[/effect]
[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]
[/modifications]
[status]
poisoned="no"
slowed="on"
[/status]
[/unit]
{NEXT id}
{CLEAR_VARIABLE spawns}
[store_unit]
@ -108,36 +108,36 @@
[/store_unit]
{VARIABLE msg "Spawning: "}
{FOREACH spawns id}
{VARIABLE spawns[$id].x $spawn_x}
{VARIABLE spawns[$id].y $spawn_y}
{RANDOMIZE 3}
{VARIABLE position "se"}
[if]
[variable]
name=random
numerical_equals=1
[/variable]
[then]
{VARIABLE position "sw"}
[/then]
[/if]
{VARIABLE spawns[$id].facing $position}
{VARIABLE_OP msg format "$msg
{VARIABLE spawns[$id].x $spawn_x}
{VARIABLE spawns[$id].y $spawn_y}
{RANDOMIZE 3}
{VARIABLE position "se"}
[if]
[variable]
name=random
numerical_equals=1
[/variable]
[then]
{VARIABLE position "sw"}
[/then]
[/if]
{VARIABLE spawns[$id].facing $position}
{VARIABLE_OP msg format "$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]
[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
@ -166,59 +166,58 @@
[/filter]
[/store_unit]
{FOREACH ai_unit id}
{VARIABLE name $ai_unit[$id].name}
{VARIABLE type $ai_unit[$id].type}
{VARIABLE hitpoints $ai_unit[$id].hitpoints}
{VARIABLE max_hp $ai_unit[$i].max_hitpoints}
{VARIABLE facing $ai_unit[$id].facing}
{VARIABLE gender $ai_unit[$id].gender}
{VARIABLE experience $ai_unit[$id].experience}
{VARIABLE poisoned $ai_unit[$id].status.poisoned}
{VARIABLE slowed $ai_unit[$id].status.slowed}
{VARIABLE hidden $ai_unit[$id].status.hidden}
{VARIABLE x $ai_unit[$id].x}
{VARIABLE y $ai_unit[$id].y}
[if]
[variable]
name=ai_unit[$id].race
equals="undead"
[/variable]
[then]
{VARIABLE name ""}
[/then]
[/if]
[unit]
type=$type
side={SIDE2}
x=$x
y=$y
experience=$experience
facing=$facing
gender=$gender
name=$name
random_traits=yes
[status]
hidden=$hidden
slowed=$slowed
poisoned=$poisoned
[/status]
[/unit]
# set hp now to adjust for trait bonuses
[store_unit]
variable=last_spawn
kill=no
[filter]
{VARIABLE name $ai_unit[$id].name}
{VARIABLE type $ai_unit[$id].type}
{VARIABLE hitpoints $ai_unit[$id].hitpoints}
{VARIABLE max_hp $ai_unit[$i].max_hitpoints}
{VARIABLE facing $ai_unit[$id].facing}
{VARIABLE gender $ai_unit[$id].gender}
{VARIABLE experience $ai_unit[$id].experience}
{VARIABLE poisoned $ai_unit[$id].status.poisoned}
{VARIABLE slowed $ai_unit[$id].status.slowed}
{VARIABLE hidden $ai_unit[$id].status.hidden}
{VARIABLE x $ai_unit[$id].x}
{VARIABLE y $ai_unit[$id].y}
[if]
[variable]
name=ai_unit[$id].race
equals="undead"
[/variable]
[then]
{VARIABLE name ""}
[/then]
[/if]
[unit]
type=$type
side={SIDE2}
x,y = $x,$y
[/filter]
[/store_unit]
{VARIABLE hp_add $last_spawn.max_hitpoints}
{VARIABLE_OP hp_add add -$max_hp}
{VARIABLE_OP $last_spawn.hitpoints add $hp_add}
[unstore_unit]
variable=last_spawn
[/unstore_unit]
x=$x
y=$y
experience=$experience
facing=$facing
gender=$gender
name=$name
random_traits=yes
[status]
hidden=$hidden
slowed=$slowed
poisoned=$poisoned
[/status]
[/unit]
# set hp now to adjust for trait bonuses
[store_unit]
variable=last_spawn
kill=no
[filter]
side={SIDE2}
x,y = $x,$y
[/filter]
[/store_unit]
{VARIABLE hp_add $last_spawn.max_hitpoints}
{VARIABLE_OP hp_add add -$max_hp}
{VARIABLE_OP $last_spawn.hitpoints add $hp_add}
[unstore_unit]
variable=last_spawn
[/unstore_unit]
{NEXT id}
{CLEAR_VARIABLE ai_unit}
{CLEAR_VARIABLE type}
@ -307,89 +306,89 @@
[/filter]
[/store_unit]
{FOREACH new_spawn unit_id}
{VARIABLE spawn_id $new_spawn[$unit_id].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]
{VARIABLE yind $new_spawn[$unit_id].y}
[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 add -$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
[/unit]
[store_unit]
variable=advancement
kill=yes
[filter]
{VARIABLE spawn_id $new_spawn[$unit_id].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]
{VARIABLE yind $new_spawn[$unit_id].y}
[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 add -$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
side={SIDE}
[/filter]
[/store_unit]
{VARIABLE upgrade_cost $advancement.cost}
{VARIABLE_OP upgrade_cost add -$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 add -$upgrade_cost}
### DEBUG
{VARIABLE_OP total_cost add $upgrade_cost}
{VARIABLE new_spawn[$unit_id].type $advanceto}
{VARIABLE new_spawn[$unit_id].role $next_role}
[/then]
[/if]
[/else]
[/if]
[/then]
[/if]
[unstore_unit]
variable=new_spawn[$unit_id]
find_vacant=yes
[/unstore_unit]
[/unit]
[store_unit]
variable=advancement
kill=yes
[filter]
x=20
y=22
side={SIDE}
[/filter]
[/store_unit]
{VARIABLE upgrade_cost $advancement.cost}
{VARIABLE_OP upgrade_cost add -$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 add -$upgrade_cost}
### DEBUG
{VARIABLE_OP total_cost add $upgrade_cost}
{VARIABLE new_spawn[$unit_id].type $advanceto}
{VARIABLE new_spawn[$unit_id].role $next_role}
[/then]
[/if]
[/else]
[/if]
[/then]
[/if]
[unstore_unit]
variable=new_spawn[$unit_id]
find_vacant=yes
[/unstore_unit]
{NEXT unit_id}
{CLEAR_VARIABLE new_spawn}
#enddef

View file

@ -284,11 +284,11 @@
[/store_unit]
{FOREACH this_side_workers i}
{CLEAR_VARIABLE this_side_workers[$i].status.worked_this_turn}
{CLEAR_VARIABLE this_side_workers[$i].status.worked_this_turn}
[unstore_unit]
variable=this_side_workers[$i]
[/unstore_unit]
[unstore_unit]
variable=this_side_workers[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE this_side_workers}
@ -363,22 +363,22 @@
[/store_unit]
{FOREACH stored_guardians i}
[object]
silent=yes
duration=forever
[filter]
x=$stored_guardians[$i].x
y=$stored_guardians[$i].y
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
flat=UNREACHABLE
sand=UNREACHABLE
[/movement_costs]
[/effect]
[/object]
[object]
silent=yes
duration=forever
[filter]
x=$stored_guardians[$i].x
y=$stored_guardians[$i].y
[/filter]
[effect]
apply_to=movement_costs
replace=true
[movement_costs]
flat=UNREACHABLE
sand=UNREACHABLE
[/movement_costs]
[/effect]
[/object]
{NEXT i}
{CLEAR_VARIABLE stored_guardians}

View file

@ -24,21 +24,21 @@
{VARIABLE sound no}
{FOREACH researchers i}
{VARIABLE_OP temp_x format "$researchers[$i].x"}
{VARIABLE_OP temp_y format "$researchers[$i].y"}
{VARIABLE_OP temp_x format "$researchers[$i].x"}
{VARIABLE_OP temp_y format "$researchers[$i].y"}
{VARIABLE_OP credited_side format $researchers[$i].side}
{VARIABLE_OP amount format $researchers.level}
{ADDING_TO_CURRENT_RESEARCH_FIELD $credited_side| $amount}
{VARIABLE_OP credited_side format $researchers[$i].side}
{VARIABLE_OP amount format $researchers.level}
{ADDING_TO_CURRENT_RESEARCH_FIELD $credited_side| $amount}
{VARIABLE sound yes}
{SCROLL_TO $temp_x $temp_y}
{VARIABLE sound yes}
{SCROLL_TO $temp_x $temp_y}
[unstore_unit]
variable=researchers[$i]
text="$amount"
{COLOR_WHITE}
[/unstore_unit]
[unstore_unit]
variable=researchers[$i]
text="$amount"
{COLOR_WHITE}
[/unstore_unit]
{NEXT i}
[if]
@ -92,24 +92,24 @@
{VARIABLE sound no}
{FOREACH harvesters i}
{VARIABLE_OP temp_x format "$harvesters[$i].x"}
{VARIABLE_OP temp_y format "$harvesters[$i].y"}
{VARIABLE_OP temp_x format "$harvesters[$i].x"}
{VARIABLE_OP temp_y format "$harvesters[$i].y"}
{VARIABLE_OP credited_side format $harvesters[$i].side}
{VARIABLE_OP amount format $player_$credited_side|.farming.gold}
{VARIABLE_OP credited_side format $harvesters[$i].side}
{VARIABLE_OP amount format $player_$credited_side|.farming.gold}
# auto-harvest
{ADD_GOLD $credited_side $amount}
{MODIFY_TERRAIN "Re" $temp_x $temp_y}
{REMOVE_ITEM $temp_x $temp_y}
{VARIABLE sound yes}
{SCROLL_TO $temp_x $temp_y}
# auto-harvest
{ADD_GOLD $credited_side $amount}
{MODIFY_TERRAIN "Re" $temp_x $temp_y}
{REMOVE_ITEM $temp_x $temp_y}
{VARIABLE sound yes}
{SCROLL_TO $temp_x $temp_y}
[unstore_unit]
variable=harvesters[$i]
text="$amount"
red,green,blue=204,204,51
[/unstore_unit]
[unstore_unit]
variable=harvesters[$i]
text="$amount"
red,green,blue=204,204,51
[/unstore_unit]
{NEXT i}
[if]
@ -122,18 +122,18 @@
{VARIABLE sound no}
{FOREACH planters i}
{VARIABLE_OP temp_x format "$planters[$i].x"}
{VARIABLE_OP temp_y format "$planters[$i].y"}
{VARIABLE_OP temp_x format "$planters[$i].x"}
{VARIABLE_OP temp_y format "$planters[$i].y"}
# auto-plant
{MODIFY_TERRAIN "Re^Gvs" $temp_x $temp_y }
{REMOVE_ITEM $temp_x $temp_y}
{PLACE_IMAGE "items/flower4.png" $temp_x $temp_y}
{VARIABLE sound yes}
# auto-plant
{MODIFY_TERRAIN "Re^Gvs" $temp_x $temp_y }
{REMOVE_ITEM $temp_x $temp_y}
{PLACE_IMAGE "items/flower4.png" $temp_x $temp_y}
{VARIABLE sound yes}
[unstore_unit]
variable=planters[$i]
[/unstore_unit]
[unstore_unit]
variable=planters[$i]
[/unstore_unit]
{NEXT i}
[if]
@ -177,22 +177,22 @@
{VARIABLE sound no}
{FOREACH miners i}
{VARIABLE_OP temp_x format "$miners[$i].x"}
{VARIABLE_OP temp_y format "$miners[$i].y"}
{VARIABLE_OP temp_x format "$miners[$i].x"}
{VARIABLE_OP temp_y format "$miners[$i].y"}
{VARIABLE_OP credited_side format $miners[$i].side}
{VARIABLE_OP amount format $player_$credited_side|.mining.gold}
{VARIABLE_OP credited_side format $miners[$i].side}
{VARIABLE_OP amount format $player_$credited_side|.mining.gold}
# auto-mine
{ADD_GOLD $credited_side $amount}
{SCROLL_TO $temp_x $temp_y}
{VARIABLE sound yes}
# auto-mine
{ADD_GOLD $credited_side $amount}
{SCROLL_TO $temp_x $temp_y}
{VARIABLE sound yes}
[unstore_unit]
variable=miners[$i]
text="$amount"
red,green,blue=204,204,51
[/unstore_unit]
[unstore_unit]
variable=miners[$i]
text="$amount"
red,green,blue=204,204,51
[/unstore_unit]
{NEXT i}
[if]

View file

@ -1032,10 +1032,10 @@ Ww, Ww, Ww, Ww
[/store_locations]
{FOREACH temp_villages_area i}
[capture_village]
side=2
x,y=$temp_villages_area[$i].x,$temp_villages_area[$i].y
[/capture_village]
[capture_village]
side=2
x,y=$temp_villages_area[$i].x,$temp_villages_area[$i].y
[/capture_village]
{NEXT i}
# Then put goblins on the northernmost villages
@ -1047,11 +1047,11 @@ Ww, Ww, Ww, Ww
[/store_locations]
{FOREACH temp_villages_area i}
[unit]
type=Goblin Spearman
side=2
x,y=$temp_villages_area[$i].x,$temp_villages_area[$i].y
[/unit]
[unit]
type=Goblin Spearman
side=2
x,y=$temp_villages_area[$i].x,$temp_villages_area[$i].y
[/unit]
{NEXT i}
{CLEAR_VARIABLE temp_villages_area}

View file

@ -27,6 +27,21 @@ wmlindent will ignore them. You may need to do this for unbalanced
macros (it's better, though, to get rid of those where possible).
Use 'wmlindent: {start,stop} ignoring' anywhere in a comment.
It is also possible to declare custom openers an closers, e.g for macros
that are actually control constructs. To do this, use declarations
# wmlindent: opener "{EXCEPTIONAL_OPENER "
# wmlindent: closer "{EXCEPTIONAL_CLOSER "
The lines after an opener will be indented an extra level; a closer
and lines following will be indented one level less. Note that these
declare prefixes; any prefix match to the non-whitespace text of a line
will be recognized.
The public utility macros "{FOREACH" and "{NEXT" come as wired-in exceptions,
because it is not guaranteed that their indent declarations will be processed
before the macro library is reached.
Interrupting will be safe, as each reindenting will be done to a copy
that is atomically renamed when it's done. If the output file is identical
to the input, the output file will simply be deleted, so the timestamp
@ -48,6 +63,9 @@ indent already zero; these two conditions strongly suggest unbalanced WML.
import sys, os, getopt, filecmp, re
from wesnoth import wmltools
closer_prefixes = ["{NEXT "]
opener_prefixes = ["{FOREACH "]
def is_directive(str):
"Identify things that shouldn't be indented."
for prefix in ("#ifdef", "#ifndef", "#else", "#endif", "#define", "#enddef"):
@ -57,11 +75,26 @@ def is_directive(str):
def closer(str):
"Are we looking at a closing tag?"
return str.startswith("[/")
if str.startswith("[/"):
return True
else:
for prefix in closer_prefixes:
if str.startswith(prefix):
return True
return False
def opener(str):
"Are we looking at an opening tag?"
return str.startswith("[") and not closer(str)
# This logic is a bit obscure. The 'not "[/" in str' catches the
# obvious case of a closing tag, but it also catches the idiom
# [allow_undo][/allow_undo] which we want to treat as a no-op.
if (str.startswith("[") and not closer(str) and not "[/" in str):
return True
else:
for prefix in opener_prefixes:
if str.startswith(prefix):
return True
return False
class bailout:
def __init__(self, filename, lineno, msg):
@ -82,6 +115,17 @@ def reindent(name, infp, outfp):
multitag = re.compile(r"\[a-z]].*\[[a-z]") # Avoid triggering on arrays
for line in infp:
countlines += 1
# User may declare indentation exceptions
if "wmlindent: opener" in line:
tag = line.split('"')[1]
if verbose and not quiet:
print >>sys.stderr, "wmlindent: declaring indent exception for %s" % tag
opener_prefixes.append(tag)
elif "wmlindent: closer" in line:
tag = line.split('"')[1]
if verbose and not quiet:
print >>sys.stderr, "wmlindent: declaring outdent exception for %s" % tag
closer_prefixes.append(tag)
# Implement passthrough mode
if "wmlindent: start ignoring" in line:
ignoring = True
@ -118,7 +162,7 @@ def reindent(name, infp, outfp):
# one that started the block.
if closer(transformed):
if indent == "":
print >>sys.stderr, 'wmlindent: "%s", line %d: close tag with indent already zero.' % (name, countlines)
print >>sys.stderr, 'wmlindent: "%s", line %d: close tag %s with indent already zero.' % (name, countlines, transformed.strip())
else:
indent = indent[:-len(wmltools.baseindent)]
# Cope with blank lines outside of multiline literals
@ -144,11 +188,7 @@ def reindent(name, infp, outfp):
# And ship the line
outfp.write(output)
# May need to indent based on the line we just saw.
# This logic is a bit obscure. The 'not "[/" in transformed'
# catches the obvious case of a closing tag, but it also
# catches the idiom [allow_undo][/allow_undo] which we
# want to treat as a no-op.
if transformed.startswith("[") and not "[/" in transformed:
if opener(transformed):
indent += wmltools.baseindent
# Compute the dostrip state likewise.
# We look for unbalanced string quotes.
@ -212,7 +252,8 @@ def convertor(linefilter, arglist, exclude):
sys.stderr.write("wmlindent: %s unchanged\n" % filename)
os.remove(filename + ".out")
else:
sys.stderr.write("wmlindent: %s changed\n" % filename)
if not quiet:
sys.stderr.write("wmlindent: %s changed\n" % filename)
if dryrun:
os.remove(filename + ".out")
else:
@ -225,9 +266,10 @@ def convertor(linefilter, arglist, exclude):
os.rename(filename + ".out", filename)
if __name__ == '__main__':
(options, arguments) = getopt.getopt(sys.argv[1:], "h?de:v",
['help', 'dryrun', 'exclude=', 'verbose'])
(options, arguments) = getopt.getopt(sys.argv[1:], "h?de:qv",
['help', 'dryrun', 'exclude=', 'quiet', 'verbose'])
verbose = 0
quiet = False
dryrun = False
exclude = []
for (opt, val) in options:
@ -239,6 +281,8 @@ if __name__ == '__main__':
verbose = max(1, verbose)
elif opt in ('-e', '--exclude'):
exclude.append(val)
elif opt in ('-q', '--quiet'):
quiet = True
elif opt in ('-v', '--verbose'):
verbose += 1
convertor(lambda n, f1, f2: reindent(n, f1, f2),