<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Solsword</id>
	<title>The Battle for Wesnoth Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Solsword"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Solsword"/>
	<updated>2026-04-25T19:45:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingUnits&amp;diff=32545</id>
		<title>BuildingUnits</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingUnits&amp;diff=32545"/>
		<updated>2009-10-03T22:45:15Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Distributing your unit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Making new units is fairly easy.  Unit configuration files are plain text files that you can edit with any editor such as Notepad, TextEdit, gedit, pico, vi, emacs, etc.  You will need to become familiar with [[UnitTypeWML|WML]] in order to make a new unit.  This page contains a more in-depth discussion of Unit WML syntax and will walk you through the creation of a new unit and discuss how you can use it in-game.&lt;br /&gt;
&lt;br /&gt;
== Recommended procedure ==&lt;br /&gt;
The easiest way to make a new unit is to copy and paste an existing unit, then modify it.  Navigate to the game's data/units directory and copy any unit.  When you are editing the unit, pay attention to the property keys.  If you forget to modify each key (for example, the unique id key), problems may arise, varying for minor issues such as lack of features on the unit, to game refusing to load the unit file, or, in the worst case, crashing the game. For complete reference on unit properties see [[UnitTypeWML]].&lt;br /&gt;
&lt;br /&gt;
Most of a unit's properties are self-explanatory to anyone who has played Battle for Wesnoth for very long, and the tags in the WML files are brief but descriptive. It is recommended that you try editing by yourself before consulting the guide.  Otherwise, you may find the guide confusing.&lt;br /&gt;
&lt;br /&gt;
== Using your new unit ==&lt;br /&gt;
Any unit in the game's existing data/units/*/ directories (you can't just add a new directory to data/units/) or ''[[EditingWesnoth#Where_is_my_user_data_directory.3F|userdata]]''/data/ will be recognized by the game. If you only want to use it once or twice as a special unit, that's all you need to do. However, just because you made a new unit does NOT mean that it can be recruited. Each scenario and multiplayer era has a specific recruit list. If your unit is not on the list, you can't recruit it. This means you need to modify the ''recruit='' key in the appropriate configuration file. [[BuildingMultiplayer]] describes different ways you do this for multiplayer. To add a unit to a campaign, read about scenarios, sides, and recruit lists in [[BuildingScenarios]].&lt;br /&gt;
&lt;br /&gt;
== Distributing your unit ==&lt;br /&gt;
&lt;br /&gt;
Note: for people using 1.7 and later, this section is out-of-date. Mainly, the campaigns/ directory is now called add-ons, but also the syntax for the main .cfg and .pbl files has changed: put _main.cfg '''inside''' your add-on directory, and put _server.pbl inside as well. Also, use ~ instead of @ for includes.&lt;br /&gt;
&lt;br /&gt;
If you made a single unit, post it on the [http://www.wesnoth.org/forum forum].  If you made a whole group of units, you can make them into a multiplayer faction or you can upload a unit pack.&lt;br /&gt;
&lt;br /&gt;
If you want to make a faction, follow the instructions in the [[BuildingFactions]] article.  You should create a new era and add your units as one of the factions.  You will not be able to add your units to any era that ships with the game.&lt;br /&gt;
&lt;br /&gt;
If you want to make a unit pack, the procedure is easier.  Unit packs are distributed for campaign writers who want to use your units in their campaigns/eras.  They download your unit pack and copy/paste the units and images into their campaign/era.&lt;br /&gt;
* Navigate to the ''userdata''/data/campaigns directory.  Everything from now on will occur relative to here.  The era we'll use as an example will be called MyUnitPack&lt;br /&gt;
* Create a text file called MyUnitPack.cfg.  Add the following lines:&lt;br /&gt;
 #		#define USE_MYUNITS		#&amp;lt;- replace MYUNITS with something descriptive&lt;br /&gt;
 #		#enddef&lt;br /&gt;
 #		#ifdef USE_MYUNITS		#&amp;lt;- replace MYUNITS with something descriptive&lt;br /&gt;
 #		{@campaigns/MyUnitPack/}&lt;br /&gt;
 #		#endif&lt;br /&gt;
:* These lines are commented out (with the #).  That way when the unit pack ships it won't affect the game.  If someone wants the game to be able to see these units, he can uncomment those lines and it will work.  However, this usually causes problems in multiplayer (you will be using units no one else has), but it can be fun for campaigns.&lt;br /&gt;
:* NOTE: the commenting/uncommenting trick will only work if the units branch off of an existing unit.  Custom L1 units will NOT show up in game automatically without editing another configuration file somewhere (scenario config file or multiplayer.cfg)&lt;br /&gt;
* Create another text file called MyUnitPack.pbl. (See [[PblWML]] for more details about *.pbl files.) Add the following lines to it:&lt;br /&gt;
 author=&amp;quot;''your name''&amp;quot;&lt;br /&gt;
 icon=&amp;quot;''any image file in the game's ./images directory''&amp;quot;&lt;br /&gt;
 version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 title=&amp;quot;My Awesome Unit Pack&amp;quot;&lt;br /&gt;
 description=&amp;quot;New race of lizard men.&amp;quot;&lt;br /&gt;
* Create a folder called MyUnitPack.  Navigate to it.&lt;br /&gt;
* Create two subdirectories: units and images.  Place your unit cfg files and artwork into those subdirectories&lt;br /&gt;
* Create a text file called MyUnitPack.cfg (or another name of your choosing).  Add the following lines:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
 path=data/campaigns/MyUnitPack&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 [+units]&lt;br /&gt;
 {@campaigns/MyUnitPack/units}&lt;br /&gt;
 [/units]&lt;br /&gt;
* You should be ready to distribute your unit pack on the campaign server now&lt;br /&gt;
* PLEASE change the names to something unique before you publish&lt;br /&gt;
&lt;br /&gt;
== Unit WML discussion ==&lt;br /&gt;
&lt;br /&gt;
As of 1.6, unit definitions are enclosed in '''[unit_type]''' tags. &lt;br /&gt;
&lt;br /&gt;
This section only provides some tips and pointers in making a unit.  Feel free to add pointers of your own.  For the full, current, complete WML reference on what to put in your [unit], see and frequently revisit [[UnitTypeWML|The Unit WML reference page]].&lt;br /&gt;
* The first attribute of a unit is the '''id''' attribute, which is a unique identifier for the unit. As value of the '''type''' attribute for these units, the '''id''' key is used. (See [[BuildingScenarios]]).&lt;br /&gt;
* When referencing the unit in a '''type''' key, the id must be reproduced verbatim, without typos, and in a case-sensitive manner.  If you don't do this, the key won't work.  If you can't recruit in a scenario, it's probably because you have a typo in one of the unit ids and the '''recruit''' key was invalidated.&lt;br /&gt;
* It also has a '''name''' key, which is the (translatable) name of the unit, and is displayed on the Status Table when a unit of this type is selected.  It does not need to be unique (but it helps).&lt;br /&gt;
* Do not set movement to 0.  It creates weird infinite movement behavior.  This might be fixed in the future.  For now, to make an immobile unit, set movement to 1 and use [movement_costs] to make it unable to move onto any terrain.&lt;br /&gt;
&lt;br /&gt;
* See [[BuildingScenariosIntermediate]] for more information on attacks.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[Creating Unit Art]]&lt;br /&gt;
* [[CampaignServerWML]]&lt;br /&gt;
* [[PblWML]]&lt;br /&gt;
* [[BuildingCampaignsThePBLFile]]&lt;br /&gt;
* [[Team_Color_Shifting]]&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingUnits&amp;diff=32544</id>
		<title>BuildingUnits</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingUnits&amp;diff=32544"/>
		<updated>2009-10-03T22:42:24Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Using your new unit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Making new units is fairly easy.  Unit configuration files are plain text files that you can edit with any editor such as Notepad, TextEdit, gedit, pico, vi, emacs, etc.  You will need to become familiar with [[UnitTypeWML|WML]] in order to make a new unit.  This page contains a more in-depth discussion of Unit WML syntax and will walk you through the creation of a new unit and discuss how you can use it in-game.&lt;br /&gt;
&lt;br /&gt;
== Recommended procedure ==&lt;br /&gt;
The easiest way to make a new unit is to copy and paste an existing unit, then modify it.  Navigate to the game's data/units directory and copy any unit.  When you are editing the unit, pay attention to the property keys.  If you forget to modify each key (for example, the unique id key), problems may arise, varying for minor issues such as lack of features on the unit, to game refusing to load the unit file, or, in the worst case, crashing the game. For complete reference on unit properties see [[UnitTypeWML]].&lt;br /&gt;
&lt;br /&gt;
Most of a unit's properties are self-explanatory to anyone who has played Battle for Wesnoth for very long, and the tags in the WML files are brief but descriptive. It is recommended that you try editing by yourself before consulting the guide.  Otherwise, you may find the guide confusing.&lt;br /&gt;
&lt;br /&gt;
== Using your new unit ==&lt;br /&gt;
Any unit in the game's existing data/units/*/ directories (you can't just add a new directory to data/units/) or ''[[EditingWesnoth#Where_is_my_user_data_directory.3F|userdata]]''/data/ will be recognized by the game. If you only want to use it once or twice as a special unit, that's all you need to do. However, just because you made a new unit does NOT mean that it can be recruited. Each scenario and multiplayer era has a specific recruit list. If your unit is not on the list, you can't recruit it. This means you need to modify the ''recruit='' key in the appropriate configuration file. [[BuildingMultiplayer]] describes different ways you do this for multiplayer. To add a unit to a campaign, read about scenarios, sides, and recruit lists in [[BuildingScenarios]].&lt;br /&gt;
&lt;br /&gt;
== Distributing your unit ==&lt;br /&gt;
If you made a single unit, post it on the [http://www.wesnoth.org/forum forum].  If you made a whole group of units, you can make them into a multiplayer faction or you can upload a unit pack.&lt;br /&gt;
&lt;br /&gt;
If you want to make a faction, follow the instructions in the [[BuildingFactions]] article.  You should create a new era and add your units as one of the factions.  You will not be able to add your units to any era that ships with the game.&lt;br /&gt;
&lt;br /&gt;
If you want to make a unit pack, the procedure is easier.  Unit packs are distributed for campaign writers who want to use your units in their campaigns/eras.  They download your unit pack and copy/paste the units and images into their campaign/era.&lt;br /&gt;
* Navigate to the ''userdata''/data/campaigns directory.  Everything from now on will occur relative to here.  The era we'll use as an example will be called MyUnitPack&lt;br /&gt;
* Create a text file called MyUnitPack.cfg.  Add the following lines:&lt;br /&gt;
 #		#define USE_MYUNITS		#&amp;lt;- replace MYUNITS with something descriptive&lt;br /&gt;
 #		#enddef&lt;br /&gt;
 #		#ifdef USE_MYUNITS		#&amp;lt;- replace MYUNITS with something descriptive&lt;br /&gt;
 #		{@campaigns/MyUnitPack/}&lt;br /&gt;
 #		#endif&lt;br /&gt;
:* These lines are commented out (with the #).  That way when the unit pack ships it won't affect the game.  If someone wants the game to be able to see these units, he can uncomment those lines and it will work.  However, this usually causes problems in multiplayer (you will be using units no one else has), but it can be fun for campaigns.&lt;br /&gt;
:* NOTE: the commenting/uncommenting trick will only work if the units branch off of an existing unit.  Custom L1 units will NOT show up in game automatically without editing another configuration file somewhere (scenario config file or multiplayer.cfg)&lt;br /&gt;
* Create another text file called MyUnitPack.pbl. (See [[PblWML]] for more details about *.pbl files.) Add the following lines to it:&lt;br /&gt;
 author=&amp;quot;''your name''&amp;quot;&lt;br /&gt;
 icon=&amp;quot;''any image file in the game's ./images directory''&amp;quot;&lt;br /&gt;
 version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 title=&amp;quot;My Awesome Unit Pack&amp;quot;&lt;br /&gt;
 description=&amp;quot;New race of lizard men.&amp;quot;&lt;br /&gt;
* Create a folder called MyUnitPack.  Navigate to it.&lt;br /&gt;
* Create two subdirectories: units and images.  Place your unit cfg files and artwork into those subdirectories&lt;br /&gt;
* Create a text file called MyUnitPack.cfg (or another name of your choosing).  Add the following lines:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
 path=data/campaigns/MyUnitPack&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 [+units]&lt;br /&gt;
 {@campaigns/MyUnitPack/units}&lt;br /&gt;
 [/units]&lt;br /&gt;
* You should be ready to distribute your unit pack on the campaign server now&lt;br /&gt;
* PLEASE change the names to something unique before you publish&lt;br /&gt;
&lt;br /&gt;
== Unit WML discussion ==&lt;br /&gt;
&lt;br /&gt;
As of 1.6, unit definitions are enclosed in '''[unit_type]''' tags. &lt;br /&gt;
&lt;br /&gt;
This section only provides some tips and pointers in making a unit.  Feel free to add pointers of your own.  For the full, current, complete WML reference on what to put in your [unit], see and frequently revisit [[UnitTypeWML|The Unit WML reference page]].&lt;br /&gt;
* The first attribute of a unit is the '''id''' attribute, which is a unique identifier for the unit. As value of the '''type''' attribute for these units, the '''id''' key is used. (See [[BuildingScenarios]]).&lt;br /&gt;
* When referencing the unit in a '''type''' key, the id must be reproduced verbatim, without typos, and in a case-sensitive manner.  If you don't do this, the key won't work.  If you can't recruit in a scenario, it's probably because you have a typo in one of the unit ids and the '''recruit''' key was invalidated.&lt;br /&gt;
* It also has a '''name''' key, which is the (translatable) name of the unit, and is displayed on the Status Table when a unit of this type is selected.  It does not need to be unique (but it helps).&lt;br /&gt;
* Do not set movement to 0.  It creates weird infinite movement behavior.  This might be fixed in the future.  For now, to make an immobile unit, set movement to 1 and use [movement_costs] to make it unable to move onto any terrain.&lt;br /&gt;
&lt;br /&gt;
* See [[BuildingScenariosIntermediate]] for more information on attacks.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[Creating Unit Art]]&lt;br /&gt;
* [[CampaignServerWML]]&lt;br /&gt;
* [[PblWML]]&lt;br /&gt;
* [[BuildingCampaignsThePBLFile]]&lt;br /&gt;
* [[Team_Color_Shifting]]&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_Abilities&amp;diff=32518</id>
		<title>WML Abilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_Abilities&amp;diff=32518"/>
		<updated>2009-09-30T01:06:41Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Updated Charm to 1.7.x syntax&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Remember that you must include the WML ability code in every scenario where you intend them to work. Or include them in the unit file inside the [unit_type] tag.&lt;br /&gt;
&lt;br /&gt;
Some abilities require macros from [[WML_Utilities|Utilities]]. &lt;br /&gt;
&lt;br /&gt;
=== Knockback  ===&lt;br /&gt;
&lt;br /&gt;
When a unit is hit with a ''knockback'' attack, it is immediately pushed one hex away from the attacker, at which point the combat ends. Exception: units in villages can't be knocked out of them.&lt;br /&gt;
&lt;br /&gt;
Examples that give ''knockback'' for every Drake Glider on their slam attack, and for the Shock Trooper named Jane:&lt;br /&gt;
 {KNOCKBACK (type=Drake Glider) slam}&lt;br /&gt;
 {KNOCKBACK description=Jane mace}&lt;br /&gt;
&lt;br /&gt;
Requires the macro ''OPPOSITE_SIDE''.&lt;br /&gt;
&lt;br /&gt;
 #define KNOCKBACK FILTER WEAPON&lt;br /&gt;
     [event]&lt;br /&gt;
         name=attacker_hits&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         [special_filter]&lt;br /&gt;
             weapon={WEAPON}&lt;br /&gt;
         [/special_filter]&lt;br /&gt;
 &lt;br /&gt;
         [sound]&lt;br /&gt;
             name=ghoul-hit.wav&lt;br /&gt;
         [/sound]&lt;br /&gt;
 &lt;br /&gt;
         {OPPOSITE_SIDE $x2 $y2 $x1 $y1 target_hex}&lt;br /&gt;
 &lt;br /&gt;
         [store_locations]&lt;br /&gt;
             x,y=$x2,$y2&lt;br /&gt;
             terrain=AaBbDeLptUVvYZ&lt;br /&gt;
             variable=defender_in_village&lt;br /&gt;
         [/store_locations]&lt;br /&gt;
         [if]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                x,y=$target_hex.x,$target_hex.y&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
             [else]&lt;br /&gt;
                 {IF_VAR defender_in_village.length not_equals 1 (&lt;br /&gt;
                     [then]&lt;br /&gt;
                         {STORE_UNIT_VAR x,y=$x2,$y2 side side_of_defender}&lt;br /&gt;
 &lt;br /&gt;
                         [teleport]&lt;br /&gt;
                             [filter]&lt;br /&gt;
                                 x,y=$x2,$y2&lt;br /&gt;
                             [/filter]&lt;br /&gt;
 &lt;br /&gt;
                             x,y=$target_hex.x,$target_hex.y&lt;br /&gt;
                         [/teleport]&lt;br /&gt;
 &lt;br /&gt;
                         [capture_village]&lt;br /&gt;
                             side=$side_of_defender&lt;br /&gt;
                             x,y=$target_hex.x,$target_hex.y&lt;br /&gt;
                         [/capture_village]&lt;br /&gt;
 &lt;br /&gt;
                         {CLEAR_VARIABLE side_of_defender}&lt;br /&gt;
                     [/then]&lt;br /&gt;
                 )}&lt;br /&gt;
             [/else]&lt;br /&gt;
         [/if]&lt;br /&gt;
 &lt;br /&gt;
         {CLEAR_VARIABLE target_hex}&lt;br /&gt;
         {CLEAR_VARIABLE defender_in_village}&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
=== Charm ===&lt;br /&gt;
&lt;br /&gt;
When a unit is hit with a ''charm'' attack, it instantly jumps to the attacker's side, and returns to it's original side at the beginning of that side's turn. A charmed unit has 1 movement point and can attack.&lt;br /&gt;
&lt;br /&gt;
Example that makes all Troll Whelps have charm on their attack:&lt;br /&gt;
&lt;br /&gt;
 {CHARM (type=Troll Whelp) fist}&lt;br /&gt;
&lt;br /&gt;
 #define CHARM FILTER WEAPON&lt;br /&gt;
     [event]&lt;br /&gt;
         name=attacker_hits&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         [special_filter]&lt;br /&gt;
             weapon={WEAPON}&lt;br /&gt;
         [/special_filter]&lt;br /&gt;
 &lt;br /&gt;
         {STORE_UNIT_VAR x,y=$x1,$y1 side charmer_side}&lt;br /&gt;
         {STORE_UNIT_VAR x,y=$x2,$y2 side charmed_side}&lt;br /&gt;
 &lt;br /&gt;
         {IF_VAR charmer_side not_equals $charmed_side (&lt;br /&gt;
             [then]&lt;br /&gt;
                 {MODIFY_UNIT x,y=$x2,$y2 variables.real_side $charmed_side}&lt;br /&gt;
                 {MODIFY_UNIT x,y=$x2,$y2 side $charmer_side}&lt;br /&gt;
                 {MODIFY_UNIT x,y=$x2,$y2 moves 1}&lt;br /&gt;
                 {MODIFY_UNIT x,y=$x2,$y2 attacks_left 1}&lt;br /&gt;
 &lt;br /&gt;
                 {VARIABLE_OP varname format &amp;quot;side_$charmed_side|_units_charmed&amp;quot;}&lt;br /&gt;
                 {VARIABLE $varname yes}&lt;br /&gt;
 &lt;br /&gt;
                 {CLEAR_VARIABLE varname}&lt;br /&gt;
             [/then]&lt;br /&gt;
         )}&lt;br /&gt;
 &lt;br /&gt;
         {CLEAR_VARIABLE charmer_side}&lt;br /&gt;
         {CLEAR_VARIABLE charmed_side}&lt;br /&gt;
     [/event]&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=side turn&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
         {VARIABLE_OP this_side_charmed to_variable &amp;quot;side_$side_number|_units_charmed&amp;quot;}&lt;br /&gt;
 &lt;br /&gt;
         {IF_VAR this_side_charmed equals yes (&lt;br /&gt;
             [then]&lt;br /&gt;
                 [store_unit]&lt;br /&gt;
                     [filter]&lt;br /&gt;
                         [not]&lt;br /&gt;
                             side=$side_number&lt;br /&gt;
                         [/not]&lt;br /&gt;
                     [/filter]&lt;br /&gt;
 &lt;br /&gt;
                     variable=possibly_charmed&lt;br /&gt;
                     kill=no&lt;br /&gt;
                 [/store_unit]&lt;br /&gt;
 &lt;br /&gt;
                 {FOREACH possibly_charmed i}&lt;br /&gt;
                     {VARIABLE_OP real_side format &amp;quot;0$possibly_charmed[$i].variables.real_side&amp;quot;}&lt;br /&gt;
 &lt;br /&gt;
                     {IF_VAR real_side not_equals &amp;quot;0&amp;quot; (&lt;br /&gt;
                         [then]&lt;br /&gt;
                             {IF_VAR side_number equals $possibly_charmed[$i].variables.real_side (&lt;br /&gt;
                                 [then]&lt;br /&gt;
                                     {CLEAR_VARIABLE possibly_charmed[$i].variables.real_side}&lt;br /&gt;
                                     {VARIABLE possibly_charmed[$i].side $side_number}&lt;br /&gt;
 &lt;br /&gt;
                                     [unstore_unit]&lt;br /&gt;
                                         variable=possibly_charmed[$i]&lt;br /&gt;
                                         find_vacant=no&lt;br /&gt;
                                     [/unstore_unit]&lt;br /&gt;
                                 [/then]&lt;br /&gt;
                             )}&lt;br /&gt;
                         [/then]&lt;br /&gt;
                     )}&lt;br /&gt;
                 {NEXT i}&lt;br /&gt;
 &lt;br /&gt;
                 {CLEAR_VARIABLE possibly_charmed}&lt;br /&gt;
             [/then]&lt;br /&gt;
         )}&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
=== Bloodlust ===&lt;br /&gt;
&lt;br /&gt;
Bloodlust is a very simple ability. If a unit that has bloodlust kills an enemy unit when attacking, it may attack again, provided that there are more enemy units adjacent to it.&lt;br /&gt;
&lt;br /&gt;
This would give the bloodlust ability to all Dwarvish Ulfserkers (making them insanely powerful):&lt;br /&gt;
&lt;br /&gt;
 {BLOODLUST (type=Dwarvish Ulfserker)}&lt;br /&gt;
&lt;br /&gt;
 #define BLOODLUST FILTER&lt;br /&gt;
     [event]&lt;br /&gt;
         name=die&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
         [filter_second]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter_second]&lt;br /&gt;
 &lt;br /&gt;
         {MODIFY_UNIT x,y=$x2,$y2 moves 0}&lt;br /&gt;
         {MODIFY_UNIT x,y=$x2,$y2 attacks_left 1}&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
=== Pickpocket ===&lt;br /&gt;
&lt;br /&gt;
This special could also be called loot. When a unit with this attack special sucessfully hits an enemy unit, it gains a certain amount of gold - say 10.&lt;br /&gt;
&lt;br /&gt;
To do this, use this code:&lt;br /&gt;
&lt;br /&gt;
 #define WEAPON_SPECIAL_PICKPOCKET&lt;br /&gt;
     [damage]&lt;br /&gt;
         id=pickpocket&lt;br /&gt;
         name=&amp;quot;Pickpocket&amp;quot;&lt;br /&gt;
         description=&amp;quot;When used offensively, this attack gives 10 gold to the attacker on every successful hit.&amp;quot; &lt;br /&gt;
         multiply=1&lt;br /&gt;
     [/damage]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Then put this event in your scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=attacker_hits&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=$side_number&lt;br /&gt;
 	 canrecruit=yes&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [special_filter]&lt;br /&gt;
         weapon=pickpocket gloves&lt;br /&gt;
     [/special_filter]&lt;br /&gt;
     [gold]&lt;br /&gt;
         side=$side_number&lt;br /&gt;
 	 amount=10&lt;br /&gt;
     [/gold]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Then give the unit you want to have the &amp;quot;pickpocket&amp;quot; special something like this:&lt;br /&gt;
&lt;br /&gt;
 [object]&lt;br /&gt;
     silent=yes&lt;br /&gt;
     [effect]&lt;br /&gt;
         apply_to=new_attack &lt;br /&gt;
 	 name=pickpocket gloves&lt;br /&gt;
 	 type=impact&lt;br /&gt;
 	 range=melee &lt;br /&gt;
 	 damage=3&lt;br /&gt;
 	 number=3 &lt;br /&gt;
 	 [specials]&lt;br /&gt;
 	     {WEAPON_SPECIAL_PICKPOCKET}&lt;br /&gt;
 	 [/specials]&lt;br /&gt;
     [/effect]&lt;br /&gt;
 [/object]&lt;br /&gt;
&lt;br /&gt;
===Soultaker===&lt;br /&gt;
&lt;br /&gt;
Any unit with this ability will gain an additional point of damage per strike every time it kills an enemy. Coder(s) unknown, made for Melon's Youkai faction (http://www.wesnoth.org/forum/viewtopic.php?f=19&amp;amp;t=20100).&lt;br /&gt;
&lt;br /&gt;
To give a unit the ability, place the following in any .cfg file loaded by the campaign or era:&lt;br /&gt;
&lt;br /&gt;
 #define ABILITY_SOULTAKER&lt;br /&gt;
 	[dummy]&lt;br /&gt;
 		id=soultaker&lt;br /&gt;
 		name= _ &amp;quot;soultaker&amp;quot;&lt;br /&gt;
 		description=_ &amp;quot;Soultaker:&lt;br /&gt;
 This unit gains an additional point added to its maximum damage whenever it kills a living unit.&amp;quot;&lt;br /&gt;
 	[/dummy]&lt;br /&gt;
 &lt;br /&gt;
 [/abilities]&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=die&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	[filter]&lt;br /&gt;
 		[not]&lt;br /&gt;
 			[wml_filter]&lt;br /&gt;
 				[status]&lt;br /&gt;
 					not_living=&amp;quot;yes&amp;quot;&lt;br /&gt;
 				[/status]&lt;br /&gt;
 			[/wml_filter]&lt;br /&gt;
 		[/not]&lt;br /&gt;
 	[/filter]&lt;br /&gt;
 &lt;br /&gt;
 	[filter_second]&lt;br /&gt;
 		ability=soultaker&lt;br /&gt;
 	[/filter_second]&lt;br /&gt;
 &lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=second_unit&lt;br /&gt;
 		{COLOR_HEAL}&lt;br /&gt;
 		text= _ &amp;quot;+1 damage&amp;quot;&lt;br /&gt;
 		find_vacant=no&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 &lt;br /&gt;
 	[object]&lt;br /&gt;
 		silent=yes&lt;br /&gt;
 		duration=forever&lt;br /&gt;
 		[filter]&lt;br /&gt;
 			x,y=$x2,$y2&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 &lt;br /&gt;
 		[effect]&lt;br /&gt;
 			apply_to=attack&lt;br /&gt;
 			range=melee&lt;br /&gt;
 			increase_damage=1&lt;br /&gt;
 			increase=1&lt;br /&gt;
 		[/effect]&lt;br /&gt;
 	[/object]&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [+abilities]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
And the following in the unit's [abilities] tag:&lt;br /&gt;
&lt;br /&gt;
 	{ABILITY_SOULTAKER}&lt;br /&gt;
&lt;br /&gt;
===Charm (Type 2)===&lt;br /&gt;
&lt;br /&gt;
An attack special. If the attack hits, and the target is level 0 or 1, the target is converted to the attacker's side. However, if it misses, the attacker is converted to the defender's side. Maintainer is krotop, using 1.4.X syntax, made for Melon's Youkai faction (http://www.wesnoth.org/forum/viewtopic.php?f=21&amp;amp;t=22539)&lt;br /&gt;
&lt;br /&gt;
Edit: Updated to 1.7.x syntax (maybe 1.6 compatible?) by solsword. See page history for the old version.&lt;br /&gt;
&lt;br /&gt;
 #textdomain wesnoth-tkotss&lt;br /&gt;
 &lt;br /&gt;
 #define ABILITY_CHARM WEAPON&lt;br /&gt;
 # dummy ability, defining the ability id for the next filters&lt;br /&gt;
 [dummy]&lt;br /&gt;
 	id=charm_attack&lt;br /&gt;
 [/dummy]&lt;br /&gt;
 &lt;br /&gt;
 [/abilities]&lt;br /&gt;
 &lt;br /&gt;
 # event that creates a variable at the beginning of the fight to check if the attacker hit at least once by the end.&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attack&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	&lt;br /&gt;
 	[filter]&lt;br /&gt;
 		ability=charm_attack&lt;br /&gt;
 	[/filter]&lt;br /&gt;
 	[filter_attack]&lt;br /&gt;
 		name={WEAPON}&lt;br /&gt;
 	[/filter_attack]&lt;br /&gt;
 	&lt;br /&gt;
 	[store_unit]&lt;br /&gt;
 		[filter]&lt;br /&gt;
 			x,y=$x1,$y1&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		variable=unit_att_with_charm&lt;br /&gt;
 		mode=append&lt;br /&gt;
 	[/store_unit]	&lt;br /&gt;
 	[set_variable]&lt;br /&gt;
 		name=unit_att_with_charm.variables.charm_has_worked&lt;br /&gt;
 		value=no&lt;br /&gt;
 	[/set_variable]	&lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=unit_att_with_charm&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	&lt;br /&gt;
 	{CLEAR_VARIABLE unit_att_with_charm}&lt;br /&gt;
 	&lt;br /&gt;
         {DEBUG &amp;quot;Charm setup&amp;quot;}&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # event that creates a &amp;quot;charm has worked&amp;quot; variable&lt;br /&gt;
 # and sets it to &amp;quot;yes&amp;quot; if the attacker hits at least once.&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attacker_hits&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	&lt;br /&gt;
 	[filter]&lt;br /&gt;
 		ability=charm_attack&lt;br /&gt;
 	[/filter]&lt;br /&gt;
 	[filter_attack]&lt;br /&gt;
 		name={WEAPON}&lt;br /&gt;
 	[/filter_attack]&lt;br /&gt;
 	&lt;br /&gt;
 	[store_unit]&lt;br /&gt;
 		[filter]&lt;br /&gt;
 			x,y=$x1,$y1&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		variable=unit_att_with_charm&lt;br /&gt;
 		mode=append&lt;br /&gt;
 	[/store_unit]&lt;br /&gt;
 	[set_variable]&lt;br /&gt;
 		name=unit_att_with_charm.variables.charm_has_worked&lt;br /&gt;
 		value=yes&lt;br /&gt;
 	[/set_variable]&lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=unit_att_with_charm&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	&lt;br /&gt;
 	{CLEAR_VARIABLE unit_att_with_charm}&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG &amp;quot;Charm hit&amp;quot;}&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # event that shifts a unit to the other side&lt;br /&gt;
 # if the defending unit&lt;br /&gt;
 #       - was not lvl1 or lvl0 &lt;br /&gt;
 #       - and was not a recruiting unit &lt;br /&gt;
 #       - and was a not a &amp;quot;non-living&amp;quot; creature&lt;br /&gt;
 # then :&lt;br /&gt;
 # -&amp;gt; if the attacker missed all attacks, it goes to the defender side.&lt;br /&gt;
 # -&amp;gt; if the attacker hit once at least, the defender goes to the attacker side.&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attack_end&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	&lt;br /&gt;
 	[filter]&lt;br /&gt;
 		ability=charm_attack&lt;br /&gt;
 	[/filter]&lt;br /&gt;
 	[filter_attack]&lt;br /&gt;
 		name={WEAPON}&lt;br /&gt;
 	[/filter_attack]&lt;br /&gt;
 	[filter_second]&lt;br /&gt;
 		canrecruit=no&lt;br /&gt;
 		[and]&lt;br /&gt;
 			level=0&lt;br /&gt;
 			[or]&lt;br /&gt;
 			level=1&lt;br /&gt;
 			[/or]&lt;br /&gt;
 		[/and]&lt;br /&gt;
 		[and]&lt;br /&gt;
 			[not]&lt;br /&gt;
 			[filter_wml]&lt;br /&gt;
 				[status]&lt;br /&gt;
 					not_living=yes&lt;br /&gt;
 				[/status]&lt;br /&gt;
 			[/filter_wml]&lt;br /&gt;
 			[/not]&lt;br /&gt;
 		[/and]&lt;br /&gt;
 	[/filter_second]&lt;br /&gt;
 	&lt;br /&gt;
 	[store_unit]&lt;br /&gt;
 		[filter]&lt;br /&gt;
 			x,y=$x1,$y1&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		variable=charmer&lt;br /&gt;
 		mode=append&lt;br /&gt;
 	[/store_unit]&lt;br /&gt;
 	&lt;br /&gt;
 	[store_unit]&lt;br /&gt;
 		[filter]&lt;br /&gt;
 			x,y=$x2,$y2&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		variable=charmed&lt;br /&gt;
 		mode=append&lt;br /&gt;
 	[/store_unit]&lt;br /&gt;
 	&lt;br /&gt;
 	[if]&lt;br /&gt;
 		[variable]&lt;br /&gt;
 			name=charmer.variables.charm_has_worked&lt;br /&gt;
 			equals=no&lt;br /&gt;
 		[/variable]&lt;br /&gt;
 		[then]&lt;br /&gt;
 			[set_variable]&lt;br /&gt;
 				name=charmer.side&lt;br /&gt;
 				value=$charmed.side&lt;br /&gt;
 			[/set_variable]&lt;br /&gt;
 		[/then]&lt;br /&gt;
 		[else]&lt;br /&gt;
 			[set_variable]&lt;br /&gt;
 				name=charmed.side&lt;br /&gt;
 				value=$charmer.side&lt;br /&gt;
 			[/set_variable]&lt;br /&gt;
 		[/else]&lt;br /&gt;
 	[/if]&lt;br /&gt;
 &lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=charmer&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=charmed&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	&lt;br /&gt;
 	{CLEAR_VARIABLE charmer}&lt;br /&gt;
 	{CLEAR_VARIABLE charmed}&lt;br /&gt;
 	&lt;br /&gt;
         {DEBUG &amp;quot;Charm resolution&amp;quot;}&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [+abilities]&lt;br /&gt;
 &lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 #define WEAPON_SPECIAL_CHARM&lt;br /&gt;
 # dummy weapon special used to describe the effect to the user&lt;br /&gt;
 &lt;br /&gt;
 [damage]&lt;br /&gt;
 	id=weapon_charm&lt;br /&gt;
 	name= _ &amp;quot;charm&amp;quot;&lt;br /&gt;
 	name_inactive= _ &amp;quot;charm&amp;quot;&lt;br /&gt;
 	description= _ &amp;quot;Charm : &lt;br /&gt;
 Turns a living level 1 or level 0 unit to your side. Beware  if all of your attacks miss, the charm user turns to the defender side, even if it is your leader. You can not charm an ennemy leader or a non-living creature.&amp;quot; &lt;br /&gt;
 	description_inactive= _ &amp;quot;Charm : &lt;br /&gt;
 Turns a living level 1 or level 0 unit to your side. Beware  if all of your attacks miss, the charm user turns to the defender side, even if it is your leader. You can not charm an ennemy leader or a non-living creature.&amp;quot; &lt;br /&gt;
 	apply_to=opponent&lt;br /&gt;
 [/damage]&lt;br /&gt;
 &lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== Works ==&lt;br /&gt;
&lt;br /&gt;
Unit with ability ''works'' will produce 1 gold per turn.&lt;br /&gt;
&lt;br /&gt;
Put this macro into you code before the last piece of code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ABILITY_WORKS&lt;br /&gt;
     [leadership]&lt;br /&gt;
          value=0&lt;br /&gt;
          id=peasant_works&lt;br /&gt;
          cumulative=no&lt;br /&gt;
          name=&amp;quot;works&amp;quot;&lt;br /&gt;
          description= _ &amp;quot;Works:&lt;br /&gt;
This unit produces 1 gold per turn.&amp;quot;&lt;br /&gt;
    [/leadership]&lt;br /&gt;
 #enddef&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put this event into your code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
	name=side turn&lt;br /&gt;
	first_time_only=no&lt;br /&gt;
	[store_unit]&lt;br /&gt;
		[filter]&lt;br /&gt;
	            #your filter here... for example type=Peasant&lt;br /&gt;
		[/filter]&lt;br /&gt;
		variable=worker&lt;br /&gt;
		kill=no&lt;br /&gt;
	[/store_unit]&lt;br /&gt;
&lt;br /&gt;
		{FOREACH worker i}&lt;br /&gt;
	&lt;br /&gt;
			 [gold]&lt;br /&gt;
                            side=$side_number &lt;br /&gt;
                            amount=1&lt;br /&gt;
                         [/gold] &lt;br /&gt;
			[unstore_unit]&lt;br /&gt;
				variable=worker[$i]&lt;br /&gt;
				text=&amp;quot;1&amp;quot;&lt;br /&gt;
			        red,green,blue=255,255,0 &lt;br /&gt;
			[/unstore_unit]&lt;br /&gt;
				&lt;br /&gt;
		{NEXT i}&lt;br /&gt;
	&lt;br /&gt;
	{CLEAR_VARIABLE worker}&lt;br /&gt;
 [/event]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And give the unit the ability like this&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 [object]&lt;br /&gt;
     silent=yes&lt;br /&gt;
     [effect]&lt;br /&gt;
	apply_to=new_ability&lt;br /&gt;
           [abilities]&lt;br /&gt;
             {ABILITY_WORKS}&lt;br /&gt;
           [/abilities]&lt;br /&gt;
     [/effect]&lt;br /&gt;
 [/object]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mind Flay  ==&lt;br /&gt;
&lt;br /&gt;
The weapon special gives an attacker 1 point of exp taken from a defender for each hit. This will violate minimum experience (i.e. defender can go below 0). &lt;br /&gt;
&lt;br /&gt;
Give this special to the attack(s) you want it to have. &lt;br /&gt;
 #define WEAPON_SPECIAL_MIND_FLAY&lt;br /&gt;
    [damage]&lt;br /&gt;
        id=mind_flay&lt;br /&gt;
        name=&amp;quot;Mind Flay&amp;quot;&lt;br /&gt;
        description=&amp;quot;When used offensively, each hit of the mind flay attack takes 1 point of experience from the defender and gives it to the attacker.&amp;quot; &lt;br /&gt;
        multiply=1&lt;br /&gt;
    [/damage]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Include these events into your scenario.&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attack&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	[special_filter]&lt;br /&gt;
 		weapon=mind flay&lt;br /&gt;
 	[/special_filter]&lt;br /&gt;
 	{VARIABLE hit_number 0}&lt;br /&gt;
 [/event]&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attacker_hits&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	[special_filter]&lt;br /&gt;
 		weapon=mind flay&lt;br /&gt;
 	[/special_filter]&lt;br /&gt;
 	{VARIABLE_OP hit_number add 1}&lt;br /&gt;
 [/event]&lt;br /&gt;
 [event]&lt;br /&gt;
 	name=attack_end&lt;br /&gt;
 	first_time_only=no&lt;br /&gt;
 	[special_filter]&lt;br /&gt;
 		weapon=mind flay&lt;br /&gt;
 	[/special_filter]&lt;br /&gt;
 	{VARIABLE_OP second_unit.experience add -$hit_number}&lt;br /&gt;
 	{VARIABLE_OP unit.experience add $hit_number}&lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=unit&lt;br /&gt;
 		find_vacant=no&lt;br /&gt;
 		text=$hit_number&lt;br /&gt;
 		blue=255&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	[unstore_unit]&lt;br /&gt;
 		variable=second_unit&lt;br /&gt;
 		find_vacant=no&lt;br /&gt;
 	[/unstore_unit]&lt;br /&gt;
 	{CLEAR_VARIABLE hit_number}&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Note: In dev version substitute &amp;quot;name=&amp;quot; instead of &amp;quot;weapon=&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Initiative  ==&lt;br /&gt;
&lt;br /&gt;
Initiative is an aura ability. Much like Leadership, it effects adjacent allies but not the unit itself.&lt;br /&gt;
&lt;br /&gt;
 #define AURA_INITIATIVE TYPE&lt;br /&gt;
 [dummy]&lt;br /&gt;
 	id=initiative&lt;br /&gt;
 	name= _ &amp;quot;initiative&amp;quot;&lt;br /&gt;
 	description= _ &amp;quot;Initiative:&lt;br /&gt;
 Adjacent allies are granted Firststrike with all weapons.&amp;quot;&lt;br /&gt;
 [/dummy]&lt;br /&gt;
 [/abilities]&lt;br /&gt;
 	[event]&lt;br /&gt;
 		name=attack&lt;br /&gt;
 		first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
 		[filter]&lt;br /&gt;
 			[filter_adjacent]&lt;br /&gt;
 				type={TYPE}&lt;br /&gt;
 				is_enemy=no&lt;br /&gt;
 			[/filter_adjacent]&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH unit.attack i}&lt;br /&gt;
 			{VARIABLE unit.attack[$i].specials.firststrike.id &amp;quot;firststrike&amp;quot;}&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 		&lt;br /&gt;
 		[unstore_unit]&lt;br /&gt;
 			variable=unit&lt;br /&gt;
 		[/unstore_unit]&lt;br /&gt;
 	[/event]&lt;br /&gt;
 	[event]&lt;br /&gt;
 		name=attack&lt;br /&gt;
 		first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
 		[filter_second]&lt;br /&gt;
 			[filter_adjacent]&lt;br /&gt;
 				type={TYPE}&lt;br /&gt;
 				is_enemy=no&lt;br /&gt;
 			[/filter_adjacent]&lt;br /&gt;
 		[/filter_second]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH second_unit.attack i}&lt;br /&gt;
 			{VARIABLE second_unit.attack[$i].specials.firststrike.id &amp;quot;firststrike&amp;quot;}&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 		&lt;br /&gt;
 		[unstore_unit]&lt;br /&gt;
 			variable=second_unit&lt;br /&gt;
 		[/unstore_unit]&lt;br /&gt;
 	[/event]&lt;br /&gt;
 	[event]&lt;br /&gt;
 		name=attack_end&lt;br /&gt;
 		first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
 		[filter]&lt;br /&gt;
 			[wml_filter]&lt;br /&gt;
 				[attack]&lt;br /&gt;
 					[specials]&lt;br /&gt;
 						[firststrike]&lt;br /&gt;
 							id=firststrike&lt;br /&gt;
 						[/firststrike]&lt;br /&gt;
 					[/specials]&lt;br /&gt;
 				[/attack]&lt;br /&gt;
 			[/wml_filter]&lt;br /&gt;
 		[/filter]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH unit.attack i}&lt;br /&gt;
 			{CLEAR_VARIABLE unit.attack[$i].specials.firststrike}&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 		&lt;br /&gt;
 		[unstore_unit]&lt;br /&gt;
 			variable=unit&lt;br /&gt;
 		[/unstore_unit]&lt;br /&gt;
 	[/event]&lt;br /&gt;
 	[event]&lt;br /&gt;
 		name=attack_end&lt;br /&gt;
 		first_time_only=no&lt;br /&gt;
 &lt;br /&gt;
 		[filter_second]&lt;br /&gt;
 			[wml_filter]&lt;br /&gt;
 				[attack]&lt;br /&gt;
 					[specials]&lt;br /&gt;
 						[firststrike]&lt;br /&gt;
 							id=firststrike&lt;br /&gt;
 						[/firststrike]&lt;br /&gt;
 					[/specials]&lt;br /&gt;
 				[/attack]&lt;br /&gt;
 			[/wml_filter]&lt;br /&gt;
 		[/filter_second]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH second_unit.attack i}&lt;br /&gt;
 			{CLEAR_VARIABLE second_unit.attack[$i].specials.firststrike}&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 		&lt;br /&gt;
 		[unstore_unit]&lt;br /&gt;
 			variable=second_unit&lt;br /&gt;
 		[/unstore_unit]&lt;br /&gt;
 	[/event]&lt;br /&gt;
 [+abilities]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
A WML filter may be added instead of the type if you want some units of that type to not have the ability.&lt;br /&gt;
&lt;br /&gt;
== Blitz ==&lt;br /&gt;
&lt;br /&gt;
Blitz is an aura ability. Much like Leadership, it effects adjacent allies but not the unit itself.&lt;br /&gt;
&lt;br /&gt;
 #define AURA_BLITZ TYPE&lt;br /&gt;
 [dummy]&lt;br /&gt;
 	id=blitz	&lt;br /&gt;
 	name= _ &amp;quot;blitz&amp;quot;&lt;br /&gt;
 	description= _ &amp;quot;Blitz:&lt;br /&gt;
 Allies that start their turn adjacent to this unit are granted Skirmisher for that turn.&amp;quot;&lt;br /&gt;
 [/dummy]&lt;br /&gt;
 [/abilities]&lt;br /&gt;
 	[event]&lt;br /&gt;
 		name=side turn&lt;br /&gt;
 		first_time_only=no&lt;br /&gt;
 		&lt;br /&gt;
 		[store_unit]&lt;br /&gt;
 			[filter]&lt;br /&gt;
 				&lt;br /&gt;
 				[wml_filter]&lt;br /&gt;
 					blitzed=1&lt;br /&gt;
 				[/wml_filter]&lt;br /&gt;
 			[/filter]&lt;br /&gt;
 			variable=blitz_refresh&lt;br /&gt;
 		[/store_unit]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH blitz_refresh i}&lt;br /&gt;
 			{CLEAR_VARIABLE blitz_refresh[$i].abilities.skirmisher}&lt;br /&gt;
 			{VARIABLE blitz_refresh[$i].blitzed 0}&lt;br /&gt;
 			[unstore_unit]&lt;br /&gt;
 				variable=blitz_refresh[$i]&lt;br /&gt;
 			[/unstore_unit]&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 &lt;br /&gt;
 		[store_unit]&lt;br /&gt;
 			[filter]&lt;br /&gt;
 				side=$side_number&lt;br /&gt;
 				[filter_adjacent]&lt;br /&gt;
 					type={TYPE}&lt;br /&gt;
 					is_enemy=no&lt;br /&gt;
 				[/filter_adjacent]&lt;br /&gt;
 			[/filter]&lt;br /&gt;
 			variable=blitzed&lt;br /&gt;
 		[/store_unit]&lt;br /&gt;
 		&lt;br /&gt;
 		{FOREACH blitzed i}&lt;br /&gt;
 			[if]&lt;br /&gt;
 				[variable]&lt;br /&gt;
 					name=blitzed[$i].abilities.skirmisher.id&lt;br /&gt;
 					not_equals=&amp;quot;skirmisher&amp;quot;&lt;br /&gt;
 				[/variable]&lt;br /&gt;
 				[then]&lt;br /&gt;
 					{VARIABLE blitzed[$i].blitzed 1}&lt;br /&gt;
 					{VARIABLE blitzed[$i].abilities.skirmisher.id skirmisher}&lt;br /&gt;
 					{VARIABLE blitzed[$i].abilities.skirmisher.name &amp;quot;skirmisher&amp;quot;}&lt;br /&gt;
 					{VARIABLE blitzed[$i].abilities.skirmisher.description  &amp;quot;Skirmisher:&lt;br /&gt;
 This unit is skilled in moving past enemies quickly, and ignores all enemy Zones of Control.&amp;quot;}&lt;br /&gt;
 					[unstore_unit]&lt;br /&gt;
 						variable=blitzed[$i]&lt;br /&gt;
 					[/unstore_unit]&lt;br /&gt;
 				[/then]&lt;br /&gt;
 			[/if]&lt;br /&gt;
 		{NEXT i}&lt;br /&gt;
 	[/event]&lt;br /&gt;
 [+abilities]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
A WML filter may be added instead of the type if you want some units of that type to not have the ability.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UsefulWMLFragments]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_Musical_Moods&amp;diff=32511</id>
		<title>WML Musical Moods</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_Musical_Moods&amp;diff=32511"/>
		<updated>2009-09-29T06:50:43Z</updated>

		<summary type="html">&lt;p&gt;Solsword: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Macros for grouping existing music (as of 1.7.x) and for changing playlists or playing random songs immediately.&lt;br /&gt;
&lt;br /&gt;
 #define MOOD_BATTLE&lt;br /&gt;
   [music]&lt;br /&gt;
     name=legends_of_the_north.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=battle.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=frantic.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=suspense.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_dangerous_symphony.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=casualties_of_war.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_EPIC&lt;br /&gt;
   [music]&lt;br /&gt;
     name=vengeful.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=frantic.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_city_falls.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=siege_of_laurelmor.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_CALM&lt;br /&gt;
   [music]&lt;br /&gt;
     name=traveling_minstrels.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elf-land.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=love_theme.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=sad.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=wanderer.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=journeys_end.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_HUSHED&lt;br /&gt;
   [music]&lt;br /&gt;
     name=revelation.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=underground.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_deep_path.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_SAD&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_king_is_dead.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elvish-theme.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=transience.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_DOOM&lt;br /&gt;
   [music]&lt;br /&gt;
     name=knalgan_theme.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=northerners.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_NORMAL&lt;br /&gt;
   [music]&lt;br /&gt;
     name=breaking_the_chains.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=heroes_rite.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=knolls.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=loyalists.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=nunc_dimittis.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=into_the_shadows.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=northern_mountains.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define SHHHH&lt;br /&gt;
   [music]&lt;br /&gt;
     name=silence.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=0&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_EPIC&lt;br /&gt;
   {RANDOM 0,1,2,3,4}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=vengeful.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=frantic.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_city_falls.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=3&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_dangerous_symphony.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=4&lt;br /&gt;
       [music]&lt;br /&gt;
         name=siege_of_laurelmor.ogg&lt;br /&gt;
         append=yes&lt;br /&gt;
         ms_before=8000&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_DOOM&lt;br /&gt;
   {RANDOM 0,1}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=knalgan_theme.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=northerners.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_ELVES&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elf-land.ogg&lt;br /&gt;
     play_once=yes&lt;br /&gt;
     immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_SILENCE&lt;br /&gt;
   [music]&lt;br /&gt;
     name=silence.ogg&lt;br /&gt;
     play_once=yes&lt;br /&gt;
     immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_BATTLE&lt;br /&gt;
   {RANDOM 0,1,2,3,4}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=legends_of_the_north.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=vengeful.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=frantic.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=3&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_dangerous_symphony.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=4&lt;br /&gt;
       [music]&lt;br /&gt;
         name=casualties_of_war.ogg&lt;br /&gt;
         append=yes&lt;br /&gt;
         ms_before=8000&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_SAD&lt;br /&gt;
   {RANDOM 0,1,2}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=elvish-theme.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_king_is_dead.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=transience.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_DEFEAT&lt;br /&gt;
   [music]&lt;br /&gt;
       name=defeat.ogg&lt;br /&gt;
       play_once=yes&lt;br /&gt;
       immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_VICTORY&lt;br /&gt;
   [music]&lt;br /&gt;
       name=victory2.ogg&lt;br /&gt;
       play_once=yes&lt;br /&gt;
       immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define VICTORY_AND_DEFEAT_MUSIC&lt;br /&gt;
   [event]&lt;br /&gt;
       name=victory&lt;br /&gt;
       {SHHHH}&lt;br /&gt;
       {CUE_VICTORY}&lt;br /&gt;
   [/event]&lt;br /&gt;
   [event]&lt;br /&gt;
       name=defeat&lt;br /&gt;
       {SHHHH}&lt;br /&gt;
       {CUE_DEFEAT}&lt;br /&gt;
   [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[UsefulWMLFragments]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CutsceneWML&amp;diff=32510</id>
		<title>CutsceneWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CutsceneWML&amp;diff=32510"/>
		<updated>2009-09-29T06:50:15Z</updated>

		<summary type="html">&lt;p&gt;Solsword: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;WML for cutscenes, including a fixed fake movement macro (for cases where the destination contains a unit) and macros for defining dialogue for units that activates when a &amp;quot;main character&amp;quot; stops south of them.&lt;br /&gt;
&lt;br /&gt;
==== Fake Movement ====&lt;br /&gt;
&lt;br /&gt;
 #define MOVE_TO FILTER X Y CONDITION&lt;br /&gt;
     # Moves a unit to an empty space near (X, Y) (or to (X, Y) if possible).&lt;br /&gt;
     # Ignores zones of control. Just like MOVE_UNIT, except doesn't glitch the&lt;br /&gt;
     # movement animation when X,Y is occupied. The destination will satisfy&lt;br /&gt;
     # CONDITION (a standard location filter), even if (X, Y) doesn't.&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=move_to_units&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
             [and]&lt;br /&gt;
                 [not]&lt;br /&gt;
                     x=recall&lt;br /&gt;
                 [/not]&lt;br /&gt;
             [/and]&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     {FOREACH move_to_units move_to_units_index}&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_id&lt;br /&gt;
             to_variable=move_to_units[$move_to_units_index].id&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [store_unit]&lt;br /&gt;
             variable=move_to_unit&lt;br /&gt;
             [filter]&lt;br /&gt;
                 id=$move_to_id&lt;br /&gt;
             [/filter]&lt;br /&gt;
         [/store_unit]&lt;br /&gt;
         # Get the starting x and y values:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=start_x&lt;br /&gt;
             to_variable=move_to_unit.x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=start_y&lt;br /&gt;
             to_variable=move_to_unit.y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Find an open space near the destination:&lt;br /&gt;
         {FIND_NEARBY ([not]&lt;br /&gt;
                           [filter]&lt;br /&gt;
                           [/filter]&lt;br /&gt;
                       [/not]&lt;br /&gt;
                       [and]&lt;br /&gt;
                           {CONDITION}&lt;br /&gt;
                       [/and]) {X} {Y} 30}&lt;br /&gt;
         # Set real coordinates and end position:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.x&lt;br /&gt;
             to_variable=nearby_locations[0].x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.y&lt;br /&gt;
             to_variable=nearby_locations[0].y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [clear_variable]&lt;br /&gt;
             name=nearby_locations&lt;br /&gt;
         [/clear_variable]&lt;br /&gt;
         [hide_unit]&lt;br /&gt;
             x,y=move_to_unit.x,move_to_unit.y&lt;br /&gt;
         [/hide_unit]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=end_x&lt;br /&gt;
             to_variable=move_to_unit.x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=end_y&lt;br /&gt;
             to_variable=move_to_unit.y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Determine new facing for the unit:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.facing&lt;br /&gt;
             format=$(if(start_x &amp;lt; end_x, se, sw))&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Scroll to the old location:&lt;br /&gt;
         [scroll_to]&lt;br /&gt;
             x=$start_x&lt;br /&gt;
             y=$start_y&lt;br /&gt;
         [/scroll_to]&lt;br /&gt;
         # Erase the old unit:&lt;br /&gt;
         [kill]&lt;br /&gt;
             id=$move_to_id&lt;br /&gt;
             animate=no&lt;br /&gt;
             fire_event=no&lt;br /&gt;
         [/kill]&lt;br /&gt;
         # Move the fake unit:&lt;br /&gt;
         [move_unit_fake]&lt;br /&gt;
             type=$move_to_unit.type&lt;br /&gt;
             gender=$move_to_unit.gender&lt;br /&gt;
             variation=$move_to_unit.variation&lt;br /&gt;
             side=$move_to_unit.side&lt;br /&gt;
             x=$start_x,$end_x&lt;br /&gt;
             y=$start_y,$end_y&lt;br /&gt;
         [/move_unit_fake]&lt;br /&gt;
         # Place the real unit:&lt;br /&gt;
         [unstore_unit]&lt;br /&gt;
             variable=move_to_unit&lt;br /&gt;
             find_vacant=yes&lt;br /&gt;
         [/unstore_unit]&lt;br /&gt;
         [redraw]&lt;br /&gt;
         [/redraw]&lt;br /&gt;
     {NEXT move_to_units_index}&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=move_to_units, move_to_unit, move_to_id, start_x, start_y, end_x, end_y&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Move to a point and then go to the recall list ====&lt;br /&gt;
&lt;br /&gt;
 #define EXIT_STAGE_RECALL FILTER X Y&lt;br /&gt;
     # Moves a unit matching the filter to X,Y, at which point it takes them&lt;br /&gt;
     # off of the map and puts them on the recall list. Doesn't work for more&lt;br /&gt;
     # than one unit at once.&lt;br /&gt;
     {MOVE_TO {FILTER} {X} {Y} ()}&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=exit_stage_recall_unit&lt;br /&gt;
         kill=yes&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     [unstore_unit]&lt;br /&gt;
         variable=exit_stage_recall_unit&lt;br /&gt;
         x,y=recall,recall&lt;br /&gt;
     [/unstore_unit]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=exit_stage_recall_unit&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Give a unit unlimited movement ====&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNLIMITED_MOVEMENT FILTER&lt;br /&gt;
     # Useful for story-only situations, this macro defines an event that&lt;br /&gt;
     # replenishes a unit's movement whenever that unit moves.&lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
         [store_unit]&lt;br /&gt;
             kill=no&lt;br /&gt;
             variable=temp&lt;br /&gt;
             [filter]&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/filter]&lt;br /&gt;
         [/store_unit]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=temp.moves&lt;br /&gt;
             to_variable=temp.max_moves&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [unstore_unit]&lt;br /&gt;
             find_vacant=no&lt;br /&gt;
             variable=temp&lt;br /&gt;
         [/unstore_unit]&lt;br /&gt;
         [clear_variable]&lt;br /&gt;
             name=temp&lt;br /&gt;
         [/clear_variable]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set up dialogue-based interaction ====&lt;br /&gt;
&lt;br /&gt;
 #define ENABLE_INTERACTION&lt;br /&gt;
     # Sets up events to handle unit interaction. See the SET_MAIN_CHARACTER and&lt;br /&gt;
     # UNIT_MESSAGE macros...&lt;br /&gt;
     [event]&lt;br /&gt;
         name=trigger_dialogue&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [switch]&lt;br /&gt;
             variable=second_unit.variables.dialogue.type&lt;br /&gt;
             [case]&lt;br /&gt;
                 value=message&lt;br /&gt;
                 {M id=$second_unit.id $second_unit.variables.dialogue.message}&lt;br /&gt;
                 [if]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=second_unit.variables.dialogue.response&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                     [then]&lt;br /&gt;
                         {M id=$unit.id $second_unit.variables.dialogue.response}&lt;br /&gt;
                     [/then]&lt;br /&gt;
                 [/if]&lt;br /&gt;
                 [if]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=second_unit.variables.dialogue.event&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                     [then]&lt;br /&gt;
                         [fire_event]&lt;br /&gt;
                             name=$second_unit.variables.dialogue.event&lt;br /&gt;
                             [primary_unit]&lt;br /&gt;
                                 id=$unit.id&lt;br /&gt;
                             [/primary_unit]&lt;br /&gt;
                             [secondary_unit]&lt;br /&gt;
                                 id=$second_unit.id&lt;br /&gt;
                             [/secondary_unit]&lt;br /&gt;
                         [/fire_event]&lt;br /&gt;
                     [/then]&lt;br /&gt;
                 [/if]&lt;br /&gt;
             [/case]&lt;br /&gt;
             [case]&lt;br /&gt;
                 value=option&lt;br /&gt;
                 [message]&lt;br /&gt;
                     id=$second_unit.id&lt;br /&gt;
                     message=$second_unit.variables.dialogue.message&lt;br /&gt;
                     [option]&lt;br /&gt;
                         message=$second_unit.variables.dialogue.option1&lt;br /&gt;
                         [command]&lt;br /&gt;
                             [if]&lt;br /&gt;
                                 [variable]&lt;br /&gt;
                                     name=second_unit.variables.dialogue.event1&lt;br /&gt;
                                     not_equals=$null&lt;br /&gt;
                                 [/variable]&lt;br /&gt;
                                 [then]&lt;br /&gt;
                                     [fire_event]&lt;br /&gt;
                                         name=$second_unit.variables.dialogue.event1&lt;br /&gt;
                                         [primary_unit]&lt;br /&gt;
                                             id=$unit.id&lt;br /&gt;
                                         [/primary_unit]&lt;br /&gt;
                                         [secondary_unit]&lt;br /&gt;
                                             id=$second_unit.id&lt;br /&gt;
                                         [/secondary_unit]&lt;br /&gt;
                                     [/fire_event]&lt;br /&gt;
                                 [/then]&lt;br /&gt;
                             [/if]&lt;br /&gt;
                         [/command]&lt;br /&gt;
                     [/option]&lt;br /&gt;
                     [option]&lt;br /&gt;
                         message=$second_unit.variables.dialogue.option2&lt;br /&gt;
                         [command]&lt;br /&gt;
                             [if]&lt;br /&gt;
                                 [variable]&lt;br /&gt;
                                     name=second_unit.variables.dialogue.event2&lt;br /&gt;
                                     not_equals=$null&lt;br /&gt;
                                 [/variable]&lt;br /&gt;
                                 [then]&lt;br /&gt;
                                     [fire_event]&lt;br /&gt;
                                         name=$second_unit.variables.dialogue.event2&lt;br /&gt;
                                         [primary_unit]&lt;br /&gt;
                                             id=$unit.id&lt;br /&gt;
                                         [/primary_unit]&lt;br /&gt;
                                         [secondary_unit]&lt;br /&gt;
                                             id=$second_unit.id&lt;br /&gt;
                                         [/secondary_unit]&lt;br /&gt;
                                     [/fire_event]&lt;br /&gt;
                                 [/then]&lt;br /&gt;
                             [/if]&lt;br /&gt;
                         [/command]&lt;br /&gt;
                     [/option]&lt;br /&gt;
                 [/message]&lt;br /&gt;
             [/case]&lt;br /&gt;
             # Note: silent failure on unknown type is intentional.&lt;br /&gt;
         [/switch]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set the main character ====&lt;br /&gt;
&lt;br /&gt;
 #define SET_MAIN_CHARACTER FILTER&lt;br /&gt;
     # Sets the filtered unit as the &amp;quot;main character&amp;quot; allowing them to talk to&lt;br /&gt;
     # units that have an appropriate 'dialogue' variable. Interaction is&lt;br /&gt;
     # triggered when the filtered unit moves to a space drectly south of a unit&lt;br /&gt;
     # with dialogue. Note that the ENABLE_INTERACTION macro must be present in&lt;br /&gt;
     # order for this macro to work. See also the UNIT_MESSAGE and UNIT_OPTION&lt;br /&gt;
     # macros.&lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
             [and]&lt;br /&gt;
                 [filter_adjacent]&lt;br /&gt;
                     count=1&lt;br /&gt;
                     adjacent=n&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=this_unit.variables.dialogue.type&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/filter_adjacent]&lt;br /&gt;
             [/and]&lt;br /&gt;
         [/filter]&lt;br /&gt;
         [fire_event]&lt;br /&gt;
             name=trigger_dialogue&lt;br /&gt;
             [primary_unit]&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/primary_unit]&lt;br /&gt;
             [secondary_unit]&lt;br /&gt;
                 [filter_adjacent]&lt;br /&gt;
                     count=1&lt;br /&gt;
                     adjacent=s&lt;br /&gt;
                     {FILTER}&lt;br /&gt;
                 [/filter_adjacent]&lt;br /&gt;
             [/secondary_unit]&lt;br /&gt;
         [/fire_event]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set dialogue for a unit ====&lt;br /&gt;
&lt;br /&gt;
 #define UNIT_MESSAGE MESSAGE RESPONSE EVENT&lt;br /&gt;
     # Defines dialogue for a unit. When the main character (see the&lt;br /&gt;
     # SET_MAIN_CHARACTER macro) triggers interaction with this unit, the&lt;br /&gt;
     # message MESSAGE will be displayed, and the triggering unit will respond&lt;br /&gt;
     # with RESPONSE, after which EVENT will be fired with the triggering unit&lt;br /&gt;
     # as the primary unit and this unit as the secondary unit. Note that this&lt;br /&gt;
     # macro should be placed within a [variables] tag inside of a [unit] tag.&lt;br /&gt;
     [dialogue]&lt;br /&gt;
         type=message&lt;br /&gt;
         message={MESSAGE}&lt;br /&gt;
         response={RESPONSE}&lt;br /&gt;
         event={EVENT}&lt;br /&gt;
     [/dialogue]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNIT_MESSAGE FILTER MESSAGE RESPONSE EVENT&lt;br /&gt;
     # Works just like the UNIT_MESSAGE macro, except that it takes a FILTER&lt;br /&gt;
     # argument and applies the message to the all units matching the filter.&lt;br /&gt;
     # UNIT_MESSAGE can only be used during unit creation, and must be placed&lt;br /&gt;
     # within a [variables] tag. SET_UNIT_MESSAGE, on the other hand, can be&lt;br /&gt;
     # used anywhere.&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.type) (&amp;quot;message&amp;quot;)}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.message) ({MESSAGE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.response) ({RESPONSE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event) ({EVENT})}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set dialogue for a unit, including a two-option question ====&lt;br /&gt;
&lt;br /&gt;
 #define UNIT_OPTION MESSAGE OPTION1 OPTION2 EVENT1 EVENT2&lt;br /&gt;
     # Defines dialogue for a unit that includes a choice to present to the&lt;br /&gt;
     # player. When the main character (see the SET_MAIN_CHARACTER macro)&lt;br /&gt;
     # triggers interaction with this unit, the message MESSAGE will be&lt;br /&gt;
     # displayed, along with the options OPTION1 and OPTION2. Depending on which&lt;br /&gt;
     # option the player chooses, either EVENT1 or EVENT2 will then be fired&lt;br /&gt;
     # with the triggering unit as the primary unit and this unit as the&lt;br /&gt;
     # secondary unit. Note that this macro should be placed within a&lt;br /&gt;
     # [variables] tag inside of a [unit] tag.&lt;br /&gt;
     [dialogue]&lt;br /&gt;
         type=option&lt;br /&gt;
         message={MESSAGE}&lt;br /&gt;
         option1={OPTION1}&lt;br /&gt;
         option2={OPTION2}&lt;br /&gt;
         event1={EVENT1}&lt;br /&gt;
         event2={EVENT2}&lt;br /&gt;
     [/dialogue]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNIT_OPTION FILTER MESSAGE OPTION1 OPTION2 EVENT1 EVENT2&lt;br /&gt;
     # Works just like the UNIT_OPTION macro, except that it takes a FILTER&lt;br /&gt;
     # argument and applies the message to all units matching the filter.&lt;br /&gt;
     # UNIT_OPTION can only be used during unit creation, and must be placed&lt;br /&gt;
     # within a [variables] tag. SET_UNIT_OPTION, on the other hand, can be&lt;br /&gt;
     # used anywhere.&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.type) (&amp;quot;option&amp;quot;)}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.message) ({MESSAGE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.option1) ({OPTION1})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.option2) ({OPTION2})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event1) ({EVENT1})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event2) ({EVENT2})}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Clear unit dialogue ====&lt;br /&gt;
&lt;br /&gt;
 #define CLEAR_UNIT_DIALOGUE FILTER&lt;br /&gt;
     # Removes any dialogue that is assigned to units matching the given filter,&lt;br /&gt;
     # including both messages and options.&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.type)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.message)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.response)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.option1)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.option2)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event1)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event2)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue)}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Assign a role to a recalled unit with various back-ups ====&lt;br /&gt;
&lt;br /&gt;
 #define FILL_ROLE_RECALL SIDE ROLE FILTER BACKUP_FILTER TYPE X Y&lt;br /&gt;
     # Recalls the first unit on side SIDE matching FILTER and assigns it the&lt;br /&gt;
     # role ROLE. If no such unit exists, it tries to find a unit that matches&lt;br /&gt;
     # the given BACKUP_FILTER on SIDE's recall list, and if it can't, it tries&lt;br /&gt;
     # to find any unit on side SIDE's recall list. If SIDE has no units on its&lt;br /&gt;
     # recall list, a unit is spawned of type TYPE to fill the role. If the role&lt;br /&gt;
     # is already filled, this does nothing. If the given location is&lt;br /&gt;
     # unavailable, the nearest empty location will be used.&lt;br /&gt;
     [if]&lt;br /&gt;
         [have_unit]&lt;br /&gt;
             side={SIDE}&lt;br /&gt;
             x,y={X},{Y}&lt;br /&gt;
         [/have_unit]&lt;br /&gt;
         [then]&lt;br /&gt;
             {FIND_NEARBY ([not]&lt;br /&gt;
                               [filter]&lt;br /&gt;
                               [/filter]&lt;br /&gt;
                           [/not]) {X} {Y} 30}&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_x&lt;br /&gt;
                 to_variable=nearby_locations[0].x&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_y&lt;br /&gt;
                 to_variable=nearby_locations[0].y&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [clear_variable]&lt;br /&gt;
                 name=nearby_locations&lt;br /&gt;
             [/clear_variable]&lt;br /&gt;
         [/then]&lt;br /&gt;
         [else]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_x&lt;br /&gt;
                 value={X}&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_y&lt;br /&gt;
                 value={Y}&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
         [/else]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {BACKUP_FILTER}&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 {BACKUP_FILTER}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 type={TYPE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 generate_name=yes&lt;br /&gt;
                 random_gender=yes&lt;br /&gt;
                 random_traits=yes&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/unit]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=fill_role_recall_target_x,fill_role_recall_target_y&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Assign a group of roles to several units with backups ====&lt;br /&gt;
