NR: Refactor the White Magi respawn location finding code into a macro
This bit was subject to a particularly bad case of code copy-pasting when the only real variable is the id of the first respawn hub candidate. Added a statement to clear the respawn_hub WML variable after running the code since it's never used again afterwards.
This commit is contained in:
parent
87b3ba5377
commit
00d7b06faf
1 changed files with 55 additions and 88 deletions
|
@ -214,6 +214,52 @@
|
||||||
{VARIABLE Eryssa_alive no}
|
{VARIABLE Eryssa_alive no}
|
||||||
[/event]
|
[/event]
|
||||||
|
|
||||||
|
#define FIND_NR_WHITE_MAGE_RESPAWN HUB_CANDIDATE
|
||||||
|
# Find a respawn point, start within 1 hex of the candidate, increase range if nothing suitable
|
||||||
|
# Search around Tallin if the candidate is still jailed
|
||||||
|
{VARIABLE current_radius 1}
|
||||||
|
[if]
|
||||||
|
[have_unit]
|
||||||
|
id={HUB_CANDIDATE}
|
||||||
|
[/have_unit]
|
||||||
|
[then]
|
||||||
|
{VARIABLE respawn_hub ({HUB_CANDIDATE})}
|
||||||
|
[/then]
|
||||||
|
[else]
|
||||||
|
{VARIABLE respawn_hub (Tallin)}
|
||||||
|
[/else]
|
||||||
|
[/if]
|
||||||
|
[while]
|
||||||
|
[variable]
|
||||||
|
name=respawn_point.length
|
||||||
|
equals=0
|
||||||
|
[/variable]
|
||||||
|
[do]
|
||||||
|
[store_locations]
|
||||||
|
variable=respawn_point
|
||||||
|
[and]
|
||||||
|
[filter]
|
||||||
|
id=$respawn_hub
|
||||||
|
[/filter]
|
||||||
|
radius=$current_radius
|
||||||
|
[/and]
|
||||||
|
# Exclude hexes with units on them and impassable terrain
|
||||||
|
[and]
|
||||||
|
[not]
|
||||||
|
[filter]
|
||||||
|
[/filter]
|
||||||
|
[/not]
|
||||||
|
[not]
|
||||||
|
terrain=Wo,*^Xm,X*,Q*
|
||||||
|
[/not]
|
||||||
|
[/and]
|
||||||
|
[/store_locations]
|
||||||
|
{VARIABLE_OP current_radius add 1}
|
||||||
|
[/do]
|
||||||
|
[/while]
|
||||||
|
{CLEAR_VARIABLE current_radius,respawn_hub}
|
||||||
|
#enddef
|
||||||
|
|
||||||
# Sister Thera death, seven randomly chosen dialogues
|
# Sister Thera death, seven randomly chosen dialogues
|
||||||
[event]
|
[event]
|
||||||
name=last breath
|
name=last breath
|
||||||
|
@ -326,48 +372,9 @@
|
||||||
[/else]
|
[/else]
|
||||||
[/switch]
|
[/switch]
|
||||||
{FLASH_WHITE ()}
|
{FLASH_WHITE ()}
|
||||||
# Find a respawn point, start within 1 hex of Father Morvin, increase range if nothing suitable
|
|
||||||
# Search around Tallin if Morvin is still jailed
|
{FIND_NR_WHITE_MAGE_RESPAWN (Father Morvin)}
|
||||||
{VARIABLE current_radius 1}
|
|
||||||
[if]
|
|
||||||
[have_unit]
|
|
||||||
id=Father Morvin
|
|
||||||
[/have_unit]
|
|
||||||
[then]
|
|
||||||
{VARIABLE respawn_hub "Father Morvin"}
|
|
||||||
[/then]
|
|
||||||
[else]
|
|
||||||
{VARIABLE respawn_hub "Tallin"}
|
|
||||||
[/else]
|
|
||||||
[/if]
|
|
||||||
[while]
|
|
||||||
[variable]
|
|
||||||
name=respawn_point.length
|
|
||||||
equals=0
|
|
||||||
[/variable]
|
|
||||||
[do]
|
|
||||||
[store_locations]
|
|
||||||
variable=respawn_point
|
|
||||||
[and]
|
|
||||||
[filter]
|
|
||||||
id=$respawn_hub
|
|
||||||
[/filter]
|
|
||||||
radius=$current_radius
|
|
||||||
[/and]
|
|
||||||
# Exclude hexes with units on them and impassable terrain
|
|
||||||
[and]
|
|
||||||
[not]
|
|
||||||
[filter]
|
|
||||||
[/filter]
|
|
||||||
[/not]
|
|
||||||
[not]
|
|
||||||
terrain=Wo,*^Xm,X*,Q*
|
|
||||||
[/not]
|
|
||||||
[/and]
|
|
||||||
[/store_locations]
|
|
||||||
{VARIABLE_OP current_radius add 1}
|
|
||||||
[/do]
|
|
||||||
[/while]
|
|
||||||
# Store unit to check if it advanced to mage of light
|
# Store unit to check if it advanced to mage of light
|
||||||
[store_unit]
|
[store_unit]
|
||||||
[filter]
|
[filter]
|
||||||
|
@ -392,9 +399,7 @@
|
||||||
[/modifications]
|
[/modifications]
|
||||||
{IS_LOYAL}
|
{IS_LOYAL}
|
||||||
[/unit]
|
[/unit]
|
||||||
{CLEAR_VARIABLE respawn_point}
|
{CLEAR_VARIABLE respawn_point,type_check}
|
||||||
{CLEAR_VARIABLE type_check}
|
|
||||||
{CLEAR_VARIABLE current_radius}
|
|
||||||
[switch]
|
[switch]
|
||||||
variable=random
|
variable=random
|
||||||
[case]
|
[case]
|
||||||
|
@ -615,46 +620,8 @@
|
||||||
[/else]
|
[/else]
|
||||||
[/switch]
|
[/switch]
|
||||||
|
|
||||||
{VARIABLE current_radius 1}
|
{FIND_NR_WHITE_MAGE_RESPAWN (Sister Thera)}
|
||||||
[if]
|
|
||||||
[have_unit]
|
|
||||||
id=Sister Thera
|
|
||||||
[/have_unit]
|
|
||||||
[then]
|
|
||||||
{VARIABLE respawn_hub "Sister Thera"}
|
|
||||||
[/then]
|
|
||||||
[else]
|
|
||||||
{VARIABLE respawn_hub "Tallin"}
|
|
||||||
[/else]
|
|
||||||
[/if]
|
|
||||||
[while]
|
|
||||||
[variable]
|
|
||||||
name=respawn_point.length
|
|
||||||
equals=0
|
|
||||||
[/variable]
|
|
||||||
[do]
|
|
||||||
[store_locations]
|
|
||||||
variable=respawn_point
|
|
||||||
[and]
|
|
||||||
[filter]
|
|
||||||
id=$respawn_hub
|
|
||||||
[/filter]
|
|
||||||
radius=$current_radius
|
|
||||||
[/and]
|
|
||||||
# Exclude hexes with units on them and impassable terrain
|
|
||||||
[and]
|
|
||||||
[not]
|
|
||||||
[filter]
|
|
||||||
[/filter]
|
|
||||||
[/not]
|
|
||||||
[not]
|
|
||||||
terrain=Wo,*^Xm,X*,Q*
|
|
||||||
[/not]
|
|
||||||
[/and]
|
|
||||||
[/store_locations]
|
|
||||||
{VARIABLE_OP current_radius add 1}
|
|
||||||
[/do]
|
|
||||||
[/while]
|
|
||||||
[store_unit]
|
[store_unit]
|
||||||
[filter]
|
[filter]
|
||||||
id=Father Morvin
|
id=Father Morvin
|
||||||
|
@ -678,9 +645,7 @@
|
||||||
[/modifications]
|
[/modifications]
|
||||||
{IS_LOYAL}
|
{IS_LOYAL}
|
||||||
[/unit]
|
[/unit]
|
||||||
{CLEAR_VARIABLE type_check}
|
{CLEAR_VARIABLE type_check,respawn_point}
|
||||||
{CLEAR_VARIABLE respawn_point}
|
|
||||||
{CLEAR_VARIABLE current_radius}
|
|
||||||
|
|
||||||
[switch]
|
[switch]
|
||||||
variable=random
|
variable=random
|
||||||
|
@ -786,6 +751,8 @@
|
||||||
[/clear_variable]
|
[/clear_variable]
|
||||||
[/event]
|
[/event]
|
||||||
|
|
||||||
|
#undef FIND_NR_WHITE_MAGE_RESPAWN
|
||||||
|
|
||||||
# Elenia death
|
# Elenia death
|
||||||
[event]
|
[event]
|
||||||
name=last breath
|
name=last breath
|
||||||
|
|
Loading…
Add table
Reference in a new issue