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}
|
||||
[/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
|
||||
[event]
|
||||
name=last breath
|
||||
|
@ -326,48 +372,9 @@
|
|||
[/else]
|
||||
[/switch]
|
||||
{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
|
||||
{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]
|
||||
|
||||
{FIND_NR_WHITE_MAGE_RESPAWN (Father Morvin)}
|
||||
|
||||
# Store unit to check if it advanced to mage of light
|
||||
[store_unit]
|
||||
[filter]
|
||||
|
@ -392,9 +399,7 @@
|
|||
[/modifications]
|
||||
{IS_LOYAL}
|
||||
[/unit]
|
||||
{CLEAR_VARIABLE respawn_point}
|
||||
{CLEAR_VARIABLE type_check}
|
||||
{CLEAR_VARIABLE current_radius}
|
||||
{CLEAR_VARIABLE respawn_point,type_check}
|
||||
[switch]
|
||||
variable=random
|
||||
[case]
|
||||
|
@ -615,46 +620,8 @@
|
|||
[/else]
|
||||
[/switch]
|
||||
|
||||
{VARIABLE current_radius 1}
|
||||
[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]
|
||||
{FIND_NR_WHITE_MAGE_RESPAWN (Sister Thera)}
|
||||
|
||||
[store_unit]
|
||||
[filter]
|
||||
id=Father Morvin
|
||||
|
@ -678,9 +645,7 @@
|
|||
[/modifications]
|
||||
{IS_LOYAL}
|
||||
[/unit]
|
||||
{CLEAR_VARIABLE type_check}
|
||||
{CLEAR_VARIABLE respawn_point}
|
||||
{CLEAR_VARIABLE current_radius}
|
||||
{CLEAR_VARIABLE type_check,respawn_point}
|
||||
|
||||
[switch]
|
||||
variable=random
|
||||
|
@ -786,6 +751,8 @@
|
|||
[/clear_variable]
|
||||
[/event]
|
||||
|
||||
#undef FIND_NR_WHITE_MAGE_RESPAWN
|
||||
|
||||
# Elenia death
|
||||
[event]
|
||||
name=last breath
|
||||
|
|
Loading…
Add table
Reference in a new issue