Author: sapient
Date: Tue Jul 29 05:41:03 2008
New Revision: 28256
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28256&view=rev
Log:
-added TRANSFORM_UNIT macro, patch #1085 by AI
Modified:
trunk/changelog
trunk/data/core/macros/unit-utils.cfg
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=28256&r1=28255&r2=28256&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Jul 29 05:41:03 2008
@@ -32,6 +32,7 @@
* 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
Modified: trunk/data/core/macros/unit-utils.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/macros/unit-utils.cfg?rev=28256&r1=28255&r2=28256&view=diff
==============================================================================
--- trunk/data/core/macros/unit-utils.cfg (original)
+++ trunk/data/core/macros/unit-utils.cfg Tue Jul 29 05:41:03 2008
@@ -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
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits