added TRANSFORM_UNIT macro, patch #1085 by AI

This commit is contained in:
Patrick Parker 2008-07-29 03:41:03 +00:00
parent 0d5eaebdf4
commit 022206e26e
2 changed files with 59 additions and 0 deletions

View file

@ -32,6 +32,7 @@ Version 1.5.2+svn:
* It is now possible to use [time_area] to add or remove new local ToD
areas and their schedules during scenario events. Removal requires to
associate an id. to [time_area]s, or it won't work.
* Added some convenience macros for units: {TRANSFORM_UNIT}, etc.
* Miscellaneous and bug fixes:
* Add some gcc-4.3.0 compilation fixes (patch #1083)
* Fixed bug #12094: Event "last breath" cannot be triggered for attackers

View file

@ -167,3 +167,61 @@
{CLEAR_VARIABLE ADVANCE_UNIT_store}
{CLEAR_VARIABLE advanceto_len}
#enddef
#define TRANSFORM_UNIT T_FILTER TRANSFORMTO
# Advances all units matching the filter to TRANSFORMTO or if missing, their normal advancement
#
# Example to turn all spearmen into cavalrymen:
#! {TRANSFORM_UNIT type=Spearman Cavalryman}
[store_unit]
[filter]
{T_FILTER}
[/filter]
variable=TU_store
kill=no
[/store_unit]
{ADVANCE_UNIT ({T_FILTER}) ({TRANSFORMTO}) }
{FOREACH TU_store i}
[store_unit]
[filter]
x,y=$TU_store[$i].x,$TU_store[$i].y
[/filter]
variable=TUrestore_store
kill=yes
[/store_unit]
[set_variables]
name=TUrestore_store
mode=merge
[value]
hitpoints=$TU_store[$i].hitpoints
experience=$TU_store[$i].experience
[insert_tag]
name=status
variable=TU_store[$i].status
[/insert_tag]
[/value]
[/set_variables]
[if]
[have_unit]
x,y=$TU_store[$i].x,$TU_store[$i].y
[filter_wml]
[status]
not_living="yes"
[/status]
[/filter_wml]
[/have_unit]
[then]
[clear_variable]
name=TUrestore_store.status.poisoned
[/clear_variable]
[/then]
[/if]
[unstore_unit]
variable=TUrestore_store
find_vacant=no
advance=false
[/unstore_unit]
{CLEAR_VARIABLE TUrestore_store}
{NEXT i}
{CLEAR_VARIABLE TU_store}
#enddef