Skip to content

Commit

Permalink
fix LoW RANDOM_PLACEMENT macro
Browse files Browse the repository at this point in the history
previously it was possible that $random was
$random_placement_locations.length which would then be not a valid index
to random_placement_locations
  • Loading branch information
gfgtdf committed May 20, 2016
1 parent 392a0bd commit 267cd23
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions data/campaigns/Legend_of_Wesmere/utils/low-macros.cfg
Expand Up @@ -151,29 +151,20 @@ Elvish Shaman, Elvish Shyde, Elvish Enchantress, Elvish Sorceress, Elvish Sylph,
# Thanks to Shadow Master for this macro
# !***Macro to random place unit within area***
#define RANDOM_PLACEMENT _X _Y _RADIUS _WML
[store_locations]
x,y={_X},{_Y}
radius={_RADIUS}
variable=random_placement_locations
[/store_locations]

{VARIABLE_OP random_string value "0..$random_placement_locations.length"}

{RANDOM $random_string}

{VARIABLE_OP random_placement_x value "$random_placement_locations[$random].x"}
{VARIABLE_OP random_placement_y value "$random_placement_locations[$random].y"}

{CLEAR_VARIABLE random_placement_locations}

{_WML}

[+unit]
x,y=$random_placement_x,$random_placement_y
[/unit]

{CLEAR_VARIABLE random_placement_x}
{CLEAR_VARIABLE random_placement_y}
[random_placement]
num_items=1
variable=random_placement_location
[filter_location]
x,y={_X},{_Y}
radius={_RADIUS}
[/filter_location]
[command]
{_WML}
[+unit]
x,y=$random_placement_location.x,$random_placement_location.y
[/unit]
[/command]
[/random_placement]
#enddef

#define STORE_SIDE SIDE
Expand Down

0 comments on commit 267cd23

Please sign in to comment.