Apply patch #1063 from AI0867...

...(ADVANCE_UNIT macro for advancing arbitrary units to arbitrary types)
This commit is contained in:
Ignacio R. Morelle 2008-07-19 01:23:51 +00:00
parent 9318a00299
commit 017a9263f0
2 changed files with 61 additions and 0 deletions

View file

@ -121,3 +121,49 @@
name=STORE_UNIT_VAR_store
[/clear_variable]
#enddef
#define ADVANCE_UNIT FILTER ADVANCETO
# Advances all units matching the filter to ADVANCETO or if missing, their normal advancement
#
# Example to advance all spearmen to a cavalrymen:
#! {ADVANCE_UNIT type=Spearman Cavalryman}
# Example to advance your leader normally:
#! {ADVANCE_UNIT side,canrecruit=1,yes ""}
[store_unit]
[filter]
{FILTER}
[/filter]
variable=ADVANCE_UNIT_store
kill=no
[/store_unit]
[set_variable]
name=advanceto_len
string_length={ADVANCETO}
[/set_variable]
{FOREACH ADVANCE_UNIT_store i}
[if]
[variable]
name=advanceto_len
greater_than=0
[/variable]
[then]
[set_variable]
name=ADVANCE_UNIT_store[$i].advances_to
value={ADVANCETO}
[/set_variable]
[/then]
[/if]
[set_variable]
name=ADVANCE_UNIT_store[$i].experience
value=$ADVANCE_UNIT_store[$i].max_experience
[/set_variable]
[unstore_unit]
variable=ADVANCE_UNIT_store[$i]
find_vacant=no
advance=true
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE ADVANCE_UNIT_store}
{CLEAR_VARIABLE advanceto_len}
#enddef

View file

@ -1003,6 +1003,21 @@ Ww, Ww, Ww, Ww
[/object]
[/event]
[label]
x,y=5,5
text="promotions"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x=5
y=5
[/filter]
{ADVANCE_UNIT x,y=5,5 (Grand Marshal,Yeti,Fire Dragon) }
[/event]
# Capture connected villages near 13,2 for team 2
[event]
name=prestart