From f3e0f4f36bbd40fb068730fb1a4c83f2dacc2467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Severin=20Gl=C3=B6ckner?= Date: Wed, 1 Aug 2018 20:15:31 +0200 Subject: [PATCH] TSG S4: Avoid submerging Rangers 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] --- .../scenarios/04_Vale_of_Tears.cfg | 94 +++++++++---------- 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/data/campaigns/The_South_Guard/scenarios/04_Vale_of_Tears.cfg b/data/campaigns/The_South_Guard/scenarios/04_Vale_of_Tears.cfg index b56a0e7897cf..a1154dfa8e00 100644 --- a/data/campaigns/The_South_Guard/scenarios/04_Vale_of_Tears.cfg +++ b/data/campaigns/The_South_Guard/scenarios/04_Vale_of_Tears.cfg @@ -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