&lt;br /&gt;
 #define ASSIGN_ROLES ROLES DESIRED_ROLE_FILTER BACKUP_ROLE_FILTER&lt;br /&gt;
     # Fills several roles at once from the pool of units specified by&lt;br /&gt;
     # DESIRED_ROLE_FILTER, using units that match BACKUP_ROLE_FILTER if&lt;br /&gt;
     # necessary. ROLES should be an ordered, comma-separated list of roles to&lt;br /&gt;
     # fill. If not enough units match among both the DESIRED and BACKUP&lt;br /&gt;
     # filters, not all of the roles will be assigned. The main advantage of&lt;br /&gt;
     # ASSIGN_ROLES over [role] tags is that you don't have to use a bunch of&lt;br /&gt;
     # [not] role= [/not] statements to ensure that each unit gets one role.&lt;br /&gt;
     [set_variables]&lt;br /&gt;
         name=roles_to_assign&lt;br /&gt;
         [split]&lt;br /&gt;
             list={ROLES}&lt;br /&gt;
             key=value&lt;br /&gt;
             separator=,&lt;br /&gt;
             remove_empty=yes&lt;br /&gt;
         [/split]&lt;br /&gt;
     [/set_variables]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=role_assignment_index&lt;br /&gt;
         value=0&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=done_assigning_roles&lt;br /&gt;
         value=no&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=primary_role_candidates&lt;br /&gt;
         [filter]&lt;br /&gt;
             {DESIRED_ROLE_FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=role_candidate_index&lt;br /&gt;
         value=0&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [while]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=done_assigning_roles&lt;br /&gt;
             boolean_equals=no&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [and]&lt;br /&gt;
             [variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 less_than=$primary_role_candidates.length&lt;br /&gt;
             [/variable]&lt;br /&gt;
         [/and]&lt;br /&gt;
         [do]&lt;br /&gt;
             # Assign a role:&lt;br /&gt;
             [role]&lt;br /&gt;
                 role=$roles_to_assign[$($role_assignment_index)].value&lt;br /&gt;
                 id=$primary_role_candidates[$($role_candidate_index)].id&lt;br /&gt;
             [/role]&lt;br /&gt;
             # Increment loop variables:&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_assignment_index&lt;br /&gt;
                 add=1&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 add=1&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             # Check the break condition:&lt;br /&gt;
             [if]&lt;br /&gt;
                 [not]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=role_assignment_index&lt;br /&gt;
                         less_than=$roles_to_assign.length&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/not]&lt;br /&gt;
                 [then]&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=done_assigning_roles&lt;br /&gt;
                         value=yes&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                 [/then]&lt;br /&gt;
             [/if]&lt;br /&gt;
         [/do]&lt;br /&gt;
     [/while]&lt;br /&gt;
     # Use backups if necessary:&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=done_assigning_roles&lt;br /&gt;
             boolean_equals=no&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [store_unit]&lt;br /&gt;
                 variable=secondary_role_candidates&lt;br /&gt;
                 [filter]&lt;br /&gt;
                     {BACKUP_ROLE_FILTER}&lt;br /&gt;
                 [/filter]&lt;br /&gt;
             [/store_unit]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 value=0&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [while]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=done_assigning_roles&lt;br /&gt;
                     boolean_equals=no&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [and]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=role_candidate_index&lt;br /&gt;
                         less_than=$secondary_role_candidates.length&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/and]&lt;br /&gt;
                 [do]&lt;br /&gt;
                     # Assign a role:&lt;br /&gt;
                     [role]&lt;br /&gt;
                         role=$roles_to_assign[$($role_assignment_index)].value&lt;br /&gt;
                         id=$secondary_role_candidates[$($role_candidate_index)].id&lt;br /&gt;
                     [/role]&lt;br /&gt;
                     # Increment loop variables:&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=role_assignment_index&lt;br /&gt;
                         add=1&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=role_candidate_index&lt;br /&gt;
                         add=1&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                     # Check the break condition:&lt;br /&gt;
                     [if]&lt;br /&gt;
                         [not]&lt;br /&gt;
                             [variable]&lt;br /&gt;
                                 name=role_assignment_index&lt;br /&gt;
                                 less_than=$roles_to_assign.length&lt;br /&gt;
                             [/variable]&lt;br /&gt;
                         [/not]&lt;br /&gt;
                         [then]&lt;br /&gt;
                             [set_variable]&lt;br /&gt;
                                 name=done_assigning_roles&lt;br /&gt;
                                 value=yes&lt;br /&gt;
                             [/set_variable]&lt;br /&gt;
                         [/then]&lt;br /&gt;
                     [/if]&lt;br /&gt;
                 [/do]&lt;br /&gt;
             [/while]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=roles_to_assign, role_assignment_index, primary_role_candidates, secondary_role_candidates, role_candidate_index, done_assigning_roles&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[UsefulWMLFragments]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32507</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32507"/>
		<updated>2009-09-29T06:42:37Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Campaign Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
*[[AlternateToDWML]]: Macros for alternate time-of-day schemes, including per-hour time-of-day.&lt;br /&gt;
&lt;br /&gt;
==== RPG Tools ====&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY from [[WML Utilities]]), move + exit to recall list, define character dialogue and a &amp;quot;main character&amp;quot;, grant unlimited moves.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32506</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32506"/>
		<updated>2009-09-29T06:41:21Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* RPG Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
==== RPG Tools ====&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY from [[WML Utilities]]), move + exit to recall list, define character dialogue and a &amp;quot;main character&amp;quot;, grant unlimited moves.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CutsceneWML&amp;diff=32505</id>
		<title>CutsceneWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CutsceneWML&amp;diff=32505"/>
		<updated>2009-09-29T06:39:02Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Initial copy of the page macros&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;WML for cutscenes, including a fixed fake movement macro (for cases where the destination contains a unit) and macros for defining dialogue for units that activates when a &amp;quot;main character&amp;quot; stops south of them.&lt;br /&gt;
&lt;br /&gt;
==== Fake Movement ====&lt;br /&gt;
&lt;br /&gt;
 #define MOVE_TO FILTER X Y CONDITION&lt;br /&gt;
     # Moves a unit to an empty space near (X, Y) (or to (X, Y) if possible).&lt;br /&gt;
     # Ignores zones of control. Just like MOVE_UNIT, except doesn't glitch the&lt;br /&gt;
     # movement animation when X,Y is occupied. The destination will satisfy&lt;br /&gt;
     # CONDITION (a standard location filter), even if (X, Y) doesn't.&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=move_to_units&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
             [and]&lt;br /&gt;
                 [not]&lt;br /&gt;
                     x=recall&lt;br /&gt;
                 [/not]&lt;br /&gt;
             [/and]&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     {FOREACH move_to_units move_to_units_index}&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_id&lt;br /&gt;
             to_variable=move_to_units[$move_to_units_index].id&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [store_unit]&lt;br /&gt;
             variable=move_to_unit&lt;br /&gt;
             [filter]&lt;br /&gt;
                 id=$move_to_id&lt;br /&gt;
             [/filter]&lt;br /&gt;
         [/store_unit]&lt;br /&gt;
         # Get the starting x and y values:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=start_x&lt;br /&gt;
             to_variable=move_to_unit.x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=start_y&lt;br /&gt;
             to_variable=move_to_unit.y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Find an open space near the destination:&lt;br /&gt;
         {FIND_NEARBY ([not]&lt;br /&gt;
                           [filter]&lt;br /&gt;
                           [/filter]&lt;br /&gt;
                       [/not]&lt;br /&gt;
                       [and]&lt;br /&gt;
                           {CONDITION}&lt;br /&gt;
                       [/and]) {X} {Y} 30}&lt;br /&gt;
         # Set real coordinates and end position:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.x&lt;br /&gt;
             to_variable=nearby_locations[0].x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.y&lt;br /&gt;
             to_variable=nearby_locations[0].y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [clear_variable]&lt;br /&gt;
             name=nearby_locations&lt;br /&gt;
         [/clear_variable]&lt;br /&gt;
         [hide_unit]&lt;br /&gt;
             x,y=move_to_unit.x,move_to_unit.y&lt;br /&gt;
         [/hide_unit]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=end_x&lt;br /&gt;
             to_variable=move_to_unit.x&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=end_y&lt;br /&gt;
             to_variable=move_to_unit.y&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Determine new facing for the unit:&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=move_to_unit.facing&lt;br /&gt;
             format=$(if(start_x &amp;lt; end_x, se, sw))&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         # Scroll to the old location:&lt;br /&gt;
         [scroll_to]&lt;br /&gt;
             x=$start_x&lt;br /&gt;
             y=$start_y&lt;br /&gt;
         [/scroll_to]&lt;br /&gt;
         # Erase the old unit:&lt;br /&gt;
         [kill]&lt;br /&gt;
             id=$move_to_id&lt;br /&gt;
             animate=no&lt;br /&gt;
             fire_event=no&lt;br /&gt;
         [/kill]&lt;br /&gt;
         # Move the fake unit:&lt;br /&gt;
         [move_unit_fake]&lt;br /&gt;
             type=$move_to_unit.type&lt;br /&gt;
             gender=$move_to_unit.gender&lt;br /&gt;
             variation=$move_to_unit.variation&lt;br /&gt;
             side=$move_to_unit.side&lt;br /&gt;
             x=$start_x,$end_x&lt;br /&gt;
             y=$start_y,$end_y&lt;br /&gt;
         [/move_unit_fake]&lt;br /&gt;
         # Place the real unit:&lt;br /&gt;
         [unstore_unit]&lt;br /&gt;
             variable=move_to_unit&lt;br /&gt;
             find_vacant=yes&lt;br /&gt;
         [/unstore_unit]&lt;br /&gt;
         [redraw]&lt;br /&gt;
         [/redraw]&lt;br /&gt;
     {NEXT move_to_units_index}&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=move_to_units, move_to_unit, move_to_id, start_x, start_y, end_x, end_y&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Move to a point and then go to the recall list ====&lt;br /&gt;
&lt;br /&gt;
 #define EXIT_STAGE_RECALL FILTER X Y&lt;br /&gt;
     # Moves a unit matching the filter to X,Y, at which point it takes them&lt;br /&gt;
     # off of the map and puts them on the recall list. Doesn't work for more&lt;br /&gt;
     # than one unit at once.&lt;br /&gt;
     {MOVE_TO {FILTER} {X} {Y} ()}&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=exit_stage_recall_unit&lt;br /&gt;
         kill=yes&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     [unstore_unit]&lt;br /&gt;
         variable=exit_stage_recall_unit&lt;br /&gt;
         x,y=recall,recall&lt;br /&gt;
     [/unstore_unit]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=exit_stage_recall_unit&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Give a unit unlimited movement ====&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNLIMITED_MOVEMENT FILTER&lt;br /&gt;
     # Useful for story-only situations, this macro defines an event that&lt;br /&gt;
     # replenishes a unit's movement whenever that unit moves.&lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
         [store_unit]&lt;br /&gt;
             kill=no&lt;br /&gt;
             variable=temp&lt;br /&gt;
             [filter]&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/filter]&lt;br /&gt;
         [/store_unit]&lt;br /&gt;
         [set_variable]&lt;br /&gt;
             name=temp.moves&lt;br /&gt;
             to_variable=temp.max_moves&lt;br /&gt;
         [/set_variable]&lt;br /&gt;
         [unstore_unit]&lt;br /&gt;
             find_vacant=no&lt;br /&gt;
             variable=temp&lt;br /&gt;
         [/unstore_unit]&lt;br /&gt;
         [clear_variable]&lt;br /&gt;
             name=temp&lt;br /&gt;
         [/clear_variable]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set up dialogue-based interaction ====&lt;br /&gt;
&lt;br /&gt;
 #define ENABLE_INTERACTION&lt;br /&gt;
     # Sets up events to handle unit interaction. See the SET_MAIN_CHARACTER and&lt;br /&gt;
     # UNIT_MESSAGE macros...&lt;br /&gt;
     [event]&lt;br /&gt;
         name=trigger_dialogue&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [switch]&lt;br /&gt;
             variable=second_unit.variables.dialogue.type&lt;br /&gt;
             [case]&lt;br /&gt;
                 value=message&lt;br /&gt;
                 {M id=$second_unit.id $second_unit.variables.dialogue.message}&lt;br /&gt;
                 [if]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=second_unit.variables.dialogue.response&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                     [then]&lt;br /&gt;
                         {M id=$unit.id $second_unit.variables.dialogue.response}&lt;br /&gt;
                     [/then]&lt;br /&gt;
                 [/if]&lt;br /&gt;
                 [if]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=second_unit.variables.dialogue.event&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                     [then]&lt;br /&gt;
                         [fire_event]&lt;br /&gt;
                             name=$second_unit.variables.dialogue.event&lt;br /&gt;
                             [primary_unit]&lt;br /&gt;
                                 id=$unit.id&lt;br /&gt;
                             [/primary_unit]&lt;br /&gt;
                             [secondary_unit]&lt;br /&gt;
                                 id=$second_unit.id&lt;br /&gt;
                             [/secondary_unit]&lt;br /&gt;
                         [/fire_event]&lt;br /&gt;
                     [/then]&lt;br /&gt;
                 [/if]&lt;br /&gt;
             [/case]&lt;br /&gt;
             [case]&lt;br /&gt;
                 value=option&lt;br /&gt;
                 [message]&lt;br /&gt;
                     id=$second_unit.id&lt;br /&gt;
                     message=$second_unit.variables.dialogue.message&lt;br /&gt;
                     [option]&lt;br /&gt;
                         message=$second_unit.variables.dialogue.option1&lt;br /&gt;
                         [command]&lt;br /&gt;
                             [if]&lt;br /&gt;
                                 [variable]&lt;br /&gt;
                                     name=second_unit.variables.dialogue.event1&lt;br /&gt;
                                     not_equals=$null&lt;br /&gt;
                                 [/variable]&lt;br /&gt;
                                 [then]&lt;br /&gt;
                                     [fire_event]&lt;br /&gt;
                                         name=$second_unit.variables.dialogue.event1&lt;br /&gt;
                                         [primary_unit]&lt;br /&gt;
                                             id=$unit.id&lt;br /&gt;
                                         [/primary_unit]&lt;br /&gt;
                                         [secondary_unit]&lt;br /&gt;
                                             id=$second_unit.id&lt;br /&gt;
                                         [/secondary_unit]&lt;br /&gt;
                                     [/fire_event]&lt;br /&gt;
                                 [/then]&lt;br /&gt;
                             [/if]&lt;br /&gt;
                         [/command]&lt;br /&gt;
                     [/option]&lt;br /&gt;
                     [option]&lt;br /&gt;
                         message=$second_unit.variables.dialogue.option2&lt;br /&gt;
                         [command]&lt;br /&gt;
                             [if]&lt;br /&gt;
                                 [variable]&lt;br /&gt;
                                     name=second_unit.variables.dialogue.event2&lt;br /&gt;
                                     not_equals=$null&lt;br /&gt;
                                 [/variable]&lt;br /&gt;
                                 [then]&lt;br /&gt;
                                     [fire_event]&lt;br /&gt;
                                         name=$second_unit.variables.dialogue.event2&lt;br /&gt;
                                         [primary_unit]&lt;br /&gt;
                                             id=$unit.id&lt;br /&gt;
                                         [/primary_unit]&lt;br /&gt;
                                         [secondary_unit]&lt;br /&gt;
                                             id=$second_unit.id&lt;br /&gt;
                                         [/secondary_unit]&lt;br /&gt;
                                     [/fire_event]&lt;br /&gt;
                                 [/then]&lt;br /&gt;
                             [/if]&lt;br /&gt;
                         [/command]&lt;br /&gt;
                     [/option]&lt;br /&gt;
                 [/message]&lt;br /&gt;
             [/case]&lt;br /&gt;
             # Note: silent failure on unknown type is intentional.&lt;br /&gt;
         [/switch]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set the main character ====&lt;br /&gt;
&lt;br /&gt;
 #define SET_MAIN_CHARACTER FILTER&lt;br /&gt;
     # Sets the filtered unit as the &amp;quot;main character&amp;quot; allowing them to talk to&lt;br /&gt;
     # units that have an appropriate 'dialogue' variable. Interaction is&lt;br /&gt;
     # triggered when the filtered unit moves to a space drectly south of a unit&lt;br /&gt;
     # with dialogue. Note that the ENABLE_INTERACTION macro must be present in&lt;br /&gt;
     # order for this macro to work. See also the UNIT_MESSAGE and UNIT_OPTION&lt;br /&gt;
     # macros.&lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         first_time_only=no&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
             [and]&lt;br /&gt;
                 [filter_adjacent]&lt;br /&gt;
                     count=1&lt;br /&gt;
                     adjacent=n&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=this_unit.variables.dialogue.type&lt;br /&gt;
                         not_equals=$null&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/filter_adjacent]&lt;br /&gt;
             [/and]&lt;br /&gt;
         [/filter]&lt;br /&gt;
         [fire_event]&lt;br /&gt;
             name=trigger_dialogue&lt;br /&gt;
             [primary_unit]&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/primary_unit]&lt;br /&gt;
             [secondary_unit]&lt;br /&gt;
                 [filter_adjacent]&lt;br /&gt;
                     count=1&lt;br /&gt;
                     adjacent=s&lt;br /&gt;
                     {FILTER}&lt;br /&gt;
                 [/filter_adjacent]&lt;br /&gt;
             [/secondary_unit]&lt;br /&gt;
         [/fire_event]&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set dialogue for a unit ====&lt;br /&gt;
&lt;br /&gt;
 #define UNIT_MESSAGE MESSAGE RESPONSE EVENT&lt;br /&gt;
     # Defines dialogue for a unit. When the main character (see the&lt;br /&gt;
     # SET_MAIN_CHARACTER macro) triggers interaction with this unit, the&lt;br /&gt;
     # message MESSAGE will be displayed, and the triggering unit will respond&lt;br /&gt;
     # with RESPONSE, after which EVENT will be fired with the triggering unit&lt;br /&gt;
     # as the primary unit and this unit as the secondary unit. Note that this&lt;br /&gt;
     # macro should be placed within a [variables] tag inside of a [unit] tag.&lt;br /&gt;
     [dialogue]&lt;br /&gt;
         type=message&lt;br /&gt;
         message={MESSAGE}&lt;br /&gt;
         response={RESPONSE}&lt;br /&gt;
         event={EVENT}&lt;br /&gt;
     [/dialogue]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNIT_MESSAGE FILTER MESSAGE RESPONSE EVENT&lt;br /&gt;
     # Works just like the UNIT_MESSAGE macro, except that it takes a FILTER&lt;br /&gt;
     # argument and applies the message to the all units matching the filter.&lt;br /&gt;
     # UNIT_MESSAGE can only be used during unit creation, and must be placed&lt;br /&gt;
     # within a [variables] tag. SET_UNIT_MESSAGE, on the other hand, can be&lt;br /&gt;
     # used anywhere.&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.type) (&amp;quot;message&amp;quot;)}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.message) ({MESSAGE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.response) ({RESPONSE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event) ({EVENT})}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Set dialogue for a unit, including a two-option question ====&lt;br /&gt;
&lt;br /&gt;
 #define UNIT_OPTION MESSAGE OPTION1 OPTION2 EVENT1 EVENT2&lt;br /&gt;
     # Defines dialogue for a unit that includes a choice to present to the&lt;br /&gt;
     # player. When the main character (see the SET_MAIN_CHARACTER macro)&lt;br /&gt;
     # triggers interaction with this unit, the message MESSAGE will be&lt;br /&gt;
     # displayed, along with the options OPTION1 and OPTION2. Depending on which&lt;br /&gt;
     # option the player chooses, either EVENT1 or EVENT2 will then be fired&lt;br /&gt;
     # with the triggering unit as the primary unit and this unit as the&lt;br /&gt;
     # secondary unit. Note that this macro should be placed within a&lt;br /&gt;
     # [variables] tag inside of a [unit] tag.&lt;br /&gt;
     [dialogue]&lt;br /&gt;
         type=option&lt;br /&gt;
         message={MESSAGE}&lt;br /&gt;
         option1={OPTION1}&lt;br /&gt;
         option2={OPTION2}&lt;br /&gt;
         event1={EVENT1}&lt;br /&gt;
         event2={EVENT2}&lt;br /&gt;
     [/dialogue]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #define SET_UNIT_OPTION FILTER MESSAGE OPTION1 OPTION2 EVENT1 EVENT2&lt;br /&gt;
     # Works just like the UNIT_OPTION macro, except that it takes a FILTER&lt;br /&gt;
     # argument and applies the message to all units matching the filter.&lt;br /&gt;
     # UNIT_OPTION can only be used during unit creation, and must be placed&lt;br /&gt;
     # within a [variables] tag. SET_UNIT_OPTION, on the other hand, can be&lt;br /&gt;
     # used anywhere.&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.type) (&amp;quot;option&amp;quot;)}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.message) ({MESSAGE})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.option1) ({OPTION1})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.option2) ({OPTION2})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event1) ({EVENT1})}&lt;br /&gt;
     {SET_PROPERTY ({FILTER}) (variables.dialogue.event2) ({EVENT2})}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Clear unit dialogue ====&lt;br /&gt;
&lt;br /&gt;
 #define CLEAR_UNIT_DIALOGUE FILTER&lt;br /&gt;
     # Removes any dialogue that is assigned to units matching the given filter,&lt;br /&gt;
     # including both messages and options.&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.type)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.message)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.response)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.option1)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.option2)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event1)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue.event2)}&lt;br /&gt;
     {CLEAR_PROPERTY ({FILTER}) (variables.dialogue)}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Assign a role to a recalled unit with various back-ups ====&lt;br /&gt;
&lt;br /&gt;
 #define FILL_ROLE_RECALL SIDE ROLE FILTER BACKUP_FILTER TYPE X Y&lt;br /&gt;
     # Recalls the first unit on side SIDE matching FILTER and assigns it the&lt;br /&gt;
     # role ROLE. If no such unit exists, it tries to find a unit that matches&lt;br /&gt;
     # the given BACKUP_FILTER on SIDE's recall list, and if it can't, it tries&lt;br /&gt;
     # to find any unit on side SIDE's recall list. If SIDE has no units on its&lt;br /&gt;
     # recall list, a unit is spawned of type TYPE to fill the role. If the role&lt;br /&gt;
     # is already filled, this does nothing. If the given location is&lt;br /&gt;
     # unavailable, the nearest empty location will be used.&lt;br /&gt;
     [if]&lt;br /&gt;
         [have_unit]&lt;br /&gt;
             side={SIDE}&lt;br /&gt;
             x,y={X},{Y}&lt;br /&gt;
         [/have_unit]&lt;br /&gt;
         [then]&lt;br /&gt;
             {FIND_NEARBY ([not]&lt;br /&gt;
                               [filter]&lt;br /&gt;
                               [/filter]&lt;br /&gt;
                           [/not]) {X} {Y} 30}&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_x&lt;br /&gt;
                 to_variable=nearby_locations[0].x&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_y&lt;br /&gt;
                 to_variable=nearby_locations[0].y&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [clear_variable]&lt;br /&gt;
                 name=nearby_locations&lt;br /&gt;
             [/clear_variable]&lt;br /&gt;
         [/then]&lt;br /&gt;
         [else]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_x&lt;br /&gt;
                 value={X}&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=fill_role_recall_target_y&lt;br /&gt;
                 value={Y}&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
         [/else]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 {BACKUP_FILTER}&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 {BACKUP_FILTER}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [recall]&lt;br /&gt;
                 show=no&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/recall]&lt;br /&gt;
             [role]&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
             [/role]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [if]&lt;br /&gt;
         [not]&lt;br /&gt;
             [have_unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/have_unit]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [then]&lt;br /&gt;
             [unit]&lt;br /&gt;
                 side={SIDE}&lt;br /&gt;
                 type={TYPE}&lt;br /&gt;
                 x,y=$fill_role_recall_target_x,$fill_role_recall_target_y&lt;br /&gt;
                 generate_name=yes&lt;br /&gt;
                 random_gender=yes&lt;br /&gt;
                 random_traits=yes&lt;br /&gt;
                 role={ROLE}&lt;br /&gt;
             [/unit]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=fill_role_recall_target_x,fill_role_recall_target_y&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==== Assign a group of roles to several units with backups ====&lt;br /&gt;
&lt;br /&gt;
 #define ASSIGN_ROLES ROLES DESIRED_ROLE_FILTER BACKUP_ROLE_FILTER&lt;br /&gt;
     # Fills several roles at once from the pool of units specified by&lt;br /&gt;
     # DESIRED_ROLE_FILTER, using units that match BACKUP_ROLE_FILTER if&lt;br /&gt;
     # necessary. ROLES should be an ordered, comma-separated list of roles to&lt;br /&gt;
     # fill. If not enough units match among both the DESIRED and BACKUP&lt;br /&gt;
     # filters, not all of the roles will be assigned. The main advantage of&lt;br /&gt;
     # ASSIGN_ROLES over [role] tags is that you don't have to use a bunch of&lt;br /&gt;
     # [not] role= [/not] statements to ensure that each unit gets one role.&lt;br /&gt;
     [set_variables]&lt;br /&gt;
         name=roles_to_assign&lt;br /&gt;
         [split]&lt;br /&gt;
             list={ROLES}&lt;br /&gt;
             key=value&lt;br /&gt;
             separator=,&lt;br /&gt;
             remove_empty=yes&lt;br /&gt;
         [/split]&lt;br /&gt;
     [/set_variables]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=role_assignment_index&lt;br /&gt;
         value=0&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=done_assigning_roles&lt;br /&gt;
         value=no&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         variable=primary_role_candidates&lt;br /&gt;
         [filter]&lt;br /&gt;
             {DESIRED_ROLE_FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=role_candidate_index&lt;br /&gt;
         value=0&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [while]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=done_assigning_roles&lt;br /&gt;
             boolean_equals=no&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [and]&lt;br /&gt;
             [variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 less_than=$primary_role_candidates.length&lt;br /&gt;
             [/variable]&lt;br /&gt;
         [/and]&lt;br /&gt;
         [do]&lt;br /&gt;
             # Assign a role:&lt;br /&gt;
             [role]&lt;br /&gt;
                 role=$roles_to_assign[$($role_assignment_index)].value&lt;br /&gt;
                 id=$primary_role_candidates[$($role_candidate_index)].id&lt;br /&gt;
             [/role]&lt;br /&gt;
             # Increment loop variables:&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_assignment_index&lt;br /&gt;
                 add=1&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 add=1&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             # Check the break condition:&lt;br /&gt;
             [if]&lt;br /&gt;
                 [not]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=role_assignment_index&lt;br /&gt;
                         less_than=$roles_to_assign.length&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/not]&lt;br /&gt;
                 [then]&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=done_assigning_roles&lt;br /&gt;
                         value=yes&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                 [/then]&lt;br /&gt;
             [/if]&lt;br /&gt;
         [/do]&lt;br /&gt;
     [/while]&lt;br /&gt;
     # Use backups if necessary:&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=done_assigning_roles&lt;br /&gt;
             boolean_equals=no&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [store_unit]&lt;br /&gt;
                 variable=secondary_role_candidates&lt;br /&gt;
                 [filter]&lt;br /&gt;
                     {BACKUP_ROLE_FILTER}&lt;br /&gt;
                 [/filter]&lt;br /&gt;
             [/store_unit]&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=role_candidate_index&lt;br /&gt;
                 value=0&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
             [while]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=done_assigning_roles&lt;br /&gt;
                     boolean_equals=no&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [and]&lt;br /&gt;
                     [variable]&lt;br /&gt;
                         name=role_candidate_index&lt;br /&gt;
                         less_than=$secondary_role_candidates.length&lt;br /&gt;
                     [/variable]&lt;br /&gt;
                 [/and]&lt;br /&gt;
                 [do]&lt;br /&gt;
                     # Assign a role:&lt;br /&gt;
                     [role]&lt;br /&gt;
                         role=$roles_to_assign[$($role_assignment_index)].value&lt;br /&gt;
                         id=$secondary_role_candidates[$($role_candidate_index)].id&lt;br /&gt;
                     [/role]&lt;br /&gt;
                     # Increment loop variables:&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=role_assignment_index&lt;br /&gt;
                         add=1&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                     [set_variable]&lt;br /&gt;
                         name=role_candidate_index&lt;br /&gt;
                         add=1&lt;br /&gt;
                     [/set_variable]&lt;br /&gt;
                     # Check the break condition:&lt;br /&gt;
                     [if]&lt;br /&gt;
                         [not]&lt;br /&gt;
                             [variable]&lt;br /&gt;
                                 name=role_assignment_index&lt;br /&gt;
                                 less_than=$roles_to_assign.length&lt;br /&gt;
                             [/variable]&lt;br /&gt;
                         [/not]&lt;br /&gt;
                         [then]&lt;br /&gt;
                             [set_variable]&lt;br /&gt;
                                 name=done_assigning_roles&lt;br /&gt;
                                 value=yes&lt;br /&gt;
                             [/set_variable]&lt;br /&gt;
                         [/then]&lt;br /&gt;
                     [/if]&lt;br /&gt;
                 [/do]&lt;br /&gt;
             [/while]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=roles_to_assign, role_assignment_index, primary_role_candidates, secondary_role_candidates, role_candidate_index, done_assigning_roles&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32504</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32504"/>
		<updated>2009-09-29T06:28:00Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* RPG Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
=== RPG Tools ===&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY from [[WML Utilities]]), move + exit to recall list, define character dialogue and a &amp;quot;main character&amp;quot;, grant unlimited moves.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32503</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32503"/>
		<updated>2009-09-29T06:27:35Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Campaign Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
=== RPG Tools ===&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY), move + exit to recall list, define character dialogue and a &amp;quot;main character&amp;quot;, grant unlimited moves.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32501</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32501"/>
		<updated>2009-09-29T06:19:51Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Logic Structure Macros */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Map Tools ====&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_Utilities&amp;diff=32500</id>
		<title>WML Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_Utilities&amp;diff=32500"/>
		<updated>2009-09-29T06:19:14Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Added search macro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Filter by Terrain ==&lt;br /&gt;
&lt;br /&gt;
 # Check whethers or not the terrain in the given coordinates is of the given&lt;br /&gt;
 # type or types. Filtering by terrain isn't possible directly.&lt;br /&gt;
 #&lt;br /&gt;
 # You can use it for example like this:&lt;br /&gt;
 #&lt;br /&gt;
 # [event]&lt;br /&gt;
 #     name=moveto&lt;br /&gt;
 #     first_time_only=no&lt;br /&gt;
 #&lt;br /&gt;
 #     {IF_TERRAIN $x1 $y1 Gg,Gs^Fp,Mm (&lt;br /&gt;
 #         [then]&lt;br /&gt;
 #             {DEBUG_MSG &amp;quot;Stepped on grassland, forest or mountains!&amp;quot;}&lt;br /&gt;
 #         [/then]&lt;br /&gt;
 #     )}&lt;br /&gt;
 # [/event]&amp;lt;br&amp;gt;&lt;br /&gt;
 #define IF_TERRAIN X Y TERRAIN CONTENTS&lt;br /&gt;
     [store_locations]&lt;br /&gt;
         x={X}&lt;br /&gt;
         y={Y}&lt;br /&gt;
         terrain={TERRAIN}&lt;br /&gt;
         variable=IF_TERRAIN_temp&lt;br /&gt;
     [/store_locations]&amp;lt;br&amp;gt; &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=IF_TERRAIN_temp.length&lt;br /&gt;
             not_equals=0&lt;br /&gt;
         [/variable]&amp;lt;br&amp;gt; &lt;br /&gt;
         {CONTENTS}&lt;br /&gt;
     [/if]&amp;lt;br&amp;gt; &lt;br /&gt;
     {CLEAR_VARIABLE IF_TERRAIN_temp}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
==Iterate==&lt;br /&gt;
&lt;br /&gt;
 # You can iterate through a range of numbers with this macro. The CONTENTS&lt;br /&gt;
 # are repeated with every iteration, and you can use the VAR variable to&lt;br /&gt;
 # insert the number of the current step into each iteration. Note that&lt;br /&gt;
 # when using this, you must iterate from a smaller number to the bigger&lt;br /&gt;
 # number, because the increment is always 1.&lt;br /&gt;
 #&lt;br /&gt;
 # Example that spawns a row of skeletons into the coordinates (4,5),&lt;br /&gt;
 # (5,5), (6,5), (7,5), (8,5) and (9,5):&lt;br /&gt;
 #&lt;br /&gt;
 # {ITERATE 4 9 i (&lt;br /&gt;
 #     [unit]&lt;br /&gt;
 #         type=Skeleton&lt;br /&gt;
 #         x=$i&lt;br /&gt;
 #         y=5&lt;br /&gt;
 #     [/unit]&lt;br /&gt;
 # )}&amp;lt;br&amp;gt;&lt;br /&gt;
 #define ITERATE FROM TO VAR CONTENTS&lt;br /&gt;
     {VARIABLE {VAR} {FROM}}&amp;lt;br&amp;gt;&lt;br /&gt;
     [while]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name={VAR}&lt;br /&gt;
             less_than_equal_to={TO}&lt;br /&gt;
         [/variable]&amp;lt;br&amp;gt;&lt;br /&gt;
         [do]&lt;br /&gt;
             {CONTENTS}&amp;lt;br&amp;gt;&lt;br /&gt;
             {VARIABLE_OP {VAR} add 1}&lt;br /&gt;
         [/do]&lt;br /&gt;
     [/while]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== Adding unit overlays with a filter instead of (x,y) ==&lt;br /&gt;
&lt;br /&gt;
 # UNIT_OVERLAY adds an overlay to a unit, taking in a standard filter&lt;br /&gt;
 #&lt;br /&gt;
 # Example that gives all spearmen a book:&lt;br /&gt;
 # {UNIT_OVERLAY type=Spearman items/book1.png}&lt;br /&gt;
 &lt;br /&gt;
 #define UNIT_OVERLAY FILTER IMG&lt;br /&gt;
     [store_unit]&lt;br /&gt;
         [filter]&lt;br /&gt;
             {FILTER}&lt;br /&gt;
         [/filter]&lt;br /&gt;
         variable=UNIT_OVERLAY_store&lt;br /&gt;
         kill=no&lt;br /&gt;
     [/store_unit]&lt;br /&gt;
     {FOREACH UNIT_OVERLAY_store UNIT_OVERLAY_i}&lt;br /&gt;
 	{VARIABLE_OP UNIT_OVERLAY_tempx format $UNIT_OVERLAY_store[$UNIT_OVERLAY_i].x}&lt;br /&gt;
 	{VARIABLE_OP UNIT_OVERLAY_tempy format $UNIT_OVERLAY_store[$UNIT_OVERLAY_i].y}&lt;br /&gt;
         [unit_overlay]&lt;br /&gt;
             x=$UNIT_OVERLAY_tempx&lt;br /&gt;
             y=$UNIT_OVERLAY_tempy&lt;br /&gt;
 		image={IMG}&lt;br /&gt;
         [/unit_overlay]&lt;br /&gt;
     {NEXT UNIT_OVERLAY_i}&lt;br /&gt;
     {CLEAR_VARIABLE UNIT_OVERLAY_store}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== Determining opposite coordinates ==&lt;br /&gt;
&lt;br /&gt;
 # Using this, you can determine the coordinates on the &amp;quot;opposite side&amp;quot; of a&lt;br /&gt;
 # central hex, relative to another hex adjacent to it. What this really means&lt;br /&gt;
 # is illustrated below:&lt;br /&gt;
 #       __            __            __&lt;br /&gt;
 #    __/  \__      __/2 \__      __/  \__&lt;br /&gt;
 #   /  \__/1 \    /  \__/  \    /2 \__/  \    C: central point&lt;br /&gt;
 #   \__/C \__/    \__/C \__/    \__/C \__/    1: the hex to &amp;quot;mirror&amp;quot;&lt;br /&gt;
 #   /2 \__/  \    /  \__/  \    /  \__/1 \    2: the result&lt;br /&gt;
 #   \__/  \__/    \__/1 \__/    \__/  \__/&lt;br /&gt;
 #      \__/          \__/          \__/&lt;br /&gt;
 #&lt;br /&gt;
 # The coordinates of the central point are given in {CENTER_X} and {CENTER_Y},&lt;br /&gt;
 # and the coordinates of hex 1 in {X} and {Y}. The coordinates of hex 2 are&lt;br /&gt;
 # then stored in {VAR}, which will have member variables x and y.&lt;br /&gt;
 #&lt;br /&gt;
 # Note that this uses the IF macro given earlier on this page.&amp;lt;br&amp;gt;&lt;br /&gt;
 #define OPPOSITE_SIDE CENTER_X CENTER_Y X Y VAR&lt;br /&gt;
     {VARIABLE x_odd {X}}&amp;lt;br&amp;gt;&lt;br /&gt;
     {VARIABLE_OP x_odd modulo 2}&amp;lt;br&amp;gt;&lt;br /&gt;
     {VARIABLE c_x {CENTER_X}}&lt;br /&gt;
     {VARIABLE c_y {CENTER_Y}}&lt;br /&gt;
     {VARIABLE s_x {X}}&lt;br /&gt;
     {VARIABLE s_y {Y}}&amp;lt;br&amp;gt;&lt;br /&gt;
     {VARIABLE result_x {CENTER_X}}&lt;br /&gt;
     {VARIABLE result_y {CENTER_Y}}&amp;lt;br&amp;gt;&lt;br /&gt;
     {IF_VAR s_x greater_than $c_x (&lt;br /&gt;
         [then]&lt;br /&gt;
             {VARIABLE_OP result_x add -1}&lt;br /&gt;
         [/then]&lt;br /&gt;
     )}&amp;lt;br&amp;gt;&lt;br /&gt;
     {IF_VAR s_x less_than $c_x (&lt;br /&gt;
         [then]&lt;br /&gt;
             {VARIABLE_OP result_x add 1}&lt;br /&gt;
         [/then]&lt;br /&gt;
     )}&amp;lt;br&amp;gt;&lt;br /&gt;
     {IF_VAR s_x equals $c_x (&lt;br /&gt;
         [then]&lt;br /&gt;
             {IF_VAR s_y less_than $c_y (&lt;br /&gt;
                 [then]&lt;br /&gt;
                     {VARIABLE_OP result_y add 1}&lt;br /&gt;
                 [/then]&lt;br /&gt;
             )}&amp;lt;br&amp;gt;&lt;br /&gt;
             {IF_VAR s_y greater_than $c_y (&lt;br /&gt;
                 [then]&lt;br /&gt;
                     {VARIABLE_OP result_y add -1}&lt;br /&gt;
                 [/then]&lt;br /&gt;
             )}&lt;br /&gt;
         [/then]&lt;br /&gt;
     )}&amp;lt;br&amp;gt;&lt;br /&gt;
     {IF_VAR x_odd equals 1 (&lt;br /&gt;
         [then]&lt;br /&gt;
             {IF_VAR s_y equals $c_y (&lt;br /&gt;
                 [then]&lt;br /&gt;
                     {VARIABLE_OP result_y add 1}&lt;br /&gt;
                 [/then]&lt;br /&gt;
             )}&lt;br /&gt;
         [/then]&amp;lt;br&amp;gt;&lt;br /&gt;
         [else]&lt;br /&gt;
             {IF_VAR s_y equals $c_y (&lt;br /&gt;
                 [then]&lt;br /&gt;
                     {VARIABLE_OP result_y add -1}&lt;br /&gt;
                 [/then]&lt;br /&gt;
             )}&lt;br /&gt;
         [/else]&lt;br /&gt;
     )}&lt;br /&gt;
     {VARIABLE {VAR}.x $result_x}&lt;br /&gt;
     {VARIABLE {VAR}.y $result_y}&amp;lt;br&amp;gt;&lt;br /&gt;
     {CLEAR_VARIABLE c_x}&lt;br /&gt;
     {CLEAR_VARIABLE c_y}&lt;br /&gt;
     {CLEAR_VARIABLE s_x}&lt;br /&gt;
     {CLEAR_VARIABLE s_y}&lt;br /&gt;
     {CLEAR_VARIABLE result_x}&lt;br /&gt;
     {CLEAR_VARIABLE result_y}&lt;br /&gt;
     {CLEAR_VARIABLE x_odd}&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== Find nearest hex(es) ==&lt;br /&gt;
