Changed Peaceful Valley so that goblins spawn on random adjacent hexes...

...(instead of always on the same ones) and that there are no spawns if
you recapture a village. Also added a new REPEAT macro.
This commit is contained in:
Lari Nieminen 2007-09-30 21:09:58 +00:00
parent 0f94f780f1
commit 06535624fc
2 changed files with 88 additions and 28 deletions

View file

@ -103,9 +103,9 @@
random_traits=no
[modifications]
[trait]
id=loyal
male_name= _ "loyal"
description= _ "to himself"
id=loyal
male_name= _ "loyal"
description= _ "to himself"
[effect]
apply_to=loyal
[/effect]
@ -126,28 +126,48 @@
# Generate a random number of guards between 0 and 2 near X,Y
# Note that this uses BfW's default behavior to shift unit placement when you try to place on top of another unit
#define RANDOM_GUARDS TYPE DESCRIPTION UDESCRIPTION SIDE X Y
{RANDOM 0..2}
{VARIABLE i 0}
[while]
[variable]
name=i
less_than=$random
[/variable]
[do]
[unit]
description={DESCRIPTION}
user_description={UDESCRIPTION}
type={TYPE}
upkeep=loyal
side={SIDE}
x={X}
y={Y}
animate=yes
[/unit]
{VARIABLE_OP i add 1}
[/do]
[/while]
{CLEAR_VARIABLE i}
{VARIABLE_OP number_of_guards random 0..2}
{REPEAT $number_of_guards (
[store_locations]
[filter_adjacent_location]
x,y={X},{Y}
[/filter_adjacent_location]
[not]
[filter]
[/filter]
[/not]
variable=possible_guard_locations
[/store_locations]
{IF_VAR possible_guard_locations.length greater_than 0 (
[then]
{VARIABLE_OP random_location_index random 0..$possible_guard_locations.length}
[move_unit_fake]
side={SIDE}
type={TYPE}
x={X},$possible_guard_locations[$random_location_index].x
y={Y},$possible_guard_locations[$random_location_index].y
[/move_unit_fake]
[unit]
description={DESCRIPTION}
user_description={UDESCRIPTION}
type={TYPE}
side={SIDE}
x,y=$possible_guard_locations[$random_location_index].x,$possible_guard_locations[$random_location_index].y
random_traits=yes
[/unit]
[/then]
)}
)}
{CLEAR_VARIABLE number_of_guards}
{CLEAR_VARIABLE possible_guard_locations}
{CLEAR_VARIABLE random_location_index}
#enddef
# In-scenario events
@ -166,7 +186,18 @@
[filter]
side=1
[/filter]
{RANDOM_GUARDS (Goblin Spearman) Villager (_ "Villager") 2 $x1 $y1}
{IF_VAR village_$x1,$y1|_cleared not_equals yes (
[then]
{RANDOM_GUARDS (Goblin Spearman) Villager (_ "Villager") 2 $x1 $y1}
{VARIABLE village_$x1,$y1|_cleared yes}
[/then]
[else]
[allow_undo][/allow_undo]
[/else]
)}
[/event]
[event]
@ -234,7 +265,6 @@
[/store_villages]
[if]
[variable]
# name=villages_owned
name=villages.length
numerical_equals=$number_villages
[/variable]
@ -250,9 +280,20 @@
[event]
name=victory
[store_villages]
variable=villages
[/store_villages]
{FOREACH villages i}
{VARIABLE_OP village_var format "village_$villages[$i].x,$villages[$i].y|_cleared"}
{CLEAR_VARIABLE $village_var}
{NEXT i}
{CLEAR_VARIABLE number_villages}
#{CLEAR_VARIABLE villages_owned}
{CLEAR_VARIABLE villages}
{CLEAR_VARIABLE village_var}
[/event]
{@campaigns/Descent_Into_Darkness/utils/global-events.cfg}

View file

@ -103,6 +103,25 @@
#enddef
# wmlindent: stop ignoring
#define REPEAT NUM CONTENT
{VARIABLE REPEAT_i 0}
[while]
[variable]
name=REPEAT_i
less_than={NUM}
[/variable]
[do]
{CONTENT}
{VARIABLE_OP REPEAT_i add 1}
[/do]
[/while]
{CLEAR_VARIABLE REPEAT_i}
#enddef
#define DEBUG_MSG MSG
# Emit a debug message. Meant to be overridden with no-op definition
# of the same name for production use.