Skip to content

Commit

Permalink
TSG S4: Avoid submerging Rangers
Browse files Browse the repository at this point in the history
If no suitable forest hex is found, the radius of the locations considered is
extended instead of placing the unit next to Ethiliel.

Also, a change of behaviour:
 * non-free hexes will not be considered
 * the bodyguards won't be placed adjacent to other units, like the ambush
 ability works normally
 * this includes Ethiliel
In general that means that units may be placed farther away than before.

[ci skip]
  • Loading branch information
sevu committed Aug 27, 2018
1 parent 3c2cd68 commit f3e0f4f
Showing 1 changed file with 43 additions and 51 deletions.
94 changes: 43 additions & 51 deletions data/campaigns/The_South_Guard/scenarios/04_Vale_of_Tears.cfg
Expand Up @@ -436,79 +436,71 @@
message= _ "You have a bodyguard?!"
[/message]

[store_unit]
[filter]
id=Ethiliel
[/filter]
variable=ethiliel_loc
kill=no
[/store_unit]

[store_locations]
terrain=*^F*
[and]
x,y=$ethiliel_loc.x,$ethiliel_loc.y
radius=3
[/and]
variable=bodyguard_loc
[/store_locations]

{VARIABLE number 0}
[while]
[variable]
name=number
#ifdef EASY
less_than=4
{VARIABLE hexes_needed 4}
#endif
#ifdef NORMAL
less_than=3
{VARIABLE hexes_needed 3}
#endif
#ifdef HARD
less_than=2
{VARIABLE hexes_needed 2}
#endif

{VARIABLE extending 3}

# We assume that there are always at least $hexes_needed free
# forest hexes with no units adjacent on the whole map, otherwise
# this will be and endless loop.
[while]
[variable]
name=bodyguard_loc.length
less_than=$hexes_needed
[/variable]
[do]
# fallback coordinates, in case no nearby vacant forest is found
{VARIABLE guard_x $ethiliel_loc.x}
{VARIABLE guard_y $ethiliel_loc.y}

[if]
[variable]
name=number
less_than=$bodyguard_loc.length
[/variable]
[then]
[set_variable]
name=guard_x
value=$bodyguard_loc[$number].x
[/set_variable]

[set_variable]
name=guard_y
value=$bodyguard_loc[$number].y
[/set_variable]
[/then]
[/if]
[store_locations]
terrain=*^F*
[not]
[filter]
# only hexes where no unit is to be matched
[/filter]
radius=1 # nor adjacent, as with normal ambush ability
[/not]
[and]
[filter]
id=Ethiliel
[/filter]
radius=$extending
include_borders=no
[/and]
variable=bodyguard_loc
include_borders=no
[/store_locations]
{VARIABLE_OP extending add 1}
[/do]
[/while]

[for]
start=0
end=$($hexes_needed-1)
variable=i
[do]
[unit]
role=Elvish Bodyguard
name= _ "Elvish Bodyguard"
type=Elvish Ranger
side=1
x,y=$guard_x,$guard_y
x=$bodyguard_loc[$i].x
y=$bodyguard_loc[$i].y
random_traits=yes
[modifications]
{TRAIT_LOYAL}
[/modifications]
{IS_LOYAL}
[/unit]

{VARIABLE_OP number add 1}
[/do]
[/while]
[/for]

{CLEAR_VARIABLE bodyguard_loc,ethiliel_loc,number}
{CLEAR_VARIABLE guard_x,guard_y}
{CLEAR_VARIABLE bodyguard_loc,hexes_needed,extending}

[message]
role=Elvish Bodyguard
Expand Down

0 comments on commit f3e0f4f

Please sign in to comment.