&lt;br /&gt;
 #define FIND_NEARBY FILTER X Y LIMIT&lt;br /&gt;
     # Does a search for a nearby location that matches the given filter.&lt;br /&gt;
     # Basically just looks for such a location with increasing radius until it&lt;br /&gt;
     # finds at least one. This is sadly inefficient, but implementing BFS in&lt;br /&gt;
     # WML is... difficult. Once LIMIT is reached, the entire map is searched.&lt;br /&gt;
     # This macro creates the 'nearby_locations' and 'nearby_distance'&lt;br /&gt;
     # variables, which can be used to access a list of locations found and the&lt;br /&gt;
     # distance to those locations, respectively. They should eventually be&lt;br /&gt;
     # cleared, which can be accomplished using the CLEANUP_SEARCH macro.&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=nearby_locations&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
         name=nearby_distance&lt;br /&gt;
         value=0&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [while]&lt;br /&gt;
         [not]&lt;br /&gt;
             [variable]&lt;br /&gt;
                 name=nearby_locations.length&lt;br /&gt;
                 greater_than=0&lt;br /&gt;
             [/variable]&lt;br /&gt;
         [/not]&lt;br /&gt;
         [and]&lt;br /&gt;
             [variable]&lt;br /&gt;
                 name=nearby_distance&lt;br /&gt;
                 less_than={LIMIT}&lt;br /&gt;
             [/variable]&lt;br /&gt;
         [/and]&lt;br /&gt;
         [do]&lt;br /&gt;
             {DEBUG &amp;quot;Searching depth $nearby_distance around ({X}, {Y})...&amp;quot;}&lt;br /&gt;
             [store_locations]&lt;br /&gt;
                 variable=nearby_locations&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
                 [and]&lt;br /&gt;
                     x,y={X},{Y}&lt;br /&gt;
                     radius=$nearby_distance&lt;br /&gt;
                 [/and]&lt;br /&gt;
             [/store_locations]&lt;br /&gt;
             {DEBUG &amp;quot;...found $nearby_locations.length locations.&amp;quot;}&lt;br /&gt;
             [set_variable]&lt;br /&gt;
                 name=nearby_distance&lt;br /&gt;
                 add=1&lt;br /&gt;
             [/set_variable]&lt;br /&gt;
         [/do]&lt;br /&gt;
     [/while]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=nearby_locations.length&lt;br /&gt;
             equals=0&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [store_locations]&lt;br /&gt;
                 variable=nearby_locations&lt;br /&gt;
                 {FILTER}&lt;br /&gt;
             [/store_locations]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CLEANUP_SEARCH&lt;br /&gt;
     # Clears variables involved in searching (the FIND_NEARBY macro). Put this&lt;br /&gt;
     # in your name=victory,defeat tag to clean up if you use FIND_NEARBY within&lt;br /&gt;
     # a scenario.&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=nearby_locations, nearby_distance&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UsefulWMLFragments]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32499</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32499"/>
		<updated>2009-09-29T06:17:21Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Music Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates.&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
==== Music Tools ====&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Map Tools ====&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_Musical_Moods&amp;diff=32498</id>
		<title>WML Musical Moods</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_Musical_Moods&amp;diff=32498"/>
		<updated>2009-09-29T06:16:38Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Added the moods macros.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Macros for grouping existing music (as of 1.7.x) and for changing playlists or playing random songs immediately.&lt;br /&gt;
&lt;br /&gt;
 #define MOOD_BATTLE&lt;br /&gt;
   [music]&lt;br /&gt;
     name=legends_of_the_north.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=battle.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=frantic.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=suspense.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_dangerous_symphony.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=casualties_of_war.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_EPIC&lt;br /&gt;
   [music]&lt;br /&gt;
     name=vengeful.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=frantic.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_city_falls.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=siege_of_laurelmor.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_CALM&lt;br /&gt;
   [music]&lt;br /&gt;
     name=traveling_minstrels.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elf-land.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=love_theme.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=sad.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=wanderer.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=journeys_end.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_HUSHED&lt;br /&gt;
   [music]&lt;br /&gt;
     name=revelation.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=underground.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_deep_path.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_SAD&lt;br /&gt;
   [music]&lt;br /&gt;
     name=the_king_is_dead.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elvish-theme.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=transience.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_DOOM&lt;br /&gt;
   [music]&lt;br /&gt;
     name=knalgan_theme.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=northerners.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define MOOD_NORMAL&lt;br /&gt;
   [music]&lt;br /&gt;
     name=breaking_the_chains.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=heroes_rite.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=knolls.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=loyalists.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=nunc_dimittis.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=into_the_shadows.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
   [music]&lt;br /&gt;
     name=northern_mountains.ogg&lt;br /&gt;
     append=yes&lt;br /&gt;
     ms_before=8000&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define SHHHH&lt;br /&gt;
   [music]&lt;br /&gt;
     name=silence.ogg&lt;br /&gt;
     append=no&lt;br /&gt;
     ms_before=0&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_EPIC&lt;br /&gt;
   {RANDOM 0,1,2,3,4}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=vengeful.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=frantic.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_city_falls.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=3&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_dangerous_symphony.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=4&lt;br /&gt;
       [music]&lt;br /&gt;
         name=siege_of_laurelmor.ogg&lt;br /&gt;
         append=yes&lt;br /&gt;
         ms_before=8000&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_DOOM&lt;br /&gt;
   {RANDOM 0,1}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=knalgan_theme.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=northerners.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_ELVES&lt;br /&gt;
   [music]&lt;br /&gt;
     name=elf-land.ogg&lt;br /&gt;
     play_once=yes&lt;br /&gt;
     immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_SILENCE&lt;br /&gt;
   [music]&lt;br /&gt;
     name=silence.ogg&lt;br /&gt;
     play_once=yes&lt;br /&gt;
     immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_BATTLE&lt;br /&gt;
   {RANDOM 0,1,2,3,4}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=legends_of_the_north.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=vengeful.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=frantic.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=3&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_dangerous_symphony.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=4&lt;br /&gt;
       [music]&lt;br /&gt;
         name=casualties_of_war.ogg&lt;br /&gt;
         append=yes&lt;br /&gt;
         ms_before=8000&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_SAD&lt;br /&gt;
   {RANDOM 0,1,2}&lt;br /&gt;
   [switch]&lt;br /&gt;
     variable=random&lt;br /&gt;
     [case]&lt;br /&gt;
       value=0&lt;br /&gt;
       [music]&lt;br /&gt;
         name=elvish-theme.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=1&lt;br /&gt;
       [music]&lt;br /&gt;
         name=the_king_is_dead.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
       value=2&lt;br /&gt;
       [music]&lt;br /&gt;
         name=transience.ogg&lt;br /&gt;
         play_once=yes&lt;br /&gt;
         immediate=yes&lt;br /&gt;
       [/music]&lt;br /&gt;
     [/case]&lt;br /&gt;
   [/switch]&lt;br /&gt;
   [clear_variable]&lt;br /&gt;
     name=random&lt;br /&gt;
   [/clear_variable]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_DEFEAT&lt;br /&gt;
   [music]&lt;br /&gt;
       name=defeat.ogg&lt;br /&gt;
       play_once=yes&lt;br /&gt;
       immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define CUE_VICTORY&lt;br /&gt;
   [music]&lt;br /&gt;
       name=victory2.ogg&lt;br /&gt;
       play_once=yes&lt;br /&gt;
       immediate=yes&lt;br /&gt;
   [/music]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 #define VICTORY_AND_DEFEAT_MUSIC&lt;br /&gt;
   [event]&lt;br /&gt;
       name=victory&lt;br /&gt;
       {SHHHH}&lt;br /&gt;
       {CUE_VICTORY}&lt;br /&gt;
   [/event]&lt;br /&gt;
   [event]&lt;br /&gt;
       name=defeat&lt;br /&gt;
       {SHHHH}&lt;br /&gt;
       {CUE_DEFEAT}&lt;br /&gt;
   [/event]&lt;br /&gt;
 #enddef&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32497</id>
		<title>UsefulWMLFragments</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UsefulWMLFragments&amp;diff=32497"/>
		<updated>2009-09-29T06:13:34Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Campaign Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Useful WML Fragments ==&lt;br /&gt;
&lt;br /&gt;
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.&lt;br /&gt;
&lt;br /&gt;
Some things '''not''' to do here:&lt;br /&gt;
* Don't add macros that duplicate things in [http://www.wesnoth.org/macro-reference.xhtml the core macro library].&lt;br /&gt;
* Don't add macros that are trivial syntax shortcuts.&lt;br /&gt;
* Don't add macros that generate unbalanced syntax fragments.&lt;br /&gt;
&lt;br /&gt;
Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.&lt;br /&gt;
&lt;br /&gt;
=== Logic Structure Macros ===&lt;br /&gt;
*[[WML Utilities]]: Macros to assist other macros. Filter by Terrain. Iterate. Overlay with Filter. Determine Opposite Coordinates.&lt;br /&gt;
&lt;br /&gt;
=== Campaign Tools ===&lt;br /&gt;
*[[Victory Conditions]]: Number of Villages, Amount of Gold. Suitable for multiplayer scenarios.&lt;br /&gt;
&lt;br /&gt;
=== Music Tools ===&lt;br /&gt;
*[[WML Musical Moods]]: Groups the Wesnoth music (as of 1.7.x) into &amp;quot;moods&amp;quot; and defines macros for playing randomly songs from these pools and for quickly switching music.&lt;br /&gt;
&lt;br /&gt;
==== Map Tools ====&lt;br /&gt;
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.&lt;br /&gt;
&lt;br /&gt;
==== Unit Tools ====&lt;br /&gt;
*[[WML Abilities]]: Knockback. Charm. Bloodlust. Abilities cannot currently be incorporated in the unit type definitions themselves, but must be included in the scenario file.&lt;br /&gt;
*[[WML Buildings]]: Generic Buildings, Light House/Dark Tower, Wishing Well #1, Wishing Well #2.&lt;br /&gt;
&lt;br /&gt;
==== Item Tools ====&lt;br /&gt;
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units.&lt;br /&gt;
&lt;br /&gt;
=== Advanced WML ===&lt;br /&gt;
*[[Advanced WML]]:  Branch on Village Type. Recruit from a Ship. Point Rotation Scheme. Store Reachable Locations.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
*[[WML Templates]]: Generic campaign, scenario and unit templates. (updated)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: UsefulWMLFragments|*]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=32496</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=32496"/>
		<updated>2009-09-29T05:31:59Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* The [specials] tag */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
==  Abilities and their effects ==&lt;br /&gt;
&lt;br /&gt;
There are two types of abilities: ones that apply to units (called ''abilities'') and ones that only apply when using a particular attack (called ''specials'' or ''weapon specials'').  A unit may have multiple abilities and an attack can have multiple specials, but by convention only one weapon special should be assigned to any given attack.&lt;br /&gt;
&lt;br /&gt;
== The ''[abilities]'' tag ==&lt;br /&gt;
&lt;br /&gt;
The following tags are used to describe an ability in WML:&lt;br /&gt;
&lt;br /&gt;
* '''[heals]''': modifies the hitpoints of a unit at the beginning the healer's turn&lt;br /&gt;
* '''[regenerate]''': modifies the hitpoints of a unit at the beginning of the unit's turn&lt;br /&gt;
* '''[resistance]''': modifies the resistance of a unit to damage&lt;br /&gt;
* '''[leadership]''': modifies the damage of a unit&lt;br /&gt;
* '''[skirmisher]''': negates enemy zones of control&lt;br /&gt;
* '''[illuminates]''': modifies the time of day adjacent to the affected units&lt;br /&gt;
* '''[teleport]''': allows the unit to teleport&lt;br /&gt;
* '''[hides]''': renders the unit invisible to enemies&lt;br /&gt;
Any other name is valid (for example '''[dummy]'''), but will result in an ability that does nothing but report it's there. These tags still use the same common keys and tags as every other ability. '''Note:''' a dummy ability must have an id for the name and description to display.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every ability ===&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of the ability.&lt;br /&gt;
* '''name_inactive''': the name of the ability when inactive.&lt;br /&gt;
* '''description''': the description of the ability.&lt;br /&gt;
* '''description_inactive''': the description of the ability when inactive.&lt;br /&gt;
* '''affect_self''': if equal to 'yes', the ability will affect the unit that has it.&lt;br /&gt;
* '''affect_allies''': if equal to 'yes', the ability will affect allies in the specified adjacent hexes.&lt;br /&gt;
* '''affect_enemies''': if equal to 'yes', the ability will affect enemies in the specified adjacent hexes.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this ability will be cumulative with the base value for this ability.&lt;br /&gt;
* '''id''': this ability will not be cumulative with other abilities using this id. Must be present if cumulative is anything other than 'yes'.&lt;br /&gt;
* '''[adjacent_description]''': contains all four of the above keys, which are used when an adjacent unit receives the ability.&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] If the unit owning the ability does not match this filter, the ability will be inactive.&lt;br /&gt;
* '''[affect_adjacent]''': each adjacent unit that does not match this filter will not receive its effects.&lt;br /&gt;
** '''adjacent''': a comma seperated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''.&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_self]''': if the owner of the ability does not match this filter, it will not receive the effects of the ability.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', etc. If several keys are used all have to match.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[heals]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': can be one of ''slowed'',''cured''.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[regenerate]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': can be one of ''slowed'',''cured''.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys and tags used by the ''[resistance]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': set resistance to this value.&lt;br /&gt;
* '''max_value''': maximum resistance value. This value '''must''' be set in order for [resistance] to function.&lt;br /&gt;
* '''add''': adds to resistance.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''apply_to''': a list of damage types; if left out, the ability applies to all types.&lt;br /&gt;
* '''active_on''': one of 'defense' or 'offense'; if left out, the ability is active on both.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[leadership]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the percentage bonus to damage.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[illuminates]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the percentage bonus to lawful units.&lt;br /&gt;
* '''max_value''': the maximum percentage bonus given.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[hides]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''alert''': the displayed text when the unit is discovered. Default &amp;quot;Ambushed!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common abilities ===&lt;br /&gt;
&lt;br /&gt;
* ABILITY_AMBUSH&lt;br /&gt;
* ABILITY_CURES&lt;br /&gt;
* ABILITY_HEALS&lt;br /&gt;
* ABILITY_ILLUMINATES&lt;br /&gt;
* ABILITY_LEADERSHIP_LEVEL_1 to ABILITY_LEADERSHIP_LEVEL_5&lt;br /&gt;
* ABILITY_NIGHTSTALK&lt;br /&gt;
* ABILITY_REGENERATES&lt;br /&gt;
* ABILITY_SKIRMISHER&lt;br /&gt;
* ABILITY_STEADFAST&lt;br /&gt;
* ABILITY_SUBMERGE&lt;br /&gt;
* ABILITY_TELEPORT&lt;br /&gt;
&lt;br /&gt;
== The ''[specials]'' tag ==&lt;br /&gt;
&lt;br /&gt;
The '''[specials]''' tag goes inside the '''[attack]''' tag. It can contain the following tags:&lt;br /&gt;
&lt;br /&gt;
* '''[damage]''': modifies the damage of a weapon&lt;br /&gt;
* '''[attacks]''': modifies the number of attacks of a weapon&lt;br /&gt;
* '''[chance_to_hit]''': modifies the chance to hit of a weapon&lt;br /&gt;
* '''[slow]'''&lt;br /&gt;
* '''[poison]'''&lt;br /&gt;
* '''[stones]''' ('''[petrifies]''' in recent versions.&lt;br /&gt;
* '''[berserk]'''&lt;br /&gt;
* '''[firststrike]'''&lt;br /&gt;
* '''[drains]'''&lt;br /&gt;
* '''[plague]'''&lt;br /&gt;
Any other name is valid, but will result in an special that does nothing but report it's there.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every weapon special ===&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of the special.&lt;br /&gt;
* '''name_inactive''': the name of the special when inactive.&lt;br /&gt;
* '''description''': the description of the special.&lt;br /&gt;
* '''description_inactive''': the description of the special when inactive.&lt;br /&gt;
* '''value''': the value to be used. Applies to '''[damage]''', '''[attacks]''', '''[chance_to_hit]''' and '''[berserk]''' (the maximum number of combat rounds).&lt;br /&gt;
* '''add''' the number to add to the base value.&lt;br /&gt;
* '''multiply''': same as '''value''', except that this multiplies the base value.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''type''': only usable in '''[plague]''', where it defines the unit type to be spawned on kill.&lt;br /&gt;
* '''id''': this ability will not be cumulative with other specials using this id.&lt;br /&gt;
* '''active_on''': one of '''defense''' or '''offense'''; if left out, the special is active on both.&lt;br /&gt;
* '''apply_to''': one of '''self''','''opponent''','''attacker''','''defender''','''both'''. Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': [[StandardUnitFilter]], which takes an extra key '''adjacent''', which is used to specify which adjacent hexes to filter on. '''adjacent''' is a comma seperated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], except that it filters on the locations rather than the units.&lt;br /&gt;
* '''[filter_self]''': the special will only be active if the owner matches this filter.&lt;br /&gt;
** '''[filter_weapon]''': a standard weapon filter.&lt;br /&gt;
* '''[filter_opponent]''': the special will only be active if the opponent matches this [[StandardUnitFilter]].&lt;br /&gt;
** '''[filter_weapon]''': a standard weapon filter.&lt;br /&gt;
* '''[filter_attacker]''': the special will only be active if the attacker matches this filter.&lt;br /&gt;
** '''[filter_weapon]''': a standard weapon filter.&lt;br /&gt;
* '''[filter_defender]''' the special will only be active if the defender matches this filter.&lt;br /&gt;
** '''[filter_weapon]''': a standard weapon filter.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', etc.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
* WEAPON_SPECIAL_BACKSTAB&lt;br /&gt;
* WEAPON_SPECIAL_BERSERK&lt;br /&gt;
* WEAPON_SPECIAL_CHARGE&lt;br /&gt;
* WEAPON_SPECIAL_DRAIN&lt;br /&gt;
* WEAPON_SPECIAL_FIRSTSTRIKE&lt;br /&gt;
* WEAPON_SPECIAL_MAGICAL&lt;br /&gt;
* WEAPON_SPECIAL_MARKSMAN&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE_TYPE TYPE&lt;br /&gt;
* WEAPON_SPECIAL_POISON&lt;br /&gt;
* WEAPON_SPECIAL_SLOW&lt;br /&gt;
* WEAPON_SPECIAL_STONE&lt;br /&gt;
* WEAPON_SPECIAL_SWARM&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[SingleUnitWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=32455</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=32455"/>
		<updated>2009-09-25T23:31:18Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Sighted event warning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== The [event] Tag ==&lt;br /&gt;
&lt;br /&gt;
This tag is a subtag of the [scenario], [unit_type] and [era] tags which is used to describe a set of actions which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer], [tutorial] and [test]), the event only occurs in that scenario. When used in a [unit_type] tag, the event will occur in all scenarios in which a unit of that type appears in (only after such a unit appears during the scenario, however). When used in an [era], the event will occur in any scenario which is played using that era.&lt;br /&gt;
&lt;br /&gt;
This tag has keys and child tags that control when and if the event actions will be triggered. Most important of these is the '''name''' key. Without it, no error will be raised but the event will never fire. Therefore, from a practical standpoint, it can be considered mandatory. All of the others can be used or not and the event actions will fire either way.&lt;br /&gt;
&lt;br /&gt;
=== The 'name' Key (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 name=&amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is '''not''' like a normal 'name' key. ''It is a basic description of when the event will trigger.'' It also has a very large number of predefined values, one of which must be used for the key to be valid.&lt;br /&gt;
&lt;br /&gt;
'''Lexicon side note:''' ''It is not uncommon to refer to these values as the 'trigger' for an event and, furthermore, to call an event by its 'trigger' name. For example, in an event containing '''name=moveto''', a person might refer to the event as a ''''moveto''' event' and/or refer to the ''''moveto''' trigger' in the event or even talk about the 'event trigger' when referring to the '''moveto''' value of the 'name' key in that event. Some or all of this usage can, in fact, be found throughout this page.''&lt;br /&gt;
&lt;br /&gt;
The '''name''' key can accept a list of comma separated values describing when the event will be triggered.*  These values may be either predefined event types or  custom event names not matching any predefined type.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 name=attacker misses,defender misses&lt;br /&gt;
&lt;br /&gt;
''* Note that unless you use [[#first_time_only|first_time_only=no]], the event will fire only once, '''not''' once for each listed type.''&lt;br /&gt;
&lt;br /&gt;
==== Predefined 'name' Key Values ====&lt;br /&gt;
&lt;br /&gt;
All predefined event types are listed here along with a description of when this value will cause the event to be triggered. Any value ''not'' listed here is a custom event name which can be triggered only by a '''[fire_event]''' tag somewhere else. Spaces in event names can be interchanged with underscores (for example, '''name=new turn''' and '''name=new_turn''' are equivalent).&lt;br /&gt;
&lt;br /&gt;
; preload {{DevFeature}}&lt;br /&gt;
: Triggers before a scenario 'prestarts' and when loading a savegame -- before anything is shown on the screen at all. Can be used to set up the [[LuaWML|Lua]] environment: loading libraries, defining helper functions, etc.&amp;lt;br /&amp;gt;'''Note:''' Unlike prestart and start, the preload event '''must be able to fire more than once!''' This is because it is triggered each time a savegame is loaded in addition to the initial time when it loads before the scenario 'prestart'. This means that it is effectively ''mandatory'' to have the [[#first_time_only|first_time_only=no]] key value in a preload event. &lt;br /&gt;
&lt;br /&gt;
; prestart&lt;br /&gt;
: Triggers before a scenario 'starts' -- before anything is shown on the screen at all. Can be used to set up things like village ownership. For things displayed on-screen such as character dialog, use '''start''' instead.&amp;lt;br /&amp;gt;'''Note:''' ''This value makes the [[#first_time_only|first_time_only]] key irrelevant since, by definition, it can only fire once.''&lt;br /&gt;
&lt;br /&gt;
; start&lt;br /&gt;
: Triggers after the map is shown but before the scenario begins -- before players can 'do' anything.&amp;lt;br /&amp;gt;'''Note:''' ''This value makes the [[#first_time_only|first_time_only]] key irrelevant since, by definition, it can only fire once.''&lt;br /&gt;
&lt;br /&gt;
; new turn&lt;br /&gt;
: Triggers whenever the last player ends their turn. See also [[#first_time_only|first_time_only=no]]. When the last player ends their turn, before any events of this type trigger, the value of the WML variable '''turn_number''' is set to the number of the turn that is beginning.&lt;br /&gt;
&lt;br /&gt;
; side turn&lt;br /&gt;
: Triggers when a side is about to start its turn. Before events of this type trigger, the value of the WML variable '''side_number''' is set to the number of the side of the player about to take their turn. This is before any healing takes place for that side, before calculating income, and before restoring unit movement and status.&lt;br /&gt;
&lt;br /&gt;
; ai turn&lt;br /&gt;
: Triggered just before the AI is invoked for a side. This is called after ''side turn'', and thus the WML variable '''side_number''' still holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
; turn refresh&lt;br /&gt;
: Like '''side turn''', triggers just before a side is taking control but '''after''' healing, calculating income, and restoring unit movement and status.&lt;br /&gt;
&lt;br /&gt;
; turn ''X''&lt;br /&gt;
: For ''X'' equals a number greater than 1, this event triggers at the start of turn ''X''. The value of ''X'' cannot be 1 but, if that effect is needed, use '''name=new turn''' and '''first_time_only=yes''' to achieve the equivalent of what '''turn 1''' would do.&lt;br /&gt;
&lt;br /&gt;
; time over&lt;br /&gt;
: Triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
&lt;br /&gt;
; enemies defeated&lt;br /&gt;
: Triggers when all units with '''canrecruit=yes''' (that is, all leaders) not allied with side 1 are killed.&lt;br /&gt;
&lt;br /&gt;
; victory&lt;br /&gt;
: In this scenario, any tag of the form '''[endlevel] result=victory [/endlevel]''' will be automatically preceded by all actions in this tag. It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:n&amp;quot; command. Scenarios where key units are picked up before the victory, or where some action chosen earlier determines which map to advance to, make it hard to quickly test scenarios in a campaign. (See also: [endlevel], [[DirectActionsWML]])&lt;br /&gt;
&lt;br /&gt;
; defeat&lt;br /&gt;
: In this scenario, any tag of the form '''[endlevel] result=defeat [/endlevel]''' will be automatically preceded by all actions in this tag. (See also [endlevel], [[DirectActionsWML]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Filters can be applied to the following event triggers (see [[FilterWML]]; see also below). The actions specified in the event tag will be executed only if the filter returns true. &lt;br /&gt;
These event triggers are all actions by units ('''moveto''', '''attack''') or things that happen to units ('''recruit''', '''advance'''). When one of these events is triggered, the position of the active unit (referred to as the '''primary unit''') is stored in the variables '''x1''' and '''y1''' and the position of any unit that primary unit does something to is stored in the variables '''x2''' and '''y2''' (this unit is referred to as the '''secondary unit''' below). '' These units are also automatically stored in the variables 'unit' and 'second_unit' as if they had been stored using the '''[store_unit]''' tag. see [[SingleUnitWML]]&lt;br /&gt;
&lt;br /&gt;
; moveto&lt;br /&gt;
: Triggers after the primary unit moves. Typically this is used when the primary unit gets to a particular location and a filter for the location of the primary unit is included; remember that this is the location that the primary unit lands on, not the location it started on or any location it travels on.&amp;lt;br /&amp;gt;''An '''[allow_undo]''' tag anywhere within a moveto event will cancel any lack of undo functionality the event would have caused. Note that undo functionality will only move the unit back to its former location; it will not other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.'' {{DevFeature}} $x2 and $y2 refer to the hex the unit came from.&lt;br /&gt;
&lt;br /&gt;
; sighted&lt;br /&gt;
: Triggers when the primary unit becomes visible to the secondary unit in particular after not being visible to the secondary unit's side (so if the secondary unit's side doesn't have shroud or fog, the event never triggers). This happens both when the primary unit moves into view during its turn, and when the secondary unit moves to a location where it can see the primary unit. (This editor hasn't tested whether the event triggers multiple times if the primary unit moves into view of multiple units at once, or if not, which one gets chosen to be the secondary unit here.) (Note: it appears that when a sighted event is triggered because an enemy unit moves into your field of view, the game engine cannot determine which unit (on your side) sees the unit that moved, and so it fires a ''name=sighted'' event without setting ''$second_unit''. This means that, for example, using ''speaker=second_unit'' inside a message tag may fail.) (Double note: it also appears that the sighted event in more recent versions of the game (1.6 and 1.7, maybe?) does not fire on enemy turns. That is, it only fires for units that become visible as a result of the motion of another unit, not for units that move into the vision of an enemy. This event is also buggy in general... it's usually better to use a moveto event with a [filter_vision] tag than to use a sighted event (and note that the combination of the two can achieve something like the old sighted event)).&lt;br /&gt;
&lt;br /&gt;
; attack&lt;br /&gt;
: Triggers when the primary unit attacks the secondary unit.&lt;br /&gt;
&lt;br /&gt;
; attack end&lt;br /&gt;
: Similar to '''attack''', but is triggered ''after'' the fight instead of before. Note that if either unit is killed during the fight, this event triggers before any '''die''' events.&lt;br /&gt;
&lt;br /&gt;
; attacker hits&lt;br /&gt;
: Triggers when the the primary unit (the attacker) hits the secondary unit (the defender). The value of the WML variable '''damage_inflicted''' is set to the number of hitpoints inflicted by the attacker.&lt;br /&gt;
&lt;br /&gt;
; attacker misses&lt;br /&gt;
: Same as ''attacker hits'', but is triggered when the attacker misses.&lt;br /&gt;
&lt;br /&gt;
; defender hits&lt;br /&gt;
: Triggers when the primary unit (the attacker) is hit in retaliation by the secondary unit (the defender). The value of the WML variable '''damage_inflicted''' is set to the number of hitpoints inflicted by the defender.&lt;br /&gt;
&lt;br /&gt;
; defender misses&lt;br /&gt;
: Same as ''defender hits'', but is triggered when the defender misses.&lt;br /&gt;
&lt;br /&gt;
; stone&lt;br /&gt;
: Triggers when the primary unit is hit by an attack with the 'stones' ability (See ''stones'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'stones' ability).&lt;br /&gt;
&lt;br /&gt;
; last breath&lt;br /&gt;
: Triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered.&lt;br /&gt;
&lt;br /&gt;
; die&lt;br /&gt;
: Triggers when the primary unit is killed by the secondary unit.&lt;br /&gt;
&lt;br /&gt;
; capture&lt;br /&gt;
: Triggers when the primary unit captures a village. The village may have been previously neutral, or previously owned by another side; merely moving into your own villages does not constitute a capture.&lt;br /&gt;
&lt;br /&gt;
; recruit&lt;br /&gt;
: Triggers when the primary unit is recruited. (That is, when a unit is recruited it will trigger this event and this event's filter will filter that unit.).&lt;br /&gt;
&lt;br /&gt;
; prerecruit&lt;br /&gt;
: Triggers when the primary unit is recruited but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
; recall&lt;br /&gt;
: Triggers after a unit is recalled.&lt;br /&gt;
&lt;br /&gt;
; prerecall&lt;br /&gt;
: Triggers when a unit is recalled but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
; advance&lt;br /&gt;
: Triggers just before the primary unit is going to advance to another unit.&lt;br /&gt;
&lt;br /&gt;
; post advance&lt;br /&gt;
: Triggers just after the primary unit has advanced to another unit.&lt;br /&gt;
&lt;br /&gt;
; select&lt;br /&gt;
: Triggers when the primary unit is selected. Also triggers when ending a move, as the game keeps the moving unit selected by selecting it again at the end of movement. ''Note: in networked multiplayer, these events are only executed by the client on which the event is triggered, leading to out of sync errors if you modify the game state in the event.''&lt;br /&gt;
&lt;br /&gt;
; menu item X&lt;br /&gt;
: Triggers when a WML menu item with id=''X'' is selected. ''Note: if the menu item has a [command], this event may be executed before or after the command; there is no guarantee.''&lt;br /&gt;
&lt;br /&gt;
=== Custom events.&lt;br /&gt;
&lt;br /&gt;
An event with a custom name may be invoked using the [[InternalActionsWML#.5Bfire_event.5D|[fire_event]]] tag.  Normally you'll use such custom events as named subroutines to be called by events with predefined types.  One common case of this, for example, is that more than one '''sighted''' events might fire the same custom event that changes the scenario objectives.&lt;br /&gt;
&lt;br /&gt;
=== Optional Keys and Tags ===&lt;br /&gt;
&lt;br /&gt;
These keys and tags are more complex ways to filter when an event should trigger:&lt;br /&gt;
&lt;br /&gt;
==== first_time_only ====&lt;br /&gt;
: Whether the event should be removed from the scenario after it is triggered. This key takes a [[ConditionalActionsWML#Boolean_Values|boolean]]; for example:&lt;br /&gt;
: ''first_time_only=yes''&lt;br /&gt;
:: Default behavior if key is omitted. The event will trigger the first time it can and never again.&lt;br /&gt;
: ''first_time_only=no''&lt;br /&gt;
:: The event will every time the criteria are met instead of only the first time.&lt;br /&gt;
&lt;br /&gt;
==== [filter] ====&lt;br /&gt;
: The event will only trigger if the primary unit matches this filter.&lt;br /&gt;
:* [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
&lt;br /&gt;
==== [filter_second] ====&lt;br /&gt;
: Like [filter], but for the secondary unit.&lt;br /&gt;
:* [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
&lt;br /&gt;
==== [filter_attack] ====&lt;br /&gt;
: Can be used to set additional filtering criteria for the primary unit and the secondary unit that are not generally available in a standard unit filter. Can be used in events ''attack'', ''attacker hits'', ''attacker misses'', ''defender hits'', ''defender misses'' and ''attack end''. For more information and other filter keys, see [[FilterWML]].&lt;br /&gt;
:* '''name''': the name of the weapon used.&lt;br /&gt;
:* '''range''': the range of the weapon used.&lt;br /&gt;
:* '''special''': filter on the attack's special power.&lt;br /&gt;
&lt;br /&gt;
==== [filter_second_attack] ====&lt;br /&gt;
: Like [filter_attack], but for the secondary unit.&lt;br /&gt;
:* '''name''': the name of the weapon used.&lt;br /&gt;
:* '''range''': the range of the weapon used.&lt;br /&gt;
:* '''special''': filter on the attack's special power.&lt;br /&gt;
&lt;br /&gt;
==== [event] ====&lt;br /&gt;
: A special case 'action', the [event] tag may be used to create a [[#Nested Events|nested event]].&lt;br /&gt;
&lt;br /&gt;
==== delayed_variable_substitution ====&lt;br /&gt;
: This key is only relevant inside of a [[#Delayed Variable Substitution|nested event]] and controls when variable substitution will occur in those special case actions.&lt;br /&gt;
&lt;br /&gt;
=== Actions triggered by [event] ===&lt;br /&gt;
&lt;br /&gt;
After the trigger conditions have been met, all action tags within the [event] tag are executed in the order they are written in.&lt;br /&gt;
&lt;br /&gt;
There are 3 main types of actions:&lt;br /&gt;
* direct actions ([[DirectActionsWML]]) which have a direct effect on gameplay&lt;br /&gt;
* display actions ([[InterfaceActionsWML]]) which show something to the user&lt;br /&gt;
* internal actions ([[InternalActionsWML]]) which are used by WML internally&lt;br /&gt;
&lt;br /&gt;
Several actions use standard filters to find out which units&lt;br /&gt;
to execute the command on.  These are denoted by the phrases&lt;br /&gt;
&amp;quot;standard unit filter&amp;quot; and &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Nested Events ===&lt;br /&gt;
&lt;br /&gt;
There is one special type of action: event creation.  By placing an '''[event]''' tag inside another '''[event]''' tag, the nested event is spawned (created) when the parent (outer) event is encountered (when executing the contents of the parent event).&lt;br /&gt;
&lt;br /&gt;
([[#Nested Event Example|See Examples]])&lt;br /&gt;
&lt;br /&gt;
==== Delayed Variable Substitution ====&lt;br /&gt;
&lt;br /&gt;
Variable substitution for a nested event can happen either when it is spawned by the parent event or when it is triggered itself. This is controlled with the key '''delayed_variable_substitution''' which is used in the nested event.&lt;br /&gt;
&lt;br /&gt;
If this key is set to ''yes'', the variables in the nested event will contain values from the turn in which the ''nested'' event was triggered. ''This is the default behavior if the key is omitted.'' If set to ''no'', the variables in the nested event are set at the time the ''parent'' event is triggered.&lt;br /&gt;
&lt;br /&gt;
This behavior can be fine tuned with a special syntax when referencing variables. Instead of the normal '''$variable''' syntax, use '''$|variable''' to cause a variable to contain values relevant to the turn in which the nested event was triggered even when '''delayed_variable_substitution''' is set to ''no''. In this way you can have a mix of variables relevant to the parent and nested event trigger times.&lt;br /&gt;
&lt;br /&gt;
([[#Delayed Variable Substitution Example|See Examples]])&lt;br /&gt;
&lt;br /&gt;
== Multiplayer safety ==&lt;br /&gt;
&lt;br /&gt;
It is only possible to use [message] with input and random numbers in events that are synchronous. This limitation is caused because that WML requires data from remote hosts which is only available after network synchronisation.&lt;br /&gt;
&lt;br /&gt;
List of event that are synchronous:&lt;br /&gt;
* moveto&lt;br /&gt;
* sighted &lt;br /&gt;
* attack&lt;br /&gt;
* attack_end &lt;br /&gt;
* attacker hits &lt;br /&gt;
* attacker misses &lt;br /&gt;
* defender hits&lt;br /&gt;
* defender misses &lt;br /&gt;
* stone&lt;br /&gt;
* last breath &lt;br /&gt;
* die&lt;br /&gt;
* capture &lt;br /&gt;
* recruit&lt;br /&gt;
* prerecruit &lt;br /&gt;
* recall &lt;br /&gt;
* prerecall &lt;br /&gt;
* advance &lt;br /&gt;
* post_advance &lt;br /&gt;
* events fired from WML event handler that is synchronous&lt;br /&gt;
* new turn {{DevFeature}}&lt;br /&gt;
* side turn {{DevFeature}}&lt;br /&gt;
* turn X {{DevFeature}}&lt;br /&gt;
* turn refresh {{DevFeature}}&lt;br /&gt;
&lt;br /&gt;
There is also event that are synchronous if fired by engine but they can be fired by wml tags too from non-synchronous event. So when you are using them you must be extra careful. For example [unsotre_unit] unit may trigger unit advancement that will fire ''advance'' and ''post advance'' events.&lt;br /&gt;
&lt;br /&gt;
== A Trap for the Unwary ==&lt;br /&gt;
&lt;br /&gt;
It is perfectly possible (and, in fact, useful) to have multiple events with the same predefined name and thus the same trigger condition.  However, it is not defined what order such events will fire in, so you need to code so the order &lt;br /&gt;
will not matter.&lt;br /&gt;
&lt;br /&gt;
Because of the above, you need to beware of using macros to generate events. If you include a macro expanding to an event definition twice, the event will be executed twice (not once) each time the trigger condition fires. Consider this code:&lt;br /&gt;
&lt;br /&gt;
 #define DOUBLE&lt;br /&gt;
     [event]&lt;br /&gt;
         name=multiply_by_2&lt;br /&gt;
         {VARIABLE_OP 2_becomes_4 multiply 2}&lt;br /&gt;
     [/event]&lt;br /&gt;
 #enddef&lt;br /&gt;
 &lt;br /&gt;
 {DOUBLE}&lt;br /&gt;
 {DOUBLE}&lt;br /&gt;
 &lt;br /&gt;
 {VARIABLE 2_becomes_4 2}&lt;br /&gt;
 		&lt;br /&gt;
 [fire_event]&lt;br /&gt;
     name=multiply_by_2&lt;br /&gt;
 [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
 {DEBUG_MSG &amp;quot;$2_becomes_4 should be 4&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
After it executes, the debug message will reveal that the variable has been set to 8, not 4.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous Notes and Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Primary/Secondary Unit Speaker Example ===&lt;br /&gt;
&lt;br /&gt;
In events, the primary unit can be referred to as '''unit''' and the secondary unit can be referred to as '''second_unit''' in [message] tags using the '''speaker''' key. For example:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=die&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker='''second_unit'''&lt;br /&gt;
         message= _ &amp;quot;Hahaha! I finally killed you!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 &lt;br /&gt;
     [message]&lt;br /&gt;
         speaker='''unit'''&lt;br /&gt;
         message= _ &amp;quot;It's not over yet! I'll come back to haunt you!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
=== Nested Event Example ===&lt;br /&gt;
&lt;br /&gt;
An event is created for a portal that opens on turn 10. The parent (or 'outer') event executes on turn 10 at which point the nested moveto event is created. This nested event executes when a player steps on a certain spot.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         # moving to 5,8 will trigger this event only on turn 10 and after&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
An equivalent way of doing this would be to create a single moveto event with an '''[if]''' statement to check for turn number but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[if]''' statements.&lt;br /&gt;
&lt;br /&gt;
=== Delayed Variable Substitution Example ===&lt;br /&gt;
&lt;br /&gt;
This code will display the turn on which the nested ''moveto'' event happens.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=yes&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;} &lt;br /&gt;
    [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Since this is the default behavior for the '''delayed_variable_substitution''' key, the following example is identical.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;} &lt;br /&gt;
    [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
This code will always display &amp;quot;Turn 10&amp;quot; when the nested ''moveto'' event happens. This is because the variable substitution is done when the parent event is triggered and spawns the nested event, ''not'' when the nested event is triggered.&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=no&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;} &lt;br /&gt;
    [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Finally, this example is identical to the first two, in that it will display the turn on which the nested ''moveto'' event happens despite the fact that the '''delayed_variable_substitution''' key is set to ''no''. This is because the special '''$|variable''' syntax is used.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=no&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $|turn_number&amp;quot;} &lt;br /&gt;
    [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[DirectActionsWML]]&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[FilterWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=TeamColoring&amp;diff=32340</id>
		<title>TeamColoring</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=TeamColoring&amp;diff=32340"/>
		<updated>2009-09-17T04:40:59Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Update to reflect the realities of the current TeamColorizer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you're an artist, or if you want to use a Wesnoth sprite as your avatar in the forums, or for whatever reason you want to produce a team-colored copy of a Wesnoth sprite without actually running Wesnoth (and probably having to cut the sprite out of a background), there are two easy tools to accomplish this:&lt;br /&gt;
&lt;br /&gt;
* TeamColorizer - This is a Python script included with Wesnoth that does an '''inaccurate''' teamcoloring: it uses a slightly different algorithm than the one used in-game. However, it allows you to use any color that you want, even colors that aren't normal team colors. You just need to do a bit of trickery.&lt;br /&gt;
* wesnoth-tc - This is a C++ program, written by Shadowmaster from the forums. It even has a GUI written for Macs. It uses the same algorithm as the Wesnoth engine.&lt;br /&gt;
&lt;br /&gt;
== TeamColorizer ==&lt;br /&gt;
&lt;br /&gt;
The TeamColorizer included with Wesnoth is at data/core/tools/unit_tree/TeamColorizer. Internally, it's used to produce the red sprites found on http://units.wesnoth.org. However, you can use it to color any image red. It's a command-line program, so first you'll need to open up a command line (either Start-&amp;gt;Run and then type &amp;quot;cmd&amp;quot; in Windows, or use Terminal on a Mac; if you run something else you should know how to do this already). Next, you need to find two things: Python, and the TeamColorizer. You don't have to do this in the shell. Python is likely to be at&lt;br /&gt;
 C:\Python&amp;lt;#&amp;gt;\Python.exe&lt;br /&gt;
or something like that, where &amp;lt;#&amp;gt; is the version, and will be something like '25' for 2.5, '26' for 2.6, etc. You actually don't need this step on a Mac. Next, you have to find the TeamColorizer, and this one you have to do in the shell, by typing&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;&lt;br /&gt;
and then either 'ls' or 'dir' depending on whether you're on Windows ('dir') or on something else. The directory you want is data/core/tools/unit_tree relative to the [http://www.wesnoth.org/wiki/EditingWesnoth#Where_is_my_game_data_directory.3F Wesnoth data directory]. Once you're there, type&lt;br /&gt;
 python TeamColorizer &amp;lt;input_image&amp;gt; &amp;lt;output_image&amp;gt;&lt;br /&gt;
where &amp;lt;input_image&amp;gt; and &amp;lt;output_image&amp;gt; are the '''full''' paths to the input image and desired output image, respectively. If you don't want to worry about where the images are, you can just copy the image you want to use into the same directory as the TeamColorizer for simplicity. Note that the output image will also appear in the same directory as the TeamColorizer unless you give it a different path. If you want, you can copy the whole TeamColorizer somewhere else for convenience. A quick example of what you might do:&lt;br /&gt;
 C:\&amp;gt; cd C:\Progra~1\Wesnoth\data\tools\unit_tree&lt;br /&gt;
 C:\Program Files\Wesnoth\data\tools\unit_tree&amp;gt; C:\Python25\Python.exe TeamColorizer C:\my_image.png out.png&lt;br /&gt;
on Windows, or&lt;br /&gt;
 cd /usr/local/share/wesnoth/data/tools/unit_tree&lt;br /&gt;
 ./TeamColorizer ~/Desktop/in.png ~/Desktop/out.png&lt;br /&gt;
on a Mac (although that Wesnoth path might not be the same as yours...).&lt;br /&gt;
&lt;br /&gt;
Note: these are pretty bad and technical instructions... especially the Windows side. Please revise them if you've got a better way of explaining things. Maybe you could just create a shortcut with the arguments in it in Windows and that would be simpler? (In fact, I'm not even sure if the Windows instructions are correct!)&lt;br /&gt;
&lt;br /&gt;
So now you have a red copy of your image. Hooray! What about other colors? There's currently a patch being considered that will make this bit a little easier (this editor will be honest and admit that eir the one that submitted the patch) but for now, you have to edit the TeamColorizer file. Open it with wordpad, textmate, or whatever text editor you normally use. Look near the top for a place where it says:&lt;br /&gt;
 team_red = 255&lt;br /&gt;
 team_green = 0&lt;br /&gt;
 team_blue = 0&lt;br /&gt;
or something like that. Simply change the red, green, and blue values to your desired color and run the script again. For reference, the Wesnoth team colors are listed in data/core/team-colors.cfg, although because of the difference in algorithm, using the &amp;quot;average color&amp;quot; listed in that file may produce more washed-out variants; try using the &amp;quot;flag color&amp;quot;, or some combination of the two.&lt;br /&gt;
&lt;br /&gt;
== wesnoth-tc ==&lt;br /&gt;
&lt;br /&gt;
If you want to use wesnoth-tc, read up on it on its [http://www.wesnoth.org/forum/viewtopic.php?f=9&amp;amp;t=22859 forum thread]. The thread has information on usage and a link to download the source, as well as information on the Mac GUI. Feel free to post more instructions here if you use it and feel like sharing any insights you gain.&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=32339</id>
		<title>Create Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=32339"/>
		<updated>2009-09-17T04:29:37Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Sprite Art */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
=== General Information ===&lt;br /&gt;
&lt;br /&gt;
Graphic artists usually meet on the [http://www.wesnoth.org/forum/viewforum.php?f=9 artwork development forum] or on the [http://www.wesnoth.org/forum/viewforum.php?f=18 restricted art development forum]. The former is a great place to post and discuss new and current Wesnoth art and graphics, and the latter to see what the art development team is working on.&lt;br /&gt;
&lt;br /&gt;
Unit and terrain art is stored in the portable network graphics (PNG) format.  Each frame of a unit animation, and each variation of a terrain is stored as a separate .png file in the &amp;quot;images&amp;quot; subdirectory of wesnoth, and generally these files will be 72 x 72 pixels (the size of Wesnoth's basic hexagonal tile) with an alpha channel (a part of the file that indicates how transparent each pixel is).  When creating your own images, you can test them without overwriting any game data by putting them in your userdata directory (see [[EditingWesnoth]] for details on Wesnoth's directory structure).  The game also supports JPEG images, though these are better suited for story art.&lt;br /&gt;
&lt;br /&gt;
To edit these graphics, you'll need some program capable of creating PNGs - some of the programs in the following list are free, open-source software, and will do the job nicely: [[Art Programs]]&lt;br /&gt;
&lt;br /&gt;
If you need some inspiration, we have a [[GraphicLibrary|Graphics Library]] which collects art posted on the forum. You can use this for ideas, and as a scrap heap for different parts of unit images (a technique described [[Give Your Hero A Personality|here]]).&lt;br /&gt;
&lt;br /&gt;
=== Roadmap ===&lt;br /&gt;
A list of what's being done and what needs doing:&lt;br /&gt;
* '''[[Tiles Status]]''' - a roadmap/plan of sorts for future work on terrain tiles&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewtopic.php?t=2014 A list] of current work that needs to be done with sprites.&lt;br /&gt;
&lt;br /&gt;
== Art Tutorials ==&lt;br /&gt;
&lt;br /&gt;
These are a work-in-progress, and describe both how to make art fit into wesnoth's style, as well as giving some considerable tips on drawing in general.  Especially useful is the [[External Tutorials]] page which lists a large number of art tutorials available on the web.&lt;br /&gt;
&lt;br /&gt;
=== General Art and Computer Graphics ===&lt;br /&gt;
* [[Using the Levels Adjustment]] - making scanned pencil drawings ''not'' look washed out.&lt;br /&gt;
* [[Extending dynamic range]] - The Grooviest (so far) tutorial about extending the dynamic range of images and how this technique can be used to make better scans of pencil drawings.&lt;br /&gt;
* [[Scanning with camera]] - How to transfer real-life art to computer using a digital camera instead of a scanner.&lt;br /&gt;
* [[How to Anti-Alias Sprite Art]] - A means of removing the jagged edges on pixel lines&lt;br /&gt;
* [[Art Supplies]] - What physical items you need to do larger cell-shaded art like that of Jetryl/Jormungadr/et al&lt;br /&gt;
* [[Inking With Pencils|Computer Inking a Sketch]] - Info from Jason Lutes on his portrait workflow&lt;br /&gt;
* [[Scaling Digital Images]] - how to properly resize an image on a computer&lt;br /&gt;
* [[How to Shade]] - at attempt at tackling a very complicated topic&lt;br /&gt;
* [[Cartography for Wesnoth|How to make Wesnoth-style Maps ]] - Kestenvarn's tricks of the trade&lt;br /&gt;
* [[Designing weapons and armour]] - Advice from zookeeper on designing realistic weapons for your characters&lt;br /&gt;
* [[Portrait Tutorial]] - a guide on how to draw unit/character portraits by Kitty.&lt;br /&gt;
* Sgt. Groovy's vector workshop - tips and tricks for drawing with Inkscape&lt;br /&gt;
** [[Z-order tricks]] - few methods for faking overlapping shapes&lt;br /&gt;
** [[Variable-width strokes]] - how to make the strokes vary in width, like being drawn with a flat-tipped pen &amp;amp;mdash; no tablet needed!&lt;br /&gt;
** [[Shaped gradients with Gaussian blur]] - how to make gradients in other shapes than linear or radial&lt;br /&gt;
** [[Smooth shading in vector]] - the basic vector techniques for smooth shading, employing Gaussian blur and clipping/masking&lt;br /&gt;
** [[Vector Inking]] - vector techniques, including mouse-only, for inking your sketches&lt;br /&gt;
** [[Making portrait art in vector]] - a complete tutorial for making Wesnoth unit portraits in vector graphics.&lt;br /&gt;
&lt;br /&gt;
=== [[Terrain|Terrain Graphics]] ===&lt;br /&gt;
&lt;br /&gt;
The following is information specific to drawing terrain for Wesnoth.  Read Frame's &amp;quot;Tiles Tutorial&amp;quot; for a good overview of how terrain graphics work.&lt;br /&gt;
&lt;br /&gt;
* [[Tiles Tutorial]] - Frame's tutorial describing the process of making terrain tiles in wesnoth, and how they interact with adjacent tiles.&lt;br /&gt;
* [[How To Make Seamless Tiles]] - The tutorial is aimed at Photoshop users, but the technique is similar with The GIMP.&lt;br /&gt;
* [[Seamless Tiles Using Inkscape]] - This tutorial teaches a method for making seamless hex tiles in vector craphics (to be rendered in raster).&lt;br /&gt;
* [[Turning Square Tiles into Hex]] - Nifty tricks for transforming square (or any rectangle) shaped seamless tiles into hexagon seamless tiles.&lt;br /&gt;
* [[CastleTutorial|Castle Tutorial]] - A description of how Wesnoth's castle tiles work (needs updating, but useful nonetheless)&lt;br /&gt;
* [[MultiHexTutorial|Multi-Hex Tiling Tutorial]] - A description of how multi-hex tiles work.&lt;br /&gt;
* [[Editing Castles]] - Instructions for how to make/edit castles (and other corner-based terrains) using yobbo's GIMP script.&lt;br /&gt;
&lt;br /&gt;
These describe the system used to specify how terrains behave in game:&lt;br /&gt;
* [[TerrainCodesWML]] - A list of the letters used to represent terrain types.&lt;br /&gt;
* [[TerrainGraphicsWML]] - If you really need to get technical, start here.&lt;br /&gt;
* [http://www.anathas.org/ayin/wesnoth/doc/terrain_graphics_wml Ayin's Terrain Graphics document] - If you really, ''really'' need to get technical, this describes the terrain graphics WML system in depth.&lt;br /&gt;
&lt;br /&gt;
=== Sprite Art ===&lt;br /&gt;
The following are different tutorials about sprite work compiled by various wesnoth sprite artists.  These will give you the most specific-to-wesnoth information about making sprites, and are well worth a read.&lt;br /&gt;
 &lt;br /&gt;
* [[Creating Unit Art]] - a list of specifications you will need to match.&lt;br /&gt;
* [[Give Your Hero A Personality]] - tricks for editing existing images, including some clip art.&lt;br /&gt;
* [[Basic Animation Tutorial]] - or &amp;quot;How to Animate Sprites for Dummies,&amp;quot; covering the basic theory, and all of the mistakes to avoid.&lt;br /&gt;
* [[Team Color Shifting]] - how to create art that uses our new team color system.&lt;br /&gt;
* [[TeamColoring]] - how to automatically team-color sprites to see what they look like in various colors.&lt;br /&gt;
* [[Creating Shadows Under Units]] - how we create the shadows for the units in-game&lt;br /&gt;
* [[Making Bow Animations]] - the current standard for how we want bow animations to work&lt;br /&gt;
* [[Rotate Pixel Art Without Blurring]]&lt;br /&gt;
* [[Creating a scratch built sprite]] - an attempt to show some ways creating a sprite from scratch&lt;br /&gt;
* [[How to create motion blurs]] - a simple explanation on how to create attack animation weapon blurs&lt;br /&gt;
* [[FrankenPacks]] - a quick and dirty way to create sprites for [[WesnothAcronyms|UMC]]&lt;br /&gt;
&lt;br /&gt;
=== External Tutorials ===&lt;br /&gt;
The following page contains dozens of links to tutorials covering all manner of artwork, including sprite art.  These were not made by wesnoth artists, but should prove very useful for general instruction.&lt;br /&gt;
&lt;br /&gt;
* [[External Tutorials]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[GraphicLibrary]] - Lots of usercontributed graphics (most should be GPL'ed)&lt;br /&gt;
* [[Project]]&lt;br /&gt;
* [http://wesnoth.dbzer0.com/blog/wpg2 External Graphic Library] - A project to better organize the art of Wesnoth.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Team_Color_Shifting&amp;diff=32338</id>
		<title>Team Color Shifting</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Team_Color_Shifting&amp;diff=32338"/>
		<updated>2009-09-17T04:27:48Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Link to the new TeamColoring wiki page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;by Richard Kettering (Jetryl)&lt;br /&gt;
&lt;br /&gt;
:Note: if you're interested in actually changing the color of a sprite that has already had this technique applied to it (i.e. automatically changing the magenta in a sprite to blue or red), see the [[TeamColoring]] page instead.&lt;br /&gt;
&lt;br /&gt;
Wesnoth's sprites are only drawn in one color, but in an actual game, all of our unit's clothing will change color to the color of whatever team they're on.  We call this &amp;quot;team color&amp;quot; shifting.  Any team color shifting system needs a way of indicating which areas of the graphic are to be changed in color.  Ours solves this by selecting a certain, specific range of colors, and shifting the pixels whenever they are that source color in the unit image.  In our system, this can be done with any set of colors that you choose, on a per-unit basis.  However, we've got a shortcut for one set of colors, magenta.  We picked a color that because it would stick out like a sore thumb; it's not an 'earthtone', and isn't commonly seen in nature.&lt;br /&gt;
&lt;br /&gt;
It's not just any magenta; it has to be from the following, very specific set:&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/colorswatch.png&lt;br /&gt;
&lt;br /&gt;
Also, it won't show up on a unit unless they have this line in their unitname.cfg file:&lt;br /&gt;
  {MAGENTA_IS_THE_TEAM_COLOR}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You'll need to have some costume element on the unit which can be designated as the team-colored piece of their outfit; It's best to design units around having this.   The easiest way to designate this, is to define a new layer in a capable program (photoshop, gimp, etc), overlaid on the rest of the image, in which you draw with our special values of magenta.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Time-Saving Tips:'''&lt;br /&gt;
&lt;br /&gt;
If units are drawn with a small color set, as used in traditional sprite art, you can use a properly-set paint-bucket tool to replace all instances of a given color.  You'll want to set it to be non-contiguous, non-antialiased and to have a tolerance of 0 (presumably, you also want it to fill based on &amp;quot;all layers&amp;quot; - these settings are based on Photoshop, and the Gimp is likely similar).&lt;br /&gt;
&lt;br /&gt;
If you're working on a sprite which isn't strictly pixel art (e.g. which doesn't have a tiny set of unique RGB values), you're not out of luck at all.  Simply take the same paint-bucket tool with the same settings, and crank the tolerance up to about 20-30.  The paint-bucket will then affect all of those similar, subtle gradations in shade which were achieved with the paintbrush tool, replacing them all with a single color.  Use this with progressively lighter shades, and you'll fill in 90% of the target area, after which it is trivial to fill the holes left behind with a pencil tool.&lt;br /&gt;
&lt;br /&gt;
Also, if you'd like a sane representation of what the final colors will look like, you can shift this separate team-color layer in your graphics application by using a '''temporary''' hue/saturation filter on that layer (I use +40 to the hue on the magenta colors to give a red hue similar but '''not''' identical to the one which the game uses).&lt;br /&gt;
&lt;br /&gt;
It is often easiest to simply sample the colors from a unit to which already has team colors on it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Screenshots:'''&lt;br /&gt;
&lt;br /&gt;
This is a screenshot of what a unit would look like if it were drawn directly, without the special pixels:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_off.png&lt;br /&gt;
&lt;br /&gt;
This is a screenshot of the team-colored pixels in a separate photoshop layer:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_alone.png&lt;br /&gt;
&lt;br /&gt;
And this is what the combined image looks like, which will get mixed-down into a single PNG file:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_on.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''WML How To: '''&lt;br /&gt;
&lt;br /&gt;
We've defined a WML macro to specify a set of magenta colors, as seen in the previous palette.  To use this, you simply sample the color with your graphics program's eyedropper tool, and then draw with it.  The macro is used just like the flag_rgb business - you simply insert the following in your unit .cfg file (for reference, the macro itself is defined in utils.cfg):&lt;br /&gt;
  {MAGENTA_IS_THE_TEAM_COLOR}&lt;br /&gt;
&lt;br /&gt;
Note that these shift ONLY the precise RGB values given - do not confuse color with hue, because every specific shade - every specific instance with a different luminosity and saturation value - must be specified separately.&lt;br /&gt;
&lt;br /&gt;
The game will shift the color set to one of the team colors; in doing so it will completely overrun the saturation of the original color.  It will change the hue to that of the team, and shift the luminosity as well.  The coloration you give is set in terms of relative luminosity - the entire patch may be bright or dark depending on which team the unit is on.  Also note that the first color specified is special, because it is treated as the median value, and will be assigned the precise luminosity value of the team color.  Anything brighter than it will be brighter than the team color, anything darker will be darker.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' design errata for nerds/game-designers: '''&lt;br /&gt;
E.g. &amp;quot;Why we did it the way we did.&amp;quot;  There are a number of other ways to do this, but this was what we settled on.  A different option might have been to use special grayscale image maps to indicate what to change, they would have basically doubled the number of images used by the game.  Alternately, we could have done some bizarre wizardry with graphics files, and included something like an alpha-channel to indicate which pixels to change; we decided against this because that would break the huge advantage of using a very standard format like PNG, which is that everyone can easily grab a program to edit it.  Design nitpickers will notice one minor disadvantage in how we did it.  The colors which get shifted away are inaccessible for direct use; but because they're such a small set of colors, and because they were chosen to be &amp;quot;unusual&amp;quot; colors (rather than common ones like earthtones), it's unlikely that not being able to use these specific RGB values would ever be a problem.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
* [[TeamColoring]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Team_Color_Shifting&amp;diff=32337</id>
		<title>Team Color Shifting</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Team_Color_Shifting&amp;diff=32337"/>
		<updated>2009-09-17T04:24:29Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;by Richard Kettering (Jetryl)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Wesnoth's sprites are only drawn in one color, but in an actual game, all of our unit's clothing will change color to the color of whatever team they're on.  We call this &amp;quot;team color&amp;quot; shifting.  Any team color shifting system needs a way of indicating which areas of the graphic are to be changed in color.  Ours solves this by selecting a certain, specific range of colors, and shifting the pixels whenever they are that source color in the unit image.  In our system, this can be done with any set of colors that you choose, on a per-unit basis.  However, we've got a shortcut for one set of colors, magenta.  We picked a color that because it would stick out like a sore thumb; it's not an 'earthtone', and isn't commonly seen in nature.&lt;br /&gt;
&lt;br /&gt;
It's not just any magenta; it has to be from the following, very specific set:&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/colorswatch.png&lt;br /&gt;
&lt;br /&gt;
Also, it won't show up on a unit unless they have this line in their unitname.cfg file:&lt;br /&gt;
  {MAGENTA_IS_THE_TEAM_COLOR}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You'll need to have some costume element on the unit which can be designated as the team-colored piece of their outfit; It's best to design units around having this.   The easiest way to designate this, is to define a new layer in a capable program (photoshop, gimp, etc), overlaid on the rest of the image, in which you draw with our special values of magenta.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Time-Saving Tips:'''&lt;br /&gt;
&lt;br /&gt;
If units are drawn with a small color set, as used in traditional sprite art, you can use a properly-set paint-bucket tool to replace all instances of a given color.  You'll want to set it to be non-contiguous, non-antialiased and to have a tolerance of 0 (presumably, you also want it to fill based on &amp;quot;all layers&amp;quot; - these settings are based on Photoshop, and the Gimp is likely similar).&lt;br /&gt;
&lt;br /&gt;
If you're working on a sprite which isn't strictly pixel art (e.g. which doesn't have a tiny set of unique RGB values), you're not out of luck at all.  Simply take the same paint-bucket tool with the same settings, and crank the tolerance up to about 20-30.  The paint-bucket will then affect all of those similar, subtle gradations in shade which were achieved with the paintbrush tool, replacing them all with a single color.  Use this with progressively lighter shades, and you'll fill in 90% of the target area, after which it is trivial to fill the holes left behind with a pencil tool.&lt;br /&gt;
&lt;br /&gt;
Also, if you'd like a sane representation of what the final colors will look like, you can shift this separate team-color layer in your graphics application by using a '''temporary''' hue/saturation filter on that layer (I use +40 to the hue on the magenta colors to give a red hue similar but '''not''' identical to the one which the game uses).&lt;br /&gt;
&lt;br /&gt;
It is often easiest to simply sample the colors from a unit to which already has team colors on it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Screenshots:'''&lt;br /&gt;
&lt;br /&gt;
This is a screenshot of what a unit would look like if it were drawn directly, without the special pixels:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_off.png&lt;br /&gt;
&lt;br /&gt;
This is a screenshot of the team-colored pixels in a separate photoshop layer:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_alone.png&lt;br /&gt;
&lt;br /&gt;
And this is what the combined image looks like, which will get mixed-down into a single PNG file:&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/team-color/tcpatch_on.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''WML How To: '''&lt;br /&gt;
&lt;br /&gt;
We've defined a WML macro to specify a set of magenta colors, as seen in the previous palette.  To use this, you simply sample the color with your graphics program's eyedropper tool, and then draw with it.  The macro is used just like the flag_rgb business - you simply insert the following in your unit .cfg file (for reference, the macro itself is defined in utils.cfg):&lt;br /&gt;
  {MAGENTA_IS_THE_TEAM_COLOR}&lt;br /&gt;
&lt;br /&gt;
Note that these shift ONLY the precise RGB values given - do not confuse color with hue, because every specific shade - every specific instance with a different luminosity and saturation value - must be specified separately.&lt;br /&gt;
&lt;br /&gt;
The game will shift the color set to one of the team colors; in doing so it will completely overrun the saturation of the original color.  It will change the hue to that of the team, and shift the luminosity as well.  The coloration you give is set in terms of relative luminosity - the entire patch may be bright or dark depending on which team the unit is on.  Also note that the first color specified is special, because it is treated as the median value, and will be assigned the precise luminosity value of the team color.  Anything brighter than it will be brighter than the team color, anything darker will be darker.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' design errata for nerds/game-designers: '''&lt;br /&gt;
E.g. &amp;quot;Why we did it the way we did.&amp;quot;  There are a number of other ways to do this, but this was what we settled on.  A different option might have been to use special grayscale image maps to indicate what to change, they would have basically doubled the number of images used by the game.  Alternately, we could have done some bizarre wizardry with graphics files, and included something like an alpha-channel to indicate which pixels to change; we decided against this because that would break the huge advantage of using a very standard format like PNG, which is that everyone can easily grab a program to edit it.  Design nitpickers will notice one minor disadvantage in how we did it.  The colors which get shifted away are inaccessible for direct use; but because they're such a small set of colors, and because they were chosen to be &amp;quot;unusual&amp;quot; colors (rather than common ones like earthtones), it's unlikely that not being able to use these specific RGB values would ever be a problem.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
* [[TeamColoring]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=TeamColoring&amp;diff=32336</id>
		<title>TeamColoring</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=TeamColoring&amp;diff=32336"/>
		<updated>2009-09-17T04:23:58Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Instructions for using the built-in teamcoloring script.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you're an artist, or if you want to use a Wesnoth sprite as your avatar in the forums, or for whatever reason you want to produce a team-colored copy of a Wesnoth sprite without actually running Wesnoth (and probably having to cut the sprite out of a background), there are two easy tools to accomplish this:&lt;br /&gt;
&lt;br /&gt;
* TeamColorizer - This is a Python script included with Wesnoth that does an '''inaccurate''' teamcoloring: it uses a slightly different algorithm than the one used in-game. However, it allows you to use any color that you want, even colors that aren't normal team colors. You just need to do a bit of trickery.&lt;br /&gt;
* wesnoth-tc - This is a C++ program, written by Shadowmaster from the forums. It even has a GUI written for Macs. It uses the same algorithm as the Wesnoth engine.&lt;br /&gt;
&lt;br /&gt;
== TeamColorizer ==&lt;br /&gt;
&lt;br /&gt;
The TeamColorizer included with Wesnoth is at data/core/tools/unit_tree/TeamColorizer. Internally, it's used to produce the red sprites found on http://units.wesnoth.org. However, you can use it to color any image red. It's a command-line program, so first you'll need to open up a command line (either Start-&amp;gt;Run and then type &amp;quot;cmd&amp;quot; in Windows, or use Terminal on a Mac; if you run something else you should know how to do this already). Next, you need to find two things: Python, and the TeamColorizer. You don't have to do this in the shell. Python is likely to be at&lt;br /&gt;
 C:\Python&amp;lt;#&amp;gt;\Python.exe&lt;br /&gt;
or something like that, where &amp;lt;#&amp;gt; is the version, and will be something like '25' for 2.5, '26' for 2.6, etc. You actually don't need this step on a Mac. Next, you have to find the TeamColorizer, and this one you have to do in the shell, by typing&lt;br /&gt;
 cd &amp;lt;directory&amp;gt;&lt;br /&gt;
and then either 'ls' or 'dir' depending on whether you're on Windows ('dir') or on something else. The directory you want is data/core/tools/unit_tree relative to the [http://www.wesnoth.org/wiki/EditingWesnoth#Where_is_my_game_data_directory.3F Wesnoth data directory]. Once you're there, type&lt;br /&gt;
 python TeamColorizer -h&lt;br /&gt;
and press enter. The program should print a help message, giving you instructions, follow these, and you can get teamcolored images. If the instructions are difficult to follow: You'll wind up using a command like&lt;br /&gt;
 python TeamColorizer --color=red my_image.png output_image.png&lt;br /&gt;
If you don't want to worry about where the images are, you can just copy the image you want to use into the same directory as the TeamColorizer for simplicity. Note that the output image will also appear in the same directory as the TeamColorizer. If you want, you can copy the TeamColorizer somewhere else for convenience.&lt;br /&gt;
&lt;br /&gt;
Note: these are pretty bad and technical instructions... especially the Windows side. Please revise them if you've got a better way of explaining things. Maybe you could just create a shortcut with the arguments in it in Windows and that would be simpler?&lt;br /&gt;
&lt;br /&gt;
Note 2: On a Mac or other Unix machine, you should be able to use&lt;br /&gt;
 ./TeamColorizer ...&lt;br /&gt;
in place of&lt;br /&gt;
 python TeamColorizer ...&lt;br /&gt;
and for those happy to deal with paths a lot, there's no reason not to do&lt;br /&gt;
 ./path/to/teamcolorizer/TeamColorizer ...&lt;br /&gt;
&lt;br /&gt;
== wesnoth-tc ==&lt;br /&gt;
&lt;br /&gt;
If you want to use wesnoth-tc, read up on it on its [http://www.wesnoth.org/forum/viewtopic.php?f=9&amp;amp;t=22859 forum thread]. The thread has information on usage and a link to download the source, as well as information on the Mac GUI. Feel free to post more instructions here if you use it and feel like sharing any insights you gain.&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32289</id>
		<title>BuildingMaps</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32289"/>
		<updated>2009-09-13T19:11:38Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Made the intro text into a short summary and made the tone less familiar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A map is just a bunch of terrain strings arranged in a rectangle (the rectangle is known as the &amp;quot;map data&amp;quot;). There are two ways to use this rectangle in a file: as a stand-alone map, or within a scenario. The easiest way to create maps is just to use the built-in editor, but if you want to actually understand how maps work, you should read a little about the map data format. This page explains that format, and then has some pointers about the editor, saving files, and how to play on a map once you've made it.&lt;br /&gt;
&lt;br /&gt;
== Wesnoth map data format ==&lt;br /&gt;
&lt;br /&gt;
Map data is used to represent maps in Wesnoth.  The encoding for maps has a specific format:&lt;br /&gt;
&lt;br /&gt;
* A map starts with a header with the following keys &lt;br /&gt;
** usage, this is map for a 'map' and 'mask' for an overlay mask&lt;br /&gt;
** border_size, the size of the border, should be 1 for map and 0 for mask. When the border_size is 1 the map border is part of the map data, this means the user can define the border instead of the game taking a guess.&lt;br /&gt;
* Between the header and the data should be 1 empty line&lt;br /&gt;
* A map data file consists of any number of lines, each with the same number of strings.&lt;br /&gt;
* Each string must be a string specified in a ''string'' key specifying a terrain (see [[TerrainLettersWML]]).&lt;br /&gt;
* Each string may be padded with spaces or tabs and must be separated with a comma, except for the last string on a line this one may not have a comma.&lt;br /&gt;
* When the file is interpreted, each string will be replaced by the terrain it refers to.&lt;br /&gt;
* Empty lines are allowed before, after and between lines of characters, between lines is not advised.&lt;br /&gt;
* Terrains may be prefixed with a number followed by one space, these indicate the starting position for side ''n''. ''n'' = 1, 2, 3, ... 9 (more might work but is untested and unsupported). This is a change from the previous system where a starting position was automatically a keep.&lt;br /&gt;
&lt;br /&gt;
It's advised to use spaces for padding and pad each column to be the same width; the game does this when writing a map file.&lt;br /&gt;
 &lt;br /&gt;
Since text file tiles are squares while game tiles are hexes, some tiles must be shifted.&lt;br /&gt;
Tiles in even-numbered columns are shifted down 1/2 of a tile.&lt;br /&gt;
For example, to have a road of connected dirt ('Re') tiles, the map data would look like this:&lt;br /&gt;
&lt;br /&gt;
 usage=map&lt;br /&gt;
 border_size=1&lt;br /&gt;
 &lt;br /&gt;
 Re, Re, Gg, Gg, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Re, Re, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Re, Re, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Gg, Gg, Re, Re&lt;br /&gt;
&lt;br /&gt;
== Creating a map ==&lt;br /&gt;
&lt;br /&gt;
This is not the Matrix.  You do not need to look at encoded maps.  Wesnoth has a fully functional map editor, accessible from within the game. The map editor should be fairly straightforward, although if you run into trouble, go ahead and ask for help on the [http://www.wesnoth.org/forum forum].&lt;br /&gt;
&lt;br /&gt;
Making good, balanced, interesting maps is another task altogether.  ESR has addressed it in his [http://catb.org/~esr/wesnoth/campaign-design-howto.html Campaign Design How-To]&lt;br /&gt;
&lt;br /&gt;
If you're a programmer, note that while the source code and most binary distributions come with the official graphical map editor, you may have to give the build system a flag or argument to tell it to compile them as well as the main game.&lt;br /&gt;
&lt;br /&gt;
== So now what? ==&lt;br /&gt;
&lt;br /&gt;
You've created an awesome map with the [[WesnothMapEditor]] and you're ready to test it out. But how can you do this? It's actually quite simple.&lt;br /&gt;
&lt;br /&gt;
==== Stand-alone maps ====&lt;br /&gt;
&lt;br /&gt;
If you just want to play the map, maybe against the computer or with a friend, all you have to do is save it into your custom maps folder (the default location). Then, when you launch the game and host a multiplayer game, the map should appear at the top of the map choices dialog.&lt;br /&gt;
&lt;br /&gt;
For the curious: Saving a map file like this creates a stand-alone file that holds the map data. That file is by default saved in '''''userdata''/editor/maps/''', and maps in that location are added to the top of the multiplayer map selection list.&lt;br /&gt;
&lt;br /&gt;
==== The map_data key ====&lt;br /&gt;
&lt;br /&gt;
There's another way to use map data. The data for the map can be placed directly inside of a ''map_data'' tag in a '''[scenario]''' tag (see [[ScenarioWML]]). An example of map data encoded directly in a file might look like this:&lt;br /&gt;
        map_data=&amp;quot;border_size=1&lt;br /&gt;
        usage=map&lt;br /&gt;
        &lt;br /&gt;
        Gg, Ke, Gg, Gg&lt;br /&gt;
        Gg, Ce, Ce, Gg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that it's almost always more useful to have a separate map file that you reference in a scenario than putting the data directly into the scenario (not least because the editor works on such separate map files). To use a saved map file in a campaign, you have to include the map data like this:&lt;br /&gt;
&lt;br /&gt;
 map_data=&amp;quot;{@editor/''map_filename''}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that @editor here means that the map should be found in the '''''userdata''/editor/maps/''' directory. You need to specify something else if your map is in another location (for example, in a campaign, the maps should go into their own folder). The [[ScenarioWML]], [[BuildingCampaignsTheCampaignFile]] and [[PreprocessorRef]] pages all contain more detailed information about how this works.&lt;br /&gt;
&lt;br /&gt;
== Discussion: Scenario File vs Standalone ==&lt;br /&gt;
&lt;br /&gt;
Campaign writers can't write campaigns without scenarios, so campaigns will always use the ''map_data'' key, either with the raw data in quotes or a preprocessor symbol {} pointing to the standalone file.&lt;br /&gt;
&lt;br /&gt;
Multiplayer mapmakers, however, '''have a choice'''.  If you want to place an object or unit on the map, you must create a scenario file starting with the '''[multiplayer]''' tag and containing the ''map_data'' key therein.  You lose the simplicity of the standalone map file, but you gain tremendous power.  Not only can you add units and objects, you can set allies, experience modifiers, add a map description, and add custom events (among other things).  The question, &amp;quot;How do I place an object on the map with the map editor&amp;quot; is such a common question that I am sorry this information is buried so deeply here.  But, now that you know you can seek out an example of a multiplayer map scenario file to use as an example.  The game comes with many maps of each type.  Check out [[BuildingMultiplayer]] for more information.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[ScenarioWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[BuildingScenariosShroudData]]&lt;br /&gt;
* [[TerrainCodesWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32288</id>
		<title>BuildingMaps</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32288"/>
		<updated>2009-09-13T19:07:34Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* So now what? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is all you need to know about maps:&lt;br /&gt;
&lt;br /&gt;
# A map is just a bunch of terrain strings arranged in a rectangle (the rectangle is known as the &amp;quot;map data&amp;quot;)&lt;br /&gt;
# There are two ways to save this rectangle in a file&lt;br /&gt;
&lt;br /&gt;
Seriously now, here are the details.&lt;br /&gt;
&lt;br /&gt;
== Wesnoth map data format ==&lt;br /&gt;
&lt;br /&gt;
Map data is used to represent maps in Wesnoth.  The encoding for maps has a specific format:&lt;br /&gt;
&lt;br /&gt;
* A map starts with a header with the following keys &lt;br /&gt;
** usage, this is map for a 'map' and 'mask' for an overlay mask&lt;br /&gt;
** border_size, the size of the border, should be 1 for map and 0 for mask. When the border_size is 1 the map border is part of the map data, this means the user can define the border instead of the game taking a guess.&lt;br /&gt;
* Between the header and the data should be 1 empty line&lt;br /&gt;
* A map data file consists of any number of lines, each with the same number of strings.&lt;br /&gt;
* Each string must be a string specified in a ''string'' key specifying a terrain (see [[TerrainLettersWML]]).&lt;br /&gt;
* Each string may be padded with spaces or tabs and must be separated with a comma, except for the last string on a line this one may not have a comma.&lt;br /&gt;
* When the file is interpreted, each string will be replaced by the terrain it refers to.&lt;br /&gt;
* Empty lines are allowed before, after and between lines of characters, between lines is not advised.&lt;br /&gt;
* Terrains may be prefixed with a number followed by one space, these indicate the starting position for side ''n''. ''n'' = 1, 2, 3, ... 9 (more might work but is untested and unsupported). This is a change from the previous system where a starting position was automatically a keep.&lt;br /&gt;
&lt;br /&gt;
It's advised to use spaces for padding and pad each column to be the same width; the game does this when writing a map file.&lt;br /&gt;
 &lt;br /&gt;
Since text file tiles are squares while game tiles are hexes, some tiles must be shifted.&lt;br /&gt;
Tiles in even-numbered columns are shifted down 1/2 of a tile.&lt;br /&gt;
For example, to have a road of connected dirt ('Re') tiles, the map data would look like this:&lt;br /&gt;
&lt;br /&gt;
 usage=map&lt;br /&gt;
 border_size=1&lt;br /&gt;
 &lt;br /&gt;
 Re, Re, Gg, Gg, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Re, Re, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Re, Re, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Gg, Gg, Re, Re&lt;br /&gt;
&lt;br /&gt;
== Creating a map ==&lt;br /&gt;
&lt;br /&gt;
This is not the Matrix.  You do not need to look at encoded maps.  Wesnoth has a fully functional map editor, accessible from within the game. The map editor should be fairly straightforward, although if you run into trouble, go ahead and ask for help on the [http://www.wesnoth.org/forum forum].&lt;br /&gt;
&lt;br /&gt;
Making good, balanced, interesting maps is another task altogether.  ESR has addressed it in his [http://catb.org/~esr/wesnoth/campaign-design-howto.html Campaign Design How-To]&lt;br /&gt;
&lt;br /&gt;
If you're a programmer, note that while the source code and most binary distributions come with the official graphical map editor, you may have to give the build system a flag or argument to tell it to compile them as well as the main game.&lt;br /&gt;
&lt;br /&gt;
== So now what? ==&lt;br /&gt;
&lt;br /&gt;
You've created an awesome map with the [[WesnothMapEditor]] and you're ready to test it out. But how can you do this? It's actually quite simple.&lt;br /&gt;
&lt;br /&gt;
==== Stand-alone maps ====&lt;br /&gt;
&lt;br /&gt;
If you just want to play the map, maybe against the computer or with a friend, all you have to do is save it into your custom maps folder (the default location). Then, when you launch the game and host a multiplayer game, the map should appear at the top of the map choices dialog.&lt;br /&gt;
&lt;br /&gt;
For the curious: Saving a map file like this creates a stand-alone file that holds the map data. That file is by default saved in '''''userdata''/editor/maps/''', and maps in that location are added to the top of the multiplayer map selection list.&lt;br /&gt;
&lt;br /&gt;
==== The map_data key ====&lt;br /&gt;
&lt;br /&gt;
There's another way to use map data. The data for the map can be placed directly inside of a ''map_data'' tag in a '''[scenario]''' tag (see [[ScenarioWML]]). An example of map data encoded directly in a file might look like this:&lt;br /&gt;
        map_data=&amp;quot;border_size=1&lt;br /&gt;
        usage=map&lt;br /&gt;
        &lt;br /&gt;
        Gg, Ke, Gg, Gg&lt;br /&gt;
        Gg, Ce, Ce, Gg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that it's almost always more useful to have a separate map file that you reference in a scenario than putting the data directly into the scenario (not least because the editor works on such separate map files). To use a saved map file in a campaign, you have to include the map data like this:&lt;br /&gt;
&lt;br /&gt;
 map_data=&amp;quot;{@editor/''map_filename''}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that @editor here means that the map should be found in the '''''userdata''/editor/maps/''' directory. You need to specify something else if your map is in another location (for example, in a campaign, the maps should go into their own folder). The [[ScenarioWML]], [[BuildingCampaignsTheCampaignFile]] and [[PreprocessorRef]] pages all contain more detailed information about how this works.&lt;br /&gt;
&lt;br /&gt;
== Discussion: Scenario File vs Standalone ==&lt;br /&gt;
&lt;br /&gt;
Campaign writers can't write campaigns without scenarios, so campaigns will always use the ''map_data'' key, either with the raw data in quotes or a preprocessor symbol {} pointing to the standalone file.&lt;br /&gt;
&lt;br /&gt;
Multiplayer mapmakers, however, '''have a choice'''.  If you want to place an object or unit on the map, you must create a scenario file starting with the '''[multiplayer]''' tag and containing the ''map_data'' key therein.  You lose the simplicity of the standalone map file, but you gain tremendous power.  Not only can you add units and objects, you can set allies, experience modifiers, add a map description, and add custom events (among other things).  The question, &amp;quot;How do I place an object on the map with the map editor&amp;quot; is such a common question that I am sorry this information is buried so deeply here.  But, now that you know you can seek out an example of a multiplayer map scenario file to use as an example.  The game comes with many maps of each type.  Check out [[BuildingMultiplayer]] for more information.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[ScenarioWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[BuildingScenariosShroudData]]&lt;br /&gt;
* [[TerrainCodesWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32283</id>
		<title>BuildingMaps</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32283"/>
		<updated>2009-09-13T05:02:24Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Made more accessible and removed some old information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is all you need to know about maps:&lt;br /&gt;
&lt;br /&gt;
# A map is just a bunch of terrain strings arranged in a rectangle (the rectangle is known as the &amp;quot;map data&amp;quot;)&lt;br /&gt;
# There are two ways to save this rectangle in a file&lt;br /&gt;
&lt;br /&gt;
Seriously now, here are the details.&lt;br /&gt;
&lt;br /&gt;
== Wesnoth map data format ==&lt;br /&gt;
&lt;br /&gt;
Map data is used to represent maps in Wesnoth.  The encoding for maps has a specific format:&lt;br /&gt;
&lt;br /&gt;
* A map starts with a header with the following keys &lt;br /&gt;
** usage, this is map for a 'map' and 'mask' for an overlay mask&lt;br /&gt;
** border_size, the size of the border, should be 1 for map and 0 for mask. When the border_size is 1 the map border is part of the map data, this means the user can define the border instead of the game taking a guess.&lt;br /&gt;
* Between the header and the data should be 1 empty line&lt;br /&gt;
* A map data file consists of any number of lines, each with the same number of strings.&lt;br /&gt;
* Each string must be a string specified in a ''string'' key specifying a terrain (see [[TerrainLettersWML]]).&lt;br /&gt;
* Each string may be padded with spaces or tabs and must be separated with a comma, except for the last string on a line this one may not have a comma.&lt;br /&gt;
* When the file is interpreted, each string will be replaced by the terrain it refers to.&lt;br /&gt;
* Empty lines are allowed before, after and between lines of characters, between lines is not advised.&lt;br /&gt;
* Terrains may be prefixed with a number followed by one space, these indicate the starting position for side ''n''. ''n'' = 1, 2, 3, ... 9 (more might work but is untested and unsupported). This is a change from the previous system where a starting position was automatically a keep.&lt;br /&gt;
&lt;br /&gt;
It's advised to use spaces for padding and pad each column to be the same width; the game does this when writing a map file.&lt;br /&gt;
 &lt;br /&gt;
Since text file tiles are squares while game tiles are hexes, some tiles must be shifted.&lt;br /&gt;
Tiles in even-numbered columns are shifted down 1/2 of a tile.&lt;br /&gt;
For example, to have a road of connected dirt ('Re') tiles, the map data would look like this:&lt;br /&gt;
&lt;br /&gt;
 usage=map&lt;br /&gt;
 border_size=1&lt;br /&gt;
 &lt;br /&gt;
 Re, Re, Gg, Gg, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Re, Re, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Re, Re, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Gg, Gg, Re, Re&lt;br /&gt;
&lt;br /&gt;
== Creating a map ==&lt;br /&gt;
&lt;br /&gt;
This is not the Matrix.  You do not need to look at encoded maps.  Wesnoth has a fully functional map editor, accessible from within the game. The map editor should be fairly straightforward, although if you run into trouble, go ahead and ask for help on the [http://www.wesnoth.org/forum forum].&lt;br /&gt;
&lt;br /&gt;
Making good, balanced, interesting maps is another task altogether.  ESR has addressed it in his [http://catb.org/~esr/wesnoth/campaign-design-howto.html Campaign Design How-To]&lt;br /&gt;
&lt;br /&gt;
If you're a programmer, note that while the source code and most binary distributions come with the official graphical map editor, you may have to give the build system a flag or argument to tell it to compile them as well as the main game.&lt;br /&gt;
&lt;br /&gt;
== So now what? ==&lt;br /&gt;
&lt;br /&gt;
You've created an awesome map with the [[WesnothMapEditor]] and you're ready to test it out. But how can you do this? It's actually quite simple.&lt;br /&gt;
&lt;br /&gt;
==== Stand-alone maps ====&lt;br /&gt;
&lt;br /&gt;
If you just want to play the map, maybe against the computer or with a friend, all you have to do is save it into your custom maps folder (which should be the default place to save things in the editor, so really all you should need to do is save it). Then, when you launch the game and host a multiplayer game, the map should appear at the top of the map choices dialog. Simple, eh?&lt;br /&gt;
&lt;br /&gt;
For the curious: Saving a map file like this creates a stand-alone file that holds the map data. That file is by default saved in '''''userdata''/editor/maps/''', and maps in that location are added to the top of the multiplayer map selection list.&lt;br /&gt;
&lt;br /&gt;
==== The map_data key ====&lt;br /&gt;
&lt;br /&gt;
There's another way to use map data. The data for the map can be placed directly inside of a ''map_data'' tag in a '''[scenario]''' tag (see [[ScenarioWML]]). An example of map data encoded directly in a file might look like this:&lt;br /&gt;
        map_data=&amp;quot;border_size=1&lt;br /&gt;
        usage=map&lt;br /&gt;
        &lt;br /&gt;
        Gg, Ke, Gg, Gg&lt;br /&gt;
        Gg, Ce, Ce, Gg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that it's almost always more useful to have a separate map file that you reference in a scenario than putting the data directly into the scenario (not least because the editor works on such separate map files). If you have a saved map file that you want to use in your campaign, you'll have to include the map data like this:&lt;br /&gt;
&lt;br /&gt;
 map_data=&amp;quot;{@editor/''map_filename''}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that @editor here means that the map should be found in the '''''userdata''/editor/maps/''' directory. You'll need to specify something else if your map is in another location (for example, in a campaign, the maps should go into their own folder). The [[ScenarioWML]], [[BuildingCampaignsTheCampaignFile]] and [[PreprocessorRef]] pages all contain more detailed information about hos this works and how it should be done.&lt;br /&gt;
&lt;br /&gt;
== Discussion: Scenario File vs Standalone ==&lt;br /&gt;
&lt;br /&gt;
Campaign writers can't write campaigns without scenarios, so campaigns will always use the ''map_data'' key, either with the raw data in quotes or a preprocessor symbol {} pointing to the standalone file.&lt;br /&gt;
&lt;br /&gt;
Multiplayer mapmakers, however, '''have a choice'''.  If you want to place an object or unit on the map, you must create a scenario file starting with the '''[multiplayer]''' tag and containing the ''map_data'' key therein.  You lose the simplicity of the standalone map file, but you gain tremendous power.  Not only can you add units and objects, you can set allies, experience modifiers, add a map description, and add custom events (among other things).  The question, &amp;quot;How do I place an object on the map with the map editor&amp;quot; is such a common question that I am sorry this information is buried so deeply here.  But, now that you know you can seek out an example of a multiplayer map scenario file to use as an example.  The game comes with many maps of each type.  Check out [[BuildingMultiplayer]] for more information.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[ScenarioWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[BuildingScenariosShroudData]]&lt;br /&gt;
* [[TerrainCodesWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32282</id>
		<title>BuildingMaps</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingMaps&amp;diff=32282"/>
		<updated>2009-09-13T04:57:11Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Clarified how to use map data&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is all you need to know about maps:&lt;br /&gt;
&lt;br /&gt;
# A map is just a bunch of terrain strings arranged in a rectangle (the rectangle is known as the &amp;quot;map data&amp;quot;)&lt;br /&gt;
# There are two ways to save this rectangle in a file&lt;br /&gt;
&lt;br /&gt;
Seriously now, here are the details.&lt;br /&gt;
&lt;br /&gt;
== Wesnoth map data format ==&lt;br /&gt;
&lt;br /&gt;
Map data is used to represent maps in Wesnoth.  The encoding for maps has a specific format:&lt;br /&gt;
&lt;br /&gt;
* A map starts with a header with the following keys &lt;br /&gt;
** usage, this is map for a 'map' and 'mask' for an overlay mask&lt;br /&gt;
** border_size, the size of the border, should be 1 for map and 0 for mask. When the border_size is 1 the map border is part of the map data, this means the user can define the border instead of the game taking a guess.&lt;br /&gt;
* Between the header and the data should be 1 empty line&lt;br /&gt;
* A map data file consists of any number of lines, each with the same number of strings.&lt;br /&gt;
* Each string must be a string specified in a ''string'' key specifying a terrain (see [[TerrainLettersWML]]).&lt;br /&gt;
* Each string may be padded with spaces or tabs and must be separated with a comma, except for the last string on a line this one may not have a comma.&lt;br /&gt;
* When the file is interpreted, each string will be replaced by the terrain it refers to.&lt;br /&gt;
* Empty lines are allowed before, after and between lines of characters, between lines is not advised.&lt;br /&gt;
* Terrains may be prefixed with a number followed by one space, these indicate the starting position for side ''n''. ''n'' = 1, 2, 3, ... 9 (more might work but is untested and unsupported). This is a change from the previous system where a starting position was automatically a keep.&lt;br /&gt;
&lt;br /&gt;
It's advised to use spaces for padding and pad each column to be the same width; the game does this when writing a map file.&lt;br /&gt;
 &lt;br /&gt;
Since text file tiles are squares while game tiles are hexes, some tiles must be shifted.&lt;br /&gt;
Tiles in even-numbered columns are shifted down 1/2 of a tile.&lt;br /&gt;
For example, to have a road of connected dirt ('Re') tiles, the map data would look like this:&lt;br /&gt;
&lt;br /&gt;
 usage=map&lt;br /&gt;
 border_size=1&lt;br /&gt;
 &lt;br /&gt;
 Re, Re, Gg, Gg, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Re, Re, Gg, Gg, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Re, Re, Gg, Gg&lt;br /&gt;
 Gg, Gg, Gg, Gg, Gg, Gg, Re, Re&lt;br /&gt;
&lt;br /&gt;
== Creating a map ==&lt;br /&gt;
&lt;br /&gt;
This is not the Matrix.  You do not need to look at encoded maps.  The source code and most binary distributions come with the official graphical map editor. When compiling from source, remember to use the ''--enable-editor'' option when configuring, otherwise the map editor won't be compiled.  Using the map editor tends to be straightforward, judging from the feedback received from novice mapmakers.  However, if you do encounter problems locating or using the editor, please ask for help on the [http://www.wesnoth.org/forum forum].&lt;br /&gt;
&lt;br /&gt;
After the map is created, you may find it easier to make small tweaks by editing the textual map data directly.&lt;br /&gt;
&lt;br /&gt;
Making good, balanced, interesting maps is another task altogether.  ESR has addressed it in his [http://catb.org/~esr/wesnoth/campaign-design-howto.html Campaign Design How-To]&lt;br /&gt;
&lt;br /&gt;
== So now what? ==&lt;br /&gt;
&lt;br /&gt;
You've created an awesome map with the [[WesnothMapEditor]] and you're ready to test it out. But how can you do this? It's actually quite simple.&lt;br /&gt;
&lt;br /&gt;
==== Stand-alone maps ====&lt;br /&gt;
&lt;br /&gt;
If you just want to play the map, maybe against the computer or with a friend, all you have to do is save it into your custom maps folder (which should be the default place to save things in the editor, so really all you should need to do is save it). Then, when you launch the game and host a multiplayer game, the map should appear at the top of the map choices dialog. Simple, eh?&lt;br /&gt;
&lt;br /&gt;
For the curious: Saving a map file like this creates a stand-alone file that holds the map data. That file is by default saved in '''''userdata''/editor/maps/''', and maps in that location are added to the top of the multiplayer map selection list.&lt;br /&gt;
&lt;br /&gt;
==== The map_data key ====&lt;br /&gt;
&lt;br /&gt;
There's another way to use map data. The data for the map can be placed directly inside of a ''map_data'' tag in a '''[scenario]''' tag (see [[ScenarioWML]]). An example of map data encoded directly in a file might look like this:&lt;br /&gt;
        map_data=&amp;quot;border_size=1&lt;br /&gt;
        usage=map&lt;br /&gt;
        &lt;br /&gt;
        Gg, Ke, Gg, Gg&lt;br /&gt;
        Gg, Ce, Ce, Gg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that it's almost always more useful to have a separate map file that you reference in a scenario than putting the data directly into the scenario (not least because the editor works on such separate map files). If you have a saved map file that you want to use in your campaign, you'll have to include the map data like this:&lt;br /&gt;
&lt;br /&gt;
 map_data=&amp;quot;{@editor/''map_filename''}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that @editor here means that the map should be found in the '''''userdata''/editor/maps/''' directory. You'll need to specify something else if your map is in another location (for example, in a campaign, the maps should go into their own folder). The [[ScenarioWML]], [[BuildingCampaignsTheCampaignFile]] and [[PreprocessorRef]] pages all contain more detailed information about hos this works and how it should be done.&lt;br /&gt;
&lt;br /&gt;
== Discussion: Scenario File vs Standalone ==&lt;br /&gt;
&lt;br /&gt;
Campaign writers can't write campaigns without scenarios, so campaigns will always use the ''map_data'' key, either with the raw data in quotes or a preprocessor symbol {} pointing to the standalone file.&lt;br /&gt;
&lt;br /&gt;
Multiplayer mapmakers, however, '''have a choice'''.  If you want to place an object or unit on the map, you must create a scenario file starting with the '''[multiplayer]''' tag and containing the ''map_data'' key therein.  You lose the simplicity of the standalone map file, but you gain tremendous power.  Not only can you add units and objects, you can set allies, experience modifiers, add a map description, and add custom events (among other things).  The question, &amp;quot;How do I place an object on the map with the map editor&amp;quot; is such a common question that I am sorry this information is buried so deeply here.  But, now that you know you can seek out an example of a multiplayer map scenario file to use as an example.  The game comes with many maps of each type.  Check out [[BuildingMultiplayer]] for more information.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[ScenarioWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[BuildingScenariosShroudData]]&lt;br /&gt;
* [[TerrainCodesWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=StandardLocationFilter&amp;diff=28194</id>
		<title>StandardLocationFilter</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=StandardLocationFilter&amp;diff=28194"/>
		<updated>2009-02-05T05:35:30Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Added an in-depth clarification of how radius= works.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
From [[FilterWML]], this is the standard way of filtering on locations. The following attributes and sub-tags are permitted:&lt;br /&gt;
&lt;br /&gt;
* '''time_of_day''': filter matches only on a given time of day (one of lawful, chaotic or neutral).&lt;br /&gt;
* '''terrain''': comma separated list of terrains. (See also: [http://www.wesnoth.org/wiki/FilterWML#Filtering_Terrains Filtering Terrains]).&lt;br /&gt;
* '''x,y''': the same as in the unit filter; supports any range ([http://www.wesnoth.org/wiki/StandardLocationFilter#Notes_about_Coordinate_Usage notes])&lt;br /&gt;
* '''[filter]''': a [[StandardUnitFilter]]; if present a unit must also be there&lt;br /&gt;
* '''owner_side''': the side of the owner, if this location is an owned village.&lt;br /&gt;
* '''find_in''': name of an array or container variable; if present, the location will not match unless it is also found stored in the variable&lt;br /&gt;
* '''radius''': matches if any location within the radius matches this filter ([http://www.wesnoth.org/wiki/StandardLocationFilter#Notes_about_Radius_Usage notes])&lt;br /&gt;
* '''[filter_radius]''': a standard location filter; normally the radius extends outwards from matching locations one step at a time without checking any additional information-- however, if this tag is present, the radius will be restricted so that it can only expand outwards in the directions where it passes the given location filter&lt;br /&gt;
* '''[and]''': an extra location filter. Unless a location matches the [and] filter, then it will be excluded. ''Note: [and],[or],and [not] extra location filters are considered after everything else in the containing filter (except radius, which is considered last in 1.3.8 and greater); they are then processed in the order encountered.''&lt;br /&gt;
* '''[or]''': an extra location filter. If a location matches the [or] filter, then it will count as a match regardless of conditions in previous filters or the containing filter.&lt;br /&gt;
* '''[not]''': an extra location filter. If a location matches the [not] filter, then that location will be excluded.&lt;br /&gt;
* '''[filter_adjacent_location]''': a standard location filter; if present the correct number of adjacent locations must match this filter&lt;br /&gt;
** '''count''': a number, range, or comma separated range; default &amp;quot;1-6&amp;quot;&lt;br /&gt;
** '''adjacent''': a comma separated list of directions; default &amp;quot;n,ne,se,s,sw,nw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Notes about Coordinate Usage==&lt;br /&gt;
When specifying coordinates, the following keys are used:&lt;br /&gt;
* '''x''': the first coordinate&lt;br /&gt;
* '''y''': the second coordinate&lt;br /&gt;
&lt;br /&gt;
While some locations should only be one hex (like the starting position of a unit),&lt;br /&gt;
others filter over multiple hexes.&lt;br /&gt;
The following syntax is used to filter over multiple hexes:&lt;br /&gt;
&lt;br /&gt;
Dashes('''-''') are used to have the location be a range of hexes.&lt;br /&gt;
There must be values before and after the dash;&lt;br /&gt;
everything in between these numbers (inclusively) is part of the range.&lt;br /&gt;
&lt;br /&gt;
Commas(''',''') are used to separate coordinates into a list.&lt;br /&gt;
The '''x''' and '''y''' lists are then paired up, with each pair representing one hex or range.&lt;br /&gt;
&lt;br /&gt;
Note: although the ordering of locations in a list generally does not matter,&lt;br /&gt;
the action '''[move_unit_fake]''' takes in a list of hexes,&lt;br /&gt;
and moves an image onto each of those hexes in order.&lt;br /&gt;
&lt;br /&gt;
==Notes about Radius Usage==&lt;br /&gt;
:If you aren't storing any locations successfully, it may be because you put the radius or filters in the wrong place for them to combine correctly.&lt;br /&gt;
  [have_location]&lt;br /&gt;
  terrain=Gg^Vh&lt;br /&gt;
  [and]&lt;br /&gt;
    x=$x1&lt;br /&gt;
    y=$y1&lt;br /&gt;
    radius=1&lt;br /&gt;
  [/and]&lt;br /&gt;
  [/have_location]&lt;br /&gt;
Note that the use of [and] here causes the radius to have a very different meaning. Normally, all of the criteria besides radius are checked, producing a set of hexes to which the radius is applied. This means, for example, that if you're trying to find &amp;quot;a hex without a unit on it within 5 hexes of (15, 23)&amp;quot;, the code:&lt;br /&gt;
  [have_location]&lt;br /&gt;
  x,y=15,23&lt;br /&gt;
  radius=5&lt;br /&gt;
  [not]&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
  [/not]&lt;br /&gt;
  [have_location]&lt;br /&gt;
will not work! First, it looks for a hex with x=15, y=23 without a unit on it. Then, it returns that hex and all hexes within 5 of it. If (15, 23) happens to be occupied, then it will return no hexes, because &amp;quot;all hexes within 5 hexes of (no hexes)&amp;quot; is still &amp;quot;no hexes&amp;quot;. Instead, put an [and] around the x,y and radius requirements, and it will separately find &amp;quot;(15, 23) and all hexes within 5 of it&amp;quot; and &amp;quot;each of those hexes that doesn't have a unit on it&amp;quot;, producing the desired result.&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=28190</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=28190"/>
		<updated>2009-02-04T12:25:31Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Fixed extra ' after moveto&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== The [event] tag ==&lt;br /&gt;
&lt;br /&gt;
This tag is a subtag of the [scenario], [unit] and [era] tags which is used to describe a set of actions which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer], [tutorial] and [test]), the event only occurs in that scenario. When used in a [unit] type definition, the event will occur in all scenarios in which a unit of that type appears in. When used in an [era], the event will occur in any scenario which is played using that era.&lt;br /&gt;
&lt;br /&gt;
Keys and tags that describe when the event should trigger:&lt;br /&gt;
* '''name''': this is not like a normal 'name' key. It is a basic description of when the event will trigger. {{DevFeature}} '''name''' can accept a list of commas separated descriptions for which the event must be triggered. Example: '''name= attacker_misses, defender_misses'''. Note that unless you use ''first_time_only=no'', the event will fire only once, not once for each listed type.&lt;br /&gt;
* '''prestart''': the event is triggered before a scenario 'starts' -- before anything is shown on the screen at all. You can use this event to set up things like village ownership. For things displayed on-screen such as character dialog, use '''start'''.&lt;br /&gt;
* '''start''': this event triggers after the map is shown but before the scenario begins&lt;br /&gt;
* '''new turn''': this event triggers whenever the last player ends their turn. See also '''first_time_only=no'''. When the last player ends their turn, before any events of this type trigger, the value of the WML variable '''turn_number''' is set to the number of the turn that is beginning.&lt;br /&gt;
* '''side turn''': this event triggers when a side is about to start its turn. Before events of this type trigger, the value of the WML variable '''side_number''' is set to the number of the side of the player about to take their turn. This is before any healing takes place for that side, before calculating income, and before restoring unit movement and status.&lt;br /&gt;
* '''turn refresh''': this event triggers just before a side is taking control after healing, calculating income, and restoring unit movement and status.&lt;br /&gt;
* '''turn X''': (for X some number) this event triggers at the start of turn ''X''. ''X'' cannot be 1.&lt;br /&gt;
* '''time over''': this event triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
* '''enemies defeated''': this event triggers when all units with '''canrecruit=yes''' (i.e. all leaders) not allied with side 1 are killed.&lt;br /&gt;
* '''victory''': in this scenario, any tag of the form '''[endlevel] result=victory [/endlevel]''' will be automatically preceded by all actions in this tag. It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:n&amp;quot; command. Scenarios where key units are picked up before the victory, or where some action chosen earlier determines which map to advance to, make it hard to quickly test scenarios in a campaign. (See also [endlevel], [[DirectActionsWML]])&lt;br /&gt;
* '''defeat''': in this scenario, any tag of the form '''[endlevel] result=defeat [/endlevel]''' will be automatically preceded by all actions in this tag. (See also [endlevel], [[DirectActionsWML]])&lt;br /&gt;
* '''ai turn''': is triggered just before the AI is invoked for a side. This is called after ''side turn'', and thus the WML variable '''side_number''' still holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
Filters can be applied to the following event triggers (see [[FilterWML]]; see also below). The actions specified in the event tag will be executed only if the filter returns true. &lt;br /&gt;
These event triggers are all actions by units ('''moveto''', '''attack''') or things that happen to units ('''recruit''', '''advance'''). When one of these events is triggered, the position of the active unit (referred to as the '''primary unit''') is stored in the variables '''x1''' and '''y1''' and the position of any unit that primary unit does something to is stored in the variables '''x2''' and '''y2''' (this unit is referred to as the '''secondary unit''' below). '' These units are also automatically stored in the variables 'unit' and 'second_unit' as if they had been stored using the '''[store_unit]''' tag. see [[SingleUnitWML]]&lt;br /&gt;
&lt;br /&gt;
* '''moveto''': triggers after the primary unit moves. Typically this is used when the primary unit gets to a particular location and a filter for the location of the primary unit is included; remember that this is the location that the primary unit lands on, not the location it started on or any location it travels on.&lt;br /&gt;
* '''sighted''': this event triggers when the primary unit becomes visible to the secondary unit in particular after not being visible to the secondary unit's side (so if the secondary unit's side doesn't have shroud or fog, the event never triggers). This happens both when the primary unit moves into view during its turn, and when the secondary unit moves to a location where it can see the primary unit. (This editor hasn't tested whether the event triggers multiple times if the primary unit moves into view of multiple units at once, or if not, which one gets chosen to be the secondary unit here.) (Note: it appears that when a sighted event is triggered because an enemy unit moves into your field of view, the game engine cannot determine which unit (on your side) sees the unit that moved, and so it fires a ''name=sighted'' event without setting ''$second_unit''. This means that, for example, using ''speaker=second_unit'' inside a message tag may fail.)&lt;br /&gt;
* '''attack''': this event triggers when the primary unit attacks the secondary unit.&lt;br /&gt;
* '''attacker_hits''': this event triggers when the the primary unit (the attacker) hits the secondary unit (the defender). {{DevFeature}} A variable '''$damage_inflicted''' allow to check the number of hitpoints inflicted by the attacker.&lt;br /&gt;
* '''attacker_misses''': same as ''attacker_hits'', but is triggered when the attacker misses.&lt;br /&gt;
* '''defender_hits''': this event triggers when the primary unit (the attacker) is hit in retaliation by the secondary unit (the defender). {{DevFeature}} A variable '''$damage_inflicted''' allow to check the number of hitpoints inflicted by the defender.&lt;br /&gt;
* '''defender_misses''': same as ''defender_hits'', but is triggered when the defender misses.&lt;br /&gt;
* '''attack_end''': is similar to '''attack''', but is instead triggered after the fight, not before. Note that if either unit is killed during the fight, this event triggers before any '''die''' events.&lt;br /&gt;
* '''stone''': this event triggers when the primary unit is hit by an attack with the 'stones' ability (See ''stones'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'stones' ability).&lt;br /&gt;
* '''last breath''': this event triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered.&lt;br /&gt;
* '''die''': this event triggers when the primary unit is killed by the secondary unit.&lt;br /&gt;
* '''capture''': this event triggers when the primary unit captures a village. The village may have been previously neutral, or previously owned by another side; merely moving into your own villages does not constitute a capture.&lt;br /&gt;
* '''recruit''': this event triggers when the primary unit is recruited or recalled. (That is, when a unit is recruited or recalled, it will trigger this event and this event's filter will filter that unit.). {{DevFeature}} The '''recruit''' will no longer triggers on recalls.&lt;br /&gt;
* '''prerecruit''': this event triggers when the primary unit is recruited, but before it is displayed. {{DevFeature}} The '''prerecruit''' will no longer triggers on recalls.&lt;br /&gt;
* '''advance''': this event triggers just before the primary unit is going to advance to another unit.&lt;br /&gt;
* '''post_advance''': this event triggers just after the primary unit has advanced to another unit.&lt;br /&gt;
* '''select''': triggers when the primary unit is selected. ''Note: in networked multiplayer, these events are only executed by the client on which the event is triggered, leading to out of sync errors if you modify the game state in the event.''&lt;br /&gt;
* '''menu item X''': triggers when a WML menu item with id=X is selected. ''Note: if the menu item has a [command], this event may be executed before or after the command; there is no guarantee.'' &lt;br /&gt;
* {{DevFeature}} '''prerecall''': triggers when a unit is recalled, but before it is displayed. This event is not trigger when a unit is recruit.&lt;br /&gt;
* {{DevFeature}} '''recall''': triggers after a unit is recalled. This event is not trigger when a unit is recruit.&lt;br /&gt;
* {{DevFeature}} other events with a custom name may be invoked from [fire_event]&lt;br /&gt;
* {{DevFeature}} '''consider attack''': triggers before the attack dialog is displayed.&lt;br /&gt;
* {{DevFeature}} '''unconsider attack''': triggers when canceling out of the attack dialog.&lt;br /&gt;
&lt;br /&gt;
An '''[allow_undo]''' tag anywhere within a moveto event will cancel any lack of undo functionality the event would have caused. Note that undo functionality will only move the unit back to its former location; it will not other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.&lt;br /&gt;
&lt;br /&gt;
The primary unit can be referred to as '''unit''' and the secondary unit can be referred to as '''second_unit''' in [message] tags using the speaker= key. For example:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
 name=die&lt;br /&gt;
   [message]&lt;br /&gt;
   speaker=second_unit&lt;br /&gt;
   message=&amp;quot;Hahaha, I finally killed you!&amp;quot;&lt;br /&gt;
   [/message]&lt;br /&gt;
 &lt;br /&gt;
   [message]&lt;br /&gt;
   speaker=unit&lt;br /&gt;
   message=&amp;quot;It's not over yet! I'll come back to haunt you!&amp;quot;&lt;br /&gt;
   [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
These keys and tags are more complex ways to filter when an event should trigger:&lt;br /&gt;
* '''first_time_only''': whether the event should be removed from the scenario after it is triggered.  Default is '''yes'''.&lt;br /&gt;
* '''[filter]''': the event will only trigger if the primary unit matches this filter.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
* '''[filter_second]''': is like [filter], but for the secondary unit.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
* '''[special_filter]''' and '''[special_filter_second]''': can be used to set some additional filtering criteria for the primary unit and the secondary unit that are not generally available in a standard unit filter. Can be used in events ''attack'', ''attacker_hits'', ''attacker_misses'', ''defender_hits'', ''defender_misses'' and ''attack_end''. ({{DevFeature}} renamed to [filter_attack] and [filter_second_attack])&lt;br /&gt;
** '''weapon''': the name of the weapon used. ({{DevFeature}} renamed to '''name''')&lt;br /&gt;
** {{DevFeature}} '''range''': the ranged of the weapon used. &lt;br /&gt;
&lt;br /&gt;
=== Actions triggered by [event] ===&lt;br /&gt;
&lt;br /&gt;
After the trigger conditions have been met, all action tags within the [event] tag are executed in the order they are written in.&lt;br /&gt;
&lt;br /&gt;
There are 3 main types of actions:&lt;br /&gt;
* direct actions ([[DirectActionsWML]]) which have a direct effect on gameplay&lt;br /&gt;
* display actions ([[InterfaceActionsWML]]) which show something to the user&lt;br /&gt;
* internal actions ([[InternalActionsWML]]) which are used by WML internally&lt;br /&gt;
&lt;br /&gt;
Several actions use standard filters to find out which units&lt;br /&gt;
to execute the command on.  These are denoted by the phrases&lt;br /&gt;
&amp;quot;standard unit filter&amp;quot; and &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Nested events ===&lt;br /&gt;
&lt;br /&gt;
There is 1 special type of action: event creation.  By placing an '''[event]''' tag inside another '''[event]''' tag, the nested event is created when the nested event is encountered (when executing the contents of the event).  For example, you could create a portal that opens on turn 10.  The outer event executes on turn 10, creating the nested moveto event, which executes when a player steps on a certain spot.  An equivalent way of doing this would be to a single moveto event with an '''[if]''' statement to check for turn number, but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[if]''' statements.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         # moving to 5,8 will trigger this event only on turn 10 and after&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Variable substitution for a nested event can happen either when the event is spawned, or when it is triggered. This is controlled with the key ''delayed_variable_substitution'' (default yes). Consider the following two examples:&lt;br /&gt;
&lt;br /&gt;
 # This makes the message display the turn on which the moveto happens,&lt;br /&gt;
 # because the variable substitution for the moveto event will be done&lt;br /&gt;
 # when the event triggers.&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 2&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=yes&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;}&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
 # This makes the message on moveto always display as &amp;quot;Turn 2&amp;quot;, because&lt;br /&gt;
 # the variable substitution is done when the moveto event is spawned,&lt;br /&gt;
 # not when it eventually triggers.&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 2&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=no&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;}&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Another way to mark an individual variable to be substituted later (when the event is triggered) is to  write it as &amp;quot;$|var&amp;quot; instead of the normal &amp;quot;$var&amp;quot;. By combining this with delayed_variable_substitution=no you can have some variables in the nested event be substituted immediately when the event is spawned and some variables substituted when the event triggers.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[DirectActionsWML]]&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[FilterWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=28165</id>
		<title>InterfaceActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=28165"/>
		<updated>2009-02-03T00:59:48Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Clarified language of [hide_unit] tag: you can have multiple hidden units, but you have to use multiple [hide_unit] tags to achieve this.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Interface actions ==&lt;br /&gt;
&lt;br /&gt;
Interface actions are actions that do not have an effect on gameplay;&lt;br /&gt;
instead, they show something to the player.  The main interface tags&lt;br /&gt;
are '''[message]''' and '''[objectives]''', but several other tags affect&lt;br /&gt;
the interface also.&lt;br /&gt;
&lt;br /&gt;
== [message] ==&lt;br /&gt;
The most commonly used interface action is [message], which displays a message to the user in a dialog box. It can also be used to take input from the user.&lt;br /&gt;
&lt;br /&gt;
The following key/tags are accepted for [message]:&lt;br /&gt;
* [[StandardUnitFilter]]: the unit whose profile and name are displayed. If no unit matching this filter is found, the message is not displayed (The unit has probably been killed).&amp;lt;br&amp;gt;'''[message]''' elements should be constructed so that it is either guaranteed that a certain unit is alive, or so that dialog flows smoothly even if the message isn't displayed.&lt;br /&gt;
&lt;br /&gt;
* '''speaker''': an alternative to standard unit filter. You may specify as the value of the speaker attribute a unit description or any of the following special values:&lt;br /&gt;
** '''narrator''': the dialog box is displayed without a caption for the unit speaking or a unit image&lt;br /&gt;
** '''unit''': the primary unit for the event is speaking&lt;br /&gt;
** '''second_unit''': the secondary unit for the event is speaking&lt;br /&gt;
&lt;br /&gt;
* '''message''': (translatable) the text to display to the right of the image. ''message'' is sometimes multiple lines; if it is, be sure to use quotes(''' ' ''' or ''' &amp;quot; ''')&lt;br /&gt;
* '''side_for''': (default: all sides) comma-separated list of sides for who message is shown.&lt;br /&gt;
* '''image''': (default: profile image of speaker) the image to display next to the message.&lt;br /&gt;
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed.&lt;br /&gt;
* '''duration''': (default: 10) the minimum number of frames for this message to be displayed. (A frame lasts about 30 milliseconds.) During this time any dialog decisions will be disregarded.&lt;br /&gt;
* '''sound''': a sound effect (wav file) to play as the message is displayed. This can be a comma-separated list, from which one will be randomly chosen.&lt;br /&gt;
* '''[option]''': zero or more '''[option]''' elements may be present. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option.&lt;br /&gt;
** ''message'' (translatable) the text displayed for the option (see [[DescriptionWML]])&lt;br /&gt;
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[InternalActionsWML]])&lt;br /&gt;
** '''[command]''': an element containing actions which are executed if the option is selected.&lt;br /&gt;
* '''[text_input]''': there can be only one [text_input] tag. this adds a text input field to the message.&lt;br /&gt;
** '''variable''': the variable that the user's input will be written to&lt;br /&gt;
** '''label''': a text label to the left of the input field&lt;br /&gt;
** '''max_chars''': the maximum number of characters that may be typed into the field&lt;br /&gt;
** '''text''': text that is written into the field in the beginning&lt;br /&gt;
* note that '''[option]''' and '''[text_input]''' can only be used in moveto events in MP, otherwise they cause OOS&lt;br /&gt;
&lt;br /&gt;
Text formatting options for '''[message]'''. These can also be used in unit names (user_description), objectives, and such.&lt;br /&gt;
* A tilde (~) as the first character causes the line to be boldfaced.&lt;br /&gt;
* An at symbol (@) as the first character causes the line to be green, as done with victory conditions.&lt;br /&gt;
* A pound symbol (#) as the first character causes the line to be red, as done with defeat conditions.&lt;br /&gt;
* An asterisk (*) as the first character causes the line to be bigger.&lt;br /&gt;
* A backquote (`) as the first character causes the line to be smaller.&lt;br /&gt;
* If used, the caption key text is boldfaced.&lt;br /&gt;
* An RGB colour code in the beginning causes the line to be the given colour. This can still be preceded by the above characters. Example: ''message=_&amp;quot;&amp;lt;255,0,0&amp;gt;Red!&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
== [objectives] ==&lt;br /&gt;
The other tag used for plot development is '''[objectives]'''.&lt;br /&gt;
The '''[objectives]''' tag overwrites any previously set objectives,&lt;br /&gt;
and displays text which should describe the objectives of the scenario.&lt;br /&gt;
Scenario objectives are displayed on the player's first turn after the tag is used,&lt;br /&gt;
or as part of the event if it triggers during that player's turn.&lt;br /&gt;
Objectives can also be accessed at any time in a scenario using the&lt;br /&gt;
&amp;quot;Scenario Objectives&amp;quot; game menu option, making this tag useful for&lt;br /&gt;
scenario-specific information that the player may need to refer to during play.&lt;br /&gt;
&lt;br /&gt;
This tag renders the ''objectives'' attribute of [scenario] obsolete (see ''objectives'', [[ScenarioWML]]).&lt;br /&gt;
Instead of using ''objectives'', use '''[objectives]''' to set scenario objectives inside a prestart event.&lt;br /&gt;
It can also be used to overwrite the starting objectives mid-scenario.&lt;br /&gt;
&lt;br /&gt;
Attributes of '''[objectives]''':&lt;br /&gt;
* '''side''': Default '0'. The side to set the objectives for. A value of 0 sets objectives for all sides.&lt;br /&gt;
* '''summary''': Displayed first in the objectives text, this should describe the basic objective for the overall scenario.  Can be omitted.&lt;br /&gt;
* '''note''': Displayed last in the objectives text, this is sometimes used for hints or additional information.  Can be omitted.&lt;br /&gt;
* '''victory_string''': Default ' _ &amp;quot;Victory:&amp;quot;', this text precedes the victory objectives.&lt;br /&gt;
* '''defeat_string''': Default ' _ &amp;quot;Defeat:&amp;quot;', this text precedes the defeat objectives.&lt;br /&gt;
* '''silent''': Default: not present. If set to &amp;quot;yes&amp;quot;, the objectives are silently changed. Else, they will be shown to the user when appropriate.&lt;br /&gt;
&lt;br /&gt;
Tags of '''[objectives]''':&lt;br /&gt;
* '''[objective]''': describes a win or loss condition. Most scenarios have multiple win or loss conditions, so use a separate [objective] subtag for each line; this helps with translations.&lt;br /&gt;
** '''description''': text for the specific win or loss condition.&lt;br /&gt;
** '''condition''': The color and placement of the text. Values are 'win'(colored green, placed after ''victory_string'') and 'lose'(colored red, placed after ''defeat_string'')&lt;br /&gt;
&lt;br /&gt;
=== Macros ===&lt;br /&gt;
There are a few predefined macros for Objectives that you can use to shorten the code. '''{SET_OBJECTIVES}''', '''{VICTORY_CONDITION}''' and '''{DEFEAT_CONDITION}'''. There are all used together. For more information look [http://www.wesnoth.org/misc/macro-reference.xhtml here]&lt;br /&gt;
&lt;br /&gt;
== [set_menu_item] ==&lt;br /&gt;
This tag is used to add a custom option in the right-click context menu which can then be used to trigger arbitrary WML commands.&lt;br /&gt;
&lt;br /&gt;
* '''id''': the unique id for this menu item. If a menu item with this id already exists, it allows you to set specific changes to that item.&lt;br /&gt;
* '''description''': the in-game text that will appear for this item in the menu.&lt;br /&gt;
* '''image''': the image to display next to this item.&lt;br /&gt;
* '''needs_select''': if ''yes'' (default ''no''), then the latest select event (see [[EventWML]]) that triggered before this menu item was chosen will be transmitted over the network before this menu item action will be. This only has any effect in networked multiplayer, and is intended to allow more elaborate menu item behaviour there without causing out of sync errors. If you don't know what this means, just leave it false.&lt;br /&gt;
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[InternalActionsWML]]) within evaluates to true. When this is evaluated, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked, so it's possible to for example only enable the option on empty hexes or on a particular unit.&lt;br /&gt;
* '''[filter_location]''': contains a location filter similar to the one found inside Single Unit Filters (see [[FilterWML]]). The menu item will only be available on matching locations.&lt;br /&gt;
* '''[command]''': contains the WML actions to be executed when the menu item is selected. Again, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked on.&lt;br /&gt;
&lt;br /&gt;
== Other interface tags ==&lt;br /&gt;
&lt;br /&gt;
The following tags are also action tags:&lt;br /&gt;
* '''[item]''': makes a graphical item appear on a certain hex. Note this only places the graphics for an item. It does not make the item do anything. Use a moveto event to make moving onto the item do something. &amp;lt;tt&amp;gt;''('''Hint:''' There are a number of predefined items that are used in various campaigns that you can make use of. You can find [http://www.wesnoth.org/macro-reference.xhtml#file:items.cfg a list of them] if you look into the items.cfg file in the wesnoth install directory (under /data/core/macros))''&amp;lt;/tt&amp;gt;&lt;br /&gt;
** '''x''', '''y''': the location to place the item.&lt;br /&gt;
** '''image''': the image (in ''images/'' as .png) to place on the hex.&lt;br /&gt;
** '''halo''': an image to place centered on the hex. Use this instead of ''image'' if the image is bigger than the hex.&lt;br /&gt;
** '''team_name''' {{DevFeature}}: name of the team for which the item is to be displayed (hidden for others). For multiple teams just put all the names in one string, for example separated by commas.&lt;br /&gt;
** '''visible_in_fog''' {{DevFeature}}: whether the item should be visible through fog or not. Default yes.&lt;br /&gt;
* '''[removeitem]''': removes any graphical items on a given hex&lt;br /&gt;
** '''x''', '''y''': the hex to remove items off&lt;br /&gt;
** '''image''' {{DevFeature}} if specified, only removes the given image item&lt;br /&gt;
* '''[print]''': displays a message across the screen. The message will disappear after a certain time.&lt;br /&gt;
** '''text''': (translatable) the text to display.&lt;br /&gt;
** '''size''': (default=12) the pointsize of the font to use&lt;br /&gt;
** '''duration''': (default=50) the length of time to display the text for. This is measured in the number of 'frames'. A frame in Wesnoth is usually displayed for around 30ms.&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color to display the text in. Values vary from 0-255.&lt;br /&gt;
* '''[move_unit_fake]''': moves an image of a unit along a certain path on the map. The path does not need to be a continuous list of adjacent hexes, so for example only the start and end points can be given, in which case the straightest line between those points will be calculated and used.&lt;br /&gt;
** '''type''': the type of the unit whose image to use&lt;br /&gt;
** '''x''': a comma-separated list of x locations to move along&lt;br /&gt;
** '''y''': a comma-separated list of y locations to move along (x and y values are matched pairs)&lt;br /&gt;
** '''side''': the side of the fake unit, used for team-coloring the fake unit&lt;br /&gt;
* '''[hide_unit]''': makes the given unit become invisible. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Each '''[hide_unit]''' tag only hides one unit.&lt;br /&gt;
** '''x''', '''y''': location of the unit to be hidden. (NOT a standard unit filter! Just x and y.)&lt;br /&gt;
* '''[unhide_unit]''': stops the currently hidden unit from being hidden.&lt;br /&gt;
* '''[scroll]''': Scroll a certain number of pixels in a given direction. Useful for earthquake/shaking effects.&lt;br /&gt;
** '''x''', '''y''': the number of pixels to scroll along the x and y axis&lt;br /&gt;
* '''[scroll_to]''': Scroll to a given hex&lt;br /&gt;
** '''x''', '''y''': the hex to scroll to&lt;br /&gt;
** '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''true'' (don't scroll to fog) and ''false'' (scroll even to fog), with ''false'' as the default.&lt;br /&gt;
* '''[scroll_to_unit]''' Scroll to a given unit&lt;br /&gt;
** [[StandardUnitFilter]]&lt;br /&gt;
** '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''true'' (don't scroll to fog) and ''false'' (scroll even to fog), with ''false'' as the default.&lt;br /&gt;
* '''[sound]''': Plays a sound&lt;br /&gt;
** '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg)&lt;br /&gt;
** '''repeat''': repeats the sound for a specified additional number of times (default=0)&lt;br /&gt;
* '''[sound_source]''': Creates a sound source. &amp;quot;Sound sources&amp;quot; is a general name for a mechanism which makes possible for map elements to emit sounds according to some rules, where &amp;quot;map elements&amp;quot; can be specific locations or terrain types. For now, only sound sources tied to locations are supported.&lt;br /&gt;
** '''id''': a unique identification key of the sound source&lt;br /&gt;
** '''sounds''': a list of comma separated, randomly played sounds associated with the sound source&lt;br /&gt;
** '''delay''': a numerical value (in milliseconds) of the minimal delay between two playbacks of the source's sound if the source remains visible on the screen; if one scrolls out and back in, the source will be considered as ready to play&lt;br /&gt;
** '''chance''': a percentage (a value from 0 to 100) describing the chance of the source being activated every second after the delay has passed or when the source's location appears on the screen (note that it cannot play more than one file at the same time)&lt;br /&gt;
** '''check_fogged''': possible values &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; - if true the source will not play if its locations are fogged/shrouded&lt;br /&gt;
** '''x,y''': a [[StandardLocationFilter]] for the locations associated with the sound source&lt;br /&gt;
** {{DevFeature}}&lt;br /&gt;
*** '''fade_range''' (default = 3): distance in hexes that determines a &amp;quot;circular&amp;quot; area around the one specified by '''full_range''' where sound volume fades out linearly&lt;br /&gt;
*** '''full_range''' (default = 14): distance in hexes that determines a &amp;quot;circular&amp;quot; area where source plays with full volume, relative to screen center&lt;br /&gt;
*** '''loop''': number of times a sound sample should be looped if it stays visible. -1 means infinite (~65000)&lt;br /&gt;
* '''[remove_sound_source]''': Removes a previously defined sound source.&lt;br /&gt;
** '''id''': the identification key of the sound source to remove&lt;br /&gt;
* '''[music]''': Switches to playing different music&lt;br /&gt;
** '''name''': the filename of the music to play (in ''music/'' as .ogg)&lt;br /&gt;
** see [[MusicListWML]] for the correct syntax&lt;br /&gt;
* '''[colour_adjust]''': tints the colour of the screen.&lt;br /&gt;
** '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each colour&lt;br /&gt;
* '''[delay]''': pauses the game&lt;br /&gt;
** '''time''': the time to pause in milliseconds&lt;br /&gt;
* '''[redraw]''': redraws the screen (this normally isn't done during events, although some of the other interface actions cause the screen or parts of it to be redrawn).&lt;br /&gt;
** '''side''': if used, recalculates fog and shroud for that side. Useful if you for example spawn friendly units in the middle of an event and want the shroud to update accordingly (otherwise units that spawn inside fog would remain invisible for the duration of the event, since the fog would not automatically get cleared around them).&lt;br /&gt;
* '''[unit_overlay]''': sets an image that will be drawn over a particular unit, and follow it around&lt;br /&gt;
** '''x''', '''y''': the location of the unit to overlay on&lt;br /&gt;
** '''image''': the image to place on the unit&lt;br /&gt;
* '''[remove_unit_overlay]''': removes a particular overlayed image from a unit&lt;br /&gt;
** '''x''', '''y''': the location of the unit to remove an overlay from&lt;br /&gt;
** '''image''': the image to remove from the unit&lt;br /&gt;
* '''[animate_unit]''': uses the custom animation of a unit to animate it on screen (if the unit has the corresponding animation)&lt;br /&gt;
** '''flag''': the key to find the good custom animation in the unit description see the '''[extra_anim]''' description in [[AnimationWML]] Standar anims can be triggered with the following keywors ''leading recruited standing idling levelin levelout healing healed poisoned movement defend attack death victory pre_teleport post_teleport''&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]] see [[FilterWML]] by default, the unit at the event location will be animated. You can use this tag to choose any other unit to animate&lt;br /&gt;
** '''[primary_attack]''': if this tag is not present, the filter for animation will be triggered with no attack. If it is here, all attacks from the unit will be filtered, and a matching one will be used to filter the animation&lt;br /&gt;
** '''[secondary_attack]''': same for the second attack&lt;br /&gt;
** '''hits''': the hit type to filter unit on&lt;br /&gt;
** '''text''': a text to hover during the animation&lt;br /&gt;
** '''red''': red value for the text color&lt;br /&gt;
** '''green''': green value for the text color&lt;br /&gt;
** '''blue''': blue value for the text color&lt;br /&gt;
** '''with_bars''': whether to display the status bars or not.&lt;br /&gt;
** '''[animate]''': a sub block with the same syntax as the '''[animate_unit]''' except that the '''[filter]''' block is mandatory to find the unit. This block will find and animate another unit simultaneously&lt;br /&gt;
** '''[facing]''': a [[StandardLocationFilter]] specifying what direction the unit should be facing when animated&lt;br /&gt;
* '''[label]''' places a label on the map.&lt;br /&gt;
** '''x''', '''y''': the location of the label&lt;br /&gt;
** '''text''': what the label should say&lt;br /&gt;
** '''team_name''': if specified, the label will only be visible to the given team.&lt;br /&gt;
** '''visible_in_fog''' {{DevFeature}}: whether the label should be visible through fog or not. Default yes.&lt;br /&gt;
* '''[deprecated_message]''' shows a deprecated message in the message area, this feature is only intended to be used to warn about deprecated macros in mainline. The message is not translatable.&lt;br /&gt;
** '''message''': the message to show.&lt;br /&gt;
* '''[debug_message]''': outputs a message to Wesnoth's console output. Intended for campaign designers to output silent text to the console, without annoying the player; then, that text might contain information useful for later bug-reporting. Information is actually output depending on the minimum severity (''log level'') for the '''notifs''' log domain. {{DevFeature}} This tag is deprecated since 1.5.8, and the '''notifs''' log domain has been removed.&lt;br /&gt;
** '''message''': the message to show&lt;br /&gt;
** '''logger''': the Wesnoth engine output logger that should catch the text; this might be 'err' (the errors log level), 'warn'/'wrn' (the warnings log level) or anything else (the information log level). Not all information will be displayed depending on the log level chosen when starting Wesnoth.&lt;br /&gt;
* '''[wml_message]''' {{DevFeature}}: in 1.5.7+svn/1.5.8 and later, this replaces [debug_message] and works identically, except that the log domain for it is '''wml''', and the '''debug/dbg''' log level is available for use with the '''logger''' attribute. Depending on the current log level ('''error''' by default), which may be changed with the in-game :log command, or the --log-&amp;lt;level&amp;gt;=wml command line switch, the messages are echoed to the in-game  chat.&lt;br /&gt;
&lt;br /&gt;
== Useful Macros ==&lt;br /&gt;
There are some predefined macros that you find useful for interface actions. You can find a complete list along with a detailed explanation of how they work [http://www.wesnoth.org/macro-reference.xhtml here].&lt;br /&gt;
* '''{FLOATING_TEXT}''' Float some text over a unit similar to the damage numbers.&lt;br /&gt;
* '''{HIGHLIGHT_UNIT}''' Highlight a unit on the map. Use this to show important units&lt;br /&gt;
* '''{HIGHLIGHT_IMAGE}''' Places and highlights an image on the map. Use this to show important items or locations&lt;br /&gt;
* '''{SET_IMAGE}''' Places an image on the map which has no other function.&lt;br /&gt;
* '''{TREMOR}''' Creates a tremor like screenshake&lt;br /&gt;
** {{DevFeature}} This macro has been deprecated in favor of '''{QUAKE &amp;lt;soundfile&amp;gt;}'''. Thus, it is equivalent to '''{QUAKE (rumble.ogg)}''', although '''cave-in.ogg''' has been added as a much better alternative for most situations.&lt;br /&gt;
* '''{FLASH_WHITE}''' Flash the screen white momentarily. You can also replace WHITE with RED, BLUE or GREEN for a different colour.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[DirectActionsWML]]&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=28121</id>
		<title>DirectActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=28121"/>
		<updated>2009-01-30T00:51:13Z</updated>

		<summary type="html">&lt;p&gt;Solsword: Added dev version exception to the remove_shroud note&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Direct actions ==&lt;br /&gt;
&lt;br /&gt;
Direct actions are actions that have a direct effect on gameplay.&lt;br /&gt;
&lt;br /&gt;
The following tags are actions:&lt;br /&gt;
* '''[endlevel]''': ends the scenario.&lt;br /&gt;
** '''result''': before the scenario is over, all events with ''name=result'' are triggered.  The message ''result_message'' with the heading ''result_heading'' (see [[LanguageWML]]) are displayed.  If ''result=victory'', the player progresses to the next level; if ''result=defeat'', the game returns to the main menu.  These last two are rarely used: ''result=continue'' behaves identically to ''result=victory'' except the player's gold is not reduced to 80%, and it does not bring up a &amp;quot;Victory&amp;quot; message or the gold changing message (since it doesn't change); ''result=continue_no_save'' works similarly, except the player is not asked whether to save the game, and is taken directly to the next scenario without any messages.  Unless ''result=defeat'', the following keys can also be used:&lt;br /&gt;
** '''bonus''': whether the player should get bonus gold (maximum possible gold that could have been earned by waiting the level out). The default is bonus=yes.&lt;br /&gt;
** '''carryover_report''' {{DevFeature}}: whether the player should receive a summary of the scenario outcome, the default is carryover_report=yes.&lt;br /&gt;
** '''save''' {{DevFeature}}: whether a start-of-scenario save should be created for the next scenario, the default is save=yes.&lt;br /&gt;
** '''linger_mode''' {{DevFeature}}: whether the game should switch to linger_mode before advancing to the next scenario, the default is linger_mode=yes.&lt;br /&gt;
** '''next_scenario''': (default specified in '''[scenario]''' tag) the ID of the next scenario that should be played.  All units that side 1 controls at this point become available for recall in ''next_scenario''.&lt;br /&gt;
** When the result is &amp;quot;victory&amp;quot; the following keys can be used:&lt;br /&gt;
*** '''carryover_percentage''' {{DevFeature}}: by default 80% of the gold is carried over to the next scenario, with this key the amount can be changed.&lt;br /&gt;
*** '''carryover_add''' {{DevFeature}}: if true the gold will be added to the starting gold the next scenario, if false the next scenario will start with the amount of the current scenario (after taxes) or the minimum in the next scenario. Default is false.&lt;br /&gt;
** '''music''' {{DevFeature}}: (default specified in '''[scenario]''' or '''[game_config]''' tags) a comma-separated list of music tracks from which one will be chosen and played once after any events related to the end of level result are executed; by default, victory_music is used on victory, and defeat_music on defeat.&lt;br /&gt;
** '''end_text''' {{DevFeature}}: Text that is shown centered in a black screen at the end of a campaign. Defaults to &amp;quot;The End&amp;quot;. Note that this has cumulative effects over the campaign - it persists even if the endlevel does not trigger the end of the campaign. See also [[CampaignWML]].&lt;br /&gt;
** '''end_text_duration''' {{DevFeature}}: Delay, in milliseconds, before displaying the game credits at the end of a campaign. In other words, for how much time '''end_text''' is displayed on screen. Defaults to 3500. Note that this has cumulative effects over the campaign - it persists even if the endlevel does not trigger the end of the campaign. See also [[CampaignWML]].&lt;br /&gt;
* '''[unit]''': places a unit on the map.  For syntax see [[SingleUnitWML]].&lt;br /&gt;
** {{Short Note:Predefined Macro|GENERIC_UNIT}}&lt;br /&gt;
** {{DevFeature}} '''to_variable''':  spawn directly into a variable instead of on the map.&lt;br /&gt;
* '''[recall]''': recalls a unit.  The unit is recalled free of charge, and is placed near the leader.&lt;br /&gt;
** [[StandardUnitFilter]]: the first matching unit will be recalled.  If no units match this tag is ignored.&lt;br /&gt;
** '''x,y''': the unit is placed here instead of next to the leader.&lt;br /&gt;
** '''show''': if not &amp;quot;no&amp;quot;, display the unit being recalled.&lt;br /&gt;
* '''[teleport]''': teleports a unit on map. {{Short Note:Predefined Macro|TELEPORT_UNIT}}&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] all units matching the filter will be teleported.&lt;br /&gt;
** '''x,y''': the position to teleport to.&lt;br /&gt;
** '''clear_shroud''': should shroud be cleared on arrival&lt;br /&gt;
** '''animate''': should a teleport animation be played (if the unit doesn't have a teleport animation, it will fade out/fade in)&lt;br /&gt;
* '''[terrain_mask]''': changes the terrain on the map.  See [[TerrainMaskWML]].&lt;br /&gt;
* '''[terrain]''': changes the terrain on the map.&lt;br /&gt;
** '''terrain''': the character of the terrain to use.  See [[TerrainCodesWML]] to see what letter a type of terrain uses.&lt;br /&gt;
** '''x,y''': the position (or range of positions) to change.&lt;br /&gt;
** {{DevFeature}} '''layer''': (overlay|base|both, default=both) only change the specified layer.&lt;br /&gt;
** {{DevFeature}} '''replace_if_failed''': (default=no) When replacing just one layer failed, try to replace the whole terrain. If '''terrain''' is an overlay only terrain, use the default_base as base layer. If the terrain has no default base, do nothing.&lt;br /&gt;
* '''[gold]''': give one side gold.&lt;br /&gt;
** '''amount''': the amount of gold to give.&lt;br /&gt;
** '''side''': (default=1) the number of the side to give the gold to.&lt;br /&gt;
* '''[unstore_unit]''': creates a unit from a game variable, and activates it on the playing field.  This must be a specific variable describing a unit, and may not be an array -- to unstore an entire array, iterate over it.  The variable is not cleared.  See also '''[store_unit]''', '''[while]''' and [clear_variable] in [[InternalActionsWML]]. Note units with a negative amount of hitpoints will be unstored with 1 hitpoint.&lt;br /&gt;
** '''variable''': the name of the variable.&lt;br /&gt;
** '''find_vacant''': whether the unit should be placed on the nearest vacant tile to its specified location.  If this is set to 'no'(default), then any unit on the same tile as the unit being unstored will be destroyed.&lt;br /&gt;
** '''text''': (translatable) floating text to display above the unit, such as a damage amount&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color to display the text in. Values vary from 0-255. You may find it convenient to use the {COLOR_HARM} or {COLOR_HEAL} macro instead. (Use {COLOR_HARM} or {COLOR_HEAL} instead of the whole red,green,blue= line.)&lt;br /&gt;
** '''advance''': if the XP has been modified then there will be tried to advance the unit, default true. &lt;br /&gt;
** {{DevFeature}} '''x''' ,'''y''': override unit location&lt;br /&gt;
* '''[allow_recruit]''': allows a side to recruit units it couldn't previously recruit.&lt;br /&gt;
** '''type''': the types of units that the side can now recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that is being allowed to recruit the units.&lt;br /&gt;
* '''[disallow_recruit]''': prevents a side from recruiting units it could previously recruit.&lt;br /&gt;
** '''type''': the types of units that the side can no longer recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that may no longer recruit the units.&lt;br /&gt;
* '''[set_recruit]''': sets the units a side can recruit.&lt;br /&gt;
** '''recruit''': the types of units that the side can now recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that is having its recruitment set.&lt;br /&gt;
* '''[modify_side]''': modifies some details of a given side in the middle of a scenario.  '''The following listed properties are the only properties that [modify_side] can affect!'&lt;br /&gt;
** '''side''': (default=1) the number of the side that is to be changed.&lt;br /&gt;
** '''income''': the income given at the begining of each turn.&lt;br /&gt;
** '''team_name''': the team in which the side plays the scenario.&lt;br /&gt;
** '''user_team_name''': a translatable string representing the team's description. This has no effect on alliances. Defaults to ''team_name''.&lt;br /&gt;
** '''gold''': the amount of gold the side owns.&lt;br /&gt;
** '''village_gold''': the income setting per village for the side.&lt;br /&gt;
** '''controller''': the identifier string of the side's controller. Uses the same syntax of the ''controller'' key in the [[SideWML|[side]]] tag.&lt;br /&gt;
** '''fog''': a boolean string (yes/no) describing the status of Fog for the side.&lt;br /&gt;
** '''shroud''': a boolean string describing the status of Shroud for the side.&lt;br /&gt;
** {{DevFeature}} '''[ai]''': replaces a side's AI parameters with the new specified ones. Uses the same syntax described in [[AiWML]].&lt;br /&gt;
* '''[modify_turns]''': modifies the turn limit in the middle of a scenario.&lt;br /&gt;
** '''value''': the new turn limit.&lt;br /&gt;
** '''add''': if used instead of ''value'', specifies the number of turns to add to the current limit (can be negative).&lt;br /&gt;
** {{DevFeature}} '''current''': changes the current turn number after applying turn limit modifications, if any. It is possible to change the current turn number to a greater one than the current only; also, it is not possible to change the turn number to exceed the turn limit.&lt;br /&gt;
* '''[capture_village]''': changes the ownership of a village.&lt;br /&gt;
** '''side''': the side that takes control of the village. If not given, the village will become neutral.&lt;br /&gt;
** '''x, y''': the location of the village.&lt;br /&gt;
* '''[kill]''': Removes all units (including units in a recall list) that match the filter from the game.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criterion&lt;br /&gt;
** '''animate''': if 'yes', displays the unit dying (fading away).&lt;br /&gt;
** '''fire_event''': if 'yes', triggers any appropriate 'die' events (See [[EventWML]]). Note that any 'die' events triggered by this are executed immediately, interrupting the current event and thus causing the x1, y1, x2, and y2 variables to be reset for that 'die' event, which in turn causes those variables to be invalid for the remainder of this event. {{DevFeature}} 'last breath' events are also fired.&lt;br /&gt;
* '''[unstone]''': Unstones all units that match the filter.&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] all units matching the filter will be unstoned.  If no unit matches the filter, then nothing happens (probably).  If absent, all units on the map are unstoned.&lt;br /&gt;
* '''[object]''': gives some unit an object and removes all items on the tile the unit is on.&lt;br /&gt;
** '''id''': when the object is picked up, a flag is set for ''id''.  The object cannot be picked up if a flag for ''id'' has been set.  This means that any object with an id can only be used once, even if first_time_only=no is set for the event. This restriction is per level. In a campaign objects with the same id can be assigned once per level.&lt;br /&gt;
** '''[effect]''': one or more effect elements may be listed.  See [[EffectWML]] for a description of [effect].&lt;br /&gt;
** '''duration''': if 'level', effects only last until the end of the level (note : 'level' is the scenario, so this doesn't mean it last until the unit levels-up).&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] the first unit found that matches the filter will be given the object.  If no unit matches the filter, then a message is displayed and the object is not removed.&lt;br /&gt;
** '''[then]''': a subtag that lets you execute actions if the filter conditions are met.  The most common action that should be inside here is a '''[removeitem]''' tag, but you could probably put any tags that otherwise work in a [then] tag.&lt;br /&gt;
** '''silent''': whether or not messages should be suppressed. Default is &amp;quot;no&amp;quot;.&lt;br /&gt;
** '''image''': the displayed image of the object.&lt;br /&gt;
** '''name''': (translatable) displayed as a caption of the image.&lt;br /&gt;
&lt;br /&gt;
** '''user_description''': {{DevFeature}} (translatable) displayed as a message of the image. In 1.4 and older versions this is just '''description'''; that will still be expected for compatibility.&lt;br /&gt;
** '''cannot_use_message''': (translatable) displayed instead of '''description''' if no unit passes the filter test.&lt;br /&gt;
** If you do not supply a filter, the object action will be applied to a unit at the location of the moveto event. Currently this isn't recommended as it is not clear that this will continue working this way. Instead it is better to explicitly include a location filter.&lt;br /&gt;
** The object action does not act on units in the recall list. There is a feature request in to allow this, but it is not clear whether or not it will be accepted.&lt;br /&gt;
* '''[remove_shroud]''': removes some shroud from the map for a certain side (only relevant for sides that have shroud=yes).&lt;br /&gt;
** '''side''': (default=1) the side for which to remove shroud.&lt;br /&gt;
** [[StandardLocationFilter]]: the range of tiles for which shroud should be removed.&lt;br /&gt;
** Note: '''[remove_shroud]''' doesnt't accept all of the standard location filters. In particular '''[filter]''' to remove shroud around units doesn't work, and radius may not either. To remove shroud around a group of units, you can temporarily switch the sides of the units using '''[store_unit]''', '''[set_variable]''', and then '''[unstore_unit]''' (do the '''[set_variable]''' and '''[unstore_unit]''' twice each, once to switch sides, and once to switch back). Just make sure you call '''[redraw]''' while the unit's side is switched to update shroud. Also make sure to use ''kill=no'' for the store and then ''find_vacant=no'' for the unstores.&lt;br /&gt;
** {{DevFeature}}: '''[remove_shroud]''' accepts a full standard location filter.&lt;br /&gt;
* '''[place_shroud]''': places some shroud on the map for a certain side (only relevant for sides that have shroud=yes).&lt;br /&gt;
** '''side''': (default=1) the side for which to place shroud.&lt;br /&gt;
** [[StandardLocationFilter]]: the range of tiles on which shroud should be placed.&lt;br /&gt;
* '''[allow_undo]''': allows the player to undo the event that this tag is inside.  Has an effect only inside moveto events.  If the move is undone, only the position of the unit will be restored; any altered variables or changes to the game will remain changed after the move is undone.  It is up to the scenario designer to avoid abusing this command.&lt;br /&gt;
** Technically, if '''[allow_undo]''' is inside an '''[event]''' with ''first_time_only=yes'' (the default setting), and the user undoes the event, then the state of the game has changed in this way: the event will not fire a second time, even though the user undid the move the first time.&lt;br /&gt;
* '''[heal_unit]''' {{DevFeature}}: heal a unit. The variable '''$heal_amount''' will be set to the exact number of points healed (i.e can be lesser than the parameter '''amount''' if the unit is fully healed).&lt;br /&gt;
**  '''[filter]''': [[StandardUnitFilter]] the first unit matching the filter will be healed. &lt;br /&gt;
**  '''[secondary_unit_filter]''': [[StandardUnitFilter]] all the units matching the filter ''and'' having the ''heals'' ability will have their animation played (if ''animate'' is set to true).&lt;br /&gt;
**  '''amount''': the maximum points the unit will be healed.&lt;br /&gt;
**  '''animate''': a boolean which indicate if the healing animations must be played.&lt;br /&gt;
* '''[time_area]''' {{DevFeature}}: how a day should progress in a given area. Everywhere not specified in a [time_area] tag is affected by the [time] and [illuminated_time] tags in the [scenario] tag&lt;br /&gt;
** [[StandardLocationFilter]]: the locations to affect.&lt;br /&gt;
** [[TimeWML]]: the new schedule.&lt;br /&gt;
** '''id''': an unique identifier assigned to a time_area. Optional, unless you want to remove the time_area later. See below.&lt;br /&gt;
** '''remove''': (boolean) yes/no value. Indicates whether the specified time_area should be removed. Requires an identifier. If no identifier is used, however, all time_areas are removed.&lt;br /&gt;
** {{DevFeature}}: in Wesnoth 1.5.9 and later, '''id''' may be a comma-separated list for removing time areas. It is not allowed, however, for inserting time areas; only the first id is taken into account in that case.&lt;br /&gt;
&lt;br /&gt;
* '''[end_turn]''' {{DevFeature}}: end the current side's turn.&lt;br /&gt;
&lt;br /&gt;
== Useful Macros ==&lt;br /&gt;
There are some predefined macros that you find useful for direct actions. You can find a complete list along with a detailed explanation of how they work [http://www.wesnoth.org/macro-reference.xhtml here].&lt;br /&gt;
* '''{MOVE_UNIT}''': Moves a unit to another location in the map and the player sees the movement (unlike [teleport])&lt;br /&gt;
* '''{FULL_HEAL}''': Brings a unit to full HP&lt;br /&gt;
* '''{LOYAL_UNIT}''': Create a loyal unit&lt;br /&gt;
* '''{MODIFY_TERRAIN_MASK}''': Modify an area of terrain&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=28054</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=28054"/>
		<updated>2009-01-21T22:26:54Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* The [event] tag */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== The [event] tag ==&lt;br /&gt;
&lt;br /&gt;
This tag is a subtag of the [scenario], [unit] and [era] tags which is used to describe a set of actions which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer], [tutorial] and [test]), the event only occurs in that scenario. When used in a [unit] type definition, the event will occur in all scenarios in which a unit of that type appears in. When used in an [era], the event will occur in any scenario which is played using that era.&lt;br /&gt;
&lt;br /&gt;
Keys and tags that describe when the event should trigger:&lt;br /&gt;
* '''name''': this is not like a normal 'name' key. It is a basic description of when the event will trigger. {{DevFeature}} '''name''' can accept a list of commas separated descriptions for which the event must be triggered. Example: '''name= attacker_misses, defender_misses'''. Note that unless you use ''first_time_only=no'', the event will fire only once, not once for each listed type.&lt;br /&gt;
* '''prestart''': the event is triggered before a scenario 'starts' -- before anything is shown on the screen at all. You can use this event to set up things like village ownership. For things displayed on-screen such as character dialog, use '''start'''.&lt;br /&gt;
* '''start''': this event triggers after the map is shown but before the scenario begins&lt;br /&gt;
* '''new turn''': this event triggers whenever the last player ends their turn. See also '''first_time_only=no'''. When the last player ends their turn, before any events of this type trigger, the value of the WML variable '''turn_number''' is set to the number of the turn that is beginning.&lt;br /&gt;
* '''side turn''': this event triggers when a side is about to start its turn. Before events of this type trigger, the value of the WML variable '''side_number''' is set to the number of the side of the player about to take their turn. This is before any healing takes place for that side, before calculating income, and before restoring unit movement and status.&lt;br /&gt;
* '''turn refresh''': this event triggers just before a side is taking control after healing, calculating income, and restoring unit movement and status.&lt;br /&gt;
* '''turn X''': (for X some number) this event triggers at the start of turn ''X''. ''X'' cannot be 1.&lt;br /&gt;
* '''time over''': this event triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
* '''enemies defeated''': this event triggers when all units with '''canrecruit=yes''' (i.e. all leaders) not allied with side 1 are killed.&lt;br /&gt;
* '''victory''': in this scenario, any tag of the form '''[endlevel] result=victory [/endlevel]''' will be automatically preceded by all actions in this tag. It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:n&amp;quot; command. Scenarios where key units are picked up before the victory, or where some action chosen earlier determines which map to advance to, make it hard to quickly test scenarios in a campaign. (See also [endlevel], [[DirectActionsWML]])&lt;br /&gt;
* '''defeat''': in this scenario, any tag of the form '''[endlevel] result=defeat [/endlevel]''' will be automatically preceded by all actions in this tag. (See also [endlevel], [[DirectActionsWML]])&lt;br /&gt;
* '''ai turn''': is triggered just before the AI is invoked for a side. This is called after ''side turn'', and thus the WML variable '''side_number''' still holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
Filters can be applied to the following event triggers (see [[FilterWML]]; see also below). The actions specified in the event tag will be executed only if the filter returns true. &lt;br /&gt;
These event triggers are all actions by units ('''moveto''', '''attack''') or things that happen to units ('''recruit''', '''advance'''). When one of these events is triggered, the position of the active unit (referred to as the '''primary unit''') is stored in the variables '''x1''' and '''y1''' and the position of any unit that primary unit does something to is stored in the variables '''x2''' and '''y2''' (this unit is referred to as the '''secondary unit''' below). '' These units are also automatically stored in the variables 'unit' and 'second_unit' as if they had been stored using the '''[store_unit]''' tag. see [[SingleUnitWML]]&lt;br /&gt;
&lt;br /&gt;
* '''moveto'''': triggers after the primary unit moves. Typically this is used when the primary unit gets to a particular location and a filter for the location of the primary unit is included; remember that this is the location that the primary unit lands on, not the location it started on or any location it travels on.&lt;br /&gt;
* '''sighted''': this event triggers when the primary unit becomes visible to the secondary unit in particular after not being visible to the secondary unit's side (so if the secondary unit's side doesn't have shroud or fog, the event never triggers). This happens both when the primary unit moves into view during its turn, and when the secondary unit moves to a location where it can see the primary unit. (This editor hasn't tested whether the event triggers multiple times if the primary unit moves into view of multiple units at once, or if not, which one gets chosen to be the secondary unit here.) (Note: it appears that when a sighted event is triggered because an enemy unit moves into your field of view, the game engine cannot determine which unit (on your side) sees the unit that moved, and so it fires a ''name=sighted'' event without setting ''$second_unit''. This means that, for example, using ''speaker=second_unit'' inside a message tag may fail.)&lt;br /&gt;
* '''attack''': this event triggers when the primary unit attacks the secondary_unit.&lt;br /&gt;
* '''attacker_hits''': this event triggers when the the primary unit (the attacker) hits the secondary unit (the defender). {{DevFeature}} A variable '''$damage_inflicted''' allow to check the number of hitpoints inflicted by the attacker.&lt;br /&gt;
* '''attacker_misses''': same as ''attacker_hits'', but is triggered when the attacker misses.&lt;br /&gt;
* '''defender_hits''': this event triggers when the primary unit (the attacker) is hit in retaliation by the secondary unit (the defender). {{DevFeature}} A variable '''$damage_inflicted''' allow to check the number of hitpoints inflicted by the defender.&lt;br /&gt;
* '''defender_misses''': same as ''defender_hits'', but is triggered when the defender misses.&lt;br /&gt;
* '''attack_end''': is similar to '''attack''', but is instead triggered after the fight, not before. Note that if either unit is killed during the fight, this event triggers before any '''die''' events.&lt;br /&gt;
* '''stone''': this event triggers when the primary unit is hit by an attack with the 'stones' ability (See ''stones'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'stones' ability).&lt;br /&gt;
* '''last breath''': this event triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered.&lt;br /&gt;
* '''die''': this event triggers when the primary unit is killed by the secondary unit.&lt;br /&gt;
* '''capture''': this event triggers when the primary unit captures a village. The village may have been previously neutral, or previously owned by another side; merely moving into your own villages does not constitute a capture.&lt;br /&gt;
* '''recruit''': this event triggers when the primary unit is recruited or recalled. (That is, when a unit is recruited or recalled, it will trigger this event and this event's filter will filter that unit.). {{DevFeature}} The '''recruit''' will no longer triggers on recalls.&lt;br /&gt;
* '''prerecruit''': this event triggers when the primary unit is recruited, but before it is displayed. {{DevFeature}} The '''prerecruit''' will no longer triggers on recalls.&lt;br /&gt;
* '''advance''': this event triggers just before the primary unit is going to advance to another unit.&lt;br /&gt;
* '''post_advance''': this event triggers just after the primary unit has advanced to another unit.&lt;br /&gt;
* '''select''': triggers when the primary unit is selected. ''Note: in networked multiplayer, these events are only executed by the client on which the event is triggered, leading to out of sync errors if you modify the game state in the event.''&lt;br /&gt;
* '''menu item X''': triggers when a WML menu item with id=X is selected. ''Note: if the menu item has a [command], this event may be executed before or after the command; there is no guarantee.'' &lt;br /&gt;
* {{DevFeature}} '''prerecall''': triggers when a unit is recalled, but before it is displayed. This event is not trigger when a unit is recruit.&lt;br /&gt;
* {{DevFeature}} '''recall''': triggers after a unit is recalled. This event is not trigger when a unit is recruit.&lt;br /&gt;
* {{DevFeature}} other events with a custom name may be invoked from [fire_event]&lt;br /&gt;
* {{DevFeature}} '''consider attack''': triggers before the attack dialog is displayed.&lt;br /&gt;
* {{DevFeature}} '''unconsider attack''': triggers when canceling out of the attack dialog.&lt;br /&gt;
&lt;br /&gt;
An '''[allow_undo]''' tag anywhere within a moveto event will cancel any lack of undo functionality the event would have caused. Note that undo functionality will only move the unit back to its former location; it will not other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.&lt;br /&gt;
&lt;br /&gt;
The primary unit can be referred to as '''unit''' and the secondary unit can be referred to as '''second_unit''' in [message] tags using the speaker= key. For example:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
 name=die&lt;br /&gt;
   [message]&lt;br /&gt;
   speaker=second_unit&lt;br /&gt;
   message=&amp;quot;Hahaha, I finally killed you!&amp;quot;&lt;br /&gt;
   [/message]&lt;br /&gt;
 &lt;br /&gt;
   [message]&lt;br /&gt;
   speaker=unit&lt;br /&gt;
   message=&amp;quot;It's not over yet! I'll come back to haunt you!&amp;quot;&lt;br /&gt;
   [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
These keys and tags are more complex ways to filter when an event should trigger:&lt;br /&gt;
* '''first_time_only''': whether the event should be removed from the scenario after it is triggered.  Default is '''yes'''.&lt;br /&gt;
* '''[filter]''': the event will only trigger if the primary unit matches this filter.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
* '''[filter_second]''': is like [filter], but for the secondary unit.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criteria&lt;br /&gt;
* '''[special_filter]''' and '''[special_filter_second]''': can be used to set some additional filtering criteria for the primary unit and the secondary unit that are not generally available in a standard unit filter. Can be used in events ''attack'', ''attacker_hits'', ''attacker_misses'', ''defender_hits'', ''defender_misses'' and ''attack_end''. ({{DevFeature}} renamed to [filter_attack] and [filter_second_attack])&lt;br /&gt;
** '''weapon''': the name of the weapon used. ({{DevFeature}} renamed to '''name''')&lt;br /&gt;
** {{DevFeature}} '''range''': the ranged of the weapon used. &lt;br /&gt;
&lt;br /&gt;
=== Actions triggered by [event] ===&lt;br /&gt;
&lt;br /&gt;
After the trigger conditions have been met, all action tags within the [event] tag are executed in the order they are written in.&lt;br /&gt;
&lt;br /&gt;
There are 3 main types of actions:&lt;br /&gt;
* direct actions ([[DirectActionsWML]]) which have a direct effect on gameplay&lt;br /&gt;
* display actions ([[InterfaceActionsWML]]) which show something to the user&lt;br /&gt;
* internal actions ([[InternalActionsWML]]) which are used by WML internally&lt;br /&gt;
&lt;br /&gt;
Several actions use standard filters to find out which units&lt;br /&gt;
to execute the command on.  These are denoted by the phrases&lt;br /&gt;
&amp;quot;standard unit filter&amp;quot; and &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Nested events ===&lt;br /&gt;
&lt;br /&gt;
There is 1 special type of action: event creation.  By placing an '''[event]''' tag inside another '''[event]''' tag, the nested event is created when the nested event is encountered (when executing the contents of the event).  For example, you could create a portal that opens on turn 10.  The outer event executes on turn 10, creating the nested moveto event, which executes when a player steps on a certain spot.  An equivalent way of doing this would be to a single moveto event with an '''[if]''' statement to check for turn number, but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[if]''' statements.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 10&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
 &lt;br /&gt;
         [filter]&lt;br /&gt;
             x,y=5,8&lt;br /&gt;
         [/filter]&lt;br /&gt;
 &lt;br /&gt;
         # moving to 5,8 will trigger this event only on turn 10 and after&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Variable substitution for a nested event can happen either when the event is spawned, or when it is triggered. This is controlled with the key ''delayed_variable_substitution'' (default yes). Consider the following two examples:&lt;br /&gt;
&lt;br /&gt;
 # This makes the message display the turn on which the moveto happens,&lt;br /&gt;
 # because the variable substitution for the moveto event will be done&lt;br /&gt;
 # when the event triggers.&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 2&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=yes&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;}&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
 # This makes the message on moveto always display as &amp;quot;Turn 2&amp;quot;, because&lt;br /&gt;
 # the variable substitution is done when the moveto event is spawned,&lt;br /&gt;
 # not when it eventually triggers.&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name=turn 2&lt;br /&gt;
 &lt;br /&gt;
     [event]&lt;br /&gt;
         name=moveto&lt;br /&gt;
         delayed_variable_substitution=no&lt;br /&gt;
 &lt;br /&gt;
         {DEBUG_MSG &amp;quot;Turn $turn_number&amp;quot;}&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Another way to mark an individual variable to be substituted later (when the event is triggered) is to  write it as &amp;quot;$|var&amp;quot; instead of the normal &amp;quot;$var&amp;quot;. By combining this with delayed_variable_substitution=no you can have some variables in the nested event be substituted immediately when the event is spawned and some variables substituted when the event triggers.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[DirectActionsWML]]&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[FilterWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=27953</id>
		<title>DirectActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=27953"/>
		<updated>2009-01-16T07:26:20Z</updated>

		<summary type="html">&lt;p&gt;Solsword: /* Direct actions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Direct actions ==&lt;br /&gt;
&lt;br /&gt;
Direct actions are actions that have a direct effect on gameplay.&lt;br /&gt;
&lt;br /&gt;
The following tags are actions:&lt;br /&gt;
* '''[endlevel]''': ends the scenario.&lt;br /&gt;
** '''result''': before the scenario is over, all events with ''name=result'' are triggered.  The message ''result_message'' with the heading ''result_heading'' (see [[LanguageWML]]) are displayed.  If ''result=victory'', the player progresses to the next level; if ''result=defeat'', the game returns to the main menu.  These last two are rarely used: ''result=continue'' behaves identically to ''result=victory'' except the player's gold is not reduced to 80%, and it does not bring up a &amp;quot;Victory&amp;quot; message or the gold changing message (since it doesn't change); ''result=continue_no_save'' works similarly, except the player is not asked whether to save the game, and is taken directly to the next scenario without any messages.  Unless ''result=defeat'', the following keys can also be used:&lt;br /&gt;
** '''bonus''': whether the player should get bonus gold (maximum possible gold that could have been earned by waiting the level out). The default is bonus=yes.&lt;br /&gt;
** '''carryover_report''' {{DevFeature}}: whether the player should receive a summary of the scenario outcome, the default is carryover_report=yes.&lt;br /&gt;
** '''save''' {{DevFeature}}: whether a start-of-scenario save should be created for the next scenario, the default is save=yes.&lt;br /&gt;
** '''linger_mode''' {{DevFeature}}: whether the game should switch to linger_mode before advancing to the next scenario, the default is linger_mode=yes.&lt;br /&gt;
** '''next_scenario''': (default specified in '''[scenario]''' tag) the ID of the next scenario that should be played.  All units that side 1 controls at this point become available for recall in ''next_scenario''.&lt;br /&gt;
** When the result is &amp;quot;victory&amp;quot; the following keys can be used:&lt;br /&gt;
*** '''carryover_percentage''' {{DevFeature}}: by default 80% of the gold is carried over to the next scenario, with this key the amount can be changed.&lt;br /&gt;
*** '''carryover_add''' {{DevFeature}}: if true the gold will be added to the starting gold the next scenario, if false the next scenario will start with the amount of the current scenario (after taxes) or the minimum in the next scenario. Default is false.&lt;br /&gt;
** '''music''' {{DevFeature}}: (default specified in '''[scenario]''' or '''[game_config]''' tags) a comma-separated list of music tracks from which one will be chosen and played once after any events related to the end of level result are executed; by default, victory_music is used on victory, and defeat_music on defeat.&lt;br /&gt;
** '''end_text''' {{DevFeature}}: Text that is shown centered in a black screen at the end of a campaign. Defaults to &amp;quot;The End&amp;quot;. Note that this has cumulative effects over the campaign - it persists even if the endlevel does not trigger the end of the campaign. See also [[CampaignWML]].&lt;br /&gt;
** '''end_text_duration''' {{DevFeature}}: Delay, in milliseconds, before displaying the game credits at the end of a campaign. In other words, for how much time '''end_text''' is displayed on screen. Defaults to 3500. Note that this has cumulative effects over the campaign - it persists even if the endlevel does not trigger the end of the campaign. See also [[CampaignWML]].&lt;br /&gt;
* '''[unit]''': places a unit on the map.  For syntax see [[SingleUnitWML]].&lt;br /&gt;
** {{Short Note:Predefined Macro|GENERIC_UNIT}}&lt;br /&gt;
** {{DevFeature}} '''to_variable''':  spawn directly into a variable instead of on the map.&lt;br /&gt;
* '''[recall]''': recalls a unit.  The unit is recalled free of charge, and is placed near the leader.&lt;br /&gt;
** [[StandardUnitFilter]]: the first matching unit will be recalled.  If no units match this tag is ignored.&lt;br /&gt;
** '''x,y''': the unit is placed here instead of next to the leader.&lt;br /&gt;
** '''show''': if not &amp;quot;no&amp;quot;, display the unit being recalled.&lt;br /&gt;
* '''[teleport]''': teleports a unit on map. {{Short Note:Predefined Macro|TELEPORT_UNIT}}&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] all units matching the filter will be teleported.&lt;br /&gt;
** '''x,y''': the position to teleport to.&lt;br /&gt;
** '''clear_shroud''': should shroud be cleared on arrival&lt;br /&gt;
** '''animate''': should a teleport animation be played (if the unit doesn't have a teleport animation, it will fade out/fade in)&lt;br /&gt;
* '''[terrain_mask]''': changes the terrain on the map.  See [[TerrainMaskWML]].&lt;br /&gt;
* '''[terrain]''': changes the terrain on the map.&lt;br /&gt;
** '''terrain''': the character of the terrain to use.  See [[TerrainCodesWML]] to see what letter a type of terrain uses.&lt;br /&gt;
** '''x,y''': the position (or range of positions) to change.&lt;br /&gt;
** {{DevFeature}} '''layer''': (overlay|base|both, default=both) only change the specified layer.&lt;br /&gt;
** {{DevFeature}} '''replace_if_failed''': (default=no) When replacing just one layer failed, try to replace the whole terrain. If '''terrain''' is an overlay only terrain, use the default_base as base layer. If the terrain has no default base, do nothing.&lt;br /&gt;
* '''[gold]''': give one side gold.&lt;br /&gt;
** '''amount''': the amount of gold to give.&lt;br /&gt;
** '''side''': (default=1) the number of the side to give the gold to.&lt;br /&gt;
* '''[unstore_unit]''': creates a unit from a game variable, and activates it on the playing field.  This must be a specific variable describing a unit, and may not be an array -- to unstore an entire array, iterate over it.  The variable is not cleared.  See also '''[store_unit]''', '''[while]''' and [clear_variable] in [[InternalActionsWML]]. Note units with a negative amount of hitpoints will be unstored with 1 hitpoint.&lt;br /&gt;
** '''variable''': the name of the variable.&lt;br /&gt;
** '''find_vacant''': whether the unit should be placed on the nearest vacant tile to its specified location.  If this is set to 'no'(default), then any unit on the same tile as the unit being unstored will be destroyed.&lt;br /&gt;
** '''text''': (translatable) floating text to display above the unit, such as a damage amount&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color to display the text in. Values vary from 0-255. You may find it convenient to use the {COLOR_HARM} or {COLOR_HEAL} macro instead. (Use {COLOR_HARM} or {COLOR_HEAL} instead of the whole red,green,blue= line.)&lt;br /&gt;
** '''advance''': if the XP has been modified then there will be tried to advance the unit, default true. &lt;br /&gt;
** {{DevFeature}} '''x''' ,'''y''': override unit location&lt;br /&gt;
* '''[allow_recruit]''': allows a side to recruit units it couldn't previously recruit.&lt;br /&gt;
** '''type''': the types of units that the side can now recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that is being allowed to recruit the units.&lt;br /&gt;
* '''[disallow_recruit]''': prevents a side from recruiting units it could previously recruit.&lt;br /&gt;
** '''type''': the types of units that the side can no longer recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that may no longer recruit the units.&lt;br /&gt;
* '''[set_recruit]''': sets the units a side can recruit.&lt;br /&gt;
** '''recruit''': the types of units that the side can now recruit.&lt;br /&gt;
** '''side''': (default=1) the number of the side that is having its recruitment set.&lt;br /&gt;
* '''[modify_side]''': modifies some details of a given side in the middle of a scenario.  '''The following listed properties are the only properties that [modify_side] can affect!'&lt;br /&gt;
** '''side''': (default=1) the number of the side that is to be changed.&lt;br /&gt;
** '''income''': the income given at the begining of each turn.&lt;br /&gt;
** '''team_name''': the team in which the side plays the scenario.&lt;br /&gt;
** '''user_team_name''': a translatable string representing the team's description. This has no effect on alliances. Defaults to ''team_name''.&lt;br /&gt;
** '''gold''': the amount of gold the side owns.&lt;br /&gt;
** '''village_gold''': the income setting per village for the side.&lt;br /&gt;
** '''controller''': the identifier string of the side's controller. Uses the same syntax of the ''controller'' key in the [[SideWML|[side]]] tag.&lt;br /&gt;
** '''fog''': a boolean string (yes/no) describing the status of Fog for the side.&lt;br /&gt;
** '''shroud''': a boolean string describing the status of Shroud for the side.&lt;br /&gt;
** {{DevFeature}} '''[ai]''': replaces a side's AI parameters with the new specified ones. Uses the same syntax described in [[AiWML]].&lt;br /&gt;
* '''[modify_turns]''': modifies the turn limit in the middle of a scenario.&lt;br /&gt;
** '''value''': the new turn limit.&lt;br /&gt;
** '''add''': if used instead of ''value'', specifies the number of turns to add to the current limit (can be negative).&lt;br /&gt;
** {{DevFeature}} '''current''': changes the current turn number after applying turn limit modifications, if any. It is possible to change the current turn number to a greater one than the current only; also, it is not possible to change the turn number to exceed the turn limit.&lt;br /&gt;
* '''[capture_village]''': changes the ownership of a village.&lt;br /&gt;
** '''side''': the side that takes control of the village. If not given, the village will become neutral.&lt;br /&gt;
** '''x, y''': the location of the village.&lt;br /&gt;
* '''[kill]''': Removes all units (including units in a recall list) that match the filter from the game.&lt;br /&gt;
** [[StandardUnitFilter]]: selection criterion&lt;br /&gt;
** '''animate''': if 'yes', displays the unit dying (fading away).&lt;br /&gt;
** '''fire_event''': if 'yes', triggers any appropriate 'die' events (See [[EventWML]]). Note that any 'die' events triggered by this are executed immediately, interrupting the current event and thus causing the x1, y1, x2, and y2 variables to be reset for that 'die' event, which in turn causes those variables to be invalid for the remainder of this event. {{DevFeature}} 'last breath' events are also fired.&lt;br /&gt;
* '''[unstone]''': Unstones all units that match the filter.&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] all units matching the filter will be unstoned.  If no unit matches the filter, then nothing happens (probably).  If absent, all units on the map are unstoned.&lt;br /&gt;
* '''[object]''': gives some unit an object and removes all items on the tile the unit is on.&lt;br /&gt;
** '''id''': when the object is picked up, a flag is set for ''id''.  The object cannot be picked up if a flag for ''id'' has been set.  This means that any object with an id can only be used once, even if first_time_only=no is set for the event. This restriction is per level. In a campaign objects with the same id can be assigned once per level.&lt;br /&gt;
** '''[effect]''': one or more effect elements may be listed.  See [[EffectWML]] for a description of [effect].&lt;br /&gt;
** '''duration''': if 'level', effects only last until the end of the level (note : 'level' is the scenario, so this doesn't mean it last until the unit levels-up).&lt;br /&gt;
** '''[filter]''': [[StandardUnitFilter]] the first unit found that matches the filter will be given the object.  If no unit matches the filter, then a message is displayed and the object is not removed.&lt;br /&gt;
** '''[then]''': a subtag that lets you execute actions if the filter conditions are met.  The most common action that should be inside here is a '''[removeitem]''' tag, but you could probably put any tags that otherwise work in a [then] tag.&lt;br /&gt;
** '''silent''': whether or not messages should be suppressed. Default is &amp;quot;no&amp;quot;.&lt;br /&gt;
** '''image''': the displayed image of the object.&lt;br /&gt;
** '''name''': (translatable) displayed as a caption of the image.&lt;br /&gt;
&lt;br /&gt;
** '''user_description''': {{DevFeature}} (translatable) displayed as a message of the image. In 1.4 and older versions this is just '''description'''; that will still be expected for compatibility.&lt;br /&gt;
** '''cannot_use_message''': (translatable) displayed instead of '''description''' if no unit passes the filter test.&lt;br /&gt;
** If you do not supply a filter, the object action will be applied to a unit at the location of the moveto event. Currently this isn't recommended as it is not clear that this will continue working this way. Instead it is better to explicitly include a location filter.&lt;br /&gt;
** The object action does not act on units in the recall list. There is a feature request in to allow this, but it is not clear whether or not it will be accepted.&lt;br /&gt;
* '''[remove_shroud]''': removes some shroud from the map for a certain side (only relevant for sides that have shroud=yes).&lt;br /&gt;
** '''side''': (default=1) the side for which to remove shroud.&lt;br /&gt;
** [[StandardLocationFilter]]: the range of tiles for which shroud should be removed.&lt;br /&gt;
** Note: '''[remove_shroud]''' doesnt't accept all of the standard location filters. In particular '''[filter]''' to remove shroud around units doesn't work, and radius may not either. To remove shroud around a group of units, you can temporarily switch the sides of the units using '''[store_unit]''', '''[set_variable]''', and then '''[unstore_unit]''' (do the '''[set_variable]''' and '''[unstore_unit]''' twice each, once to switch sides, and once to switch back). Just make sure you call '''[redraw]''' while the unit's side is switched to update shroud. Also make sure to use ''kill=no'' for the store and then ''find_vacant=no'' for the unstores.&lt;br /&gt;
* '''[place_shroud]''': places some shroud on the map for a certain side (only relevant for sides that have shroud=yes).&lt;br /&gt;
** '''side''': (default=1) the side for which to place shroud.&lt;br /&gt;
** [[StandardLocationFilter]]: the range of tiles on which shroud should be placed.&lt;br /&gt;
* '''[allow_undo]''': allows the player to undo the event that this tag is inside.  Has an effect only inside moveto events.  If the move is undone, only the position of the unit will be restored; any altered variables or changes to the game will remain changed after the move is undone.  It is up to the scenario designer to avoid abusing this command.&lt;br /&gt;
** Technically, if '''[allow_undo]''' is inside an '''[event]''' with ''first_time_only=yes'' (the default setting), and the user undoes the event, then the state of the game has changed in this way: the event will not fire a second time, even though the user undid the move the first time.&lt;br /&gt;
* '''[heal_unit]''' {{DevFeature}}: heal a unit. The variable '''$heal_amount''' will be set to the exact number of points healed (i.e can be lesser than the parameter '''amount''' if the unit is fully healed).&lt;br /&gt;
**  '''[filter]''': [[StandardUnitFilter]] the first unit matching the filter will be healed. &lt;br /&gt;
**  '''[secondary_unit_filter]''': [[StandardUnitFilter]] all the units matching the filter ''and'' having the ''heals'' ability will have their animation played (if ''animate'' is set to true).&lt;br /&gt;
**  '''amount''': the maximum points the unit will be healed.&lt;br /&gt;
**  '''animate''': a boolean which indicate if the healing animations must be played.&lt;br /&gt;
* '''[time_area]''' {{DevFeature}}: changes the schedule in the given locations.&lt;br /&gt;
** [[StandardLocationFilter]]: the locations to affect.&lt;br /&gt;
** [[TimeWML]]: the new schedule.&lt;br /&gt;
* '''[end_turn]''' {{DevFeature}}: end the current side's turn.&lt;br /&gt;
&lt;br /&gt;
== Useful Macros ==&lt;br /&gt;
There are some predefined macros that you find useful for direct actions. You can find a complete list along with a detailed explanation of how they work [http://www.wesnoth.org/macro-reference.xhtml here].&lt;br /&gt;
* '''{MOVE_UNIT}''': Moves a unit to another location in the map and the player sees the movement (unlike [teleport])&lt;br /&gt;
* '''{FULL_HEAL}''': Brings a unit to full HP&lt;br /&gt;
* '''{LOYAL_UNIT}''': Create a loyal unit&lt;br /&gt;
* '''{MODIFY_TERRAIN_MASK}''': Modify an area of terrain&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Solsword</name></author>
		
	</entry>
</feed>