<?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=Laela</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=Laela"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Laela"/>
	<updated>2026-05-11T21:25:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74971</id>
		<title>CompatibilityBreakingChanges</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74971"/>
		<updated>2026-04-13T12:12:24Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Compatibility breaking changes between 1.18 and 1.19/1.20 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This lists removed WML functionality and helpful hints for avoiding pitfalls.&lt;br /&gt;
&lt;br /&gt;
The previous list is available [https://forums.wesnoth.org/viewtopic.php?t=58532 here].&lt;br /&gt;
&lt;br /&gt;
== Compatibility breaking changes between 1.18 and 1.19/1.20 ==&lt;br /&gt;
* The following macros were removed ([https://github.com/wesnoth/wesnoth/pull/11126 #11126])&lt;br /&gt;
** EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
** NO_EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
** NO_GOLD_CARRYOVER_NOTE&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_100&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_40&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_20&lt;br /&gt;
** MISSILE_FRAME_FIREBALL&lt;br /&gt;
** MESSAGE&lt;br /&gt;
** STORY_PART_SPEECH&lt;br /&gt;
** LOYAL_UNDEAD_UNIT&lt;br /&gt;
** ON_SIGHTING&lt;br /&gt;
** MAKE_AI_SIDE_PERSISTENT&lt;br /&gt;
** DRAKE_FLYING_ANIM&lt;br /&gt;
** NO_INTERRUPT_NO_UNDO&lt;br /&gt;
** ENABLE_NIGHTBLADE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;This lists removed WML functionality and helpful hints for avoiding pitfalls.&lt;br /&gt;
&lt;br /&gt;
A similar thread for changes before 1.18 can be found [url=https://forums.wesnoth.org/viewtopic.php?t=57288]here[/url].&lt;br /&gt;
&lt;br /&gt;
[b][u]Compatibility breaking (requires updates to work)[/u][/b]&lt;br /&gt;
[list][*][c][kill][/c] now reduces target unit hitpoints to 0 before triggering [c]last_breath, die[/c] events. This affects mentioned events that rely on [have_unit] conditions.&lt;br /&gt;
[*]WFL Removed properties [c]unit.side[/c] and [c]terrain.owner[/c]. Use [c]unit.side_number[/c] and [c]terrain.owner_side[/c] instead. They return 1-indexed side, removed properties returned 0-indexed side.&lt;br /&gt;
[*]Abilities with both [c]add[/c] and [c]sub[/c] now calculate value differently&lt;br /&gt;
[*]rotate_loc_around formula now works&lt;br /&gt;
[*][era] with id=era_dunefolk does not exist anymore&lt;br /&gt;
[*][side]'s leader attribute has been removed&lt;br /&gt;
[*][side]'s [variables] tag is now used to set side variables. Use [side]'s [leader] tag to set a unit variable.&lt;br /&gt;
[*]Setting gold to decimal value fails with error. Previously it was converted to int automatically. As of 1.19.21, automatic conversion is only done in [gold], but not in Lua or [modify_side].&lt;br /&gt;
[/list]&lt;br /&gt;
&lt;br /&gt;
[b][u]Deprecations (will continue to work for now)[/u][/b]&lt;br /&gt;
[list][*]rechange [experimental_filter_ability/active] and [experimental_filter_specials] to [filter_ability] and [filter_specials] and make &amp;quot;experimental_&amp;quot; deprecated.&lt;br /&gt;
[/list]&lt;br /&gt;
&lt;br /&gt;
[b][u]New features (help fill this list, https://wiki.wesnoth.org/Special:WhatLinksHere/Template:DevFeature1.19)[/u][/b]&lt;br /&gt;
[list]&lt;br /&gt;
[*]StandardAbilityFilter, including [pr]7814[/pr]&lt;br /&gt;
[*][resistance] min_value&lt;br /&gt;
[*][attack] alignment&lt;br /&gt;
[*]New events [c]unit_hits[/c], [c]unit_misses[/c]&lt;br /&gt;
[*]Positive [c]attack_weight[/c] now affects weapon selection&lt;br /&gt;
[*]Unit attack [effect]+Lua+formula API min_range and max_range&lt;br /&gt;
[*]Lua unit attributes fearless and healthy&lt;br /&gt;
[*]wesnoth.game_config shows some color-related values&lt;br /&gt;
[*]wesnoth.units.rebuild&lt;br /&gt;
[*]stringx.ends_with, stringx.starts_with&lt;br /&gt;
[*]Unit formula new attributes objects, advancements_taken, traits_count, objects_count, advancements_taken_count, fearless, healthy&lt;br /&gt;
[*]Formula functions lerp_index, ends_with, replace_all, starts_with, get_palette&lt;br /&gt;
[*]Custom themes https://wiki.wesnoth.org/GUIToolkit#Custom_themes&lt;br /&gt;
[*]Abilities and specials now support [event] (does not work correctly due to [issue]10819[/issue])&lt;br /&gt;
[*]Ability &amp;amp; Weapon specials registry ([pr]10644[/pr]) (does not work correctly if ability contains [event] due to [issue]10819[/issue])&lt;br /&gt;
[*][effect][remove_specials]&lt;br /&gt;
[*]Expose unit pick dialog to Lua as a simple API call ([pr]8829[/pr])&lt;br /&gt;
[*][fire_event][data] can be accessed from other event as $data&lt;br /&gt;
[*]Unit Type Editor&lt;br /&gt;
[*][era]auto_sort allows to use custom faction ordering&lt;br /&gt;
[*][terrain_defaults] formula is now working as expected in case formula evaluates to null&lt;br /&gt;
[*][set_menu_item] description substitutes variables when rightclick is used&lt;br /&gt;
[*][defense]&lt;br /&gt;
[*][resistance_defaults] is not causing OOS in random maps anymore&lt;br /&gt;
[*]Ability/weapon special descriptions support po variables in descriptions like [c]$add[/c], [c]$sub[/c] etc that contain the value of the relevant key. ([pr]10053[/pr], [pr]10293[/pr], [pr]10749[/pr])&lt;br /&gt;
[*]Ability/weapon special help page ids now follow the format: [c]ability_&amp;lt;unique_id&amp;gt;[/c] or [c]weaponspecial_&amp;lt;unique_id&amp;gt;[/c] ([pr]11012[/pr]).&lt;br /&gt;
[*]A lot more functions were added to https://wiki.wesnoth.org/LuaAPI/types/widget with https://wiki.wesnoth.org/index.php?title=LuaAPI%2Ftypes%2Fwidget&amp;amp;type=revision&amp;amp;diff=74843&amp;amp;oldid=74842&lt;br /&gt;
[/list]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=ConditionalActionsWML&amp;diff=74918</id>
		<title>ConditionalActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=ConditionalActionsWML&amp;diff=74918"/>
		<updated>2026-03-22T15:17:31Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [variable] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], Conditional Actions WML is used to describe container actions that create branching and flow control for WML. The [[#Conditional Actions|conditional actions]] act as gatekeepers, encapsulating other actions with [[#Condition Tags|conditions]] which must be met before an action can take place. These conditional actions also contain the actions which will take place if those conditions are met and, in some cases, what actions will take place if they are ''not'' met.&lt;br /&gt;
&lt;br /&gt;
== Conditional Actions ==&lt;br /&gt;
&lt;br /&gt;
These actions describe actions that should be executed only if certain conditions are met.&lt;br /&gt;
&lt;br /&gt;
=== [if] ===&lt;br /&gt;
&lt;br /&gt;
Executes actions only if the contained [[#Condition Tags|conditions]] are met.&lt;br /&gt;
&lt;br /&gt;
* [[#Condition Tags|Condition Tags]]: Conditions which must be met for the actions in the '''[then]''' tag to be executed.&lt;br /&gt;
&lt;br /&gt;
* '''[then]''': Contains [[ActionWML|actions]] which should be executed if all conditions evaluate as true ''or'' if any single '''[or]''' tag evaluates as true.&lt;br /&gt;
&lt;br /&gt;
* '''[elseif]''': {{DevFeature1.13|0}} in case that the conditions inside '''[if]''' aren't met, these tags will be evalutated one by one. If the specified conditions are met, the contained [then] tags will be executed, and the cycle will end.&lt;br /&gt;
** [[#Condition Tags|Condition Tags]]: Specifies the conditions, just like in '''[if]'''.&lt;br /&gt;
** '''[then]''': Specifies actions, exactly like the '''[then]''' tag inside '''[if]'''.&lt;br /&gt;
&lt;br /&gt;
* '''[else]''': Contains [[ActionWML|actions]] which should be executed if all condition tags in the '''[if]''' and any directly nested '''[elseif]''' all evaluate as false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Attention''': There are tags named [if] and [else] inside [animation] (see [[AnimationWML#.5Bif.5D_and_.5Belse.5D|AnimationWML]]), which have a different syntax.&lt;br /&gt;
&lt;br /&gt;
Example usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[if]&lt;br /&gt;
   [variable]&lt;br /&gt;
      name=we.gold&lt;br /&gt;
      greater_than=$they.gold&lt;br /&gt;
   [/variable]&lt;br /&gt;
   [elseif]&lt;br /&gt;
      [variable]&lt;br /&gt;
         name=we.gold&lt;br /&gt;
         equals=$they.gold&lt;br /&gt;
      [/variable]&lt;br /&gt;
      [then]&lt;br /&gt;
         [message]&lt;br /&gt;
            message=This should be fair!&lt;br /&gt;
         [/message]&lt;br /&gt;
      [/then]&lt;br /&gt;
   [/elseif]&lt;br /&gt;
   [else]&lt;br /&gt;
      [message]&lt;br /&gt;
         message=This will not be easy!&lt;br /&gt;
      [/message]&lt;br /&gt;
   [/else]&lt;br /&gt;
[/if]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [switch] ===&lt;br /&gt;
&lt;br /&gt;
The '''[switch]''' tag is a special case because it does not use [[#Condition Tags|Condition Tags]] to control whether actions are performed. Instead, it executes different sets of actions based on the value of a variable&lt;br /&gt;
&lt;br /&gt;
* '''variable''': The name of the variable to check.&lt;br /&gt;
* '''[case]''': Case tag which forms a block containing:&lt;br /&gt;
** '''value''': The value to test the variable's value against. This can be a comma separated list of values.&lt;br /&gt;
** [[ActionWML|Action WML]]: Action WML to execute if the variable matches the value. (The rest of the '''[case]''' block after the '''value''' attribute.)&lt;br /&gt;
* '''[else]''': Else tag which forms a block of [[ActionWML|Action WML]] to execute if no '''[case]''' block contains a '''value''' matching the value of the '''variable'''.&lt;br /&gt;
&lt;br /&gt;
Example usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[switch]&lt;br /&gt;
   variable=foo&lt;br /&gt;
   [case]&lt;br /&gt;
      value=&amp;quot;A&amp;quot;&lt;br /&gt;
      # ... WML if foo=A ...&lt;br /&gt;
   [/case]&lt;br /&gt;
   [case]&lt;br /&gt;
      value=&amp;quot;B&amp;quot;&lt;br /&gt;
      # ... WML if foo=B ...&lt;br /&gt;
   [/case]&lt;br /&gt;
   [else]&lt;br /&gt;
      # ... WML if not foo=A nor foo=B ...&lt;br /&gt;
   [/else]&lt;br /&gt;
[/switch]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [while] ===&lt;br /&gt;
&lt;br /&gt;
Like the '''[if]''' tag, executes actions only if conditions described in the contained [[#Condition Tags|conditions]] are met. Additionally, the '''[while]''' tag ''continues'' to execute the actions until the contained [[#Condition Tags|conditions]] are no longer met. Executes a maximum of 65536 iterations per invocation.&lt;br /&gt;
&lt;br /&gt;
* [[#Condition Tags|Condition Tags]]: Conditions which must be met for the actions in the '''[do]''' tag to be executed.&lt;br /&gt;
&lt;br /&gt;
* '''[do]''': contains [[ActionWML|actions]] that should be executed repeatedly until some condition is false. Multiple '''[do]''' tags can be used, and they will be executed in sequence on each iteration. However, there is usually no reason to do this.&lt;br /&gt;
&lt;br /&gt;
The '''[while]''' tag is useful for iterating over an array.&lt;br /&gt;
An array is a list of values.&lt;br /&gt;
The ''number''th value in the array '''array''' is stored in the WML variable '''''array''[number]'''.&lt;br /&gt;
Note that if '''number''' is the value of the variable '''variable''',&lt;br /&gt;
the expression '''$''array''[$variable]''' will return the ''number''th value in ''array''.&lt;br /&gt;
&lt;br /&gt;
==== 'FOREACH' Macro ====&lt;br /&gt;
This macro simplifies the use of a '''[while]''' tag to create a ''for-each'' iteration format. This is useful, for example, when you want to iterate over each row in a table. To use it, use the [http://www.wesnoth.org/macro-reference.xhtml#FOREACH FOREACH] and [http://www.wesnoth.org/macro-reference.xhtml#NEXT NEXT] macros. Note: This macro is deprecated; you should just use the '''[foreach]''' WML tag instead.&lt;br /&gt;
&lt;br /&gt;
==== 'REPEAT' Macro ====&lt;br /&gt;
This macro simplifies the use of a '''[while]''' tag to execute the same  [[ActionWML|actions]] repeatedly for a specified number of times. To use it, use the [http://www.wesnoth.org/macro-reference.xhtml#REPEAT REPEAT] macro.&lt;br /&gt;
&lt;br /&gt;
=== [for] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Loops over an integer range. Note that, if iterating over an array to delete several elements, it is best to use '''reverse=yes''' to avoid accidentally skipping some elements.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': The name of the variable containing the current index. Defaults to ''i''. If there is already a variable with this name, it will be automatically saved before the start of the loop, and reset to its previous value when the loop exits. If there wasn't a variable with that name before the loop, it will be automatically deleted, there is no need to do a '''[clear_variable]''' afterwards&lt;br /&gt;
* '''start''': The index of the first element to loop over, and sets the starting value of '''variable'''.  Defaults to 0.&lt;br /&gt;
* '''end''': The index of the final element to loop over, and sets the maximum allowed value of '''variable'''.  Defaults to '''start'''.&lt;br /&gt;
* '''step''': The value added to the current value of '''variable''' after each iteration of the loop.  Defaults to 1 if '''start''' &amp;lt; '''end''', or -1 if '''start''' &amp;gt; '''end'''.&lt;br /&gt;
** For example, if '''start=1''' and '''step=2''', then the value of '''variable''' for each iteration will be: 1, 3, 5, ...&lt;br /&gt;
* '''array''': Specify an array to iterate over.  This is a shortcut for setting '''start=0''' and '''end=$($array_name.length-1)'''&lt;br /&gt;
** If '''array''' is set, then '''start''', '''end''', and '''step''' are ignored.&lt;br /&gt;
* '''reverse''': If set to '''yes''', and '''array''' was specified, then this is a shortcut for setting '''start=$($array_name.length-1)''' and '''end=0'''.&lt;br /&gt;
* '''[do]''': The actions to execute on each iteration. As with '''[while]''', it is possible to use multiple '''[do]''' tags, but there is usually no reason to.&lt;br /&gt;
&lt;br /&gt;
=== [foreach] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Loops over an array variable. This is not used to implement the {FOREACH} macro because [foreach] doesn't support adding or removing elements while looping (and will usually raise an error), use '''[for]''' instead.&lt;br /&gt;
&lt;br /&gt;
* '''array''': The array variable to loop over.&lt;br /&gt;
* '''variable''': The name of a variable which refers to the current item. Defaults to ''this_item''. Any changes made to this variable will persist in the array after the loop has completed.&lt;br /&gt;
* '''index_var''': The name of a variable which refers to the index of the current item. Defaults to ''i''. Note that this is just for information purposes and should not be used to access the array from within the loop (any such changes made will not persist).&lt;br /&gt;
* '''readonly''': If set to yes, this prevents the array from being modified in any way during the loop. (It defaults to no.) That means that changes made through the '''variable''' will ''not'' persist. Changes made through the '''index_var''' will also not persist (as normal). In effect, the array is reverted to its original state once the loop exits.&lt;br /&gt;
* '''[do]''': The actions to execute on each iteration. As with '''[while]''', it is possible to use multiple '''[do]''' tags, but there is usually no reason to.&lt;br /&gt;
&lt;br /&gt;
The '''[foreach]''' tag simulates local-scoping of its index variables. If there was already a WML variable with the same name (by default ''i'' and ''this_item'' respectively), it will be automatically saved before the start of the '''[do]''', and reset to its previous value when the loop exits.  If there wasn't a variable with that name before the loop, there is no need to do a '''[clear_variable]''' afterwards.&lt;br /&gt;
&lt;br /&gt;
It's possible to nest '''[foreach]''' loops, however 1.16 does not support using the same ''variable='' name for both loops ([https://github.com/wesnoth/wesnoth/issues/6305 issue 6305], fixed in {{DevFeature1.17|13}}).&lt;br /&gt;
&lt;br /&gt;
=== [repeat] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Repeats some actions a fixed number of times. This is a completely stateless loop - there's no way to know which iteration of the loop you're on. (If you need this, use '''[for]''' instead.)&lt;br /&gt;
&lt;br /&gt;
* '''times''': The number of times to repeat the actions.&lt;br /&gt;
* '''[do]''': The actions to repeat.  As with '''[while]''', it is possible to use multiple '''[do]''' tags, but there is usually no reason to.&lt;br /&gt;
&lt;br /&gt;
=== [command] ===&lt;br /&gt;
&lt;br /&gt;
This tag is more of an Unconditional Action: when it is encountered, the [[ActionWML|actions]] in its content are simply executed once. In practice, this tag serves little purpose. However, it may be used to arrange actions together in logical groups, for example, with actions that are stored in an array and later inserted.&lt;br /&gt;
(It is also used inside of [set_menu_item] and [option] of [[InterfaceActionsWML]].)&lt;br /&gt;
&lt;br /&gt;
== Condition Tags ==&lt;br /&gt;
&lt;br /&gt;
These tags describe conditions which must be met before an action can take place. Some or all of them are used in the various [[#Conditional Actions|Conditional Actions]].&lt;br /&gt;
&lt;br /&gt;
=== [true] ===&lt;br /&gt;
&lt;br /&gt;
Represents a condition that always yields true. Takes no arguments.&lt;br /&gt;
&lt;br /&gt;
=== [false] ===&lt;br /&gt;
&lt;br /&gt;
Represents a condition that always yields false. Takes no arguments.&lt;br /&gt;
&lt;br /&gt;
=== [have_unit] ===&lt;br /&gt;
&lt;br /&gt;
A unit with greater than zero hit points matching this filter exists.&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]] '''*''': Selection criteria. Do not use a [filter] tag.&lt;br /&gt;
* '''count''': ''(Optional)'' If used, a number of units equal to the value must match the filter. Accepts a number, range, or comma separated range. If not used, the default value is &amp;quot;1-99999&amp;quot;.&lt;br /&gt;
* '''search_recall_list''': ''(Optional)'' If 'yes', search through recall list too. (Default is 'no')&lt;br /&gt;
&lt;br /&gt;
=== [have_location] ===&lt;br /&gt;
&lt;br /&gt;
A location matching this filter exists.&lt;br /&gt;
&lt;br /&gt;
* [[StandardLocationFilter]]: Selection criteria.&lt;br /&gt;
* '''count''': ''(Optional)'' If used, a number of locations equal to the value must match the filter. Accepts a number, range, or comma separated range. If not used, the default value is &amp;quot;1-99999&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [have_side] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|10}}&lt;br /&gt;
&lt;br /&gt;
* [[StandardSideFilter]]: Selection criteria.&lt;br /&gt;
* '''count''': ''(Optional)'' If used, exactly this number of sides must match the filter. Accepts only a number.&lt;br /&gt;
&lt;br /&gt;
=== [has_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
The specified achievement has been completed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML|[achievements_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' This is not safe to use in online multiplayer since different players can have different achievements completed. As such it will always be treated as if the achievement is not completed.&lt;br /&gt;
&lt;br /&gt;
=== [has_sub_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|17}}&lt;br /&gt;
&lt;br /&gt;
The specified achievement has been completed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML|[achievements_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''sub_id''': The id of the sub-achievement.&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' This is not safe to use in online multiplayer since different players can have different sub-achievements completed. As such it will always be treated as if the sub-achievement is not completed.&lt;br /&gt;
&lt;br /&gt;
=== [variable] ===&lt;br /&gt;
&lt;br /&gt;
Test the value of a WML [[VariablesWML|variable]] against another value.&lt;br /&gt;
&lt;br /&gt;
* '''name''': The name of the variable to test.&lt;br /&gt;
* ''&amp;lt;comparison&amp;gt;'': '''One''' of the following keys must be used to compare the value of the named variable, represented as ''$name'' below, against another value:&lt;br /&gt;
** '''contains''': ''$name'' contains this string value.&lt;br /&gt;
** '''equals''': ''$name'' is equal (string wise) to this value.&lt;br /&gt;
** '''not_equals''': ''$name'' is not equal (string wise) to this value.&lt;br /&gt;
** '''numerical_equals''': ''$name'' is equal (numerically) to this value. &lt;br /&gt;
** '''numerical_not_equals''': ''$name'' is not equal (numerically) to this value.&lt;br /&gt;
** '''greater_than''': ''$name'' is numerically greater than this value.&lt;br /&gt;
** '''greater_than_equal_to''': ''$name'' is numerically greater than or equal to this value.&lt;br /&gt;
** '''less_than''': ''$name'' is numerically less than this value.&lt;br /&gt;
** '''less_than_equal_to''': ''$name'' is numerically less than or equal to this value.&lt;br /&gt;
** '''boolean_equals''': ''$name'' has an equivalent boolean value.&lt;br /&gt;
** '''boolean_not_equals''': ''$name'' does not have an equivalent boolean value.&lt;br /&gt;
** '''formula''': {{DevFeature1.15|0}} ''$name'' satisfies the given [[Wesnoth_Formula_Language|WFL]] formula.&lt;br /&gt;
** '''blank''': {{DevFeature1.19|19}} ''$name'' is blank when this value is ''yes'' and not blank when this value is ''no''.&lt;br /&gt;
&lt;br /&gt;
====Boolean Values====&lt;br /&gt;
When values are evaluated as boolean values they are checked to see if they are ''false'' or ''true''.&lt;br /&gt;
&lt;br /&gt;
* These values are evaluated as ''true'': '''&amp;quot;yes&amp;quot;''' and '''&amp;quot;true&amp;quot;'''&lt;br /&gt;
* These values are evaluated as ''false'': '''&amp;quot;no&amp;quot;''', '''&amp;quot;false&amp;quot;''' and '''&amp;quot;&amp;quot;'''(uninitialized)&lt;br /&gt;
** However, in contexts where ''true'' is defined as the default value, an uninitialized value would be considered true. &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' Do not use &amp;quot;off&amp;quot;, &amp;quot;on&amp;quot;, integers, floating-point numbers or anything else than the above as booleans.&lt;br /&gt;
&lt;br /&gt;
====Formulas====&lt;br /&gt;
When using a formula, the variable's value can be referenced as '''value''' in the formula. This is a WFL representation of a config object that supports the following fields:&lt;br /&gt;
&lt;br /&gt;
* '''__all_children''': A list of key-value pairs, where the key is the tag name and the value is another config object representing the tag content.&lt;br /&gt;
* '''__children''': A map from tag name to a list of all children with that tag name.&lt;br /&gt;
* '''__attributes''': A map from attribute to value. Only useful if you specifically require a map for some reason.&lt;br /&gt;
* ''Any attribute name'': The value of that attribute&lt;br /&gt;
* ''Any tag name'': A list of all children with that tag name.&lt;br /&gt;
* Note that if there is a tag and an attribute with the same name, accessing it by name will return the attribute. You would need to use '''__children''' to access the tag.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you had a variable with the following WML content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[my_variable]&lt;br /&gt;
    stuff=777&lt;br /&gt;
    something=a value&lt;br /&gt;
    [something]&lt;br /&gt;
        value=42&lt;br /&gt;
    [/something]&lt;br /&gt;
    [another_tag]&lt;br /&gt;
        value=21&lt;br /&gt;
    [/another_tag]&lt;br /&gt;
    [subarray]&lt;br /&gt;
        value=8&lt;br /&gt;
    [/subarray]&lt;br /&gt;
    [subarray]&lt;br /&gt;
        value=91&lt;br /&gt;
    [/subarray]&lt;br /&gt;
    [another_tag]&lt;br /&gt;
        value=12&lt;br /&gt;
    [/another_tag]&lt;br /&gt;
[/my_variable]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then the formula could access the following variables on the '''value''' object:&lt;br /&gt;
* '''__all_children''': A list of ordered key-value pairs roughly equivalent to &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;['something' -&amp;gt; ['value' -&amp;gt; 42], 'another_tag' -&amp;gt; ['value' -&amp;gt; 21], 'subarray' -&amp;gt; ['value' -&amp;gt; 8], 'subarray' -&amp;gt; ['value' -&amp;gt; 91], 'another_tag' -&amp;gt; ['value' -&amp;gt; 12]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''__children''': A map roughly equivalent to &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;['something' -&amp;gt; [['value' -&amp;gt; 42]], 'another_tag' -&amp;gt; [['value' -&amp;gt; 21], ['value' -&amp;gt; 12]], 'subarray' -&amp;gt; [['value' -&amp;gt; 8], ['value' -&amp;gt; 91]]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''__attributes''': A map equivalent to &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;['stuff' -&amp;gt; 777, 'something' -&amp;gt; 'a value']&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''stuff''': The number &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;777&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''something''': The string &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;'a value'&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''another_tag''': A list roughly equivalent to &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;[['value' -&amp;gt; 21], ['value' -&amp;gt; 12]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''subarray''': A list roughly equivalent to &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;[['value' -&amp;gt; 8], ['value' -&amp;gt; 91]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|11}} When using a formula, you can now specify an additional key:&lt;br /&gt;
&lt;br /&gt;
* '''as_type''': Specifies the type of the '''value''' object in the formula. The default is ''wml'', which uses the structure as described above. The other supported options are:&lt;br /&gt;
** ''unit'': Interprets the variable's value as a stored unit, allowing you to write the formula the same way you would in a [[StandardUnitFilter]].&lt;br /&gt;
** ''weapon'': Interprets the variable's value as an attack type, allowing you to write the formula the same way you would in a [[StandardWeaponFilter]].&lt;br /&gt;
&lt;br /&gt;
=== [found_item] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}} Test if an item (i.e., a modification given by &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[DirectActionsWML#.5Bobject.5D|object]]]) has been found yet. Note: This will only detect objects added via ActionWML in an event in the same scenario. It will not detect objects added in [modifications] when a unit is created, nor objects added via [modify_unit] or the Lua wesnoth.add_modification function, nor objects added in a previous scenario in a campaign.&lt;br /&gt;
&lt;br /&gt;
* '''id''': The ID of the item to test. It must exactly match an [object] that has been taken for the test to pass.&lt;br /&gt;
&lt;br /&gt;
=== [proceed_to_next_scenario] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|10}} In SP, true if the scenario has been won.&lt;br /&gt;
&lt;br /&gt;
=== [lua] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}} Evaluate a lua expression, which must return a boolean value. Useful for writing one-off conditions that are difficult to express with other tags, but for much-used conditions it's better to define a custom condition tag using [[LuaAPI/wesnoth#wesnoth.wml_conditionals|wesnoth.wml_conditionals]].&lt;br /&gt;
&lt;br /&gt;
* '''code''': The Lua expression.&lt;br /&gt;
* '''name''': A name used to identify the tag in error messages.&lt;br /&gt;
* '''[args]''': Arbitrary data passed to the expression, accessible via &amp;lt;tt&amp;gt;...&amp;lt;/tt&amp;gt; in the Lua code.&lt;br /&gt;
&lt;br /&gt;
For example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
	name=new turn&lt;br /&gt;
	first_time_only=no&lt;br /&gt;
	[filter_condition]&lt;br /&gt;
		[lua]&lt;br /&gt;
			code = &amp;lt;&amp;lt; return (wml.variables.turn_number % 2 == 0) &amp;gt;&amp;gt;&lt;br /&gt;
		[/lua]&lt;br /&gt;
	[/filter_condition]&lt;br /&gt;
	[message]&lt;br /&gt;
		speaker=narrator&lt;br /&gt;
		message= &amp;quot;Hello world $turn_number|&amp;quot;&lt;br /&gt;
	[/message]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Meta-Condition Tags ===&lt;br /&gt;
&lt;br /&gt;
These tags aren't really conditions, themselves. Instead they are wrapped around condition tags to group them into multiple conditions that must all be met, lists of conditions that only one must be met, or conditions that must not be met. These are handled in top-to-bottom order in any combination you can think of. One important thing to remember is if you are using '''[or]''' tags, the first conditional statement should ''not'' have an '''[or]''' tag wrapped around it.&lt;br /&gt;
&lt;br /&gt;
; [and]&lt;br /&gt;
: A condition which must evaluate to true in addition to any other conditions that precede it. This is useful as a bracket for complex conditions, but not strictly necessary.&lt;br /&gt;
:* [[#Condition Tags|Condition Tags]]: If these evaluate to true, the '''[and]''' tag evaluates to true.&lt;br /&gt;
&lt;br /&gt;
; [or]&lt;br /&gt;
: A condition which, when false, has no effect, but when true, allows previously failed conditions to be ignored. &lt;br /&gt;
:* [[#Condition Tags|Condition Tags]]: If these evaluate to true, the '''[or]''' tag evaluates to true. &lt;br /&gt;
&lt;br /&gt;
; [not]&lt;br /&gt;
: Similar to [and], but its contents must be false. Thus it reverses the evaluation of its contents. Since a normal condition tag without contents is always considered true, an empty [not] is always considered false.&lt;br /&gt;
:* [[#Condition Tags|Condition Tags]]: If these evaluate to true, the '''[not]''' tag evaluates to false. If these evaluate to false, the '''[not]''' tag evaluates to true.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When multiple meta-conditions are encountered one after another in a containing tag, the evaluation order is as follows:&lt;br /&gt;
# the immediate contents of the containing tag are evaluated first to determine if there is a successful match known as a &amp;quot;true&amp;quot; condition&lt;br /&gt;
# this true or false result is combined with the top meta-condition to produce another true or false result&lt;br /&gt;
# this result is combined with the next meta-condition, and so on. However, if the engine recognizes that no remaining meta-conditions might reverse the result, it will cleverly skip them.&lt;br /&gt;
# if the final result is a successful match, then the [[:Category:ActionsWML|action]] will take place.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[SyntaxWML]]&lt;br /&gt;
* [[InternalActionsWML]]&lt;br /&gt;
* [[DirectActionsWML]]&lt;br /&gt;
* [[InterfaceActionsWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wml&amp;diff=74913</id>
		<title>LuaAPI/wml</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wml&amp;diff=74913"/>
		<updated>2026-03-20T21:09:25Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;wml&amp;lt;/tt&amp;gt; module contains functions for working with WML tables. This module is available starting in 1.14.0.&lt;br /&gt;
&lt;br /&gt;
A WML table is a specially-formatted Lua table representing WML tags and values. For more detail on the format of WML tables, see [[LuaWML#Encoding_WML_objects_into_Lua_tables|LuaWML]].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wml.attribute_count ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.attribute_count'''(''config'') &amp;amp;rarr; ''count''&lt;br /&gt;
&lt;br /&gt;
Returns the number of attributes in the specified WML table.&lt;br /&gt;
&lt;br /&gt;
=== wml.child_array ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.child_array'''(''config'', ''child_tag_name'') &amp;amp;rarr; ''array''&lt;br /&gt;
&lt;br /&gt;
Like [[#wml.child_range]], but returns an array instead of an iterator. Useful if you need random access to the children.&lt;br /&gt;
&lt;br /&gt;
=== wml.child_count ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.child_count'''(''config'', ''child_tag_name'') &amp;amp;rarr; ''count''&lt;br /&gt;
&lt;br /&gt;
Returns the number of children in the config with the given tag name.&lt;br /&gt;
&lt;br /&gt;
=== wml.child_range ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.child_range'''(''config'', ''child_tag_name'') &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''wml table''&lt;br /&gt;
&lt;br /&gt;
Returns an iterator over all the sub-tags of a WML object with the given name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local u = wesnoth.units.find_on_map{ id = &amp;quot;Delfador&amp;quot; }[1]&lt;br /&gt;
for att in wml.child_range(u.__cfg, &amp;quot;attack&amp;quot;) do&lt;br /&gt;
    wesnoth.message(tostring(att.description))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.find_child ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.find_child'''(''config'', [''tag_name''], ''filter'') &amp;amp;rarr; ''child or nil'', ''index''&lt;br /&gt;
&lt;br /&gt;
Finds a child of the given config that matches the given filter, and returns the child or nil if not found. The index of the child is also returned. If a tag name is specified, the search is restricted to that tag.&lt;br /&gt;
&lt;br /&gt;
=== wml.get_child ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.get_child'''(''config'', ''child_tag_name'', [''id'']) &amp;amp;rarr; ''child_table''&lt;br /&gt;
&lt;br /&gt;
Returns the first sub-tag of a WML object with the given name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local u = wesnoth.units.find_on_map{ id = &amp;quot;Delfador&amp;quot; }[1]&lt;br /&gt;
local costs = wml.get_child(u.__cfg, &amp;quot;movement_costs&amp;quot;)&lt;br /&gt;
wesnoth.message(string.format(&amp;quot;Delfador needs %d points to move through a forest.&amp;quot;, costs.forest))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a third parameter is passed, only children having a ''id'' attribute equal to it are considered.&lt;br /&gt;
&lt;br /&gt;
=== wml.get_nth_child ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.get_nth_child'''(''config'', ''child_tag_name'', ''n'') &amp;amp;rarr; ''child_table''&lt;br /&gt;
&lt;br /&gt;
Returns the ''n''th sub-tag of a WML object with the given name.&lt;br /&gt;
&lt;br /&gt;
=== wml.remove_child ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.remove_child'''(''config'', ''child_tag_name'')&lt;br /&gt;
&lt;br /&gt;
Deletes the first child tag with the given name. This does not work on vconfig objects, however.&lt;br /&gt;
&lt;br /&gt;
=== wml.remove_children ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.remove_children'''(''config'', ''child_tag_name'', ...)&lt;br /&gt;
&lt;br /&gt;
Deletes all child tags with the given names. This does not work on vconfig objects, however. You can pass as many tag names as you want as separate arguments.&lt;br /&gt;
&lt;br /&gt;
=== wml.tag ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.tag'''.''tag_name''(''contents'') &amp;amp;rarr; ''tag_table''&lt;br /&gt;
&lt;br /&gt;
Returns a table representing a tag within a WML table; can be used to create subtags with less brackets. It's common to use direct-table invocation for this, omitting the function parentheses.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.wml_actions.event { name = &amp;quot;new turn&amp;quot;, wml.tag.message { speaker = &amp;quot;narrator&amp;quot;, message = &amp;quot;?&amp;quot; } }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.clone ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.clone'''(''wml_table'') &amp;amp;rarr; ''cloned_table''&lt;br /&gt;
&lt;br /&gt;
Returns a clone (deep copy) of the passed WML table.&lt;br /&gt;
&lt;br /&gt;
=== wml.equal ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.equal'''(''config'', ''config'') &amp;amp;rarr; ''true or false''&lt;br /&gt;
&lt;br /&gt;
Tests whether two WML objects are equal. Equal objects will produce an empty diff, and will be serialized to the same string.&lt;br /&gt;
&lt;br /&gt;
=== wml.valid ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.valid'''(''table'') &amp;amp;rarr; ''is_wml''&lt;br /&gt;
&lt;br /&gt;
Tests whether the passed table represents a valid WML table. It will also return true if passed a vconfig.&lt;br /&gt;
&lt;br /&gt;
=== wml.valid_var ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|19}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.valid_var'''(''string'') &amp;amp;rarr; ''true or false''&lt;br /&gt;
&lt;br /&gt;
Returns true if input looks like WML variable path for [set_variables].&lt;br /&gt;
&lt;br /&gt;
=== wml.matches_filter ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.matches_filter'''(''WML table'', ''filter'')''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Test if a config matches a WML filter (as [[FilterWML#Filtering_on_WML_data|&amp;lt;tt&amp;gt;[filter_wml]&amp;lt;/tt&amp;gt;]]).&lt;br /&gt;
&lt;br /&gt;
=== wml.load ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.load'''(''file'', [''defines'', [''schema'']]) &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
Loads WML from a file and optionally validates it against a schema. The file and schema (if present) must both be a valid WML path, and the schema must point to a [[SchemaWML]] file. All built-in schema files can be found directly in the &amp;quot;schema&amp;quot; folder – for example, &amp;quot;schema/game_config.cfg&amp;quot; is the schema for an add-on's (and core's) _main.cfg.&lt;br /&gt;
&lt;br /&gt;
The second parameter can either be a boolean specifying whether or not to preprocess the file (defaults to true), or an array of macros to be defined in the preprocessor (which of course implies the file will be preprocessed). The second form only allows specifying names to be defined. It does not allow setting a value or anything more complex.&lt;br /&gt;
&lt;br /&gt;
=== wml.parse ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.parse'''(''string'', [''schema'']) &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
Parses a string containing WML code and optionally validates it against the provided schema. Unlike load, this function does ''not'' run the preprocessor, though &amp;lt;tt&amp;gt;#textdomain&amp;lt;/tt&amp;gt; directives will still be recognized.&lt;br /&gt;
&lt;br /&gt;
=== wml.merge ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.merge'''(''base table'', ''merge data'', [''mode'']) &amp;amp;rarr; ''merged config''&lt;br /&gt;
&lt;br /&gt;
Merges two WML tables recursively, using the specified mode. Possible modes are '''merge''', '''replace''', and '''append'''. The modes work the same as in [[InternalActionsWML#.5Bset_variables.5D|[set_variables]]]. The mode only affects how child tags are merged; merging of attributes is always done the same way. The default mode is '''merge'''.&lt;br /&gt;
&lt;br /&gt;
=== wml.diff ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.diff'''(''left'', ''right'') &amp;amp;rarr; ''diff config''&lt;br /&gt;
&lt;br /&gt;
Compares two WML tables and produces an output table in [[DiffWML]] detailing their differences.&lt;br /&gt;
&lt;br /&gt;
=== wml.patch ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.patch'''(''base'', ''diff'') &amp;amp;rarr; ''patched config''&lt;br /&gt;
&lt;br /&gt;
Takes a WML table and a diff in [[DiffWML]] format and returns a new WML table modified according to the diff's instructions.&lt;br /&gt;
&lt;br /&gt;
=== wml.interpolate ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
* '''wml.interpolate'''('''template''', '''variables''') &amp;amp;rarr; ''interpolated config''&lt;br /&gt;
&lt;br /&gt;
Interpolates variables into a WML table, including '''[insert_tag]'''. This is the same as what a vconfig does implicitly, but can use any valid WML table as a source of variables.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local variables = {&lt;br /&gt;
  -- A scalar variable&lt;br /&gt;
  number = 100,&lt;br /&gt;
  -- An array variable with two entries&lt;br /&gt;
  wml.tag.list{value = 42, rank = 3},&lt;br /&gt;
  wml.tag.list{value = 21, rank = 1},&lt;br /&gt;
}&lt;br /&gt;
local subst = {&lt;br /&gt;
  key = &amp;quot;$number&amp;quot;,&lt;br /&gt;
  wml.tag.insert_tag{&lt;br /&gt;
    name = &amp;quot;entry&amp;quot;,&lt;br /&gt;
    variable = &amp;quot;list&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
local result = wml.interpolate(subst, variables)&lt;br /&gt;
print(wml.tostring(result))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code will output the following WML in the Lua console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
key=100&lt;br /&gt;
[entry]&lt;br /&gt;
  rank=3&lt;br /&gt;
  value=42&lt;br /&gt;
[/entry]&lt;br /&gt;
[entry]&lt;br /&gt;
  rank=1&lt;br /&gt;
  value=21&lt;br /&gt;
[/entry]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.tostring ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.tostring'''(''wml_table'') &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
Takes a userdata with metatable wml object or a wml table and dumps its content into a pretty string. {{DevFeature1.15|0}} The string output is syntactically valid WML that if parsed would produce the same config.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wml.variables[&amp;quot;number&amp;quot;] = 100&lt;br /&gt;
local vconfig = wml.tovconfig({ key = &amp;quot;$number&amp;quot;, another_key = true,&lt;br /&gt;
    {&amp;quot;a_subtag&amp;quot;, { a_key_in_the_subtag = &amp;quot;foo&amp;quot; }}&lt;br /&gt;
})&lt;br /&gt;
wesnoth.message(wml.tostring(vconfig))&lt;br /&gt;
wesnoth.message(wml.tostring(vconfig.__literal))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.tovconfig ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.tovconfig'''(''config'') &amp;amp;rarr; ''vconfig''&lt;br /&gt;
&lt;br /&gt;
Converts a WML table into a proxy object which performs variable substitution on the fly. The proxy object can for most intents and purposes be treated as a read-only table - the length operator works as expected, as does the ipairs function. The pairs function also works, but it is a little different than on a plain table - it will return only the attributes of the vconfig and not the tags. See [[LuaWML#Encoding_WML_objects_into_Lua_tables|LuaWML]] for more information about the structure of a vconfig (which is the same as the structure of a WML table). A vconfig has four special keys (''__literal'', ''__parsed'', ''__shallow_literal'', ''__shallow_parsed'') which correspond to the functions in this module by the same name, but in most cases it is better to use the functions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wml.variables[&amp;quot;varname&amp;quot;] = &amp;quot;to_be_deleted&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- correct&lt;br /&gt;
wesnoth.wml_actions.clear_variable { name = &amp;quot;to_be_deleted&amp;quot; }&lt;br /&gt;
-- error: try to delete a variable literally called &amp;quot;$varname&amp;quot;&lt;br /&gt;
wesnoth.wml_actions.clear_variable { name = &amp;quot;$varname&amp;quot; }&lt;br /&gt;
-- correct: &amp;quot;$varname&amp;quot; is replaced by &amp;quot;to_be_deleted&amp;quot; at the right time&lt;br /&gt;
wesnoth.wml_actions.clear_variable(wml.tovconfig { name = &amp;quot;$varname&amp;quot; })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.literal ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.literal'''(''config'') &amp;amp;rarr; ''wml_table''&lt;br /&gt;
&lt;br /&gt;
Returns the ''__literal'' field of its argument if it is a userdata, the argument itself otherwise. If the argument is ''nil'', it returns an empty table. This function is meant to be called when a WML action handler can be called indifferently from WML (hence receiving a userdata) or from Lua (hence possibly receiving a table).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wml_actions.display_literal_value(cfg)&lt;br /&gt;
   cfg = wml.literal(cfg)&lt;br /&gt;
   wesnoth.message(tostring(cfg.value)) &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: when the argument is a plain table, the function returns it as is. In particular, modifying the fields of the returned table causes the original table to be modified too.&lt;br /&gt;
&lt;br /&gt;
=== wml.parsed ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.parsed'''(''config'') &amp;amp;rarr; ''wml_table''&lt;br /&gt;
&lt;br /&gt;
Returns the ''__parsed'' field of its argument if it is a userdata, the argument itself otherwise. See also [[#wml.literal]].&lt;br /&gt;
&lt;br /&gt;
=== wml.shallow_literal ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.shallow_literal'''(''config'') &amp;amp;rarr; ''wml_table''&lt;br /&gt;
&lt;br /&gt;
Returns the ''__shallow_literal'' field of its argument if it is a userdata, the argument itself otherwise. See also [[#wml.literal]].&lt;br /&gt;
&lt;br /&gt;
=== wml.shallow_parsed ===&lt;br /&gt;
&lt;br /&gt;
* '''wml.shallow_parsed'''(''config'') &amp;amp;rarr; ''wml_table''&lt;br /&gt;
&lt;br /&gt;
Returns the ''__shallow_parsed'' field of its argument if it is a userdata, the argument itself otherwise. See also [[#wml.literal]].&lt;br /&gt;
&lt;br /&gt;
=== wml.all_variables ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.all_variables''' &amp;amp;rarr; ''table''&lt;br /&gt;
&lt;br /&gt;
Returns a copy of all the WML variables currently set in the form of a WML table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
for key, value in pairs(wml.all_variables) do&lt;br /&gt;
    if type(value) == &amp;quot;table&amp;quot; then&lt;br /&gt;
        print(key, value[1], value[2])&lt;br /&gt;
    else&lt;br /&gt;
        print(key, value)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.variables ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.variables'''.''variable'' &amp;amp;harr; ''variable_contents''&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.variables'''[''variable_path''] &amp;amp;harr; ''variable_contents''&lt;br /&gt;
&lt;br /&gt;
This table grants read-write access to the WML variables by their fully-qualified name. Looking up a non-existent variable yields nil; otherwise, it returns a scalar for a WML attribute and a table for a WML object. The format of the table is described in [[LuaWML#Encoding WML objects into Lua tables]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.fire(&amp;quot;store_unit&amp;quot;, { variable=&amp;quot;my_unit&amp;quot;, { &amp;quot;filter&amp;quot;, { id=&amp;quot;hero&amp;quot; } } })&lt;br /&gt;
local heros_hp = wml.variables[&amp;quot;my_unit[0].hitpoints&amp;quot;]&lt;br /&gt;
wesnoth.message(string.format(&amp;quot;The 'hero' unit has %d hitpoints.&amp;quot;, heros_hp))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, if the variable name happens to designate a sequence of WML objects, only the first one (index 0) is fetched. If all the WML objects with this name should have been returned, use [[#wml.array_access.get]] instead. If you need a specific one, include the index in the lookup key.&lt;br /&gt;
&lt;br /&gt;
Assigning to a key in this table converts the Lua object to a WML variable if possible. For a table, a WML object is created; otherwise, an attribute is created. Note that you cannot assign a simple array as it will be mistaken for a WML table and give an error. Assigning nil clears the variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wml.variables[&amp;quot;my_unit.hitpoints&amp;quot;] = heros_hp + 10&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.variables_proxy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.variables_proxy'''.''variable'' &amp;amp;harr; ''proxy''&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.variables_proxy'''[''variable_path''] &amp;amp;harr; ''proxy''&lt;br /&gt;
&lt;br /&gt;
Similar to &amp;lt;tt&amp;gt;wml.variables&amp;lt;/tt&amp;gt;, but if the variable is a container, then the fields of the returned table are then proxies to the WML objects with the same names; reading/writing to them will directly access the WML sub-variables. Note that this is still somewhat experimental and doesn't allow you to fully treat variables as if they were standard Lua tables.&lt;br /&gt;
&lt;br /&gt;
=== wml.array_access.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.array_access.get'''(''var_name'', [''context'']) &amp;amp;rarr; ''array of variable_contents''&lt;br /&gt;
&lt;br /&gt;
Fetches all the WML container variables with given name and returns a table containing them (starting at index 1). The context specifies where to get variables from. You can pass either a unit or a side as the context in order to get an array from the unit variables or side variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function get_recall_list(side)&lt;br /&gt;
    wesnoth.fire(&amp;quot;store_unit&amp;quot;, { x = &amp;quot;recall&amp;quot;, variable = &amp;quot;LUA_recall_list&amp;quot; })&lt;br /&gt;
    local l = wml.array_access.get &amp;quot;LUA_recall_list&amp;quot;&lt;br /&gt;
    wml.variables.LUA_recall_list = nil&lt;br /&gt;
    return l&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.array_access.get_proxy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.array_access.get_proxy'''(''var_name'') &amp;amp;rarr; ''array of proxies''&lt;br /&gt;
&lt;br /&gt;
Creates proxies for all the WML container variables with given name and returns a table containing them (starting at index 1). This function is similar to [[#wml.array_access.get]], except that the proxies can be used for modifying WML containers. Note that changes to the returned array itself will not be reflected in the variable, however; only changes to the array elements.&lt;br /&gt;
&lt;br /&gt;
=== wml.array_access.set ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.array_access.set'''(''varname'', ''array'', [''context''])&lt;br /&gt;
&lt;br /&gt;
Creates WML container variables with given name from given table. The context specifies where to put the variables. You can pass either a unit or a side as the context in order to set an array in the unit variables or side variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wml.array_access.set(&amp;quot;target&amp;quot;, { {t=t1}, {t=t2}, {t=t3} })&lt;br /&gt;
-- target[0].t &amp;lt;- t1; target[1].t &amp;lt;- t2; target[2].t &amp;lt;- t3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wml.array_variables ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.array_variables'''.''variable'' &amp;amp;harr; ''array of variable_contents''&lt;br /&gt;
* {{LuaGameOnly}}{{LuaMapOnly}} '''wml.array_variables'''[''variable_path''] &amp;amp;harr; ''array of variable_contents''&lt;br /&gt;
&lt;br /&gt;
Like '''wml.variables''', except that it works on arrays as with '''wml.array_access.get''' and '''wml.array_access.set'''. This is a little more convenient when working with global WML variables rather than unit or side variables.&lt;br /&gt;
&lt;br /&gt;
=== wml.eval_conditional ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wml.eval_conditional'''(''conditional_tags'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Returns true if the conditional described by the WML table passes. Note: WML variables are substituted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local result = wml.eval_conditional {&lt;br /&gt;
  wml.tag.have_unit { id = &amp;quot;hero&amp;quot; },&lt;br /&gt;
  wml.tag.variable { name = &amp;quot;counter&amp;quot;, numerical_equals = &amp;quot;$old_counter&amp;quot; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Prior to 1.15.13, this was available as '''wesnoth.eval_conditional'''.&lt;br /&gt;
&lt;br /&gt;
=== wml.fire ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wml.fire'''(''tag'', ''parameters'')&lt;br /&gt;
* {{DevFeature1.17|17}} {{LuaGameOnly}} '''wml.fire'''.''tag''(''parameters'')&lt;br /&gt;
&lt;br /&gt;
Fire a WML action tag. Note: WML variables are substituted into the parameters table.&lt;br /&gt;
&lt;br /&gt;
Note: Prior to 1.15.13, this was available as '''wesnoth.fire'''. The second form was available through '''helper.set_wml_action_metatable'''.&lt;br /&gt;
&lt;br /&gt;
=== wml.error ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wml.error'''(''message'')&lt;br /&gt;
&lt;br /&gt;
Interrupts the current execution and displays a WML error message. This is intended for error messages in the implementaton of custom ActionWML or ConditionalWML tags. For errors in a Lua API, the built-in '''error''' function is a more suitable choice.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local names = cfg.name or wml.error(&amp;quot;[clear_variable] missing required name= attribute.&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Distributing_content&amp;diff=74519</id>
		<title>Distributing content</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Distributing_content&amp;diff=74519"/>
		<updated>2025-09-17T08:00:08Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Create}}&lt;br /&gt;
&lt;br /&gt;
You've completed your creation. You've tested it, polished it, and tweaked it. You feel confident that your add-on is the greatest achievement since the sandwich was invented. Now what? Make it available to the world!&lt;br /&gt;
&lt;br /&gt;
== The Add-on Server ==&lt;br /&gt;
&lt;br /&gt;
The add-on server is the preferred way to distribute your creations, whether it's a single map or a large campaign. The rules for publishing to the add-ons server are [https://forums.wesnoth.org/viewtopic.php?f=15&amp;amp;t=24320 here].&lt;br /&gt;
&lt;br /&gt;
In in order to publish an add-on to the server, you need to create a &amp;lt;b&amp;gt;_server.pbl&amp;lt;/b&amp;gt; file inside your add-on's directory. Detailed instructions on the syntax of the file are located on the [[PblWML]] page. The &amp;lt;b&amp;gt;_main.cfg&amp;lt;/b&amp;gt; file is also required, even for resource add-ons.&lt;br /&gt;
&lt;br /&gt;
Once you are ready to publish:&lt;br /&gt;
* Open Wesnoth&lt;br /&gt;
* Select &amp;lt;b&amp;gt;Add-ons&amp;lt;/b&amp;gt; from the main menu&lt;br /&gt;
* Connect to the default &amp;lt;i&amp;gt;add-ons.wesnoth.org&amp;lt;/i&amp;gt; add-on server&lt;br /&gt;
* In 1.12: Select your add-on, which will be the last entry in the list of add-ons. Then select &amp;lt;b&amp;gt;Publish add-on: &amp;lt;i&amp;gt;Your Add-on Name&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
* In 1.14: In the &amp;quot;State&amp;quot; drop-down above the list, select &amp;quot;Publishable&amp;quot;, and the list will show only your add-on. Select your add-on, then click on the shield icon with the upwards arrow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; If you haven't included a passphrase in the &amp;lt;b&amp;gt;_server.pbl&amp;lt;/b&amp;gt; file then Wesnoth will add a randomly-generated password to it. This password can be used to upload updates. {{DevFeature1.15|12}} it will prompt for a passphrase instead of randomly generating one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; By default, all files and folders inside the add-on's directory are uploaded, except those that begin with &amp;lt;b&amp;gt;'.'&amp;lt;/b&amp;gt; and those that end in &amp;lt;b&amp;gt;'~'&amp;lt;/b&amp;gt;. If you want to exclude any others, you may do so by creating a &amp;lt;b&amp;gt;_server.ign&amp;lt;/b&amp;gt; file and listing within it the files or folders you wish not to be uploaded (see [[IGNFileFormat]] for more information).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; A command-line interface to publish add-ons exists for those who prefer it. The script is located in a path like &amp;quot;/share/wesnoth/data/tools/wesnoth_addon_manager&amp;quot; (may depend on your OS and wesnoth version).&lt;br /&gt;
&lt;br /&gt;
==== License ====&lt;br /&gt;
&lt;br /&gt;
Whenever you upload or update your add-on, you will have to confirm that it is licensed as required by&lt;br /&gt;
* [[Wesnoth:Copyrights#User_Made_Content_-_Code]] and&lt;br /&gt;
* [[Wesnoth:Copyrights#User_Made_Content_-_Visual_and_Audio_Content]]&lt;br /&gt;
&lt;br /&gt;
When a user downloads your add-on, it will include the ART_LICENSE that you included and a COPYING.txt file containing a copy of the GNU GPL version 2, signifying the content is licensed under such.&lt;br /&gt;
&lt;br /&gt;
== The Forum ==&lt;br /&gt;
&lt;br /&gt;
Creating a thread on the [http://www.wesnoth.org/forum/ Wesnoth forums] is a good way to receive feedback for your add-on.  Making use of the [feedback] tag in your &amp;lt;b&amp;gt;_server.pbl&amp;lt;/b&amp;gt; is also highly recommended.&lt;br /&gt;
&lt;br /&gt;
While it is possible to upload your add-on directly to the forums, that is not recommended since it requires extra steps on the part of the downloader and limits the add-on's exposure to players who regularly visit the forum.&lt;br /&gt;
&lt;br /&gt;
== Version control distribution ==&lt;br /&gt;
&lt;br /&gt;
It is recommended that you create your own personal repository on a service such as [https://github.com/ GitHub]. This will allow tracking changes you make to your content, as well as make it easier for others to collaborate with you.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[PblWML]]&lt;br /&gt;
* [[IGNFileFormat]]&lt;br /&gt;
* [[Wesnoth:Copyrights]]&lt;br /&gt;
* [[Guide_to_UMC_Campaigns|Guide to UMC Campaigns]]&lt;br /&gt;
* [[AddonServers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Create]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaWML/Reorganization&amp;diff=74449</id>
		<title>LuaWML/Reorganization</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaWML/Reorganization&amp;diff=74449"/>
		<updated>2025-07-23T21:53:59Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a proposal to clean up and reorganize the existing set of Lua functions, helpers, tables, and proxy tables into a coherent, organized API, separated by category. The global wesnoth table would be the access point for the API categories, with subtables for each category within it from which the specific API item can be accessed (these subtables will essentially each represent a namespace). The idea would be to deprecate, but not immediately remove, the old access points, keeping them as valid aliases for a few versions to ensure backwards compatibility for developers and content creators and allowing them time to switch over.&lt;br /&gt;
&lt;br /&gt;
The status of this document is currently an unapproved draft proposal pending discussion, consensus, and implementation. If and when these changes are implemented, [[LuaWML]] should be kept intact to (a) temporarily serve as documentation for the deprecated access points and (b) permanently describe the [lua] tag and its usage. The new &amp;quot;Lua API&amp;quot; should then be documented on its own page by the same name.&lt;br /&gt;
&lt;br /&gt;
Some portions of the original proposal have already been implemented (though not always in precisely the proposed manner). These portions have been removed from this document; see the page history for more information on removed portions.&lt;br /&gt;
&lt;br /&gt;
Most names will remain the same, but some will be changed for consistency (ex: anything previously referring to a &amp;quot;tile&amp;quot; now refers to a &amp;quot;hex&amp;quot;), accuracy (ex: &amp;quot;theme_items&amp;quot; has nothing to do with themes or items (renamed to wesnoth.interface.game_display)), or because their category makes part of their name redundant (ex: &amp;quot;wesnoth.get_unit&amp;quot; is now &amp;quot;wesnoth.units.get&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Note also that the metatable functions are planned to be modified to no longer require a table to be passed in for use, and simply return a proxy table for whatever kind of metatable is being created, and as such, their names will be radically changed in this proposal to reflect their primary purpose (to get a proxy table which behaves a certain way). This also raises the question of why exactly certain data need to have a proxy returned from some creation function (such as the proxy for working with WML variables), and certain others are available through direct access to proxy tables (such as sides, game config, current, etc.), and others yes are modified through getters and/or setters despite being heavily id-based and thus prime candidates for proxy table usage (such as traits and eras). There is also the question of missing functionality and providing access to data which should be available but is not. These topics can and should be discussed and fleshed out as well, but are beyond the current scope of this document, which is to perform a one-to-one reorganization of existing functionality.&lt;br /&gt;
&lt;br /&gt;
In addition, the author of this proposal is very much aware that there are likely to be a great deal of differing opinions on how such a reorganization should take place, and therefore a [https://forums.wesnoth.org/viewtopic.php?f=10&amp;amp;t=44792 discussion has been opened on the forum]. Specific topics that are not set in stone are:&lt;br /&gt;
*Whether ALL API items should be within a category&lt;br /&gt;
*Whether the wesnoth table should, indeed, be the ONLY global table in the API&lt;br /&gt;
*Whether there should be a &amp;quot;misc&amp;quot; category for stuff that doesn't fit nicely anywhere else&lt;br /&gt;
*The specific names and categorizations of each specific API item&lt;br /&gt;
*Should the scope be expanded to drop functions and proxies which no longer make sense?&lt;br /&gt;
*Should the scope be expanded to modify the behavior of existing functions or proxies to make things more consistent?&lt;br /&gt;
*Pretty much anything and everything else about this proposal, indeed, all the way down to &amp;quot;should we even DO this at all?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The categories and names being proposed are as follows:&lt;br /&gt;
&lt;br /&gt;
== string ==&lt;br /&gt;
APIs for manipulation of strings&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.textdomain&lt;br /&gt;
|wesnoth.string.textdomain&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== output ==&lt;br /&gt;
APIs for the output of text messages&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.message&lt;br /&gt;
|wesnoth.output.message&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.clear_messages&lt;br /&gt;
|wesnoth.output.clear_messages&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.log&lt;br /&gt;
|wesnoth.output.log&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sound ==&lt;br /&gt;
APIs relating to sound&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.play_sound&lt;br /&gt;
|wesnoth.sound.play&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.set_music&lt;br /&gt;
|wesnoth.sound.set_music&lt;br /&gt;
|wesnoth.music.set or wesnoth.music.play?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.add_sound_source&lt;br /&gt;
|wesnoth.sound.add_source&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.remove_sound_source&lt;br /&gt;
|wesnoth.sound.remove_source&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_sound_source&lt;br /&gt;
|wesnoth.sound.get_source&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== map ==&lt;br /&gt;
APIs for working with the game map&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_map_size&lt;br /&gt;
|wesnoth.map.get_size&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_terrain&lt;br /&gt;
|wesnoth.map.get_terrain&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.set_terrain&lt;br /&gt;
|wesnoth.map.set_terrain&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_locations&lt;br /&gt;
|wesnoth.map.get_locations&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_villages&lt;br /&gt;
|wesnoth.map.get_villages&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_village_owner&lt;br /&gt;
|wesnoth.map.get_village_owner&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.set_village_owner&lt;br /&gt;
|wesnoth.map.set_village_owner&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.match_location&lt;br /&gt;
|wesnoth.map.location_matches&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.add_fog&lt;br /&gt;
|wesnoth.map.add_fog&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.remove_fog&lt;br /&gt;
|wesnoth.map.remove_fog&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_time_of_day&lt;br /&gt;
|wesnoth.map.get_time_of_day&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.add_time_area&lt;br /&gt;
|wesnoth.map.add_time_area&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.remove_time_area&lt;br /&gt;
|wesnoth.map.remove_time_area&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_starting_location&lt;br /&gt;
|wesnoth.map.get_side_starting_location&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.find_path&lt;br /&gt;
|wesnoth.map.find_path&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.find_vacant_tile&lt;br /&gt;
|wesnoth.map.find_vacant_hex&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.find_reach&lt;br /&gt;
|wesnoth.map.find_reach&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.find_cost_map&lt;br /&gt;
|wesnoth.map.find_cost_map&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.distance_between&lt;br /&gt;
|wesnoth.map.distance_between&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.adjacent_tiles&lt;br /&gt;
|wesnoth.map.adjacent_hex_iterator&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== file ==&lt;br /&gt;
APIs for working with files&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.dofile&lt;br /&gt;
|wesnoth.file.run&lt;br /&gt;
|Should this remain as &amp;quot;dofile&amp;quot;, which is the standard name used by lua?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.require&lt;br /&gt;
|wesnoth.file.require&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.read_file&lt;br /&gt;
|wesnoth.file.read&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_image_size&lt;br /&gt;
|wesnoth.file.image_size&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.have_file&lt;br /&gt;
|wesnoth.file.exists&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== game ==&lt;br /&gt;
APIs for working with game states and data&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.game_config&lt;br /&gt;
|wesnoth.game.config&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_era&lt;br /&gt;
|wesnoth.game.get_era&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.current&lt;br /&gt;
|wesnoth.game.current&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.synchronize_choice&lt;br /&gt;
|wesnoth.game.synchronize&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.set_next_scenario&lt;br /&gt;
|wesnoth.game.set_next_scenario&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.name_generator&lt;br /&gt;
|wesnoth.game.name_generator&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.compare_versions&lt;br /&gt;
|wesnoth.game.compare_versions&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_time_stamp&lt;br /&gt;
|wesnoth.game.get_time_stamp&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_terrain_info&lt;br /&gt;
|wesnoth.game.get_terrain_info&lt;br /&gt;
|Should this be in map?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.simulate_combat&lt;br /&gt;
|wesnoth.game.simulate_combat&lt;br /&gt;
|Should this be in unit?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.get_traits&lt;br /&gt;
|wesnoth.game.get_traits&lt;br /&gt;
|Should this be in unit?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.races&lt;br /&gt;
|wesnoth.game.races&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.game_events&lt;br /&gt;
|wesnoth.game.events&lt;br /&gt;
|Should this be somewhere else? If so, where?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== formula ==&lt;br /&gt;
APIs for working with [[Wesnoth Formula Language]]&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.eval_formula&lt;br /&gt;
|wesnoth.formula.evaluate&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.compile_formula&lt;br /&gt;
|wesnoth.formula.compile&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== math ==&lt;br /&gt;
Mathematical APIs&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.random&lt;br /&gt;
|wesnoth.math.random&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.rand&lt;br /&gt;
|wesnoth.math.randvar&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.round&lt;br /&gt;
|wesnoth.math.round&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.shuffle&lt;br /&gt;
|wesnoth.math.shuffle&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== action ==&lt;br /&gt;
APIs for working with [[ActionWML|WML actions]]&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.fire&lt;br /&gt;
|wesnoth.action.execute&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.wml_actions&lt;br /&gt;
|wesnoth.action.tags&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|helper.set_wml_action_metatable&lt;br /&gt;
|wesnoth.action.get_execution_table&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== event ==&lt;br /&gt;
APIs for working with [[EventWML|WML events]]&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.fire_event&lt;br /&gt;
|wesnoth.event.fire&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.fire_event_by_id&lt;br /&gt;
|wesnoth.event.fire_by_id&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.add_event_handler&lt;br /&gt;
|wesnoth.event.add_handler&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.remove_event_handler&lt;br /&gt;
|wesnoth.event.remove_handler&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== conditional ==&lt;br /&gt;
APIs for working with [[ConditionalActionsWML|WML conditionals]]&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.wml_conditionals&lt;br /&gt;
|wesnoth.conditional.tags&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.eval_conditional&lt;br /&gt;
|wesnoth.conditional.evaluate&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== effect ==&lt;br /&gt;
APIs for working with [[EffectWML|WML effects]]&lt;br /&gt;
{| border=1&lt;br /&gt;
!Old Access Point&lt;br /&gt;
!New Access Point&lt;br /&gt;
!Comments&lt;br /&gt;
|-&lt;br /&gt;
|wesnoth.effects&lt;br /&gt;
|wesnoth.effect.types&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:WML_Tags&amp;diff=74428</id>
		<title>Template:WML Tags</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Template:WML_Tags&amp;diff=74428"/>
		<updated>2025-07-14T09:01:43Z</updated>

		<summary type="html">&lt;p&gt;Laela: remove SavefileWML links from template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;reference-sidebar&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;span class=&amp;quot;editlink&amp;quot;&amp;gt;&amp;amp;#91;[{{SERVER}}{{localurl:Template:WML Tags|action=edit}} edit]&amp;amp;#93;&amp;lt;/span&amp;gt;'''[[ReferenceWML|WML Tags]]'''&lt;br /&gt;
|-&lt;br /&gt;
|''A:'' &lt;br /&gt;
[[AbilitiesWML#The .5Babilities.5D tag|abilities]],&lt;br /&gt;
[[CreditsWML#.5Babout.5D|about]],&lt;br /&gt;
[[AchievementsWML#.5Bachievement.5D|achievement]],&lt;br /&gt;
[[AchievementsWML#.5Bachievement_group.5D|achievement_group]],&lt;br /&gt;
[[Lua_AI_Legacy_Methods_Howto#Behavior_.28Sticky.29_Candidate_Actions|add_ai_behavior]],&lt;br /&gt;
[[AdvancedPreferenceWML|advanced_preference]],&lt;br /&gt;
[[UnitTypeWML#advancefrom|advancefrom]],&lt;br /&gt;
[[UnitTypeWML#After_max_level_advancement_.28AMLA.29|advancement]],&lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|advances]],&lt;br /&gt;
[[AbilitiesWML#affect_adjacent|affect_adjacent]],&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Top-level_Elements|ai]],&lt;br /&gt;
[[StandardSideFilter#allied_with|allied_with]], &lt;br /&gt;
[[DirectActionsWML#.5Ballow_end_turn.5D|allow_end_turn]],&lt;br /&gt;
[[DirectActionsWML#.5Ballow_extra_recruit.5D|allow_extra_recruit]],&lt;br /&gt;
[[DirectActionsWML#.5Ballow_recruit.5D|allow_recruit]],&lt;br /&gt;
[[DirectActionsWML#.5Ballow_undo.5D|allow_undo]],&lt;br /&gt;
[[ConditionalActionsWML#Meta-Condition_Tags|and]],&lt;br /&gt;
[[InterfaceActionsWML#.5Banimate_unit.5D|animate_unit]],&lt;br /&gt;
[[AnimationWML#The .5Banimation.5D tag|animation]],&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Aspects|aspect]],&lt;br /&gt;
attack ([[ReplayWML#attack|replay]], [[UnitTypeWML#Attacks|weapon]]),&lt;br /&gt;
[[AnimationWML#short-attack|attack_anim]],&lt;br /&gt;
attacks ([[AbilitiesWML#The_.5Bspecials.5D_tag|special]], [[StatisticalScenarioWML#The_.5Bteam.5D_tag|stats]]),&lt;br /&gt;
[[AiWML#avoid|avoid]];&lt;br /&gt;
|-&lt;br /&gt;
|''B:'' &lt;br /&gt;
[[UnitTypeWML#base_unit|base_unit]], &lt;br /&gt;
[[IntroWML#.5Bbackground_layer.5D|background_layer]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|berserk]], &lt;br /&gt;
[[BinaryPathWML|binary_path]],&lt;br /&gt;
[[InternalActionsWML#Flow_control_actions|break]],&lt;br /&gt;
[[EditorWML#The_.5Bbrush.5D_tag|brush]];&lt;br /&gt;
|-&lt;br /&gt;
|''C:'' &lt;br /&gt;
[[CampaignWML#The_.5Bcampaign.5D_tag|campaign]],&lt;br /&gt;
[[DirectActionsWML#.5Bcancel_action.5D|cancel_action]],&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bcandidate_action.5D_Tag|candidate_action]], &lt;br /&gt;
[[DirectActionsWML#.5Bcapture_village.5D|capture_village]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bswitch.5D|case]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|chance_to_hit]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bchange_theme.5D|change_theme]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bchat.5D|chat]],&lt;br /&gt;
[[OptionWML#checkbox|checkbox]],&lt;br /&gt;
[[OptionWML#choice|choice]],&lt;br /&gt;
[[ReplayWML#choose|choose]],&lt;br /&gt;
[[PersistenceWML#WML Syntax|clear_global_variable]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bclear_menu_item.5D|clear_menu_item]],&lt;br /&gt;
[[InternalActionsWML#.5Bclear_variable.5D|clear_variable]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bcolor_adjust.5D|color_adjust]],&lt;br /&gt;
[[GameConfigWML#Color_Palettes|color_palette]],&lt;br /&gt;
[[GameConfigWML#Color_Palettes|color_range]],&lt;br /&gt;
command&amp;amp;nbsp;([[ConditionalActionsWML#.5Bcommand.5D|action]], [[ReplayWML|replay]]),&lt;br /&gt;
[[InternalActionsWML#Flow_control_actions|continue]],&lt;br /&gt;
[[CoreWML|core]],&lt;br /&gt;
[[CreditsWML#.5Bcredits_group.5D|credits_group]],&lt;br /&gt;
[[AiWML#The_.5Bgoal.5D_Tag|criteria]];&lt;br /&gt;
|-&lt;br /&gt;
|''D:'' &lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|damage]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|damage_type]], &lt;br /&gt;
[[AnimationWML#short-death|death]], &lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|deaths]],&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Aspects|default]], &lt;br /&gt;
[[AnimationWML#short-defend|defend]],&lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|defends]],&lt;br /&gt;
[[UnitsWML#defense|defense]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bdelay.5D|delay]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bdeprecated_message.5D|deprecated_message]],&lt;br /&gt;
[[ReplayWML#attack|destination]],&lt;br /&gt;
[[CampaignWML#difficulty|difficulty]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|disable]],&lt;br /&gt;
[[DirectActionsWML#.5Bdisallow_end_turn.5D|disallow_end_turn]],&lt;br /&gt;
[[DirectActionsWML#.5Bdisallow_extra_recruit.5D|disallow_extra_recruit]],&lt;br /&gt;
[[DirectActionsWML#.5Bdisallow_recruit.5D|disallow_recruit]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bwhile.5D|do]], &lt;br /&gt;
[[DirectActionsWML#.5Bdo_command.5D|do_command]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|drains]], &lt;br /&gt;
[[AnimationWML#short-draw_weapon|draw_weapon_anim]];&lt;br /&gt;
|-&lt;br /&gt;
|''E:'' &lt;br /&gt;
[[EditorWML#The_.5Beditor_group.5D_tag|editor_group]],&lt;br /&gt;
[[EditorWML#The_.5Beditor_music.5D_tag|editor_music]],&lt;br /&gt;
[[EditorWML#The_.5Beditor_times.5D_tag|editor_times]],&lt;br /&gt;
[[EffectWML|effect]],&lt;br /&gt;
else&amp;amp;nbsp;([[ConditionalActionsWML#.5Bif.5D|action]], [[AnimationWML#Conditional Branches|animation]]), [[ConditionalActionsWML#.5Bif.5D|elseif]],&lt;br /&gt;
[[DirectActionsWML#.5Bendlevel.5D|endlevel]],&lt;br /&gt;
end_turn&amp;amp;nbsp;([[DirectActionsWML#.5Bend_turn.5D|action]], [[ReplayWML#end_turn|replay]]),&lt;br /&gt;
[[StandardSideFilter#enemy_of|enemy_of]], &lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Engines|engine]], &lt;br /&gt;
entry&amp;amp;nbsp;([[CreditsWML#.5Bentry.5D|credits]], [[OptionWML#entry|options]]),&lt;br /&gt;
[[EraWML|era]],&lt;br /&gt;
[[EventWML|event]],&lt;br /&gt;
[[StandardUnitFilter#filter_ability|experimental_filter_ability]],&lt;br /&gt;
[[StandardUnitFilter#filter_ability_active|experimental_filter_ability_active]],&lt;br /&gt;
[[AbilitiesWML#filter_specials|experimental_filter_specials]],&lt;br /&gt;
[[AnimationWML#short-extra|extra_anim]];&lt;br /&gt;
|-&lt;br /&gt;
|''F:''&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Aspects|facet]],&lt;br /&gt;
[[InterfaceActionsWML#.5Banimate_unit.5D|facing]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bmove_units_fake.5D|fake_unit]], &lt;br /&gt;
[[ConditionalActionsWML#.5Bfalse.5D|false]],&lt;br /&gt;
[[PblWML#.5Bfeedback.5D|feedback]],&lt;br /&gt;
[[UnitTypeWML#variation|female]], &lt;br /&gt;
filter ([[FilterWML|concept]], [[EventWML#.5Bfilter.5D|event]]),&lt;br /&gt;
[[StandardUnitFilter#filter_adjacent|filter_adjacent]], &lt;br /&gt;
[[StandardLocationFilter#filter_adjacent_location|filter_adjacent_location]], &lt;br /&gt;
[[FilterWML#Filtering_Weapons|filter_attack]],&lt;br /&gt;
[[AbilitiesWML#filter_attacker|filter_attacker]], &lt;br /&gt;
[[AbilitiesWML#filter_base_value|filter_base_value]], &lt;br /&gt;
[[EventWML#.5Bfilter_condition.5D|filter_condition]],&lt;br /&gt;
[[AbilitiesWML#filter_defender|filter_defender]], &lt;br /&gt;
[[AiWML#Filtering_Combat_with_the_attacks_Aspect|filter_enemy]],&lt;br /&gt;
[[StandardLocationFilter|filter_location]],&lt;br /&gt;
[[AbilitiesWML#filter_opponent|filter_opponent]], &lt;br /&gt;
[[AiWML#Filtering_Combat_with_the_attacks_Aspect|filter_own]],&lt;br /&gt;
[[StandardLocationFilter#filter_owner|filter_owner]], &lt;br /&gt;
[[StandardLocationFilter#filter_radius|filter_radius]], &lt;br /&gt;
[[SingleUnitWML#filter_recall|filter_recall]], &lt;br /&gt;
[[StandardUnitFilter|filter_second]],&lt;br /&gt;
[[FilterWML#Filtering_Weapons|filter_second_attack]],&lt;br /&gt;
[[AbilitiesWML#filter_self|filter_self]], &lt;br /&gt;
[[StandardSideFilter|filter_side]],&lt;br /&gt;
[[AbilitiesWML#filter_student|filter_student]], &lt;br /&gt;
[[FilterWML#Filtering_Vision|filter_vision]],&lt;br /&gt;
[[FilterWML#Filtering_Weapons|filter_weapon]], &lt;br /&gt;
[[FilterWML#Filtering_on_WML_data|filter_wml]],&lt;br /&gt;
[[InternalActionsWML#.5Bfind_path.5D|find_path]],&lt;br /&gt;
[[InternalActionsWML#.5Bfire_event.5D|fire_event]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|firststrike]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bfloating_text.5D|floating_text]],&lt;br /&gt;
[[FontsWML|fonts]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bfor.5D|for]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bforeach.5D|foreach]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bfound_item.5D|found_item]],&lt;br /&gt;
[[AnimationWML#The .5Bframe.5D tag|frame]];&lt;br /&gt;
|-&lt;br /&gt;
|''G:'' &lt;br /&gt;
[[GameConfigWML|game_config]],&lt;br /&gt;
[[PersistenceWML#WML Syntax|get_global_variable]],&lt;br /&gt;
[[AiWML#The_.5Bgoal.5D_Tag|goal]],&lt;br /&gt;
[[DirectActionsWML#.5Bgold.5D|gold]],&lt;br /&gt;
[[InterfaceActionsWML#objectives-gold_carryover|gold_carryover]];&lt;br /&gt;
|-&lt;br /&gt;
|''H:'' &lt;br /&gt;
[[DirectActionsWML#.5Bharm_unit.5D|harm_unit]],&lt;br /&gt;
[[StandardSideFilter#has_ally|has_ally]], &lt;br /&gt;
[[StandardUnitFilter#has_attack|has_attack]],&lt;br /&gt;
[[StandardSideFilter#has_unit|has_unit]], &lt;br /&gt;
[[ConditionalActionsWML#.5Bhas_achievement.5D|has_achievement]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bhave_location.5D|have_location]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bhave_side.5D|have_side]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bhave_unit.5D|have_unit]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|heal_on_hit]], &lt;br /&gt;
[[DirectActionsWML#.5Bheal_unit.5D|heal_unit]],&lt;br /&gt;
[[AnimationWML#short-healed|healed_anim]], &lt;br /&gt;
[[AnimationWML#short-healing|healing_anim]], &lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|heals]], &lt;br /&gt;
[[UnitsWML#.5Bhide_help.5D|hide_help]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bhide_unit.5D|hide_unit]],&lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|hides]];&lt;br /&gt;
|-&lt;br /&gt;
|''I:'' &lt;br /&gt;
[[AnimationWML#short-idle|idle_anim]], &lt;br /&gt;
if&amp;amp;nbsp;([[ConditionalActionsWML#.5Bif.5D|action]], [[AnimationWML#Conditional Branches|animation]], [[IntroWML|intro]]),&lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|illuminates]], &lt;br /&gt;
image&amp;amp;nbsp;([[IntroWML#.5Bimage.5D|intro]], [[TerrainGraphicsWML#The_.5Bimage.5D_subtag|terrain]]),&lt;br /&gt;
[[ReplayWML#init_side|init_side]],&lt;br /&gt;
[[VariablesWML#.5Binsert_tag.5D|insert_tag]],&lt;br /&gt;
[[InterfaceActionsWML#.5Binspect.5D|inspect]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bitem.5D|item]],&lt;br /&gt;
[[EditorWML#The_.5Bitem_group.5D_tag|item_group]];&lt;br /&gt;
|-&lt;br /&gt;
|''J:''&lt;br /&gt;
[[UnitsWML#jamming_costs|jamming_costs]],&lt;br /&gt;
[[InternalActionsWML#join|join]];&lt;br /&gt;
|-&lt;br /&gt;
|''K:'' &lt;br /&gt;
[[DirectActionsWML#.5Bkill.5D|kill]],&lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|killed]];&lt;br /&gt;
|-&lt;br /&gt;
|''L:'' &lt;br /&gt;
[[InterfaceActionsWML#.5Blabel.5D|label]],&lt;br /&gt;
[[LanguageWML|language]],&lt;br /&gt;
[[SideWML#leader|leader]],&lt;br /&gt;
[[AiWML#leader_goal|leader_goal]],&lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|leadership]], &lt;br /&gt;
[[AnimationWML#short-leading|leading_anim]], &lt;br /&gt;
[[AnimationWML#short-levelin|levelin_anim]],&lt;br /&gt;
[[AnimationWML#short-levelout|levelout_anim]], &lt;br /&gt;
[[DirectActionsWML#.5Blift_fog.5D|lift_fog]],&lt;br /&gt;
[[AI_Recruitment#instructions-limit|limit]],&lt;br /&gt;
[[InternalActionsWML#set_variables-literal|literal]],&lt;br /&gt;
[[AddonsWML#load_resource|load_resource]],&lt;br /&gt;
[[LocaleWML|locale]],&lt;br /&gt;
[[InterfaceActionsWML#.5Block_view.5D|lock_view]],&lt;br /&gt;
[[LuaWML|lua]];&lt;br /&gt;
|-&lt;br /&gt;
|''M:'' &lt;br /&gt;
[[UnitTypeWML#variation|male]],&lt;br /&gt;
[[ReplayWML#map_data|map_data]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bmessage.5D|message]],&lt;br /&gt;
[[Micro AIs|micro_ai]],&lt;br /&gt;
[[AnimationWML#The .5Bframe.5D tag|missile_frame]],&lt;br /&gt;
[[ModificationWML|modification]],&lt;br /&gt;
[[SingleUnitWML#modifications|modifications]],&lt;br /&gt;
[[DirectActionsWML#.5Bmodify_ai.5D|modify_ai]],&lt;br /&gt;
[[DirectActionsWML#.5Bmodify_side.5D|modify_side]],&lt;br /&gt;
[[DirectActionsWML#.5Bmodify_turns.5D|modify_turns]],&lt;br /&gt;
[[DirectActionsWML#.5Bmodify_unit.5D|modify_unit]],&lt;br /&gt;
[[AddonsWML#modify_unit_type|modify_unit_type]],&lt;br /&gt;
[[ReplayWML#move|move]],&lt;br /&gt;
[[DirectActionsWML#.5Bmove_unit.5D|move_unit]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bmove_unit_fake.5D|move_unit_fake]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bmove_units_fake.5D|move_units_fake]],&lt;br /&gt;
[[AnimationWML#short-movement|movement_anim]], &lt;br /&gt;
[[UnitsWML#movement_costs|movement costs]],&lt;br /&gt;
[[UnitsWML#.5Bmovetype.5D|movetype]],&lt;br /&gt;
[[ScenarioWML#The_.5Bmultiplayer.5D_tag|multiplayer]],&lt;br /&gt;
[[EraWML#Defining_Factions|multiplayer_side]],&lt;br /&gt;
[[MusicListWML#.5Bmusic.5D|music]];&lt;br /&gt;
|-&lt;br /&gt;
|''N:'' &lt;br /&gt;
[[ConditionalActionsWML#Meta-Condition_Tags|not]], &lt;br /&gt;
[[InterfaceActionsWML#objectives-note|note]];&lt;br /&gt;
|-&lt;br /&gt;
|''O:'' &lt;br /&gt;
[[DirectActionsWML#.5Bobject.5D|object]],&lt;br /&gt;
[[InterfaceActionsWML#objectives-objective|objective]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bobjectives.5D|objectives]],&lt;br /&gt;
[[DirectActionsWML#.5Bon_undo.5D|on_undo]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bopen_help.5D|open_help]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bmessage.5D|option]],&lt;br /&gt;
[[OptionWML|options]],&lt;br /&gt;
[[ConditionalActionsWML#Meta-Condition_Tags|or]];&lt;br /&gt;
|-&lt;br /&gt;
|''P:'' &lt;br /&gt;
[[IntroWML#.5Bpart.5D|part]], &lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|petrifies]], &lt;br /&gt;
[[DirectActionsWML#.5Bpetrify.5D|petrify]], &lt;br /&gt;
[[DirectActionsWML#.5Bplace_shroud.5D|place_shroud]], &lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|plague]], &lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|poison]], &lt;br /&gt;
[[AnimationWML#short-post_movement|post_movement_anim]], &lt;br /&gt;
[[AnimationWML#short-pre_movement|pre_movement_anim]], &lt;br /&gt;
[[InternalActionsWML#.5Bfire_event.5D|primary_attack]], &lt;br /&gt;
[[InternalActionsWML#.5Bfire_event.5D|primary_unit]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bprint.5D|print]], &lt;br /&gt;
[[DirectActionsWML#.5Bprogress_achievement.5D|progress_achievement]], &lt;br /&gt;
[[DirectActionsWML#.5Bput_to_recall_list.5D|put_to_recall_list]];&lt;br /&gt;
|-&lt;br /&gt;
|''R:'' &lt;br /&gt;
[[UnitsWML#.5Brace.5D|race]], &lt;br /&gt;
[[InternalActionsWML#.5Brandom_placement.5D|random_placement]], &lt;br /&gt;
recall&amp;amp;nbsp;([[DirectActionsWML#.5Brecall.5D|action]], [[ReplayWML#recall|replay]]), &lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|recalls]],&lt;br /&gt;
[[ReplayWML#recruit|recruit]], &lt;br /&gt;
[[AnimationWML#short-recruit|recruit_anim]], &lt;br /&gt;
[[AnimationWML#short-recruiting|recruiting_anim]], &lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|recruits]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bredraw.5D|redraw]],&lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|regenerate]],&lt;br /&gt;
[[InternalActionsWML#.5Bremove_event.5D|remove_event]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bremove_item.5D|remove_item]], &lt;br /&gt;
[[DirectActionsWML#.5Bremove_object.5D|remove_object]], &lt;br /&gt;
[[DirectActionsWML#.5Bremove_shroud.5D|remove_shroud]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bremove_sound_source.5D|remove_sound_source]], &lt;br /&gt;
[[DirectActionsWML#.5Bremove_time_area.5D|remove_time_area]], &lt;br /&gt;
[[DirectActionsWML#.5Bremove_trait.5D|remove_trait]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bremove_unit_overlay.5D|remove_unit_overlay]],&lt;br /&gt;
[[ConditionalActionsWML#.5Brepeat.5D|repeat]],&lt;br /&gt;
[[DirectActionsWML#.5Breplace_map.5D|replace_map]], &lt;br /&gt;
[[DirectActionsWML#.5Breplace_schedule.5D|replace_schedule]], &lt;br /&gt;
[[ReplayWML|replay]], &lt;br /&gt;
[[DirectActionsWML#.5Breset_fog.5D|reset_fog]], &lt;br /&gt;
resistance&amp;amp;nbsp;([[AbilitiesWML#The_.5Babilities.5D_tag|ability]], [[UnitsWML#resistance|unit]]),&lt;br /&gt;
[[UnitsWML#.5Bresistance_defaults.5D|resistance_defaults]],&lt;br /&gt;
[[ThemeWML#The_toplevel_.5Btheme.5D_tag|resolution]],&lt;br /&gt;
[[ModificationWML#The_.5Bresource.5D_toplevel_tag|resource]],&lt;br /&gt;
[[InternalActionsWML#Flow_control_actions|return]],&lt;br /&gt;
[[InternalActionsWML#.5Brole.5D|role]], &lt;br /&gt;
[[TerrainMaskWML#rule|rule]];&lt;br /&gt;
|-&lt;br /&gt;
|''S:'' &lt;br /&gt;
[[ScenarioWML#The_.5Bscenario.5D_tag|scenario]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bscreen_fade.5D|screen_fade]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bscroll.5D|scroll]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bscroll_to.5D|scroll_to]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bscroll_to_unit.5D|scroll_to_unit]], &lt;br /&gt;
[[InternalActionsWML#.5Bfire_event.5D|secondary_attack]], &lt;br /&gt;
[[InternalActionsWML#.5Bfire_event.5D|secondary_unit]], &lt;br /&gt;
[[HelpWML#section|section]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bselect_unit.5D|select_unit]], &lt;br /&gt;
[[ReplayWML#sequence|sequence]], &lt;br /&gt;
[[DirectActionsWML#.5Bset_achievement.5D|set_achievement]],&lt;br /&gt;
[[DirectActionsWML#.5Bset_extra_recruit.5D|set_extra_recruit]],&lt;br /&gt;
[[PersistenceWML#WML_Syntax|set_global_variable]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bset_menu_item.5D|set_menu_item]], &lt;br /&gt;
[[DirectActionsWML#.5Bset_recruit.5D|set_recruit]],&lt;br /&gt;
[[EffectWML#set_specials|set_specials]], &lt;br /&gt;
[[InternalActionsWML#.5Bset_variable.5D|set_variable]], &lt;br /&gt;
[[InternalActionsWML#.5Bset_variables.5D|set_variables]], &lt;br /&gt;
[[AnimationWML#short-sheath_weapon|sheath_weapon_anim]], &lt;br /&gt;
show_if&amp;amp;nbsp;([[InterfaceActionsWML#.5Bmessage.5D|message]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bobjectives.5D|objective]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bset_menu_item.5D|set_menu_item]]),&lt;br /&gt;
[[InterfaceActionsWML#.5Bshow_objectives.5D|show_objectives]],&lt;br /&gt;
[[SideWML|side]], &lt;br /&gt;
[[AbilitiesWML#The_.5Babilities.5D_tag|skirmisher]], &lt;br /&gt;
[[OptionWML#slider|slider]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|slow]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bsound.5D|sound]], &lt;br /&gt;
[[InterfaceActionsWML#.5Bsound_source.5D|sound_source]], &lt;br /&gt;
source&amp;amp;nbsp;([[ReplayWML#attack|replay]], [[DirectActionsWML#.5Btunnel.5D|teleport]]),&lt;br /&gt;
[[UnitTypeWML#Special Notes|special_note]],&lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|specials]], &lt;br /&gt;
[[InternalActionsWML#set_variables-split|split]],&lt;br /&gt;
[[Wesnoth_AI_Framework#The_.5Bai.5D_Tag_.E2.80.94_Stages|stage]], &lt;br /&gt;
[[AnimationWML#short-standing|standing_anim]], &lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bstatistics.5D_tag|statistics]],&lt;br /&gt;
[[SingleUnitWML#status|status]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_gold.5D|store_gold]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_items.5D|store_items]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_locations.5D|store_locations]],&lt;br /&gt;
[[InternalActionsWML#.5Bstore_map_dimensions.5D|store_map_dimensions]],&lt;br /&gt;
[[InternalActionsWML#.5Bstore_reachable_locations.5D|store_reachable_locations]],&lt;br /&gt;
[[InternalActionsWML#.5Bstore_relative_direction.5D|store_relative_direction]],&lt;br /&gt;
[[InternalActionsWML#.5Bstore_side.5D|store_side]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_starting_location.5D|store_starting_location]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_time_of_day.5D|store_time_of_day]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_turns.5D|store_turns]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_unit.5D|store_unit]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_unit_defense.5D|store_unit_defense]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_unit_defense_on.5D|store_unit_defense_on]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_unit_type.5D|store_unit_type]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_unit_type_ids.5D|store_unit_type_ids]], &lt;br /&gt;
[[InternalActionsWML#.5Bstore_villages.5D|store_villages]], &lt;br /&gt;
[[IntroWML|story]], &lt;br /&gt;
[[AbilitiesWML#The_.5Bspecials.5D_tag|swarm]], &lt;br /&gt;
[[AchievementsWML#.5Bsub_achievement.5D|sub_achievement]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bswitch.5D|switch]],&lt;br /&gt;
[[InternalActionsWML#.5Bsync_variable.5D|sync_variable]];&lt;br /&gt;
|-&lt;br /&gt;
|''T:'' &lt;br /&gt;
[[DirectActionsWML#.5Btunnel.5D|target]], &lt;br /&gt;
[[StatisticalScenarioWML#The_.5Bteam.5D_tag|team]],&lt;br /&gt;
teleport&amp;amp;nbsp;([[AbilitiesWML#Extra_tags_used_by_the_.5Bteleport.5D_ability|ability]], [[DirectActionsWML#.5Bteleport.5D|action]]),&lt;br /&gt;
[[AnimationWML#short-teleport|teleport_anim]],&lt;br /&gt;
[[DirectActionsWML#.5Bterrain.5D|terrain]], &lt;br /&gt;
[[UnitsWML#.5Bterrain_defaults.5D|terrain_defaults]],&lt;br /&gt;
[[TerrainGraphicsWML|terrain_graphics]], &lt;br /&gt;
[[TerrainMaskWML|terrain_mask]], &lt;br /&gt;
[[TerrainWML|terrain_type]], &lt;br /&gt;
[[ScenarioWML#The_.5Btest.5D_tag|test]],&lt;br /&gt;
[[InterfaceActionsWML#.5Btest_condition.5D|test_condition]],&lt;br /&gt;
[[TestWML#The_.5Btest_do_attack_by_id.5D_tag|test_do_attack_by_id]],&lt;br /&gt;
[[InterfaceActionsWML#message-text_input|text_input]], &lt;br /&gt;
[[GettextForWesnothDevelopers#The_textdomain_tag|textdomain]],&lt;br /&gt;
[[ThemeWML|theme]],&lt;br /&gt;
[[ConditionalActionsWML#.5Bif.5D|then]],&lt;br /&gt;
[[TerrainGraphicsWML#The_.5Btile.5D_subtag|tile]], &lt;br /&gt;
[[TimeWML|time]], &lt;br /&gt;
[[DirectActionsWML#.5Btime_area.5D|time_area]], &lt;br /&gt;
[[HelpWML#topic|topic]], &lt;br /&gt;
[[HelpWML#toplevel|toplevel]], &lt;br /&gt;
[[UnitsWML#.5Btrait.5D|trait]], &lt;br /&gt;
[[DirectActionsWML#.5Btransform_unit.5D|transform_unit]], &lt;br /&gt;
[[InternalActionsWML#.5Bfind_path.5D|traveler]], &lt;br /&gt;
[[ConditionalActionsWML#.5Btrue.5D|true]],&lt;br /&gt;
[[DirectActionsWML#.5Btunnel.5D|tunnel]];&lt;br /&gt;
|-&lt;br /&gt;
|''U:'' &lt;br /&gt;
[[InterfaceActionsWML#.5Bunhide_unit.5D|unhide_unit]], &lt;br /&gt;
unit&amp;amp;nbsp;([[DirectActionsWML#.5Bunit.5D|action]], [[SingleUnitWML|scenario]]), &lt;br /&gt;
[[InterfaceActionsWML#.5Bunit_overlay.5D|unit_overlay]], &lt;br /&gt;
[[UnitTypeWML|unit_type]], &lt;br /&gt;
[[InternalActionsWML#.5Bunit_worth.5D|unit_worth]], &lt;br /&gt;
[[UnitsWML|units]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bunlock_view.5D|unlock_view]],&lt;br /&gt;
[[DirectActionsWML#.5Bunpetrify.5D|unpetrify]], &lt;br /&gt;
[[DirectActionsWML#.5Bunstore_unit.5D|unstore_unit]],&lt;br /&gt;
[[InternalActionsWML#.5Bunsynced.5D|unsynced]];&lt;br /&gt;
|-&lt;br /&gt;
| ''V:'' &lt;br /&gt;
[[InternalActionsWML#set_variables-value|value]], &lt;br /&gt;
[[ConditionalActionsWML#.5Bvariable.5D|variable]],&lt;br /&gt;
[[VariablesWML#The_.5Bvariables.5D_tag|variables]],&lt;br /&gt;
[[TerrainGraphicsWML#variant|variant]],&lt;br /&gt;
[[UnitTypeWML#variation|variation]], &lt;br /&gt;
[[AnimationWML#short-victory|victory_anim]], &lt;br /&gt;
[[SideWML#village|village]],&lt;br /&gt;
[[UnitsWML#vision_costs|vision_costs]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bvolume.5D|volume]];&lt;br /&gt;
|-&lt;br /&gt;
| ''W:'' &lt;br /&gt;
[[ConditionalActionsWML#.5Bwhile.5D|while]],&lt;br /&gt;
[[InterfaceActionsWML#.5Bwml_message.5D|wml_message]],&lt;br /&gt;
[[SchemaWML|wml_schema]];&lt;br /&gt;
|-&lt;br /&gt;
| ''Z:''&lt;br /&gt;
[[InterfaceActionsWML#.5Bzoom.5D|zoom]];&lt;br /&gt;
|}&amp;lt;includeonly&amp;gt;[[Category:WML Reference]]&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;A box with all the WML tags, each one linking to the page and section they are described in. This box should be included in each of the [[ReferenceWML|WML reference]] pages.&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=74424</id>
		<title>InterfaceActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=74424"/>
		<updated>2025-07-06T12:14:08Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [message] */ second_image https://github.com/wesnoth/wesnoth/commit/cb63cd3778b870cd51c058fabaacc28db8b99e54&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Interface actions ==&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], interface actions are actions that do not have a direct 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;
== [inspect] ==&lt;br /&gt;
This user interface instantly displays the gamestate inspector dialog at the current scenario state (the same one that can be brought up with [[CommandMode|the ''':inspect''' command]]), which can be used to inspect the values of WML variables, AI configuration, recall lists, and more.&lt;br /&gt;
&lt;br /&gt;
* '''name''': optional attribute to specify the name of this gamestate inspector dialog. It is just a label to help differentiate between different invocations of gamestate inspector dialog.&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. Do not use a [filter] tag. 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 id 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;
* '''male_message''', '''female_message''': {{DevFeature1.13|2}} (translatable) Used instead of ''message'' if the unit's gender matches. Never used if there is no unit (ie ''speaker=narrator''). {{DevFeature1.13|6}} This matches the primary unit, not the secondary unit.&lt;br /&gt;
* '''wait_description''': {{DevFeature1.13|2}} the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]).&lt;br /&gt;
* '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
* '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number.&lt;br /&gt;
* '''image''': (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side. &lt;br /&gt;
** {{DevFeature1.13|0}} &amp;lt;b&amp;gt;none:&amp;lt;/b&amp;gt; display no image&lt;br /&gt;
* '''mirror''': {{DevFeature1.13|5}} whether to mirror the image specified by the '''image''' attribute.&lt;br /&gt;
* '''second_image''': {{DevFeature1.13|6}} same as the '''image''' attribute, but the image is displayed on the right of the message text. {{DevFeature1.17|7}} not working anymore {{DevFeature1.19|9}} working again&lt;br /&gt;
* '''second_mirror''': {{DevFeature1.13|6}} same as '''mirror''', but for the '''second_image''' attribute.&lt;br /&gt;
* '''image_pos''': {{DevFeature1.13|5}} whether to show the image on the left or right; supercedes the use of ~RIGHT() described above&lt;br /&gt;
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors.&lt;br /&gt;
* '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''.&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Boolean specifying whether to highlight the speaker. Defaults to ''yes''.&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;
* '''voice''', '''male_voice''', '''female_voice''': {{DevFeature1.13|?}} a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for '''message'''. They are never used when the speaker is the narrator - only '''voice''' is used in that case.&lt;br /&gt;
* {{anchor|message-option|'''[option]'''}}: No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events''&lt;br /&gt;
** '''message''': (translatable) the text displayed for the option. {{DevFeature1.15|1}} This is now a synonym for '''description='''.&lt;br /&gt;
** '''image''', '''label''', '''description''', '''default''': See [[DescriptionWML#WML_Format|DescriptionWML]].&lt;br /&gt;
** '''value''': {{DevFeature1.13|?}} Gives the option a value to be stored in a variable.&lt;br /&gt;
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
** '''[command]''': an element containing actions which are executed if the option is selected.&lt;br /&gt;
* '''variable''': {{DevFeature1.13|?}} If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has '''[show_if]''' condition evaluated as false, then it is hidden and excluded from the indexing.&lt;br /&gt;
* {{anchor|message-text_input|'''[text_input]'''}}: there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events''&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_length''': 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;
* Check [[EventWML#Multiplayer_safety]] to find out in which events you can safely use '''[option]''' and '''[text_input]''' without causing OOS.&lt;br /&gt;
&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
'''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [https://docs.gtk.org/Pango/pango_markup.html#pango-markup Pango markup formatting codes].&lt;br /&gt;
&lt;br /&gt;
Prefer to use single quotes (') instead of double quotes (&amp;quot;) within the formatting string, as double quotes would need to be escaped in WML (&amp;quot;&amp;quot;). Escaping markup can be done with [https://github.com/wesnoth/wesnoth/blob/9daa10a9f27c5a95520e871417bbd72aa52aa688/src/font/pango/escape.hpp#L38-L42 HTML entities].&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to write &amp;quot;You are victorious!&amp;quot; in large, italic, gold letters, you might write it this way:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;span color='#BCB088' size='large' font-style='italic'&amp;gt;You are victorious!&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are the codes taken from the Pango markup formatting guide:&lt;br /&gt;
&lt;br /&gt;
*'''font''', '''font_desc''': A font description string, such as &amp;quot;Sans Italic 12&amp;quot;.&lt;br /&gt;
*'''font_family''', '''face''': A font family name.&lt;br /&gt;
*'''font_size''', '''size''': Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.&lt;br /&gt;
*'''font_style''', '''style''': One of 'normal', 'oblique', 'italic'.&lt;br /&gt;
*'''font_weight''', '''weight''': One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.&lt;br /&gt;
*'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'.&lt;br /&gt;
*'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.&lt;br /&gt;
*'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's [https://github.com/GNOME/pango/blob/main/tools/rgb.txt rgb.txt] file.&lt;br /&gt;
*'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''underline''': One of 'none', 'single', 'double', 'low', 'error'.&lt;br /&gt;
*'''underline_color''': The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''rise''': Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.&lt;br /&gt;
*'''strikethrough''': 'true' or 'false' whether to strike through the text.&lt;br /&gt;
*'''strikethrough_color''': The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'&lt;br /&gt;
*'''fallback''': 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.&lt;br /&gt;
*'''letter_spacing''': Inter-letter spacing in 1024ths of a point.&lt;br /&gt;
*'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'.&lt;br /&gt;
*'''gravity_hint''': One of 'natural', 'strong', 'line'.&lt;br /&gt;
&lt;br /&gt;
The following pango attributes are also available directly as attributes of the '''[message]''' tag:&lt;br /&gt;
{{DevFeature1.13|4}}&lt;br /&gt;
&lt;br /&gt;
*'''font'''&lt;br /&gt;
*'''font_family'''&lt;br /&gt;
*'''font_size'''&lt;br /&gt;
*'''font_style'''&lt;br /&gt;
*'''font_weight'''&lt;br /&gt;
*'''font_variant'''&lt;br /&gt;
*'''font_stretch'''&lt;br /&gt;
*'''color'''&lt;br /&gt;
*'''bgcolor'''&lt;br /&gt;
*'''underline'''&lt;br /&gt;
*'''underline_color'''&lt;br /&gt;
*'''rise'''&lt;br /&gt;
*'''strikethrough'''&lt;br /&gt;
*'''strikethrough_color'''&lt;br /&gt;
*'''fallback'''&lt;br /&gt;
*'''letter_spacing'''&lt;br /&gt;
*'''gravity'''&lt;br /&gt;
*'''gravity_hint'''&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;
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. note: There are side-specific objectives and default objectives, which are used in case a side doesn't have specific ones. Specifying 0 sets the default ones.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Sets the objectives of all matching sides to these passed specifications (the rest of this [objectives] tag). If no sides (such as when passing side=0) or all sides match, sets the default objectives, and the side specific ones for the matching sides otherwise.&lt;br /&gt;
* '''bullet''': Default '• '. Replaces the default bullet, with whatever is passed, for all objectives, gold carryover notes, and notes defined with [note].&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. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''defeat_string''': Default ' _ &amp;quot;Defeat:&amp;quot;', this text precedes the defeat objectives. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''gold_carryover_string''': Default ' _ &amp;quot;Gold carryover:&amp;quot;', this text precedes the gold carryover information.&lt;br /&gt;
* '''notes_string''': Default ' _ &amp;quot;Notes:&amp;quot;', this text precedes the notes.&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;
* '''delayed_variable_substitution''': {{DevFeature1.13|8}} If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed.&lt;br /&gt;
&lt;br /&gt;
Tags of '''[objectives]''':&lt;br /&gt;
* {{anchor|objectives-objective|'''[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;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block.&lt;br /&gt;
** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255' for winning objectives, '0' for losing objectives. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''description''': text for the specific win or loss condition.&lt;br /&gt;
** '''caption''': a text which will be displayed above the ''description''. This can be used to display a subcategory of objectives below ''victory_string'' or ''defeat_string''.&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;
** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no.&lt;br /&gt;
** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only, or when manually opening the scenario objectives.&lt;br /&gt;
* {{anchor|objectives-gold_carryover|'''[gold_carryover]'''}}: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives].&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '192'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned.&lt;br /&gt;
** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned.&lt;br /&gt;
** '''[show_if]''': {{DevFeature1.13|11}} Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at '''[show_objectives]''' time only.&lt;br /&gt;
* {{anchor|objectives-note|'''[note]'''}}: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key.&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire note, including the bullet.&lt;br /&gt;
** '''blue''': Default '255'. Overrides the default blue coloring of the entire note, including the bullet.&lt;br /&gt;
** '''description''': the text of the note.&lt;br /&gt;
** '''[show_if]''': The note will not be shown if the specified condition isn't met. Conditional notes are refreshed at '''[show_objectives]''' time only.&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. The menu items can be set and modified during any event, for example during &amp;quot;start&amp;quot; or &amp;quot;prestart&amp;quot; events. The user can also assign hotkeys to these WML commands unless specified otherwise. When the hotkey is pressed the event will be fired/filtered at the current mouse position.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth.&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. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters.&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, defaults to &amp;quot;buttons/WML-custom.png&amp;quot;&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. {{DevFeature1.13|6}} ''needs_select=yes'' is deprecated, consider using manual variable syncing with [sync_variable].&lt;br /&gt;
* '''synced''' {{DevFeature1.13|1}}: if ''no'' (default ''yes'') the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with ''synced=no'' will cause OOS&lt;br /&gt;
* '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. &lt;br /&gt;
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) 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 [[StandardLocationFilter]] similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations.&lt;br /&gt;
* '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:&lt;br /&gt;
** '''key''': a string that contains the key to assign to this.&lt;br /&gt;
** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''':  boolean values.&lt;br /&gt;
** '''repeat_on_hold''' {{DevFeature1.13|12}}: if ''yes'' (default ''no''), holding the hotkey will repeat the action continuously, unless it blocks input with something like '''[message]'''. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.&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;
** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item.&lt;br /&gt;
&lt;br /&gt;
== [clear_menu_item] ==&lt;br /&gt;
&lt;br /&gt;
Removes a menu item from the scenario.&lt;br /&gt;
Normally menu items are, including all their defining wml, automatically carried over between scenarios. This tag prevents this. (The behavior is comparable to set_variable/clear_variable).&lt;br /&gt;
* '''id''': (string): id of the menu item to clear. Can be a comma-separated list.&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;
&lt;br /&gt;
=== [change_theme] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Change the current interface theme.&lt;br /&gt;
&lt;br /&gt;
* '''theme''': The ID of the new theme. Use &amp;lt;code&amp;gt;theme=&amp;lt;/code&amp;gt; (empty key) to switch back to the theme that the player has selected in Preferences. On &amp;lt;b&amp;gt;1.14.2&amp;lt;/b&amp;gt; and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine).&lt;br /&gt;
&lt;br /&gt;
=== [item] ===&lt;br /&gt;
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. (only for [event][item]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ImagePathFunctions#Blit_Function|BLIT]] the image onto &amp;lt;tt&amp;gt;misc/blank-hex.png&amp;lt;/tt&amp;gt; (a blank 72x72 image).)''&lt;br /&gt;
* '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image ([https://github.com/wesnoth/wesnoth/issues/1219 #1219]). ''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per [[AnimationWML]] is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100'' or equivalently (requires Wesnoth 1.11.2+): ''halo=scenery/fire[1~8].png:100''&lt;br /&gt;
* '''name''' an id that can be used to remove the item.&lt;br /&gt;
* '''team_name''': 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. {{DevFeature1.15|0}} In 1.14 the '''[side]team_name''' attribute was expected to be a substring of this '''team_name'''. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([https://github.com/wesnoth/wesnoth/pull/3533 #3533])&lt;br /&gt;
* '''visible_in_fog''': whether the item should be visible through fog or not. Default yes.&lt;br /&gt;
* '''submerge''': float, between 0 and 1: specifies how much of the image should be submerged. Gets multiplied with [[TerrainWML|[terrain]]]&amp;lt;nowiki/&amp;gt;submerge. Default 0.&lt;br /&gt;
* '''z_order''': float: defines the order the items get drawn in. Default 0.&lt;br /&gt;
* '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items.&lt;br /&gt;
* '''[filter_team]''': {{DevFeature1.15|0}} A [[StandardSideFilter]]. Set '''team_name''' to the union of all '''[side]team_name''' attributes of all sides that match the SSF. ([https://github.com/wesnoth/wesnoth/pull/3533 #3533])&lt;br /&gt;
* {{DevFeature1.15|0}} If both '''team_name''' and '''[filter_team]''' are set, '''team_name''' is ignored.&lt;br /&gt;
&lt;br /&gt;
=== [remove_item] ===&lt;br /&gt;
Removes any graphical items on a given hex.&lt;br /&gt;
* [[StandardLocationFilter]]: the hexes to remove items from&lt;br /&gt;
* '''image''': if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any [[ImagePathFunctions|image path functions]] appended to the original image name.)&lt;br /&gt;
&lt;br /&gt;
=== [print] ===&lt;br /&gt;
Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered.&lt;br /&gt;
* '''text''': (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one.&lt;br /&gt;
* '''size''': (default=12) the pointsize of the font to use&lt;br /&gt;
* '''duration''': the length of time to display the text for.&lt;br /&gt;
** (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms.&lt;br /&gt;
** {{DevFeature1.15|4}} This is measured in milliseconds. Don't use the default value, because it's a mere 50ms.&lt;br /&gt;
** {{DevFeature1.15|14}} The default is 5000 milliseconds.&lt;br /&gt;
** {{DevFeature1.15|14}} The string '''unlimited''' displays the text until it's removed by another [print] tag.&lt;br /&gt;
* '''color''': (default '''0,0,0''') three comma-separated values giving the red, green and blue values (0-255).&lt;br /&gt;
* '''red''', '''green''', '''blue''': deprecated, use color=0,0,0 instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit_fake] ===&lt;br /&gt;
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;
* '''gender''': the gender of the fake unit. Example: gender=female&lt;br /&gt;
* '''variation''': the variation of the fake unit. Example: variation=undead&lt;br /&gt;
* '''image_mods''': [[ImagePathFunctions|image path functions]] sequence to be applied on the fake unit.&lt;br /&gt;
* '''force_scroll''':  Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_units_fake] ===&lt;br /&gt;
moves multiple images of units along paths on the map. These units are moved in lockstep.&lt;br /&gt;
* '''force_scroll''': {{DevFeature1.15|0}} Has the same meaning as in [move_unit_fake] but a different default.&lt;br /&gt;
* '''[fake_unit]''': A fake unit to move&lt;br /&gt;
** '''type''': the type of 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;
** '''skip_steps''': the number of steps to skip before this unit starts moving&lt;br /&gt;
&lt;br /&gt;
=== [hide_unit] ===&lt;br /&gt;
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit.&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will be hidden&lt;br /&gt;
&lt;br /&gt;
=== [unhide_unit] ===&lt;br /&gt;
Stops the currently hidden units from being hidden.&lt;br /&gt;
* [[StandardUnitFilter]]: Only the matching units will be unhidden&lt;br /&gt;
&lt;br /&gt;
=== [lock_view] ===&lt;br /&gt;
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game.&lt;br /&gt;
&lt;br /&gt;
This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally.&lt;br /&gt;
&lt;br /&gt;
=== [unlock_view] ===&lt;br /&gt;
Unlocks gamemap view scrolling for human players.&lt;br /&gt;
&lt;br /&gt;
=== [scroll] ===&lt;br /&gt;
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;
* '''side''': the side or sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to] ===&lt;br /&gt;
Scroll to a given hex&lt;br /&gt;
* [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex being scrolled to (defaults to ''no'').&lt;br /&gt;
* '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to_unit] ===&lt;br /&gt;
Scroll to a given unit&lt;br /&gt;
* [[StandardUnitFilter]]; do not use a [filter] subtag.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex the unit is on (defaults to ''no'').&lt;br /&gt;
* '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
* '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [select_unit] ===&lt;br /&gt;
Selects a given unit.&lt;br /&gt;
* [[StandardUnitFilter]]: The first unit found will be selected.&lt;br /&gt;
* '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.)&lt;br /&gt;
* '''highlight''': whether the unit's current hex should be highlighted (def. ''yes'').&lt;br /&gt;
&lt;br /&gt;
'''Note:''' fire_event does not appear to work in 1.14 or 1.16.&lt;br /&gt;
&lt;br /&gt;
=== [sound]===&lt;br /&gt;
Plays a sound&lt;br /&gt;
* '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly.&lt;br /&gt;
* '''repeat''': repeats the sound for a specified additional number of times (default=0)&lt;br /&gt;
&lt;br /&gt;
=== [sound_source] ===&lt;br /&gt;
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 ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are fogged&lt;br /&gt;
* '''check_shrouded''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are shrouded&lt;br /&gt;
* '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source&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;
&lt;br /&gt;
=== [story] ===&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Shows the story screen.&lt;br /&gt;
* '''title''': Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title.&lt;br /&gt;
* '''[part]''', '''[if]''', '''[switch]''', '''[wml_message]''', '''[deprecated_message]''' : See [[IntroWML]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_sound_source] ===&lt;br /&gt;
Removes a previously defined sound source.&lt;br /&gt;
* '''id''': the identification key of the sound source to remove&lt;br /&gt;
&lt;br /&gt;
=== [music] ===&lt;br /&gt;
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;
&lt;br /&gt;
=== [volume] ===&lt;br /&gt;
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100:  &lt;br /&gt;
* '''music''':  Changes the music volume.&lt;br /&gt;
* '''sound''':  Changes the sound volume.&lt;br /&gt;
&lt;br /&gt;
=== [color_adjust] ===&lt;br /&gt;
Adjust the color tint of terrain, by adjusting time-of-day coloring.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color&lt;br /&gt;
&lt;br /&gt;
=== [screen_fade] ===&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from 0 to 255, the final overlay color (defaults to 0,0,0)&lt;br /&gt;
* '''alpha''': value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen.&lt;br /&gt;
* '''duration''': the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate.&lt;br /&gt;
&lt;br /&gt;
=== [delay] ===&lt;br /&gt;
Pauses the game.&lt;br /&gt;
* '''time''': the time to pause in milliseconds&lt;br /&gt;
* '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game.&lt;br /&gt;
&lt;br /&gt;
=== [redraw] ===&lt;br /&gt;
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;
* '''clear_shroud''' (boolean yes|no, default no): If yes, clears fog and shroud around existing units. 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;
* '''[[StandardSideFilter]]''': the sides for which to recalculate fog and shroud.&lt;br /&gt;
* '''side''': If used (forces clear_shroud=yes), clears fog and shroud for that side.&lt;br /&gt;
&lt;br /&gt;
=== [unit_overlay] ===&lt;br /&gt;
Sets an image that will be drawn over a particular unit, and follow it around&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter])&lt;br /&gt;
* '''image''': the image to place on the unit&lt;br /&gt;
* '''object_id''': object id to use, defaults to the '''image''' key with an &amp;quot;overlay_&amp;quot; prefix; this allows using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']]&lt;br /&gt;
* '''duration''': object duration&lt;br /&gt;
&lt;br /&gt;
=== [remove_unit_overlay] ===&lt;br /&gt;
Removes a particular overlayed image from a unit&lt;br /&gt;
* [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter])&lt;br /&gt;
* '''image''': the image to remove from the unit&lt;br /&gt;
* '''object_id''': object id to use&lt;br /&gt;
Using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271&lt;br /&gt;
&lt;br /&gt;
=== [animate_unit] ===&lt;br /&gt;
Uses an 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 custom animation in the unit description (see the '''[extra_anim]''' description in [[AnimationWML]]). Standard animations can be triggered with the following keywords: ''leading recruited standing idling levelout levelin healing healed poisoned movement defend attack death victory pre_teleport post_teleport''&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument, 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. Takes a weapon filter as argument, see [[FilterWML]].&lt;br /&gt;
* '''[secondary_attack]''': Similar to '''[primary_attack]'''. May be needed to trigger a defense animation correctly, if there are more than one animations available for the defending unit.&lt;br /&gt;
* '''hits''': yes/no/hit/miss/kill: which according variation of a attack/defense animation shall be chosen (required)&lt;br /&gt;
* '''text''': a text to hover during the animation &lt;br /&gt;
* '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
* '''red''': red value for the text color (0-255)&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''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar)&lt;br /&gt;
* '''[animate]''': a sub block with the same syntax as '''[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 hex the unit should be facing when animated&lt;br /&gt;
&lt;br /&gt;
=== [label] ===&lt;br /&gt;
Places a label on the map.&lt;br /&gt;
* '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''text''': what the label should say. If you put an empty string &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location.&lt;br /&gt;
* '''team_name''': if specified, the label will only be visible to the given team.&lt;br /&gt;
* '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255. When you use Pango markup in the text, you cannot use this, but in that case you could colorize the text via Pango markup.&lt;br /&gt;
* '''visible_in_fog''': whether the label should be visible through fog or not. Default yes.&lt;br /&gt;
* '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no.&lt;br /&gt;
* '''immutable''': whether this label is protected from being removed or changed by players. Default yes.&lt;br /&gt;
* '''category''': the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox.&lt;br /&gt;
* '''tooltip''': A tooltip visible when mouseovering the hex the label is on&lt;br /&gt;
* '''side''': the number of the side that placed the label. Can be 0 for labels placed by WML.&lt;br /&gt;
&lt;br /&gt;
=== [floating_text]===&lt;br /&gt;
Floats text (similar to the damage and healing numbers) on the given locations.&lt;br /&gt;
* [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units).&lt;br /&gt;
* '''text''': the text to display.&lt;br /&gt;
&lt;br /&gt;
The default text color is &amp;lt;span style=&amp;quot;color: #6b8cff;&amp;quot;&amp;gt;'''#6b8cff'''&amp;lt;/span&amp;gt;. To change the color, use [[#Formatting|Pango markup]]. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Float some golden yellow text at 20,20.&lt;br /&gt;
[floating_text]&lt;br /&gt;
   x,y=20,20&lt;br /&gt;
   text=&amp;quot;&amp;lt;span color='#cccc33'&amp;gt;&amp;quot; + _ &amp;quot;Your text here&amp;quot; + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
[/floating_text]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [deprecated_message] ===&lt;br /&gt;
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;
* '''level''': {{DevFeature1.13|10}} The deprecation level, a number from 1 to 3.&lt;br /&gt;
* '''what''': {{DevFeature1.13|10}} The name of the thing being deprecated. Use this instead of '''message''' if possible; a stock message will be generated from it. Use '''message''' only if more information is required; it will be appended to the stock message. This should not be translatable&lt;br /&gt;
* '''version''': {{DevFeature1.13|10}} For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does ''not'' indicate the version in which it became deprecated. &lt;br /&gt;
&lt;br /&gt;
The meanings of the deprecation levels are as follows:&lt;br /&gt;
&lt;br /&gt;
# Deprecated, but will only be removed if absolutely necessary. The '''version''' key is ignored.&lt;br /&gt;
# It will be removed no earlier than a specified version.&lt;br /&gt;
# It will be removed in the next stable version&lt;br /&gt;
# It has already been removed, leaving just a stub to inform users of how to update their code.&lt;br /&gt;
&lt;br /&gt;
Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The '''message''' can be translatable, but does not need to be.&lt;br /&gt;
&lt;br /&gt;
=== [wml_message] ===&lt;br /&gt;
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. WML wrapper of [[LuaAPI/wesnoth#wesnoth.log]], see the link for more description.&lt;br /&gt;
* '''message''': the message to show.&lt;br /&gt;
* '''to_chat''': controls whether message is visible in chat, though logger=wml means message is visible anyways. Default ''no''.&lt;br /&gt;
* '''logger''': one of '''info''', '''debug''', '''warning''', '''error''', '''wml'''. Default ''info''.&lt;br /&gt;
&lt;br /&gt;
=== [test_condition] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why.&lt;br /&gt;
&lt;br /&gt;
* '''result''': Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass.&lt;br /&gt;
* '''logger''': Same as for [wml_message]. Defaults to &amp;quot;warning&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [open_help] ===&lt;br /&gt;
Opens the in-game help.&lt;br /&gt;
* '''topic''': the id of the topic to open&lt;br /&gt;
&lt;br /&gt;
Examples of ids:&lt;br /&gt;
* unit_Mage&lt;br /&gt;
* unit_Dark Adept&lt;br /&gt;
* weaponspecial_charge&lt;br /&gt;
* terrain_human_castle&lt;br /&gt;
&lt;br /&gt;
The engine will print the topic ids if run from the command line with the ''--log-debug=help'' option.&lt;br /&gt;
&lt;br /&gt;
=== [show_objectives] ===&lt;br /&gt;
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.)&lt;br /&gt;
* '''side''': the side to show the objectives. If not set, all sides are used.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Tag affects the matching sides instead of just all or the one given by the integer value of the side= key.&lt;br /&gt;
&lt;br /&gt;
=== [chat] ===&lt;br /&gt;
Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: [[LuaWML:Display#wesnoth.message]]. {{DevFeature1.13|9}} can be visible for observers.&lt;br /&gt;
* '''speaker''': (default=&amp;quot;WML&amp;quot;) A string for the name of the sender of the message.&lt;br /&gt;
* '''message''': The message that should be displayed.&lt;br /&gt;
* '''observable''' (boolean yes|no, default yes): {{DevFeature1.13|9}} Whether the message is displayed for observers.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once.&lt;br /&gt;
&lt;br /&gt;
=== [zoom] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map.&lt;br /&gt;
&lt;br /&gt;
* '''factor''': The new zoom factor, measured as a multiple of the base zoom.&lt;br /&gt;
* '''relative''': If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no.&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;
* '''{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;
* '''{QUAKE &amp;lt;soundfile&amp;gt;}''' Creates a tremor-like screenshake and plays &amp;lt;soundfile&amp;gt;. For example, '''{QUAKE (rumble.ogg)}'''.&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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth&amp;diff=74408</id>
		<title>LuaAPI/wesnoth</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth&amp;diff=74408"/>
		<updated>2025-06-22T09:24:16Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* wesnoth.current */ user_is_replaying&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module contains most of the core Wesnoth API. It is always loaded and available.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.dofile ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.dofile'''(''file_path'', [...]) &amp;amp;rarr; ...&lt;br /&gt;
&lt;br /&gt;
Loads and executes a file. The rules for locating the files are the same as for WML files, except that they require a ''.lua'' extension instead of ''.cfg.'' Any extra parameters to '''dofile''' are forwarded to the script (which can access them via the special &amp;lt;tt&amp;gt;...&amp;lt;/tt&amp;gt; variable), and '''dofile''' returns all the values returned by the script.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.require ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.require'''(''module'') &amp;amp;rarr; ''module_contents''&lt;br /&gt;
&lt;br /&gt;
Returns the contents of the specified module, loading it if necessary. The module can either be a simple name or a file path similar to that used by '''wesnoth.dofile'''. In addition, the ''.lua'' extension will automatically be appended if necessary. The module script is invoked with no arguments, and '''wesnoth.require''' then passes back its first return value, discarding any additional ones. If the module is a directory, then all lua files are loaded, and a table containing the resulting modules is returned, with the keys being the filenames minus the ''.lua'' extension.&lt;br /&gt;
&lt;br /&gt;
'''wesnoth.require''' returns nil on failure, for example if it could not locate the module. If it did locate the module, but the module did not return anything (or returned nil), then '''wesnoth.require''' returns an empty table with a metatable that raises an error on any attempt to access it.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.textdomain ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.textdomain'''(''domain'') &amp;amp;rarr; ''textdomain_constructor''&lt;br /&gt;
&lt;br /&gt;
Returns a callable userdata that can be used to construct translatable strings. A typical use is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local _ = wesnoth.textdomain &amp;quot;example&amp;quot;&lt;br /&gt;
wesnoth.alert(_ &amp;quot;This is an example translated string!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full syntax for using the result of this function is:&lt;br /&gt;
&lt;br /&gt;
* ''textdomain_constructor''(''string'', [''string_plural'', ''number'']) &amp;amp;rarr; ''translatable_string''&lt;br /&gt;
&lt;br /&gt;
By passing the optional arguments, you can vary the string based on a number that will be substituted into it. As with all Lua functions, the parentheses are optional when passing a single string argument, as in the above example. This plural syntax returns a form of the string that's grammatically suitable for the indicated number, but doesn't actually substitute the number in – you need to do that yourself with either '''string.format''' or '''stringx.vformat'''.&lt;br /&gt;
&lt;br /&gt;
The returned translatable string can be treated in many ways like a regular string. Translatable strings can be compared with other translatable strings or concatenated with each other or with regular strings or integers. The length operator also works, though it should be noted that its value may change if the language is changed. If you need to pass a translatable string to a function that doesn't understand them, it can be converted to a regular string with tostring.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.log ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.log'''([''logger''], ''message'', ''in_chat'')&lt;br /&gt;
&lt;br /&gt;
Logs a message to the console. These messages are normally not visible unless Wesnoth is run from the command-line or (in Windows) with the --wconsole switch. The in_chat argument, however, can be set to true to also echo the message to the in-game chat area.&lt;br /&gt;
&lt;br /&gt;
''logger'' is the log level.&lt;br /&gt;
&lt;br /&gt;
In any context, ''logger'' can be the standard log levels of '''info''', '''debug''', '''warning''', or '''error'''. Various abbreviations of the standard four are also recognised. The default logger is '''info'''.&lt;br /&gt;
&lt;br /&gt;
In the game context, you can also set the ''logger'' to '''wml'''. The '''wml''' log level is special and is intended for WML errors; it always goes to chat, so the in_chat argument is ignored and can be omitted.&lt;br /&gt;
&lt;br /&gt;
The logdomain to enable these logs depends on the context. In the game context, they are written to the '''wml''' logdomain. In other contexts, the logdomain is '''scripting/lua/user'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.as_text ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|10}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.as_text'''(''value1'', ''value2'', ...)&lt;br /&gt;
&lt;br /&gt;
Accept one or more values as arguments and returns them as a string.  This is intended for use as an easy way to view the contents of lua tables.  Using the returned string for any other purpose is not supported.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}} This is now available in all contexts.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.simulate_combat ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.simulate_combat'''(''attacker'', [''attacker_weapon_index''], ''defender'', [''defender_weapon_index'']) &amp;amp;rarr; ''attacker stats evaluation'', ''defender stats evaluation'', ''attacker weapon evaluation'', ''defender weapon evaluation''&lt;br /&gt;
&lt;br /&gt;
Computes the hitpoint distribution and status chance after a combat between two units.  The first unit is the attacker. The attacker does not have to be on the map, but its location should be meaningful - that is, it can be a private-to-Lua clone of a unit with the '''x''' and '''y''' values changed, but whatever it is it has to have '''x''' and '''y''' values that allow attacking the defender (with '''max_range''' of the attack set appropriately it's possible to simulate attacking non-adjacent units). The second unit is the defender; it has to be on the map.&lt;br /&gt;
&lt;br /&gt;
Optional integers can be passed after each unit to select a particular weapon, otherwise the &amp;quot;best&amp;quot; one is selected.  When giving the weapon, the parameter is the weapon number (integer, starting at 1) and not the attack definition.&lt;br /&gt;
&lt;br /&gt;
The function returns four tables describing the evaluation of the combat. The first two contain an evaluation of the combatant's stats over the course of the fight, while the second two contains more detailed information on their weapons.&lt;br /&gt;
&lt;br /&gt;
The stats evaluation tables contain the following keys:&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''poisoned''' &amp;amp;rarr; ''probability''&lt;br /&gt;
* ''stats''.'''slowed''' &amp;amp;rarr; ''probability''&lt;br /&gt;
* ''stats''.'''untouched''' &amp;amp;rarr; ''probability''&lt;br /&gt;
&lt;br /&gt;
The probability that the unit will be poisoned or slowed, or that it will survive with no damage taken. (A scenario where the unit's hitpoints increase counts as untouched.)&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''average_hp''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The expected value of the unit's hitpoints after the fight.&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''hp_chance''' &amp;amp;rarr; ''mapping of hp to probability''&lt;br /&gt;
&lt;br /&gt;
The probability that the unit's hitpoints will be at a specific value after the fight. Though it looks almost like an array, it begins at index 0 unlike a typical Lua array. Thus, it's better understood as an associated mapping from the resulting hitpoints value to the probability of ending the combat with that value. Therefore, the value at index 0 represents the chance that the unit will die.&lt;br /&gt;
&lt;br /&gt;
The weapon evaluation tables contain the following keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Key !!Description&lt;br /&gt;
|-&lt;br /&gt;
|attack_num&lt;br /&gt;
| DEPRECATED (use '''number''').  Attack number (0 based, -1 for no attack).&lt;br /&gt;
|-&lt;br /&gt;
|chance_to_hit&lt;br /&gt;
|Effective chance to hit as a percentage (all factors accounted for). &lt;br /&gt;
|-&lt;br /&gt;
|damage&lt;br /&gt;
|Effective damage of the weapon (all factors accounted for).&lt;br /&gt;
|-&lt;br /&gt;
|drains&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|drains]] opponent when it hits.&lt;br /&gt;
|-&lt;br /&gt;
|drain_constant&lt;br /&gt;
|Base HP drained regardless of damage dealt.&lt;br /&gt;
|-&lt;br /&gt;
|drain_percent&lt;br /&gt;
|Percentage of damage recovered as health.&lt;br /&gt;
|-&lt;br /&gt;
|firststrike&lt;br /&gt;
|Attack has [[AbilitiesWML#The_.5Bspecials.5D_tag|firststrike]] special.&lt;br /&gt;
|-&lt;br /&gt;
|name&lt;br /&gt;
|Name (not description) of the attack.&lt;br /&gt;
|-&lt;br /&gt;
|number&lt;br /&gt;
|Attack number (1 based, 0 for no attack).&lt;br /&gt;
|-&lt;br /&gt;
|num_blows&lt;br /&gt;
|Effective number of blows (takes [[AbilitiesWML#The_.5Bspecials.5D_tag|swarm]] into account).&lt;br /&gt;
|-&lt;br /&gt;
|petrifies&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|petrifies]] opponent when it hits. &lt;br /&gt;
|-&lt;br /&gt;
|plagues&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|turns opponent into a zombie]] when fatal.&lt;br /&gt;
|-&lt;br /&gt;
|plague_type&lt;br /&gt;
|The [[AbilitiesWML#Extra_keys_used_by_the_.5Bplague.5D_special|plague type]] used by the attack, if any.&lt;br /&gt;
|-&lt;br /&gt;
|poisons&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|poisons]] opponent when it hits.&lt;br /&gt;
|-&lt;br /&gt;
|rounds&lt;br /&gt;
|[[AbilitiesWML#The_.5Bspecials.5D_tag|Berserk]] special can force us to fight more than one round.&lt;br /&gt;
|-&lt;br /&gt;
|slows&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|slows]] opponent when it hits.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local function display_stats(n, t)&lt;br /&gt;
    wesnoth.interface.add_chat_message(string.format(&lt;br /&gt;
        &amp;quot;Chance for the %s\n  to be slowed: %f,\n  to be poisoned: %f,\n  to die: %f.\nAverage HP: %f.&amp;quot;,&lt;br /&gt;
        n, t.slowed, t.poisoned, t.hp_chance[0], t.average_hp))&lt;br /&gt;
end&lt;br /&gt;
local att_stats, def_stats = wesnoth.simulate_combat(att, att_weapon, def, def_weapon)&lt;br /&gt;
display_stats(&amp;quot;attacker&amp;quot;, att_stats)&lt;br /&gt;
display_stats(&amp;quot;defender&amp;quot;, def_stats)&lt;br /&gt;
&lt;br /&gt;
local att_stats, def_stats, att_weapon, def_weapon = wesnoth.simulate_combat(attacker, att_weapon_number, defender)&lt;br /&gt;
wesnoth.interface.add_chat_message(string.format(&lt;br /&gt;
    &amp;quot;The attack %s should be countered with %s, which does %d damage, has %d%% chance to hit and forces %d attack rounds due to its berserk ability.&amp;quot;,&lt;br /&gt;
    att_weapon.name, def_weapon.name or &amp;quot;no weapon&amp;quot;, def_weapon.damage, def_weapon.chance_to_hit, def_weapon.rounds))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.name_generator ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.name_generator'''('''&amp;quot;markov&amp;quot;''', ''definition'', [''chain_size'', [''max_length'']]) &amp;amp;rarr; ''generator function''&lt;br /&gt;
* '''wesnoth.name_generator'''('''&amp;quot;cfg&amp;quot;''', ''definition'') &amp;amp;rarr; ''generator function''&lt;br /&gt;
* ''generator function''() &amp;amp;rarr; ''random name''&lt;br /&gt;
&lt;br /&gt;
Constructs a name generator for use in generating names using either the Markov chain algorithm used in older versions of Wesnoth or the context-free grammar generator used since 1.13.5. The type parameter indicates which algorithm to use (either markov or cfg). The definition can be a string, just like it would be in a config file, or it can be formatted as a table. Additional parameters may be passed, depending on the type of generator. The function returns a callable userdata, which will return a new name each time it is called (with no parameters).&lt;br /&gt;
&lt;br /&gt;
* '''Markov chain''': A Markov chain generator works by analyzing a list of input names and noticing tendencies in the way the letters are strung together. It can then apply those tendencies to produce new similar names that were not in the original list. Longer lists give better results. The definition is a list of names, formatted either as a comma-separated string or as an array-like table. The Markov generator can take two additional parameters.&lt;br /&gt;
** ''chain_size'': A value greater than 1 for the ''chain_size'' causes the analyzer to consider the words in chunks, which is similar to analyzing them syllable by syllable instead of letter by letter. The default chain size is 2, meaning that the analyzer treats words as consisting of 2-character syllables.&lt;br /&gt;
** ''max_length'': Places a cap on the total length of the name. The default value is 12 characters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local markov_names = wesnoth.name_generator('markov', {'Kaasa', 'Kayya', 'Keyya', 'Kiira', 'Korra'}, 1)&lt;br /&gt;
print(markov_names(), markov_names(), markov_names())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''Context-free grammar''': A [[context-free grammar]] is a way of specifying how strings can be constructed. The definition may be specified as a multi-line string, just as described in the preceding link, or it can be formatted as a table where the keys are non-terminals and the values are what they expand to. The expansion of each non-terminal can be formatted either as a |-separated list as described in the preceding link, or as an array-like table. (Mixing the two forms is permissible too.) The context-free generator has no additional parameters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local cfg_names = wesnoth.name_generator('cfg', {&lt;br /&gt;
  main = {'{prefix}{suffix}', '{prefix}{centre}{suffix}'},&lt;br /&gt;
  prefix = 'Kaa|Ka|Ke|Kuu|Ko',&lt;br /&gt;
  suffix = 'sa|yya|ra|rra',&lt;br /&gt;
  centre = 'err|aash|eez|azz'&lt;br /&gt;
})&lt;br /&gt;
print(cfg_names(), cfg_names(), cfg_names())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': If you want to generate a name using any of the default generators, you can use the predefined generators in the [[LuaAPI/types#race|race]] instead of constructing one with this function.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.compile_formula ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.compile_formula'''(''formula'') &amp;amp;rarr; ''compiled formula''&lt;br /&gt;
&lt;br /&gt;
Compiles a [[Wesnoth Formula Language]] formula into a Lua callable userdata. A compiled formula can be converted back to valid code using the built-in &amp;lt;code&amp;gt;tostring&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.eval_formula ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.eval_formula'''(''formula'', [''variables'']) &amp;amp;rarr; ''result''&lt;br /&gt;
* ''compiled formula''([''variables'']) &amp;amp;rarr; ''result''&lt;br /&gt;
&lt;br /&gt;
Evaluate a [[Wesnoth Formula Language]] formula and return the result it computed (which can be '''nil''').&lt;br /&gt;
&lt;br /&gt;
The passed in variables can be an arbitrary Lua table, which defines variables available to the formula. Unlike with WML tables, there is no restriction on the format of this table. The formula can access the variables as a list using the special WFL variable '''__list''', or as a map using the special WFL variable '''__map'''. Directly accessing keys on the table is also possible.&lt;br /&gt;
&lt;br /&gt;
It is also possible to pass a unit proxy as the variables, which evaluates the formula in that unit's context just as if it had been used in a [[StandardUnitFilter]].&lt;br /&gt;
&lt;br /&gt;
When calling '''wesnoth.eval_formula''', the first argument may either be an already-compiled formula or a string, in which case it will be automatically compiled on the fly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local f = wesnoth.compile_formula('if(x &amp;gt; y, x - y, x + y)')&lt;br /&gt;
&lt;br /&gt;
print(f{x=1,y=2}) -- prints 3.0&lt;br /&gt;
print(f{x=1,y=3}) -- prints 4.0&lt;br /&gt;
print(f{x=2,y=3}) -- prints 5.0&lt;br /&gt;
print(f{x=1,y=1}) -- prints 2.0&lt;br /&gt;
print(f{x=3,y=1}) -- prints 2.0&lt;br /&gt;
print(f{x=3,y=2}) -- prints 1.0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.version ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.version'''(''version string'') &amp;amp;rarr; ''version''&lt;br /&gt;
* '''wesnoth.version'''(''major'', [''minor'', [''patch'']], [''suffix'')) &amp;amp;rarr; ''version''&lt;br /&gt;
&lt;br /&gt;
Creates a version object, either by parsing a string or by building it from its component parts. The resulting version object can be compared with other version objects using the standard Lua comparison operators, which follows the same rules as the [[PreprocessorRef#.23ifver_and_.23ifnver|#ifver]] preprocessor statement. It can also be decomposed by accessing the following keys on the object:&lt;br /&gt;
&lt;br /&gt;
* ''integer'': Grab any integer version component by index. A non-canonical version may have more than three components.&lt;br /&gt;
* '''major''': The major version number (index 1).&lt;br /&gt;
* '''minor''': The minor version number (index 2).&lt;br /&gt;
* '''revision''': The patch revision number (index 3).&lt;br /&gt;
* '''is_canonical''': True if the version has at most three components (plus an optional suffix).&lt;br /&gt;
* '''sep''': The character that separates the version components from the suffix (usually either + or nil).&lt;br /&gt;
* '''special''': The version suffix, for example the &amp;quot;dev&amp;quot; in &amp;quot;1.15.14+dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The version can be converted to a string using the built-in '''tostring''' function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local function version_is_sufficient(required)&lt;br /&gt;
  return wesnoth.current_version() &amp;gt;= required&lt;br /&gt;
end&lt;br /&gt;
local required = wesnoth.version &amp;quot;1.9.6&amp;quot;&lt;br /&gt;
if not version_is_sufficient(required) then&lt;br /&gt;
  gui.alert(string.format(&amp;quot;Your BfW version is insufficient, please get BfW %s or greater!&amp;quot;, tostring(required)))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.current_version ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.current_version'''() &amp;amp;rarr; ''current version''&lt;br /&gt;
&lt;br /&gt;
Returns the current version of Wesnoth as a version object.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.ms_since_init ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.ms_since_init'''() &amp;amp;rarr; ''milliseconds''&lt;br /&gt;
&lt;br /&gt;
This function returns the amount of milliseconds that have passed since Wesnoth started up the current session. Its only use is to track the passage of real time.&lt;br /&gt;
&lt;br /&gt;
'''WARNING:''' this function uses the same code as [set_variable] time=stamp, and so it is MP-unsafe. It is provided only for benchmark purposes and AI development, although it should work inside wesnoth.synchronize_choice() as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.deprecated_message ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.deprecated_message'''(''element_name'', ''level'', ''version'', ''detail_message'')&lt;br /&gt;
&lt;br /&gt;
Displays a deprecation warning in the Lua console. The level is an integer from 1 to 4 inclusive (see [[CompatibilityStandards#Deprecation_levels_-_When_to_remove_deprecated_features|deprecation levels]]), and the version can be left nil for levels 1 and 4. Otherwise it must be a version ''string'' (not a version object from [[#wesnoth.version|wesnoth.version]]).&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.deprecate_api ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.deprecate_api'''(''original_name'', ''new_name'', ''level'', ''version'', ''element'', ''detail_message'') &amp;amp;rarr; ''deprecated wrapper''&lt;br /&gt;
&lt;br /&gt;
Creates a deprecated wrapper for a function or table. A deprecated function will raise the deprecated message the first time it's called, and then suppress it thereafter. A deprecated table will raise the deprecated message the first time a key is read or assigned, and then suppress it thereafter.&lt;br /&gt;
&lt;br /&gt;
The ''element'' is the function or table to wrap. It can be the original function or the new function (which may happen if the function was renamed without any interface changes), or a wrapper function that calls the new function while providing the interface of the old function. The ''level'' and ''version'' are as in [[#wesnoth.deprecated_message|wesnoth.deprecated_message]].&lt;br /&gt;
&lt;br /&gt;
If ''level'' is 4, then the ''element'' is ignored (you can pass '''nil''') and a generic deprecated wrapper is returned that does nothing but raises the deprecated message the first time you call it, assign a key, or read a key, and suppresses it thereafter. This is intended for a function that was removed without deprecation, to leave behind a more informative message if someone still attempts to use it.&lt;br /&gt;
&lt;br /&gt;
If Wesnoth is run with the &amp;lt;tt&amp;gt;--strict-lua&amp;lt;/tt&amp;gt; command-line option, this function will return '''nil''' instead of the deprecated wrapper. Since the normal use-case of this function is to assign the deprecated wrapper to the original name, this has the effect of erasing any deprecated functions from the API.&lt;br /&gt;
&lt;br /&gt;
The result of this function always contains a '''__deprecated''' attribute set to true, which can allow identifying if something is deprecated.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.type ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.type'''(''value'') &amp;amp;rarr; ''type name''&lt;br /&gt;
&lt;br /&gt;
Returns a string describing the value's type. This is the same as the built-in type function, except that it returns a more specific string in the case of userdata or tables, based on the metatable. For example, it would return 'unit' if called on a unit.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.named_tuple ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.named_tuple'''(''array'', ''names'') &amp;amp;rarr; ''named tuple''&lt;br /&gt;
&lt;br /&gt;
Decorates a numeric based array so that the indices can be accessed by name instead of by index. This function is used internally for a number of things, most notably map locations and WML tags. Most end-users will not need to use it, but it could be useful if you wish to build a Lua API that returns locations (or similar data) in the engine-standard format.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local t = wesnoth.named_tuple({42,21,36}, {'x', 'y', 'z'})&lt;br /&gt;
&lt;br /&gt;
print(t[1]) -- prints 42&lt;br /&gt;
print(t[2]) -- prints 21&lt;br /&gt;
print(t[3]) -- prints 36&lt;br /&gt;
print(t.x) -- prints 42&lt;br /&gt;
print(t.y) -- prints 21&lt;br /&gt;
print(t.z) -- prints 36&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.get_language ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.get_language'''() &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
Gets the language the UI is currently set to. Note that this may return an empty string if using the system default language.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.print_attributes ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.print_attributes'''(''object'', [''function''])&lt;br /&gt;
&lt;br /&gt;
Prints out a list of attributes that can be accessed on the object, excluding deprecated functionality. The function defaults to '''print''', and receives a formatted line usually containing multiple attributes. They are annotated by type – &amp;amp;fnof; for a function, &amp;amp;dagger; for a table, ! if there was an error attempting to determine the type (which includes write-only attributes). Other types are unannotated.&lt;br /&gt;
&lt;br /&gt;
For tables, by default this iterates the table using '''pairs''' to discover the attributes available, walking the metatable hierarchy if there is an '''__index''' table and filtering out anything that contains a '''__deprecated''' attribute set to '''true'''. However, if finds a function as the '''__index''', and the table's metatable also has a member '''__dir''', it will be used instead. The '''__dir''' can either be an array of strings, or a function that returns an array of strings. It will automatically be sorted and have any duplicates filtered out.&lt;br /&gt;
&lt;br /&gt;
For custom objects defined by the engine, there is special handling so that this function shows the correct result. For example, if used on a GUI2 widget object, it will show the attributes available for that type of widget, as well as the IDs of any sub-widgets that can be accessed by name.&lt;br /&gt;
&lt;br /&gt;
In the Lua console only, this function can also be referenced by a shorter alias, '''dir'''.&lt;br /&gt;
&lt;br /&gt;
== Hooks ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.persistent_tags ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.persistent_tags'''.''action''.'''read''' &amp;amp;harr; '''function'''(''wml content'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.persistent_tags'''.''action''.'''write''' &amp;amp;harr; '''function'''(''add_tag_function'')&lt;br /&gt;
&lt;br /&gt;
This is an associative table defining tags that should be persisted in saved games. Each tag is itself a table containing two functions, read and write. The write function is called in &amp;lt;tt&amp;gt;on_load&amp;lt;/tt&amp;gt; and passed a function as a parameter which takes a WML table and adds it to the saved game under the specified tag; the read function is called once per matching tag found in the saved game, and is passed a WML table of its contents. Note the asymmetry here: if you're saving an array, the write function is responsible for saving the entire array (and is only called once), while the read function is only responsible for loading one item (and is called several times).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local inventory = {}&lt;br /&gt;
&lt;br /&gt;
function wesnoth.persistent_tags.inventory.read(cfg)&lt;br /&gt;
    inventory[cfg.side] = cfg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function wesnoth.persistent_tags.inventory.write(add)&lt;br /&gt;
    for i = 1, #wesnoth.sides do&lt;br /&gt;
        add(inventory[i])&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that you don't need to create &amp;lt;tt&amp;gt;wesnoth.persistent_tags.inventory&amp;lt;/tt&amp;gt; as an empty table first; you can simply define the read and write functions.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.wml_actions ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.wml_actions'''.''action'' &amp;amp;harr; '''function'''(''wml parameters table'')&lt;br /&gt;
&lt;br /&gt;
This is a hook table that exposes and defines WML actions. Each function in this table corresponds to a single ActionWML tag, allowing you to invoke tags, define custom tags, and even modify the behavior of built-in tags. The single argument to these functions is a WML table, the content of the tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_actions.freeze_unit(cfg)&lt;br /&gt;
    local unit_id = cfg.id or wml.error &amp;quot;[freeze_unit] expects an id= attribute.&amp;quot;&lt;br /&gt;
    local unit = wesnoth.units.get(unit_id)&lt;br /&gt;
    if unit then unit.moves = 0 end&lt;br /&gt;
    wesnoth.units.modify({ id = unit_id }, { moves = 0 })&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The new tag can now be used in plain WML code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[freeze_unit]&lt;br /&gt;
    id=Delfador&lt;br /&gt;
[/freeze_unit]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can override functions already assigned to the table. This is useful if you need to extend functionality of core tags. For instance, the following script overrides the [[InterfaceActionsWML#Other interface tags|[print]]] tag so that messages are displayed with a bigger font.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_actions.print(cfg)&lt;br /&gt;
    local modified_cfg = setmetatable({}, {__index = cfg})&lt;br /&gt;
    modified_cfg.size = (cfg.size or 12) + 10&lt;br /&gt;
    wesnoth.wml_actions.print(modified_cfg)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An action handler should be able to handle being called with either a WML table or a WML vconfig userdata. It is recommended to pass the argument through ''wml.tovconfig'' before doing anything with it, both in the action's definition and when calling it directly (in case its definition did not do that). The engine always passes a vconfig when calling a WML action.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.wml_conditionals ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.wml_conditionals'''.''action'' &amp;amp;harr; '''function'''(''wml parameters table'') &amp;amp;rarr; ''boolean result''&lt;br /&gt;
&lt;br /&gt;
This is a hook table like wesnoth.wml_actions. You can use it to define new ConditionalWML tags that will be recognized in WML when using [if], [show_if], [while], etc., or more generally when [[../wml#wml.eval_conditional|'''wml.eval_conditional''']] is run.&lt;br /&gt;
&lt;br /&gt;
Use it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_conditionals.foo(cfg)&lt;br /&gt;
    local bar = cfg.bar or wml.error(&amp;quot;[foo] tag did not have 'bar' attribute&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    return (bar == &amp;quot;baz&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this lua code is executed, it would make the following syntax be valid WML in your add-on:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[if]&lt;br /&gt;
   [foo]&lt;br /&gt;
      bar = $X&lt;br /&gt;
   [/foo]&lt;br /&gt;
   [then]&lt;br /&gt;
      [message]&lt;br /&gt;
         # ...&lt;br /&gt;
      [/message]&lt;br /&gt;
   [/then]&lt;br /&gt;
[/if]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the basic logic tags of ConditionalWML (true, false, and, or, not) do not pass through this table and cannot be overridden.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.effects ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name'' &amp;amp;harr; '''function'''(''unit'', ''wml table'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name''.'''__descr''' &amp;amp;harr; ''description''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name''.'''__descr''' &amp;amp;harr; '''function'''(''unit'', ''wml table'') &amp;amp;rarr; ''description''&lt;br /&gt;
&lt;br /&gt;
This table contains the implementation of [[EffectWML|[effect]]]s. Each value is a callable value that takes a unit and the effect config. It can be a function or a callable table. If it is a callable table, its metatable may have a '''__descr''' field which is either a string or a function. Built-in effects are present in this table, and you may register your own custom effects too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
function wesnoth.effects.min_resistance(u, cfg)&lt;br /&gt;
	local resistance_new = {}&lt;br /&gt;
	local resistance_old = wml.parsed(wml.get_child(cfg, &amp;quot;resistance&amp;quot;))&lt;br /&gt;
	for k,v in pairs(resistance_old) do&lt;br /&gt;
		if type(k) == &amp;quot;string&amp;quot; and type(v) == &amp;quot;number&amp;quot; and u:resistance_to(k) &amp;gt;= v then&lt;br /&gt;
			resistance_new[k] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	wesnoth.effects.resistance(u, {&lt;br /&gt;
		apply_to = &amp;quot;resistance&amp;quot;,&lt;br /&gt;
		replace = true,&lt;br /&gt;
		T.resistance (resistance_new),&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code above adds a new &amp;lt;code&amp;gt;min_resistance&amp;lt;/code&amp;gt; effect that will set the resistances to specific values if they are currently below that value. It can then be used like this (for example, in [[DirectActionsWML#.5Bobject.5D|[object]]]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[effect]&lt;br /&gt;
  apply_to=min_resistance&lt;br /&gt;
  [resistance]&lt;br /&gt;
    cold=50&lt;br /&gt;
  [/resistance]&lt;br /&gt;
[/effect]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in order work properly, effects must be registered before any units are created. This means it must be placed into a global or scenario level [lua] tag. In particular, the preload event is too late.&lt;br /&gt;
&lt;br /&gt;
You can also specify description modifiers, which will be used if a custom effect is placed in a &amp;lt;code&amp;gt;[trait]&amp;lt;/code&amp;gt; tag. Instead of setting a function as the effect, you set a table with a &amp;lt;code&amp;gt;__call&amp;lt;/code&amp;gt; metafunction which does what the function would have done. The table can then have an additional &amp;lt;code&amp;gt;__descr&amp;lt;/code&amp;gt; metafunction which updates descriptions as necessary. The built-in effects all use this structure. This metafunction takes the same arguments as the regular effect function, but should not modify the unit. Instead, it returns a string to be appended to the trait's effect description.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.micro_ais ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.micro_ais'''.''ai_name'' &amp;amp;harr; ''function''(''cfg'') &amp;amp;rarr; ''required'', ''optional'', ''ca_params''&lt;br /&gt;
&lt;br /&gt;
Registers a new [[Micro_AIs#Custom_Micro_AIs|MicroAI]] with '''ai_type'''=''ai_name''. The function will be called by the [micro_ai] tag to set up the AI. See the link for more details on how this works.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.custom_synced_commands ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.custom_synced_commands'''.''command_name'' &amp;amp;harr; ''function''(''cfg'')&lt;br /&gt;
&lt;br /&gt;
Registers a custom synced command, which can be invoked by AI to enable unusual behaviour. The command can do basically anything, and is guaranteed to run on all clients. The WML table passed to the callback is the same table passed to [[LuaAPI/wesnoth/sync#wesnoth.sync.invoke_command|wesnoth.sync.invoke_command]].&lt;br /&gt;
&lt;br /&gt;
== Data ==&lt;br /&gt;
&lt;br /&gt;
Access to most of the game data is available via various tables in the &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.colors ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|4}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.colors'''.''color_name'' &amp;amp;rarr; ''color info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[GameConfigWML#Color_Palettes|color ranges]]. This can be used to translate the color name available from '''wesnoth.sides[n].color''' to RGB values.&lt;br /&gt;
&lt;br /&gt;
Each color info table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''mid''' - average shade for recoloring with the team color&lt;br /&gt;
* '''min''' - minimum shade for recoloring with the team color (this is likely to be black)&lt;br /&gt;
* '''max''' - maximum shade for recoloring with the team color (this is likely to be almost white)&lt;br /&gt;
* '''minimap''' - representative color to use on the mini-map&lt;br /&gt;
* '''pango_color''' - {{DevFeature1.15|13}} a hex string such as '''#ff0000''' suitable for use in formatted text&lt;br /&gt;
&lt;br /&gt;
Each of '''mid''', '''min''', '''max''' and '''minimap''' have the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''r''' - red component of that color&lt;br /&gt;
* '''g''' - green component of that color&lt;br /&gt;
* '''b''' - blue component of that color&lt;br /&gt;
* '''a''' - alpha component of that color (probably fully opaque)&lt;br /&gt;
&lt;br /&gt;
Reference usage in mainline: see data/multiplayer/eras.lua&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.current ===&lt;br /&gt;
&lt;br /&gt;
Contains various information about the current game and event state.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.side''' &amp;amp;rarr; ''side number''&lt;br /&gt;
&lt;br /&gt;
The number of the currently active side.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.turn''' &amp;amp;rarr; ''turn number''&lt;br /&gt;
&lt;br /&gt;
The current turn number.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.synced_state''' &amp;amp;rarr; ''state''&lt;br /&gt;
&lt;br /&gt;
Allows you to determine whether the current code runs in a synced context. Returns one of the following strings:&lt;br /&gt;
&lt;br /&gt;
:* '''synced''' - The current code runs on all mp clients. This is the normal context, in which all gamestate changing actions should take place.&lt;br /&gt;
:* '''unsynced''' - The current code runs only on the local machine, so changing the gamestate here will cause out-of-sync errors. For example, during '''select''' events or during the calculation of a [[LuaAPI/wesnoth/interface#wesnoth.interface.game_display|game_display]] hook. Typical things to do here are UI related things, or entering the synced state via '''[do_command]'''.&lt;br /&gt;
:* '''local_choice''' - The current code was invoked by [[#wesnoth.synchronize_choice|synchronize_choice]] and runs only on one local client to calculate the return value for the choice. You cannot enter the synced context with '''[do_command]''' now.&lt;br /&gt;
:* '''preload''' - We are currently running a preload event or an even earlier event. This behaves similar to '''local_choice'''.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.user_can_invoke_commands''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Indicates whether the player is currently able to take actions in the game.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.user_is_replaying''' &amp;amp;rarr; ''boolean'' {{DevFeature1.19|7}}&lt;br /&gt;
&lt;br /&gt;
Indicates whether the player is currently in replay mode.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.map''' &amp;amp;rarr; ''map userdata''&lt;br /&gt;
&lt;br /&gt;
The current active game map. See [[LuaAPI/types/map]] and [[LuaAPI/wesnoth/map]] for information on how this data can be used.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.schedule''' &amp;amp;rarr; ''schedule userdata''&lt;br /&gt;
&lt;br /&gt;
The current global time schedule. This is a special object with the following properties:&lt;br /&gt;
&lt;br /&gt;
:* #''schedule''&lt;br /&gt;
:The Lua length operator will return the number of turns in the schedule.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''[''index''] &amp;amp;harr; ''time of day info''&lt;br /&gt;
:Get the information for a particular time of day, or replace it with new info.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''.'''time_of_day''' &amp;amp;harr; ''id''&lt;br /&gt;
:Get the ID of the current active time of day, or switch to a new one. If the time of day occurs more than once in the schedule, the time will be set to the first occurrence.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''.'''liminal_bonus''' &amp;amp;harr; ''bonus''&lt;br /&gt;
:Get the maximum bonus for liminal units in the current schedule. You can also override the default by assigning a different value, or revert to the default by assigning nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.event_context''' &amp;amp;rarr; ''WML table''&lt;br /&gt;
&lt;br /&gt;
Contains information on the current active event. Returns a table with the following keys:&lt;br /&gt;
&lt;br /&gt;
:* '''name''' - The event name. This is the actual event that fired, not the name in the [event] tag, so it never contains commas or variables.&lt;br /&gt;
:* '''id''' - The event's unique ID, if it has one.&lt;br /&gt;
:* '''weapon''' - The first weapon relevant to the event, if any.&lt;br /&gt;
:* '''second_weapon''' - The second weapon relevant to the event, if any.&lt;br /&gt;
:* '''damage_inflicted''' - The damage inflicted in the event, if applicable.&lt;br /&gt;
:* '''x1''', '''y1''' - The first location relevant to the event, if any.&lt;br /&gt;
:* '''x2''', '''y2''' - The second location relevant to the event, if any.&lt;br /&gt;
:* '''unit_x''', '''unit_y''' - The location of the first unit relevant to the event, if any. This is the same as '''x1''', '''y1''' in most cases. Currently the only exceptions are enter and exit hex events.&lt;br /&gt;
:* '''data''' - {{DevFeature1.17|6}} The event data. Can contain anything at all if the event was fired by [[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire|wesnoth.game_events.fire]]. In a village capture event, '''owner_side''' will contain the former owner of the village.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_config ===&lt;br /&gt;
&lt;br /&gt;
Contains static global information about the game. Some of this information can also be modified on the fly, but only in the game context, not in the plugin or map generator context.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.base_income''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.village_income''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.village_support''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.poison_amount''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.rest_heal_amount''' &amp;amp;harr; ''integer'&lt;br /&gt;
* '''wesnoth.game_config.recall_cost''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.combat_experience''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.kill_experience''' &amp;amp;harr; ''integer''&lt;br /&gt;
&lt;br /&gt;
Values of various game settings.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.global_traits'''[''trait id''] &amp;amp;rarr;&lt;br /&gt;
&lt;br /&gt;
A table with named fields (trait id strings) holding the wml tables defining the traits. This contains all global traits the engine knows about, but race-specific traits are not included. The known fields and subtags of each element are the ones which were given in the wml definition of the [[SingleUnitWML|trait]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
print(wesnoth.game_config.global_traits.strong.male_name)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_config.do_healing''' &amp;amp;harr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether healing will occur at the beginning of each side's turn.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_config.theme''' &amp;amp;harr; ''theme id''&lt;br /&gt;
&lt;br /&gt;
The currently active in-game theme.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.debug''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether debug mode is currently active. Debug mode is activated by the --debug command-line parameter or the :debug in-game command.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.debug_lua''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether Lua debug is enabled. Lua debug is activated by the --debug-lua command-line parameter. This does not seem to do anything by default.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.mp_debug''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether MP debug is enabled. MP debug is activated in the same way as debug mode, but is only active in multiplayer games.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.strict_lua''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether strict Lua mode is enabled. Strict Lua mode is activated by the --strict-lua command-line parameter and causes all deprecated Lua APIs to be completely removed from the engine.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.palettes'''.''palette'' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the color palette with the given name, as defined by a '''[color_palette]''' tag in the [[GameConfigWML#Color_Palettes|game config]].&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.red_green_scale''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for health bars.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.red_green_scale_text''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for health numbers.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.blue_white_scale''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for experience bars.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.blue_white_scale_text''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for experience numbers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.races ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.races'''.''id'' &amp;amp;rarr; ''race info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[UnitsWML#.5Brace.5D|races]]. Returns a [[LuaAPI/types#Race|race userdata]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.scenario ===&lt;br /&gt;
&lt;br /&gt;
Contains information about the current scenario&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.turns''' &amp;amp;harr; ''turn limit''&lt;br /&gt;
&lt;br /&gt;
The current turn limit of the scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.next''' &amp;amp;harr; ''scenario id''&lt;br /&gt;
&lt;br /&gt;
The ID of the scenario to transition to when this scenario ends.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.id''' &amp;amp;rarr; ''scenario id''&lt;br /&gt;
&lt;br /&gt;
The ID of the current scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.name''' &amp;amp;rarr; &lt;br /&gt;
&lt;br /&gt;
The name of the current scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.defeat_music''' &amp;amp;harr; ''list of music tracks''&lt;br /&gt;
&lt;br /&gt;
The music to play if you lose this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.victory_music''' &amp;amp;harr; ''list of music tracks''&lt;br /&gt;
&lt;br /&gt;
The music to play if you win this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.show_credits''' &amp;amp;harr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether credits should be shown when this scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.end_text''' &amp;amp;harr; ''text''&lt;br /&gt;
&lt;br /&gt;
The end text to show when the scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.end_text_duration''' &amp;amp;harr; ''duration''&lt;br /&gt;
&lt;br /&gt;
How long to show the end text for when the scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.difficulty''' &amp;amp;rarr; ''difficult''&lt;br /&gt;
&lt;br /&gt;
The difficulty level this scenario is being played on.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.type''' &amp;amp;rarr; ''tag name''&lt;br /&gt;
&lt;br /&gt;
The type of this scenario. One of the strings '''scenario''', '''multiplayer''', or '''test'''.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.era''' &amp;amp;rarr; ''era tag''&lt;br /&gt;
&lt;br /&gt;
The [era] tag active in this scenario. Accessing this will throw an error in single-player games. This exists only for players which have the era installed, so for an era with ''require_era=yes'' it is safe to use.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.campaign''' &amp;amp;rarr; ''campaign tag''&lt;br /&gt;
&lt;br /&gt;
The [campaign] tag active in this scenario. Accessing this will throw an error in multiplayer or test games, so be sure to check '''wesnoth.scenario.type''' first in generic code.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.resources''' &amp;amp;rarr; ''list of resource tags''&lt;br /&gt;
&lt;br /&gt;
A list of [resource] tags active in this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.modifications''' &amp;amp;rarr; ''list of modification tags''&lt;br /&gt;
&lt;br /&gt;
A list of [modification] tags active in this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.mp_settings''' &amp;amp;rarr; ''table''&lt;br /&gt;
&lt;br /&gt;
In a multiplayer game, this is a proxy table which gives read only access to all MP-only configuration options which appear as attributes of [multiplayer] tag in a save game file. This allows accessing basically everything that can be set in the create game screen. The following keys exist in the returned table:&lt;br /&gt;
&lt;br /&gt;
* '''active_mods''' - A list of all active modification IDs&lt;br /&gt;
* '''hash''' - A hash of mp data&lt;br /&gt;
* '''mp_campaign''' - Name of mp campaign&lt;br /&gt;
* '''mp_scenario''' - ID of this mp scenario&lt;br /&gt;
* '''mp_scenario_name''' - Name of this mp scenario&lt;br /&gt;
* '''scenario''' - MP lobby title &lt;br /&gt;
* '''difficulty_define''' - The campaign difficulty string for an mp campaign&lt;br /&gt;
* '''mp_village_gold'''&lt;br /&gt;
* '''mp_village_support'''&lt;br /&gt;
* '''mp_num_turns'''&lt;br /&gt;
* '''mp_era''' - The id of the chosen era&lt;br /&gt;
* '''mp_eras''' - A list of all era ids&lt;br /&gt;
* '''mp_fog'''&lt;br /&gt;
* '''mp_shroud'''&lt;br /&gt;
* '''mp_random_start_time'''&lt;br /&gt;
* '''experience_modifier'''&lt;br /&gt;
* '''mp_use_map_settings'''&lt;br /&gt;
* '''mp_countdown''' - Whether the timer is enabled&lt;br /&gt;
* '''mp_countdown_action_bonus'''&lt;br /&gt;
* '''mp_countdown_init_time''' &lt;br /&gt;
* '''mp_countdown_reservoir_time'''&lt;br /&gt;
* '''mp_countdown_turn_bonus'''&lt;br /&gt;
* '''observer'''&lt;br /&gt;
* '''shuffle_sides'''&lt;br /&gt;
* '''savegame''' - Whether this is a reloaded game&lt;br /&gt;
* '''side_users''' - List of how sides are assigned to users (at game start)&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.terrain_types ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|12}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.terrain_types'''[''code''] &amp;amp;rarr; ''terrain info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[TerrainWML|terrain types]] by their terrain code. Returns a table with the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''id'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''editor_name'''&lt;br /&gt;
* '''description'''&lt;br /&gt;
* '''icon'''&lt;br /&gt;
* '''editor_image'''&lt;br /&gt;
* '''light'''&lt;br /&gt;
* '''village'''&lt;br /&gt;
* '''castle'''&lt;br /&gt;
* '''keep'''&lt;br /&gt;
* '''healing'''&lt;br /&gt;
* '''mvt_alias''' {{DevFeature1.19|10}}&lt;br /&gt;
* '''def_alias''' {{DevFeature1.19|10}}&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.unit_types ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.unit_types'''[''id''] &amp;amp;rarr; ''unit type info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[UnitTypeWML|unit types]] by their ID. Returns a [[LuaAPI/types#Unit_Type|unit type userdata]].&lt;br /&gt;
&lt;br /&gt;
== Submodules ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module also contains a number of submodules for working with particular aspects of the game.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.audio ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/audio|submodule]] containing functions for playing music and sound effects.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.achievements ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/achievements|submodule]] containing functions for working with in-game achievements.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/game_events|submodule]] containing functions for working with event handlers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.map ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|11}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/map|submodule]] containing functions for querying and manipulating the game map.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/interface|submodule]] containing functions pertaining to the in-game UI.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.paths ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/paths|submodule]] containing functions related to pathfinding.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.schedule ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|14}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/schedule|submodule]] containing functions to manipulate the time of day schedule.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/sides|submodule]] containing functions for manipulating the sides of a scenario.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sync ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|14}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/sync|submodule]] containing functions to deal with multiplayer synchronization.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/units|submodule]] containing functions to manipulate units on the map.&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference]]&lt;br /&gt;
&lt;br /&gt;
== Unsupported Functions ==&lt;br /&gt;
&lt;br /&gt;
The following functions exist in the '''wesnoth''' module but are not intended to be used:&lt;br /&gt;
&lt;br /&gt;
* wesnoth.allow_undo&lt;br /&gt;
* wesnoth.cancel_action&lt;br /&gt;
* wesnoth.clear_menu_item&lt;br /&gt;
* wesnoth.set_menu_item&lt;br /&gt;
* wesnoth.kernel_type&lt;br /&gt;
* wesnoth.log_replay&lt;br /&gt;
* wesnoth.print&lt;br /&gt;
* wesnoth.redraw&lt;br /&gt;
* wesnoth.add_known_unit&lt;br /&gt;
* wesnoth.get_era&lt;br /&gt;
* wesnoth.get_resource&lt;br /&gt;
&lt;br /&gt;
Some of these have WML equivalents, so if you need the functionality you should call the WML action directly (via [[#wesnoth.wml_actions|wml_actions]] or [[LuaAPI/wml#wml.fire|wml.fire]]). Others are internal functionality used in core Lua scripts, which are not intended for general use. These functions ''may'' be removed or changed without warning or going through a deprecation cycle.&lt;br /&gt;
&lt;br /&gt;
Examination of the '''wesnoth''' module will also reveal two additional subtables - the '''package''' table, which is where packages loaded by [[#wesnoth.require|wesnoth.require]] persist (meaning you can force '''wesnoth.require''' to reload a file by nulling out its entry in this table), and the '''experimental''' module, which contains functions that are available for use but without warranty - they may change without warning or going through a deprecation cycle. Use of both of these tables is unsupported.&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EraWML&amp;diff=74406</id>
		<title>EraWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EraWML&amp;diff=74406"/>
		<updated>2025-06-21T08:02:59Z</updated>

		<summary type="html">&lt;p&gt;Laela: auto_sort&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== The [era] top level tag ==&lt;br /&gt;
&lt;br /&gt;
This [[AddonsWML|addon module]] tag describes one era. An era is a set of teams to play in multiplayer.&lt;br /&gt;
&lt;br /&gt;
In the multiplayer game creation screen, an era is chosen by the host by the 'Era' option button.&lt;br /&gt;
&lt;br /&gt;
The following key/tags are recognized for '''[era]''', in addition to the common [[AddonsWML|addon module keys and tags]]:&lt;br /&gt;
* &amp;lt;span id=&amp;quot;require_era&amp;quot;&amp;gt;'''require_era'''&amp;lt;/span&amp;gt;: whether clients are required to have this era installed beforehand to be allowed join a game using this era. Possible values 'yes' (the default) and 'no'.&lt;br /&gt;
* '''allow_scenario''': a list of scenario ids. Only the scenarios with matching ids will be allowed to be played with this era.&lt;br /&gt;
* '''disallow_scenario''': a list of scenario ids. Only the scenarios with matching ids will not be allowed to be played with this era. Cannot be used in parallel with allow_scenario.&lt;br /&gt;
* '''ignore_incompatible_scenario''': a list of scenario ids. The scenarios with matching ids will be considered compatible with this era regardless their dependencies.&lt;br /&gt;
* '''allow_modification''': same as allow_scenario, but for modifications.&lt;br /&gt;
* '''disallow_modification''': same as disallow_scenario, but for modifications. Cannot be used in parallel with allow_modification.&lt;br /&gt;
* '''ignore_incompatible_modification''': same as ignore_incompatible_scenario, but for modifications.&lt;br /&gt;
* '''force_modification''': a list of modification ids. The specified modifications must be enabled to play this era.&lt;br /&gt;
* '''hide_help''': {{DevFeature1.13|0}} whether this era should show up in the help browser or not. Default no.&lt;br /&gt;
&lt;br /&gt;
== Defining Factions ==&lt;br /&gt;
&lt;br /&gt;
Each faction in the era is defined by a '''[multiplayer_side]''' tag. This tag contains most of the same keys as a [side] tag (see [[SideWML]]). When a multiplayer game is played, then the [side] tag for the scenario is merged with the keys (currently, not tags) of the '''[multiplayer_side]''' tag of the faction which the side chose.&lt;br /&gt;
&lt;br /&gt;
Each faction needs to specify its recruit list with the '''recruit''' key, which is described in [[SideWML]].&lt;br /&gt;
&lt;br /&gt;
The following additional keys are unique to '''[multiplayer_side]''':&lt;br /&gt;
&lt;br /&gt;
* '''id''': faction ID - must be unique to your era. No gameplay effect&lt;br /&gt;
* '''name''': a description that Wesnoth displays as the option selecting that faction. This key is used for sorting factions in era.&lt;br /&gt;
* '''image''': an image to display in the option. This image will use the team color.&lt;br /&gt;
* '''leader''': a list of unit types. Must be present. When this faction is chosen, the side can choose any of these unit types to be the side's leader (i.e. &amp;quot;Choose your Leader&amp;quot;). They will also have the option of having one of these types being chosen randomly.&lt;br /&gt;
* '''random_leader''': if this list of types is present, it would use this list to instead to choose a random leader. If not it would use '''leader'''&lt;br /&gt;
* '''random_faction''': default 'no'. If 'yes', then when this faction is chosen, another non random faction will be randomly chosen instead. The leader will also be chosen randomly. All random_faction=yes factions are sorted before other factions.&lt;br /&gt;
* '''choices''': Empty by default. If non-empty and the faction has '''random_faction=yes''', it is the list of the IDs of the non random factions that will be choosen randomly. If empty, any faction can be chosen.&lt;br /&gt;
* '''except''': Empty by default. If the faction has random_faction=yes, it is the list of the IDs of the non random factions that will not be choosen randomly.&lt;br /&gt;
* '''type''': the unit type of the default leader for the side. This must be present. 'random' is a valid value here and will cause a random leader choice by default. As of 1.16.2 at least this key has no effect and is not required to be present.&lt;br /&gt;
* '''terrain_liked''': an unseparated list of terrains (see [[TerrainCodesWML]]). On random maps, these terrains will determine which keep the side is assigned, attempting to put it near the listed terrains.&lt;br /&gt;
* '''description''': a short description of the faction, displayed in the help browser.&lt;br /&gt;
* '''auto_sort''': {{DevFeature1.19|13}} default 'yes'. If 'no', factions will be displayed in the order written in WML instead of sorted by name. In older versions there are workarounds like https://github.com/wesnoth/wesnoth/issues/3177.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[SideWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=StandardUnitFilter&amp;diff=74393</id>
		<title>StandardUnitFilter</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=StandardUnitFilter&amp;diff=74393"/>
		<updated>2025-06-09T18:48:59Z</updated>

		<summary type="html">&lt;p&gt;Laela: &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 units.&lt;br /&gt;
&lt;br /&gt;
When a unit filter is applied to a map, first it applies to all units on the field,&lt;br /&gt;
based on their coordinates.&lt;br /&gt;
Next it applies to units in the recall list.&lt;br /&gt;
This is important to remember as it means, for example,&lt;br /&gt;
that the tag '''[kill]''' can be used to kill units in the recall list.&lt;br /&gt;
&lt;br /&gt;
You can access the filtered unit within the filter as the ''$this_unit'' variable, see [[SingleUnitWML]] for the possible content of these variables&lt;br /&gt;
&lt;br /&gt;
The term [[StandardUnitFilter]] means that the set of such keys and tags (see below) can appear at that point. Often a [[StandardUnitFilter]] needs to be included in a [filter] tag. But many tags take the [[StandardUnitFilter]] directly as an argument, like [[DirectActionsWML#.5Bkill.5D|[kill]]] and [[ConditionalActionsWML#.5Bhave_unit.5D|[have_unit]]] (which each accept a few additional keys of their own). See [[Special:WhatLinksHere/StandardUnitFilter]] for tags which can contain a StandardUnitFilter.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
The following attributes and sub-tags are allowed:&lt;br /&gt;
&lt;br /&gt;
* '''id''': unit matches the given id. This is the same as ''id'' in the [unit] tag. Note that it is independent of a unit's user-visible name, which can be internationalized independent of this (see [[SingleUnitWML]]). id= can be a comma-separated list, every unit with one of these ids matches.&lt;br /&gt;
* '''speaker''': alias for id (no comma-separated list supported)&lt;br /&gt;
* '''type''': matches the unit's type name (can be a list of types)&lt;br /&gt;
* '''type_adv_tree''': {{DevFeature1.13|7}} matches the type name of the unit and all its advancements (can be a list)&lt;br /&gt;
* '''race''': the race of the unit type. This can be a comma-separated list; the unit's race must match one of the given races. &amp;lt;br&amp;gt;Mainline races are listed in data/core/units.cfg&amp;lt;br&amp;gt; &lt;br /&gt;
* '''variation''': the unit type variation id (can be a list of variation ids)&lt;br /&gt;
* '''has_variation''': matches if the unit type for the unit defines at least one of the variation ids provided as a comma-separated list&lt;br /&gt;
* '''upkeep''': {{DevFeature1.15|3}} The upkeep of the unit. Can be either a non-negative number or one of the special values ''loyal'', ''free'', ''full''. Note that while ''loyal'' and ''free'' are synonymous with an upkeep of 0, the value ''full'' is not synonymous with any single numeric value – it is equivalent to &amp;lt;code&amp;gt;$this_unit.level&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''ability''': unit has an ability with the given id; see [[AbilitiesWML]]. This can be a comma-separated list. The unit must have at least one of the specified abilities.&lt;br /&gt;
* '''ability_type''': {{DevFeature1.13|7}} unit has an ability with the given type (tag name) - eg, ''ability_type=heals'' will match a unit with any healing ability.&lt;br /&gt;
* '''ability_type_active''': {{DevFeature1.13|8}} unit has an ''active'' ability with the given type (tag name).&lt;br /&gt;
* '''ability_id_active''': {{DevFeature1.15|13}} unit has an ''active'' ability with the given id; see [[AbilitiesWML]]&lt;br /&gt;
* '''trait''': {{DevFeature1.13|8}} This can be a comma-separated list. The unit must have at least one of the specified traits.&lt;br /&gt;
* '''status''': {{DevFeature1.13|0}} matches if the unit has the specified status active. This can be a comma-separated list, in which case the unit will match as long as it has one of the listed statuses active (note: possible statuses are listed on the [[SingleUnitWML]] page).&lt;br /&gt;
* '''side''': the unit is on the given side (can be a list)&lt;br /&gt;
* '''has_weapon''': the unit has a weapon with the given name {{DevFeature1.13|5}} Now deprecated&lt;br /&gt;
* {{anchor|has_attack|'''[has_attack]'''}}: {{DevFeature1.13|5}} the unit has a weapon matching the [[StandardWeaponFilter]]. If this is present, '''has_weapon''' is ignored.&lt;br /&gt;
* '''canrecruit''': yes if the unit can recruit (i.e. is a leader)&lt;br /&gt;
* '''gender''': female if the unit is female rather than the default of male&lt;br /&gt;
* '''role''': the unit has been assigned the given role; see '''[role]''', [[InternalActionsWML]]&lt;br /&gt;
* '''level''': the level of the unit (this can be a comma-separated list).&lt;br /&gt;
* '''defense''': current defense of the unit on current tile (chance to hit %, like in movement type definitions)&lt;br /&gt;
* '''movement_cost''': current movement cost of the unit on current tile. Can be a number, range, or comma separated range.&lt;br /&gt;
* '''x,y''': the position of the unit. Note: As a special case '''x,y=recall,recall''' matches units on the recall list. Note that the similar '''search_recall_list=yes''' key is only available as part of the '''[have_unit]''' condition tag, and is not otherwise considered part of a StandardUnitFilter.&lt;br /&gt;
* '''find_in''': name of an array or container variable; if present, the unit will not match unless a unit with the same '''id''' is already stored in the variable&lt;br /&gt;
* {{anchor|filter_vision|'''[filter_vision]'''}}: this tests whether or not the unit is currently visible&lt;br /&gt;
** '''visible''': yes or no, default yes. When &amp;quot;yes&amp;quot;, this matches units that are not obscured by fog or shroud, and that are not hiding (via the {{tag|AbilitiesWML|hides}} ability). When &amp;quot;no&amp;quot;, this matches units that are obscured by fog or shroud, or that are hiding.&lt;br /&gt;
** [[StandardSideFilter]] tags and keys. Filter for who may be able to see (or not see) the unit. If there is *at least one* matching side which can see the unit then the filter matches, and otherwise it fails to match.&lt;br /&gt;
* {{anchor|filter_wml|'''[filter_wml]'''}}: Converts the unit to WML (as if by '''[store_unit]''') and tests it against a [[FilterWML#Filtering_on_WML_data|WML filter]]. For a list of things in the WML that could be filtered on, see [[SingleUnitWML]] or open a saved game in a text editor. Note that this is slower than other methods, so if possible it's better to use other filter keys and tags; however, if the WML filter contains only a child '''[variables]''', then the unit is not converted to WML and the filter is matched only against the unit's variables (which are already WML).&lt;br /&gt;
* '''[and]''': an extra unit filter. Unless the unit also matches the [and] filter, then it will not count as a match. ''Note: [and],[or], and [not] filters are considered after the containing filter; they are then processed in the order encountered.''&lt;br /&gt;
* '''[or]''': an extra unit filter. If a unit 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 unit filter. If a unit matches the [not] filter, then that unit will not be considered a match by the containing filter.&lt;br /&gt;
* {{anchor|filter_adjacent|'''[filter_adjacent]'''}} with a StandardUnitFilter as argument. If present the correct number of adjacent units must match this filter.&lt;br /&gt;
**'''StandardUnitFilter''' tags and keys&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; (see [[StandardLocationFilter#Directions|notes]])&lt;br /&gt;
** '''is_enemy''': a boolean specifying whether the adjacent unit must be an enemy or an ally (optional)&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} Within [filter_adjacent], the special variable $other_unit refers to the filtered unit from the enclosing filter, while $this_unit refers (as with all StandardUnitFilters) to the unit being filtered on.&lt;br /&gt;
* '''[filter_location]''': [[StandardLocationFilter]] - the tile that the unit is standing on matches the location filter.&lt;br /&gt;
*'''[filter_side]''': The currently filtered unit's side must match this [[StandardSideFilter]] for the unit to match.&lt;br /&gt;
**[[StandardSideFilter]] tags and keys&lt;br /&gt;
* '''formula''': A formula using [[Wesnoth Formula Language]]. The &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable is set to the current $this_unit, and the formula should return a boolean. If it returns 0, the filter does not match. Otherwise, the filter does match. {{DevFeature1.13|5}} If the filter has a secondary unit, the formula can access it using the &amp;lt;code&amp;gt;other&amp;lt;/code&amp;gt; variable. Both the unit and the secondary unit are a '''unit object''', with keys documented [[#Wesnoth_Formula_Language|below]]. Do not surround the formula in &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* '''lua_function''': the name of a [[LuaWML|Lua]] function in the global environment that takes a unit as an argument and returns true if the given unit matches the filter. {{DevFeature1.13|5}} Non-global functions can now be used here by building a dot-separated &amp;quot;path&amp;quot;. Note that this is not actually interpreted as Lua code even though it superficially resembles it, so using a Lua keyword in the path will work, for example &amp;quot;my_filter_functions.goto&amp;quot; will correctly use the function which in actual Lua code would need to be referenced as &amp;lt;code&amp;gt;my_filter_functions[&amp;quot;goto&amp;quot;]&amp;lt;/code&amp;gt;.&lt;br /&gt;
* {{anchor|filter_ability|'''[experimental_filter_ability]'''}}: {{DevFeature1.17|17}} [[StandardAbilityFilter]] matches if the unit has an ability with the given properties - eg, ''[experimental_filter_ability]affect_self=yes'' will match a unit with any ability with ''affect_self=yes''. {{DevFeature1.19|5}} [experimental_filter_ability] deprecated, use [filter_ability] instead.&lt;br /&gt;
* {{anchor|filter_ability_active|'''[experimental_filter_ability_active]'''}}: {{DevFeature1.17|17}} [[StandardAbilityFilter]] matches if the unit has an ''active'' ability with the given properties - eg, ''[experimental_filter_ability_active]affect_adjacent=yes'' will match a unit with any ''active'' ability with ''[affect_adjacent]''. The attributes checked are the same as for [experimental_filter_ability].  {{DevFeature1.19|5}} [experimental_filter_ability_active] deprecated, use [filter_ability] instead.&lt;br /&gt;
* '''[filter_ability]''': {{DevFeature1.19|5}} [[StandardAbilityFilter]] matches if the unit has anability with the given properties - eg, ''[filter_ability]affect_adjacent=yes'' will match a unit with any ability with ''[affect_adjacent]''.&lt;br /&gt;
** '''active''': if active=yes, matches if the unit has an ''active'' ability with the given properties, if active=no, matches if the unit has an ability with the given properties regardless of 'active' or not. '''active''' is false by default.&lt;br /&gt;
&lt;br /&gt;
== [[Wesnoth Formula Language]] ==&lt;br /&gt;
&lt;br /&gt;
When using the '''formula''' key, the '''self''' and (if present) '''other''' objects support the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''x''', '''y''', '''loc''' - the latter is a '''location object''' such as what would be returned from [[Wesnoth_Formula_Language#loc|loc()]].&lt;br /&gt;
* '''id'''&lt;br /&gt;
* '''type'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''usage'''&lt;br /&gt;
* '''canrecruit''', '''leader'''&lt;br /&gt;
* '''undead''' - true if the unit has the ''not_living'' status&lt;br /&gt;
* '''attacks''' - a list of '''[[FilterWML#Filtering_Weapons|weapon objects]]'''&lt;br /&gt;
* '''abilities''' - a list of the ability IDs the unit possesses&lt;br /&gt;
* '''hitpoints''', '''max_hitpoints'''&lt;br /&gt;
* '''experience''', '''max_experience'''&lt;br /&gt;
* '''moves''', '''max_moves'''&lt;br /&gt;
* '''attacks_left''', '''max_attacks'''&lt;br /&gt;
* '''level''', '''full''' - '''full''' refers to the unit's level to support the formula &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;upkeep = full&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''traits''' - a list of the trait IDs&lt;br /&gt;
* '''objects''' {{DevFeature1.19|0}} - a list of the objects IDs&lt;br /&gt;
* '''advancements_taken''' {{DevFeature1.19|0}} - a list of the advancements taken IDs&lt;br /&gt;
* '''traits_count''' {{DevFeature1.19|0}} - number of traits used by unit regardless of IDs&lt;br /&gt;
* '''objects_count''' {{DevFeature1.19|0}} -  number of objects used by unit regardless of IDs&lt;br /&gt;
* '''advancements_taken_count''' {{DevFeature1.19|0}} -  number of advancements taken used by unit regardless of IDs&lt;br /&gt;
* '''extra_recruit'''&lt;br /&gt;
* '''advances_to'''&lt;br /&gt;
* '''status''' - a list of active statuses&lt;br /&gt;
* '''side_number'''&lt;br /&gt;
* '''cost'''&lt;br /&gt;
* '''upkeep'''&lt;br /&gt;
* '''loyal''' - a constant 0 to support the formula &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;upkeep = loyal&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''hidden'''&lt;br /&gt;
* '''petrified''' - true if the unit has the '''petrified''' status&lt;br /&gt;
* '''resting'''&lt;br /&gt;
* '''role'''&lt;br /&gt;
* '''race'''&lt;br /&gt;
* '''gender'''&lt;br /&gt;
* '''variation'''&lt;br /&gt;
* '''zoc'''&lt;br /&gt;
* '''alignment'''&lt;br /&gt;
* '''facing'''&lt;br /&gt;
* '''resistance''', '''movement_cost''', '''vision_cost''', '''jamming_cost''', '''defense''' - {{DevFeature1.15|3}} Maps containing the basic movetype data. The '''defense''' and '''resistance''' maps contain the actual defense and resistance values, rather than the values specified in the WML, so you do not need to subtract them from 100.&lt;br /&gt;
* '''flying''' {{DevFeature1.15|3}}&lt;br /&gt;
* '''fearless''', '''healthy''' {{DevFeature1.19|4}}&lt;br /&gt;
* '''vars''' - WFL variables owned by the unit, which can be set and used by FormulaAI&lt;br /&gt;
* '''wml_vars''' - the WML variables stored in the unit&lt;br /&gt;
* '''n''', '''s''', '''ne''', '''se''', '''nw''', '''sw''', '''lawful''', '''chaotic''', '''neutral''', '''liminal''', '''male''', '''female''' - these are all defined to be the equivalent string so that, for example, you can write a formula like &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;alignment = liminal and gender = female&amp;lt;/syntaxhighlight&amp;gt; without needing to quote the alignment and gender strings.&lt;br /&gt;
&lt;br /&gt;
== A Note about Re-Using the Same Attribute ==&lt;br /&gt;
You are limited to having each attribute, such as '''id''', appear once or less in a [[StandardUnitFilter]]. However, this can be worked around. If you have several specific units you want excepted from matching, use a separate [or] subfilters for each one. Also you can use [not] subfilters. For example to kill ([kill] uses the standard unit filter) all units except Gwiti Ha'atel and Tanar you can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[kill]&lt;br /&gt;
    [not]&lt;br /&gt;
        id=Gwiti Ha'atel&lt;br /&gt;
    [/not]&lt;br /&gt;
    [not]&lt;br /&gt;
        id=Tanar&lt;br /&gt;
    [/not]&lt;br /&gt;
[/kill]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And similarly if you wanted to kill both Gwiti Ha'atel and Tanar, but no one else you could do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[kill]&lt;br /&gt;
    id=Gwiti Ha'atel&lt;br /&gt;
    [or]&lt;br /&gt;
       id=Tanar&lt;br /&gt;
    [/or]&lt;br /&gt;
[/kill]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
* [[FilterWML/Examples_-_How_to_use_Filter|How To Use Filter (with examples)]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[FilterWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74392</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74392"/>
		<updated>2025-06-09T18:47:55Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Common keys and tags for every weapon special */&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.&lt;br /&gt;
&lt;br /&gt;
Each ability or special defines an effect based on one to three units. Most abilities apply to a single unit, and '''[filter_self]''' can be used to determine when the ability is active. Weapon specials apply to two units, which can be filtered either as &amp;quot;attacker&amp;quot; and &amp;quot;defender&amp;quot; (with the obvious meaning) or as &amp;quot;self&amp;quot; and &amp;quot;other&amp;quot; – the unit that possesses the special, and that unit's opponent. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_opponent]'''.&lt;br /&gt;
&lt;br /&gt;
Leadership-style abilities are a more complex case, as they involve three units. Like a weapon special, there is an attacker and defender, but there is also a third unit that could be referred to as the &amp;quot;teacher&amp;quot;. The &amp;quot;teacher&amp;quot; is the unit that possesses the ability, so it is referred to as &amp;quot;self&amp;quot; in the ability. A leadership ability works by temporarily granting a weapon special to either the attacker or the defender. The unit that benefits from this is referred to as the &amp;quot;student&amp;quot;, while the unit that does not benefit is simply the &amp;quot;other&amp;quot; unit. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_opponent]''', while the student can be filtered with '''[filter_student]'''.&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 of 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;
* {{DevFeature1.15|0}} All [[#The_.5Bspecials.5D_tag|weapon specials]] except for '''[plague]''', '''[heal_on_hit]''', and '''[swarm]''' can be placed in the '''[abilities]''' tag. These [[#Extra_tags_and_keys_used_by_weapon_specials_as_abilities|&amp;quot;weapon specials as abilities&amp;quot;]] will give the weapon special to all attacks the unit has.&lt;br /&gt;
* Any other tag is valid (for example '''[dummy]'''), but will result in an ability that does nothing but report it's there. '''Note:''' a dummy ability must have an id for the name and description to display.&lt;br /&gt;
* {{DevFeature1.15|3}} All the engine [[#The_.5Bspecials.5D_tag|weapon specials]] can be placed in the [abilities] tag now.&lt;br /&gt;
&lt;br /&gt;
=== Available formula variables in Abilities and Weapon Specials  ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|?}} When using formulas in abilities and weapon specials, the following formula variables are available:&lt;br /&gt;
* '''self''': (unit) the unit that has the ability&lt;br /&gt;
* '''student''': (unit) for leadership-like abilities this is the unit that is adjacent to the unit that has the ability; if affect_self=yes, this is also unit who has ability.&lt;br /&gt;
* '''attacker''': (unit) for attack-related abilities and weapon specials, this is the attacking unit during the attack.&lt;br /&gt;
* '''defender''': (unit) for attack-related abilities and weapon specials, this is the defending unit during the attack.&lt;br /&gt;
* '''other''': (unit) the unit whose stats get modified from the ability. For abilities without 'apply_to=opponent' this is always the same as 'student'.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every ability ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any ability that expects a numeric value will also accept formulas using &lt;br /&gt;
[[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses. However, do '''not''' precede those parentheses with a dollar sign like &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the ability. If omitted, the ability will be a hidden ability.&lt;br /&gt;
* '''female_name''': the (translatable) name of the ability when possessed by a female unit. Defaults to ''name'' if not specified.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the ability when inactive. Defaults to ''name'' if not specified; if the ability is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''female_name_inactive''': the (translatable) name of the ability when inactive and possessed by a female unit. Defaults to ''name_inactive'' if not specified. You should thus set ''female_name'' as well!&lt;br /&gt;
* '''description''': the (translatable) description of the ability.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the ability when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* '''affect_self''': if equal to 'yes' (default), the ability will affect the unit that has it.&lt;br /&gt;
* '''affect_allies''': if equal to 'yes', the ability will affect units from the same and allied sides in the specified adjacent hexes. If set to 'no' it will not affect own or allied sides. If not set (default) it will affect units on the same side but not from allied sides.&lt;br /&gt;
* '''affect_enemies''': if equal to 'yes' (default is 'no'), 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. ''Beware of the bug with cumulative leadership in 1.16 https://github.com/wesnoth/wesnoth/issues/6466 , more info see below, in &amp;quot;Extra keys used by the ''leadership'' ability&amp;quot; section''. {{DevFeature1.17|5}}, bug fixed.&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;
* '''halo_image''': {{DevFeature1.17|22}} if used, the halo specified showed on unit affected by ability.&lt;br /&gt;
* '''overlay_image''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit affected by ability.&lt;br /&gt;
* '''halo_image_self''': {{DevFeature1.17|22}} if used, the halo specified showed on unit who has ability when active.&lt;br /&gt;
* '''overlay_image_self''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit who has ability when active.&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] If the unit owning the ability does not match this filter, the ability will be inactive.&lt;br /&gt;
* {{anchor|affect_adjacent|'''[affect_adjacent]'''}}: an adjacent unit that does not match this filter will not receive its effects. There can be multiple [affect_adjacent] tags in a single ability; a unit needs to match any one of these to receive the effects. The side requirement of matching units is defined by the '''affect_allies''' and '''affect_enemies''' keys. If there are no [affect_adjacent] tags, then no adjacent units will receive the effects.&lt;br /&gt;
** '''adjacent''': a comma separated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''. (See [[StandardLocationFilter#Directions|notes]])&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]]. {{DevFeature1.13|2}} The variable $other_unit refers to the unit owning the ability.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} set to 1 by default, it determines the range within which units can be affected beyond immediately adjacent units, if the value is equal to 'full-map', the area is the entire map.&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. [filter_self] takes a [[StandardUnitFilter]] as argument.&lt;br /&gt;
* '''[filter_adjacent]''' {{DevFeature1.19|10}}: if an adjacent unit does not match this filter, the ability will not be active and no-one will receive its affects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). In fact, it's really a shorthand for a [filter_adjacent] nested within [filter]. The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[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;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this ability appears in. Note that such events get included when a unit with this ability first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&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'' or ''cured''. ''slowed'' means poison will not take effect for adjacent units (it's not related to the weapon special &amp;quot;slows&amp;quot;).&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'' or ''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. Default: 0%. {{DevFeature1.17|24}} Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|0}} minimum resistance value. Default: no limit.&lt;br /&gt;
* '''add''': adds to resistance. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': subtracts from resistance.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides 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;
These keys affect the actual resistance (e.g. -20%), not the damage modifier normally used in [resistance] (e.g. 120).&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the opponent uses a matching weapon.&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;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
''Note:'' cumulative leadership with '''cumulative=yes''' and '''value=''' doesn't work in 1.16 (but fixed in 1.17.12 and later). To work around use '''add=''' or '''sub=''' key (it doesn't require cumulative) (https://github.com/wesnoth/wesnoth/issues/6466 ). If you want each instance of a ''[leadership]'' with the same id to be added you will be able to reuse '''cumulative=yes''' in 1.17.12 and later, otherwise, if you want to add the value of another ''[leadership]'' only once even with the same id in several copies, use '''add'''.&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the opponent uses a matching weapon.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[illuminates]'' ability ===&lt;br /&gt;
&lt;br /&gt;
Because this ability changes the terrain instead of units on it, affect_self, affect_allies, affect_enemies and [filter_adjacent] have no effect.&lt;br /&gt;
* '''value''': the percentage bonus to lawful units. Units with '''alignment=lawful''' do +''value'' % damage when under the influence of a unit with this ability. Units with '''alignment=chaotic''' do -''value'' % damage. Units with '''alignment=neutral''' are unaffected by this ability. Units with '''alignment=liminal''' do -(abs(''value'')) % damage. ''value'' can be a negative number; this is useful if you want to give Chaotic units an advantage instead of Lawful ones. &lt;br /&gt;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
* '''max_value''': the maximum percentage bonus given. Cannot be less than 0. Defaults to 0 if not present.&lt;br /&gt;
* '''min_value''': the minimum percentage bonus given. Cannot be greater than 0. Defaults to 0 if not present.&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;
=== Extra tags used by the ''[teleport]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''[tunnel]''' - a [[DirectActionsWML#.5Btunnel.5D|tunnel tag]] (without the remove key) defining the tunneling source and target hexes, and maybe other conditions. (It automatically applies only to the unit with the ability.)  You may use $teleport_unit inside the [tunnel][source] and [tunnel][target] tag for filtering purposes.&lt;br /&gt;
&lt;br /&gt;
=== Extra tags and keys used by weapon specials as abilities ===&lt;br /&gt;
&lt;br /&gt;
* {{anchor|filter_student|'''[filter_student]'''}}: {{DevFeature1.15|0}} If present, only the unit matching this filter, either the possessor of the ability if affect_self=yes, or an adjacent unit matching '''[filter_adjacent]''' will be affected. '''Replaces''' '''[filter_self]''' of normal weapon specials.&lt;br /&gt;
* '''overwrite_specials''': {{DevFeature1.15|13}} If present, allows a special abilities weapon with a numerical value to impose its value and ignore values of abilities or specials of the same type. If '''overwrite_specials=one_side''', the specials and abilities used by the opponent of the unit affected by the ability with this key and applied to it will not be affected. If '''overwrite_specials=both_sides''', all non-key-carrying abilities and all specials of the same type affecting the recipient unit will be affected, even if used by the opponent (used in the macro FORCE_CHANCE_TO_HIT).&lt;br /&gt;
* {{anchor|overwrite|'''[overwrite]'''}}: {{DevFeature1.17|22}} Part of '''overwrite_specials'''. Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** {{anchor|filter_specials|'''[experimental_filter_specials]'''}}: [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
* Other keys and tags appropriate to the specific weapon special.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common abilities ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:abilities.cfg macro reference]&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;
* {{DevFeature1.13|2}} ABILITY_LEADERSHIP (replaces the above leadership macros, which are now deprecated)&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;
* '''[attacks]''': modifies the number of attacks of a weapon, in using '''value''', '''add''', '''sub''', '''multiply''' or '''divide''' attributes&lt;br /&gt;
* '''[berserk]''': pushes the attack for more than one combat round, using '''value''' attribute, '''value''' is 1 by default&lt;br /&gt;
* '''[chance_to_hit]''': modifies the chance to hit of a weapon, using same standard numerical attributes as '''[attacks]'''&lt;br /&gt;
* '''[damage]''': modifies the damage of a weapon, using same attributes as '''[attacks]''' and '''[chance_to_hit]'''&lt;br /&gt;
* '''[damage_type]''' {{DevFeature1.17|23}}: changes the damage type of a weapon&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker half of the damage dealt, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 50% by default&lt;br /&gt;
* '''[firststrike]''': forces the weapon to always strike first&lt;br /&gt;
* '''[heal_on_hit]''': heals the attacker when an attack connects, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 0 by default&lt;br /&gt;
* '''[petrifies]''': turns the target to stone&lt;br /&gt;
* '''[plague]''': when used to kill an enemy, a friendly unit takes its place&lt;br /&gt;
* '''[poison]''': poisons the target&lt;br /&gt;
* '''[slow]''': slows the target&lt;br /&gt;
* '''[swarm]''': number of strikes decreases as the unit loses hitpoints&lt;br /&gt;
Any other tag is valid, but will result in a special that does nothing but report it is there.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every weapon special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any weapon special that expects a numeric value will also accept formulas using [[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the special. If omitted, the special will be hidden from the player.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the special when inactive. Defaults to ''name'' if not specified; if the special is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''description''': the (translatable) description of the special.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the special when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&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''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''' {{DevFeature1.19|10}}: if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability], {{DevFeature1.19|5}} [experimental_filter_specials] deprecated, use [filter_specials] instead.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this weapon special appears in. Note that such events get included when a unit with this weapon special first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74391</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74391"/>
		<updated>2025-06-09T18:46:55Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Common keys and tags for every ability */&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.&lt;br /&gt;
&lt;br /&gt;
Each ability or special defines an effect based on one to three units. Most abilities apply to a single unit, and '''[filter_self]''' can be used to determine when the ability is active. Weapon specials apply to two units, which can be filtered either as &amp;quot;attacker&amp;quot; and &amp;quot;defender&amp;quot; (with the obvious meaning) or as &amp;quot;self&amp;quot; and &amp;quot;other&amp;quot; – the unit that possesses the special, and that unit's opponent. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_opponent]'''.&lt;br /&gt;
&lt;br /&gt;
Leadership-style abilities are a more complex case, as they involve three units. Like a weapon special, there is an attacker and defender, but there is also a third unit that could be referred to as the &amp;quot;teacher&amp;quot;. The &amp;quot;teacher&amp;quot; is the unit that possesses the ability, so it is referred to as &amp;quot;self&amp;quot; in the ability. A leadership ability works by temporarily granting a weapon special to either the attacker or the defender. The unit that benefits from this is referred to as the &amp;quot;student&amp;quot;, while the unit that does not benefit is simply the &amp;quot;other&amp;quot; unit. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_opponent]''', while the student can be filtered with '''[filter_student]'''.&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 of 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;
* {{DevFeature1.15|0}} All [[#The_.5Bspecials.5D_tag|weapon specials]] except for '''[plague]''', '''[heal_on_hit]''', and '''[swarm]''' can be placed in the '''[abilities]''' tag. These [[#Extra_tags_and_keys_used_by_weapon_specials_as_abilities|&amp;quot;weapon specials as abilities&amp;quot;]] will give the weapon special to all attacks the unit has.&lt;br /&gt;
* Any other tag is valid (for example '''[dummy]'''), but will result in an ability that does nothing but report it's there. '''Note:''' a dummy ability must have an id for the name and description to display.&lt;br /&gt;
* {{DevFeature1.15|3}} All the engine [[#The_.5Bspecials.5D_tag|weapon specials]] can be placed in the [abilities] tag now.&lt;br /&gt;
&lt;br /&gt;
=== Available formula variables in Abilities and Weapon Specials  ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|?}} When using formulas in abilities and weapon specials, the following formula variables are available:&lt;br /&gt;
* '''self''': (unit) the unit that has the ability&lt;br /&gt;
* '''student''': (unit) for leadership-like abilities this is the unit that is adjacent to the unit that has the ability; if affect_self=yes, this is also unit who has ability.&lt;br /&gt;
* '''attacker''': (unit) for attack-related abilities and weapon specials, this is the attacking unit during the attack.&lt;br /&gt;
* '''defender''': (unit) for attack-related abilities and weapon specials, this is the defending unit during the attack.&lt;br /&gt;
* '''other''': (unit) the unit whose stats get modified from the ability. For abilities without 'apply_to=opponent' this is always the same as 'student'.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every ability ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any ability that expects a numeric value will also accept formulas using &lt;br /&gt;
[[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses. However, do '''not''' precede those parentheses with a dollar sign like &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the ability. If omitted, the ability will be a hidden ability.&lt;br /&gt;
* '''female_name''': the (translatable) name of the ability when possessed by a female unit. Defaults to ''name'' if not specified.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the ability when inactive. Defaults to ''name'' if not specified; if the ability is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''female_name_inactive''': the (translatable) name of the ability when inactive and possessed by a female unit. Defaults to ''name_inactive'' if not specified. You should thus set ''female_name'' as well!&lt;br /&gt;
* '''description''': the (translatable) description of the ability.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the ability when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* '''affect_self''': if equal to 'yes' (default), the ability will affect the unit that has it.&lt;br /&gt;
* '''affect_allies''': if equal to 'yes', the ability will affect units from the same and allied sides in the specified adjacent hexes. If set to 'no' it will not affect own or allied sides. If not set (default) it will affect units on the same side but not from allied sides.&lt;br /&gt;
* '''affect_enemies''': if equal to 'yes' (default is 'no'), 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. ''Beware of the bug with cumulative leadership in 1.16 https://github.com/wesnoth/wesnoth/issues/6466 , more info see below, in &amp;quot;Extra keys used by the ''leadership'' ability&amp;quot; section''. {{DevFeature1.17|5}}, bug fixed.&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;
* '''halo_image''': {{DevFeature1.17|22}} if used, the halo specified showed on unit affected by ability.&lt;br /&gt;
* '''overlay_image''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit affected by ability.&lt;br /&gt;
* '''halo_image_self''': {{DevFeature1.17|22}} if used, the halo specified showed on unit who has ability when active.&lt;br /&gt;
* '''overlay_image_self''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit who has ability when active.&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] If the unit owning the ability does not match this filter, the ability will be inactive.&lt;br /&gt;
* {{anchor|affect_adjacent|'''[affect_adjacent]'''}}: an adjacent unit that does not match this filter will not receive its effects. There can be multiple [affect_adjacent] tags in a single ability; a unit needs to match any one of these to receive the effects. The side requirement of matching units is defined by the '''affect_allies''' and '''affect_enemies''' keys. If there are no [affect_adjacent] tags, then no adjacent units will receive the effects.&lt;br /&gt;
** '''adjacent''': a comma separated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''. (See [[StandardLocationFilter#Directions|notes]])&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]]. {{DevFeature1.13|2}} The variable $other_unit refers to the unit owning the ability.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} set to 1 by default, it determines the range within which units can be affected beyond immediately adjacent units, if the value is equal to 'full-map', the area is the entire map.&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. [filter_self] takes a [[StandardUnitFilter]] as argument.&lt;br /&gt;
* '''[filter_adjacent]''' {{DevFeature1.19|10}}: if an adjacent unit does not match this filter, the ability will not be active and no-one will receive its affects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). In fact, it's really a shorthand for a [filter_adjacent] nested within [filter]. The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[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;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this ability appears in. Note that such events get included when a unit with this ability first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&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'' or ''cured''. ''slowed'' means poison will not take effect for adjacent units (it's not related to the weapon special &amp;quot;slows&amp;quot;).&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'' or ''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. Default: 0%. {{DevFeature1.17|24}} Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|0}} minimum resistance value. Default: no limit.&lt;br /&gt;
* '''add''': adds to resistance. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': subtracts from resistance.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides 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;
These keys affect the actual resistance (e.g. -20%), not the damage modifier normally used in [resistance] (e.g. 120).&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the opponent uses a matching weapon.&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;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
''Note:'' cumulative leadership with '''cumulative=yes''' and '''value=''' doesn't work in 1.16 (but fixed in 1.17.12 and later). To work around use '''add=''' or '''sub=''' key (it doesn't require cumulative) (https://github.com/wesnoth/wesnoth/issues/6466 ). If you want each instance of a ''[leadership]'' with the same id to be added you will be able to reuse '''cumulative=yes''' in 1.17.12 and later, otherwise, if you want to add the value of another ''[leadership]'' only once even with the same id in several copies, use '''add'''.&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the opponent uses a matching weapon.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[illuminates]'' ability ===&lt;br /&gt;
&lt;br /&gt;
Because this ability changes the terrain instead of units on it, affect_self, affect_allies, affect_enemies and [filter_adjacent] have no effect.&lt;br /&gt;
* '''value''': the percentage bonus to lawful units. Units with '''alignment=lawful''' do +''value'' % damage when under the influence of a unit with this ability. Units with '''alignment=chaotic''' do -''value'' % damage. Units with '''alignment=neutral''' are unaffected by this ability. Units with '''alignment=liminal''' do -(abs(''value'')) % damage. ''value'' can be a negative number; this is useful if you want to give Chaotic units an advantage instead of Lawful ones. &lt;br /&gt;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
* '''max_value''': the maximum percentage bonus given. Cannot be less than 0. Defaults to 0 if not present.&lt;br /&gt;
* '''min_value''': the minimum percentage bonus given. Cannot be greater than 0. Defaults to 0 if not present.&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;
=== Extra tags used by the ''[teleport]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''[tunnel]''' - a [[DirectActionsWML#.5Btunnel.5D|tunnel tag]] (without the remove key) defining the tunneling source and target hexes, and maybe other conditions. (It automatically applies only to the unit with the ability.)  You may use $teleport_unit inside the [tunnel][source] and [tunnel][target] tag for filtering purposes.&lt;br /&gt;
&lt;br /&gt;
=== Extra tags and keys used by weapon specials as abilities ===&lt;br /&gt;
&lt;br /&gt;
* {{anchor|filter_student|'''[filter_student]'''}}: {{DevFeature1.15|0}} If present, only the unit matching this filter, either the possessor of the ability if affect_self=yes, or an adjacent unit matching '''[filter_adjacent]''' will be affected. '''Replaces''' '''[filter_self]''' of normal weapon specials.&lt;br /&gt;
* '''overwrite_specials''': {{DevFeature1.15|13}} If present, allows a special abilities weapon with a numerical value to impose its value and ignore values of abilities or specials of the same type. If '''overwrite_specials=one_side''', the specials and abilities used by the opponent of the unit affected by the ability with this key and applied to it will not be affected. If '''overwrite_specials=both_sides''', all non-key-carrying abilities and all specials of the same type affecting the recipient unit will be affected, even if used by the opponent (used in the macro FORCE_CHANCE_TO_HIT).&lt;br /&gt;
* {{anchor|overwrite|'''[overwrite]'''}}: {{DevFeature1.17|22}} Part of '''overwrite_specials'''. Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** {{anchor|filter_specials|'''[experimental_filter_specials]'''}}: [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
* Other keys and tags appropriate to the specific weapon special.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common abilities ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:abilities.cfg macro reference]&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;
* {{DevFeature1.13|2}} ABILITY_LEADERSHIP (replaces the above leadership macros, which are now deprecated)&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;
* '''[attacks]''': modifies the number of attacks of a weapon, in using '''value''', '''add''', '''sub''', '''multiply''' or '''divide''' attributes&lt;br /&gt;
* '''[berserk]''': pushes the attack for more than one combat round, using '''value''' attribute, '''value''' is 1 by default&lt;br /&gt;
* '''[chance_to_hit]''': modifies the chance to hit of a weapon, using same standard numerical attributes as '''[attacks]'''&lt;br /&gt;
* '''[damage]''': modifies the damage of a weapon, using same attributes as '''[attacks]''' and '''[chance_to_hit]'''&lt;br /&gt;
* '''[damage_type]''' {{DevFeature1.17|23}}: changes the damage type of a weapon&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker half of the damage dealt, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 50% by default&lt;br /&gt;
* '''[firststrike]''': forces the weapon to always strike first&lt;br /&gt;
* '''[heal_on_hit]''': heals the attacker when an attack connects, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 0 by default&lt;br /&gt;
* '''[petrifies]''': turns the target to stone&lt;br /&gt;
* '''[plague]''': when used to kill an enemy, a friendly unit takes its place&lt;br /&gt;
* '''[poison]''': poisons the target&lt;br /&gt;
* '''[slow]''': slows the target&lt;br /&gt;
* '''[swarm]''': number of strikes decreases as the unit loses hitpoints&lt;br /&gt;
Any other tag is valid, but will result in a special that does nothing but report it is there.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every weapon special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any weapon special that expects a numeric value will also accept formulas using [[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the special. If omitted, the special will be hidden from the player.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the special when inactive. Defaults to ''name'' if not specified; if the special is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''description''': the (translatable) description of the special.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the special when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&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''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability], {{DevFeature1.19|5}} [experimental_filter_specials] deprecated, use [filter_specials] instead.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this weapon special appears in. Note that such events get included when a unit with this weapon special first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=74244</id>
		<title>DirectActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=74244"/>
		<updated>2025-04-02T17:55:47Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [gold] */ side is not used anymore&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. They can be used inside of [[EventWML|events]].&lt;br /&gt;
&lt;br /&gt;
The following tags are actions:&lt;br /&gt;
&lt;br /&gt;
=== [endlevel] ===&lt;br /&gt;
Ends the scenario.&lt;br /&gt;
* '''result''': before the scenario is over, all events with ''name=result'' are triggered. If ''result=victory'', the player progresses to the next level (i.e., the next scenario in single player); if ''result=defeat'', the game returns to the main menu. &lt;br /&gt;
&lt;br /&gt;
When the result is &amp;quot;victory&amp;quot; the following keys can 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. {{DevFeature1.13|2}} Alternatively, a number, defining the bonus multiple (1.0 meaning full).&lt;br /&gt;
* '''carryover_report''': whether the player should receive a summary of the scenario outcome, the default is carryover_report=yes.&lt;br /&gt;
* '''save''': whether a start-of-scenario save should be created for the next scenario, the default is save=yes. Do not confuse this with saving of replays for the current scenario.&lt;br /&gt;
* '''replay_save''': whether a replay save for the current scenario is allowed, the default is replay_save=yes. If yes, the player's settings in preferences will be used to determine if a replay is saved. If no, will override and not save a replay.&lt;br /&gt;
* '''linger_mode''': If ...=yes, the screen is greyed out and there's the possibility to save before advancing to the next scenario, the default is linger_mode=yes.&lt;br /&gt;
* '''reveal_map''': (Multiplayer only) (Default is 'yes') If 'no', shroud doesn't disappear when game ended.&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;
* '''carryover_percentage''': 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''': if yes the gold will be added to the starting gold the next scenario, if no the next scenario will start with the amount of the current scenario (after taxes) or the minimum in the next scenario. Default is no.&lt;br /&gt;
* '''music''': (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_credits''': Whether to display the credits screen at the end of a single-player campaign. Defaults to ''yes''. 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''': (translatable) 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''': 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;
* &amp;lt;strike&amp;gt;'''[next_scenario_settings]''': Any tags or attribute children of this optional argument to [endlevel] are merged into the scenario/multiplayer tag of the *next* scenario. This allows you to e.g. reconfigure the [side] tags or settings, just before load. &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* &amp;lt;strike&amp;gt;'''[next_scenario_append]''': Any tags of this optional argument are appended at high level to the next scenario. This is most appropriate for [event] tags, although you may find other uses. Example test scenario for these features: https://gna.org/support/download.php?file_id=20119 &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* '''[result]''' {{DevFeature1.13|0}} Allows specification of a side specific result, this is for competitive multiplayer scenarios/campaigns where it might happen that one player wins but another player loses.  The following attributes are accepted and have the same effect as in '''[endlevel]''':&lt;br /&gt;
** '''result'''&lt;br /&gt;
** '''bonus'''&lt;br /&gt;
** '''carryover_percentage'''&lt;br /&gt;
** '''carryover_add'''&lt;br /&gt;
&lt;br /&gt;
And there is also&lt;br /&gt;
** '''side''' The number of the side for which these results should apply.&lt;br /&gt;
&lt;br /&gt;
=== [unit] ===&lt;br /&gt;
Creates a unit (either on the map, on a recall list, or into a variable for later use.)  For syntax see [[SingleUnitWML]].&lt;br /&gt;
* {{Short Note:Predefined Macro|GENERIC_UNIT}}&lt;br /&gt;
&lt;br /&gt;
This tag can also recall an existing unit, which happens when:&lt;br /&gt;
* the '''id=''' attribute is used&lt;br /&gt;
* a unit with that '''id=''' already exists&lt;br /&gt;
* (might be unnecessary) the existing unit is on the side's recall list&lt;br /&gt;
in this case, the unit is recalled at the '''x,y=''' or '''location_id=''' given, and any other data in the tag is ignored.&lt;br /&gt;
&lt;br /&gt;
Campaign authors: a usual way to recall plot-necessary heroes is to use a macro with the data for creating that hero. This helps during debugging, because you can skip to scenarios and the recall-or-create functionality means that any units which are normally met in a previous scenario are automatically created (otherwise some scenarios may be an instant loss). This can only be used for units that must survive the previous scenarios, as it would recreate units if they died in a previous scenario.&lt;br /&gt;
For example,&lt;br /&gt;
[https://github.com/wesnoth/wesnoth/blob/1.14.7/data/campaigns/Heir_To_The_Throne/utils/httt_utils.cfg#L685 HttT's NEED_DELFADOR macro].&lt;br /&gt;
&lt;br /&gt;
=== [recall] ===&lt;br /&gt;
Recalls a unit taking into account any [[SingleUnitWML|filter_recall]] of the leader.   The unit is recalled free of charge, and is placed near its leader, e.g., if multiple leaders are present, near the first found which would be able to normally recall it.&lt;br /&gt;
&lt;br /&gt;
If neither a valid map location is provided nor a leader on the map would be able to recall it, the tag is ignored.&lt;br /&gt;
 &lt;br /&gt;
* [[StandardUnitFilter]]: the first matching unit will be recalled.  If no units match this tag is ignored. Do not use a [filter] tag. If a comma separated list is given, every unit currently considered for recall is checked against all the types (not each single one of the types against all units).&lt;br /&gt;
* '''x,y''': the unit is placed here instead of next to the leader.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to recall to. Used instead of '''x,y'''.&lt;br /&gt;
* '''show''': yes/no, default yes: whether the unit is animated (faded in) or instantly displayed&lt;br /&gt;
* '''fire_event''': boolean yes|no (default no); whether any according prerecall or recall events shall be fired.&lt;br /&gt;
* '''check_passability''': (boolean yes|no, default yes): If yes, checks for terrain passability when placing the unit (a nearby passable hex is chosen).&lt;br /&gt;
* '''[secondary_unit]''': {{DevFeature1.13|?}} If present and show=yes, a matching unit will be chosen and their recruiting animation played.&lt;br /&gt;
&lt;br /&gt;
=== [teleport] ===&lt;br /&gt;
Teleports a unit on map. {{Short Note:Predefined Macro|TELEPORT_UNIT}}&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] the first unit matching this filter will be teleported.&lt;br /&gt;
* '''x,y''': the hex to teleport to. If that hex is occupied, the closest unoccupied hex will be used instead.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to teleport to. Used instead of '''x,y'''.&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;
* '''check_passability''': (boolean yes|no, default yes): normally, units will not be teleported into terrain that is impassable for them. Setting this attribute to &amp;quot;no&amp;quot; permits it.&lt;br /&gt;
&lt;br /&gt;
(Note: There is also a ability named teleport, see [[AbilitiesWML]].)&lt;br /&gt;
&lt;br /&gt;
=== [terrain_mask] ===&lt;br /&gt;
Changes the terrain on the map.  See [[TerrainMaskWML]].&lt;br /&gt;
&lt;br /&gt;
=== [terrain] ===&lt;br /&gt;
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;
* [[StandardLocationFilter]]. This [[StandardLocationFilter]]'s terrain= key is used for the new terrain, filtering by terrain can be done with a nested [[StandardLocationFilter]]: [and]terrain=terrain_string_to_be_filtered_for.&lt;br /&gt;
* '''layer''': (overlay|base|both, default=both) only change the specified layer.&lt;br /&gt;
* '''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;
* '''location_id''': This key sets a string as a way to mark the hex or hexes for later reference.  It is very similar to the leader starting position, and can also be set that way in the map editor.&lt;br /&gt;
&lt;br /&gt;
If you want to remove the overlays from a terrain and leave only the base, use:&lt;br /&gt;
 layer=overlay&lt;br /&gt;
 terrain=&amp;quot;^&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages is that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [gold] ===&lt;br /&gt;
Gives sides gold.&lt;br /&gt;
* '''amount''': the amount of gold to give.&lt;br /&gt;
* [[StandardSideFilter]] sides to give the gold to. Default is all sides.&lt;br /&gt;
&lt;br /&gt;
=== [unstore_unit] ===&lt;br /&gt;
Creates a unit from a game variable, and activates it on the playing field or recall list.  This must be a specific variable describing a unit, and may not be an array (if it is, only the first unit will be unstored).&lt;br /&gt;
&lt;br /&gt;
This may be useful in different contexts:&lt;br /&gt;
* To update a unit on the map after having edited its WML. This usage is common, but discouraged - if possible, you should use [[#.5Bmodify_unit.5B|[modify_unit]]] or [[#.5Bobject.5B|[object]]] instead.&lt;br /&gt;
* To place a previously-defined unit into the scenario, if it was directly defined in a WML variable, using [unit] with the key '''to_variable'''. This usage is rather uncommon.&lt;br /&gt;
* To place a unit back into the game that was removed earlier, for example a hero that leaves the party for awhile and then comes back.&lt;br /&gt;
&lt;br /&gt;
The variable is not cleared. To unstore units from an array variable, iterate over the array. See [[VariablesWML]] and [[VariablesWML/How to use variables]] for more information about variable usage. See also [[InternalActionsWML#.5Bstore_unit.5D|[store_unit]]], [[ConditionalActionsWML|For]], [[ConditionalActionsWML#.5Bwhile.5D|[while]]] and [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]].&lt;br /&gt;
&lt;br /&gt;
The tag takes the following keys:&lt;br /&gt;
* '''variable''': This is required to indicate the name of the variable to read the unit from.&lt;br /&gt;
* '''Placement keys''':&lt;br /&gt;
** '''x''' ,'''y''': By default, the unit will be placed at the location specified in the variable, but if these keys are present, the unit will be placed at that location instead. To place the unit on the recall list of its side, use '''x,y=recall,recall'''. (If you want to change the said, you need to first update ''$unit.side'' in the variable before unstoring.)&lt;br /&gt;
** '''location_id''': {{DevFeature1.15|0}} The name of a special map location to unstore to. Used instead of '''x,y'''.&lt;br /&gt;
** '''find_vacant''' (yes|no, default no): 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;
** '''check_passability''' (yes|no, default yes): Only relevant if '''find_vacant=yes'''. In that case, this determines whether game will try to find a passable tile for the unit. If set to no, the unit may be placed on an impassable tile. Note that if both '''find_vacant''' and '''check_passability''' are set, then the unit's position may be shifted even if there is not a unit on the target space, if that space is not passable for the unit.&lt;br /&gt;
* '''Animation keys''' (these determine the visual effect of how the unit is placed or updated):&lt;br /&gt;
** '''text''': (translatable) A floating text to display above the unit, such as a damage amount.&lt;br /&gt;
** '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color of the text. 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;
** '''animate''': (boolean yes|no, default yes) Determines whether to play any animations associated with the unstore. Currently this only affects the advancement animation (&amp;quot;levelout&amp;quot; and &amp;quot;levelin&amp;quot;, defaulting to a fade to white and back) if the unit ends up advancing.&lt;br /&gt;
* '''Side-effect keys''' (these directly modify the behaviour of the action):&lt;br /&gt;
** '''advance''': (default=yes) if yes the unit is advanced if it has enough XP. When modifying XP, make sure to do it from inside a [[EventWML#Multiplayer_safety|synchronized event]] or it may lead to OOS errors, especially when several advancement paths exist. Note that advance and post advance events are called, so infinite loops can happen.&lt;br /&gt;
** '''fire_event''' (yes|no, default no): Whether any advance/post advance events shall be fired if an advancement takes place. This also affects whether the unit placed event is fired.&lt;br /&gt;
&lt;br /&gt;
Units can be unstored with negative (or zero) hit points. This can be useful if modifying a unit in its last_breath event (as the unit's death is already the next step), but tends to look wrong in other cases. In particular, it is possible to have units with negative hit points in play. Such units are aberrations, subject to unusual behavior as the game compensates for them. (For example, such units are currently automatically hit&amp;amp;mdash;and killed&amp;amp;mdash;in combat.) The details of the unusual behavior are subject to change between stable releases without warning.&lt;br /&gt;
&lt;br /&gt;
=== [allow_recruit] ===&lt;br /&gt;
Allows a side to recruit units it couldn't previously recruit. Any leader on this side will now be able to recruit the new units.&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. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [allow_extra_recruit] ===&lt;br /&gt;
Allows a leader to recruit units it couldn't previously recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[allow_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_recruit] ===&lt;br /&gt;
Prevents a side from recruiting units it could previously recruit. No leader on this side will be able to recruit the specified units anymore, unless that leader has the same unit in their personal '''extra_recruit''' list.&lt;br /&gt;
* '''type''': the types of units that the side can no longer recruit. {{DevFeature1.13|0}} If omitted, all recruits for matching sides will be disallowed.&lt;br /&gt;
* '''side''': (default=1) the number of the side that may no longer recruit the units. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_extra_recruit] ===&lt;br /&gt;
Prevents a leader from recruiting units it could previously recruit. This won't prevent the leader from recruiting that unit if the unit is in the '''[side]recruit=''' list – you must use '''[disallow_recruit]''' in that case.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can no longer recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [set_recruit] ===&lt;br /&gt;
Sets the units a side can recruit. Any leader on this side will now be able to recruit these units.&lt;br /&gt;
* '''recruit''': the types of units that the side can now recruit.&lt;br /&gt;
* '''side''': The number of the side that is having its recruitment set. This can be a comma-separated list.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [set_extra_recruit] === &lt;br /&gt;
Sets the units a leader can recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[set_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [modify_side] ===&lt;br /&gt;
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. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* '''income''': the income given at the begining of each turn.&lt;br /&gt;
* '''recruit''': a list of unit types, replacing the side's current recruitment list.&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;
* '''side_name''': {{DevFeature1.13|?}} a translatable string representing the side leader's description.&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. warning: in multiplayer, changing the controller of a side might result in OOS during some events like, for example 'side_turn_end'; see [https://github.com/wesnoth/wesnoth/issues/2563 issue #2563].&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;
* '''hidden''': a boolean string specifying whether side is shown in status table.&lt;br /&gt;
* '''color''': a team color range specification, name (e.g. &amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;), or number (e.g. &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;) for this side. The default color range names, numbers, and definitions can be found in data/core/team_colors.cfg.&lt;br /&gt;
* '''[ai]''': sets/changes AI parameters for the side. Only parameters that are specified in the tag are changed, this does not reset others to their default values. Uses the same syntax as described in [[AiWML]].  Note that [modify_side][ai] works for all simple AI parameters and some, but not all, of the composite ones. If in doubt, use [[AiWML#Adding_and_Deleting_Aspects_with_the_.5Bmodify_ai.5D_Tag|[modify_ai]]]] instead, which always works. {{DevFeature1.13|?}} If this contains an '''ai_algorithm''', the AI parameters will be reset to those of the indicated AI before adding any additional parameters included in the tag. In other words, this allows replacing the AI config rather than appending to it.&lt;br /&gt;
* '''switch_ai''': replaces a side ai with a new AI from specified file(ignoring those AI parameters above). Path to file follows the usual WML convention.&lt;br /&gt;
* '''reset_maps''': If set to &amp;quot;yes&amp;quot;, then the shroud is spread to all hexes, covering the parts of the map that had already been explored by the side, including hexes currently seen. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if shroud is on, but this is evaluated after shroud= (and before shroud_data=).&lt;br /&gt;
* '''reset_view''': If set to &amp;quot;yes&amp;quot;, then the fog of war is spread to all hexes, covering the parts of the map that had already been seen this turn by the side, including hexes currently seen, excluding hexes affected by multi-turn {{tag|DirectActionsWML|lift_fog}}. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if fog is on, but this is evaluated after fog=.&lt;br /&gt;
* '''share_maps''': change the share_maps side attribute. Be sure to use shroud=yes for that side and have it as an ally&lt;br /&gt;
* '''share_view''': change the share_view side attribute. Be sure to use fog=yes for that side and have it as an ally&lt;br /&gt;
* '''share_vision''': change both the above at the same time&lt;br /&gt;
* '''shroud_data''': changes to the side's shroud, using the same format as when defining the [side].&lt;br /&gt;
* '''suppress_end_turn_confirmation''': Boolean value controlling whether or not a player is asked for confirmation when skipping a turn.&lt;br /&gt;
* '''scroll_to_leader''': Boolean value controlling whether or not the game view scrolls to the side leader at the start of their turn when present.&lt;br /&gt;
* '''flag''': Flag animation for villages owned by this side (see [[SideWML|[side]]]).&lt;br /&gt;
* '''flag_icon''': Flag icon used for this side in the status bar (see [[SideWML|[side]]]).&lt;br /&gt;
* '''village_support''': The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.&lt;br /&gt;
* '''defeat_condition''' {{DevFeature1.13|0}}: When the side is considered defeated (see [[SideWML|[side]]]).&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the side; uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* '''[variables]''' {{DevFeature1.15|3}} The contents of this tag is merged into the side's variables.&lt;br /&gt;
&lt;br /&gt;
=== [modify_turns] ===&lt;br /&gt;
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;
* '''current''': changes the current turn number after applying turn limit modifications, if any. It is not possible to change the turn number to exceed the turn limit (1 &amp;lt;= current turns &amp;lt;= max turns).&lt;br /&gt;
&lt;br /&gt;
=== [allow_end_turn] ===&lt;br /&gt;
Allows human players to end their turn through the user interface if they were previously affected by the '''[disallow_end_turn]''' action. This action doesn't take any arguments.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_end_turn] ===&lt;br /&gt;
Disallows human players to end their turn through the user interface. This action doesn't require arguments.&lt;br /&gt;
* '''reason''' (translatable): {{DevFeature1.15|0}} Allows to optionally specify a reason.&lt;br /&gt;
&lt;br /&gt;
=== [capture_village] ===&lt;br /&gt;
Changes the ownership of a village.&lt;br /&gt;
* [[StandardLocationFilter]]: all village locations matching the filter are affected.&lt;br /&gt;
* '''side''': the side that takes control of the village. This side needs to have a leader (canrecruit=yes). If the side key is not given, the village will become neutral (unless [filter_side] is present, in which case that side fiter decides, see below).&lt;br /&gt;
* '''[filter_side]''' with [[StandardSideFilter]] tags and keys as arguments; if both this tag and inline side= are present it's an error. Otherwise, the first matching side gets ownership (or the village becomes neutral if none match).&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default: no): Whether any capture events shall be fired.&lt;br /&gt;
&lt;br /&gt;
=== [kill] ===&lt;br /&gt;
Removes all units (including units in a recall list) that match the filter from the game.&lt;br /&gt;
* [[StandardUnitFilter]]: Selection criterion; do not use a [filter] tag.&lt;br /&gt;
* '''animate''' (default 'no'): if 'yes', displays the unit dying (fading away). {{DevFeature1.13|8}} If '''[secondary_unit]''' is given, also plays the victory animation of that unit.&lt;br /&gt;
* '''fire_event''' (default 'no'): if 'yes', triggers any appropriate 'die' events (See [[EventWML]]). Note that events are only fired for killed units that have been on the map (as opposed to recall list).&lt;br /&gt;
* '''[secondary_unit]''' with a [[StandardUnitFilter]] as argument. Do not use a [filter] tag. Has an effect only if fire_event=yes ({{DevFeature1.13|8}} or if it has a victory animation and animate=yes). The first on-map unit matching the filter becomes second_unit in any fired die and last breath events. If an on-map unit matches and if there are several units killed with a single [kill] tag, second_unit is this same unit for all of them. If no on-map unit matches or [secondary_unit] isn't present, the variable second_unit in each of the die and last breath events is always the same as the variable unit (the dying unit).&lt;br /&gt;
* '''[primary_attack]''' {{DevFeature1.13|8}} The attacker's weapon to use for matching the animation. Useful for example on the wose, whose death animation depends on the damage type it was killed by. If a secondary unit is specified, this is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the unit. However, if there is no secondary unit specified, it is instead treated as an [[UnitTypeWML#Attacks|weapon definition]], and the animation will be run as if an imaginary unit possessing that weapon was the attacker.&lt;br /&gt;
* '''[secondary_attack]''' {{DevFeature1.13|8}} Similar to the above, but for the defender's weapon. This is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the dying unit.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit] ===&lt;br /&gt;
Moves a unit along a path on the map. The path can be specified exactly, or as a series of waypoints that the unit will pass through.&lt;br /&gt;
* [[StandardUnitFilter]] as argument; do not use a [filter] tag. All units matching the filter are moved. If the target location is occupied, the nearest free location is chosen.&lt;br /&gt;
* '''to_x''' (unsigned integer): The units are moved to this x coordinate. Can be a comma-separated list, in which case the unit follows this given path during the move.&lt;br /&gt;
* '''to_y''' (unsigned integer): The units are moved to this y coordinate. Can be a comma-separated list.&lt;br /&gt;
* '''dir''' (string): {{DevFeature1.15|0}} Performs a relative movement instead of an absolute movement. For example, dir=n,n,nw will move two spaces north and then one space to the northwest. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''to_location''': {{DevFeature1.15|0}} Moves matching units to locations placed in the map editor with the &amp;quot;New Location&amp;quot; button. Can be a comma-separated list. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''check_passability''' (boolean yes|no, default yes): Whether the terrain the unit is moved to should be checked for suiting the unit. (If it does not, a nearby suitable hex is chosen.)&lt;br /&gt;
* '''force_scroll''': Whether to scroll the map or not even when [[InterfaceActionsWML#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to using [[InterfaceActionsWML#.5Bmove_unit_fake.5D|[move_unit_fake]]]'s default value.&lt;br /&gt;
* '''clear_shroud''': {{DevFeature1.15|0}} (boolean yes|no, default no) Whether to remove shroud and fog after the unit was moved, but before events are fired. It will not clear all alongside the path, only around the target destination.&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default no): Whether any according moveto events shall be fired. The target location ($x1, $y1 in the event) may not be the same location that the unit was tried to be moved to, if the original target location is occupied or impassable.&lt;br /&gt;
&lt;br /&gt;
=== [modify_ai] ===&lt;br /&gt;
Changes AI objects (aspects, goals, candidate actions or stages) for a specified side. See [[Modifying_AI_Components#The_.5Bmodify_ai.5D_Tag|Modifying AI Components]] for full description.&lt;br /&gt;
&lt;br /&gt;
* '''action''' (string): Takes values 'add', 'change', 'delete' or 'try_delete' to do just that for the AI object.&lt;br /&gt;
* '''path''' (string): Describes which AI object is to be modified.  &lt;br /&gt;
* '''[facet]''', '''[goal]''', '''[candidate_action]''' or '''[stage]''': Details about the AI object to be modified.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [modify_unit] ===&lt;br /&gt;
works similar to the MODIFY_UNIT macro.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. All units matching this filter are modified. Matches on recall list units too.&lt;br /&gt;
* '''[object]''', '''[trait]''', {{DevFeature1.13|5}} '''[advancement]''' - The given modifications will be immediately applied to all units matching the filter. ([object] is described further [[#.5Bobject.5D|below]])&lt;br /&gt;
** '''delayed_variable_substitution''' {{DevFeature1.13|5}} (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object], [trait], or [advancement] is not variable-substituted at execution time of the event containing this [modify_unit]. You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
** Do not use a '''[modifications]''' tag, as this may skip some of the special-case handling for newly added objects, traits and advancements, and will potentially overwrite existing modifications.&lt;br /&gt;
* '''[effect]''' {{DevFeature1.13|6}} Applies the effect directly to the unit. See [[EffectWML]].&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the unit (saved inside the unit's [variables] tag); uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* Accepts generally the syntax inside of wml unit variables created by [store_unit] which can be viewed in a savefile or by using the [[CommandMode|inspect command]]. Cannot remove things or add/alter unit animations. Subtags with the same name must be written in the correct order to match them with the tag they are supposed to modify. Note that keys will be processed in arbitrary order, which may cause problems if you use formulas that depend on other formulas. To work around this you may need to use the tag twice with the same filter.&lt;br /&gt;
example usage (see also the test scenario):&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[modify_unit]&lt;br /&gt;
  [filter]&lt;br /&gt;
    x,y=38,6&lt;br /&gt;
  [/filter]&lt;br /&gt;
  hitpoints=10&lt;br /&gt;
  {TRAIT_HEALTHY}&lt;br /&gt;
[/modify_unit]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit which is currently modified is accessible via $this_unit, e.g. hitpoints = &amp;quot;$($this_unit.hitpoints / 2)&amp;quot; to set the hitpoints of all units to half of their current value. This this_unit variable is independent from the this_unit variable available in the SUF used to determine which units to modify (first all matching units are gathered, and then all those are modified).&lt;br /&gt;
&lt;br /&gt;
Modifying a unit ''may'' trigger an advancement event if the experience is set higher than the max_experience. However, this behaviour should not be relied upon to happen under all circumstances; if it's desired, the event should be triggered separately, for example with '''[transform_unit]'''. Setting value, including empty string, of ''type'' acts as shortcut of ''experience=&amp;quot;$this_unit.max_experience&amp;quot;''.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Some some properties of the units are reset sometimes (for example when the unit advances or when [remove_object] is called), so it's usually better to change them with [object] ([object] inside [modify_unit]) than to change those properties directly via [modify_unit]. The following properties are ''not'' reset in [remove_object] and are thus safe to use directly in [modify_unit]:&lt;br /&gt;
* '''side'''&lt;br /&gt;
* '''gender'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''canrecruit'''&lt;br /&gt;
* '''unrenamable'''&lt;br /&gt;
* '''extra_recruit'''&lt;br /&gt;
* '''[variables]'''&lt;br /&gt;
* '''facing'''&lt;br /&gt;
* '''x, y'''&lt;br /&gt;
* '''goto_x, goto_y'''&lt;br /&gt;
* '''hitpoints'''&lt;br /&gt;
* '''experience'''&lt;br /&gt;
* '''moves'''&lt;br /&gt;
* '''[status]'''&lt;br /&gt;
* '''attacks_left'''&lt;br /&gt;
* '''role'''&lt;br /&gt;
&lt;br /&gt;
=== [transform_unit] ===&lt;br /&gt;
Transforms every unit on the map matching the filter to the given unit type. Keeps intact hit points, experience and status. If the unit is transformed to a non-living type (undead or mechanical), it will be also unpoisoned. Hit points will be changed if necessary to respect the transformed unit's maximum hit points. Regardless of anything else, the unit will be rebuilt. Thus, transforming a unit to its current type is a way to force a rebuild, for example after manually removing a modification.&lt;br /&gt;
* [[StandardUnitFilter]]: do not use a [filter] tag.&lt;br /&gt;
* '''transform_to''': the unit type in which all the units matching the filter will be transformed. If missing, the units will follow their normal advancement.&lt;br /&gt;
&lt;br /&gt;
=== [petrify] ===&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are petrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [unpetrify] ===&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are unpetrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [object] ===&lt;br /&gt;
Gives some unit an object which modifies their stats in some way. This tag can also be used in places that don't support ActionWML, such as [[#.5Bmodify_unit.5D|[modify_unit]]] or [[SingleUnitWML|[unit][modifications]]]. The following is supported in all these places:&lt;br /&gt;
* '''[effect]''': one or more effect elements may be listed.  See [[EffectWML]] for a description of [effect].&lt;br /&gt;
* '''duration''':&lt;br /&gt;
**if 'scenario', effects only last until the end of the scenario.&lt;br /&gt;
**if 'forever' or not set, effects never wear off.&lt;br /&gt;
** if 'turn', effects only last until the start of the unit's next turn (when the unit refreshes movement and attacks). (Like other start-of-turn behavior, objects with a duration of &amp;quot;turn&amp;quot; won't expire before turn 2.)&lt;br /&gt;
** {{DevFeature1.13|1}} if 'turn end', effects only last until the end of the unit's next turn (exactly like the slowed status).&lt;br /&gt;
* Other keys, such as '''id''', may be used to remove the object later, but are not used by the engine. An '''[object]''' tag can contain any arbitrary data that may be helpful to identify the object to remove later using a [[FilterWML#Filtering_on_WML_data|WML filter]].&lt;br /&gt;
&lt;br /&gt;
The following is supported only when using '''[object]''' as ActionWML:&lt;br /&gt;
* '''id''': (Optional) By default, an object with a defined ID can only be picked up once per scenario, even if it is removed later or first_time_only=no is set for the event. You can remove this restriction by setting take_only_once=no. For filtering objects, it might be simpler to use a custom key such as item_id. The id string can contain only letters, numbers and underscores. The ID is also commonly used to manually remove the object later, for example with [[#.5Bremove_object.5D|[remove_object]]].&lt;br /&gt;
* '''take_only_once''': (default yes) {{DevFeature1.13|6}} If set to &amp;quot;no&amp;quot;, the object's ID does not prevent it from being taken more than once.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object] is not variable-substituted at execution time of the event where this [object] is within.  You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. The first unit found that matches the filter will be given the object. Only on-map units are considered. If no unit matches or no [filter] is supplied, it tries to apply the object to the unit at the $x1,$y1 location of the event where this [object] is in. The case of no unit being at that spot is handled in the same way as no unit matching a given filter ([else] commands executed, cannot_use_message displayed). Note that units on the recall list will not be checked. To add an [object] to a unit on the recall list you have to use '''[modify_unit][object]'''.&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 '''[remove_item]''' tag, but you could probably put any tags that otherwise work in a [then] tag.&lt;br /&gt;
* '''[else]''': a subtag that lets you execute actions if the filter conditions are *not* met.&lt;br /&gt;
* '''silent''': whether or not messages should be suppressed. Default is &amp;quot;no&amp;quot;. {{DevFeature1.13|2}} If no description is provided, this defaults to yes, but can still be overridden.&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;
* '''description''': (translatable) displayed as a message of the image.&lt;br /&gt;
* '''cannot_use_message''': (translatable) displayed instead of '''description''' if no unit passes the filter test.&lt;br /&gt;
&lt;br /&gt;
=== [remove_object] ===&lt;br /&gt;
{{DevFeature1.13|6}}&lt;br /&gt;
&lt;br /&gt;
Removes an object from matching units.&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching objects removed. Use no [filter] tag.&lt;br /&gt;
* '''object_id''': The id of the object to be removed.&lt;br /&gt;
&lt;br /&gt;
Note that some unit properties are not restored ideally, e.g. current unit's health reversion might not work as expected (max_hitpoints will though). {{DevFeature1.15|0}} This was fixed.&lt;br /&gt;
&lt;br /&gt;
Note that [remove_object] works the following way: &lt;br /&gt;
&lt;br /&gt;
# Remove the object from the unit&lt;br /&gt;
# Rebuild the unit to make the changes effective.&lt;br /&gt;
&lt;br /&gt;
Step 2 implies that changes done for example via [modify_unit] (or via the [store_unit] + [set_variable] + [unstore_unit] technique) will be reset if those changes change a property that is a property of the unit type. See the note under [[#.5Bmodify_unit.5D|[modify_unit]]] to get a list of properties that can safely be changed via [modify_unit].&lt;br /&gt;
&lt;br /&gt;
=== [remove_trait] ===&lt;br /&gt;
{{DevFeature1.15|2}}&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching traits removed. Use no [filter] tag.&lt;br /&gt;
* '''trait_id''': The id of the trait to be removed. See [[UnitsWML#.5Btrait.5D|[trait]]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list of sides. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles for which shroud should be removed&lt;br /&gt;
&lt;br /&gt;
=== [place_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles on which shroud should be placed&lt;br /&gt;
&lt;br /&gt;
=== [lift_fog] ===&lt;br /&gt;
Lifts the fog of war from parts of the map for a certain side (only relevant for sides that have fog=yes), allowing a player to witness what occurs there even if that player has no units within vision range.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the tiles from which fog should be lifted.&lt;br /&gt;
* '''multiturn''': ''yes/no, default:no''. The default (not multiturn) causes fog to be removed in the same way that normal vision works; the cleared tiles will remain cleared until fog is recalculated (which normally happens when a side ends its turn). When multiturn is set to &amp;quot;yes&amp;quot;, the cleared tiles remain clear until {{tag||reset_fog}} cancels the clearing. This allows tiles to remain clear for multiple turns, or to be refogged before the end of the current turn (without also refogging all tiles). Multiturn lifted fog is not shared with allies (even when share_vision=all).&lt;br /&gt;
&lt;br /&gt;
=== [reset_fog] ===&lt;br /&gt;
The primary use of this tag is to remove multiturn lifted fog (created by {{tag||lift_fog}}), which causes the fog to reset to what it would have been had WML not interfered. (That is, hexes that a side's units could not see at any point this turn will be re-fogged, while seen hexes remain defogged.)&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the fog reset will be restricted to these tiles.&lt;br /&gt;
* '''reset_view''': ''yes/no, default: no'' If set to &amp;quot;yes&amp;quot;, then in addition to removing multiturn fog, the side's current view is canceled (independent of the SLF). This means that all hexes will become fogged for the side unless multiturn fog exists outside the tiles selected by the SLF. Normally, one would want the currently seen hexes to become clear of fog; this is done automatically at the end of many events, and it can be done manually with {{tag|InterfaceActionsWML|redraw}}.&lt;br /&gt;
Omitting both the SSF and the SLF would cancel all earlier uses of [lift_fog].&lt;br /&gt;
Additionally setting reset_view=&amp;quot;yes&amp;quot; would cause the side's entire map to be fogged (unless an ally keeps hexes clear by sharing its view).&lt;br /&gt;
&lt;br /&gt;
=== [allow_undo] ===&lt;br /&gt;
Normally when an event with a handler fires, the player's undo stack is cleared, preventing all actions performed so far from being undone. Including this tag in the event handler prevents the stack from being cleared for this reason, allowing the player to undo actions. (However, the stack might still be cleared for other reasons, such as fog being cleared or combat occurring.) In the common cases, this means '''[allow_undo]''' allows the current action to be undone even though an event was handled. There is a less common case, though &amp;amp;mdash; specifically when handling a menu item, where there is no current action &amp;amp;mdash; and in this case, '''[allow_undo]''' means merely that earlier actions can still be undone.&lt;br /&gt;
* Using this tag in a menu item has an additional side effect in 1.11. Starting with version 1.11.1, executing a WML menu item normally counts as doing something as far as the &amp;quot;you have not started your turn yet&amp;quot; dialog is concerned. However, a menu item whose handler includes '''[allow_undo]''' will not count.&lt;br /&gt;
&lt;br /&gt;
The types of actions that can be undone are movement, recalling, and dismissing a unit from the recall list. If an action is undone, only the position (or existence) of the involved unit will be restored; any altered variables or changes to the game will remain changed after the action 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 action the first time.&lt;br /&gt;
* Although recalling can be undone, recruitment can not be undone; this seems to apply even when the recruit's traits are not randomly-generated (tested on 1.12.6 and 1.14.4+dev).&lt;br /&gt;
&lt;br /&gt;
If an '''[event]''' uses both '''[allow_undo]''' and [[InternalActionsWML#.5Bfire_event.5D|'''[fire_event]''']] then the '''[allow_undo]''' must be after the '''[fire_event]'''.&lt;br /&gt;
&lt;br /&gt;
Due to a bug in 1.12 ([http://web.archive.org/web/20170330000414/http://gna.org/bugs/?23323 https://gna.org/bugs/?23323]) '''[allow_undo]''' should not be used in events that use one of the following things because it might cause OOS: &lt;br /&gt;
* [message] with [option]s&lt;br /&gt;
* [get_global_variable]&lt;br /&gt;
* wesnoth.synchronize_choice&lt;br /&gt;
&lt;br /&gt;
While in 1.13 using '''[allow_undo]''' together with those things won't give you a guaranteed OOS, there are some non-obvious situations where it will, for example assume the following event:&lt;br /&gt;
&lt;br /&gt;
   [event]&lt;br /&gt;
     name=&amp;quot;moveto&amp;quot;&lt;br /&gt;
     [message]&lt;br /&gt;
       message = &amp;quot;message&amp;quot;&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 1&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 2&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
     [/message]&lt;br /&gt;
     [allow_undo]&lt;br /&gt;
     [/allow_undo]&lt;br /&gt;
   [/event]&lt;br /&gt;
&lt;br /&gt;
It will cause OOS when the message is undone: since the event is already executed (erased) on one client only , the clients will disagree about how many choices happen during the next moveto action.&lt;br /&gt;
&lt;br /&gt;
=== [on_undo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Contains commands to execute when the player undoes the action which triggered the parent event.&lt;br /&gt;
*'''delayed_variable_substitution''' {{DevFeature1.13|5}}: ''yes/no, default no (always no before 1.13.5)'' As in [[EventWML]], specifies whether to perform variable substitution when the parent event is run, or when the contents are run. If delayed substitution is used, [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] from the parent event context are available, but may occasionally have unexpected values. (In particular, $unit.x and $unit.y may not have the expected value when undoing a move event, though $x1 and $y1 should be correct.)&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
It is not clear where whether the actionwml in [on_undo] in executed before or after the action is undone. Also, specially for enter/leave_hex events the units position when executing the [on_undo] code is usually different than when executing the original event. The recommended way to work around these issues is to refer to the unit by id instead of position and store all other needed information variables as 'upvalues'. You can also move the actual undo code to an external event. For example&lt;br /&gt;
 [event]&lt;br /&gt;
   name=&amp;quot;undo_blah&amp;quot;&lt;br /&gt;
   first_time_only=no&lt;br /&gt;
   [store_unit]&lt;br /&gt;
     id=&amp;quot;$moved_unit_id&amp;quot;&lt;br /&gt;
   [/store_unit]&lt;br /&gt;
   ... do undo stuff stuff&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 ... in some other event&lt;br /&gt;
   [on_undo]&lt;br /&gt;
     # store ''upvalues&lt;br /&gt;
     {VARIABLE moved_unit_id $unit.id}&lt;br /&gt;
     # call actual undo handler&lt;br /&gt;
     [fire_event]&lt;br /&gt;
       name = &amp;quot;undo_blah&amp;quot;&lt;br /&gt;
     [/fire_event]&lt;br /&gt;
   [on_undo]&lt;br /&gt;
&lt;br /&gt;
=== [on_redo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Same as [on_undo], except executes the commands on redo. Note that the parent event is not triggered again on a redo.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} [on_redo] is deprecated and has no effect anymore.&lt;br /&gt;
&lt;br /&gt;
Note that [on_redo] is not guaranteed to be called when redoing an action, the engine might also decide to just fire the original events again.&lt;br /&gt;
&lt;br /&gt;
=== [cancel_action] ===&lt;br /&gt;
Although Wesnoth 1.12 does not have this tag, it is the default behavior of '''enter_hex'''/'''exit_hex''' [event] in that version.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}} In this version, [cancel_action] is recognised, but has no effect (a bug).&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
In an '''enter_hex'''/'''exit_hex''' [event], interrupt the movement, leaving the unit where it is. This is intended to be used with an event that gives the player new information, to let the player choose whether to change their plans. For example, if the player has commanded a unit to move from (1,1) to (3,3) and attack a unit on (4,4); then a [cancel_action] inside an '''enter_hex''' [event] on (2,2) would make the unit stop on (2,2). A [cancel_action] inside an enter_hex [event] on (3,3) would let the player choose whether to attack.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
In a '''capture'''/'''moveto''' [event], interrupt the attack.&lt;br /&gt;
&lt;br /&gt;
=== [heal_unit] ===&lt;br /&gt;
Heal a unit. The variable '''$heal_amount''' will be set to the exact number of points healed (i.e can be less than the parameter '''amount''' if the unit is fully healed). $heal_amount contains only the number of hitpoints the first unit that was found got healed. When the variable is not needed, use {CLEAR_VARIABLE heal_amount} after this tag.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}} The '''$heal_amount''' variable is no longer set. Use the '''variable''' key instead.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] All matching on-map units are healed. If no filter is supplied, it is tried to take the unit at $x1, $y1.&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] all the units matching the filter ''and'' having the ''heals'' ability will have their animation played (if ''animate'' is set to yes) for each of the units healed.&lt;br /&gt;
*  '''amount''': (integer, default full) the maximum points the unit(s) will be healed. This can't be used to set the unit's hitpoints below 1 or above the unit's maximum hitpoints. If &amp;quot;full&amp;quot;, it fully heals the unit.&lt;br /&gt;
*  '''animate''': a boolean which indicate if the healing animations must be played. (default no)&lt;br /&gt;
*  '''moves''': (integer, default 0) The maximum current movement points the units will be &amp;quot;healed&amp;quot;. Can't set below 0 or above max_moves. If &amp;quot;full&amp;quot;, sets moves to max_moves.&lt;br /&gt;
* '''restore_attacks''': (boolean, default no) Whether the units' attacks_left should be reset to their max_attacks (usually 1).&lt;br /&gt;
* '''restore_statuses''': (boolean, default yes) Whether standard statuses should be reset to &amp;quot;no&amp;quot;. This affects poisoned, slowed, petrified and unhealable.&lt;br /&gt;
* '''variable''': {{DevFeature1.17|0}} creates an array with the given name; each item of the array has two fields, ''id='' (the ID of the unit being healed) and ''heal_amount='' (the amount of HPs the unit has been healed by).&lt;br /&gt;
&lt;br /&gt;
=== [harm_unit] ===&lt;br /&gt;
Harms every unit matching the filter, for the specific damage amount. When harming multiple units, the special variable '''$this_unit''' can be used to access the current unit being harmed. This obviously does not work inside the filters though, as they give '''$this_unit''' a different meaning.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] all matching units will be harmed (required).&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] if present, the first matching unit will attack all the units matching the filter above.&lt;br /&gt;
*  '''amount''': the amount of damage that will be done (required).&lt;br /&gt;
*  '''alignment''': (default neutral) applies an alignment to the damage, this means that if alignment=chaotic, the damage will be increased at night and reduced at day.&lt;br /&gt;
*  '''damage_type''': if present, amount will be altered by unit resistance to the damage type specified.&lt;br /&gt;
*  '''kill''': (default yes) if yes, when a harmed unit goes to or below 0 HP, it is killed; if no its HP are set to 1.&lt;br /&gt;
*  '''fire_event''': (default no) if yes, when a unit is killed by harming, the corresponding events are fired.  If yes, also the corresponding advance and post advance events are fired.&lt;br /&gt;
*  '''animate''': (default no) if yes, scrolls to each unit before harming it and plays its defense (or attack, if it's the harmer) and death animations. Special values supported, other than the usual yes and no, are &amp;quot;attacker&amp;quot;, that means only the harmer will be animated, and &amp;quot;defender&amp;quot;, that means only the harmed units will be animated. If the supplied value is yes, attacker or defender also advancement animations are played.&lt;br /&gt;
*  '''[primary_attack], [secondary_attack]''': these set the weapon against which the harmed units will defend, and that the harming unit will use to attack, respectively (notice this is the opposite of '''[filter]''' and '''[filter_second]''' above). This allows for playing specific defense and attack animations. Both tags are expected to contain a [[FilterWML#Filtering_Weapons|Standard Weapon Filter]].&lt;br /&gt;
*  '''delay''': if animate=yes, sets the delay (in milliseconds, default 500) between each unit harming.&lt;br /&gt;
*  '''variable''': if present, the damage caused to the unit, altered by resistances, will be stored in a WML array with the given name, under the ''harm_amount='' key. {{DevFeature1.17|0}} Each item of the array also has an ''id='' key, which contains the ID of the unit being harmed.&lt;br /&gt;
*  '''poisoned, slowed, petrified, unhealable''': (default no) if yes, every harmed unit that doesn't already have such status will have it set.&lt;br /&gt;
*  '''experience''': (default yes) If there is a harmer, experience will be attributed similar to regular combat. Can take list of values. When any value is provided, all unspecified experience types default to not giving experience. Supported values: {{DevFeature1.17|25}} until that version only experience=yes and experience=no are supported&lt;br /&gt;
** no - none of involved units get any experience (this value only works if it is the only value in list)&lt;br /&gt;
** kill - the harming unit receives experience based on level of harmed unit in attack which kills harmed unit&lt;br /&gt;
** attack - the harming unit receives experience based on level of harmed unit in attack which does not kill harmed unit, or in attack which kills harmed unit while kill experience is disabled&lt;br /&gt;
** defend - the unit being harmed receives experience based on level of harming unit in attack which does not kill harmed unit&lt;br /&gt;
** fight - short form of experience=attack,defend&lt;br /&gt;
** yes - short form of experience=kill,attack,defend&lt;br /&gt;
*  '''resistance_multiplier''': the harmed unit's resistance is multiplied by the supplied value; this means that a value lower than 1 increases it, and a value greater than 1 decreases it. Default value is 1, that means no modification.&lt;br /&gt;
&lt;br /&gt;
=== [time_area] ===&lt;br /&gt;
How a day should progress in a given area. Everywhere not specified in a [time_area] tag is affected by the [time] tags in the [scenario] tag.&lt;br /&gt;
* [[StandardLocationFilter]]: the locations to affect. ''note: only for [event][time_area]s - at scenario toplevel [time_area] does not support [[StandardLocationFilter]], only location ranges''&lt;br /&gt;
* '''[time]''': one or more tags describing the new schedule, see [[TimeWML]].&lt;br /&gt;
* '''id''': an unique identifier assigned to a time_area. Optional, unless you want to remove the time_area later or reference it from a location filter elsewhere. Can be a comma-separated list when removing time_areas, 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;
* '''current_time''': The time slot number (starting with zero) active at the creation of the area.&lt;br /&gt;
&lt;br /&gt;
''Example:'' (caves in parts of a map)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[time_area]&lt;br /&gt;
    id = cave_area&lt;br /&gt;
    x = 1-2,4-5&lt;br /&gt;
    y = 1-2,1-2&lt;br /&gt;
    {UNDERGROUND}&lt;br /&gt;
[/time_area]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifying an id allows the area to be referenced from location filters. Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
    [time_area]&lt;br /&gt;
        id = glyphs&lt;br /&gt;
        x = 9,14&lt;br /&gt;
        y = 11,3&lt;br /&gt;
    [/time_area]&lt;br /&gt;
    [event]&lt;br /&gt;
        name = moveto&lt;br /&gt;
        first_time_only=no&lt;br /&gt;
        [filter]&lt;br /&gt;
            side = 1&lt;br /&gt;
            [filter_location]&lt;br /&gt;
                area = glyphs&lt;br /&gt;
            [/filter_location]&lt;br /&gt;
        [/filter]&lt;br /&gt;
        # Do something, for example healing the unit&lt;br /&gt;
    [/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [remove_time_area] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
This is a syntactic shortcut for [time_area] remove=.&lt;br /&gt;
* '''id''': Comma-separated list of time area ids to remove.&lt;br /&gt;
&lt;br /&gt;
=== [end_turn] ===&lt;br /&gt;
End the current side's turn. The current event is finished before the turn is ended. Also, if the current event (where the tag appears) has been fired by another event, that event (and the complete stack of other possible parent events) is ended before [end_turn] comes into affect. Also, events following the event stack that fired [end_turn] are not omitted (e.g. [end_turn] is used by a side turn event and a turn refresh event does something afterwards).&lt;br /&gt;
&lt;br /&gt;
=== [replace_map] ===&lt;br /&gt;
&lt;br /&gt;
Replaces the entire map.&lt;br /&gt;
* '''map_data''': Content of a wesnoth map file. (This key used to be just '''map='''.) Example:&lt;br /&gt;
 map_data=&amp;quot;{campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map}&amp;quot;&lt;br /&gt;
* '''map_file''': {{DevFeature1.13|?}} Path to a Wesnoth map file; can be used instead of '''map'''. The file will be loaded when the tag is executed, rather than being embedded wholesale in the preprocessed WML. Example:&lt;br /&gt;
 map_file=campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map&lt;br /&gt;
{{DevFeature1.15|3}} If the file is not found directly, it will be searched for in the [[BinaryPathWML|[binary_path]]]. Assuming a standard campaign or add-on layout, the example above can be replaced by:&lt;br /&gt;
 map_file=01_The_Elves_Besieged.map&lt;br /&gt;
* '''expand''': if 'yes', allows the map size to increase. The expansion direction is currently always bottom-right.&lt;br /&gt;
* '''shrink''': if 'yes', allows the map size to decrease. If the map size is reduced, any units that would no longer be on the map due to its coordinates no longer existing will be put into the recall list.&lt;br /&gt;
Note: When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages it that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [replace_schedule] ===&lt;br /&gt;
Replace the time of day schedule of the entire scenario.&lt;br /&gt;
* [[TimeWML]]: the new schedule.&lt;br /&gt;
* '''current_time''': The time slot number (starting with zero) active at schedule replacement. ('''NB''': due to https://github.com/wesnoth/wesnoth/issues/5757 this attribute is ignored in versions 1.16.*. The fix was delivered in 1.17.* but wasn't backported due to backward-compatibility requirements)&lt;br /&gt;
&lt;br /&gt;
=== [tunnel] ===&lt;br /&gt;
&lt;br /&gt;
Create a tunnel between some locations, later usable by units to move from source hex to target hex (using the movement cost of unit on the target terrain).&lt;br /&gt;
&lt;br /&gt;
'''Behavior Change as of Wesnoth 1.13.6:''' Vision is now possible (and enabled by default) through tunnels and allied units on the exit hex do not block a tunnel by default any more. This is done in order for moves through tunnels to be consistent with other moves. The previous behavior can still be accomplished by using the new optional keys listed below.&lt;br /&gt;
&lt;br /&gt;
* '''[filter]''': (required) [[StandardUnitFilter]] the units which can use the tunnel. Leave empty for &amp;quot;all units&amp;quot;.&lt;br /&gt;
* '''[source]''': (required) [[StandardLocationFilter]] the source hex(es). Use $teleport_unit to filter on unit being teleported.&lt;br /&gt;
* '''[target]''': (required) [[StandardLocationFilter]] the target hex(es). Use $teleport_unit to filter on unit being teleported.&lt;br /&gt;
* '''id''': (optional) identifier for the tunnel, to allow removing.&lt;br /&gt;
* '''remove''': (boolean, default: no)  If yes, removes all defined tunnels with the same ID (then only id= is necessary).&lt;br /&gt;
* '''bidirectional''': (boolean, default: yes) If yes, creates also a tunnel in the other direction. &lt;br /&gt;
* '''always_visible''': (boolean, default: no) If yes, the possible movement of enemies under fog can be seen.&lt;br /&gt;
* '''allow_vision''': (boolean, default: yes) {{DevFeature1.13|6}} If no, vision through a tunnel is not possible. Note that in that case the tunnel cannot be used if the tunnel exit is under shroud (which previously was ''always'' the case).&lt;br /&gt;
* '''pass_allied_units''': (boolean, default: yes) {{DevFeature1.13|6}} If no, allied (including own) units on the exit hex block a tunnel.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean, default: yes): If yes, the WML block contained in this [tunnel] is not variable-substituted at execution time of the event where this [tunnel] is within. Instead, variables are substituted when the tunnel is used by a unit. See [[EventWML#Nested_Events]]&lt;br /&gt;
&lt;br /&gt;
(Note: The tunnel tag can also be used inside the [[AbilitiesWML|[teleport]]] ability, without remove= and id=).&lt;br /&gt;
&lt;br /&gt;
=== [do_command] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Executes a command, specified using the same syntax as a [command] tag in [[ReplayWML]]. Not all [command]'s are valid: only these are accepted&lt;br /&gt;
&lt;br /&gt;
* [attack]&lt;br /&gt;
* [move]&lt;br /&gt;
* [recruit]&lt;br /&gt;
* [recall]&lt;br /&gt;
* [disband]&lt;br /&gt;
* [fire_event]&lt;br /&gt;
* [lua_ai] {{DevFeature1.13|12}} This has been removed and is replaced with [custom_command]&lt;br /&gt;
&lt;br /&gt;
The tags corresponding to player actions generally use the same codepath as if a player had ordered it. That means for example that only moves that player would be allowed to do are possible, and movement is interrupted when sighting enemy unit.&lt;br /&gt;
&lt;br /&gt;
One purpose of this tag is to allow scripting of noninteractive scenarios -- without a tag like this, this might require elaborate mechanisms to coerce ais in order to test these code paths.&lt;br /&gt;
&lt;br /&gt;
This command should be replay safe if it is either invoked in a synced context, ''or'' invoked in code that is never synced, like AI code, a select event, or a menu item with `synced = false`. However, if you use desynchronized logic ''during'' an event that is otherwise synced, invoking [do_command] based on that desynchronized logic will result in out-of-sync errors during the replay; in this case, you must explicitly synchronize which command to do using something like the lua function wesnoth.sync.evaluate_single.&lt;br /&gt;
&lt;br /&gt;
=== [put_to_recall_list] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Puts a unit to the recall list of its side.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': the unit(s) to get put to the recall list.&lt;br /&gt;
* '''heal''': (default=no) Whether the unit should be refreshed, similar to the unit moving to the recall list at the end of a scenario.&lt;br /&gt;
&lt;br /&gt;
=== [set_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified achievement as completed and shows a popup stating it's been completed. The popup is not shown if the achievement has already been achieved.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
&lt;br /&gt;
=== [set_sub_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|17}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified sub-achievement as completed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''sub_id''': The id of the sub-achievement.&lt;br /&gt;
&lt;br /&gt;
=== [progress_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Progress an achievement by the specified amount, with an optional limit for how far the achievement can be progressed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''amount''': The amount to increment the achievement.&lt;br /&gt;
* '''limit''': (optional) Using this attribute will prevent achievements from progressing past this value.&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 [https://www.wesnoth.org/macro-reference.html 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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth&amp;diff=74234</id>
		<title>LuaAPI/wesnoth</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth&amp;diff=74234"/>
		<updated>2025-03-23T17:26:08Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* wesnoth.terrain_types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module contains most of the core Wesnoth API. It is always loaded and available.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.dofile ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.dofile'''(''file_path'', [...]) &amp;amp;rarr; ...&lt;br /&gt;
&lt;br /&gt;
Loads and executes a file. The rules for locating the files are the same as for WML files, except that they require a ''.lua'' extension instead of ''.cfg.'' Any extra parameters to '''dofile''' are forwarded to the script (which can access them via the special &amp;lt;tt&amp;gt;...&amp;lt;/tt&amp;gt; variable), and '''dofile''' returns all the values returned by the script.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.require ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.require'''(''module'') &amp;amp;rarr; ''module_contents''&lt;br /&gt;
&lt;br /&gt;
Returns the contents of the specified module, loading it if necessary. The module can either be a simple name or a file path similar to that used by '''wesnoth.dofile'''. In addition, the ''.lua'' extension will automatically be appended if necessary. The module script is invoked with no arguments, and '''wesnoth.require''' then passes back its first return value, discarding any additional ones. If the module is a directory, then all lua files are loaded, and a table containing the resulting modules is returned, with the keys being the filenames minus the ''.lua'' extension.&lt;br /&gt;
&lt;br /&gt;
'''wesnoth.require''' returns nil on failure, for example if it could not locate the module. If it did locate the module, but the module did not return anything (or returned nil), then '''wesnoth.require''' returns an empty table with a metatable that raises an error on any attempt to access it.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.textdomain ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.textdomain'''(''domain'') &amp;amp;rarr; ''textdomain_constructor''&lt;br /&gt;
&lt;br /&gt;
Returns a callable userdata that can be used to construct translatable strings. A typical use is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local _ = wesnoth.textdomain &amp;quot;example&amp;quot;&lt;br /&gt;
wesnoth.alert(_ &amp;quot;This is an example translated string!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full syntax for using the result of this function is:&lt;br /&gt;
&lt;br /&gt;
* ''textdomain_constructor''(''string'', [''string_plural'', ''number'']) &amp;amp;rarr; ''translatable_string''&lt;br /&gt;
&lt;br /&gt;
By passing the optional arguments, you can vary the string based on a number that will be substituted into it. As with all Lua functions, the parentheses are optional when passing a single string argument, as in the above example. This plural syntax returns a form of the string that's grammatically suitable for the indicated number, but doesn't actually substitute the number in – you need to do that yourself with either '''string.format''' or '''stringx.vformat'''.&lt;br /&gt;
&lt;br /&gt;
The returned translatable string can be treated in many ways like a regular string. Translatable strings can be compared with other translatable strings or concatenated with each other or with regular strings or integers. The length operator also works, though it should be noted that its value may change if the language is changed. If you need to pass a translatable string to a function that doesn't understand them, it can be converted to a regular string with tostring.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.log ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.log'''([''logger''], ''message'', ''in_chat'')&lt;br /&gt;
&lt;br /&gt;
Logs a message to the console. These messages are normally not visible unless Wesnoth is run from the command-line or (in Windows) with the --wconsole switch. The in_chat argument, however, can be set to true to also echo the message to the in-game chat area.&lt;br /&gt;
&lt;br /&gt;
''logger'' is the log level.&lt;br /&gt;
&lt;br /&gt;
In any context, ''logger'' can be the standard log levels of '''info''', '''debug''', '''warning''', or '''error'''. Various abbreviations of the standard four are also recognised. The default logger is '''info'''.&lt;br /&gt;
&lt;br /&gt;
In the game context, you can also set the ''logger'' to '''wml'''. The '''wml''' log level is special and is intended for WML errors; it always goes to chat, so the in_chat argument is ignored and can be omitted.&lt;br /&gt;
&lt;br /&gt;
The logdomain to enable these logs depends on the context. In the game context, they are written to the '''wml''' logdomain. In other contexts, the logdomain is '''scripting/lua/user'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.as_text ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|10}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.as_text'''(''value1'', ''value2'', ...)&lt;br /&gt;
&lt;br /&gt;
Accept one or more values as arguments and returns them as a string.  This is intended for use as an easy way to view the contents of lua tables.  Using the returned string for any other purpose is not supported.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}} This is now available in all contexts.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.simulate_combat ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.simulate_combat'''(''attacker'', [''attacker_weapon_index''], ''defender'', [''defender_weapon_index'']) &amp;amp;rarr; ''attacker stats evaluation'', ''defender stats evaluation'', ''attacker weapon evaluation'', ''defender weapon evaluation''&lt;br /&gt;
&lt;br /&gt;
Computes the hitpoint distribution and status chance after a combat between two units.  The first unit is the attacker. The attacker does not have to be on the map, but its location should be meaningful - that is, it can be a private-to-Lua clone of a unit with the '''x''' and '''y''' values changed, but whatever it is it has to have '''x''' and '''y''' values that allow attacking the defender (with '''max_range''' of the attack set appropriately it's possible to simulate attacking non-adjacent units). The second unit is the defender; it has to be on the map.&lt;br /&gt;
&lt;br /&gt;
Optional integers can be passed after each unit to select a particular weapon, otherwise the &amp;quot;best&amp;quot; one is selected.  When giving the weapon, the parameter is the weapon number (integer, starting at 1) and not the attack definition.&lt;br /&gt;
&lt;br /&gt;
The function returns four tables describing the evaluation of the combat. The first two contain an evaluation of the combatant's stats over the course of the fight, while the second two contains more detailed information on their weapons.&lt;br /&gt;
&lt;br /&gt;
The stats evaluation tables contain the following keys:&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''poisoned''' &amp;amp;rarr; ''probability''&lt;br /&gt;
* ''stats''.'''slowed''' &amp;amp;rarr; ''probability''&lt;br /&gt;
* ''stats''.'''untouched''' &amp;amp;rarr; ''probability''&lt;br /&gt;
&lt;br /&gt;
The probability that the unit will be poisoned or slowed, or that it will survive with no damage taken. (A scenario where the unit's hitpoints increase counts as untouched.)&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''average_hp''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The expected value of the unit's hitpoints after the fight.&lt;br /&gt;
&lt;br /&gt;
* ''stats''.'''hp_chance''' &amp;amp;rarr; ''mapping of hp to probability''&lt;br /&gt;
&lt;br /&gt;
The probability that the unit's hitpoints will be at a specific value after the fight. Though it looks almost like an array, it begins at index 0 unlike a typical Lua array. Thus, it's better understood as an associated mapping from the resulting hitpoints value to the probability of ending the combat with that value. Therefore, the value at index 0 represents the chance that the unit will die.&lt;br /&gt;
&lt;br /&gt;
The weapon evaluation tables contain the following keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Key !!Description&lt;br /&gt;
|-&lt;br /&gt;
|attack_num&lt;br /&gt;
| DEPRECATED (use '''number''').  Attack number (0 based, -1 for no attack).&lt;br /&gt;
|-&lt;br /&gt;
|chance_to_hit&lt;br /&gt;
|Effective chance to hit as a percentage (all factors accounted for). &lt;br /&gt;
|-&lt;br /&gt;
|damage&lt;br /&gt;
|Effective damage of the weapon (all factors accounted for).&lt;br /&gt;
|-&lt;br /&gt;
|drains&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|drains]] opponent when it hits.&lt;br /&gt;
|-&lt;br /&gt;
|drain_constant&lt;br /&gt;
|Base HP drained regardless of damage dealt.&lt;br /&gt;
|-&lt;br /&gt;
|drain_percent&lt;br /&gt;
|Percentage of damage recovered as health.&lt;br /&gt;
|-&lt;br /&gt;
|firststrike&lt;br /&gt;
|Attack has [[AbilitiesWML#The_.5Bspecials.5D_tag|firststrike]] special.&lt;br /&gt;
|-&lt;br /&gt;
|name&lt;br /&gt;
|Name (not description) of the attack.&lt;br /&gt;
|-&lt;br /&gt;
|number&lt;br /&gt;
|Attack number (1 based, 0 for no attack).&lt;br /&gt;
|-&lt;br /&gt;
|num_blows&lt;br /&gt;
|Effective number of blows (takes [[AbilitiesWML#The_.5Bspecials.5D_tag|swarm]] into account).&lt;br /&gt;
|-&lt;br /&gt;
|petrifies&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|petrifies]] opponent when it hits. &lt;br /&gt;
|-&lt;br /&gt;
|plagues&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|turns opponent into a zombie]] when fatal.&lt;br /&gt;
|-&lt;br /&gt;
|plague_type&lt;br /&gt;
|The [[AbilitiesWML#Extra_keys_used_by_the_.5Bplague.5D_special|plague type]] used by the attack, if any.&lt;br /&gt;
|-&lt;br /&gt;
|poisons&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|poisons]] opponent when it hits.&lt;br /&gt;
|-&lt;br /&gt;
|rounds&lt;br /&gt;
|[[AbilitiesWML#The_.5Bspecials.5D_tag|Berserk]] special can force us to fight more than one round.&lt;br /&gt;
|-&lt;br /&gt;
|slows&lt;br /&gt;
|Attack [[AbilitiesWML#The_.5Bspecials.5D_tag|slows]] opponent when it hits.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local function display_stats(n, t)&lt;br /&gt;
    wesnoth.interface.add_chat_message(string.format(&lt;br /&gt;
        &amp;quot;Chance for the %s\n  to be slowed: %f,\n  to be poisoned: %f,\n  to die: %f.\nAverage HP: %f.&amp;quot;,&lt;br /&gt;
        n, t.slowed, t.poisoned, t.hp_chance[0], t.average_hp))&lt;br /&gt;
end&lt;br /&gt;
local att_stats, def_stats = wesnoth.simulate_combat(att, att_weapon, def, def_weapon)&lt;br /&gt;
display_stats(&amp;quot;attacker&amp;quot;, att_stats)&lt;br /&gt;
display_stats(&amp;quot;defender&amp;quot;, def_stats)&lt;br /&gt;
&lt;br /&gt;
local att_stats, def_stats, att_weapon, def_weapon = wesnoth.simulate_combat(attacker, att_weapon_number, defender)&lt;br /&gt;
wesnoth.interface.add_chat_message(string.format(&lt;br /&gt;
    &amp;quot;The attack %s should be countered with %s, which does %d damage, has %d%% chance to hit and forces %d attack rounds due to its berserk ability.&amp;quot;,&lt;br /&gt;
    att_weapon.name, def_weapon.name or &amp;quot;no weapon&amp;quot;, def_weapon.damage, def_weapon.chance_to_hit, def_weapon.rounds))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.name_generator ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.name_generator'''('''&amp;quot;markov&amp;quot;''', ''definition'', [''chain_size'', [''max_length'']]) &amp;amp;rarr; ''generator function''&lt;br /&gt;
* '''wesnoth.name_generator'''('''&amp;quot;cfg&amp;quot;''', ''definition'') &amp;amp;rarr; ''generator function''&lt;br /&gt;
* ''generator function''() &amp;amp;rarr; ''random name''&lt;br /&gt;
&lt;br /&gt;
Constructs a name generator for use in generating names using either the Markov chain algorithm used in older versions of Wesnoth or the context-free grammar generator used since 1.13.5. The type parameter indicates which algorithm to use (either markov or cfg). The definition can be a string, just like it would be in a config file, or it can be formatted as a table. Additional parameters may be passed, depending on the type of generator. The function returns a callable userdata, which will return a new name each time it is called (with no parameters).&lt;br /&gt;
&lt;br /&gt;
* '''Markov chain''': A Markov chain generator works by analyzing a list of input names and noticing tendencies in the way the letters are strung together. It can then apply those tendencies to produce new similar names that were not in the original list. Longer lists give better results. The definition is a list of names, formatted either as a comma-separated string or as an array-like table. The Markov generator can take two additional parameters.&lt;br /&gt;
** ''chain_size'': A value greater than 1 for the ''chain_size'' causes the analyzer to consider the words in chunks, which is similar to analyzing them syllable by syllable instead of letter by letter. The default chain size is 2, meaning that the analyzer treats words as consisting of 2-character syllables.&lt;br /&gt;
** ''max_length'': Places a cap on the total length of the name. The default value is 12 characters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local markov_names = wesnoth.name_generator('markov', {'Kaasa', 'Kayya', 'Keyya', 'Kiira', 'Korra'}, 1)&lt;br /&gt;
print(markov_names(), markov_names(), markov_names())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''Context-free grammar''': A [[context-free grammar]] is a way of specifying how strings can be constructed. The definition may be specified as a multi-line string, just as described in the preceding link, or it can be formatted as a table where the keys are non-terminals and the values are what they expand to. The expansion of each non-terminal can be formatted either as a |-separated list as described in the preceding link, or as an array-like table. (Mixing the two forms is permissible too.) The context-free generator has no additional parameters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local cfg_names = wesnoth.name_generator('cfg', {&lt;br /&gt;
  main = {'{prefix}{suffix}', '{prefix}{centre}{suffix}'},&lt;br /&gt;
  prefix = 'Kaa|Ka|Ke|Kuu|Ko',&lt;br /&gt;
  suffix = 'sa|yya|ra|rra',&lt;br /&gt;
  centre = 'err|aash|eez|azz'&lt;br /&gt;
})&lt;br /&gt;
print(cfg_names(), cfg_names(), cfg_names())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': If you want to generate a name using any of the default generators, you can use the predefined generators in the [[LuaAPI/types#race|race]] instead of constructing one with this function.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.compile_formula ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.compile_formula'''(''formula'') &amp;amp;rarr; ''compiled formula''&lt;br /&gt;
&lt;br /&gt;
Compiles a [[Wesnoth Formula Language]] formula into a Lua callable userdata. A compiled formula can be converted back to valid code using the built-in &amp;lt;code&amp;gt;tostring&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.eval_formula ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.eval_formula'''(''formula'', [''variables'']) &amp;amp;rarr; ''result''&lt;br /&gt;
* ''compiled formula''([''variables'']) &amp;amp;rarr; ''result''&lt;br /&gt;
&lt;br /&gt;
Evaluate a [[Wesnoth Formula Language]] formula and return the result it computed (which can be '''nil''').&lt;br /&gt;
&lt;br /&gt;
The passed in variables can be an arbitrary Lua table, which defines variables available to the formula. Unlike with WML tables, there is no restriction on the format of this table. The formula can access the variables as a list using the special WFL variable '''__list''', or as a map using the special WFL variable '''__map'''. Directly accessing keys on the table is also possible.&lt;br /&gt;
&lt;br /&gt;
It is also possible to pass a unit proxy as the variables, which evaluates the formula in that unit's context just as if it had been used in a [[StandardUnitFilter]].&lt;br /&gt;
&lt;br /&gt;
When calling '''wesnoth.eval_formula''', the first argument may either be an already-compiled formula or a string, in which case it will be automatically compiled on the fly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local f = wesnoth.compile_formula('if(x &amp;gt; y, x - y, x + y)')&lt;br /&gt;
&lt;br /&gt;
print(f{x=1,y=2}) -- prints 3.0&lt;br /&gt;
print(f{x=1,y=3}) -- prints 4.0&lt;br /&gt;
print(f{x=2,y=3}) -- prints 5.0&lt;br /&gt;
print(f{x=1,y=1}) -- prints 2.0&lt;br /&gt;
print(f{x=3,y=1}) -- prints 2.0&lt;br /&gt;
print(f{x=3,y=2}) -- prints 1.0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.version ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.version'''(''version string'') &amp;amp;rarr; ''version''&lt;br /&gt;
* '''wesnoth.version'''(''major'', [''minor'', [''patch'']], [''suffix'')) &amp;amp;rarr; ''version''&lt;br /&gt;
&lt;br /&gt;
Creates a version object, either by parsing a string or by building it from its component parts. The resulting version object can be compared with other version objects using the standard Lua comparison operators, which follows the same rules as the [[PreprocessorRef#.23ifver_and_.23ifnver|#ifver]] preprocessor statement. It can also be decomposed by accessing the following keys on the object:&lt;br /&gt;
&lt;br /&gt;
* ''integer'': Grab any integer version component by index. A non-canonical version may have more than three components.&lt;br /&gt;
* '''major''': The major version number (index 1).&lt;br /&gt;
* '''minor''': The minor version number (index 2).&lt;br /&gt;
* '''revision''': The patch revision number (index 3).&lt;br /&gt;
* '''is_canonical''': True if the version has at most three components (plus an optional suffix).&lt;br /&gt;
* '''sep''': The character that separates the version components from the suffix (usually either + or nil).&lt;br /&gt;
* '''special''': The version suffix, for example the &amp;quot;dev&amp;quot; in &amp;quot;1.15.14+dev&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The version can be converted to a string using the built-in '''tostring''' function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local function version_is_sufficient(required)&lt;br /&gt;
  return wesnoth.current_version() &amp;gt;= required&lt;br /&gt;
end&lt;br /&gt;
local required = wesnoth.version &amp;quot;1.9.6&amp;quot;&lt;br /&gt;
if not version_is_sufficient(required) then&lt;br /&gt;
  gui.alert(string.format(&amp;quot;Your BfW version is insufficient, please get BfW %s or greater!&amp;quot;, tostring(required)))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.current_version ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.current_version'''() &amp;amp;rarr; ''current version''&lt;br /&gt;
&lt;br /&gt;
Returns the current version of Wesnoth as a version object.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.ms_since_init ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.ms_since_init'''() &amp;amp;rarr; ''milliseconds''&lt;br /&gt;
&lt;br /&gt;
This function returns the amount of milliseconds that have passed since Wesnoth started up the current session. Its only use is to track the passage of real time.&lt;br /&gt;
&lt;br /&gt;
'''WARNING:''' this function uses the same code as [set_variable] time=stamp, and so it is MP-unsafe. It is provided only for benchmark purposes and AI development, although it should work inside wesnoth.synchronize_choice() as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.deprecated_message ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.deprecated_message'''(''element_name'', ''level'', ''version'', ''detail_message'')&lt;br /&gt;
&lt;br /&gt;
Displays a deprecation warning in the Lua console. The level is an integer from 1 to 4 inclusive (see [[CompatibilityStandards#Deprecation_levels_-_When_to_remove_deprecated_features|deprecation levels]]), and the version can be left nil for levels 1 and 4. Otherwise it must be a version ''string'' (not a version object from [[#wesnoth.version|wesnoth.version]]).&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.deprecate_api ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.deprecate_api'''(''original_name'', ''new_name'', ''level'', ''version'', ''element'', ''detail_message'') &amp;amp;rarr; ''deprecated wrapper''&lt;br /&gt;
&lt;br /&gt;
Creates a deprecated wrapper for a function or table. A deprecated function will raise the deprecated message the first time it's called, and then suppress it thereafter. A deprecated table will raise the deprecated message the first time a key is read or assigned, and then suppress it thereafter.&lt;br /&gt;
&lt;br /&gt;
The ''element'' is the function or table to wrap. It can be the original function or the new function (which may happen if the function was renamed without any interface changes), or a wrapper function that calls the new function while providing the interface of the old function. The ''level'' and ''version'' are as in [[#wesnoth.deprecated_message|wesnoth.deprecated_message]].&lt;br /&gt;
&lt;br /&gt;
If ''level'' is 4, then the ''element'' is ignored (you can pass '''nil''') and a generic deprecated wrapper is returned that does nothing but raises the deprecated message the first time you call it, assign a key, or read a key, and suppresses it thereafter. This is intended for a function that was removed without deprecation, to leave behind a more informative message if someone still attempts to use it.&lt;br /&gt;
&lt;br /&gt;
If Wesnoth is run with the &amp;lt;tt&amp;gt;--strict-lua&amp;lt;/tt&amp;gt; command-line option, this function will return '''nil''' instead of the deprecated wrapper. Since the normal use-case of this function is to assign the deprecated wrapper to the original name, this has the effect of erasing any deprecated functions from the API.&lt;br /&gt;
&lt;br /&gt;
The result of this function always contains a '''__deprecated''' attribute set to true, which can allow identifying if something is deprecated.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.type ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.type'''(''value'') &amp;amp;rarr; ''type name''&lt;br /&gt;
&lt;br /&gt;
Returns a string describing the value's type. This is the same as the built-in type function, except that it returns a more specific string in the case of userdata or tables, based on the metatable. For example, it would return 'unit' if called on a unit.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.named_tuple ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.named_tuple'''(''array'', ''names'') &amp;amp;rarr; ''named tuple''&lt;br /&gt;
&lt;br /&gt;
Decorates a numeric based array so that the indices can be accessed by name instead of by index. This function is used internally for a number of things, most notably map locations and WML tags. Most end-users will not need to use it, but it could be useful if you wish to build a Lua API that returns locations (or similar data) in the engine-standard format.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local t = wesnoth.named_tuple({42,21,36}, {'x', 'y', 'z'})&lt;br /&gt;
&lt;br /&gt;
print(t[1]) -- prints 42&lt;br /&gt;
print(t[2]) -- prints 21&lt;br /&gt;
print(t[3]) -- prints 36&lt;br /&gt;
print(t.x) -- prints 42&lt;br /&gt;
print(t.y) -- prints 21&lt;br /&gt;
print(t.z) -- prints 36&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.get_language ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.get_language'''() &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
Gets the language the UI is currently set to. Note that this may return an empty string if using the system default language.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.print_attributes ===&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.print_attributes'''(''object'', [''function''])&lt;br /&gt;
&lt;br /&gt;
Prints out a list of attributes that can be accessed on the object, excluding deprecated functionality. The function defaults to '''print''', and receives a formatted line usually containing multiple attributes. They are annotated by type – &amp;amp;fnof; for a function, &amp;amp;dagger; for a table, ! if there was an error attempting to determine the type (which includes write-only attributes). Other types are unannotated.&lt;br /&gt;
&lt;br /&gt;
For tables, by default this iterates the table using '''pairs''' to discover the attributes available, walking the metatable hierarchy if there is an '''__index''' table and filtering out anything that contains a '''__deprecated''' attribute set to '''true'''. However, if finds a function as the '''__index''', and the table's metatable also has a member '''__dir''', it will be used instead. The '''__dir''' can either be an array of strings, or a function that returns an array of strings. It will automatically be sorted and have any duplicates filtered out.&lt;br /&gt;
&lt;br /&gt;
For custom objects defined by the engine, there is special handling so that this function shows the correct result. For example, if used on a GUI2 widget object, it will show the attributes available for that type of widget, as well as the IDs of any sub-widgets that can be accessed by name.&lt;br /&gt;
&lt;br /&gt;
In the Lua console only, this function can also be referenced by a shorter alias, '''dir'''.&lt;br /&gt;
&lt;br /&gt;
== Hooks ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.persistent_tags ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.persistent_tags'''.''action''.'''read''' &amp;amp;harr; '''function'''(''wml content'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.persistent_tags'''.''action''.'''write''' &amp;amp;harr; '''function'''(''add_tag_function'')&lt;br /&gt;
&lt;br /&gt;
This is an associative table defining tags that should be persisted in saved games. Each tag is itself a table containing two functions, read and write. The write function is called in &amp;lt;tt&amp;gt;on_load&amp;lt;/tt&amp;gt; and passed a function as a parameter which takes a WML table and adds it to the saved game under the specified tag; the read function is called once per matching tag found in the saved game, and is passed a WML table of its contents. Note the asymmetry here: if you're saving an array, the write function is responsible for saving the entire array (and is only called once), while the read function is only responsible for loading one item (and is called several times).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local inventory = {}&lt;br /&gt;
&lt;br /&gt;
function wesnoth.persistent_tags.inventory.read(cfg)&lt;br /&gt;
    inventory[cfg.side] = cfg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function wesnoth.persistent_tags.inventory.write(add)&lt;br /&gt;
    for i = 1, #wesnoth.sides do&lt;br /&gt;
        add(inventory[i])&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that you don't need to create &amp;lt;tt&amp;gt;wesnoth.persistent_tags.inventory&amp;lt;/tt&amp;gt; as an empty table first; you can simply define the read and write functions.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.wml_actions ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.wml_actions'''.''action'' &amp;amp;harr; '''function'''(''wml parameters table'')&lt;br /&gt;
&lt;br /&gt;
This is a hook table that exposes and defines WML actions. Each function in this table corresponds to a single ActionWML tag, allowing you to invoke tags, define custom tags, and even modify the behavior of built-in tags. The single argument to these functions is a WML table, the content of the tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_actions.freeze_unit(cfg)&lt;br /&gt;
    local unit_id = cfg.id or wml.error &amp;quot;[freeze_unit] expects an id= attribute.&amp;quot;&lt;br /&gt;
    local unit = wesnoth.units.get(unit_id)&lt;br /&gt;
    if unit then unit.moves = 0 end&lt;br /&gt;
    wesnoth.units.modify({ id = unit_id }, { moves = 0 })&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The new tag can now be used in plain WML code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[freeze_unit]&lt;br /&gt;
    id=Delfador&lt;br /&gt;
[/freeze_unit]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can override functions already assigned to the table. This is useful if you need to extend functionality of core tags. For instance, the following script overrides the [[InterfaceActionsWML#Other interface tags|[print]]] tag so that messages are displayed with a bigger font.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_actions.print(cfg)&lt;br /&gt;
    local modified_cfg = setmetatable({}, {__index = cfg})&lt;br /&gt;
    modified_cfg.size = (cfg.size or 12) + 10&lt;br /&gt;
    wesnoth.wml_actions.print(modified_cfg)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An action handler should be able to handle being called with either a WML table or a WML vconfig userdata. It is recommended to pass the argument through ''wml.tovconfig'' before doing anything with it, both in the action's definition and when calling it directly (in case its definition did not do that). The engine always passes a vconfig when calling a WML action.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.wml_conditionals ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.wml_conditionals'''.''action'' &amp;amp;harr; '''function'''(''wml parameters table'') &amp;amp;rarr; ''boolean result''&lt;br /&gt;
&lt;br /&gt;
This is a hook table like wesnoth.wml_actions. You can use it to define new ConditionalWML tags that will be recognized in WML when using [if], [show_if], [while], etc., or more generally when [[../wml#wml.eval_conditional|'''wml.eval_conditional''']] is run.&lt;br /&gt;
&lt;br /&gt;
Use it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function wesnoth.wml_conditionals.foo(cfg)&lt;br /&gt;
    local bar = cfg.bar or wml.error(&amp;quot;[foo] tag did not have 'bar' attribute&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    return (bar == &amp;quot;baz&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this lua code is executed, it would make the following syntax be valid WML in your add-on:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[if]&lt;br /&gt;
   [foo]&lt;br /&gt;
      bar = $X&lt;br /&gt;
   [/foo]&lt;br /&gt;
   [then]&lt;br /&gt;
      [message]&lt;br /&gt;
         # ...&lt;br /&gt;
      [/message]&lt;br /&gt;
   [/then]&lt;br /&gt;
[/if]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the basic logic tags of ConditionalWML (true, false, and, or, not) do not pass through this table and cannot be overridden.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.effects ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name'' &amp;amp;harr; '''function'''(''unit'', ''wml table'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name''.'''__descr''' &amp;amp;harr; ''description''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.effects'''.''name''.'''__descr''' &amp;amp;harr; '''function'''(''unit'', ''wml table'') &amp;amp;rarr; ''description''&lt;br /&gt;
&lt;br /&gt;
This table contains the implementation of [[EffectWML|[effect]]]s. Each value is a callable value that takes a unit and the effect config. It can be a function or a callable table. If it is a callable table, its metatable may have a '''__descr''' field which is either a string or a function. Built-in effects are present in this table, and you may register your own custom effects too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
function wesnoth.effects.min_resistance(u, cfg)&lt;br /&gt;
	local resistance_new = {}&lt;br /&gt;
	local resistance_old = wml.parsed(wml.get_child(cfg, &amp;quot;resistance&amp;quot;))&lt;br /&gt;
	for k,v in pairs(resistance_old) do&lt;br /&gt;
		if type(k) == &amp;quot;string&amp;quot; and type(v) == &amp;quot;number&amp;quot; and u:resistance_to(k) &amp;gt;= v then&lt;br /&gt;
			resistance_new[k] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	wesnoth.effects.resistance(u, {&lt;br /&gt;
		apply_to = &amp;quot;resistance&amp;quot;,&lt;br /&gt;
		replace = true,&lt;br /&gt;
		T.resistance (resistance_new),&lt;br /&gt;
	})&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code above adds a new &amp;lt;code&amp;gt;min_resistance&amp;lt;/code&amp;gt; effect that will set the resistances to specific values if they are currently below that value. It can then be used like this (for example, in [[DirectActionsWML#.5Bobject.5D|[object]]]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[effect]&lt;br /&gt;
  apply_to=min_resistance&lt;br /&gt;
  [resistance]&lt;br /&gt;
    cold=50&lt;br /&gt;
  [/resistance]&lt;br /&gt;
[/effect]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in order work properly, effects must be registered before any units are created. This means it must be placed into a global or scenario level [lua] tag. In particular, the preload event is too late.&lt;br /&gt;
&lt;br /&gt;
You can also specify description modifiers, which will be used if a custom effect is placed in a &amp;lt;code&amp;gt;[trait]&amp;lt;/code&amp;gt; tag. Instead of setting a function as the effect, you set a table with a &amp;lt;code&amp;gt;__call&amp;lt;/code&amp;gt; metafunction which does what the function would have done. The table can then have an additional &amp;lt;code&amp;gt;__descr&amp;lt;/code&amp;gt; metafunction which updates descriptions as necessary. The built-in effects all use this structure. This metafunction takes the same arguments as the regular effect function, but should not modify the unit. Instead, it returns a string to be appended to the trait's effect description.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.micro_ais ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.micro_ais'''.''ai_name'' &amp;amp;harr; ''function''(''cfg'') &amp;amp;rarr; ''required'', ''optional'', ''ca_params''&lt;br /&gt;
&lt;br /&gt;
Registers a new [[Micro_AIs#Custom_Micro_AIs|MicroAI]] with '''ai_type'''=''ai_name''. The function will be called by the [micro_ai] tag to set up the AI. See the link for more details on how this works.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.custom_synced_commands ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.custom_synced_commands'''.''command_name'' &amp;amp;harr; ''function''(''cfg'')&lt;br /&gt;
&lt;br /&gt;
Registers a custom synced command, which can be invoked by AI to enable unusual behaviour. The command can do basically anything, and is guaranteed to run on all clients. The WML table passed to the callback is the same table passed to [[LuaAPI/wesnoth/sync#wesnoth.sync.invoke_command|wesnoth.sync.invoke_command]].&lt;br /&gt;
&lt;br /&gt;
== Data ==&lt;br /&gt;
&lt;br /&gt;
Access to most of the game data is available via various tables in the &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.colors ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|4}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.colors'''.''color_name'' &amp;amp;rarr; ''color info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[GameConfigWML#Color_Palettes|color ranges]]. This can be used to translate the color name available from '''wesnoth.sides[n].color''' to RGB values.&lt;br /&gt;
&lt;br /&gt;
Each color info table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''mid''' - average shade for recoloring with the team color&lt;br /&gt;
* '''min''' - minimum shade for recoloring with the team color (this is likely to be black)&lt;br /&gt;
* '''max''' - maximum shade for recoloring with the team color (this is likely to be almost white)&lt;br /&gt;
* '''minimap''' - representative color to use on the mini-map&lt;br /&gt;
* '''pango_color''' - {{DevFeature1.15|13}} a hex string such as '''#ff0000''' suitable for use in formatted text&lt;br /&gt;
&lt;br /&gt;
Each of '''mid''', '''min''', '''max''' and '''minimap''' have the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''r''' - red component of that color&lt;br /&gt;
* '''g''' - green component of that color&lt;br /&gt;
* '''b''' - blue component of that color&lt;br /&gt;
* '''a''' - alpha component of that color (probably fully opaque)&lt;br /&gt;
&lt;br /&gt;
Reference usage in mainline: see data/multiplayer/eras.lua&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.current ===&lt;br /&gt;
&lt;br /&gt;
Contains various information about the current game and event state.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.side''' &amp;amp;rarr; ''side number''&lt;br /&gt;
&lt;br /&gt;
The number of the currently active side.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.turn''' &amp;amp;rarr; ''turn number''&lt;br /&gt;
&lt;br /&gt;
The current turn number.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.synced_state''' &amp;amp;rarr; ''state''&lt;br /&gt;
&lt;br /&gt;
Allows you to determine whether the current code runs in a synced context. Returns one of the following strings:&lt;br /&gt;
&lt;br /&gt;
:* '''synced''' - The current code runs on all mp clients. This is the normal context, in which all gamestate changing actions should take place.&lt;br /&gt;
:* '''unsynced''' - The current code runs only on the local machine, so changing the gamestate here will cause out-of-sync errors. For example, during '''select''' events or during the calculation of a [[LuaAPI/wesnoth/interface#wesnoth.interface.game_display|game_display]] hook. Typical things to do here are UI related things, or entering the synced state via '''[do_command]'''.&lt;br /&gt;
:* '''local_choice''' - The current code was invoked by [[#wesnoth.synchronize_choice|synchronize_choice]] and runs only on one local client to calculate the return value for the choice. You cannot enter the synced context with '''[do_command]''' now.&lt;br /&gt;
:* '''preload''' - We are currently running a preload event or an even earlier event. This behaves similar to '''local_choice'''.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.user_can_invoke_commands''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Indicates whether the player is currently able to take actions in the game.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.map''' &amp;amp;rarr; ''map userdata''&lt;br /&gt;
&lt;br /&gt;
The current active game map. See [[LuaAPI/types/map]] and [[LuaAPI/wesnoth/map]] for information on how this data can be used.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.schedule''' &amp;amp;rarr; ''schedule userdata''&lt;br /&gt;
&lt;br /&gt;
The current global time schedule. This is a special object with the following properties:&lt;br /&gt;
&lt;br /&gt;
:* #''schedule''&lt;br /&gt;
:The Lua length operator will return the number of turns in the schedule.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''[''index''] &amp;amp;harr; ''time of day info''&lt;br /&gt;
:Get the information for a particular time of day, or replace it with new info.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''.'''time_of_day''' &amp;amp;harr; ''id''&lt;br /&gt;
:Get the ID of the current active time of day, or switch to a new one. If the time of day occurs more than once in the schedule, the time will be set to the first occurrence.&lt;br /&gt;
&lt;br /&gt;
:* ''schedule''.'''liminal_bonus''' &amp;amp;harr; ''bonus''&lt;br /&gt;
:Get the maximum bonus for liminal units in the current schedule. You can also override the default by assigning a different value, or revert to the default by assigning nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.current.event_context''' &amp;amp;rarr; ''WML table''&lt;br /&gt;
&lt;br /&gt;
Contains information on the current active event. Returns a table with the following keys:&lt;br /&gt;
&lt;br /&gt;
:* '''name''' - The event name. This is the actual event that fired, not the name in the [event] tag, so it never contains commas or variables.&lt;br /&gt;
:* '''id''' - The event's unique ID, if it has one.&lt;br /&gt;
:* '''weapon''' - The first weapon relevant to the event, if any.&lt;br /&gt;
:* '''second_weapon''' - The second weapon relevant to the event, if any.&lt;br /&gt;
:* '''damage_inflicted''' - The damage inflicted in the event, if applicable.&lt;br /&gt;
:* '''x1''', '''y1''' - The first location relevant to the event, if any.&lt;br /&gt;
:* '''x2''', '''y2''' - The second location relevant to the event, if any.&lt;br /&gt;
:* '''unit_x''', '''unit_y''' - The location of the first unit relevant to the event, if any. This is the same as '''x1''', '''y1''' in most cases. Currently the only exceptions are enter and exit hex events.&lt;br /&gt;
:* '''data''' - {{DevFeature1.17|6}} The event data. Can contain anything at all if the event was fired by [[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire|wesnoth.game_events.fire]]. In a village capture event, '''owner_side''' will contain the former owner of the village.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_config ===&lt;br /&gt;
&lt;br /&gt;
Contains static global information about the game. Some of this information can also be modified on the fly, but only in the game context, not in the plugin or map generator context.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.base_income''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.village_income''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.village_support''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.poison_amount''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.rest_heal_amount''' &amp;amp;harr; ''integer'&lt;br /&gt;
* '''wesnoth.game_config.recall_cost''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.combat_experience''' &amp;amp;harr; ''integer''&lt;br /&gt;
* '''wesnoth.game_config.kill_experience''' &amp;amp;harr; ''integer''&lt;br /&gt;
&lt;br /&gt;
Values of various game settings.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.global_traits'''[''trait id''] &amp;amp;rarr;&lt;br /&gt;
&lt;br /&gt;
A table with named fields (trait id strings) holding the wml tables defining the traits. This contains all global traits the engine knows about, but race-specific traits are not included. The known fields and subtags of each element are the ones which were given in the wml definition of the [[SingleUnitWML|trait]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
print(wesnoth.game_config.global_traits.strong.male_name)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_config.do_healing''' &amp;amp;harr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether healing will occur at the beginning of each side's turn.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_config.theme''' &amp;amp;harr; ''theme id''&lt;br /&gt;
&lt;br /&gt;
The currently active in-game theme.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.debug''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether debug mode is currently active. Debug mode is activated by the --debug command-line parameter or the :debug in-game command.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.debug_lua''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether Lua debug is enabled. Lua debug is activated by the --debug-lua command-line parameter. This does not seem to do anything by default.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.mp_debug''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether MP debug is enabled. MP debug is activated in the same way as debug mode, but is only active in multiplayer games.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.game_config.strict_lua''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether strict Lua mode is enabled. Strict Lua mode is activated by the --strict-lua command-line parameter and causes all deprecated Lua APIs to be completely removed from the engine.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.palettes'''.''palette'' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the color palette with the given name, as defined by a '''[color_palette]''' tag in the [[GameConfigWML#Color_Palettes|game config]].&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.red_green_scale''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for health bars.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.red_green_scale_text''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for health numbers.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.blue_white_scale''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for experience bars.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} '''wesnoth.game_config.blue_white_scale_text''' &amp;amp;rarr; ''list of colors''&lt;br /&gt;
&lt;br /&gt;
Returns the gradient used for experience numbers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.races ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.races'''.''id'' &amp;amp;rarr; ''race info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[UnitsWML#.5Brace.5D|races]]. Returns a [[LuaAPI/types#Race|race userdata]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.scenario ===&lt;br /&gt;
&lt;br /&gt;
Contains information about the current scenario&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.turns''' &amp;amp;harr; ''turn limit''&lt;br /&gt;
&lt;br /&gt;
The current turn limit of the scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.next''' &amp;amp;harr; ''scenario id''&lt;br /&gt;
&lt;br /&gt;
The ID of the scenario to transition to when this scenario ends.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.id''' &amp;amp;rarr; ''scenario id''&lt;br /&gt;
&lt;br /&gt;
The ID of the current scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.name''' &amp;amp;rarr; &lt;br /&gt;
&lt;br /&gt;
The name of the current scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.defeat_music''' &amp;amp;harr; ''list of music tracks''&lt;br /&gt;
&lt;br /&gt;
The music to play if you lose this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.victory_music''' &amp;amp;harr; ''list of music tracks''&lt;br /&gt;
&lt;br /&gt;
The music to play if you win this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.show_credits''' &amp;amp;harr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether credits should be shown when this scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.end_text''' &amp;amp;harr; ''text''&lt;br /&gt;
&lt;br /&gt;
The end text to show when the scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.end_text_duration''' &amp;amp;harr; ''duration''&lt;br /&gt;
&lt;br /&gt;
How long to show the end text for when the scenario ends. Only relevant if '''wesnoth.scenario.next''' is nil.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.difficulty''' &amp;amp;rarr; ''difficult''&lt;br /&gt;
&lt;br /&gt;
The difficulty level this scenario is being played on.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.type''' &amp;amp;rarr; ''tag name''&lt;br /&gt;
&lt;br /&gt;
The type of this scenario. One of the strings '''scenario''', '''multiplayer''', or '''test'''.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.era''' &amp;amp;rarr; ''era tag''&lt;br /&gt;
&lt;br /&gt;
The [era] tag active in this scenario. Accessing this will throw an error in single-player games. This exists only for players which have the era installed, so for an era with ''require_era=yes'' it is safe to use.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.campaign''' &amp;amp;rarr; ''campaign tag''&lt;br /&gt;
&lt;br /&gt;
The [campaign] tag active in this scenario. Accessing this will throw an error in multiplayer or test games, so be sure to check '''wesnoth.scenario.type''' first in generic code.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.resources''' &amp;amp;rarr; ''list of resource tags''&lt;br /&gt;
&lt;br /&gt;
A list of [resource] tags active in this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.modifications''' &amp;amp;rarr; ''list of modification tags''&lt;br /&gt;
&lt;br /&gt;
A list of [modification] tags active in this scenario.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.scenario.mp_settings''' &amp;amp;rarr; ''table''&lt;br /&gt;
&lt;br /&gt;
In a multiplayer game, this is a proxy table which gives read only access to all MP-only configuration options which appear as attributes of [multiplayer] tag in a save game file. This allows accessing basically everything that can be set in the create game screen. The following keys exist in the returned table:&lt;br /&gt;
&lt;br /&gt;
* '''active_mods''' - A list of all active modification IDs&lt;br /&gt;
* '''hash''' - A hash of mp data&lt;br /&gt;
* '''mp_campaign''' - Name of mp campaign&lt;br /&gt;
* '''mp_scenario''' - ID of this mp scenario&lt;br /&gt;
* '''mp_scenario_name''' - Name of this mp scenario&lt;br /&gt;
* '''scenario''' - MP lobby title &lt;br /&gt;
* '''difficulty_define''' - The campaign difficulty string for an mp campaign&lt;br /&gt;
* '''mp_village_gold'''&lt;br /&gt;
* '''mp_village_support'''&lt;br /&gt;
* '''mp_num_turns'''&lt;br /&gt;
* '''mp_era''' - The id of the chosen era&lt;br /&gt;
* '''mp_eras''' - A list of all era ids&lt;br /&gt;
* '''mp_fog'''&lt;br /&gt;
* '''mp_shroud'''&lt;br /&gt;
* '''mp_random_start_time'''&lt;br /&gt;
* '''experience_modifier'''&lt;br /&gt;
* '''mp_use_map_settings'''&lt;br /&gt;
* '''mp_countdown''' - Whether the timer is enabled&lt;br /&gt;
* '''mp_countdown_action_bonus'''&lt;br /&gt;
* '''mp_countdown_init_time''' &lt;br /&gt;
* '''mp_countdown_reservoir_time'''&lt;br /&gt;
* '''mp_countdown_turn_bonus'''&lt;br /&gt;
* '''observer'''&lt;br /&gt;
* '''shuffle_sides'''&lt;br /&gt;
* '''savegame''' - Whether this is a reloaded game&lt;br /&gt;
* '''side_users''' - List of how sides are assigned to users (at game start)&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.terrain_types ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|12}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.terrain_types'''[''code''] &amp;amp;rarr; ''terrain info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[TerrainWML|terrain types]] by their terrain code. Returns a table with the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''id'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''editor_name'''&lt;br /&gt;
* '''description'''&lt;br /&gt;
* '''icon'''&lt;br /&gt;
* '''editor_image'''&lt;br /&gt;
* '''light'''&lt;br /&gt;
* '''village'''&lt;br /&gt;
* '''castle'''&lt;br /&gt;
* '''keep'''&lt;br /&gt;
* '''healing'''&lt;br /&gt;
* '''mvt_alias''' {{DevFeature1.19|10}}&lt;br /&gt;
* '''def_alias''' {{DevFeature1.19|10}}&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.unit_types ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.unit_types'''[''id''] &amp;amp;rarr; ''unit type info''&lt;br /&gt;
&lt;br /&gt;
Access defined [[UnitTypeWML|unit types]] by their ID. Returns a [[LuaAPI/types#Unit_Type|unit type userdata]].&lt;br /&gt;
&lt;br /&gt;
== Submodules ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module also contains a number of submodules for working with particular aspects of the game.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.audio ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/audio|submodule]] containing functions for playing music and sound effects.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.achievements ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/achievements|submodule]] containing functions for working with in-game achievements.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events ===&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/game_events|submodule]] containing functions for working with event handlers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.map ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|11}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/map|submodule]] containing functions for querying and manipulating the game map.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/interface|submodule]] containing functions pertaining to the in-game UI.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.paths ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/paths|submodule]] containing functions related to pathfinding.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.schedule ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|14}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/schedule|submodule]] containing functions to manipulate the time of day schedule.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/sides|submodule]] containing functions for manipulating the sides of a scenario.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sync ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|14}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/sync|submodule]] containing functions to deal with multiplayer synchronization.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
A [[LuaAPI/wesnoth/units|submodule]] containing functions to manipulate units on the map.&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference]]&lt;br /&gt;
&lt;br /&gt;
== Unsupported Functions ==&lt;br /&gt;
&lt;br /&gt;
The following functions exist in the '''wesnoth''' module but are not intended to be used:&lt;br /&gt;
&lt;br /&gt;
* wesnoth.allow_undo&lt;br /&gt;
* wesnoth.cancel_action&lt;br /&gt;
* wesnoth.clear_menu_item&lt;br /&gt;
* wesnoth.set_menu_item&lt;br /&gt;
* wesnoth.kernel_type&lt;br /&gt;
* wesnoth.log_replay&lt;br /&gt;
* wesnoth.print&lt;br /&gt;
* wesnoth.redraw&lt;br /&gt;
* wesnoth.add_known_unit&lt;br /&gt;
* wesnoth.get_era&lt;br /&gt;
* wesnoth.get_resource&lt;br /&gt;
&lt;br /&gt;
Some of these have WML equivalents, so if you need the functionality you should call the WML action directly (via [[#wesnoth.wml_actions|wml_actions]] or [[LuaAPI/wml#wml.fire|wml.fire]]). Others are internal functionality used in core Lua scripts, which are not intended for general use. These functions ''may'' be removed or changed without warning or going through a deprecation cycle.&lt;br /&gt;
&lt;br /&gt;
Examination of the '''wesnoth''' module will also reveal two additional subtables - the '''package''' table, which is where packages loaded by [[#wesnoth.require|wesnoth.require]] persist (meaning you can force '''wesnoth.require''' to reload a file by nulling out its entry in this table), and the '''experimental''' module, which contains functions that are available for use but without warranty - they may change without warning or going through a deprecation cycle. Use of both of these tables is unsupported.&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74221</id>
		<title>UnitsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74221"/>
		<updated>2025-03-20T11:32:13Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [terrain_defaults] */ 9676&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
The '''[units]''' tag is a [[ReferenceWML#WML_toplevel_tags|top-level WML tag]] which defines the unit types that will be available in the game.&lt;br /&gt;
&lt;br /&gt;
A '''[units]''' tag primarily contains [[UnitTypeWML|[unit_type]]] tags, each of which defines one unit type, and can also contain other tags, which mostly provide definitions of things like races and movement types that are used in unit type definitions.&lt;br /&gt;
&lt;br /&gt;
== Subtags of [units] ==&lt;br /&gt;
&lt;br /&gt;
The following tags can be used as subtags of a '''[units]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== [unit_type] ===&lt;br /&gt;
&lt;br /&gt;
{{Main|UnitTypeWML}}&lt;br /&gt;
&lt;br /&gt;
In a '''[units]''' tag, a '''[unit_type]''' tag defines a unit type.&lt;br /&gt;
&lt;br /&gt;
=== [trait] ===&lt;br /&gt;
&lt;br /&gt;
The '''[trait]''' tag describes a trait. When it appears in the '''[units]''' toplevel, it describes a global trait, and all races with the attribute '''ignore_global_traits=no''' will have this trait.; it may also appear in other places.&lt;br /&gt;
* '''id''': unique identifier; needed for random trait generation to work properly&lt;br /&gt;
* '''availability''': describes whether a trait is &amp;quot;musthave&amp;quot; for a race/unit type or is available to &amp;quot;any&amp;quot; unit, including leaders. The default is for a trait to only be available to nonleaders. Currently &amp;quot;any&amp;quot; should not be used for traits available in multiplayer. It can be used for campaign specific traits.&lt;br /&gt;
* '''male_name''': text displayed in the status of unit with the trait if the unit is male.&lt;br /&gt;
* '''female_name''': text displayed in the status of unit with the trait if the unit is female.&lt;br /&gt;
* '''name''': text displayed in the status of unit with the trait if none of the two above is used.&lt;br /&gt;
* '''description''': text displayed for the description of the trait when moving the cursor over the trait.&lt;br /&gt;
* '''help_text''': {{DevFeature1.13|6}} text displayed for the description of the trait in the help. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''[effect]''': described in [[EffectWML]]. More than one of these can be used.&lt;br /&gt;
* '''require_traits''': {{DevFeature1.17|13}} An optional comma-separated list of trait id keys that represent traits that are required by this one. Order is not important. If the unit not already has all of the traits that appear in this list, then this trait will not be generated for this unit.&lt;br /&gt;
* '''exclude_traits''': {{DevFeature1.17|13}} An optional comma-separated list of trait id keys that represent traits that are mutually exclusive to this one. Order is not important. If the unit already has any of the traits that appear once in this list, then this trait will not be generated for this unit. Of course, for this to really make two traits mutually exclusive, you need to add exclude_traits to both trait definitions.&lt;br /&gt;
&lt;br /&gt;
=== [movetype] ===&lt;br /&gt;
&lt;br /&gt;
The '''[movetype]''' tag is used to make shortcuts to describe units with similar terrain handicaps. Units from the same advancement tree should generally have the same movetype.&lt;br /&gt;
* '''name''': an ID for this movetype. Units with the attribute '''movement_type=''name''''' will be assigned this movetype.&lt;br /&gt;
* '''flies''' or {{DevFeature1.15|0}} '''flying''': either 'yes' or 'no' (default). A unit with ''flying=yes'' does not have its image's height adjusted for different terrains.&lt;br /&gt;
** This key corresponds to [unit]'s '''flying''' key.&lt;br /&gt;
** In Wesnoth 1.12 and 1.14, the value of '''flying''' sometimes overrides the value of '''flies''', but in other times '''flying''' is ignored&lt;br /&gt;
** {{DevFeature1.15|0}} '''flying''' always overrides the '''flies''' value, with the intention that '''flies''' will be deprecated.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|14}} note=Translatable string, which can be set if there’s something special about this movetype. It will be displayed in the unit's help page. For typical movetypes this is not set. An example are horses with the ''mounted'' movetype. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* {{anchor|resistance|'''[resistance]'''}}: describes how much damage the unit takes from different types of attacks. The attribute '''''type''=''resistance''''' makes the unit receive ''resistance'' percent of damage, or resist '''100-resistance''' percent of damage from attacks with '''type=''type'''''. So for example, a resistance of fire=110 means, this unit will receive 110% of damage, or have a resistance of -10% as displayed in-game. A value of fire=0 would mean, the unit receives no damage and therefore has a resistance of 100%.&amp;lt;br&amp;gt; The available attack types in mainline are blade, pierce, impact, fire, cold, and arcane.&lt;br /&gt;
* {{anchor|movement_costs|'''[movement_costs]'''}}: describes how fast the unit moves on different terrains. The attribute '''''terrain''=''cost''''' means that the unit will need to use ''cost'' move points to move onto that ''terrain''.&lt;br /&gt;
* {{anchor|vision_costs|'''[vision_costs]'''}}: describes how far the unit clears fog and shroud on different terrains. The attribute '''''terrain''=''cost''''' means that the unit will need to use ''cost'' vision points to view into that ''terrain''. (If not specified for a particular terrain, the vision cost defaults to the movement cost.)&lt;br /&gt;
* {{anchor|jamming_costs|'''[jamming_costs]'''}}: {{DevFeature1.13|0}} describes how far the unit interferes with the vision of other units over different terrains. This works the same as movement and vision costs. [https://forums.wesnoth.org/viewtopic.php?f=21&amp;amp;t=44577&amp;amp;p=644985#p644985 Example of jamming]&lt;br /&gt;
* {{anchor|defense|'''[defense]'''}}: describes how likely the unit is to be hit on different terrains. The attribute '''''terrain''=''defense''''' means that the unit will be hit ''defense'' percent of the time in that ''terrain''. If the defense value is negative, then that specifies an upper limit. The number in absolute terms is then also the best defense that the unit may have if there is more than one terrain type involved. For example '''forest=-70''' common for mounted units means the unit cannot get more than 30% defense on forest terrain. Regardless what other terrain the forest is on.&lt;br /&gt;
&lt;br /&gt;
The available keys for the '''[movement_costs]''', '''[vision_costs]''', '''[jamming_costs]''' and '''[defense]''' tags are the '''id'''s of archetype terrains (those not aliased to any other terrain, see [[TerrainWML]]).&amp;lt;br&amp;gt;&lt;br /&gt;
In mainline that encompasses deep_water, shallow_water, reef, swamp_water, flat, sand, forest, hills, mountains, village, castle, cave, frozen, unwalkable, fungus, and impassable.&lt;br /&gt;
&lt;br /&gt;
=== [race] ===&lt;br /&gt;
&lt;br /&gt;
The '''[race]''' tag is used to make shortcuts to describe units with similar names. Units from the same advancement tree should generally have the same race. Also, units with the same race should generally be recruitable by the same sides/factions. 'id' and 'plural_name' and ('name' or ('male_name' and 'female_name')) '''must''' be supplied.&lt;br /&gt;
* '''id''': ID for this race. Units with the attribute '''race=''id''''' will be assigned this race. In older versions of WML, the value of the name key was used as id if the id field was missing, but this is no longer the case.&lt;br /&gt;
* '''plural_name''': user-visible name for its people (e.g. &amp;quot;Merfolk&amp;quot; or &amp;quot;Elves&amp;quot;). Currently only used in the in-game help.&lt;br /&gt;
* '''male_name''': user-visible name for the race of the male units (e.g. &amp;quot;Merman&amp;quot;). Currently only used in the in-game unit status.&lt;br /&gt;
* '''female_name''': user-visible name for the race of the female units (e.g. &amp;quot;Mermaid&amp;quot;). Currently only used in the in-game unit status.&lt;br /&gt;
* '''name''': the default value for the three keys above. The 'name' key is the default for 'male_name' and 'female_name'.&lt;br /&gt;
* '''description''': text used in the in-game help.&lt;br /&gt;
* '''help_taxonomy''': {{DevFeature1.15|5}} in the help browser, show this race as a group of units from another race; the value of this attribute should be the other race's '''id''' attribute. This only affects the help browser, for all other purposes (such as WML filters) the two races are completely separate. (How this is visualised in the help browser is a GUI design decision, this attribute merely tells the engine that the relationship exists.)&lt;br /&gt;
* '''name_generator''' {{DevFeature1.13|5}}: [[Context-free grammar]] describing unit names, if absent or invalid, falls back to male_names or female_names&lt;br /&gt;
* '''male_name_generator''' {{DevFeature1.13|5}}: Like name_generator, but specific for male names&lt;br /&gt;
* '''female_name_generator''' {{DevFeature1.13|5}}: Like name_generator, but specific for female names&lt;br /&gt;
* '''male_names''', '''female_names''': lists of names (i.e. non-translatable strings). They are inputted into the Markov name generator to generate random names. ''male_names'' describes units with '''gender=male'''; ''female_names'' describes units with '''gender=female'''.&lt;br /&gt;
* '''markov_chain_size''': (default 2) number of letters per &amp;quot;syllable&amp;quot;. &amp;quot;Syllables&amp;quot; are groupings of names that the Markov name generator uses to determine names. It does this by running a probability algorithm to guess from the name list which syllables fit well together, which can start or end a name, etc.&lt;br /&gt;
* '''num_traits''': is the number of non-repeating traits each unit of this race can be assigned.&lt;br /&gt;
* '''ignore_global_traits''': 'yes' or 'no' (default). Determines whether global traits (see [traits] above) are applied.&lt;br /&gt;
* '''undead_variation''': sets the default undead variation for members of this race.&lt;br /&gt;
* '''[topic]''': describes extra help topics for this race.&lt;br /&gt;
* '''[trait]''': describes a trait for this race. See above for syntax.&lt;br /&gt;
&lt;br /&gt;
=== [resistance_defaults] ===&lt;br /&gt;
&lt;br /&gt;
Note: broken in 1.14.8, fixed in 1.14.16 and 1.15.9 ([https://github.com/wesnoth/wesnoth/issues/5308 issue #5308])&lt;br /&gt;
&lt;br /&gt;
The '''[resistance_defaults]''' tag allows you to add resistance for custom damage types to already-defined movetypes (such as core movetypes).&lt;br /&gt;
* '''id''': The damage type you want to apply resistance defaults for.&lt;br /&gt;
* '''default''': The default resistance for all movetypes. You can set it to a number, or to a [[Wesnoth Formula Language|formula]] (enclosed in parentheses, but with no preceding dollar sign &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; or whitespace) which can reference any of the default resistance types - arcane, fire, etc. A common usage for formulas might be to set it to be equal to another resistance, eg '''default=&amp;quot;(impact)&amp;quot;'''.&lt;br /&gt;
* Other keys reference the '''name=''' attribute of a defined movetype. For example, 'smallfoot=50' will set the resistance to 50 for the smallfoot movement type. Formulas can also be used here, for example 'smallfoot=(impact)'.&lt;br /&gt;
&lt;br /&gt;
''Note:'' The '''default=''' key and other keys are handled slightly differently. A '''default=''' value will never override an explicitly specified value either in the same '''[resistance_defaults]''' tag or in a '''[movetype]''' definition, but other keys always take priority over values specified in a '''[movetype]''' definition.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|9}} The formulas can now access other parts of the movetype, for example &amp;quot;(resistance.arcane)&amp;quot; or &amp;quot;(movement_costs.flat)&amp;quot;. For [resistance_defaults], &amp;quot;(arcane)&amp;quot; is shorthand for, and equivalent to, &amp;quot;(resistance.arcane)&amp;quot;. See the documentation in the [terrain_defaults] section for more details about this.&lt;br /&gt;
&lt;br /&gt;
=== [terrain_defaults] ===&lt;br /&gt;
&lt;br /&gt;
Note: broken in 1.14.8, fixed in 1.14.16 and 1.15.11 ([https://github.com/wesnoth/wesnoth/issues/5308 issue #5308])&lt;br /&gt;
&lt;br /&gt;
The '''[terrain_defaults]''' tag allows you to add costs and defenses for custom terrain types to already-defined movetypes (such as core movetypes).&lt;br /&gt;
* '''id''': The '''id=''' attribute of the terrain type you want to apply cost and defense defaults for.&lt;br /&gt;
* Subtags are used to specify the values using the same syntax as [resistance_defaults] - an optional default key, and subsequent keys which are movetype names. As with [resistance_defaults], you can use [[Wesnoth Formula Language|formulas]] if you enclose them in parentheses (but with no preceding dollar sign &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; or whitespace).&lt;br /&gt;
* Short names for the subtags are '''[movement]''', '''[jamming]''', '''[vision]''', and '''[defense]'''.&lt;br /&gt;
* Long names for the subtags are '''[movement_costs]''', '''[vision_costs]''', '''[jamming_costs]''', and '''[defense]'''.&lt;br /&gt;
&lt;br /&gt;
1.14.16 and 1.15.11 recognise both the short and long names above. 1.15.9 and 1.15.10 only recognised the long names, and all other prior versions only recognised the short names.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.14|16}} {{DevFeature1.15|9}} The formulas can now access other parts of the movetype, for example '''(resistance.arcane)''' or '''(movement_costs.swamp_water)'''. Simply using '''(swamp_water)''' is shorthand for the value in whichever subtag is being patched. Formulas only recognise the long names.&lt;br /&gt;
&lt;br /&gt;
The '''[terrain_defaults]''' tags are processed before any calculations of mixed terrains happen, and can only access the values for the basic terrain types. It's not useful to set a value for a mixed terrain type, as the calculations of mixed terrains' values decompose the mixed terrain to its base terrains before calculating the result, thus ignoring any patched values for mixed terrains.&lt;br /&gt;
&lt;br /&gt;
Setting a '''default=''' value for '''[vision_costs]''' or '''[jamming_costs]''' means that that value will be used instead of falling back to using the movement_costs for calculating vision. For this reason, it's likely that '''default=''' should only be used when patching the '''[movement_costs]''' and '''[defense]''', not for vision or jamming.&lt;br /&gt;
&lt;br /&gt;
A formula may use data added in a previous '''[terrain_defaults]'''. However, relying on data in the same '''[terrain_defaults]''' that creates or changes it is unsupported, because no guarantee is made of the order in which the subtags are processed.&lt;br /&gt;
&lt;br /&gt;
While '''[terrain_defaults]''' formulas can use resistances, and '''[resistance_defaults]''' formulas can use movement costs, no guarantee is made of whether '''[terrain_defaults]''' tags will be processed before or after '''[resistance_defaults]''' tags. Therefore, formulas should only use base terrains and not rely on data added by the other kind of movetype-patching tag.&lt;br /&gt;
&lt;br /&gt;
=== [hide_help] ===&lt;br /&gt;
&lt;br /&gt;
The '''[hide_help]''' tag allows you to hide some units from the help. Mainly useful if you can't change these units (e.g. mainline units) and thus can't add a 'hide_help=yes' key to them. Only really useful for campaigns, not for eras. The following keys and their contents uses an 'OR' logic between them.&lt;br /&gt;
* '''type''': list of unit types.&lt;br /&gt;
* '''race''': list of races. Equivalent to all unit types of these races.&lt;br /&gt;
* '''type_adv_tree''': list of unit types. Equivalent to all these types and their advancement trees.&lt;br /&gt;
* '''all''': 'yes' or 'no' (default). 'yes' is equivalent to all unit types (useful before [not])&lt;br /&gt;
* '''[not]''': all the previous keys (except 'all') can also be used in [not] sub-tags. And you can use [not] recursively. For example, if you want to only show the Yeti and the human race except the mage tree, use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[hide_help]&lt;br /&gt;
    all=yes&lt;br /&gt;
    [not]&lt;br /&gt;
        type=Yeti&lt;br /&gt;
        race=human&lt;br /&gt;
        [not]&lt;br /&gt;
            type_adv_tree=Mage&lt;br /&gt;
        [/not]&lt;br /&gt;
    [/not]&lt;br /&gt;
[/hide_help]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74220</id>
		<title>UnitsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74220"/>
		<updated>2025-03-20T11:31:37Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [resistance_defaults] */ 9676&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
The '''[units]''' tag is a [[ReferenceWML#WML_toplevel_tags|top-level WML tag]] which defines the unit types that will be available in the game.&lt;br /&gt;
&lt;br /&gt;
A '''[units]''' tag primarily contains [[UnitTypeWML|[unit_type]]] tags, each of which defines one unit type, and can also contain other tags, which mostly provide definitions of things like races and movement types that are used in unit type definitions.&lt;br /&gt;
&lt;br /&gt;
== Subtags of [units] ==&lt;br /&gt;
&lt;br /&gt;
The following tags can be used as subtags of a '''[units]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== [unit_type] ===&lt;br /&gt;
&lt;br /&gt;
{{Main|UnitTypeWML}}&lt;br /&gt;
&lt;br /&gt;
In a '''[units]''' tag, a '''[unit_type]''' tag defines a unit type.&lt;br /&gt;
&lt;br /&gt;
=== [trait] ===&lt;br /&gt;
&lt;br /&gt;
The '''[trait]''' tag describes a trait. When it appears in the '''[units]''' toplevel, it describes a global trait, and all races with the attribute '''ignore_global_traits=no''' will have this trait.; it may also appear in other places.&lt;br /&gt;
* '''id''': unique identifier; needed for random trait generation to work properly&lt;br /&gt;
* '''availability''': describes whether a trait is &amp;quot;musthave&amp;quot; for a race/unit type or is available to &amp;quot;any&amp;quot; unit, including leaders. The default is for a trait to only be available to nonleaders. Currently &amp;quot;any&amp;quot; should not be used for traits available in multiplayer. It can be used for campaign specific traits.&lt;br /&gt;
* '''male_name''': text displayed in the status of unit with the trait if the unit is male.&lt;br /&gt;
* '''female_name''': text displayed in the status of unit with the trait if the unit is female.&lt;br /&gt;
* '''name''': text displayed in the status of unit with the trait if none of the two above is used.&lt;br /&gt;
* '''description''': text displayed for the description of the trait when moving the cursor over the trait.&lt;br /&gt;
* '''help_text''': {{DevFeature1.13|6}} text displayed for the description of the trait in the help. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''[effect]''': described in [[EffectWML]]. More than one of these can be used.&lt;br /&gt;
* '''require_traits''': {{DevFeature1.17|13}} An optional comma-separated list of trait id keys that represent traits that are required by this one. Order is not important. If the unit not already has all of the traits that appear in this list, then this trait will not be generated for this unit.&lt;br /&gt;
* '''exclude_traits''': {{DevFeature1.17|13}} An optional comma-separated list of trait id keys that represent traits that are mutually exclusive to this one. Order is not important. If the unit already has any of the traits that appear once in this list, then this trait will not be generated for this unit. Of course, for this to really make two traits mutually exclusive, you need to add exclude_traits to both trait definitions.&lt;br /&gt;
&lt;br /&gt;
=== [movetype] ===&lt;br /&gt;
&lt;br /&gt;
The '''[movetype]''' tag is used to make shortcuts to describe units with similar terrain handicaps. Units from the same advancement tree should generally have the same movetype.&lt;br /&gt;
* '''name''': an ID for this movetype. Units with the attribute '''movement_type=''name''''' will be assigned this movetype.&lt;br /&gt;
* '''flies''' or {{DevFeature1.15|0}} '''flying''': either 'yes' or 'no' (default). A unit with ''flying=yes'' does not have its image's height adjusted for different terrains.&lt;br /&gt;
** This key corresponds to [unit]'s '''flying''' key.&lt;br /&gt;
** In Wesnoth 1.12 and 1.14, the value of '''flying''' sometimes overrides the value of '''flies''', but in other times '''flying''' is ignored&lt;br /&gt;
** {{DevFeature1.15|0}} '''flying''' always overrides the '''flies''' value, with the intention that '''flies''' will be deprecated.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|14}} note=Translatable string, which can be set if there’s something special about this movetype. It will be displayed in the unit's help page. For typical movetypes this is not set. An example are horses with the ''mounted'' movetype. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* {{anchor|resistance|'''[resistance]'''}}: describes how much damage the unit takes from different types of attacks. The attribute '''''type''=''resistance''''' makes the unit receive ''resistance'' percent of damage, or resist '''100-resistance''' percent of damage from attacks with '''type=''type'''''. So for example, a resistance of fire=110 means, this unit will receive 110% of damage, or have a resistance of -10% as displayed in-game. A value of fire=0 would mean, the unit receives no damage and therefore has a resistance of 100%.&amp;lt;br&amp;gt; The available attack types in mainline are blade, pierce, impact, fire, cold, and arcane.&lt;br /&gt;
* {{anchor|movement_costs|'''[movement_costs]'''}}: describes how fast the unit moves on different terrains. The attribute '''''terrain''=''cost''''' means that the unit will need to use ''cost'' move points to move onto that ''terrain''.&lt;br /&gt;
* {{anchor|vision_costs|'''[vision_costs]'''}}: describes how far the unit clears fog and shroud on different terrains. The attribute '''''terrain''=''cost''''' means that the unit will need to use ''cost'' vision points to view into that ''terrain''. (If not specified for a particular terrain, the vision cost defaults to the movement cost.)&lt;br /&gt;
* {{anchor|jamming_costs|'''[jamming_costs]'''}}: {{DevFeature1.13|0}} describes how far the unit interferes with the vision of other units over different terrains. This works the same as movement and vision costs. [https://forums.wesnoth.org/viewtopic.php?f=21&amp;amp;t=44577&amp;amp;p=644985#p644985 Example of jamming]&lt;br /&gt;
* {{anchor|defense|'''[defense]'''}}: describes how likely the unit is to be hit on different terrains. The attribute '''''terrain''=''defense''''' means that the unit will be hit ''defense'' percent of the time in that ''terrain''. If the defense value is negative, then that specifies an upper limit. The number in absolute terms is then also the best defense that the unit may have if there is more than one terrain type involved. For example '''forest=-70''' common for mounted units means the unit cannot get more than 30% defense on forest terrain. Regardless what other terrain the forest is on.&lt;br /&gt;
&lt;br /&gt;
The available keys for the '''[movement_costs]''', '''[vision_costs]''', '''[jamming_costs]''' and '''[defense]''' tags are the '''id'''s of archetype terrains (those not aliased to any other terrain, see [[TerrainWML]]).&amp;lt;br&amp;gt;&lt;br /&gt;
In mainline that encompasses deep_water, shallow_water, reef, swamp_water, flat, sand, forest, hills, mountains, village, castle, cave, frozen, unwalkable, fungus, and impassable.&lt;br /&gt;
&lt;br /&gt;
=== [race] ===&lt;br /&gt;
&lt;br /&gt;
The '''[race]''' tag is used to make shortcuts to describe units with similar names. Units from the same advancement tree should generally have the same race. Also, units with the same race should generally be recruitable by the same sides/factions. 'id' and 'plural_name' and ('name' or ('male_name' and 'female_name')) '''must''' be supplied.&lt;br /&gt;
* '''id''': ID for this race. Units with the attribute '''race=''id''''' will be assigned this race. In older versions of WML, the value of the name key was used as id if the id field was missing, but this is no longer the case.&lt;br /&gt;
* '''plural_name''': user-visible name for its people (e.g. &amp;quot;Merfolk&amp;quot; or &amp;quot;Elves&amp;quot;). Currently only used in the in-game help.&lt;br /&gt;
* '''male_name''': user-visible name for the race of the male units (e.g. &amp;quot;Merman&amp;quot;). Currently only used in the in-game unit status.&lt;br /&gt;
* '''female_name''': user-visible name for the race of the female units (e.g. &amp;quot;Mermaid&amp;quot;). Currently only used in the in-game unit status.&lt;br /&gt;
* '''name''': the default value for the three keys above. The 'name' key is the default for 'male_name' and 'female_name'.&lt;br /&gt;
* '''description''': text used in the in-game help.&lt;br /&gt;
* '''help_taxonomy''': {{DevFeature1.15|5}} in the help browser, show this race as a group of units from another race; the value of this attribute should be the other race's '''id''' attribute. This only affects the help browser, for all other purposes (such as WML filters) the two races are completely separate. (How this is visualised in the help browser is a GUI design decision, this attribute merely tells the engine that the relationship exists.)&lt;br /&gt;
* '''name_generator''' {{DevFeature1.13|5}}: [[Context-free grammar]] describing unit names, if absent or invalid, falls back to male_names or female_names&lt;br /&gt;
* '''male_name_generator''' {{DevFeature1.13|5}}: Like name_generator, but specific for male names&lt;br /&gt;
* '''female_name_generator''' {{DevFeature1.13|5}}: Like name_generator, but specific for female names&lt;br /&gt;
* '''male_names''', '''female_names''': lists of names (i.e. non-translatable strings). They are inputted into the Markov name generator to generate random names. ''male_names'' describes units with '''gender=male'''; ''female_names'' describes units with '''gender=female'''.&lt;br /&gt;
* '''markov_chain_size''': (default 2) number of letters per &amp;quot;syllable&amp;quot;. &amp;quot;Syllables&amp;quot; are groupings of names that the Markov name generator uses to determine names. It does this by running a probability algorithm to guess from the name list which syllables fit well together, which can start or end a name, etc.&lt;br /&gt;
* '''num_traits''': is the number of non-repeating traits each unit of this race can be assigned.&lt;br /&gt;
* '''ignore_global_traits''': 'yes' or 'no' (default). Determines whether global traits (see [traits] above) are applied.&lt;br /&gt;
* '''undead_variation''': sets the default undead variation for members of this race.&lt;br /&gt;
* '''[topic]''': describes extra help topics for this race.&lt;br /&gt;
* '''[trait]''': describes a trait for this race. See above for syntax.&lt;br /&gt;
&lt;br /&gt;
=== [resistance_defaults] ===&lt;br /&gt;
&lt;br /&gt;
Note: broken in 1.14.8, fixed in 1.14.16 and 1.15.9 ([https://github.com/wesnoth/wesnoth/issues/5308 issue #5308])&lt;br /&gt;
&lt;br /&gt;
The '''[resistance_defaults]''' tag allows you to add resistance for custom damage types to already-defined movetypes (such as core movetypes).&lt;br /&gt;
* '''id''': The damage type you want to apply resistance defaults for.&lt;br /&gt;
* '''default''': The default resistance for all movetypes. You can set it to a number, or to a [[Wesnoth Formula Language|formula]] (enclosed in parentheses, but with no preceding dollar sign &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; or whitespace) which can reference any of the default resistance types - arcane, fire, etc. A common usage for formulas might be to set it to be equal to another resistance, eg '''default=&amp;quot;(impact)&amp;quot;'''.&lt;br /&gt;
* Other keys reference the '''name=''' attribute of a defined movetype. For example, 'smallfoot=50' will set the resistance to 50 for the smallfoot movement type. Formulas can also be used here, for example 'smallfoot=(impact)'.&lt;br /&gt;
&lt;br /&gt;
''Note:'' The '''default=''' key and other keys are handled slightly differently. A '''default=''' value will never override an explicitly specified value either in the same '''[resistance_defaults]''' tag or in a '''[movetype]''' definition, but other keys always take priority over values specified in a '''[movetype]''' definition.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|9}} The formulas can now access other parts of the movetype, for example &amp;quot;(resistance.arcane)&amp;quot; or &amp;quot;(movement_costs.flat)&amp;quot;. For [resistance_defaults], &amp;quot;(arcane)&amp;quot; is shorthand for, and equivalent to, &amp;quot;(resistance.arcane)&amp;quot;. See the documentation in the [terrain_defaults] section for more details about this.&lt;br /&gt;
&lt;br /&gt;
=== [terrain_defaults] ===&lt;br /&gt;
&lt;br /&gt;
Note: broken in 1.14.8, fixed in 1.14.16 and 1.15.11 ([https://github.com/wesnoth/wesnoth/issues/5308 issue #5308])&lt;br /&gt;
&lt;br /&gt;
The '''[terrain_defaults]''' tag allows you to add costs and defenses for custom terrain types to already-defined movetypes (such as core movetypes).&lt;br /&gt;
* '''id''': The '''id=''' attribute of the terrain type you want to apply cost and defense defaults for.&lt;br /&gt;
* Subtags are used to specify the values using the same syntax as [resistance_defaults] - an optional default key, and subsequent keys which are movetype names. As with [resistance_defaults], you can use [[Wesnoth Formula Language|formulas]] if you enclose them in parentheses (but with no preceding dollar sign &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt;).&lt;br /&gt;
* Short names for the subtags are '''[movement]''', '''[jamming]''', '''[vision]''', and '''[defense]'''.&lt;br /&gt;
* Long names for the subtags are '''[movement_costs]''', '''[vision_costs]''', '''[jamming_costs]''', and '''[defense]'''.&lt;br /&gt;
&lt;br /&gt;
1.14.16 and 1.15.11 recognise both the short and long names above. 1.15.9 and 1.15.10 only recognised the long names, and all other prior versions only recognised the short names.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.14|16}} {{DevFeature1.15|9}} The formulas can now access other parts of the movetype, for example '''(resistance.arcane)''' or '''(movement_costs.swamp_water)'''. Simply using '''(swamp_water)''' is shorthand for the value in whichever subtag is being patched. Formulas only recognise the long names.&lt;br /&gt;
&lt;br /&gt;
The '''[terrain_defaults]''' tags are processed before any calculations of mixed terrains happen, and can only access the values for the basic terrain types. It's not useful to set a value for a mixed terrain type, as the calculations of mixed terrains' values decompose the mixed terrain to its base terrains before calculating the result, thus ignoring any patched values for mixed terrains.&lt;br /&gt;
&lt;br /&gt;
Setting a '''default=''' value for '''[vision_costs]''' or '''[jamming_costs]''' means that that value will be used instead of falling back to using the movement_costs for calculating vision. For this reason, it's likely that '''default=''' should only be used when patching the '''[movement_costs]''' and '''[defense]''', not for vision or jamming.&lt;br /&gt;
&lt;br /&gt;
A formula may use data added in a previous '''[terrain_defaults]'''. However, relying on data in the same '''[terrain_defaults]''' that creates or changes it is unsupported, because no guarantee is made of the order in which the subtags are processed.&lt;br /&gt;
&lt;br /&gt;
While '''[terrain_defaults]''' formulas can use resistances, and '''[resistance_defaults]''' formulas can use movement costs, no guarantee is made of whether '''[terrain_defaults]''' tags will be processed before or after '''[resistance_defaults]''' tags. Therefore, formulas should only use base terrains and not rely on data added by the other kind of movetype-patching tag.&lt;br /&gt;
&lt;br /&gt;
=== [hide_help] ===&lt;br /&gt;
&lt;br /&gt;
The '''[hide_help]''' tag allows you to hide some units from the help. Mainly useful if you can't change these units (e.g. mainline units) and thus can't add a 'hide_help=yes' key to them. Only really useful for campaigns, not for eras. The following keys and their contents uses an 'OR' logic between them.&lt;br /&gt;
* '''type''': list of unit types.&lt;br /&gt;
* '''race''': list of races. Equivalent to all unit types of these races.&lt;br /&gt;
* '''type_adv_tree''': list of unit types. Equivalent to all these types and their advancement trees.&lt;br /&gt;
* '''all''': 'yes' or 'no' (default). 'yes' is equivalent to all unit types (useful before [not])&lt;br /&gt;
* '''[not]''': all the previous keys (except 'all') can also be used in [not] sub-tags. And you can use [not] recursively. For example, if you want to only show the Yeti and the human race except the mage tree, use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[hide_help]&lt;br /&gt;
    all=yes&lt;br /&gt;
    [not]&lt;br /&gt;
        type=Yeti&lt;br /&gt;
        race=human&lt;br /&gt;
        [not]&lt;br /&gt;
            type_adv_tree=Mage&lt;br /&gt;
        [/not]&lt;br /&gt;
    [/not]&lt;br /&gt;
[/hide_help]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=74162</id>
		<title>InterfaceActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=74162"/>
		<updated>2025-02-12T20:12:12Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [wml_message] */ update about rewrite to Lua during 1.13.x&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Interface actions ==&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], interface actions are actions that do not have a direct 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;
== [inspect] ==&lt;br /&gt;
This user interface instantly displays the gamestate inspector dialog at the current scenario state (the same one that can be brought up with [[CommandMode|the ''':inspect''' command]]), which can be used to inspect the values of WML variables, AI configuration, recall lists, and more.&lt;br /&gt;
&lt;br /&gt;
* '''name''': optional attribute to specify the name of this gamestate inspector dialog. It is just a label to help differentiate between different invocations of gamestate inspector dialog.&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. Do not use a [filter] tag. 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 id 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;
* '''male_message''', '''female_message''': {{DevFeature1.13|2}} (translatable) Used instead of ''message'' if the unit's gender matches. Never used if there is no unit (ie ''speaker=narrator''). {{DevFeature1.13|6}} This matches the primary unit, not the secondary unit.&lt;br /&gt;
* '''wait_description''': {{DevFeature1.13|2}} the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]).&lt;br /&gt;
* '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
* '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number.&lt;br /&gt;
* '''image''': (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side. &lt;br /&gt;
** {{DevFeature1.13|0}} &amp;lt;b&amp;gt;none:&amp;lt;/b&amp;gt; display no image&lt;br /&gt;
* '''mirror''': {{DevFeature1.13|5}} whether to mirror the image specified by the '''image''' attribute.&lt;br /&gt;
* '''second_image''': {{DevFeature1.13|6}} same as the '''image''' attribute, but the image is displayed on the right of the message text. {{DevFeature1.17|7}} not working anymore, but there is plan to fix it eventually https://github.com/wesnoth/wesnoth/issues/8770&lt;br /&gt;
* '''second_mirror''': {{DevFeature1.13|6}} same as '''mirror''', but for the '''second_image''' attribute.&lt;br /&gt;
* '''image_pos''': {{DevFeature1.13|5}} whether to show the image on the left or right; supercedes the use of ~RIGHT() described above&lt;br /&gt;
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors.&lt;br /&gt;
* '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''.&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Boolean specifying whether to highlight the speaker. Defaults to ''yes''.&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;
* '''voice''', '''male_voice''', '''female_voice''': {{DevFeature1.13|?}} a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for '''message'''. They are never used when the speaker is the narrator - only '''voice''' is used in that case.&lt;br /&gt;
* {{anchor|message-option|'''[option]'''}}: No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events''&lt;br /&gt;
** '''message''': (translatable) the text displayed for the option. {{DevFeature1.15|1}} This is now a synonym for '''description='''.&lt;br /&gt;
** '''image''', '''label''', '''description''', '''default''': See [[DescriptionWML#WML_Format|DescriptionWML]].&lt;br /&gt;
** '''value''': {{DevFeature1.13|?}} Gives the option a value to be stored in a variable.&lt;br /&gt;
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
** '''[command]''': an element containing actions which are executed if the option is selected.&lt;br /&gt;
* '''variable''': {{DevFeature1.13|?}} If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has '''[show_if]''' condition evaluated as false, then it is hidden and excluded from the indexing.&lt;br /&gt;
* {{anchor|message-text_input|'''[text_input]'''}}: there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events''&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_length''': 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;
* Check [[EventWML#Multiplayer_safety]] to find out in which events you can safely use '''[option]''' and '''[text_input]''' without causing OOS.&lt;br /&gt;
&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
'''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [https://docs.gtk.org/Pango/pango_markup.html#pango-markup Pango markup formatting codes].&lt;br /&gt;
&lt;br /&gt;
Prefer to use single quotes (') instead of double quotes (&amp;quot;) within the formatting string, as double quotes would need to be escaped in WML (&amp;quot;&amp;quot;). Escaping markup can be done with [https://github.com/wesnoth/wesnoth/blob/9daa10a9f27c5a95520e871417bbd72aa52aa688/src/font/pango/escape.hpp#L38-L42 HTML entities].&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to write &amp;quot;You are victorious!&amp;quot; in large, italic, gold letters, you might write it this way:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;span color='#BCB088' size='large' font-style='italic'&amp;gt;You are victorious!&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are the codes taken from the Pango markup formatting guide:&lt;br /&gt;
&lt;br /&gt;
*'''font''', '''font_desc''': A font description string, such as &amp;quot;Sans Italic 12&amp;quot;.&lt;br /&gt;
*'''font_family''', '''face''': A font family name.&lt;br /&gt;
*'''font_size''', '''size''': Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.&lt;br /&gt;
*'''font_style''', '''style''': One of 'normal', 'oblique', 'italic'.&lt;br /&gt;
*'''font_weight''', '''weight''': One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.&lt;br /&gt;
*'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'.&lt;br /&gt;
*'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.&lt;br /&gt;
*'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's [https://github.com/GNOME/pango/blob/main/tools/rgb.txt rgb.txt] file.&lt;br /&gt;
*'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''underline''': One of 'none', 'single', 'double', 'low', 'error'.&lt;br /&gt;
*'''underline_color''': The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''rise''': Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.&lt;br /&gt;
*'''strikethrough''': 'true' or 'false' whether to strike through the text.&lt;br /&gt;
*'''strikethrough_color''': The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'&lt;br /&gt;
*'''fallback''': 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.&lt;br /&gt;
*'''letter_spacing''': Inter-letter spacing in 1024ths of a point.&lt;br /&gt;
*'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'.&lt;br /&gt;
*'''gravity_hint''': One of 'natural', 'strong', 'line'.&lt;br /&gt;
&lt;br /&gt;
The following pango attributes are also available directly as attributes of the '''[message]''' tag:&lt;br /&gt;
{{DevFeature1.13|4}}&lt;br /&gt;
&lt;br /&gt;
*'''font'''&lt;br /&gt;
*'''font_family'''&lt;br /&gt;
*'''font_size'''&lt;br /&gt;
*'''font_style'''&lt;br /&gt;
*'''font_weight'''&lt;br /&gt;
*'''font_variant'''&lt;br /&gt;
*'''font_stretch'''&lt;br /&gt;
*'''color'''&lt;br /&gt;
*'''bgcolor'''&lt;br /&gt;
*'''underline'''&lt;br /&gt;
*'''underline_color'''&lt;br /&gt;
*'''rise'''&lt;br /&gt;
*'''strikethrough'''&lt;br /&gt;
*'''strikethrough_color'''&lt;br /&gt;
*'''fallback'''&lt;br /&gt;
*'''letter_spacing'''&lt;br /&gt;
*'''gravity'''&lt;br /&gt;
*'''gravity_hint'''&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;
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. note: There are side-specific objectives and default objectives, which are used in case a side doesn't have specific ones. Specifying 0 sets the default ones.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Sets the objectives of all matching sides to these passed specifications (the rest of this [objectives] tag). If no sides (such as when passing side=0) or all sides match, sets the default objectives, and the side specific ones for the matching sides otherwise.&lt;br /&gt;
* '''bullet''': Default '• '. Replaces the default bullet, with whatever is passed, for all objectives, gold carryover notes, and notes defined with [note].&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. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''defeat_string''': Default ' _ &amp;quot;Defeat:&amp;quot;', this text precedes the defeat objectives. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''gold_carryover_string''': Default ' _ &amp;quot;Gold carryover:&amp;quot;', this text precedes the gold carryover information.&lt;br /&gt;
* '''notes_string''': Default ' _ &amp;quot;Notes:&amp;quot;', this text precedes the notes.&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;
* '''delayed_variable_substitution''': {{DevFeature1.13|8}} If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed.&lt;br /&gt;
&lt;br /&gt;
Tags of '''[objectives]''':&lt;br /&gt;
* {{anchor|objectives-objective|'''[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;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block.&lt;br /&gt;
** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255' for winning objectives, '0' for losing objectives. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''description''': text for the specific win or loss condition.&lt;br /&gt;
** '''caption''': a text which will be displayed above the ''description''. This can be used to display a subcategory of objectives below ''victory_string'' or ''defeat_string''.&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;
** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no.&lt;br /&gt;
** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only, or when manually opening the scenario objectives.&lt;br /&gt;
* {{anchor|objectives-gold_carryover|'''[gold_carryover]'''}}: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives].&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '192'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned.&lt;br /&gt;
** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned.&lt;br /&gt;
** '''[show_if]''': {{DevFeature1.13|11}} Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at '''[show_objectives]''' time only.&lt;br /&gt;
* {{anchor|objectives-note|'''[note]'''}}: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key.&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire note, including the bullet.&lt;br /&gt;
** '''blue''': Default '255'. Overrides the default blue coloring of the entire note, including the bullet.&lt;br /&gt;
** '''description''': the text of the note.&lt;br /&gt;
** '''[show_if]''': The note will not be shown if the specified condition isn't met. Conditional notes are refreshed at '''[show_objectives]''' time only.&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. The menu items can be set and modified during any event, for example during &amp;quot;start&amp;quot; or &amp;quot;prestart&amp;quot; events. The user can also assign hotkeys to these WML commands unless specified otherwise. When the hotkey is pressed the event will be fired/filtered at the current mouse position.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth.&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. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters.&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, defaults to &amp;quot;buttons/WML-custom.png&amp;quot;&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. {{DevFeature1.13|6}} ''needs_select=yes'' is deprecated, consider using manual variable syncing with [sync_variable].&lt;br /&gt;
* '''synced''' {{DevFeature1.13|1}}: if ''no'' (default ''yes'') the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with ''synced=no'' will cause OOS&lt;br /&gt;
* '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. &lt;br /&gt;
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) 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 [[StandardLocationFilter]] similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations.&lt;br /&gt;
* '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:&lt;br /&gt;
** '''key''': a string that contains the key to assign to this.&lt;br /&gt;
** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''':  boolean values.&lt;br /&gt;
** '''repeat_on_hold''' {{DevFeature1.13|12}}: if ''yes'' (default ''no''), holding the hotkey will repeat the action continuously, unless it blocks input with something like '''[message]'''. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.&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;
** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item.&lt;br /&gt;
&lt;br /&gt;
== [clear_menu_item] ==&lt;br /&gt;
&lt;br /&gt;
Removes a menu item from the scenario.&lt;br /&gt;
Normally menu items are, including all their defining wml, automatically carried over between scenarios. This tag prevents this. (The behavior is comparable to set_variable/clear_variable).&lt;br /&gt;
* '''id''': (string): id of the menu item to clear. Can be a comma-separated list.&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;
&lt;br /&gt;
=== [change_theme] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Change the current interface theme.&lt;br /&gt;
&lt;br /&gt;
* '''theme''': The ID of the new theme. Use &amp;lt;code&amp;gt;theme=&amp;lt;/code&amp;gt; (empty key) to switch back to the theme that the player has selected in Preferences. On &amp;lt;b&amp;gt;1.14.2&amp;lt;/b&amp;gt; and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine).&lt;br /&gt;
&lt;br /&gt;
=== [item] ===&lt;br /&gt;
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. (only for [event][item]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ImagePathFunctions#Blit_Function|BLIT]] the image onto &amp;lt;tt&amp;gt;misc/blank-hex.png&amp;lt;/tt&amp;gt; (a blank 72x72 image).)''&lt;br /&gt;
* '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image (https://github.com/wesnoth/wesnoth/issues/1219).&lt;br /&gt;
* '''name''' an id that can be used to remove the item.&lt;br /&gt;
''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100''&lt;br /&gt;
or equivalently (requires Wesnoth 1.11.2+):&lt;br /&gt;
''halo=scenery/fire[1~8].png:100''&lt;br /&gt;
* '''team_name''': 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. {{DevFeature1.15|0}} In 1.14 the '''[side]team_name''' attribute was expected to be a substring of this '''team_name'''. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* '''visible_in_fog''': whether the item should be visible through fog or not. Default yes.&lt;br /&gt;
* '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items.&lt;br /&gt;
* '''[filter_team]''': {{DevFeature1.15|0}} A [[StandardSideFilter]]. Set '''team_name''' to the union of all '''[side]team_name''' attributes of all sides that match the SSF. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* {{DevFeature1.15|0}} If both '''team_name''' and '''[filter_team]''' are set, '''team_name''' is ignored.&lt;br /&gt;
&lt;br /&gt;
=== [remove_item] ===&lt;br /&gt;
Removes any graphical items on a given hex.&lt;br /&gt;
* [[StandardLocationFilter]]: the hexes to remove items from&lt;br /&gt;
* '''image''': if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any [[ImagePathFunctions|image path functions]] appended to the original image name.)&lt;br /&gt;
&lt;br /&gt;
=== [print] ===&lt;br /&gt;
Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered.&lt;br /&gt;
* '''text''': (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one.&lt;br /&gt;
* '''size''': (default=12) the pointsize of the font to use&lt;br /&gt;
* '''duration''': the length of time to display the text for.&lt;br /&gt;
** (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms.&lt;br /&gt;
** {{DevFeature1.15|4}} This is measured in milliseconds. Don't use the default value, because it's a mere 50ms.&lt;br /&gt;
** {{DevFeature1.15|14}} The default is 5000 milliseconds.&lt;br /&gt;
** {{DevFeature1.15|14}} The string '''unlimited''' displays the text until it's removed by another [print] tag.&lt;br /&gt;
* '''color''': (default '''0,0,0''') three comma-separated values giving the red, green and blue values (0-255).&lt;br /&gt;
* '''red''', '''green''', '''blue''': deprecated, use color=0,0,0 instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit_fake] ===&lt;br /&gt;
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;
* '''gender''': the gender of the fake unit. Example: gender=female&lt;br /&gt;
* '''variation''': the variation of the fake unit. Example: variation=undead&lt;br /&gt;
* '''image_mods''': [[ImagePathFunctions|image path functions]] sequence to be applied on the fake unit.&lt;br /&gt;
* '''force_scroll''':  Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_units_fake] ===&lt;br /&gt;
moves multiple images of units along paths on the map. These units are moved in lockstep.&lt;br /&gt;
* '''force_scroll''': {{DevFeature1.15|0}} Has the same meaning as in [move_unit_fake] but a different default.&lt;br /&gt;
* '''[fake_unit]''': A fake unit to move&lt;br /&gt;
** '''type''': the type of 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;
** '''skip_steps''': the number of steps to skip before this unit starts moving&lt;br /&gt;
&lt;br /&gt;
=== [hide_unit] ===&lt;br /&gt;
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit.&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will be hidden&lt;br /&gt;
&lt;br /&gt;
=== [unhide_unit] ===&lt;br /&gt;
Stops the currently hidden units from being hidden.&lt;br /&gt;
* [[StandardUnitFilter]]: Only the matching units will be unhidden&lt;br /&gt;
&lt;br /&gt;
=== [lock_view] ===&lt;br /&gt;
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game.&lt;br /&gt;
&lt;br /&gt;
This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally.&lt;br /&gt;
&lt;br /&gt;
=== [unlock_view] ===&lt;br /&gt;
Unlocks gamemap view scrolling for human players.&lt;br /&gt;
&lt;br /&gt;
=== [scroll] ===&lt;br /&gt;
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;
* '''side''': the side or sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to] ===&lt;br /&gt;
Scroll to a given hex&lt;br /&gt;
* [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex being scrolled to (defaults to ''no'').&lt;br /&gt;
* '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to_unit] ===&lt;br /&gt;
Scroll to a given unit&lt;br /&gt;
* [[StandardUnitFilter]]; do not use a [filter] subtag.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex the unit is on (defaults to ''no'').&lt;br /&gt;
* '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
* '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [select_unit] ===&lt;br /&gt;
Selects a given unit.&lt;br /&gt;
* [[StandardUnitFilter]]: The first unit found will be selected.&lt;br /&gt;
* '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.)&lt;br /&gt;
* '''highlight''': whether the unit's current hex should be highlighted (def. ''yes'').&lt;br /&gt;
&lt;br /&gt;
'''Note:''' fire_event does not appear to work in 1.14 or 1.16.&lt;br /&gt;
&lt;br /&gt;
=== [sound]===&lt;br /&gt;
Plays a sound&lt;br /&gt;
* '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly.&lt;br /&gt;
* '''repeat''': repeats the sound for a specified additional number of times (default=0)&lt;br /&gt;
&lt;br /&gt;
=== [sound_source] ===&lt;br /&gt;
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 ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are fogged&lt;br /&gt;
* '''check_shrouded''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are shrouded&lt;br /&gt;
* '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source&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;
&lt;br /&gt;
=== [story] ===&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Shows the story screen.&lt;br /&gt;
* '''title''': Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title.&lt;br /&gt;
* '''[part]''', '''[if]''', '''[switch]''', '''[wml_message]''', '''[deprecated_message]''' : See [[IntroWML]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_sound_source] ===&lt;br /&gt;
Removes a previously defined sound source.&lt;br /&gt;
* '''id''': the identification key of the sound source to remove&lt;br /&gt;
&lt;br /&gt;
=== [music] ===&lt;br /&gt;
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;
&lt;br /&gt;
=== [volume] ===&lt;br /&gt;
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100:  &lt;br /&gt;
* '''music''':  Changes the music volume.&lt;br /&gt;
* '''sound''':  Changes the sound volume.&lt;br /&gt;
&lt;br /&gt;
=== [color_adjust] ===&lt;br /&gt;
Adjust the color tint of terrain, by adjusting time-of-day coloring.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color&lt;br /&gt;
&lt;br /&gt;
=== [screen_fade] ===&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from 0 to 255, the final overlay color (defaults to 0,0,0)&lt;br /&gt;
* '''alpha''': value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen.&lt;br /&gt;
* '''duration''': the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate.&lt;br /&gt;
&lt;br /&gt;
=== [delay] ===&lt;br /&gt;
Pauses the game.&lt;br /&gt;
* '''time''': the time to pause in milliseconds&lt;br /&gt;
* '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game.&lt;br /&gt;
&lt;br /&gt;
=== [redraw] ===&lt;br /&gt;
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;
* '''clear_shroud''' (boolean yes|no, default no): If yes, clears fog and shroud around existing units. 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;
* '''[[StandardSideFilter]]''': the sides for which to recalculate fog and shroud.&lt;br /&gt;
* '''side''': If used (forces clear_shroud=yes), clears fog and shroud for that side.&lt;br /&gt;
&lt;br /&gt;
=== [unit_overlay] ===&lt;br /&gt;
Sets an image that will be drawn over a particular unit, and follow it around&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter])&lt;br /&gt;
* '''image''': the image to place on the unit&lt;br /&gt;
* '''object_id''': object id to use, defaults to the '''image''' key with an &amp;quot;overlay_&amp;quot; prefix; this allows using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']]&lt;br /&gt;
* '''duration''': object duration&lt;br /&gt;
&lt;br /&gt;
=== [remove_unit_overlay] ===&lt;br /&gt;
Removes a particular overlayed image from a unit&lt;br /&gt;
* [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter])&lt;br /&gt;
* '''image''': the image to remove from the unit&lt;br /&gt;
* '''object_id''': object id to use&lt;br /&gt;
Using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271&lt;br /&gt;
&lt;br /&gt;
=== [animate_unit] ===&lt;br /&gt;
Uses an 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 custom animation in the unit description (see the '''[extra_anim]''' description in [[AnimationWML]]). Standard animations can be triggered with the following keywords: ''leading recruited standing idling levelout levelin healing healed poisoned movement defend attack death victory pre_teleport post_teleport''&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument, 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. Takes a weapon filter as argument, see [[FilterWML]].&lt;br /&gt;
* '''[secondary_attack]''': Similar to '''[primary_attack]'''. May be needed to trigger a defense animation correctly, if there are more than one animations available for the defending unit.&lt;br /&gt;
* '''hits''': yes/no/hit/miss/kill: which according variation of a attack/defense animation shall be chosen (required)&lt;br /&gt;
* '''text''': a text to hover during the animation &lt;br /&gt;
* '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
* '''red''': red value for the text color (0-255)&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''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar)&lt;br /&gt;
* '''[animate]''': a sub block with the same syntax as '''[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 hex the unit should be facing when animated&lt;br /&gt;
&lt;br /&gt;
=== [label] ===&lt;br /&gt;
Places a label on the map.&lt;br /&gt;
* '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''text''': what the label should say. If you put an empty string &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location.&lt;br /&gt;
* '''team_name''': if specified, the label will only be visible to the given team.&lt;br /&gt;
* '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255.&lt;br /&gt;
* '''visible_in_fog''': whether the label should be visible through fog or not. Default yes.&lt;br /&gt;
* '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no.&lt;br /&gt;
* '''immutable''': whether this label is protected from being removed or changed by players. Default yes.&lt;br /&gt;
* '''category''': the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox.&lt;br /&gt;
* '''tooltip''': A tooltip visible when mouseovering the hex the label is on&lt;br /&gt;
* '''side''': the number of the side that placed the label. Can be 0 for labels placed by WML.&lt;br /&gt;
&lt;br /&gt;
=== [floating_text]===&lt;br /&gt;
Floats text (similar to the damage and healing numbers) on the given locations.&lt;br /&gt;
* [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units).&lt;br /&gt;
* '''text''': the text to display.&lt;br /&gt;
&lt;br /&gt;
The default text color is &amp;lt;span style=&amp;quot;color: #6b8cff;&amp;quot;&amp;gt;'''#6b8cff'''&amp;lt;/span&amp;gt;. To change the color, use [[#Formatting|Pango markup]]. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Float some golden yellow text at 20,20.&lt;br /&gt;
[floating_text]&lt;br /&gt;
   x,y=20,20&lt;br /&gt;
   text=&amp;quot;&amp;lt;span color='#cccc33'&amp;gt;&amp;quot; + _ &amp;quot;Your text here&amp;quot; + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
[/floating_text]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [deprecated_message] ===&lt;br /&gt;
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;
* '''level''': {{DevFeature1.13|10}} The deprecation level, a number from 1 to 3.&lt;br /&gt;
* '''what''': {{DevFeature1.13|10}} The name of the thing being deprecated. Use this instead of '''message''' if possible; a stock message will be generated from it. Use '''message''' only if more information is required; it will be appended to the stock message. This should not be translatable&lt;br /&gt;
* '''version''': {{DevFeature1.13|10}} For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does ''not'' indicate the version in which it became deprecated. &lt;br /&gt;
&lt;br /&gt;
The meanings of the deprecation levels are as follows:&lt;br /&gt;
&lt;br /&gt;
# Deprecated, but will only be removed if absolutely necessary. The '''version''' key is ignored.&lt;br /&gt;
# It will be removed no earlier than a specified version.&lt;br /&gt;
# It will be removed in the next stable version&lt;br /&gt;
# It has already been removed, leaving just a stub to inform users of how to update their code.&lt;br /&gt;
&lt;br /&gt;
Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The '''message''' can be translatable, but does not need to be.&lt;br /&gt;
&lt;br /&gt;
=== [wml_message] ===&lt;br /&gt;
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. WML wrapper of [[LuaAPI/wesnoth#wesnoth.log]], see the link for more description.&lt;br /&gt;
* '''message''': the message to show.&lt;br /&gt;
* '''to_chat''': controls whether message is visible in chat, though logger=wml means message is visible anyways. Default ''no''.&lt;br /&gt;
* '''logger''': one of '''info''', '''debug''', '''warning''', '''error''', '''wml'''. Default ''info''.&lt;br /&gt;
&lt;br /&gt;
=== [test_condition] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why.&lt;br /&gt;
&lt;br /&gt;
* '''result''': Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass.&lt;br /&gt;
* '''logger''': Same as for [wml_message]. Defaults to &amp;quot;warning&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [open_help] ===&lt;br /&gt;
Opens the in-game help.&lt;br /&gt;
* '''topic''': the id of the topic to open&lt;br /&gt;
&lt;br /&gt;
Examples of ids:&lt;br /&gt;
* unit_Mage&lt;br /&gt;
* unit_Dark Adept&lt;br /&gt;
* weaponspecial_charge&lt;br /&gt;
* terrain_human_castle&lt;br /&gt;
&lt;br /&gt;
The engine will print the topic ids if run from the command line with the ''--log-debug=help'' option.&lt;br /&gt;
&lt;br /&gt;
=== [show_objectives] ===&lt;br /&gt;
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.)&lt;br /&gt;
* '''side''': the side to show the objectives. If not set, all sides are used.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Tag affects the matching sides instead of just all or the one given by the integer value of the side= key.&lt;br /&gt;
&lt;br /&gt;
=== [chat] ===&lt;br /&gt;
Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: [[LuaWML:Display#wesnoth.message]]. {{DevFeature1.13|9}} can be visible for observers.&lt;br /&gt;
* '''speaker''': (default=&amp;quot;WML&amp;quot;) A string for the name of the sender of the message.&lt;br /&gt;
* '''message''': The message that should be displayed.&lt;br /&gt;
* '''observable''' (boolean yes|no, default yes): {{DevFeature1.13|9}} Whether the message is displayed for observers.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once.&lt;br /&gt;
&lt;br /&gt;
=== [zoom] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map.&lt;br /&gt;
&lt;br /&gt;
* '''factor''': The new zoom factor, measured as a multiple of the base zoom.&lt;br /&gt;
* '''relative''': If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no.&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;
* '''{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;
* '''{QUAKE &amp;lt;soundfile&amp;gt;}''' Creates a tremor-like screenshake and plays &amp;lt;soundfile&amp;gt;. For example, '''{QUAKE (rumble.ogg)}'''.&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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InternalActionsWML&amp;diff=74136</id>
		<title>InternalActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InternalActionsWML&amp;diff=74136"/>
		<updated>2025-01-24T21:04:04Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [fire_event] */ [data] as $data&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], Internal actions are actions that WML uses internally that do not directly affect game play (or, at least, are not readily apparent to the player). For example, storing a variable is an internal action.&lt;br /&gt;
&lt;br /&gt;
== Variable Actions ==&lt;br /&gt;
&lt;br /&gt;
These actions are focused, in one way or another, on [[VariablesWML|variables]]. Creating them, modifying them, capturing game data to them, you name it, these actions are all about the variables.&lt;br /&gt;
&lt;br /&gt;
=== [set_variable] ===&lt;br /&gt;
&lt;br /&gt;
The '''[set_variable]''' tag is used to create and manipulate [[VariablesWML|WML variables­­­]]. The [https://www.wesnoth.org/macro-reference.html#VARIABLE VARIABLE] macro is a quick syntactic shortcut for simple variable creation and the [https://www.wesnoth.org/macro-reference.html#VARIABLE_OP VARIABLE_OP] macro is a quick syntactic shortcut for performing simple mathematical operations on variables.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of the variable to manipulate&lt;br /&gt;
&lt;br /&gt;
* '''value''': set the variable to the given value (can be numeric or string). Use literal for no substitution. (see [[VariablesWML]])&lt;br /&gt;
&lt;br /&gt;
* '''literal''': set the variable to the given value (can be numeric or string). This does not interpret any dollar signs.&lt;br /&gt;
&lt;br /&gt;
* '''to_variable''': set the variable to the value of the given variable, e.g. 'to_variable=temp' would be equivalent to 'value=$temp'.&lt;br /&gt;
&lt;br /&gt;
* '''add''': add the given amount to the variable.&lt;br /&gt;
&lt;br /&gt;
* '''sub''': subtract the given amount from the variable.&lt;br /&gt;
&lt;br /&gt;
* '''multiply''': multiply the variable by the given number. The result is a float.&amp;lt;br /&amp;gt;To negate a number, multiply by -1. If you negate 0, the result is a floating-point negative zero -0. To display -0 as 0, use a second tag with add=0; it will flip -0 to 0 but not affect other numbers.&lt;br /&gt;
&lt;br /&gt;
* '''divide''': divide the variable by the given number. The result is a float. Wesnoth 1.9 and later no longer uses integer division. Use a second tag with round=floor if you relied on this.&lt;br /&gt;
&lt;br /&gt;
* '''modulo''': returns the remainder of a division.&lt;br /&gt;
&lt;br /&gt;
* '''abs''': Returns the absolute value of the variable.&lt;br /&gt;
&lt;br /&gt;
* '''root''': Use '''root=square''' to calculate the square root. {{DevFeature1.15|0}} Also supports '''root=cube''' and arbitrary integer roots.&lt;br /&gt;
&lt;br /&gt;
* '''power''': Raise the variable to some power.&lt;br /&gt;
&lt;br /&gt;
* '''rand''': the variable will be randomly set.&amp;lt;br&amp;gt;You may provide a comma separated list of possibilities, e.g. 'rand=Bob,Bill,Bella'.&amp;lt;br&amp;gt;You may provide a range of numbers (integers), e.g. 'rand=3..5'.&amp;lt;br&amp;gt;You may combine these, e.g. 'rand=100,1..9', in which case there would be 1/10th chance of getting 100, just like for each of 1 to 9. If a number or item is repeated, it is sampled more frequently as appropriate. See [[MultiplayerContent]] for more info on the MP case.&amp;lt;br&amp;gt;Using rand= will automatically result in the current action being non undoable. Ignoring possible [allow_undo].&lt;br /&gt;
&lt;br /&gt;
* '''time=stamp''': Retrieves a timestamp in milliseconds since wesnoth was started, can be used as timing aid. Don't try to use this as random value in MP since it will cause an OOS.&lt;br /&gt;
&lt;br /&gt;
* '''string_length''': Retrieves the length in characters of the string passed as this attribute's value; such string is parsed and variable substitution applied automatically (see [[VariablesWML]] for details).&lt;br /&gt;
&lt;br /&gt;
* {{anchor|join|'''[join]'''}} joins an array of strings to create a textual list&lt;br /&gt;
** '''variable''': name of the array&lt;br /&gt;
** '''key''': the key of each array element(array[$i].foo) in which the strings are stored&lt;br /&gt;
** '''separator''': separator to connect the elements&lt;br /&gt;
** '''remove_empty''': whether to ignore empty elements&lt;br /&gt;
&lt;br /&gt;
* '''ipart''': Assigns the integer part (the part to the left of the decimal point) of the referenced variable.&lt;br /&gt;
&lt;br /&gt;
* '''fpart''': Assigns the decimal part (the part to the right of the decimal point) of the referenced variable.&lt;br /&gt;
&lt;br /&gt;
* '''round''': Rounds the variable to the specified number of digits of precision. Negative precision works as expected (rounding 19517 to -2 = 19500). Special values:&lt;br /&gt;
**'''round=ceil''': Rounds upward to the nearest integer.&lt;br /&gt;
**'''round=floor''': Rounds down to the nearest integer.&lt;br /&gt;
**'''round=trunc''': {{DevFeature1.15|0}} Rounds towards zero; this is the same operation as '''ipart''', but operating on the value already contained in the variable rather than the value assigned to the key.&lt;br /&gt;
&lt;br /&gt;
* '''min''', '''max''': {{DevFeature1.15|9}} Specify a comma-separated list of numbers; either the smallest or largest number in the list will be assigned to the variable.&lt;br /&gt;
&lt;br /&gt;
* '''reverse=yes''': {{DevFeature1.15|9}} Reverses the string value of the variable. For example, &amp;quot;delfador&amp;quot; becomes &amp;quot;rodafled&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* '''formula''': Calculate the new value of the variable from a [[Wesnoth_Formula_Language|WFL]] formula operating on the old value. This is similar to using the '''$(...)''' syntax but avoids the possibility of WFL syntax errors if a referenced variable is empty.&lt;br /&gt;
&lt;br /&gt;
=== [set_variables] ===&lt;br /&gt;
&lt;br /&gt;
Manipulates a WML array or container&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of the array or container to manipulate&lt;br /&gt;
&lt;br /&gt;
* '''mode''': one of the following values:&lt;br /&gt;
** ''replace'': will clear the array '''name''' and replace it with given data. This is the default value.&lt;br /&gt;
** ''append'': will append given data to the current array&lt;br /&gt;
** ''merge'': will merge in the given data into '''name'''. Attributes in '''[value]''' will overwrite any existing already in '''name'''. Tags in '''[value]''' modify the corresponding tag of the original value of '''name''', so for example the first '''[attack]''' tag in '''[value]''' would modify the first '''[attack]''' tag of '''name''' rather than appending a new '''[attack]''' tag. A few special syntaxes are supported:&lt;br /&gt;
*** ''__remove=yes'': When used in a subtag, causes the corresponding subtag in '''name''' to be deleted rather than merged. Deletion happens after any other subtags have been merged.&lt;br /&gt;
*** ''add_to_xxx'': Adds its integer value to the integer value of '''xxx''' in '''name''', and sets '''xxx''' in '''name''' to the result. {{DevFeature1.13|8}} Now adds as real numbers rather than integers.&lt;br /&gt;
*** ''concat_to_xxx'': {{DevFeature1.13|8}} Similar to '''add_to_xxx''', but does string concatenation instead of numerical addition.&lt;br /&gt;
** ''insert'': will insert the given data at the index specified in the '''name''' attribute, such as name=my_array[1]. The default index is zero, which will insert to the front of the array. '''Note:''' if an invalid index is used, empty containers will be created before the insertion is performed. In other words, do not attempt to insert at an index greater than (or equal to) the array's current length. This limitation may be removed in future versions.&lt;br /&gt;
&lt;br /&gt;
* '''to_variable''': set the array or container to the value of the given variable&lt;br /&gt;
&lt;br /&gt;
* {{anchor|set_variables-value|'''[value]'''}}: the WML inside the [value] tags will be stored in data, variables will be interpolated directly, use $| in order to escape the $ sign, you can store arrays of WML by supplying multiple [value] tags. ([[#Using_.5Bset_variables.5D_to_Create_Arrays_of_WML|See Example]])&lt;br /&gt;
&lt;br /&gt;
* {{anchor|set_variables-literal|'''[literal]'''}}: same as '''[value]''', but variables will not be substituted, '''[literal]''' and '''[value]''' can not be used in the same [set_variables] tag, i.e. you can not create arrays by piling a mix of '''[value]''' and '''[literal]''' tags&lt;br /&gt;
&lt;br /&gt;
*{{anchor|set_variables-split|'''[split]'''}}: splits a textual list into an array which will then be set to data&lt;br /&gt;
** '''list''': textual list to split&lt;br /&gt;
** '''key''': the key of each array element(array[$i].foo) in which the strings are stored; defaults to ''value'' if omitted.&lt;br /&gt;
** '''separator''': separator to separate the elements; if omitted, each character of the string will become an element in the result array.&lt;br /&gt;
** '''remove_empty''': whether to ignore empty elements; ignored if '''separator''' is omitted&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|4}} You can now mix '''[value]''', '''[literal]''', and '''[split]''' in the same '''[set_variables]''' tag. They will be processed in order of appearance. Multiple instances of [split] are also supported now.&lt;br /&gt;
&lt;br /&gt;
=== Capturing Game Data ===&lt;br /&gt;
&lt;br /&gt;
These actions capture different bits of game data and store them to variables so they can be examined and/or manipulated.&lt;br /&gt;
&lt;br /&gt;
==== [store_gold] ====&lt;br /&gt;
&lt;br /&gt;
Stores a side's gold into a variable.&lt;br /&gt;
&lt;br /&gt;
* '''[[StandardSideFilter]]''': The first matching side's gold will be stored in the variable &amp;quot;variable&amp;quot;.&lt;br /&gt;
* '''variable''': (default='gold') the name of the variable to store the gold in&lt;br /&gt;
&lt;br /&gt;
==== [store_locations] ====&lt;br /&gt;
&lt;br /&gt;
Stores a series of locations that pass certain criteria into an array. Each member of the array has members 'x' and 'y' (the position) and 'terrain' (the terrain type) and 'owner_side' (villages only). The array will include any unreachable border hexes, if applicable.&lt;br /&gt;
&lt;br /&gt;
* [[StandardLocationFilter]]: a location or location range which specifies the locations to store. By default, all locations on the map are stored.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable (array) into which to store the locations. Defaults to '''location'''.&lt;br /&gt;
&lt;br /&gt;
* '''mode''': {{DevFeature1.13|0}} defaults to ''always_clear'', which clears the variable, whether or not a match is found. If mode is set to ''replace'', the variable will not be cleared, and locations which match the filter will overwrite existing elements at the start of the array, leaving any additional elements intact if the original array contained more elements than there are locations matching the filter. If mode is set to ''append'', the variable will not be cleared, and locations which match the filter will be added to the array after the existing elements.&lt;br /&gt;
&lt;br /&gt;
==== [store_reachable_locations] ====&lt;br /&gt;
&lt;br /&gt;
Stores locations reachable by the given units. Can store either the movement, attack or vision ranges.&lt;br /&gt;
&lt;br /&gt;
* '''[filter]''': a [[StandardUnitFilter]]. The locations reachable by any of the matching units will be stored.&lt;br /&gt;
* '''[filter_location]''': (optional) a [[StandardLocationFilter]]. Only locations which also match this filter will be stored.&lt;br /&gt;
* '''range''': possible values ''movement'' (default), ''attack'', ''vision''. If ''movement'', stores the locations within the movement range of the unit, taking Zone of Control into account. If ''attack'', stores the attack range (movement range + 1 hex). See note below for ''vision''.&lt;br /&gt;
* '''moves''':  possible values ''current'' (default), ''max''. For ''movement'' and ''attack'', specifies whether to use the current or maximum movement points when calculating the range. Ignored for ''vision''.&lt;br /&gt;
* '''viewing_side''': If left unset then fog and shroud are ignored, hidden ambushers are not ignored, and the real reach of the units is stored. If set to a non-zero number, then the area stored for each unit matching the SUF is based on the information visible to that unit's side; it doesn't matter which non-zero number is given. Ignored completely for ''vision''.&lt;br /&gt;
* '''variable''': the name of the variable (array) into which to store the locations.&lt;br /&gt;
&lt;br /&gt;
In 1.14 and before, the ''vision'' range is calculated as max movement range ignoring ZoC + 1 hex.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|12}} ''vision'' uses the same calculations as the fog and shroud, and handles:&lt;br /&gt;
* units with vision costs different to movement costs&lt;br /&gt;
* units whose vision points aren't the same as their max movement points&lt;br /&gt;
* jamming by enemy units&lt;br /&gt;
&lt;br /&gt;
==== [store_map_dimensions] ====&lt;br /&gt;
&lt;br /&gt;
Stores the map dimensions in a variable.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable where the values will be saved into. If it is skipped, a variable 'map_size' is used, and its contents overridden, if they existed already. The result is a container variable, with members ''width'' and ''height''.&lt;br /&gt;
&lt;br /&gt;
==== [store_side] ====&lt;br /&gt;
&lt;br /&gt;
Stores information about a certain side in a variable.&lt;br /&gt;
&lt;br /&gt;
'''Keys:'''&lt;br /&gt;
* '''[[StandardSideFilter]]''': All matching sides are stored. (An array is created if several sides match - access it with side[2].team_name and so on.)&lt;br /&gt;
* '''variable''': the name of the variable to store the information in (default: &amp;quot;side&amp;quot;)&lt;br /&gt;
* '''mode''':{{DevFeature1.13|0}} defaults to ''always_clear'', which clears the variable, whether or not a match is found. If mode is set to ''replace'', the variable will not be cleared, and sides which match the filter will overwrite existing elements at the start of the array, leaving any additional elements intact if the original array contained more elements than there are sides matching the filter. If mode is set to ''append'', the variable will not be cleared, and sides which match the filter will be added to the array after the existing elements.&lt;br /&gt;
'''Result'''&lt;br /&gt;
&lt;br /&gt;
Variable will contain following members:&lt;br /&gt;
* '''color''': Team color used for ellipses, sprites, and flags. Will be one of the id's found in data/core/team-colors.cfg or a custom color defined by [[GameConfigWML#Color_Palettes|[color_range]]].&lt;br /&gt;
* '''controller''': Indicates type of player that control this side. ''Note: In networked multiplayer, the controller attribute may not be the same on all clients. Be very careful or you have OOS errors.''&lt;br /&gt;
** '''human''': Human player&lt;br /&gt;
** '''ai''': If players assigns &amp;quot;Computer Player&amp;quot; to &amp;quot;Player/Type&amp;quot; in game lobby&lt;br /&gt;
** '''null''': If players assigns &amp;quot;Empty&amp;quot; to &amp;quot;Player/Type&amp;quot; in game lobby&lt;br /&gt;
* '''fog''': Indicates whether this side is affected by fog of war.&lt;br /&gt;
* '''gold''': The amount of gold the side has.&lt;br /&gt;
* '''hidden''': (boolean) If 'yes', side is not shown in status table.&lt;br /&gt;
* '''income''': Income for this side (base income + all village income. AKA gross income. Note that this is different from the [side] income key).&lt;br /&gt;
* '''name''': Name of player.&lt;br /&gt;
* '''recruit''': A comma-separated list of unit types that can be recruited by this side.&lt;br /&gt;
* '''shroud''': Whether this side is affected by shroud.&lt;br /&gt;
* '''side''': The $side_number of the side belonging to this container&lt;br /&gt;
* '''side_name''': Translated string representing the side's description.&lt;br /&gt;
* '''team_name''': String representing the team's description. Sides with the same team_name are allied.&lt;br /&gt;
* '''user_team_name''': Translated string representing the team's description.&lt;br /&gt;
* '''village_gold''': The amount of gold given to this side per village it controls per turn.&lt;br /&gt;
* '''scroll_to_leader''': (boolean) Whether the game view scrolls to the side leader at the start of their turn.&lt;br /&gt;
* '''flag''': Flag animation for villages owned by this side (see [[SideWML|[side]]]). Unless previously specified in [side] or changed with WML (see [[DirectActionsWML#.5Bmodify_side.5D|[modify_side]]]), this value may be empty for the default flag animation.&lt;br /&gt;
* '''flag_icon''': Flag icon for the status bar for this side (see [[SideWML|[side]]]). Unless previously specified in [side] or changed with WML (see [[DirectActionsWML#.5Bmodify_side.5D|[modify_side]]]), this value may be empty for the default flag icon.&lt;br /&gt;
* '''village_support''': The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.&lt;br /&gt;
* '''defeat_condition''': {{DevFeature1.13|7}} When the side will be considered defeated. See description at [[SideWML]], [[ScenarioWML#Scenario_End_Conditions]]&lt;br /&gt;
* '''faction''': {{DevFeature1.13|7}} id of the selected faction, string (multiplayer-only)&lt;br /&gt;
* '''faction_name''': {{DevFeature1.13|7}} Name of the selected faction, string (multiplayer-only)&lt;br /&gt;
* '''num_units''' {{DevFeature1.13|7}}: The number of units the side currently has on the map.&lt;br /&gt;
* '''num_villages''' {{DevFeature1.13|7}}: The number of villages the side currently controls.&lt;br /&gt;
* '''total_upkeep''' {{DevFeature1.13|7}}: The number of unit levels the side is currently supporting.&lt;br /&gt;
* '''expenses''' {{DevFeature1.13|7}}: The amount of gold the side is currently spending to support units.&lt;br /&gt;
* '''net_income''' {{DevFeature1.13|7}}: The income the side gains per turn after expenses.&lt;br /&gt;
* '''base_income''' {{DevFeature1.13|8}}: The income the side gains per turn (same as [side] income key)&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.13|7}} All other keys and tags of the side that are contained in [[LuaWML:Sides#wesnoth.sides|wesnoth.sides]] .__cfg&lt;br /&gt;
&lt;br /&gt;
==== [store_starting_location] ====&lt;br /&gt;
&lt;br /&gt;
Stores the starting location of a side's leader in a variable. The variable is a composite type which will have members 'x', 'y', 'terrain' and 'owner_side' (villages only)&lt;br /&gt;
&lt;br /&gt;
* [[StandardSideFilter]]: The starting locations of all matching sides will be stored. If multiple sides are matched, a WML array will be created.&lt;br /&gt;
* '''variable''': (default='location'): the name of the variable to store the location in&lt;br /&gt;
* '''mode''':{{DevFeature1.13|0}} defaults to ''always_clear'', which clears the variable, whether or not a match is found. If mode is set to ''replace'', the variable will not be cleared, and the starting locations of the sides which match the filter will overwrite existing elements at the start of the array, leaving any additional elements intact if the original array contained more elements than there are locations matching the filter. If mode is set to ''append'', the variable will not be cleared, and the starting locations of the matching sides will be added to the array after the existing elements.&lt;br /&gt;
&lt;br /&gt;
==== [store_time_of_day] ====&lt;br /&gt;
&lt;br /&gt;
Stores time of day information from the current scenario into a WML variable container.&lt;br /&gt;
&lt;br /&gt;
* '''x, y''': Location to store the time for. [[DirectActionsWML#.5Btime_area.5D|Time areas]] matter; illumination does not. If this is omitted, the global (location-independent) time is stored.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': (default='time_of_day') name of the container on which to store the information. The container will be filled with the same attributes found on [[TimeWML]].&lt;br /&gt;
&lt;br /&gt;
* '''turn''': (defaults to the current turn number) changes the turn number for which time of day information should be retrieved.&lt;br /&gt;
&lt;br /&gt;
==== [store_turns] ====&lt;br /&gt;
&lt;br /&gt;
Stores the turn limit (the maximum number of turns). If there is no limit, this stores ''-1''.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': (default='turns') the name of the variable in which to store the turn limit.&lt;br /&gt;
&lt;br /&gt;
==== [store_unit] ====&lt;br /&gt;
&lt;br /&gt;
Stores details about units into a [[VariablesWML#Container|container]] variable. When a unit is stored, all keys and tags in the unit definition may be manipulated, including some others, with [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]]. A sample '''list of these tags and keys''' can be found at [[InternalActionsWMLUnitTags]].&lt;br /&gt;
&lt;br /&gt;
If you have a doubt about what keys are valid or what the valid value range is for each key, code a [store_unit] event, save the game, and examine what keys are in the file (or just examine the '''[unit]''' tag(s) in any save file). One can also use the [[CommandMode|:inspect]] command or the [[InterfaceActionsWML#.5Binspect.5D|[inspect]]] tag to open a game-state inspector dialog, which can be used to view unit properties.&lt;br /&gt;
&lt;br /&gt;
Common usage is to manipulate a unit by using '''[store_unit]''' to store it into a variable, followed by manipulation of the variable, and then [[DirectActionsWML#.5Bunstore_unit.5D|[unstore_unit]]] to re-create the unit with the modified variables.&lt;br /&gt;
&lt;br /&gt;
''Note: stored units also exist on the field, and modifying the stored variable will not automatically change the stats of the units. You need to use [unstore_unit]. See also [[DirectActionsWML#.5Bunstore_unit.5D|[unstore_unit]]] and [[ConditionalActionsWML#.5Bforeach.5D|[foreach]]].&lt;br /&gt;
&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. All units matching this filter will be stored. If there are multiple units, they will be stored into an array of variables. The units will be stored in order of their internal ''underlying_id'' attribute, which is usually in creation order (but you normally should not depend on the order).&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable into which to store the unit(s)&lt;br /&gt;
&lt;br /&gt;
* '''mode''': defaults to ''always_clear'', which clears the variable, whether or not a match is found. If mode is set to ''replace'', the variable will not be cleared, and units which match the filter will overwrite existing elements at the start of the array, leaving any additional elements intact if the original array contained more elements than there are units matching the filter. If mode is set to ''append'', the variable will not be cleared, and units which match the filter will be added to the array after the existing elements.&lt;br /&gt;
&lt;br /&gt;
* '''kill''': if 'yes' the units that are stored will be removed from play. This is useful for instance to remove access to a player's recall list, with the intent to restore the recall list later.&lt;br /&gt;
&lt;br /&gt;
==== [store_unit_defense] ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|7}} Fixed, was broken in 1.15.3&lt;br /&gt;
&lt;br /&gt;
Stores in a variable the defense of a unit on a particular terrain. If terrain or location is not specified, the terrain on which the unit currently stands is used. (Note: it is a WML defense, so the higher it is, the weaker unit's defense is. A footpad on castle has 70% defense, so this function stores the value 30.)&lt;br /&gt;
&lt;br /&gt;
* StandardUnitFilter&lt;br /&gt;
* '''loc_x''', '''loc_y''': x and y of a valid map location. The terrain on this location will be used for the defense calculation.&lt;br /&gt;
* '''terrain''': The terrain code for which unit defense should be calculated. If '''terrain''' is specified, '''loc_x''' and '''loc_y''' are ignored.&lt;br /&gt;
* '''variable''': the name of the variable into which to store the defense. default: &amp;quot;terrain_defense&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== [store_unit_defense_on] ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|7}} Similar to [store_unit_defense], but stores the same number that would be shown in the UI. For example, a footpad on castle has 70% defense, so this stores the value 70.&lt;br /&gt;
&lt;br /&gt;
Takes the same attributes as [store_unit_defense], and defaults to storing the value in &amp;quot;terrain_defense&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== [store_unit_type] ====&lt;br /&gt;
&lt;br /&gt;
Stores a unit type definition into a variable.&lt;br /&gt;
&lt;br /&gt;
* '''type''': (required) the defined ID of the unit type, for example &amp;quot;Goblin Knight&amp;quot;. Do not use a translation mark or it will not work correctly for different languages. A comma-separated list of IDs may also be used to store an array of unit types.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable into which to store the unit type information (default &amp;quot;unit_type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* '''mode''':{{DevFeature1.13|0}} defaults to ''always_clear'', which clears the variable. If mode is set to ''replace'', the variable will not be cleared, and the unit type will overwrite the existing element at the start of the array, leaving any additional elements intact if the original array contained more elements. If mode is set to ''append'', the variable will not be cleared, and the unit type will be added to the array after the existing elements.&lt;br /&gt;
&lt;br /&gt;
==== [store_unit_type_ids] ====&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable into which to store a comma-separated list of all unit type IDs including all from all loaded addons&lt;br /&gt;
&lt;br /&gt;
==== [store_villages] ====&lt;br /&gt;
&lt;br /&gt;
Stores a series of locations of villages that pass certain criteria into an array. Each member of the result array will have members 'x' and 'y' (the position) and 'terrain' (the terrain type) and 'owner_side'.&lt;br /&gt;
&lt;br /&gt;
Note: This differs from using [store_locations] only in that the hexes considered for match are restricted to those with villages (those whose terrain type has its 'gives_income' flag set to true), in the same way that use of either the 'owner_side' key or the '[filter_owner]' will. In fact, if either of these are present, [store_villages] and [store_locations] will behave identically.&lt;br /&gt;
&lt;br /&gt;
* '''variable''': the name of the variable (array) into which to store the locations (default: &amp;quot;location&amp;quot;)&lt;br /&gt;
* '''[[StandardLocationFilter]]''' tags and keys as arguments&lt;br /&gt;
&lt;br /&gt;
==== [store_items] ====&lt;br /&gt;
&lt;br /&gt;
Stores current items in the scenario into an array. Each entry has at least members x and y and can have all of the other keys listed in the documentation of [[InterfaceActionsWML#.5Bitem.5D|[item]]] (depending on what was set during creating the item).&lt;br /&gt;
&lt;br /&gt;
*'''variable''': name of the wml variable array to use (default &amp;quot;items&amp;quot;)&lt;br /&gt;
*'''[[StandardLocationFilter]]''' keys as arguments: only items on locations matching this [[StandardLocationFilter]] will be stored&lt;br /&gt;
*'''item_name''': {{DevFeature1.15|0}} if given, only items created with a matching '''[item]name=''' will be stored. As of 1.15.0, this does not support comma-separated lists.&lt;br /&gt;
&lt;br /&gt;
==== [store_relative_direction] ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Gets the relative direction from one hex to another. This is an interface to the function wesnoth uses to decide how a unit will face while it is moving / attacking / defending.&lt;br /&gt;
&lt;br /&gt;
* '''[source]''' x and y must describe a map location&lt;br /&gt;
* '''[destination]''' similar&lt;br /&gt;
* '''variable''' name of the variable to store string result in (one of 'n', 'nw', 'ne', 's', 'sw', 'se')&lt;br /&gt;
* '''mode''' optional. 0 is the default setting corresponding to default wesnoth implementation used in animations. 1 is an alternate &amp;quot;radially symmetric&amp;quot; mode. The default mode breaks ties in the direction of south, since this makes more units face the player directly on screen. The radially symmetric mode breaks ties in the direction of counter-clockwise, and might be more appropriate in some cases.&lt;br /&gt;
&lt;br /&gt;
==== [find_path] ====&lt;br /&gt;
&lt;br /&gt;
A WML interface to the pathfinder. Calculates the path between a unit and a location and returns the result in a WML variable, that contains also an array for every step of the path (including the starting hex).&lt;br /&gt;
&lt;br /&gt;
*'''[traveler]''': [[StandardUnitFilter]], only the first matching unit will be used for calculation&lt;br /&gt;
*'''[destination]''': [[StandardLocationFilter]]&lt;br /&gt;
*'''variable''': the variable name where the result will be stored, if no value is supplied 'path' will be used as default name. Each step will be stored in a [step] array inside that variable.&lt;br /&gt;
*'''allow_multiple_turns''': default no, if yes also moves that require more than one turn will be calculated.&lt;br /&gt;
*'''check_visibility''': default no, if yes the path will not be computed if some hexes are not visible due to shroud.&lt;br /&gt;
*'''check_teleport''': default yes; if no, teleport won't be taken in account while computing path.&lt;br /&gt;
*'''check_zoc''': default yes; if no, unit ZOCs won't be considered while calculating the path.&lt;br /&gt;
*'''nearest_by''': {{DevFeature1.15|2}} possible values &amp;quot;movement_cost&amp;quot; (default), &amp;quot;steps&amp;quot;, &amp;quot;hexes&amp;quot;; if the [destination] SLF matches multiple hexes, the one that would need the least movement points to reach may not be the one that's closest as measured by '''hexes''', or closest as measured by steps, from the starting point. This option chooses which measurement to prefer.&lt;br /&gt;
&lt;br /&gt;
More detail about multiple destinations and the return structure is on [[FindPathExplanation]] (moved out of this page because it has an image in it).&lt;br /&gt;
&lt;br /&gt;
This is the structure of the variable returned by [find_path]:&lt;br /&gt;
 [path]&lt;br /&gt;
 	hexes = non-zero if a path was successfully found.&lt;br /&gt;
 		if the path is calculated to an impassable hex, or the move requires multiple turns&lt;br /&gt;
 		and allow_multiple_turns is no, its value will be 0.&lt;br /&gt;
 	from_x, from_y = location of the unit&lt;br /&gt;
 	to_x, to_y = destination&lt;br /&gt;
 	movement_cost = total movement cost required by unit to reach that hex&lt;br /&gt;
 	required_turns = total turns required by unit to reach that hex&lt;br /&gt;
 	[step]&lt;br /&gt;
 		x, y = location of the step&lt;br /&gt;
 		terrain = terrain of the step&lt;br /&gt;
 		movement_cost = movement cost required by unit to reach that hex&lt;br /&gt;
 		required_turns = turns required by unit to reach that hex&lt;br /&gt;
 	[/step]&lt;br /&gt;
 [/path]&lt;br /&gt;
&lt;br /&gt;
==== [unit_worth] ====&lt;br /&gt;
Takes only an inline [[StandardUnitFilter]] (only the first matching unit will be used for the calculation) and outputs the following variables: &lt;br /&gt;
*'''cost''': the current unit cost&lt;br /&gt;
*'''next_cost''': the cost of the most expensive advancement&lt;br /&gt;
*'''health''': the health of the unit in percentage&lt;br /&gt;
*'''experience''': current experience in percentage&lt;br /&gt;
*'''unit_worth''': how much the unit is worth&lt;br /&gt;
&lt;br /&gt;
Mainly used for internal AI checks, but one could in theory just do anything with it.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     [unit_worth]&lt;br /&gt;
        x,y=$x1,$y1&lt;br /&gt;
     [/unit_worth]&lt;br /&gt;
     [message]&lt;br /&gt;
         id=$unit.id&lt;br /&gt;
         message=_&amp;quot;I cost $cost gold, with $health|% of my hitpoints and $experience|% on the way to cost $next_cost|.&lt;br /&gt;
 I am estimated to be worth $unit_worth&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [clear_variable]&lt;br /&gt;
         name=cost,next_cost,health,experience,unit_worth&lt;br /&gt;
     [/clear_variable]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
=== [clear_variable] ===&lt;br /&gt;
&lt;br /&gt;
This will delete the given variable. This tag can delete a scalar or an entire array; it can also delete one container at an array index. The macro [https://www.wesnoth.org/macro-reference.html#CLEAR_VARIABLE CLEAR_VARIABLE] is a shortcut for this tag.&lt;br /&gt;
&lt;br /&gt;
This action is good to use to clean up the set of variables; for example, a well-behaved scenario will delete any variables that should not be kept for the next scenario before the end of the scenario. One can also clear tags and variables of stored units; for example, one can remove [trait]s and [object]s.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of the variable to clear. This can also be a comma-separated list of multiple variable names.&lt;br /&gt;
** If a name ends with an array index, then it deletes that one container, and shifts the indexes of all subsequent containers. For example, &amp;lt;code&amp;gt;{CLEAR_VARIABLE my_awesome_array[2]}&amp;lt;/code&amp;gt; deletes &amp;lt;code&amp;gt;my_awesome_array[2]&amp;lt;/code&amp;gt;, but then moves &amp;lt;code&amp;gt;my_awesome_array[3]&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;my_awesome_array[2]&amp;lt;/code&amp;gt;, moves &amp;lt;code&amp;gt;my_awesome_array[4]&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;my_awesome_array[3]&amp;lt;/code&amp;gt;, and so on until the end of the array.&lt;br /&gt;
** Note that &amp;lt;code&amp;gt;{CLEAR_VARIABLE my_awesome_array}&amp;lt;/code&amp;gt; deletes the entire array, but &amp;lt;code&amp;gt;{CLEAR_VARIABLE my_awesome_array[0]}&amp;lt;/code&amp;gt; deletes only the first container.&lt;br /&gt;
&lt;br /&gt;
=== [sync_variable] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Sets one or multiple variables to the same value as on all clients and also on replays, it uses the value from the currently active side.&lt;br /&gt;
* '''name''' the name of the variable to synchonize this can be a comma seperated list.&lt;br /&gt;
&lt;br /&gt;
== Other Internal Actions ==&lt;br /&gt;
&lt;br /&gt;
Believe it or not, there are some internal actions that are not focused primarily on variables. They are all grouped here.&lt;br /&gt;
&lt;br /&gt;
=== [fire_event] ===&lt;br /&gt;
&lt;br /&gt;
Trigger a WML event (used often for [[EventWML#Custom_events|custom events]])&lt;br /&gt;
&lt;br /&gt;
* '''name''': the name of event to trigger&lt;br /&gt;
** ''(Optional)'' {{DevFeature1.13|6}}&lt;br /&gt;
&lt;br /&gt;
* '''id''': ''(Optional)'' the id of a single event to trigger {{DevFeature1.13|6}}&lt;br /&gt;
&lt;br /&gt;
* '''[primary_unit]''': ''(Optional)'' Primary unit for the event. Will never match on a recall list unit. The first unit matching the filter will be chosen.&lt;br /&gt;
**[[StandardUnitFilter]] as argument. Do not use a [filter] tag.&lt;br /&gt;
&lt;br /&gt;
* '''[secondary_unit]''': ''(Optional)'' Same as '''[primary_unit]''' except for the secondary unit.&lt;br /&gt;
**[[StandardUnitFilter]] as argument. Do not use a [filter] tag.&lt;br /&gt;
&lt;br /&gt;
* '''[primary_attack]''': Information passed to the primary attack filter and $weapon variable on the new event.&lt;br /&gt;
&lt;br /&gt;
* '''[secondary_attack]''': Information passed to the second attack filter and $second_weapon variable on the new event.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.17|6}} '''[data]''': Additional arbitrary data to pass to the event. In addition to passing custom data, this can be used to set the '''damage_inflicted''' in an attack event or the '''owner_side''' in a village capture event. Values can be used by Lua. {{DevFeature1.19|9}} Values can be accessed as $data.&lt;br /&gt;
&lt;br /&gt;
=== [remove_event] ===&lt;br /&gt;
{{DevFeature1.13|0}} Removes the event with the specified id.&lt;br /&gt;
&lt;br /&gt;
* '''id''': the id of the event to remove. May be a comma separated list.&lt;br /&gt;
&lt;br /&gt;
=== [role] ===&lt;br /&gt;
&lt;br /&gt;
Tries to find a unit to assign a role to.&amp;lt;br&amp;gt;This is useful if you want to choose a non-major character to say some things during the game. Once a role is assigned, you can use '''role=''' in a unit filter to identify the unit with that role (See [[FilterWML]]).&amp;lt;br&amp;gt;However, there is no guarantee that roles will ever be assigned. You can use '''[have_unit]''' (see [[ConditionalActionsWML#Condition_Tags|Condition Tags]]) to see whether a role was assigned. This tag uses a [[StandardUnitFilter]] (without [filter]) with the modification to order the search by type, mark only the first unit found with the role, and the role attribute is not used in the search. If for some reason you want to search for units that have or don't have existing roles, you can use one or more [not] filters. The will check recall lists in addition to units on the map. In normal use, you will probably want to include a ''side'' attribute to force the unit to be on a particular side.&lt;br /&gt;
&lt;br /&gt;
* '''role''': the value to store as the unit's role. This role is not used in the [[StandardUnitFilter]] when doing the search for the unit to assign this role to.&lt;br /&gt;
&lt;br /&gt;
* '''type''': a comma-separated list of possible types the unit can be. If any types are given, then units will be searched by type in the order listed. If no type is given, then no particular order with respect to type is guaranteed.&lt;br /&gt;
&lt;br /&gt;
* '''reassign''': {{DevFeature1.13|6}} Can be either yes or no, defaults to yes. If set to '''no''' then first search for a unit that already has this role, and if found use that unit.&lt;br /&gt;
&lt;br /&gt;
* '''search_recall_list''': {{DevFeature1.13|5}} whether to consider units on the recall list when assigning the role. Can be either yes or no, defaults to yes. {{DevFeature1.13|6}} If set to 'only', then units on the map are not considered when assigning the role - only units on the recall list can receive it. If '''reassign''' is '''no''', this setting also affects the search for a unit that already has the role.&lt;br /&gt;
&lt;br /&gt;
* '''[else]''' {{DevFeature1.13|5}} ActionWML to execute if the game is unable to find a unit to assign the role to. For example, this could be used to create a new unit satisfying the role.&lt;br /&gt;
&lt;br /&gt;
* {{anchor|auto_recall|'''[auto_recall]'''}}: {{DevFeature1.13|6}} If present, and the role is assigned to a unit on the recall list, then that unit is recalled. Supports all unique keys of [[DirectActionsWML#.5Brecall.5D|&amp;amp;#x5b;recall&amp;amp;#x5d;]], but no [[StandardUnitFilter]].&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]], do not use a [filter] sub-tag. SUF's role= and type= keys are not used: if you want to use them, use a nested SUF wrapped inside a [and] tag.&lt;br /&gt;
&lt;br /&gt;
=== [random_placement] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Selects randomly a given number of locations from a given set of locations and exectutes the given code for each of those locations.&lt;br /&gt;
&lt;br /&gt;
* '''[filter_location]''': a [[StandardLocationFilter]].&lt;br /&gt;
* '''[command]''': contains ActionWml that is executed for each of the locations.&lt;br /&gt;
* '''num_items''': the number of locations that should be selected. There are several ways of specifying this:&lt;br /&gt;
** An integer, giving the exact number of locations to use. (Variable substitution is supported too.)&lt;br /&gt;
** {{DevFeature1.15|0}} A percentage, meaning that fraction of the total available spaces.&lt;br /&gt;
** {{DevFeature1.15|0}} A [[Wesnoth_Formula_Language|WFL]] formula. It has access to one variable, ''size'', which is the total number of available spaces. In order to identify it as a WFL formula, the entire expression must be enclosed in parentheses. (Do not use a '''$''', as that will cause it to see ''size'' as zero.)&lt;br /&gt;
** A Lua expression. As with a WFL expression, it can access the ''size'' variable. {{DevFeature1.15|0}} This is now deprecated.&lt;br /&gt;
* '''variable''': The name of the variable that contains the current location during the execution of [command]. This is a container with the attributes x, y, n and terrain.&lt;br /&gt;
* '''min_distance''': The minimum distance of 2 chosen locations, a value less than 0 means that the same locations can be chosen more than one time.&lt;br /&gt;
* '''allow_less''': If yes, the tag will not show an error in case there were less than num_items locations available.&lt;br /&gt;
&lt;br /&gt;
=== Flow control actions ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
There are three actions that alter the flow of execution. They are '''[break]''', '''[continue]''', and '''[return]'''. All of them take no arguments.&lt;br /&gt;
&lt;br /&gt;
* '''[break]''': The nearest enclosing loop immediately stops executing, and control continues with the next action after the end of that loop. If there is no enclosing loop, this is equivalent to '''[return]'''.&lt;br /&gt;
* '''[continue]''': The nearest enclosing loop immediately stops executing, and control continues at the beginning of that loop, with any iteration variables updated for the next iteration. If there is no enclosing loop, this is an error.&lt;br /&gt;
* '''[return]''': Control immediately returns to the Wesnoth engine. This completely exits the current event, including any nested events, such that the [message] will not be displayed in the below example. No further WML actions are executed in this context. Any separate, subsequent events will be run as usual.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
   name=moveto&lt;br /&gt;
   [fire_event]&lt;br /&gt;
      name=return_please&lt;br /&gt;
   [/fire_event]&lt;br /&gt;
   [message]&lt;br /&gt;
     message=&amp;quot;Made it back&amp;quot;&lt;br /&gt;
   [/message]&lt;br /&gt;
[/event]&lt;br /&gt;
[event]&lt;br /&gt;
   name=return_please&lt;br /&gt;
   [return][/return]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [unsynced] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Runs the contained actionwml in a unsynced context, that means actions performed inside [unsynced] are not synced over the network. for example &lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
   name=moveto&lt;br /&gt;
   {VARIABLE_OP message rand &amp;quot;Hi,Hello,How are you?&amp;quot;}&lt;br /&gt;
   [message]&lt;br /&gt;
      message = $message&lt;br /&gt;
   [/message]&lt;br /&gt;
   {CLEAR_VARIABLE message}&lt;br /&gt;
   [allow_undo]&lt;br /&gt;
   [/allow_undo]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will print the same message to all clients, but also disallow undoing (regardless of [allow_undo]) for that moveto becasue it requests a synced random seed form the server. However this code&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
   name=moveto&lt;br /&gt;
   [unsynced]&lt;br /&gt;
      {VARIABLE_OP message rand &amp;quot;Hi,Hello,How are you?&amp;quot;}&lt;br /&gt;
      [message]&lt;br /&gt;
         message = $message&lt;br /&gt;
      [/message]&lt;br /&gt;
      {CLEAR_VARIABLE message}&lt;br /&gt;
   [/unsynced]&lt;br /&gt;
   [allow_undo]&lt;br /&gt;
   [/allow_undo]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will not prevent undoing, but might print a different message for each client in a multiplayer game (or during a sp replay), so `[unsynced]` should not be used for actions that actually change the gamestate otherwise you'll get OOS&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Using [set_variables] to Create Arrays of WML ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[set_variables]&lt;br /&gt;
    name=arr&lt;br /&gt;
    mode=replace&lt;br /&gt;
    [value]&lt;br /&gt;
        foo=bar&lt;br /&gt;
    [/value]&lt;br /&gt;
    [value]&lt;br /&gt;
       foo=more&lt;br /&gt;
    [/value]&lt;br /&gt;
[/set_variables]&lt;br /&gt;
{DEBUG_MSG $arr[0].foo}&lt;br /&gt;
{DEBUG_MSG $arr[1].foo}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will produce two output messages, first one saying '''bar''' and next one saying '''more'''.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[VariablesWML]]&lt;br /&gt;
* [[ActionWML]]&lt;br /&gt;
** [[ConditionalWML]]&lt;br /&gt;
** [[DirectActionsWML]]&lt;br /&gt;
** [[InterfaceActionsWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Wesnoth_Formula_Language&amp;diff=74134</id>
		<title>Wesnoth Formula Language</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Wesnoth_Formula_Language&amp;diff=74134"/>
		<updated>2025-01-23T20:47:02Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Strings */ string to list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Wesnoth Formula Language is a functional language used to evaluate expressions within the game engine. It allows performing calculations that would not otherwise be possible using only WML. For example, to have an event trigger when a unit has less than half its hitpoints, you could write the following as the event's filter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[filter]&lt;br /&gt;
    formula = &amp;quot;(hitpoints &amp;lt; max_hitpoints / 2)&amp;quot;&lt;br /&gt;
[/filter]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''formula''' key is a part of [[StandardUnitFilter]] that accepts a condition written as WFL. The part inside the quotes is the WFL formula. This example will evaluate to true if the unit's '''hitpoints''' are less than half its '''max_hitpoints'''.&lt;br /&gt;
&lt;br /&gt;
== Data Types and Operators ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth Formula Language has seven basic data types – [[#Numbers|integers]], [[#Numbers|real numbers]] (usually called &amp;quot;decimals&amp;quot;), [[#Strings|strings]], [[#Lists|lists]], [[#Maps|maps]], [[#Objects|objects]], and [[#Other Types and Operators|null]].&lt;br /&gt;
&lt;br /&gt;
=== Numbers ===&lt;br /&gt;
&lt;br /&gt;
The most common use of WFL is for simple calculations involving numbers. For this, the standard arithmetic operators (&amp;lt;code&amp;gt;+ - * / %&amp;lt;/code&amp;gt;) work as you would expect, performing addition, subtraction, multiplication, division, and remainder. {{DevFeature1.13|5}} The remainder operator even works on decimal numbers, producing the integer remainder of the division.&lt;br /&gt;
&lt;br /&gt;
The only caveat to watch out for is that &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; rounds down when used on integers. For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;5 / 2&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;. To avoid this, make sure at least one of the numbers includes a decimal point - &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;5.0 / 2&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;2.5&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that WFL supports only three decimal places of precision for decimal numbers; beyond that it will still be rounded down. (So &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;1.0 / 16&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;0.062&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;0.0625&amp;lt;/code&amp;gt;.) The &amp;lt;code&amp;gt;^&amp;lt;/code&amp;gt; operator performs exponentiation (raising to a power) - for example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;2 ^ 3&amp;lt;/syntaxhighlight&amp;gt; evaluates to &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also use the standard comparison operators (&amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;=&amp;lt;/code&amp;gt;) on numbers. This is often useful in unit filters - for example, a formula of &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;hitpoints &amp;lt; max_hitpoints / 2&amp;lt;/syntaxhighlight&amp;gt; will match only if the unit is at less than half health. Comparison operators return 1 for true and 0 for false; there is no boolean type. Comparing values of different types will always return 0, with one exception – comparing an integer and decimal number will work as expected.&lt;br /&gt;
&lt;br /&gt;
One final numeric operator exists - the dice roll. The syntax &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;3d12&amp;lt;/syntaxhighlight&amp;gt; will roll three 12-sided dice and return the sum of the results. Note however that this is not multiplayer-safe, so using it can and will produce OOS errors. {{DevFeature1.13|5}} The dice operator is now synced and should be safe for use in multiplayer contexts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' {{DevFeature1.13|5}} Some numeric operations will return null instead of a number. This usually involves the exponentiation operator - for example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;(-2) ^ 0.5&amp;lt;/syntaxhighlight&amp;gt; attempts to take the square root of -2, which doesn't exist, so it returns null to indicate this. Dividing by zero also returns null, as well as certain [[#Numeric Functions|math functions]] in appropriate circumstances.&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
WFL also supports strings, which must be enclosed in single quotes (&amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;'like this'&amp;lt;/syntaxhighlight&amp;gt;). The comparison operators (&amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;=&amp;lt;/code&amp;gt;) also work on strings, performing lexicographical comparison (ie, alphabetical order). The comparison is case sensitive.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
Strings can be concatenated with the concatenation operator &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt;. They also support interpolations enclosed in square brackets, the contents of which can be any valid formula. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'Some text: [a + b]' where a = 12, b = 10&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
results in the string &amp;lt;code&amp;gt;Some text: 22&amp;lt;/code&amp;gt;. (The &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; operator is explained [[#Variables|below]].)&lt;br /&gt;
&lt;br /&gt;
If you need to include a literal square bracket in a string, write &amp;lt;code&amp;gt;[(]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;[)]&amp;lt;/code&amp;gt;. For a literal single quote, you can write &amp;lt;code&amp;gt;[']&amp;lt;/code&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'[(]It[']s bracketed![)]'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
results in the string &amp;lt;code&amp;gt;[It's bracketed!]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can index the characters or words of a string with the following syntax:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'Hello World'.char[4]&lt;br /&gt;
'Hello World'.word[1]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These return &amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;World&amp;lt;/code&amp;gt;, respectively. A third option is also available, &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt;, which splits the string on commas but allows parentheses to prevent a portion of the string from being split up. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'First Item,Second Item,Third Item'.item[1]&lt;br /&gt;
'a,b,(c,d,e),f,g'.item[2]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These return &amp;lt;code&amp;gt;Second Item&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;(c,d,e)&amp;lt;/code&amp;gt;, respectively. When not providing index, list is returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'a,b,(c,d,e),f,g'.item = ['a', 'b', '(c,d,e)', 'f', 'g']&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lists ===&lt;br /&gt;
&lt;br /&gt;
A list is a sequence of values represented as square brackets, [], surrounding a comma-separated list. For instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[ 1, 5, 'abc' ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The comparison operators work on lists, performing lexicographical comparison. A specific list index can be obtained with the indexing operator, like this: &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;my_list[index]&amp;lt;/syntaxhighlight&amp;gt;. The first element of a list is numbered 0.&lt;br /&gt;
&lt;br /&gt;
There are four ''vector operators'' (&amp;lt;code&amp;gt;.+ .- .* ./&amp;lt;/code&amp;gt;) that perform entrywise operations on lists. For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;[1,2,3] .+ [12,2,8]&amp;lt;/syntaxhighlight&amp;gt; produces &amp;lt;code&amp;gt;[13,4,11]&amp;lt;/code&amp;gt;. Both lists must be of the same length to use these operators, and of course, they must contain only numbers.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
A negative list index now counts from the end of the list - &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; refers to the last element. You can check if an element exists in a list using the &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; operator. Lists can also be joined with the concatenation operator &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt;, and sliced using the range operator &amp;lt;code&amp;gt;~&amp;lt;/code&amp;gt;. In fact, the range operator produces a list of consecutive numbers, and in fact any list of numbers can be used to index a list - the result is to take the elements at the requested indices, in order. Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[1, 7, 'abc', 2.5, 'foobar', 127][1~3]&lt;br /&gt;
(10~20)[[0,-1]]&lt;br /&gt;
[1, 7, 'abc', 2.5, 'foobar', 127][[2,4]]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These result in the following lists:&lt;br /&gt;
&lt;br /&gt;
 [7, 'abc', 2.5]&lt;br /&gt;
 [10,20]&lt;br /&gt;
 ['abc', 'foobar']&lt;br /&gt;
&lt;br /&gt;
=== Maps ===&lt;br /&gt;
&lt;br /&gt;
A map is a sequence of key-value pairs. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[12 -&amp;gt; 'Hello', [1,2] -&amp;gt; 9, 'abc' -&amp;gt; 1.5]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The comparison operators work on maps. A specific element of a map can be obtained with the indexing operation. In the above example, the following conditions are all true (assuming the map is in a variable called &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self[12] = 'Hello'&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self[[1,2]] = 9&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self['abc'] = 1.5&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
You can now use the &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; operator to test if a key exists in the map. You can also access string keys using the dot operator &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as long as they are valid identifiers. (Valid identifiers contain letters and underscores only; no digits are permitted.)&lt;br /&gt;
&lt;br /&gt;
Note that the selection indexing that lists use is ''not'' valid for maps - a list can be used as a key, after all.&lt;br /&gt;
&lt;br /&gt;
=== Objects ===&lt;br /&gt;
&lt;br /&gt;
An object is a container containing additional variables (see [[#Variables|below]] for further explanation of variables) which are not in the global scope. The ''dot operator'' can be used to evaluate a formula in the object's scope. For example, suppose ''u'' is a unit object referring to your leader, who is an Elvish Ranger who has taken 12 damage (thus has 30 hit points). Then &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u.hitpoints&amp;lt;/syntaxhighlight&amp;gt; will evaluate to the number 30. For a more advanced example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u . (hitpoints &amp;lt; max_hitpoints - 10)&amp;lt;/syntaxhighlight&amp;gt; will evaluate to true if the unit has taken more than 10 damage, which in this example, it has. (This could also be written &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u.hitpoints &amp;lt; u.max_hitpoints - 10&amp;lt;/syntaxhighlight&amp;gt; if you prefer; this enters the scope twice, instead of once, but the result is identical.)&lt;br /&gt;
&lt;br /&gt;
Objects generally cannot be created directly by the code - they are created for you by the game when formulas are called in certain contexts. However, there are two types of object that ''can'' be created by your code. The first is the location object, which has variables ''x'' and ''y''; it can be created by the [[#loc|&amp;lt;code&amp;gt;loc()&amp;lt;/code&amp;gt;]] function. The second is the map pair object, which is returned (or used internally) by several of the built-in functions and has variables ''key'' and ''value''.&lt;br /&gt;
&lt;br /&gt;
==== Documentation of some common objects ====&lt;br /&gt;
&lt;br /&gt;
There are a number of common objects that are given as the context object for formulas throughout the engine. Not all of these will be available in all formulas, but many of them are available in more than one formula. To learn what objects are available in a given location, see the WML documentation of that location.&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter#Wesnoth_Formula_Language|unit objects]]&lt;br /&gt;
* [[FilterWML#Filtering_Weapons|weapon objects]]&lt;br /&gt;
* [[StandardLocationFilter#Wesnoth_Formula_Language|terrain objects]]&lt;br /&gt;
* [[StandardSideFilter#Wesnoth_Formula_Language|side objects]]&lt;br /&gt;
* [[ImagePathFunctions#CHAN:_General function|pixel objects]]&lt;br /&gt;
* [[ConditionalActionsWML#.5Bvariable.5D|WML objects]]&lt;br /&gt;
* [[EventWML#filter_formula|game state objects]]&lt;br /&gt;
&lt;br /&gt;
=== Other Types and Operators ===&lt;br /&gt;
&lt;br /&gt;
There is one other basic type in WFL - the null type, which is used to mean &amp;quot;no value&amp;quot;. It will be returned if you attempt to perform an invalid operation, such as dividing a string. It is also returned by the built-in &amp;lt;code&amp;gt;null()&amp;lt;/code&amp;gt; function, which allows you to test if a value is null by writing &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;value = null()&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logical operators &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; can be used to connect conditional expressions, and the unary operator &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt; negates them. Note that &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; is inclusive - &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;A or B&amp;lt;/syntaxhighlight&amp;gt; is false only if both ''A'' and ''B'' are false. These operators consider &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or null to be false, while all other values count as true. The [[#if|&amp;lt;code&amp;gt;if()&amp;lt;/code&amp;gt;]] function also follows the same rules to determine whether a value is true or false.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Programmers familiar with other languages may occasionally be surprised by the fact that &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; do not short-circuit (which would mean that they will never evaluate their second argument if they can know their result solely from the first argument). This should not be a problem in general formula usage, since functions do not have side-effects, but it could make a difference when using the debug functions.&lt;br /&gt;
&lt;br /&gt;
=== Operator Precedence ===&lt;br /&gt;
&lt;br /&gt;
The precedence of various operators is, more or less, what you'd expect - you can write something like &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a + b * 2 &amp;lt;= 5 and n - m / 4 &amp;gt; 7&amp;lt;/syntaxhighlight&amp;gt; and the engine will do what you expect - first multiplication and division, then addition and subtraction, then comparison, and finally logical conjunction. The only thing to watch out for is when chaining exponentiation - all operators are left associative, so &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a ^ b ^ c&amp;lt;/syntaxhighlight&amp;gt; will be evaluated as &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;(a ^ b) ^ c&amp;lt;/syntaxhighlight&amp;gt; instead of &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a ^ (b ^ c)&amp;lt;/syntaxhighlight&amp;gt; like you would expect. {{DevFeature1.13|5}} This has been fixed - exponentiation is now right-associative.&lt;br /&gt;
&lt;br /&gt;
The full precedence list is as follows, from lowest to highest; operators on the same line have equal precedence.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clauses&lt;br /&gt;
# &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt;&lt;br /&gt;
# Comparison operators &amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;= in&amp;lt;/code&amp;gt;&lt;br /&gt;
# Range-generating operator &amp;lt;code&amp;gt;~&amp;lt;/code&amp;gt;&lt;br /&gt;
# Additive operators &amp;lt;code&amp;gt;+ - ..&amp;lt;/code&amp;gt;&lt;br /&gt;
# Multiplicative operators &amp;lt;code&amp;gt;* /&amp;lt;/code&amp;gt;&lt;br /&gt;
# Modulus &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt;&lt;br /&gt;
# Exponentiation &amp;lt;code&amp;gt;^&amp;lt;/code&amp;gt;&lt;br /&gt;
# Dice operator &amp;lt;code&amp;gt;d&amp;lt;/code&amp;gt;&lt;br /&gt;
# Dot operator &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
WFL is a ''functional'' language, so of course it has functions. There is a large library of [[#Core Functions|built-in functions]], and you can also [[#Defining Functions|define your own]].&lt;br /&gt;
&lt;br /&gt;
Calling a function is simple, and works exactly how you would expect if you've worked with functions in a mathematical context: &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;clamp(value, 0, 21)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Being a functional language, WFL does not have conditional or looping statements. Instead, these are provided by functions. For a simple conditional, you can use the &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt; function, as in the following example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wfl&amp;gt;&lt;br /&gt;
if(hitpoints &amp;gt; 37,&lt;br /&gt;
    max_hitpoints / 2,&lt;br /&gt;
    hitpoints - 3&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, looping is done via functions. There are several built-in higher-order functions that can be used to iterate over lists and maps, such as &amp;lt;tt&amp;gt;filter&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;choose&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;map&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;reduce&amp;lt;/tt&amp;gt;. See the corresponding function definitions for more information.&lt;br /&gt;
&lt;br /&gt;
== Variables ==&lt;br /&gt;
&lt;br /&gt;
Formulas may have a variety of variables, depending on the context in which they are evaluated. A string substitution formula like &amp;lt;code&amp;gt;$(3 + 5)&amp;lt;/code&amp;gt; has no variables, but a [[StandardUnitFilter|unit filter]] formula has variables such as &amp;lt;code&amp;gt;hitpoints&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;max_hitpoints&amp;lt;/code&amp;gt; which contain various properties of the unit being tested (the same unit which is also referred to in variable substitution as &amp;lt;code&amp;gt;$this_unit&amp;lt;/code&amp;gt;). The special variable &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; typically refers to the &amp;quot;global context&amp;quot; - in the case of a unit filter formula, the unit itself. This means for example that &amp;lt;code&amp;gt;self.hitpoints&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hitpoints&amp;lt;/code&amp;gt; are equivalent when used in a unit filter formula. In a string substitution formula (the &amp;lt;code&amp;gt;$(formula)&amp;lt;/code&amp;gt; syntax), &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; is null. Because of this, you should prefer not to use the substitution syntax in places where formulas are specifically supported.&lt;br /&gt;
&lt;br /&gt;
A formula may declare additional variables using a &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clause. This assigns a meaning to any unknown variables in the preceding formula. The general syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;formula&amp;gt; where &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt; [, &amp;lt;variable&amp;gt; = value ...]&lt;br /&gt;
&lt;br /&gt;
This functions similarly to an operator, so if desired, you could have multiple where clauses in a single formula. Note that all variables in WFL are read-only - they are variables because they may have different values depending on the context in which the formula is evaluated, but for a given context, they are constant. A variable that has not been assigned a value is considered to have a value of null. Variables are lazily-evaluated - if a where clause declares a variable that is never used, the expression assigned to it will never be evaluated. (This only really matters if it contains a call to a debug function.)&lt;br /&gt;
&lt;br /&gt;
Variable names can contain letters and underscores only. In particular, they cannot contain digits. Also, names are case-sensitive, so ''y'' and ''Y'' refer to two different variables. The following names are reserved and cannot be used for the name of a variable or function:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;d&amp;lt;/tt&amp;gt; - dice operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;or&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; - containment operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;def&amp;lt;/tt&amp;gt; - defines a function&lt;br /&gt;
* &amp;lt;tt&amp;gt;and&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;not&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;fai&amp;lt;/tt&amp;gt; - deprecated synonym of &amp;lt;tt&amp;gt;wfl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;wfl&amp;lt;/tt&amp;gt; - declares filename&lt;br /&gt;
* &amp;lt;tt&amp;gt;where&amp;lt;/tt&amp;gt; - declares variables&lt;br /&gt;
* &amp;lt;tt&amp;gt;faiend&amp;lt;/tt&amp;gt; - deprecated synonym of &amp;lt;tt&amp;gt;wflend&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;wflend&amp;lt;/tt&amp;gt; - closes file scope&lt;br /&gt;
* &amp;lt;tt&amp;gt;functions&amp;lt;/tt&amp;gt; - lists all defined functions&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
&lt;br /&gt;
Sometimes with particularly complicated formulas, it may be useful to document what's going on inline. Of course, you can use WML comments to do this, but in some cases it may be useful to put some comments in the middle of the formula. This is easily done - simply enclose them in &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; characters, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
#This is a Wesnoth Formula Language comment.#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the final &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; - unlike WML, WFL requires this to indicate where the comment ends.&lt;br /&gt;
&lt;br /&gt;
== Defining Functions ==&lt;br /&gt;
&lt;br /&gt;
There are several predefined functions in the Wesnoth Formula Language, and if these are not enough, it is possible to define your own functions. The special variable &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;functions&amp;lt;/syntaxhighlight&amp;gt; always evaluates to a list of all known function names. This is mainly useful only as a debugging tool, though.&lt;br /&gt;
&lt;br /&gt;
To define a function, you use the &amp;lt;code&amp;gt;def&amp;lt;/code&amp;gt; keyword. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def sgn(x) if(x &amp;lt; 0, -1, x &amp;gt; 0, 1, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This defines a function called &amp;lt;code&amp;gt;sgn&amp;lt;/code&amp;gt; which returns the sign of the input number. The semicolon marks the end of the function. It's optional if there's nothing else following the function, but in practice this will very rarely be the case.&lt;br /&gt;
&lt;br /&gt;
Function names have the same limitation as variable names – they can contain only letters and underscores, and cannot contain digits.&lt;br /&gt;
&lt;br /&gt;
You can select one of the function's arguments to be the &amp;quot;default&amp;quot; argument. If an object is passed to the default argument, then any attributes of that object are directly accessible in the global scope. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def is_badly_wounded(u*) hitpoints &amp;lt; max_hitpoints / 2;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function takes a unit and returns 1 if it is at less than half hitpoints. The &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; indicates the default argument, without which it would instead have to be defined like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def is_badly_wounded(u) u.hitpoints &amp;lt; u.max_hitpoints / 2;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's important to remember that the function body has access to no variables other than its parameters. For example, the following function would not work (in an AI context) even though the my_leader variable is defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def endangers_leader(u) distance_between(u.loc, my_leader.loc) &amp;lt; u.moves;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is because the body of the function can't see the my_leader variable. To make this work, you would need to pass in my_leader as an additional parameter.&lt;br /&gt;
&lt;br /&gt;
'''Note: Prior to 1.14, function definitions only work in AI code and GUI2 code.'''&lt;br /&gt;
&lt;br /&gt;
== Where to Use Formulas ==&lt;br /&gt;
&lt;br /&gt;
Formulas can only be used in specific attributes in WML. The documentation of a WML tag will note which keys can have a formula placed in them. Some common examples include [[FilterWML|filters]], [[GUIToolkit|GUI2 dialogs]], and [[AbilitiesWML|unit abilities]]. Another example is the [[VariablesWML#Variable_Substitution|&amp;lt;code&amp;gt;$(formula)&amp;lt;/code&amp;gt; substitution]] syntax, which allows the use of formulas wherever variables are parsed.&lt;br /&gt;
&lt;br /&gt;
When using a formula in WML (other than in a substitution, which is usually part of a longer already-quoted passage), it is highly recommended to place double quotes around the formula, to avoid ambiguity between the WML and WFL parsers. The double angle quotes are also acceptable for this purpose. If you don't quote your formulas, there are two issues you could run into:&lt;br /&gt;
&lt;br /&gt;
# WML uses the &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; operator to represent concatenation of strings, as well as line continuation. Because of this, an unquoted &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; will be ''removed'', likely causing the WFL formula to fail to compile.&lt;br /&gt;
# Unquoted WML text has the whitespace collapsed. If using WFL strings where whitespace is significant, this can result in surprises. For example, the formula &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;length('One    Two    Three')&amp;lt;/syntaxhighlight&amp;gt; would return 13 instead of the expected 19 if double quotes are not placed around the formula.&lt;br /&gt;
&lt;br /&gt;
Some attributes in WML ''require'' a formula, which means that anything placed in the attribute will always be considered to be a formula. In this case, the formula doesn't need to be enclosed in parentheses – just the double quotes will suffice. However, there are also attributes that take an ''optional'' formula. These are most common in GUI2, but are also found in other places. In such attributes, the formula ''must'' be enclosed in parentheses. Failure to do so will result in it being parsed as just a straight value. As a general guideline, if the attribute key contains the word &amp;quot;formula&amp;quot;, it is usually required to be a formula, whereas attributes with optional formulas do ''not'' contain the word &amp;quot;formula&amp;quot; in the key.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Do ''not'' use a &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; to introduce a formula. The &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; is not part of WFL syntax. It introduces a ''substitution'', a concept which is covered in more detail at [[VariablesWML#Variable Substitution]]. Although WFL can be used ''inside'' a substitution, a substitution itself is not WFL, and you should ''never'' use a &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; in WFL. However, in practice, substitutions and WFL are often used together – as substitution is processed first, you may see WFL formulas that appear to contain a &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; inside them. This is ''not'' part of the WFL – it is more like a macro substitution to be carried out before the formula runs. So, of course, it will only work in places that support ''both'' WFL and substitution.&lt;br /&gt;
&lt;br /&gt;
== Files ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
On occasion, you may find yourself working with formulas complex enough to split them out into a separate file. The formula engine normally assumes that it is executing inline code and reports errors accordingly, but you can tell it to enter a file scope using the special &amp;lt;code&amp;gt;wfl&amp;lt;/code&amp;gt; keyword. The convention is to frame your code, so that any file looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
wfl 'filename.wfl'&lt;br /&gt;
&lt;br /&gt;
# Put whatever code you need here, possibly including function definitions. #&lt;br /&gt;
&lt;br /&gt;
wflend&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The matching &amp;lt;code&amp;gt;wflend&amp;lt;/code&amp;gt; is required.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This functionality was available prior to 1.13.5 using keywords &amp;lt;code&amp;gt;fai&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;faiend&amp;lt;/code&amp;gt;. These keywords are now deprecated, but still work.&lt;br /&gt;
&lt;br /&gt;
These directives have no effect on the formula code itself. They only change how error messages are reported if something goes wrong. Files using these directives are usually included using the WML preprocessor, though they could also be loaded in Lua with [[LuaAPI/filesystem#filesystem.read_file|filesystem.read_file]].&lt;br /&gt;
&lt;br /&gt;
== Core Functions ==&lt;br /&gt;
&lt;br /&gt;
Many of the core functions exhibit two features that (as of 1.13.4) cannot be used in user-defined functions. The first is the ability to accept a varying number of arguments - some core functions accept any number of arguments, while others have a few optional arguments. The second is that arguments are lazily-evaluated, and in some cases some arguments will not be evaluated at all, while others may be evaluated multiple times with different variable values. The description of each function will explain how and when its arguments are evaluated.&lt;br /&gt;
&lt;br /&gt;
Most of the core functions can be used from any formula. However, there are some that are only available in formulas that have access to the game state. The following formulas have access to the game state and can use those functions:&lt;br /&gt;
&lt;br /&gt;
* Formulas used in [[FilterWML]]&lt;br /&gt;
* Formulas used in [[AbilitiesWML]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;filter_formula&amp;lt;/tt&amp;gt; in [[EventWML#filter_formula|EventWML]]&lt;br /&gt;
* Formulas evaluated from the formula console (accessed by pressing F)&lt;br /&gt;
&lt;br /&gt;
The following formulas do not have access to the game state and cannot use those functions:&lt;br /&gt;
&lt;br /&gt;
* Formulas used in [[GUI2]]&lt;br /&gt;
* [[SyntaxWML#formula_substitution|Substitution]] formulas using &amp;lt;tt&amp;gt;$(...)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* [[ImagePathFunctions#CHAN: General function|IPF]] formulas used in &amp;lt;tt&amp;gt;~CHAN()&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;~ALPHA()&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Formulas compiled from [[LuaAPI/wesnoth#wesnoth.compile_formula|Lua]]&lt;br /&gt;
&lt;br /&gt;
=== Conditional Functions ===&lt;br /&gt;
&lt;br /&gt;
There are two functions which return one of their input values based on some condition - the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; function, and the &amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt; function. Both evaluate only as many parameters as is needed to determine which value to return. In particular, parameters that are neither returned nor part of the condition will never be evaluated.&lt;br /&gt;
&lt;br /&gt;
==== if ====&lt;br /&gt;
&lt;br /&gt;
* if(''condition'', ''if true'' [, ''condition 2'', ''if true 2'', ...] [, ''otherwise''])&lt;br /&gt;
&lt;br /&gt;
This function first evaluates the ''condition'', which is a formula. If it evaluates to true, then the function evaluates and returns the ''if true'' parameter; otherwise, it tries the next condition (if any) with the same result. If none of the conditions evaluate to true, then it returns the ''otherwise'' parameter if present, or &amp;lt;code&amp;gt;null()&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
For instance, an AI that recruits Wolf Riders on the first turn, and Orcish Grunts thereafter might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
if(turn = 1, recruit('Wolf Rider'), recruit('Orcish Grunt'))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== switch ====&lt;br /&gt;
&lt;br /&gt;
* switch(''formula'', ''value 1'', ''outcome 1'' [, ... , ''value N'', ''outcome N''] [, ''default outcome''])&lt;br /&gt;
&lt;br /&gt;
The switch function first evaluates the input ''formula'', and then checks if it is equal to any of the specified ''values''. If matching value is found, the ''outcome'' assigned to it is returned; if not, then function returns either ''default outcome'' (if specified) or null.&lt;br /&gt;
&lt;br /&gt;
=== Numeric Functions ===&lt;br /&gt;
&lt;br /&gt;
Several basic math functions are available. These generally work equally on integer and decimal values.&lt;br /&gt;
&lt;br /&gt;
==== abs ====&lt;br /&gt;
&lt;br /&gt;
* abs(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value of an input number; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
abs( -5 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return 5.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== acos ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* acos(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arccosine of the input number, in degrees.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== asin ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* asin(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arcsine of the input number, in degrees.&lt;br /&gt;
&lt;br /&gt;
==== atan ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* atan(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arctangent of the input number, in degrees.&lt;br /&gt;
==== as_decimal ====&lt;br /&gt;
&lt;br /&gt;
* as_decimal(''number'')&lt;br /&gt;
&lt;br /&gt;
Ensures that the number is a decimal rather than an integer; useful if you're dividing two unknown values and want to ensure that the result is a decimal.&lt;br /&gt;
&lt;br /&gt;
==== cbrt ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* cbrt(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the cube root of the input number. This is better than using the exponentiation operator, because it will give the correct result for negative numbers.&lt;br /&gt;
&lt;br /&gt;
==== ceil ====&lt;br /&gt;
&lt;br /&gt;
* ceil(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the ceiling of the specified number, ie rounding it up to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== clamp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}}&lt;br /&gt;
&lt;br /&gt;
* clamp(''number'', ''min'', ''max'')&lt;br /&gt;
&lt;br /&gt;
Combines min and max into a single call. If ''number'' is less than ''min'', returns ''min''; if it's greater than ''max'', returns ''max''. Otherwise, returns ''number''.&lt;br /&gt;
&lt;br /&gt;
==== cos ====&lt;br /&gt;
&lt;br /&gt;
* cos(''angle'')&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== exp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* exp(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the exponential of the input number, which is the constant ''e'' raised to the specified power.&lt;br /&gt;
&lt;br /&gt;
==== floor ====&lt;br /&gt;
&lt;br /&gt;
* floor(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the floor of the specified number, ie rounding it down to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== frac ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* frac(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the fractional part of the specified number.&lt;br /&gt;
&lt;br /&gt;
==== hypot ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* hypot(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Returns the hypoteneuse length of a triangle with sides ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
==== lerp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}}&lt;br /&gt;
&lt;br /&gt;
* lerp(''min'', ''max'', ''fraction'')&lt;br /&gt;
&lt;br /&gt;
Returns a linear interpolation between ''min'' and ''max'' according to the specified ''fraction''.&lt;br /&gt;
&lt;br /&gt;
==== lerp_index ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* lerp_index(''list'', ''ratio'')&lt;br /&gt;
&lt;br /&gt;
Returns the element of the list that is closest to being at the specified ratio of the list's length.&lt;br /&gt;
&lt;br /&gt;
'''Example''': &amp;lt;syntaxhighlight lang=wfl inline&amp;gt;lerp_index([1, 12, 32, 10], 0.26])&amp;lt;/syntaxhighlight&amp;gt; returns 12.&lt;br /&gt;
&lt;br /&gt;
==== log ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* log(''number'', [, ''base''])&lt;br /&gt;
&lt;br /&gt;
Returns the logarithm of the input number. If ''base'' is omitted, it returns the natural logarithm; otherwise, the logarithm to the specified base.&lt;br /&gt;
&lt;br /&gt;
==== max ====&lt;br /&gt;
&lt;br /&gt;
* max(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
Returns the largest number from the list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
max([2, 8, -10, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== min ====&lt;br /&gt;
&lt;br /&gt;
* min(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
Returns the smallest number from the list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
min( [ 3, 7, -2, 6] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return &amp;lt;code&amp;gt;-2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== pi ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* pi()&lt;br /&gt;
&lt;br /&gt;
Returns pi.&lt;br /&gt;
&lt;br /&gt;
==== root ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* root(''number'', ''base'')&lt;br /&gt;
&lt;br /&gt;
Returns the root of the input number, to the specified base. This is better than using the exponentiation operator, because it will give the correct result for negative numbers and odd bases (for example, the fifth root of -32, which is -2).&lt;br /&gt;
&lt;br /&gt;
==== round ====&lt;br /&gt;
&lt;br /&gt;
* round(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the specified number rounded to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== sgn ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* sgn(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the sign of the number, ie -1 if it is negative, 1 if it is positive, and 0 if it is zero.&lt;br /&gt;
&lt;br /&gt;
==== sin ====&lt;br /&gt;
&lt;br /&gt;
* sin(''angle'')&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== sqrt ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* sqrt(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the input number.&lt;br /&gt;
&lt;br /&gt;
==== sum ====&lt;br /&gt;
&lt;br /&gt;
* sum(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates to the sum of the numbers in the ''list of numbers''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sum([ 2, 5, 8])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;15&amp;lt;/code&amp;gt;, and:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sum(map(my_units, max_hitpoints - hitpoints))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
finds the total damage your units have taken.&lt;br /&gt;
&lt;br /&gt;
==== tan ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* tan(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== trunc ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* trunc(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the truncation of the specified number, ie rounding it towards zero. This is different from floor when applied to negative numbers - floor(-7.5) gives -8, but trunc(-7.5) gives -7.&lt;br /&gt;
&lt;br /&gt;
==== wave ====&lt;br /&gt;
&lt;br /&gt;
* wave(''number'')&lt;br /&gt;
&lt;br /&gt;
Given a numeric value V, this returns:&lt;br /&gt;
&lt;br /&gt;
  sin(2*pi*V)&lt;br /&gt;
&lt;br /&gt;
=== String Functions ===&lt;br /&gt;
&lt;br /&gt;
There are a few useful functions for manipulating strings.&lt;br /&gt;
&lt;br /&gt;
==== concatenate ====&lt;br /&gt;
&lt;br /&gt;
* concatenate(''value1''[, ''value2'', ...])&lt;br /&gt;
&lt;br /&gt;
Converts each of its arguments to a string, and concatenates the result together into a single string.&lt;br /&gt;
&lt;br /&gt;
==== contains_string ====&lt;br /&gt;
&lt;br /&gt;
* contains_string(''string'', ''search_string'')&lt;br /&gt;
&lt;br /&gt;
Returns 1 if ''search_string'' can be found within ''string'' (as a substring), 0 otherwise. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
contains_string( 'Testing', 'ing' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== length ====&lt;br /&gt;
&lt;br /&gt;
* length(''string'')&lt;br /&gt;
&lt;br /&gt;
Returns the length of the input string.&lt;br /&gt;
&lt;br /&gt;
==== ends_with ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* ends_with(''string'', ''suffix'')&lt;br /&gt;
&lt;br /&gt;
Determines whether the ''string'' ends with the specified ''suffix''.&lt;br /&gt;
&lt;br /&gt;
==== find_string ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* find_string(''string'', ''search_string'')&lt;br /&gt;
&lt;br /&gt;
Returns the index at which ''search_string'' starts within ''string'' (as a substring), or -1 if it is not found. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
find_string( 'Testing', 'ing' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== replace ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* replace(''string'', ''offset'', [''size'',] ''replacement'')&lt;br /&gt;
&lt;br /&gt;
Returns a new string obtained by replacing a portion of the input ''string'' with the contents of the ''replacement'' string. The ''offset'' and ''size'' work the same as for &amp;lt;code&amp;gt;substring&amp;lt;/code&amp;gt;. Examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', 4, 5, 'dumb')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -9, 4, 'sleeping')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -9, 'brook!')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -6, -4, 'yellow')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return the following strings:&lt;br /&gt;
&lt;br /&gt;
 'The dumb brown fox jumps over the lazy dog!'&lt;br /&gt;
 'The quick brown fox jumps over the sleeping dog!'&lt;br /&gt;
 'The quick brown fox jumps over the brook!'&lt;br /&gt;
 'The quick brown fox jumps over the yellow dog!'&lt;br /&gt;
&lt;br /&gt;
==== replace_all ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* replace_all(''string'', ''match'', ''replacement'')&lt;br /&gt;
&lt;br /&gt;
Returns a copy of ''string'' with all occurrences of ''match'' replaced by ''replacement''.&lt;br /&gt;
&lt;br /&gt;
==== starts_with ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* starts_with(''string'', ''prefix'')&lt;br /&gt;
&lt;br /&gt;
Determines whether the ''string'' begins with the specified ''prefix''.&lt;br /&gt;
&lt;br /&gt;
==== substring ====&lt;br /&gt;
&lt;br /&gt;
* substring(''string'', ''offset''[, ''size''])&lt;br /&gt;
&lt;br /&gt;
Extracts a substring from the given input string. The ''offset'' specifies the first character to extract; the first character is &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, and negative values count from the end, so the last character is &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt;. If specified, the ''size'' indicates the total number of characters to extract; it cannot be negative. If omitted, all characters from the ''offset'' to the end of the string are returned. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', 4, 5)&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -9, 4)&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -9)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return &amp;lt;code&amp;gt;'quick'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'lazy'&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;'lazy dog!'&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The ''size'' can now be negative. This means to count backwards from the given ''offset'' (but always including the given offset, so a ''size'' of -1 gives the same result as 1). For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -6, -4)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'lazy'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== List and Map Functions ===&lt;br /&gt;
&lt;br /&gt;
This section contains functions that directly manipulate a map or list.&lt;br /&gt;
&lt;br /&gt;
==== head ====&lt;br /&gt;
&lt;br /&gt;
* head(''list'' [, ''count''])&lt;br /&gt;
&lt;br /&gt;
Returns the first item from the ''list''; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
head([5, 7, 9])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;, and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
head( [ 'Orc', 'Human' ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'Orc'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} If a second argument is given, it returns a list containing the first ''count'' elements from the ''list''. Note that &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;head(L)&amp;lt;/syntaxhighlight&amp;gt; is different from &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;head(L,1)&amp;lt;/syntaxhighlight&amp;gt; - the former returns the first element, while the latter returns a list containing only the first element.&lt;br /&gt;
&lt;br /&gt;
==== index_of ====&lt;br /&gt;
&lt;br /&gt;
* index_of(''value'', ''list'')&lt;br /&gt;
&lt;br /&gt;
This function will return the first index where ''value'' can be found in the input ''list''. It will return -1 if the value is not found in the ''list'.&lt;br /&gt;
&lt;br /&gt;
==== keys ====&lt;br /&gt;
&lt;br /&gt;
* keys(''map'')&lt;br /&gt;
&lt;br /&gt;
Extracts the key values from an input ''map'' and returns them as a list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
keys(['Elvish Fighter' -&amp;gt; 50, 'Elvish Archer' -&amp;gt; 60])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns&lt;br /&gt;
&lt;br /&gt;
 ['Elvish Fighter', 'Elvish Archer']&lt;br /&gt;
&lt;br /&gt;
==== size ====&lt;br /&gt;
&lt;br /&gt;
* size(''list'')&lt;br /&gt;
&lt;br /&gt;
This function returns the number of elements in the ''list''.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;size([5, 7, 9])&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; and &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;size(['Archer', 'Fighter'])&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== sort ====&lt;br /&gt;
&lt;br /&gt;
* sort(''list'', ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates to a result list sorted according to the comparison ''formula'' for each item &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and its successor &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;. For instance, sorting units according to hitpoints would be done by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sort(my_units, a.hitpoints &amp;gt; b.hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To sort them in the reverse order, simply use &amp;lt;code&amp;gt;&amp;amp;lt;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== tail ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* tail(''list'' [, ''count''])&lt;br /&gt;
&lt;br /&gt;
Returns the last item from the ''list''; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tail([5, 7, 9])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt;, and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tail( [ 'Orc', 'Human' ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'Human'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a second argument is given, it returns a list containing the last ''count'' elements from the ''list''. Note that &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;tail(L)&amp;lt;/syntaxhighlight&amp;gt; is different from &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;tail(L,1)&amp;lt;/syntaxhighlight&amp;gt; - the former returns the last element, while the latter returns a list containing only the last element.&lt;br /&gt;
&lt;br /&gt;
==== tolist ====&lt;br /&gt;
&lt;br /&gt;
* tolist(''map'')&lt;br /&gt;
&lt;br /&gt;
This function takes a map and return a list of key-value pair objects. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tolist(['Elf' -&amp;gt; 10, 'Dwarf' -&amp;gt; 20])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return:&lt;br /&gt;
&lt;br /&gt;
 [{key-&amp;gt;'Elf',value-&amp;gt;10}, {key-&amp;gt;'Dwarf',value-&amp;gt;20}]&lt;br /&gt;
&lt;br /&gt;
==== tomap ====&lt;br /&gt;
&lt;br /&gt;
* tomap(''list A'' [, ''list B''])&lt;br /&gt;
&lt;br /&gt;
This function takes one or two ''lists'' as input and returns a map. If only one list is specified, then the function will evaluate this list, count how many similar elements are found within the list, and return a map with keys being these elements, and values being a number representing how many of them the list contains. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tomap(['elf', 'dwarf', 'elf', 'elf', 'human', 'human'])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return:&lt;br /&gt;
&lt;br /&gt;
 ['elf' -&amp;gt; 3, 'dwarf' -&amp;gt; 1, 'human' -&amp;gt; 2]&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} However, if all the elements are key-value pairs such as those created by ''pair'' or ''tolist'', then this function will invert the effect of ''tolist'' and return the original map which would have produced the input list as output when passed to ''tolist''. If only some elements are key-value pairs, those elements will be directly converted into key-value pairs in the resulting map, while other values will be treated as described above.&lt;br /&gt;
&lt;br /&gt;
If two lists are specified, then the elements of the first one will be used as a keys, and the elements of the second one as a values, when creating an output map. Note that these input lists must be of the same length. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tomap(['elf', 'dwarf' ], [10, 20])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in:&lt;br /&gt;
&lt;br /&gt;
 ['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20]&lt;br /&gt;
&lt;br /&gt;
==== values ====&lt;br /&gt;
&lt;br /&gt;
* values(''map'')&lt;br /&gt;
&lt;br /&gt;
Extracts the values assigned to keys from an input ''map'' and returns them as a list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
values(['Elvish Fighter' -&amp;gt; 50, 'Elvish Archer' -&amp;gt; 60])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns&lt;br /&gt;
&lt;br /&gt;
 [50, 60]&lt;br /&gt;
&lt;br /&gt;
=== List-processing Functions ===&lt;br /&gt;
&lt;br /&gt;
This section covers functions that operate on maps or lists by applying one or more formulas in succession to each element. Most return another map or list, &amp;lt;code&amp;gt;reduce&amp;lt;/code&amp;gt; instead combines all the elements into a single result.&lt;br /&gt;
&lt;br /&gt;
==== choose ====&lt;br /&gt;
&lt;br /&gt;
* choose(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates ''formula'' for each item in the ''input'' (which can be a list or a map). It will return the first item to which ''formula'' gave the highest value. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
choose(my_units, level)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
gives back the unit with the highest level.&lt;br /&gt;
&lt;br /&gt;
The implicit input when evaluating a mapping/filtering function's ''formula'' component will be that specific item under evaluation (in this example one of &amp;quot;my_units&amp;quot;), and it can be explicitly referenced as &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; when necessary. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
When evaluating a map, we can reference each key by &amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt; and each value by &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;. In this case, the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable is this key-value pair. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
choose(['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20 ], value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return a key-value pair &lt;br /&gt;
&lt;br /&gt;
 {key-&amp;gt;'dwarf', value-&amp;gt;20}&lt;br /&gt;
&lt;br /&gt;
The curly braces are used in output to indicate that this is an object, not a map. It is not valid WFL syntax.&lt;br /&gt;
&lt;br /&gt;
==== filter ====&lt;br /&gt;
&lt;br /&gt;
* filter(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on each item in the ''input'' (which can be a list or a map). It will evaluate to a list or map which only contains items that the ''formula'' was true for. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
filter(my_units, hitpoints &amp;lt; max_hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return all of your units which have less than maximum hitpoints. For instance this could be used if looking for candidates for healing.&lt;br /&gt;
&lt;br /&gt;
==== find ====&lt;br /&gt;
 &lt;br /&gt;
* find(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run &amp;lt;formula&amp;gt; on each item in the &amp;lt;input&amp;gt; (which can be a list or a map) and will return the first item for which &amp;lt;formula&amp;gt; was true. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
find(units, type = 'Elvish Archer' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return the first unit of type 'Elvish Archer'.&lt;br /&gt;
&lt;br /&gt;
==== map ====&lt;br /&gt;
&lt;br /&gt;
* map(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on each item in the ''input'' (which can be a list or a map), and evaluate to a new list or map or a map, which contains the same number of items as in ''input'', with the formulas run on each item. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable. When run on a map, the resulting map has the same keys as the input map, but with the values updated to the results of the ''formula''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map([10,20], self*self)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map([10,20], 'value', value*value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will both result in [100, 400]. The formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(my_units, hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will give a list back with the number of hitpoints each unit has. This is more useful in conjunction with other functions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20 ], value*2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above will produce ['elf' -&amp;gt; 20, 'dwarf' -&amp;gt; 40]. Note that in case of a map data type, the &amp;lt;code&amp;gt;map&amp;lt;/code&amp;gt; function can only modify the value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(tomap([3,5,8,8]), value+key*100)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above will produce &amp;lt;code&amp;gt;[3 -&amp;gt; 301, 5 -&amp;gt; 502, 8 -&amp;gt; 801]&amp;lt;/code&amp;gt;. This can be used to take a list and make a map containing pairs &amp;lt;code&amp;gt;[element_from_that_list -&amp;gt; f(element_from_that_list,number_of_repetitions_of_that_element_in_that_list)]&amp;lt;/code&amp;gt; where &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; is an arbitrary function.&lt;br /&gt;
&lt;br /&gt;
==== reduce ====&lt;br /&gt;
&lt;br /&gt;
* reduce(''list'', [''identity'', ] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on the first and second members of the ''list'', then on the result and the third member and so on until the list is depleted. The final result is then returned. The two variables used in the ''formula'' are always 'a' and 'b'.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;reduce([1,2,3,4], a+b)&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;reduce([9,4,8,2], 10*a+b)&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;9482&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The new ''identity'' argument specifies the starting value (which is null or 0 by default). If ''list'' is empty, then ''identity'' is returned. Otherwise, the list will be considered as if ''identity'' were an extra first element. For example, to calculate the product of a list of numbers, you might do something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
reduce(your_list, 1, a * b)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will return 1 if the list is empty, as expected - the product of no numbers is 1. If the list is not empty, adding 1 to the list will have no effect, since it is the multiplicative identity.&lt;br /&gt;
&lt;br /&gt;
==== take_while ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* take_while(''list'', ''formula'')&lt;br /&gt;
&lt;br /&gt;
Evaluates the ''formula'' for each element of the ''list'' until it finds one for which it evaluates to false, then returns a list of all elements up to but not including that element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
take_while([1,5,3,6,3,7,9,5,6,4,12,2,53,2,1], self &amp;lt; 10)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns the list &amp;lt;code&amp;gt;[1,5,3,6,3,7,9,5,6,4]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== zip ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* zip(''list1'', ... , ''listN'')&lt;br /&gt;
* zip(''list of lists'')&lt;br /&gt;
&lt;br /&gt;
Takes a list of lists and generates a new list of lists such that list ''n'' contains element ''n'' of each of the original lists, in order. If the lists are not all of the same length, it treats them as if they were padded on the end with null values so that they are all the length of the longest list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
zip([1,2,3],[4,5,6])&lt;br /&gt;
zip([1,4],[2,5],[3,6])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return &amp;lt;code&amp;gt;[[1,4],[2,5],[3,6]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[1,2,3],[4,5,6]]&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Location Functions ===&lt;br /&gt;
&lt;br /&gt;
Functions for working with locations on a hex map.&lt;br /&gt;
&lt;br /&gt;
==== adjacent_locs ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* adjacent_locs(''center'')&lt;br /&gt;
&lt;br /&gt;
Returns a list of all locations adjacent to the specified location. When called from a formula with access to the game state, it automatically excludes locations that don't exist on the map. Otherwise, it operates as if on an infinite map. This means you should generally not expect the returned list to contain exactly 6 elements.&lt;br /&gt;
&lt;br /&gt;
==== are_adjacent ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* are_adjacent(''loc1'', ''loc2'')&lt;br /&gt;
&lt;br /&gt;
Check if two locations are adjacent. Returns 1 (true) or 0 (false).&lt;br /&gt;
&lt;br /&gt;
==== direction_from ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* direction_from(''start'', ''direction'', [''distance''])&lt;br /&gt;
&lt;br /&gt;
Returns the hex reached by travelling in the specified direction from a starting hex for a certain distance (default 1 hex).&lt;br /&gt;
&lt;br /&gt;
==== distance_between ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* distance_between(''start'', ''end'')&lt;br /&gt;
&lt;br /&gt;
Returns the distance between the locations ''start'' and ''end'', which must be location objects such as those created by &amp;lt;code&amp;gt;loc()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This function was already available in FormulaAI prior to 1.13.5; however, from 1.13.5 onward it is available to all formulas.&lt;br /&gt;
&lt;br /&gt;
==== loc ====&lt;br /&gt;
&lt;br /&gt;
* loc(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Creates and returns a location object with the specified coordinates. If assigned to a variable ''pos'' (eg with a &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clause), the individual coordinates can be accessed as &amp;lt;code&amp;gt;pos.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pos.y&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== locations_in_radius ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* locations_in_radius(''center'', ''radius'')&lt;br /&gt;
&lt;br /&gt;
Returns a list of all locations within a given radius of the specified center hex.&lt;br /&gt;
Only locations on the map will be returned.&lt;br /&gt;
&lt;br /&gt;
==== relative_dir ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* relative_dir(''loc1'', ''loc2'')&lt;br /&gt;
&lt;br /&gt;
Returns the direction you need to travel to progress from one location to another. The returned location is one of the six possible directions on the Wesnoth hex map, or an empty string if both locations are the same.&lt;br /&gt;
&lt;br /&gt;
==== rotate_loc_around ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}} but returns wrong result until {{DevFeature1.19|2}}&lt;br /&gt;
&lt;br /&gt;
* rotate_loc_around(''center'', ''loc'', ''angle'')&lt;br /&gt;
&lt;br /&gt;
Rotates a location around a given center to produce a new location. The angle is an integer between -6 and 6, which can be understood as a multiple of 60 degrees.&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Functions ===&lt;br /&gt;
&lt;br /&gt;
Some functions really don't fit into any category. They are all listed here.&lt;br /&gt;
&lt;br /&gt;
==== null ====&lt;br /&gt;
&lt;br /&gt;
* null([''arguments''])&lt;br /&gt;
&lt;br /&gt;
Evaluates each of its arguments (if any) in order, then returns null. Since formulas generally do not have side-effects, there is little point in specifying any arguments unless you are writing AI code (where several functions do have side-effects).&lt;br /&gt;
&lt;br /&gt;
==== pair ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* pair(''key'', ''value'')&lt;br /&gt;
&lt;br /&gt;
Creates a key-value pair object, the same as those created by the ''tolist'' function.&lt;br /&gt;
&lt;br /&gt;
==== reverse ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* reverse(''string or list'')&lt;br /&gt;
&lt;br /&gt;
Returns the input string or list backwards.&lt;br /&gt;
&lt;br /&gt;
==== type ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* type(''anything'')&lt;br /&gt;
&lt;br /&gt;
Returns the type of its input as a string. Possible results are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;'integer'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'decimal'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'string'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'list'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'map'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'null'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'object'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== get_palette ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* get_palette(''name'')&lt;br /&gt;
&lt;br /&gt;
Returns a list of colours that make up the named palette. Palettes are defined by a '''[color_palette]''' tag, usually in the [[GameConfigWML#Color_Palettes|game config]]. The palettes defined in core Wesnoth are '''magenta''', '''flag_green''', and '''ellipse_red'''. In addition to defined palettes, several hard-coded palettes are available by name. They are '''red_green_scale''', '''red_green_scale_text''', '''blue_white_scale''', and '''blue_white_scale_text'''. These are also defined in the game config, but not with a '''[color_palette]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Functions ===&lt;br /&gt;
&lt;br /&gt;
There are also a few functions that can be useful for debugging formulas, for example by displaying intermediate results to the screen. Note that this breaks the general rule that functions do not have side-effects.&lt;br /&gt;
&lt;br /&gt;
==== debug ====&lt;br /&gt;
&lt;br /&gt;
* debug([''formula''])&lt;br /&gt;
&lt;br /&gt;
Starts a GUI formula AI debugger when evaluating a formula. It takes a formula, evaluates it and returns the result unchanged. '''Note:''' this does not appear to work in 1.13.3.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The formula allows you to step through the formula one operation at a time, viewing the current stack and execution trace. As of 1.13.5, you need to enable [[CommandMode|debug mode]] to use the debugger; otherwise, it will simply be skipped.&lt;br /&gt;
&lt;br /&gt;
==== debug_print ====&lt;br /&gt;
&lt;br /&gt;
'''you need to enable formula log (--log-info='scripting/formula') to see the result of this call'''&lt;br /&gt;
&lt;br /&gt;
* debug_print([''explanation'' ,] ''formula'' )&lt;br /&gt;
&lt;br /&gt;
This function can be used for debugging a formula. It takes a ''formula'', writes its result to the console, and returns it unchanged. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_print([1, 2, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in printing to the console&lt;br /&gt;
&lt;br /&gt;
 [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
and returning the same.&lt;br /&gt;
&lt;br /&gt;
We can specify an optional parameter ''explanation'' that helps to distinguish between multiple ''debug_print'' calls in the same formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_print('My array: ', [1, 2, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will write in the console:&lt;br /&gt;
&lt;br /&gt;
 My array: [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
and return&lt;br /&gt;
&lt;br /&gt;
 [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
==== debug_profile ====&lt;br /&gt;
&lt;br /&gt;
* debug_profile(''formula'' [, ''explanation''])&lt;br /&gt;
&lt;br /&gt;
Evaluates the formula 1000 times and prints (as with debug_print) a number indicating the average time required to evaluate the formula. Mainly intended for internal testing, but could occasionally be useful for people working with complicated formulas. The optional ''explanation'' argument is used in the same way as in debug_print.&lt;br /&gt;
&lt;br /&gt;
==== debug_float ====&lt;br /&gt;
&lt;br /&gt;
* debug_float(''location'', [''explanation'',] ''formula'' )&lt;br /&gt;
&lt;br /&gt;
This function can be used for debugging a formula. It takes a formula, floats a label containing the result on the hex specified (in the same way damage is displayed) and returns it unchanged. Note that the ''location'' here is an object type; it can be created with the &amp;lt;code&amp;gt;[[#loc|loc()]]&amp;lt;/code&amp;gt; function. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_float(me.loc, me.id)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will make a label containing the id of the unit ''me'' float over the unit.&lt;br /&gt;
&lt;br /&gt;
Return value is also the unit id.&lt;br /&gt;
&lt;br /&gt;
We can specify an optional parameter ''explanation'' that helps to distinguish between multiple ''debug_float'' calls in the same formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_float( me.loc, 'id: ', me.id )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will float the following label&lt;br /&gt;
&lt;br /&gt;
 id: unit_id&lt;br /&gt;
&lt;br /&gt;
and return the unit id.&lt;br /&gt;
&lt;br /&gt;
==== dir ====&lt;br /&gt;
&lt;br /&gt;
* dir(''object'')&lt;br /&gt;
&lt;br /&gt;
This function return a list of all attributes in ''object''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
dir(my_leader)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in the following output:&lt;br /&gt;
&lt;br /&gt;
 [ 'x', 'y', 'loc', 'id', 'type', 'name', 'leader', 'undead', 'traits', 'attacks', 'abilities', 'hitpoints',&lt;br /&gt;
 'max_hitpoints', 'experience', 'max_experience', 'level', 'total_movement', 'movement_left', 'attacks_left',&lt;br /&gt;
 'side', 'states', 'cost', 'usage', 'vars']&lt;br /&gt;
&lt;br /&gt;
This command is useful in the formula command line, to get information about the attributes of different types of data.&lt;br /&gt;
&lt;br /&gt;
=== Game State Functions ===&lt;br /&gt;
&lt;br /&gt;
These are functions that access the game state. Therefore, they are not available in all formulas, as described above.&lt;br /&gt;
&lt;br /&gt;
==== base_tod_bonus ====&lt;br /&gt;
&lt;br /&gt;
* base_tod_bonus([''loc'', [''turn'']])&lt;br /&gt;
&lt;br /&gt;
Evaluates the base time-of-day bonus, excluding the effect of illumination from abilities or terrain. If no turn is specified, the current turn is used. If no location is specified, the bonus is calculated for the global schedule without taking any time areas into account, but if a location is specified, it will account for any time areas that might affect that location.&lt;br /&gt;
&lt;br /&gt;
==== chance_to_hit ====&lt;br /&gt;
&lt;br /&gt;
* chance_to_hit(''unit'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the base chance for the unit to be hit if it moved to the given location or terrain. This is essentially the inverse of its defense. It is returned as an integer between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
==== defense_on ====&lt;br /&gt;
&lt;br /&gt;
* defense_on(''unit'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the defense that the unit would have if it moved to the given location or terrain. It is returned as an integer between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
==== enemy_of ====&lt;br /&gt;
&lt;br /&gt;
* enemy_of(''self'', ''other'')&lt;br /&gt;
&lt;br /&gt;
Determines whether two units are enemies. Returns 1 (true) or 0 (false).&lt;br /&gt;
&lt;br /&gt;
==== get_unit_type ====&lt;br /&gt;
&lt;br /&gt;
* get_unit_type(''id'')&lt;br /&gt;
&lt;br /&gt;
Returns an object describing the specified unit type, or null if no such unit type exists. A unit type object has many of the same keys as a unit, excluding those that are expected to change over time such as &amp;lt;tt&amp;gt;hitpoints&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== jamming_cost ====&lt;br /&gt;
&lt;br /&gt;
* jamming_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the jamming cost for the unit to block vision on the given location terrain.&lt;br /&gt;
&lt;br /&gt;
==== movement_cost ====&lt;br /&gt;
&lt;br /&gt;
* movement_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the movement cost for the unit to enter the given location or terrain.&lt;br /&gt;
&lt;br /&gt;
==== resistance_on ====&lt;br /&gt;
&lt;br /&gt;
* resistance_on(''unit'', ''location'', ''type'', [''attacker''])&lt;br /&gt;
&lt;br /&gt;
Calculates the unit's resistance to the given damage type when standing on the specified location. If specified, the ''attacker'' parameter should be 1 to indicate that the unit is the attacker, or 0 to indicate that it is the defender, as this status can affect resistances. By default, it is assumed to be the defender.&lt;br /&gt;
&lt;br /&gt;
This is returned not as the raw resistance set in WML, but the actual resistance that the player sees, so it ranges between -100 and 100.&lt;br /&gt;
&lt;br /&gt;
==== tod_bonus ====&lt;br /&gt;
&lt;br /&gt;
* tod_bonus([''loc'', [''turn'']])&lt;br /&gt;
&lt;br /&gt;
Evaluates the final time-of-day bonus, accounting for the effect of illumination from abilities or terrain. If no turn is specified, the current turn is used. If no location is specified, the bonus is calculated for the global schedule without taking any time areas into account, but if a location is specified, it will account for any time areas that might affect that location.&lt;br /&gt;
&lt;br /&gt;
==== unit_at ====&lt;br /&gt;
&lt;br /&gt;
* unit_at(''location'')&lt;br /&gt;
&lt;br /&gt;
Returns the unit on the given location, or null if there is no unit there.&lt;br /&gt;
&lt;br /&gt;
==== vision_cost ====&lt;br /&gt;
&lt;br /&gt;
* vision_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the vision cost for the unit to see through the given location or terrain.&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=74099</id>
		<title>DirectActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=74099"/>
		<updated>2025-01-13T19:57:56Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [modify_unit] */ type and experience&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. They can be used inside of [[EventWML|events]].&lt;br /&gt;
&lt;br /&gt;
The following tags are actions:&lt;br /&gt;
&lt;br /&gt;
=== [endlevel] ===&lt;br /&gt;
Ends the scenario.&lt;br /&gt;
* '''result''': before the scenario is over, all events with ''name=result'' are triggered. If ''result=victory'', the player progresses to the next level (i.e., the next scenario in single player); if ''result=defeat'', the game returns to the main menu. &lt;br /&gt;
&lt;br /&gt;
When the result is &amp;quot;victory&amp;quot; the following keys can 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. {{DevFeature1.13|2}} Alternatively, a number, defining the bonus multiple (1.0 meaning full).&lt;br /&gt;
* '''carryover_report''': whether the player should receive a summary of the scenario outcome, the default is carryover_report=yes.&lt;br /&gt;
* '''save''': whether a start-of-scenario save should be created for the next scenario, the default is save=yes. Do not confuse this with saving of replays for the current scenario.&lt;br /&gt;
* '''replay_save''': whether a replay save for the current scenario is allowed, the default is replay_save=yes. If yes, the player's settings in preferences will be used to determine if a replay is saved. If no, will override and not save a replay.&lt;br /&gt;
* '''linger_mode''': If ...=yes, the screen is greyed out and there's the possibility to save before advancing to the next scenario, the default is linger_mode=yes.&lt;br /&gt;
* '''reveal_map''': (Multiplayer only) (Default is 'yes') If 'no', shroud doesn't disappear when game ended.&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;
* '''carryover_percentage''': 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''': if yes the gold will be added to the starting gold the next scenario, if no the next scenario will start with the amount of the current scenario (after taxes) or the minimum in the next scenario. Default is no.&lt;br /&gt;
* '''music''': (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_credits''': Whether to display the credits screen at the end of a single-player campaign. Defaults to ''yes''. 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''': (translatable) 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''': 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;
* &amp;lt;strike&amp;gt;'''[next_scenario_settings]''': Any tags or attribute children of this optional argument to [endlevel] are merged into the scenario/multiplayer tag of the *next* scenario. This allows you to e.g. reconfigure the [side] tags or settings, just before load. &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* &amp;lt;strike&amp;gt;'''[next_scenario_append]''': Any tags of this optional argument are appended at high level to the next scenario. This is most appropriate for [event] tags, although you may find other uses. Example test scenario for these features: https://gna.org/support/download.php?file_id=20119 &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* '''[result]''' {{DevFeature1.13|0}} Allows specification of a side specific result, this is for competitive multiplayer scenarios/campaigns where it might happen that one player wins but another player loses.  The following attributes are accepted and have the same effect as in '''[endlevel]''':&lt;br /&gt;
** '''result'''&lt;br /&gt;
** '''bonus'''&lt;br /&gt;
** '''carryover_percentage'''&lt;br /&gt;
** '''carryover_add'''&lt;br /&gt;
&lt;br /&gt;
And there is also&lt;br /&gt;
** '''side''' The number of the side for which these results should apply.&lt;br /&gt;
&lt;br /&gt;
=== [unit] ===&lt;br /&gt;
Creates a unit (either on the map, on a recall list, or into a variable for later use.)  For syntax see [[SingleUnitWML]].&lt;br /&gt;
* {{Short Note:Predefined Macro|GENERIC_UNIT}}&lt;br /&gt;
&lt;br /&gt;
This tag can also recall an existing unit, which happens when:&lt;br /&gt;
* the '''id=''' attribute is used&lt;br /&gt;
* a unit with that '''id=''' already exists&lt;br /&gt;
* (might be unnecessary) the existing unit is on the side's recall list&lt;br /&gt;
in this case, the unit is recalled at the '''x,y=''' or '''location_id=''' given, and any other data in the tag is ignored.&lt;br /&gt;
&lt;br /&gt;
Campaign authors: a usual way to recall plot-necessary heroes is to use a macro with the data for creating that hero. This helps during debugging, because you can skip to scenarios and the recall-or-create functionality means that any units which are normally met in a previous scenario are automatically created (otherwise some scenarios may be an instant loss). This can only be used for units that must survive the previous scenarios, as it would recreate units if they died in a previous scenario.&lt;br /&gt;
For example,&lt;br /&gt;
[https://github.com/wesnoth/wesnoth/blob/1.14.7/data/campaigns/Heir_To_The_Throne/utils/httt_utils.cfg#L685 HttT's NEED_DELFADOR macro].&lt;br /&gt;
&lt;br /&gt;
=== [recall] ===&lt;br /&gt;
Recalls a unit taking into account any [[SingleUnitWML|filter_recall]] of the leader.   The unit is recalled free of charge, and is placed near its leader, e.g., if multiple leaders are present, near the first found which would be able to normally recall it.&lt;br /&gt;
&lt;br /&gt;
If neither a valid map location is provided nor a leader on the map would be able to recall it, the tag is ignored.&lt;br /&gt;
 &lt;br /&gt;
* [[StandardUnitFilter]]: the first matching unit will be recalled.  If no units match this tag is ignored. Do not use a [filter] tag. If a comma separated list is given, every unit currently considered for recall is checked against all the types (not each single one of the types against all units).&lt;br /&gt;
* '''x,y''': the unit is placed here instead of next to the leader.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to recall to. Used instead of '''x,y'''.&lt;br /&gt;
* '''show''': yes/no, default yes: whether the unit is animated (faded in) or instantly displayed&lt;br /&gt;
* '''fire_event''': boolean yes|no (default no); whether any according prerecall or recall events shall be fired.&lt;br /&gt;
* '''check_passability''': (boolean yes|no, default yes): If yes, checks for terrain passability when placing the unit (a nearby passable hex is chosen).&lt;br /&gt;
* '''[secondary_unit]''': {{DevFeature1.13|?}} If present and show=yes, a matching unit will be chosen and their recruiting animation played.&lt;br /&gt;
&lt;br /&gt;
=== [teleport] ===&lt;br /&gt;
Teleports a unit on map. {{Short Note:Predefined Macro|TELEPORT_UNIT}}&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] the first unit matching this filter will be teleported.&lt;br /&gt;
* '''x,y''': the hex to teleport to. If that hex is occupied, the closest unoccupied hex will be used instead.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to teleport to. Used instead of '''x,y'''.&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;
* '''check_passability''': (boolean yes|no, default yes): normally, units will not be teleported into terrain that is impassable for them. Setting this attribute to &amp;quot;no&amp;quot; permits it.&lt;br /&gt;
&lt;br /&gt;
(Note: There is also a ability named teleport, see [[AbilitiesWML]].)&lt;br /&gt;
&lt;br /&gt;
=== [terrain_mask] ===&lt;br /&gt;
Changes the terrain on the map.  See [[TerrainMaskWML]].&lt;br /&gt;
&lt;br /&gt;
=== [terrain] ===&lt;br /&gt;
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;
* [[StandardLocationFilter]]. This [[StandardLocationFilter]]'s terrain= key is used for the new terrain, filtering by terrain can be done with a nested [[StandardLocationFilter]]: [and]terrain=terrain_string_to_be_filtered_for.&lt;br /&gt;
* '''layer''': (overlay|base|both, default=both) only change the specified layer.&lt;br /&gt;
* '''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;
* '''location_id''': This key sets a string as a way to mark the hex or hexes for later reference.  It is very similar to the leader starting position, and can also be set that way in the map editor.&lt;br /&gt;
&lt;br /&gt;
If you want to remove the overlays from a terrain and leave only the base, use:&lt;br /&gt;
 layer=overlay&lt;br /&gt;
 terrain=&amp;quot;^&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages is that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [gold] ===&lt;br /&gt;
Gives sides 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. Can be a comma-separated list of sides. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [unstore_unit] ===&lt;br /&gt;
Creates a unit from a game variable, and activates it on the playing field or recall list.  This must be a specific variable describing a unit, and may not be an array (if it is, only the first unit will be unstored).&lt;br /&gt;
&lt;br /&gt;
This may be useful in different contexts:&lt;br /&gt;
* To update a unit on the map after having edited its WML. This usage is common, but discouraged - if possible, you should use [[#.5Bmodify_unit.5B|[modify_unit]]] or [[#.5Bobject.5B|[object]]] instead.&lt;br /&gt;
* To place a previously-defined unit into the scenario, if it was directly defined in a WML variable, using [unit] with the key '''to_variable'''. This usage is rather uncommon.&lt;br /&gt;
* To place a unit back into the game that was removed earlier, for example a hero that leaves the party for awhile and then comes back.&lt;br /&gt;
&lt;br /&gt;
The variable is not cleared. To unstore units from an array variable, iterate over the array. See [[VariablesWML]] and [[VariablesWML/How to use variables]] for more information about variable usage. See also [[InternalActionsWML#.5Bstore_unit.5D|[store_unit]]], [[ConditionalActionsWML|For]], [[ConditionalActionsWML#.5Bwhile.5D|[while]]] and [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]].&lt;br /&gt;
&lt;br /&gt;
The tag takes the following keys:&lt;br /&gt;
* '''variable''': This is required to indicate the name of the variable to read the unit from.&lt;br /&gt;
* '''Placement keys''':&lt;br /&gt;
** '''x''' ,'''y''': By default, the unit will be placed at the location specified in the variable, but if these keys are present, the unit will be placed at that location instead. To place the unit on the recall list of its side, use '''x,y=recall,recall'''. (If you want to change the said, you need to first update ''$unit.side'' in the variable before unstoring.)&lt;br /&gt;
** '''location_id''': {{DevFeature1.15|0}} The name of a special map location to unstore to. Used instead of '''x,y'''.&lt;br /&gt;
** '''find_vacant''' (yes|no, default no): 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;
** '''check_passability''' (yes|no, default yes): Only relevant if '''find_vacant=yes'''. In that case, this determines whether game will try to find a passable tile for the unit. If set to no, the unit may be placed on an impassable tile. Note that if both '''find_vacant''' and '''check_passability''' are set, then the unit's position may be shifted even if there is not a unit on the target space, if that space is not passable for the unit.&lt;br /&gt;
* '''Animation keys''' (these determine the visual effect of how the unit is placed or updated):&lt;br /&gt;
** '''text''': (translatable) A floating text to display above the unit, such as a damage amount.&lt;br /&gt;
** '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color of the text. 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;
** '''animate''': (boolean yes|no, default yes) Determines whether to play any animations associated with the unstore. Currently this only affects the advancement animation (&amp;quot;levelout&amp;quot; and &amp;quot;levelin&amp;quot;, defaulting to a fade to white and back) if the unit ends up advancing.&lt;br /&gt;
* '''Side-effect keys''' (these directly modify the behaviour of the action):&lt;br /&gt;
** '''advance''': (default=yes) if yes the unit is advanced if it has enough XP. When modifying XP, make sure to do it from inside a [[EventWML#Multiplayer_safety|synchronized event]] or it may lead to OOS errors, especially when several advancement paths exist. Note that advance and post advance events are called, so infinite loops can happen.&lt;br /&gt;
** '''fire_event''' (yes|no, default no): Whether any advance/post advance events shall be fired if an advancement takes place. This also affects whether the unit placed event is fired.&lt;br /&gt;
&lt;br /&gt;
Units can be unstored with negative (or zero) hit points. This can be useful if modifying a unit in its last_breath event (as the unit's death is already the next step), but tends to look wrong in other cases. In particular, it is possible to have units with negative hit points in play. Such units are aberrations, subject to unusual behavior as the game compensates for them. (For example, such units are currently automatically hit&amp;amp;mdash;and killed&amp;amp;mdash;in combat.) The details of the unusual behavior are subject to change between stable releases without warning.&lt;br /&gt;
&lt;br /&gt;
=== [allow_recruit] ===&lt;br /&gt;
Allows a side to recruit units it couldn't previously recruit. Any leader on this side will now be able to recruit the new units.&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. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [allow_extra_recruit] ===&lt;br /&gt;
Allows a leader to recruit units it couldn't previously recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[allow_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_recruit] ===&lt;br /&gt;
Prevents a side from recruiting units it could previously recruit. No leader on this side will be able to recruit the specified units anymore, unless that leader has the same unit in their personal '''extra_recruit''' list.&lt;br /&gt;
* '''type''': the types of units that the side can no longer recruit. {{DevFeature1.13|0}} If omitted, all recruits for matching sides will be disallowed.&lt;br /&gt;
* '''side''': (default=1) the number of the side that may no longer recruit the units. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_extra_recruit] ===&lt;br /&gt;
Prevents a leader from recruiting units it could previously recruit. This won't prevent the leader from recruiting that unit if the unit is in the '''[side]recruit=''' list – you must use '''[disallow_recruit]''' in that case.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can no longer recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [set_recruit] ===&lt;br /&gt;
Sets the units a side can recruit. Any leader on this side will now be able to recruit these units.&lt;br /&gt;
* '''recruit''': the types of units that the side can now recruit.&lt;br /&gt;
* '''side''': The number of the side that is having its recruitment set. This can be a comma-separated list.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [set_extra_recruit] === &lt;br /&gt;
Sets the units a leader can recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[set_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [modify_side] ===&lt;br /&gt;
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. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* '''income''': the income given at the begining of each turn.&lt;br /&gt;
* '''recruit''': a list of unit types, replacing the side's current recruitment list.&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;
* '''side_name''': {{DevFeature1.13|?}} a translatable string representing the side leader's description.&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. warning: in multiplayer, changing the controller of a side might result in OOS during some events like, for example 'side_turn_end'; see [https://github.com/wesnoth/wesnoth/issues/2563 issue #2563].&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;
* '''hidden''': a boolean string specifying whether side is shown in status table.&lt;br /&gt;
* '''color''': a team color range specification, name (e.g. &amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;), or number (e.g. &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;) for this side. The default color range names, numbers, and definitions can be found in data/core/team_colors.cfg.&lt;br /&gt;
* '''[ai]''': sets/changes AI parameters for the side. Only parameters that are specified in the tag are changed, this does not reset others to their default values. Uses the same syntax as described in [[AiWML]].  Note that [modify_side][ai] works for all simple AI parameters and some, but not all, of the composite ones. If in doubt, use [[AiWML#Adding_and_Deleting_Aspects_with_the_.5Bmodify_ai.5D_Tag|[modify_ai]]]] instead, which always works. {{DevFeature1.13|?}} If this contains an '''ai_algorithm''', the AI parameters will be reset to those of the indicated AI before adding any additional parameters included in the tag. In other words, this allows replacing the AI config rather than appending to it.&lt;br /&gt;
* '''switch_ai''': replaces a side ai with a new AI from specified file(ignoring those AI parameters above). Path to file follows the usual WML convention.&lt;br /&gt;
* '''reset_maps''': If set to &amp;quot;yes&amp;quot;, then the shroud is spread to all hexes, covering the parts of the map that had already been explored by the side, including hexes currently seen. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if shroud is on, but this is evaluated after shroud= (and before shroud_data=).&lt;br /&gt;
* '''reset_view''': If set to &amp;quot;yes&amp;quot;, then the fog of war is spread to all hexes, covering the parts of the map that had already been seen this turn by the side, including hexes currently seen, excluding hexes affected by multi-turn {{tag|DirectActionsWML|lift_fog}}. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if fog is on, but this is evaluated after fog=.&lt;br /&gt;
* '''share_maps''': change the share_maps side attribute. Be sure to use shroud=yes for that side and have it as an ally&lt;br /&gt;
* '''share_view''': change the share_view side attribute. Be sure to use fog=yes for that side and have it as an ally&lt;br /&gt;
* '''share_vision''': change both the above at the same time&lt;br /&gt;
* '''shroud_data''': changes to the side's shroud, using the same format as when defining the [side].&lt;br /&gt;
* '''suppress_end_turn_confirmation''': Boolean value controlling whether or not a player is asked for confirmation when skipping a turn.&lt;br /&gt;
* '''scroll_to_leader''': Boolean value controlling whether or not the game view scrolls to the side leader at the start of their turn when present.&lt;br /&gt;
* '''flag''': Flag animation for villages owned by this side (see [[SideWML|[side]]]).&lt;br /&gt;
* '''flag_icon''': Flag icon used for this side in the status bar (see [[SideWML|[side]]]).&lt;br /&gt;
* '''village_support''': The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.&lt;br /&gt;
* '''defeat_condition''' {{DevFeature1.13|0}}: When the side is considered defeated (see [[SideWML|[side]]]).&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the side; uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* '''[variables]''' {{DevFeature1.15|3}} The contents of this tag is merged into the side's variables.&lt;br /&gt;
&lt;br /&gt;
=== [modify_turns] ===&lt;br /&gt;
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;
* '''current''': changes the current turn number after applying turn limit modifications, if any. It is not possible to change the turn number to exceed the turn limit (1 &amp;lt;= current turns &amp;lt;= max turns).&lt;br /&gt;
&lt;br /&gt;
=== [allow_end_turn] ===&lt;br /&gt;
Allows human players to end their turn through the user interface if they were previously affected by the '''[disallow_end_turn]''' action. This action doesn't take any arguments.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_end_turn] ===&lt;br /&gt;
Disallows human players to end their turn through the user interface. This action doesn't require arguments.&lt;br /&gt;
* '''reason''' (translatable): {{DevFeature1.15|0}} Allows to optionally specify a reason.&lt;br /&gt;
&lt;br /&gt;
=== [capture_village] ===&lt;br /&gt;
Changes the ownership of a village.&lt;br /&gt;
* [[StandardLocationFilter]]: all village locations matching the filter are affected.&lt;br /&gt;
* '''side''': the side that takes control of the village. This side needs to have a leader (canrecruit=yes). If the side key is not given, the village will become neutral (unless [filter_side] is present, in which case that side fiter decides, see below).&lt;br /&gt;
* '''[filter_side]''' with [[StandardSideFilter]] tags and keys as arguments; if both this tag and inline side= are present it's an error. Otherwise, the first matching side gets ownership (or the village becomes neutral if none match).&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default: no): Whether any capture events shall be fired.&lt;br /&gt;
&lt;br /&gt;
=== [kill] ===&lt;br /&gt;
Removes all units (including units in a recall list) that match the filter from the game.&lt;br /&gt;
* [[StandardUnitFilter]]: Selection criterion; do not use a [filter] tag.&lt;br /&gt;
* '''animate''' (default 'no'): if 'yes', displays the unit dying (fading away). {{DevFeature1.13|8}} If '''[secondary_unit]''' is given, also plays the victory animation of that unit.&lt;br /&gt;
* '''fire_event''' (default 'no'): if 'yes', triggers any appropriate 'die' events (See [[EventWML]]). Note that events are only fired for killed units that have been on the map (as opposed to recall list).&lt;br /&gt;
* '''[secondary_unit]''' with a [[StandardUnitFilter]] as argument. Do not use a [filter] tag. Has an effect only if fire_event=yes ({{DevFeature1.13|8}} or if it has a victory animation and animate=yes). The first on-map unit matching the filter becomes second_unit in any fired die and last breath events. If an on-map unit matches and if there are several units killed with a single [kill] tag, second_unit is this same unit for all of them. If no on-map unit matches or [secondary_unit] isn't present, the variable second_unit in each of the die and last breath events is always the same as the variable unit (the dying unit).&lt;br /&gt;
* '''[primary_attack]''' {{DevFeature1.13|8}} The attacker's weapon to use for matching the animation. Useful for example on the wose, whose death animation depends on the damage type it was killed by. If a secondary unit is specified, this is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the unit. However, if there is no secondary unit specified, it is instead treated as an [[UnitTypeWML#Attacks|weapon definition]], and the animation will be run as if an imaginary unit possessing that weapon was the attacker.&lt;br /&gt;
* '''[secondary_attack]''' {{DevFeature1.13|8}} Similar to the above, but for the defender's weapon. This is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the dying unit.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit] ===&lt;br /&gt;
Moves a unit along a path on the map. The path can be specified exactly, or as a series of waypoints that the unit will pass through.&lt;br /&gt;
* [[StandardUnitFilter]] as argument; do not use a [filter] tag. All units matching the filter are moved. If the target location is occupied, the nearest free location is chosen.&lt;br /&gt;
* '''to_x''' (unsigned integer): The units are moved to this x coordinate. Can be a comma-separated list, in which case the unit follows this given path during the move.&lt;br /&gt;
* '''to_y''' (unsigned integer): The units are moved to this y coordinate. Can be a comma-separated list.&lt;br /&gt;
* '''dir''' (string): {{DevFeature1.15|0}} Performs a relative movement instead of an absolute movement. For example, dir=n,n,nw will move two spaces north and then one space to the northwest. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''to_location''': {{DevFeature1.15|0}} Moves matching units to locations placed in the map editor with the &amp;quot;New Location&amp;quot; button. Can be a comma-separated list. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''check_passability''' (boolean yes|no, default yes): Whether the terrain the unit is moved to should be checked for suiting the unit. (If it does not, a nearby suitable hex is chosen.)&lt;br /&gt;
* '''force_scroll''': Whether to scroll the map or not even when [[InterfaceActionsWML#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to using [[InterfaceActionsWML#.5Bmove_unit_fake.5D|[move_unit_fake]]]'s default value.&lt;br /&gt;
* '''clear_shroud''': {{DevFeature1.15|0}} (boolean yes|no, default no) Whether to remove shroud and fog after the unit was moved, but before events are fired. It will not clear all alongside the path, only around the target destination.&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default no): Whether any according moveto events shall be fired. The target location ($x1, $y1 in the event) may not be the same location that the unit was tried to be moved to, if the original target location is occupied or impassable.&lt;br /&gt;
&lt;br /&gt;
=== [modify_ai] ===&lt;br /&gt;
Changes AI objects (aspects, goals, candidate actions or stages) for a specified side. See [[Modifying_AI_Components#The_.5Bmodify_ai.5D_Tag|Modifying AI Components]] for full description.&lt;br /&gt;
&lt;br /&gt;
* '''action''' (string): Takes values 'add', 'change', 'delete' or 'try_delete' to do just that for the AI object.&lt;br /&gt;
* '''path''' (string): Describes which AI object is to be modified.  &lt;br /&gt;
* '''[facet]''', '''[goal]''', '''[candidate_action]''' or '''[stage]''': Details about the AI object to be modified.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [modify_unit] ===&lt;br /&gt;
works similar to the MODIFY_UNIT macro.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. All units matching this filter are modified. Matches on recall list units too.&lt;br /&gt;
* '''[object]''', '''[trait]''', {{DevFeature1.13|5}} '''[advancement]''' - The given modifications will be immediately applied to all units matching the filter. ([object] is described further [[#.5Bobject.5D|below]])&lt;br /&gt;
** '''delayed_variable_substitution''' {{DevFeature1.13|5}} (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object], [trait], or [advancement] is not variable-substituted at execution time of the event containing this [modify_unit]. You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
** Do not use a '''[modifications]''' tag, as this may skip some of the special-case handling for newly added objects, traits and advancements, and will potentially overwrite existing modifications.&lt;br /&gt;
* '''[effect]''' {{DevFeature1.13|6}} Applies the effect directly to the unit. See [[EffectWML]].&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the unit (saved inside the unit's [variables] tag); uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* Accepts generally the syntax inside of wml unit variables created by [store_unit] which can be viewed in a savefile or by using the [[CommandMode|inspect command]]. Cannot remove things or add/alter unit animations. Subtags with the same name must be written in the correct order to match them with the tag they are supposed to modify. Note that keys will be processed in arbitrary order, which may cause problems if you use formulas that depend on other formulas. To work around this you may need to use the tag twice with the same filter.&lt;br /&gt;
example usage (see also the test scenario):&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[modify_unit]&lt;br /&gt;
  [filter]&lt;br /&gt;
    x,y=38,6&lt;br /&gt;
  [/filter]&lt;br /&gt;
  hitpoints=10&lt;br /&gt;
  {TRAIT_HEALTHY}&lt;br /&gt;
[/modify_unit]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit which is currently modified is accessible via $this_unit, e.g. hitpoints = &amp;quot;$($this_unit.hitpoints / 2)&amp;quot; to set the hitpoints of all units to half of their current value. This this_unit variable is independent from the this_unit variable available in the SUF used to determine which units to modify (first all matching units are gathered, and then all those are modified).&lt;br /&gt;
&lt;br /&gt;
Modifying a unit ''may'' trigger an advancement event if the experience is set higher than the max_experience. However, this behaviour should not be relied upon to happen under all circumstances; if it's desired, the event should be triggered separately, for example with '''[transform_unit]'''. Setting value, including empty string, of ''type'' acts as shortcut of ''experience=&amp;quot;$this_unit.max_experience&amp;quot;''.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Some some properties of the units are reset sometimes (for example when the unit advances or when [remove_object] is called), so it's usually better to change them with [object] ([object] inside [modify_unit]) than to change those properties directly via [modify_unit]. The following properties are ''not'' reset in [remove_object] and are thus safe to use directly in [modify_unit]:&lt;br /&gt;
* '''side'''&lt;br /&gt;
* '''gender'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''canrecruit'''&lt;br /&gt;
* '''unrenamable'''&lt;br /&gt;
* '''extra_recruit'''&lt;br /&gt;
* '''[variables]'''&lt;br /&gt;
* '''facing'''&lt;br /&gt;
* '''x, y'''&lt;br /&gt;
* '''goto_x, goto_y'''&lt;br /&gt;
* '''hitpoints'''&lt;br /&gt;
* '''experience'''&lt;br /&gt;
* '''moves'''&lt;br /&gt;
* '''[status]'''&lt;br /&gt;
* '''attacks_left'''&lt;br /&gt;
* '''role'''&lt;br /&gt;
&lt;br /&gt;
=== [transform_unit] ===&lt;br /&gt;
Transforms every unit on the map matching the filter to the given unit type. Keeps intact hit points, experience and status. If the unit is transformed to a non-living type (undead or mechanical), it will be also unpoisoned. Hit points will be changed if necessary to respect the transformed unit's maximum hit points. Regardless of anything else, the unit will be rebuilt. Thus, transforming a unit to its current type is a way to force a rebuild, for example after manually removing a modification.&lt;br /&gt;
* [[StandardUnitFilter]]: do not use a [filter] tag.&lt;br /&gt;
* '''transform_to''': the unit type in which all the units matching the filter will be transformed. If missing, the units will follow their normal advancement.&lt;br /&gt;
&lt;br /&gt;
=== [petrify] ===&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are petrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [unpetrify] ===&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are unpetrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [object] ===&lt;br /&gt;
Gives some unit an object which modifies their stats in some way. This tag can also be used in places that don't support ActionWML, such as [[#.5Bmodify_unit.5D|[modify_unit]]] or [[SingleUnitWML|[unit][modifications]]]. The following is supported in all these places:&lt;br /&gt;
* '''[effect]''': one or more effect elements may be listed.  See [[EffectWML]] for a description of [effect].&lt;br /&gt;
* '''duration''':&lt;br /&gt;
**if 'scenario', effects only last until the end of the scenario.&lt;br /&gt;
**if 'forever' or not set, effects never wear off.&lt;br /&gt;
** if 'turn', effects only last until the start of the unit's next turn (when the unit refreshes movement and attacks). (Like other start-of-turn behavior, objects with a duration of &amp;quot;turn&amp;quot; won't expire before turn 2.)&lt;br /&gt;
** {{DevFeature1.13|1}} if 'turn end', effects only last until the end of the unit's next turn (exactly like the slowed status).&lt;br /&gt;
* Other keys, such as '''id''', may be used to remove the object later, but are not used by the engine. An '''[object]''' tag can contain any arbitrary data that may be helpful to identify the object to remove later using a [[FilterWML#Filtering_on_WML_data|WML filter]].&lt;br /&gt;
&lt;br /&gt;
The following is supported only when using '''[object]''' as ActionWML:&lt;br /&gt;
* '''id''': (Optional) By default, an object with a defined ID can only be picked up once per scenario, even if it is removed later or first_time_only=no is set for the event. You can remove this restriction by setting take_only_once=no. For filtering objects, it might be simpler to use a custom key such as item_id. The id string can contain only letters, numbers and underscores. The ID is also commonly used to manually remove the object later, for example with [[#.5Bremove_object.5D|[remove_object]]].&lt;br /&gt;
* '''take_only_once''': (default yes) {{DevFeature1.13|6}} If set to &amp;quot;no&amp;quot;, the object's ID does not prevent it from being taken more than once.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object] is not variable-substituted at execution time of the event where this [object] is within.  You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. The first unit found that matches the filter will be given the object. Only on-map units are considered. If no unit matches or no [filter] is supplied, it tries to apply the object to the unit at the $x1,$y1 location of the event where this [object] is in. The case of no unit being at that spot is handled in the same way as no unit matching a given filter ([else] commands executed, cannot_use_message displayed). Note that units on the recall list will not be checked. To add an [object] to a unit on the recall list you have to use '''[modify_unit][object]'''.&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 '''[remove_item]''' tag, but you could probably put any tags that otherwise work in a [then] tag.&lt;br /&gt;
* '''[else]''': a subtag that lets you execute actions if the filter conditions are *not* met.&lt;br /&gt;
* '''silent''': whether or not messages should be suppressed. Default is &amp;quot;no&amp;quot;. {{DevFeature1.13|2}} If no description is provided, this defaults to yes, but can still be overridden.&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;
* '''description''': (translatable) displayed as a message of the image.&lt;br /&gt;
* '''cannot_use_message''': (translatable) displayed instead of '''description''' if no unit passes the filter test.&lt;br /&gt;
&lt;br /&gt;
=== [remove_object] ===&lt;br /&gt;
{{DevFeature1.13|6}}&lt;br /&gt;
&lt;br /&gt;
Removes an object from matching units.&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching objects removed. Use no [filter] tag.&lt;br /&gt;
* '''object_id''': The id of the object to be removed.&lt;br /&gt;
&lt;br /&gt;
Note that some unit properties are not restored ideally, e.g. current unit's health reversion might not work as expected (max_hitpoints will though). {{DevFeature1.15|0}} This was fixed.&lt;br /&gt;
&lt;br /&gt;
Note that [remove_object] works the following way: &lt;br /&gt;
&lt;br /&gt;
# Remove the object from the unit&lt;br /&gt;
# Rebuild the unit to make the changes effective.&lt;br /&gt;
&lt;br /&gt;
Step 2 implies that changes done for example via [modify_unit] (or via the [store_unit] + [set_variable] + [unstore_unit] technique) will be reset if those changes change a property that is a property of the unit type. See the note under [[#.5Bmodify_unit.5D|[modify_unit]]] to get a list of properties that can safely be changed via [modify_unit].&lt;br /&gt;
&lt;br /&gt;
=== [remove_trait] ===&lt;br /&gt;
{{DevFeature1.15|2}}&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching traits removed. Use no [filter] tag.&lt;br /&gt;
* '''trait_id''': The id of the trait to be removed. See [[UnitsWML#.5Btrait.5D|[trait]]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list of sides. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles for which shroud should be removed&lt;br /&gt;
&lt;br /&gt;
=== [place_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles on which shroud should be placed&lt;br /&gt;
&lt;br /&gt;
=== [lift_fog] ===&lt;br /&gt;
Lifts the fog of war from parts of the map for a certain side (only relevant for sides that have fog=yes), allowing a player to witness what occurs there even if that player has no units within vision range.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the tiles from which fog should be lifted.&lt;br /&gt;
* '''multiturn''': ''yes/no, default:no''. The default (not multiturn) causes fog to be removed in the same way that normal vision works; the cleared tiles will remain cleared until fog is recalculated (which normally happens when a side ends its turn). When multiturn is set to &amp;quot;yes&amp;quot;, the cleared tiles remain clear until {{tag||reset_fog}} cancels the clearing. This allows tiles to remain clear for multiple turns, or to be refogged before the end of the current turn (without also refogging all tiles). Multiturn lifted fog is not shared with allies (even when share_vision=all).&lt;br /&gt;
&lt;br /&gt;
=== [reset_fog] ===&lt;br /&gt;
The primary use of this tag is to remove multiturn lifted fog (created by {{tag||lift_fog}}), which causes the fog to reset to what it would have been had WML not interfered. (That is, hexes that a side's units could not see at any point this turn will be re-fogged, while seen hexes remain defogged.)&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the fog reset will be restricted to these tiles.&lt;br /&gt;
* '''reset_view''': ''yes/no, default: no'' If set to &amp;quot;yes&amp;quot;, then in addition to removing multiturn fog, the side's current view is canceled (independent of the SLF). This means that all hexes will become fogged for the side unless multiturn fog exists outside the tiles selected by the SLF. Normally, one would want the currently seen hexes to become clear of fog; this is done automatically at the end of many events, and it can be done manually with {{tag|InterfaceActionsWML|redraw}}.&lt;br /&gt;
Omitting both the SSF and the SLF would cancel all earlier uses of [lift_fog].&lt;br /&gt;
Additionally setting reset_view=&amp;quot;yes&amp;quot; would cause the side's entire map to be fogged (unless an ally keeps hexes clear by sharing its view).&lt;br /&gt;
&lt;br /&gt;
=== [allow_undo] ===&lt;br /&gt;
Normally when an event with a handler fires, the player's undo stack is cleared, preventing all actions performed so far from being undone. Including this tag in the event handler prevents the stack from being cleared for this reason, allowing the player to undo actions. (However, the stack might still be cleared for other reasons, such as fog being cleared or combat occurring.) In the common cases, this means '''[allow_undo]''' allows the current action to be undone even though an event was handled. There is a less common case, though &amp;amp;mdash; specifically when handling a menu item, where there is no current action &amp;amp;mdash; and in this case, '''[allow_undo]''' means merely that earlier actions can still be undone.&lt;br /&gt;
* Using this tag in a menu item has an additional side effect in 1.11. Starting with version 1.11.1, executing a WML menu item normally counts as doing something as far as the &amp;quot;you have not started your turn yet&amp;quot; dialog is concerned. However, a menu item whose handler includes '''[allow_undo]''' will not count.&lt;br /&gt;
&lt;br /&gt;
The types of actions that can be undone are movement, recalling, and dismissing a unit from the recall list. If an action is undone, only the position (or existence) of the involved unit will be restored; any altered variables or changes to the game will remain changed after the action 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 action the first time.&lt;br /&gt;
* Although recalling can be undone, recruitment can not be undone; this seems to apply even when the recruit's traits are not randomly-generated (tested on 1.12.6 and 1.14.4+dev).&lt;br /&gt;
&lt;br /&gt;
If an '''[event]''' uses both '''[allow_undo]''' and [[InternalActionsWML#.5Bfire_event.5D|'''[fire_event]''']] then the '''[allow_undo]''' must be after the '''[fire_event]'''.&lt;br /&gt;
&lt;br /&gt;
Due to a bug in 1.12 ([http://web.archive.org/web/20170330000414/http://gna.org/bugs/?23323 https://gna.org/bugs/?23323]) '''[allow_undo]''' should not be used in events that use one of the following things because it might cause OOS: &lt;br /&gt;
* [message] with [option]s&lt;br /&gt;
* [get_global_variable]&lt;br /&gt;
* wesnoth.synchronize_choice&lt;br /&gt;
&lt;br /&gt;
While in 1.13 using '''[allow_undo]''' together with those things won't give you a guaranteed OOS, there are some non-obvious situations where it will, for example assume the following event:&lt;br /&gt;
&lt;br /&gt;
   [event]&lt;br /&gt;
     name=&amp;quot;moveto&amp;quot;&lt;br /&gt;
     [message]&lt;br /&gt;
       message = &amp;quot;message&amp;quot;&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 1&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 2&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
     [/message]&lt;br /&gt;
     [allow_undo]&lt;br /&gt;
     [/allow_undo]&lt;br /&gt;
   [/event]&lt;br /&gt;
&lt;br /&gt;
It will cause OOS when the message is undone: since the event is already executed (erased) on one client only , the clients will disagree about how many choices happen during the next moveto action.&lt;br /&gt;
&lt;br /&gt;
=== [on_undo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Contains commands to execute when the player undoes the action which triggered the parent event.&lt;br /&gt;
*'''delayed_variable_substitution''' {{DevFeature1.13|5}}: ''yes/no, default no (always no before 1.13.5)'' As in [[EventWML]], specifies whether to perform variable substitution when the parent event is run, or when the contents are run. If delayed substitution is used, [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] from the parent event context are available, but may occasionally have unexpected values. (In particular, $unit.x and $unit.y may not have the expected value when undoing a move event, though $x1 and $y1 should be correct.)&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
It is not clear where whether the actionwml in [on_undo] in executed before or after the action is undone. Also, specially for enter/leave_hex events the units position when executing the [on_undo] code is usually different than when executing the original event. The recommended way to work around these issues is to refer to the unit by id instead of position and store all other needed information variables as 'upvalues'. You can also move the actual undo code to an external event. For example&lt;br /&gt;
 [event]&lt;br /&gt;
   name=&amp;quot;undo_blah&amp;quot;&lt;br /&gt;
   first_time_only=no&lt;br /&gt;
   [store_unit]&lt;br /&gt;
     id=&amp;quot;$moved_unit_id&amp;quot;&lt;br /&gt;
   [/store_unit]&lt;br /&gt;
   ... do undo stuff stuff&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 ... in some other event&lt;br /&gt;
   [on_undo]&lt;br /&gt;
     # store ''upvalues&lt;br /&gt;
     {VARIABLE moved_unit_id $unit.id}&lt;br /&gt;
     # call actual undo handler&lt;br /&gt;
     [fire_event]&lt;br /&gt;
       name = &amp;quot;undo_blah&amp;quot;&lt;br /&gt;
     [/fire_event]&lt;br /&gt;
   [on_undo]&lt;br /&gt;
&lt;br /&gt;
=== [on_redo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Same as [on_undo], except executes the commands on redo. Note that the parent event is not triggered again on a redo.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} [on_redo] is deprecated and has no effect anymore.&lt;br /&gt;
&lt;br /&gt;
Note that [on_redo] is not guaranteed to be called when redoing an action, the engine might also decide to just fire the original events again.&lt;br /&gt;
&lt;br /&gt;
=== [cancel_action] ===&lt;br /&gt;
Although Wesnoth 1.12 does not have this tag, it is the default behavior of '''enter_hex'''/'''exit_hex''' [event] in that version.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}} In this version, [cancel_action] is recognised, but has no effect (a bug).&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
In an '''enter_hex'''/'''exit_hex''' [event], interrupt the movement, leaving the unit where it is. This is intended to be used with an event that gives the player new information, to let the player choose whether to change their plans. For example, if the player has commanded a unit to move from (1,1) to (3,3) and attack a unit on (4,4); then a [cancel_action] inside an '''enter_hex''' [event] on (2,2) would make the unit stop on (2,2). A [cancel_action] inside an enter_hex [event] on (3,3) would let the player choose whether to attack.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
In a '''capture'''/'''moveto''' [event], interrupt the attack.&lt;br /&gt;
&lt;br /&gt;
=== [heal_unit] ===&lt;br /&gt;
Heal a unit. The variable '''$heal_amount''' will be set to the exact number of points healed (i.e can be less than the parameter '''amount''' if the unit is fully healed). $heal_amount contains only the number of hitpoints the first unit that was found got healed. When the variable is not needed, use {CLEAR_VARIABLE heal_amount} after this tag.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}} The '''$heal_amount''' variable is no longer set. Use the '''variable''' key instead.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] All matching on-map units are healed. If no filter is supplied, it is tried to take the unit at $x1, $y1.&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] all the units matching the filter ''and'' having the ''heals'' ability will have their animation played (if ''animate'' is set to yes) for each of the units healed.&lt;br /&gt;
*  '''amount''': (integer, default full) the maximum points the unit(s) will be healed. This can't be used to set the unit's hitpoints below 1 or above the unit's maximum hitpoints. If &amp;quot;full&amp;quot;, it fully heals the unit.&lt;br /&gt;
*  '''animate''': a boolean which indicate if the healing animations must be played. (default no)&lt;br /&gt;
*  '''moves''': (integer, default 0) The maximum current movement points the units will be &amp;quot;healed&amp;quot;. Can't set below 0 or above max_moves. If &amp;quot;full&amp;quot;, sets moves to max_moves.&lt;br /&gt;
* '''restore_attacks''': (boolean, default no) Whether the units' attacks_left should be reset to their max_attacks (usually 1).&lt;br /&gt;
* '''restore_statuses''': (boolean, default yes) Whether standard statuses should be reset to &amp;quot;no&amp;quot;. This affects poisoned, slowed, petrified and unhealable.&lt;br /&gt;
* '''variable''': {{DevFeature1.17|0}} creates an array with the given name; each item of the array has two fields, ''id='' (the ID of the unit being healed) and ''heal_amount='' (the amount of HPs the unit has been healed by).&lt;br /&gt;
&lt;br /&gt;
=== [harm_unit] ===&lt;br /&gt;
Harms every unit matching the filter, for the specific damage amount. When harming multiple units, the special variable '''$this_unit''' can be used to access the current unit being harmed. This obviously does not work inside the filters though, as they give '''$this_unit''' a different meaning.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] all matching units will be harmed (required).&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] if present, the first matching unit will attack all the units matching the filter above.&lt;br /&gt;
*  '''amount''': the amount of damage that will be done (required).&lt;br /&gt;
*  '''alignment''': (default neutral) applies an alignment to the damage, this means that if alignment=chaotic, the damage will be increased at night and reduced at day.&lt;br /&gt;
*  '''damage_type''': if present, amount will be altered by unit resistance to the damage type specified.&lt;br /&gt;
*  '''kill''': (default yes) if yes, when a harmed unit goes to or below 0 HP, it is killed; if no its HP are set to 1.&lt;br /&gt;
*  '''fire_event''': (default no) if yes, when a unit is killed by harming, the corresponding events are fired.  If yes, also the corresponding advance and post advance events are fired.&lt;br /&gt;
*  '''animate''': (default no) if yes, scrolls to each unit before harming it and plays its defense (or attack, if it's the harmer) and death animations. Special values supported, other than the usual yes and no, are &amp;quot;attacker&amp;quot;, that means only the harmer will be animated, and &amp;quot;defender&amp;quot;, that means only the harmed units will be animated. If the supplied value is yes, attacker or defender also advancement animations are played.&lt;br /&gt;
*  '''[primary_attack], [secondary_attack]''': these set the weapon against which the harmed units will defend, and that the harming unit will use to attack, respectively (notice this is the opposite of '''[filter]''' and '''[filter_second]''' above). This allows for playing specific defense and attack animations. Both tags are expected to contain a [[FilterWML#Filtering_Weapons|Standard Weapon Filter]].&lt;br /&gt;
*  '''delay''': if animate=yes, sets the delay (in milliseconds, default 500) between each unit harming.&lt;br /&gt;
*  '''variable''': if present, the damage caused to the unit, altered by resistances, will be stored in a WML array with the given name, under the ''harm_amount='' key. {{DevFeature1.17|0}} Each item of the array also has an ''id='' key, which contains the ID of the unit being harmed.&lt;br /&gt;
*  '''poisoned, slowed, petrified, unhealable''': (default no) if yes, every harmed unit that doesn't already have such status will have it set.&lt;br /&gt;
*  '''experience''': (default yes) If there is a harmer, experience will be attributed similar to regular combat. Can take list of values. When any value is provided, all unspecified experience types default to not giving experience. Supported values: {{DevFeature1.17|25}} until that version only experience=yes and experience=no are supported&lt;br /&gt;
** no - none of involved units get any experience (this value only works if it is the only value in list)&lt;br /&gt;
** kill - the harming unit receives experience based on level of harmed unit in attack which kills harmed unit&lt;br /&gt;
** attack - the harming unit receives experience based on level of harmed unit in attack which does not kill harmed unit, or in attack which kills harmed unit while kill experience is disabled&lt;br /&gt;
** defend - the unit being harmed receives experience based on level of harming unit in attack which does not kill harmed unit&lt;br /&gt;
** fight - short form of experience=attack,defend&lt;br /&gt;
** yes - short form of experience=kill,attack,defend&lt;br /&gt;
*  '''resistance_multiplier''': the harmed unit's resistance is multiplied by the supplied value; this means that a value lower than 1 increases it, and a value greater than 1 decreases it. Default value is 1, that means no modification.&lt;br /&gt;
&lt;br /&gt;
=== [time_area] ===&lt;br /&gt;
How a day should progress in a given area. Everywhere not specified in a [time_area] tag is affected by the [time] tags in the [scenario] tag.&lt;br /&gt;
* [[StandardLocationFilter]]: the locations to affect. ''note: only for [event][time_area]s - at scenario toplevel [time_area] does not support [[StandardLocationFilter]], only location ranges''&lt;br /&gt;
* '''[time]''': one or more tags describing the new schedule, see [[TimeWML]].&lt;br /&gt;
* '''id''': an unique identifier assigned to a time_area. Optional, unless you want to remove the time_area later or reference it from a location filter elsewhere. Can be a comma-separated list when removing time_areas, 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;
* '''current_time''': The time slot number (starting with zero) active at the creation of the area.&lt;br /&gt;
&lt;br /&gt;
''Example:'' (caves in parts of a map)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[time_area]&lt;br /&gt;
    id = cave_area&lt;br /&gt;
    x = 1-2,4-5&lt;br /&gt;
    y = 1-2,1-2&lt;br /&gt;
    {UNDERGROUND}&lt;br /&gt;
[/time_area]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifying an id allows the area to be referenced from location filters. Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
    [time_area]&lt;br /&gt;
        id = glyphs&lt;br /&gt;
        x = 9,14&lt;br /&gt;
        y = 11,3&lt;br /&gt;
    [/time_area]&lt;br /&gt;
    [event]&lt;br /&gt;
        name = moveto&lt;br /&gt;
        first_time_only=no&lt;br /&gt;
        [filter]&lt;br /&gt;
            side = 1&lt;br /&gt;
            [filter_location]&lt;br /&gt;
                area = glyphs&lt;br /&gt;
            [/filter_location]&lt;br /&gt;
        [/filter]&lt;br /&gt;
        # Do something, for example healing the unit&lt;br /&gt;
    [/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [remove_time_area] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
This is a syntactic shortcut for [time_area] remove=.&lt;br /&gt;
* '''id''': Comma-separated list of time area ids to remove.&lt;br /&gt;
&lt;br /&gt;
=== [end_turn] ===&lt;br /&gt;
End the current side's turn. The current event is finished before the turn is ended. Also, if the current event (where the tag appears) has been fired by another event, that event (and the complete stack of other possible parent events) is ended before [end_turn] comes into affect. Also, events following the event stack that fired [end_turn] are not omitted (e.g. [end_turn] is used by a side turn event and a turn refresh event does something afterwards).&lt;br /&gt;
&lt;br /&gt;
=== [replace_map] ===&lt;br /&gt;
&lt;br /&gt;
Replaces the entire map.&lt;br /&gt;
* '''map_data''': Content of a wesnoth map file. (This key used to be just '''map='''.) Example:&lt;br /&gt;
 map_data=&amp;quot;{campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map}&amp;quot;&lt;br /&gt;
* '''map_file''': {{DevFeature1.13|?}} Path to a Wesnoth map file; can be used instead of '''map'''. The file will be loaded when the tag is executed, rather than being embedded wholesale in the preprocessed WML. Example:&lt;br /&gt;
 map_file=campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map&lt;br /&gt;
{{DevFeature1.15|3}} If the file is not found directly, it will be searched for in the [[BinaryPathWML|[binary_path]]]. Assuming a standard campaign or add-on layout, the example above can be replaced by:&lt;br /&gt;
 map_file=01_The_Elves_Besieged.map&lt;br /&gt;
* '''expand''': if 'yes', allows the map size to increase. The expansion direction is currently always bottom-right.&lt;br /&gt;
* '''shrink''': if 'yes', allows the map size to decrease. If the map size is reduced, any units that would no longer be on the map due to its coordinates no longer existing will be put into the recall list.&lt;br /&gt;
Note: When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages it that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [replace_schedule] ===&lt;br /&gt;
Replace the time of day schedule of the entire scenario.&lt;br /&gt;
* [[TimeWML]]: the new schedule.&lt;br /&gt;
* '''current_time''': The time slot number (starting with zero) active at schedule replacement. ('''NB''': due to https://github.com/wesnoth/wesnoth/issues/5757 this attribute is ignored in versions 1.16.*. The fix was delivered in 1.17.* but wasn't backported due to backward-compatibility requirements)&lt;br /&gt;
&lt;br /&gt;
=== [tunnel] ===&lt;br /&gt;
&lt;br /&gt;
Create a tunnel between some locations, later usable by units to move from source hex to target hex (using the movement cost of unit on the target terrain).&lt;br /&gt;
&lt;br /&gt;
'''Behavior Change as of Wesnoth 1.13.6:''' Vision is now possible (and enabled by default) through tunnels and allied units on the exit hex do not block a tunnel by default any more. This is done in order for moves through tunnels to be consistent with other moves. The previous behavior can still be accomplished by using the new optional keys listed below.&lt;br /&gt;
&lt;br /&gt;
* '''[filter]''': (required) [[StandardUnitFilter]] the units which can use the tunnel. Leave empty for &amp;quot;all units&amp;quot;.&lt;br /&gt;
* '''[source]''': (required) [[StandardLocationFilter]] the source hex(es). Use $teleport_unit to filter on unit being teleported.&lt;br /&gt;
* '''[target]''': (required) [[StandardLocationFilter]] the target hex(es). Use $teleport_unit to filter on unit being teleported.&lt;br /&gt;
* '''id''': (optional) identifier for the tunnel, to allow removing.&lt;br /&gt;
* '''remove''': (boolean, default: no)  If yes, removes all defined tunnels with the same ID (then only id= is necessary).&lt;br /&gt;
* '''bidirectional''': (boolean, default: yes) If yes, creates also a tunnel in the other direction. &lt;br /&gt;
* '''always_visible''': (boolean, default: no) If yes, the possible movement of enemies under fog can be seen.&lt;br /&gt;
* '''allow_vision''': (boolean, default: yes) {{DevFeature1.13|6}} If no, vision through a tunnel is not possible. Note that in that case the tunnel cannot be used if the tunnel exit is under shroud (which previously was ''always'' the case).&lt;br /&gt;
* '''pass_allied_units''': (boolean, default: yes) {{DevFeature1.13|6}} If no, allied (including own) units on the exit hex block a tunnel.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean, default: yes): If yes, the WML block contained in this [tunnel] is not variable-substituted at execution time of the event where this [tunnel] is within. Instead, variables are substituted when the tunnel is used by a unit. See [[EventWML#Nested_Events]]&lt;br /&gt;
&lt;br /&gt;
(Note: The tunnel tag can also be used inside the [[AbilitiesWML|[teleport]]] ability, without remove= and id=).&lt;br /&gt;
&lt;br /&gt;
=== [do_command] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Executes a command, specified using the same syntax as a [command] tag in [[ReplayWML]]. Not all [command]'s are valid: only these are accepted&lt;br /&gt;
&lt;br /&gt;
* [attack]&lt;br /&gt;
* [move]&lt;br /&gt;
* [recruit]&lt;br /&gt;
* [recall]&lt;br /&gt;
* [disband]&lt;br /&gt;
* [fire_event]&lt;br /&gt;
* [lua_ai] {{DevFeature1.13|12}} This has been removed and is replaced with [custom_command]&lt;br /&gt;
&lt;br /&gt;
The tags corresponding to player actions generally use the same codepath as if a player had ordered it. That means for example that only moves that player would be allowed to do are possible, and movement is interrupted when sighting enemy unit.&lt;br /&gt;
&lt;br /&gt;
One purpose of this tag is to allow scripting of noninteractive scenarios -- without a tag like this, this might require elaborate mechanisms to coerce ais in order to test these code paths.&lt;br /&gt;
&lt;br /&gt;
This command should be replay safe if it is either invoked in a synced context, ''or'' invoked in code that is never synced, like AI code, a select event, or a menu item with `synced = false`. However, if you use desynchronized logic ''during'' an event that is otherwise synced, invoking [do_command] based on that desynchronized logic will result in out-of-sync errors during the replay; in this case, you must explicitly synchronize which command to do using something like the lua function wesnoth.sync.evaluate_single.&lt;br /&gt;
&lt;br /&gt;
=== [put_to_recall_list] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Puts a unit to the recall list of its side.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': the unit(s) to get put to the recall list.&lt;br /&gt;
* '''heal''': (default=no) Whether the unit should be refreshed, similar to the unit moving to the recall list at the end of a scenario.&lt;br /&gt;
&lt;br /&gt;
=== [set_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified achievement as completed and shows a popup stating it's been completed. The popup is not shown if the achievement has already been achieved.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
&lt;br /&gt;
=== [set_sub_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|17}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified sub-achievement as completed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''sub_id''': The id of the sub-achievement.&lt;br /&gt;
&lt;br /&gt;
=== [progress_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Progress an achievement by the specified amount, with an optional limit for how far the achievement can be progressed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''amount''': The amount to increment the achievement.&lt;br /&gt;
* '''limit''': (optional) Using this attribute will prevent achievements from progressing past this value.&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 [https://www.wesnoth.org/macro-reference.html 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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=74083</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=74083"/>
		<updated>2025-01-06T17:37:45Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* id */ when event has no id, but is in one [unit_type], there is no duplication, but when same event is provided by ability to multiple types, id is useful&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 [[ActionWML|actions]] which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer] 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;
'''Lexicon side note:''' ''The word &amp;quot;event&amp;quot; in the [event] tag itself may be considered an abbreviation of the term &amp;quot;event handler&amp;quot; because it is technically not a game &amp;quot;event&amp;quot; but an event '''handler''' for the game events fired with the given 'name'. However, this distinction is usually unimportant in most discussions and the event handlers are therefore simply referred to as &amp;quot;events&amp;quot; in this documentation.''&lt;br /&gt;
&lt;br /&gt;
=== The 'name' Key (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=&amp;lt;value&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This key defines which game event or trigger your [event] tag will be handling. This 'name' key should not be confused with a descriptive comment; it is rather a precise value which must match the predefined game event's name to be valid.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=attacker misses,defender misses&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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;
All predefined event types are listed below, along with a description of when this value will cause the event to be triggered, in the [[#Predefined_Events_Without_Filters|Predefined Events Without Filters]] and [[#Predefined_Events_With_Filters|Predefined Events With Filters]] sections. Any value ''not'' listed there is a custom event name which can be triggered only by a '''[fire_event]''' tag somewhere else. &lt;br /&gt;
&lt;br /&gt;
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;
==== Variables in the name ====&lt;br /&gt;
&lt;br /&gt;
If the name contains variables, they will be substituted each time the event is triggered. For example, '''name=turn $disaster_turn''' will only trigger if the turn number is currently equal to whatever number is stored in the variable '''$disaster_turn'''; updating the variable will adjust the turn that the event triggers on. However, if the variable contents contains a comma, it won't be parsed after substitution. Since an event name can't contain a comma, this means the event will never trigger.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Commas resulting from variable substitution are now parsed. If you write '''name=$important_event''' and the variable '''$important_event''' contains the text &amp;quot;capture,die&amp;quot;, the event will trigger on either a death or a village capture.&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. Also, custom events come very handy in [[Wml_optimisation]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# The following is the definition of a custom event &amp;quot;unit recruited&amp;quot;&lt;br /&gt;
[event]&lt;br /&gt;
    name=unit_recruited&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=unit&lt;br /&gt;
        message=_ &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
[/event]&lt;br /&gt;
&lt;br /&gt;
# This is a standard recruit event that triggers whenever a unit is recruited by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recruit&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # And now a fire_event tag is used to trigger the previously defined event. To use&lt;br /&gt;
    # &amp;quot;speaker=unit&amp;quot; in the fired event, it's also necessary to specify the [primary_unit].&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # As a result, every time side 1 recruits a unit, this unit says &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can have more code after the '''[fire_event]''', which will run after the fired event has happened.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# This is a standard recall event that triggers whenever a unit is recalled by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recall&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # Fire the custom event, exactly as the in recruit event&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # After that event has happened, the remaining code in this event is run&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=second_unit&lt;br /&gt;
        message=_ &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
    # As a result, every time side 1 recalls a unit, the recalled unit says&lt;br /&gt;
    # &amp;quot;Reporting for duty!&amp;quot;, and the leader replies &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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 trigger every time the criteria are met instead of only the first time.&lt;br /&gt;
&lt;br /&gt;
==== id ====&lt;br /&gt;
: If an id is specified, then the event will not be added if another event with the same id already exists. An id will also allow the event to be removed, see below. Supplying a non-empty id= is usually desired to avoid duplicates in case same [event] is used in multiple [unit_type] or ability/weapon special.&lt;br /&gt;
&lt;br /&gt;
==== remove ====&lt;br /&gt;
: Removes an event instead of adding a new one. This key takes a [[ConditionalActionsWML#Boolean_Values|boolean]]; if yes, does the same as a [[InternalActionsWML#.5Bremove_event.5D|[remove_event]]] with the same id= value, and the other attributes of this event tag are ignored.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} May be a comma separated list.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|7}} Prints a deprecation warning recommending to use [remove_event] instead.&lt;br /&gt;
&lt;br /&gt;
==== priority ====&lt;br /&gt;
: {{DevFeature1.17|20}} If several '[event]' tags have the same name, then any with a high priority value will be triggered before events with a lower priority value. Negative numbers are also supported, to run after events without a priority (as the attribute defaults to zero). For events with equal priority, the order is determined by the order in which the events were added.&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 based on the weapon used by the primary unit. This is usable in the events ''attack'', ''attacker hits'', ''attacker misses'', ''defender hits'', ''defender misses'', ''attack end'', ''last breath'', and ''die''. For more information and filter keys, see [[FilterWML#Filtering Weapons|Filtering Weapons]]. The most commonly used keys are the following.&lt;br /&gt;
:* '''name''': the name of the weapon used.&lt;br /&gt;
:* '''range''': the range of the weapon used.&lt;br /&gt;
:* '''special_id''': filter on the attack's weapon special id.&lt;br /&gt;
:* '''special_type''': filter on the attack's weapon special type.&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_id_active''': filter on the attack's weapon special id active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_type_active''': filter on the attack's weapon special type active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
&lt;br /&gt;
==== [filter_second_attack] ====&lt;br /&gt;
: Like [filter_attack], but for the weapon used by the secondary unit.&lt;br /&gt;
&lt;br /&gt;
==== [filter_condition] ====&lt;br /&gt;
: This tag makes sense inside any sort of event - even those that don't have units, or custom events,... The event will only trigger if this condition evaluates to true.&lt;br /&gt;
:* [[ConditionalActionsWML#Condition_Tags|Condition Tags]]&lt;br /&gt;
: note: This tag is meant to be used when the firing of an event shall be based on variables/conditions which cannot be retrieved from the filtered units.&lt;br /&gt;
&lt;br /&gt;
==== [filter_side] ====&lt;br /&gt;
: The current side (usually the side $side_number) must match the passed [[StandardSideFilter]] for the event to fire.&lt;br /&gt;
:* SSF tags and keys as arguments as described in [[StandardSideFilter]].&lt;br /&gt;
: note: This tag makes most sense in side turn and turn refresh events. However, all wml events have a current side so one could also prevent e.g. a moveto event from firing if you put a [filter_side] tag there and the moving unit's side doesn't match.&lt;br /&gt;
&lt;br /&gt;
==== [insert_tag] ====&lt;br /&gt;
: An '''[insert_tag]''' that expands to any of the above filter tags will result in the filter being loaded from the variable each time the game checks if the event should fire. This can result in the event's filter varying from turn to turn.&lt;br /&gt;
&lt;br /&gt;
==== filter_formula ====&lt;br /&gt;
:{{DevFeature1.17|6}}&lt;br /&gt;
: Similar to [filter_condition], but the condition is expressed in [[Wesnoth Formula Language]]. The formula has access to the following keys:&lt;br /&gt;
:*Event information:&lt;br /&gt;
:**'''event''' - the event name&lt;br /&gt;
:**'''event_id''' - the event's unique ID&lt;br /&gt;
:**'''event_data''' - additional information specific to the event, such as owner_side or damage_inflicted, or anything passed in '''[fire_event][data]'''.&lt;br /&gt;
:**'''loc''', '''unit''' - primary event location and unit&lt;br /&gt;
:**'''second_loc''', '''second_unit''' - secondary event location and unit&lt;br /&gt;
:**'''weapon''', '''second_weapon''' - primary and secondary weapon&lt;br /&gt;
:*Gamestate information:&lt;br /&gt;
:**'''turn_number'''&lt;br /&gt;
:**'''time_of_day''' - the time of day ID&lt;br /&gt;
:**'''side_number''' - currently active side&lt;br /&gt;
:**'''sides''' - a list of all sides&lt;br /&gt;
:**'''units''' - a list of all units on the map&lt;br /&gt;
:**'''map''' - the entire game map as a two-dimensional array&lt;br /&gt;
&lt;br /&gt;
==== delayed_variable_substitution ====&lt;br /&gt;
: This key is only relevant inside of a [[#Delayed Variable Substitution_2|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 [[ActionWML|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;
More details in [[ActionWML]]. Actions can also be dynamically inserted via '''[insert_tag]'''.&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;
In multiplayer it is only safe to use WML that might require synchronization with other players because of input or random numbers (like [message] with input or options or [unstore_unit] where a unit might advance) in the following events. This is because in these cases WML needs data from other players to work right and/or do the same thing for all players. This data is only available after a network synchronization.&lt;br /&gt;
&lt;br /&gt;
List of synchronized events:&lt;br /&gt;
* moveto&lt;br /&gt;
* enter hex&lt;br /&gt;
* exit hex&lt;br /&gt;
* sighted&lt;br /&gt;
* last breath &lt;br /&gt;
* menu item X&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;
* pre advance&lt;br /&gt;
* post advance &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;
* unit hits&lt;br /&gt;
* unit misses&lt;br /&gt;
* start&lt;br /&gt;
* prestart (prestart are synced but [message][option] &amp;amp; [unstore_unit] advancement choices will do a random decision because UI things don't work during prestart events.)&lt;br /&gt;
* new turn &lt;br /&gt;
* side turn &lt;br /&gt;
* turn X &lt;br /&gt;
* side X turn &lt;br /&gt;
* side X turn Y &lt;br /&gt;
* turn refresh&lt;br /&gt;
* side turn end&lt;br /&gt;
* side X turn end&lt;br /&gt;
* side turn X end&lt;br /&gt;
* side X turn Y end&lt;br /&gt;
* turn end&lt;br /&gt;
* turn X end&lt;br /&gt;
* {{DevFeature1.13|0}} enemies defeated&lt;br /&gt;
* {{DevFeature1.13|0}} time over&lt;br /&gt;
* {{DevFeature1.13|10}} victory&lt;br /&gt;
* {{DevFeature1.13|10}} defeat&lt;br /&gt;
* {{DevFeature1.13|0}} scenario_end&lt;br /&gt;
The following are &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; synced:&lt;br /&gt;
* select&lt;br /&gt;
* preload&lt;br /&gt;
* victory {{DevFeature1.13|10}} local_victory&lt;br /&gt;
* defeat {{DevFeature1.13|10}} local_defeat&lt;br /&gt;
* ai turn&lt;br /&gt;
&lt;br /&gt;
If an event is not listed here, ask someone to be sure.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility of events that are normally synchronized when fired by the engine but can be non-synchronized when fired by WML tags from non-synchronized event. So when you are using them you must be extra careful. For example [unstore_unit] may trigger a 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;
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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
=== Event IDs ===&lt;br /&gt;
&lt;br /&gt;
This problem can be avoided by setting an '''id''' on the event, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
#define DOUBLE&lt;br /&gt;
    [event]&lt;br /&gt;
        name=multiply_by_2&lt;br /&gt;
        id=doubler_event&lt;br /&gt;
        {VARIABLE_OP 2_becomes_4 multiply 2}&lt;br /&gt;
    [/event]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Events with the same ID will only be accepted once by the engine no matter how many times they are included, and will only be saved once to the scenario's savefile.  Events with an ID can also be removed by using the '''remove''' key, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    id=doubler_event&lt;br /&gt;
    remove=yes&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that WML is encountered (at toplevel or after created from another event), the event with this ID is removed from the scenario wml, thus firing it has no effect.  After an event is removed, it can still be re-added later.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events Without Filters ==&lt;br /&gt;
&lt;br /&gt;
These events do not take filter parameters (except [filter_condition] which works for all events).&lt;br /&gt;
&lt;br /&gt;
=== preload ===&lt;br /&gt;
&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.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a game is started, saved, and then reloaded, the preload event will fire two times while playing.  However, it will only fire once when viewing the replay. If the preload event alters the gamestate the second time it fired while playing (when loading the saved game) then it can result in Out Of Sync errors.&lt;br /&gt;
&lt;br /&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;
&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.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers after the map is shown but before the scenario begins -- before players can 'do' anything.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers at the start of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. 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;
=== turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. The WML variable '''side_number''' will contain the side that ended their turn.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of turn ''X''.&lt;br /&gt;
&lt;br /&gt;
=== side turn ===&lt;br /&gt;
&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;
&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. Note that this event might be called several times per turn in case that fallbacks to human or droiding is involved. I.e. it happens at the middle of turn of human side 1 if the human player droids his side. It happens after the selection of ai to play the turn but before AI is told that new turn has come.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''  ''This event can break replays if it is used improperly. The ai turn event does not fire during replays. The intention is only to guide the AI to make choices (movements, attacks) which are then saved to the replay.''&lt;br /&gt;
&lt;br /&gt;
=== turn refresh ===&lt;br /&gt;
&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. WML variable '''side_number''' holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
Note that the turn refresh event does occur on turn 1, even though healing, income and unit refreshing do not.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the start of turn ''X''. It's the first side initialization event. &lt;br /&gt;
&lt;br /&gt;
Side initialization events go in the order of: &lt;br /&gt;
&lt;br /&gt;
# '''turn ''X''''' &lt;br /&gt;
# '''new turn''' &lt;br /&gt;
# '''side turn''' &lt;br /&gt;
# '''side ''X'' turn''' &lt;br /&gt;
# '''side turn ''X''''' &lt;br /&gt;
# '''side ''X'' turn ''Y''''' &lt;br /&gt;
# '''turn refresh''' &lt;br /&gt;
# '''side ''X'' turn refresh''' &lt;br /&gt;
# '''turn ''X'' refresh''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' refresh'''&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ''Y'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of turn ''Y'' of side X &lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any turn of side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any side on turn X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side X turn Y refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X on turn Y&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers for any side at the refresh of turn X.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers after a side ends its turn. Like side turn, there are also some variations for specific combinations of side number and turn number. Here is the order in which the turn end events trigger:&lt;br /&gt;
&lt;br /&gt;
# '''side turn end''' &lt;br /&gt;
# '''side ''X'' turn end''' &lt;br /&gt;
# '''side turn ''X'' end''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' end''' &lt;br /&gt;
# '''turn end''' &lt;br /&gt;
# '''turn ''X'' end''' &lt;br /&gt;
&lt;br /&gt;
=== time over ===&lt;br /&gt;
&lt;br /&gt;
Triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
&lt;br /&gt;
=== enemies defeated ===&lt;br /&gt;
&lt;br /&gt;
Triggers when all sides that are not defeated are allied and if there is at least one human (or human networked) side among them. Especially this event triggers in a situaltion that would normaly cause a victory due to enemies defeated. (regardless of whether this was disabled with victory_when_enemies_defeated=no). &lt;br /&gt;
&lt;br /&gt;
=== local_victory ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 and earlier, the event described here is '''victory''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the player's side won. If it fires as a result of an '''[endlevel]''' tag, the event is processed before the line after the '''[endlevel]]''' tag. The event is not synchronized, as in networked mp it is possible to have different results for different players.&lt;br /&gt;
&lt;br /&gt;
=== local_defeat ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 are earlier, the event described here is '''defeat''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
Functions identically to '''local_victory''', except that the player's side lost.&lt;br /&gt;
&lt;br /&gt;
=== victory ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''victory''' event is equivalent to 1.14's '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game will proceed to the next scenario. In multiplayer, this means that it will fire on all players' clients, even for players who received a '''local_defeat''', as long as the game continues to the next scenario. This event is synchronized.&lt;br /&gt;
&lt;br /&gt;
It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:next_level&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.&lt;br /&gt;
&lt;br /&gt;
=== defeat ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''defeat''' event is equivalent to 1.14's '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game resulted in a game-over other than victoriously reaching the end of a campaign (including single-scenario campaigns). Synchronization (including bug #4667) is the same as '''victory'''.&lt;br /&gt;
&lt;br /&gt;
=== scenario_end ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|10}} This event fires immediately after '''victory''' or '''defeat'''; it is synchronized, but is also affected by bug #4667.&lt;br /&gt;
&lt;br /&gt;
Note: in 1.13.0 - 1.13.9 this event was added as a synchronized alternative to the events that are, since 1.13.10, called local_victory or local_defeat.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events With Filters ==&lt;br /&gt;
&lt;br /&gt;
Filters (except [filter_condition] which is for all sorts of events) 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]]. weapon and second_weapon variables are available inside attack, attacker_hits, defender_hits, unit_hits, die and last_breath events. See [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== moveto ===&lt;br /&gt;
&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. If the unit moves to a village, the capture event will be fired before this event. &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 undo other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.'' $x2 and $y2 refer to the hex the unit came from.&lt;br /&gt;
&lt;br /&gt;
=== sighted ===&lt;br /&gt;
&lt;br /&gt;
A '''sighted''' event is triggered by a unit becoming visible to a side (other than the unit's own side). This is mostly useful when the side seeing the unit uses [[fog of war]] or [[shroud]], but they still fire even when fog/shroud is not in use, and they do take into account the {{tag2|AbilitiesWML#The_.5Babilities.5D_tag|hides}} ability (for a moving unit and for ambushers). The ''primary unit'' is the unit that became visible, and the ''secondary unit'' belongs to the side that now sees the primary unit. In some cases, sighted events can be delayed from when they &amp;quot;should&amp;quot; occur. If that happens, the secondary unit will be filtered as if it was at the location where the event &amp;quot;should&amp;quot; have occurred, and ''x2,y2'' will store that location (not the current position of the secondary unit). To understand when sighted events fire, it is helpful to distinguish the times the acting unit sights other units from the times when the acting unit is sighted.&lt;br /&gt;
&lt;br /&gt;
An acting unit can sight other units when it is recruited, recalled, leveled, or moved, and when fog or shroud is cleared from occupied hexes as a result. In these cases, the acting unit is always the ''secondary unit''. For the first three actions, there are two events associated with the action; clearing occurs between these events, but any sighted events are fired after the second event. (For example, when a unit is recruited, the ''prerecruit'' event fires, then fog is cleared, then the ''recruit'' event fires, then ''sighted'' events fire.) For movement, the sighted events fire between ''enter_hex'' and ''exit_hex'' events, but sometimes sighted events are postponed until the moving unit reaches a good place to stop (e.g. not in an occupied hex). As a major exception to the above, players have the option to delay shroud (and fog) updates. If the player delays shroud updates, sighted events are also delayed until the shroud is updated.&lt;br /&gt;
&lt;br /&gt;
An acting unit can be sighted by other sides when it is recruited, recalled, leveled (in rare cases), or moved. In these cases, the acting unit is always the ''primary unit''. These events fire after sightings by the acting unit (unless the player delayed shroud updates). For the first two, the sighted event fires for all sides that can see the unit, other than the unit's own side (even if those sides use neither fog nor shroud). For leveling units, sides that could see the unit before it leveled are excluded. (This is why these events are rare &amp;amp;ndash; the leveling unit must have lost a [hides] ability as a result of leveling in order to be seen after, but not before, leveling.) For movement, a sighted event is fired for each side that could see the unit after movement, but not before. In particular, only the starting and ending hexes are considered; a unit that moves through seen hexes but ends movement in a fogged hex does not trigger a sighted event for itself. In all cases where the acting unit is sighted, a (single) ''secondary unit'' is chosen from the sighting team. This choice should be considered arbitrary, but units within their sight range of the acting unit are chosen in preference to units further away. You may want to use [filter_second] in order to restrict a sighted event in a single player scenario to only being triggered by the player and not by other non-allied sides.&lt;br /&gt;
&lt;br /&gt;
Sighted events are not triggered by a ''hides'' ability becoming inactive, unless it becomes inactive due to that unit's movement or to that unit ambushing another. (To detect a ''nightstalk'' ability becoming inactive due to time of day, use a ''new_turn'' event. Custom ''hides'' abilities might need similar handling.)&lt;br /&gt;
&lt;br /&gt;
Sighted events have some special caveats for WML authors. First and foremost, {{tag|DirectActionsWML|allow_undo}} should generally be avoided in sighted events. It can be used if current unit positions have no bearing on the event, but otherwise it could cause a replay to go out of sync if a player delays shroud updates and undoes a move. This should not be an onerous restriction, though, as clearing fog will block the ability to undo, regardless of what happens within an event. Secondly, it is currently possible for WML to kill a unit involved in a sighted event before that event fires. If that happens, filters on the killed unit will not match anything and the event may seem to have not fired.&lt;br /&gt;
&lt;br /&gt;
=== enter_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex entered during movement, with $x1,$y1 identifying the hex entered and $x2,$y2 identifying the previous hex (just exited). In Wesnoth 1.12, the movement will be interrupted, stopping the unit where it is; this behavior can be avoided by using the {{tag|DirectActionsWML|allow_undo}} tag or `NO_INTERRUPT_NO_UNDO` macro. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the entered hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (7ca5a0df, just before 1.13.11), if the hex is occupied then $unit contains the occupying unit, not the moving unit.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (1.16.2), if the hex is occupied then $unit does contain the moving unit.&lt;br /&gt;
&lt;br /&gt;
=== exit_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex exited during movement, with $x1,$y1 identifying the hex exited and $x2,$y2 identifying the next hex (to be entered). If this event is handled without using {{tag|DirectActionsWML|allow_undo}}, then movement is interrupted, stopping the unit where it is. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the exited hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
=== pre attack {{DevFeature1.17|7}}===&lt;br /&gt;
&lt;br /&gt;
Similar to '''attack''', but is triggered before calculating the number of attacks and the movement of the unit. Can be used for modifications, which affect these values.&lt;br /&gt;
&lt;br /&gt;
=== attack ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit attacks the secondary unit. Variables $weapon and $second_weapon contain weapons used for this attack by primary and secondary units respectively for all attack-related events (attack_end, attacker_hits, attacker_misses, defender_hits, defender_misses, die and last_breath).&lt;br /&gt;
&lt;br /&gt;
=== attack end ===&lt;br /&gt;
&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;
&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;
&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;
&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;
&lt;br /&gt;
Same as ''defender hits'', but is triggered when the defender misses.&lt;br /&gt;
&lt;br /&gt;
=== unit hits {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the the primary unit (either attacker or defender) hits the secondary unit (the other). The value of the WML variable '''damage_inflicted''' is set to the number of hitpoints inflicted by the primary unit.&lt;br /&gt;
&lt;br /&gt;
Compared to ''defender hits'', primary and secondary units are swapped. &lt;br /&gt;
&lt;br /&gt;
=== unit misses {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Same as ''unit hits'', but is triggered when the unit misses.&lt;br /&gt;
&lt;br /&gt;
=== petrified ===&lt;br /&gt;
Triggers when the primary unit is hit by an attack with the 'petrifies' ability (See ''petrifies'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'petrifies' ability).&lt;br /&gt;
&lt;br /&gt;
=== last breath ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered. Use this instead of name=die when you want the primary unit to make a final [message]. &lt;br /&gt;
&lt;br /&gt;
=== die ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit. ''Note: The primary unit is not removed from the game until the end of this event. The primary unit can still be manipulated, will block other units from taking its hex, and will still be found by standard unit filters (except [have_unit]). To prevent this behavior, you can use [kill] to remove the unit immediately. However, this will stop any (still unfired) other events that also match the unit from firing afterwards, so use with caution.'' If you want the primary unit to make a final [message], use name=last_breath, see above.&lt;br /&gt;
&lt;br /&gt;
=== capture ===&lt;br /&gt;
&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. This event will be fired before the moveto event. Villages becoming neutral (via [capture_village]) do not fire capture events. The variable $owner_side contains the previous owner side of the village. 0 means neutral.&lt;br /&gt;
&lt;br /&gt;
=== recruit ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit). (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;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== recall ===&lt;br /&gt;
&lt;br /&gt;
Triggers after the primary unit is recalled (by the secondary unit).&lt;br /&gt;
&lt;br /&gt;
=== prerecall ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recalled (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just before the primary unit is going to advance to another unit, or advance by AMLA. (This is after the player selects which advancement, if there is a choice). If this event removes the unit, changes the unit's type, or reduces the unit's experience below what it needs to advance, then the advancement is aborted. This also applies to advancement by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== pre advance ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} Triggers before the unit advancement dialog is shown. If this event removes the unit or reduces the unit's experience below what it needs to advance, then the advancement is aborted.&lt;br /&gt;
&lt;br /&gt;
Care needs to be taken when tags that may trigger advancement themselves are used in this event. For example '''[transform_unit]''', '''[unstore_unit]''', '''[modify_unit]''' etc.&lt;br /&gt;
&lt;br /&gt;
=== post advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just after the primary unit has advanced to another unit, or advance by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== select ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is selected. Prior to version 1.11, this also triggered when a move was interrupted, 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;
&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;
=== unit placed {{DevFeature1.13|3}}===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is placed on the map, regardless of method. This includes but might not be limited to:&lt;br /&gt;
* Leaders and units placed in side definitions (fired once for every unit right before prestart events)&lt;br /&gt;
* Recruited and recalled units&lt;br /&gt;
* Units placed on the map with the [unit] tag ('''not''' units created directly onto a recall list or variable)&lt;br /&gt;
* Units placed by the wesnoth.put_unit() Lua function&lt;br /&gt;
* Units placed by :to_map in Lua (which is a shortcut for the above)&lt;br /&gt;
* Units created via debug mode&lt;br /&gt;
* Units created by plague &lt;br /&gt;
* Every use of [unstore_unit], when ''fire_event'' is set to ''yes'' (default is ''no'')&lt;br /&gt;
* Units moved on map with [move_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units matching the filter of [petrify], [unpetrify] or [harm_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units who receive a bonus from the feeding ability every time except the first, before {{DevFeature1.15|8}}&lt;br /&gt;
This event is solely intended for special cases where no other event types suffice, for example if you must immediately apply a modification to every unit that ever appears. The event does '''not''' keep track of which units it has previously fired for, but can fire an unlimited number of times for the same unit as long the unit is &amp;quot;placed&amp;quot; several times and the event filter doesn't prevent it.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    name=last breath&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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way of doing this would be to create a single moveto event with a '''[filter_condition]''' statement to check for turn number but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[filter_condition]''' statements. Using '''[if]''' tags is also an option especially if your event has '''first_time_only=yes'''.&lt;br /&gt;
&lt;br /&gt;
=== Delayed Variable Substitution Example ===&lt;br /&gt;
&lt;br /&gt;
This code will display a message showing the turn number on which the nested ''moveto'' event happens.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, the following example is identical to the first two in that it will display a message showing the turn number 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multiple Nested Events ===&lt;br /&gt;
&lt;br /&gt;
Every delayed_variable_substitution=no causes a variable substitution run on the subevent where it occurs at the spawn time of this event and on all following subevents. For any specific event, variable substitution happens at least one time when the event is executed. For each delayed=no key appearing in itself or in an event of an &amp;quot;older&amp;quot; generation, which is not the toplevel event, an additional variable substitution run is made.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event] # parent&lt;br /&gt;
    name=turn 2&lt;br /&gt;
    # delayed_variable_substitution=no # In the parent event, delayed= has no effect.&lt;br /&gt;
 &lt;br /&gt;
    [event] # child&lt;br /&gt;
        name=turn 3&lt;br /&gt;
        delayed_variable_substitution=no # Causes variable substitution in the child, grandchild and great-grandchild event&lt;br /&gt;
        # at execution time of the parent event = spawn time of the child event.&lt;br /&gt;
&lt;br /&gt;
        [event]# grandchild&lt;br /&gt;
            name=turn 4&lt;br /&gt;
            delayed_variable_substitution=yes # no variable substitution in the grandchild and great-grandchild event&lt;br /&gt;
            # at execution time of the child event = spawn time of the grandchild event&lt;br /&gt;
&lt;br /&gt;
            [event] # great-grandchild&lt;br /&gt;
                name=turn 5&lt;br /&gt;
                {DEBUG_MSG $turn_number} # output: 2 - value from the variable substitution at execution time of the parent event,&lt;br /&gt;
                # caused by delayed=no in the child event&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $||turn_number}# output: &amp;quot;$turn_number&amp;quot;&lt;br /&gt;
                # Each variable substitution transforms a &amp;quot;$|&amp;quot; to a &amp;quot;$&amp;quot; (except when no | left).&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $|turn_number}# output: 5 - from the variable substitution at execution time&lt;br /&gt;
                # of the great-grandchild event&lt;br /&gt;
            [/event]&lt;br /&gt;
        [/event]&lt;br /&gt;
    [/event]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=74074</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=74074"/>
		<updated>2025-01-05T15:36:17Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Unit Type */ image_icon in recruit #9702&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
Each '''[unit_type]''' tag defines one unit type. (for the use of [unit] to create a unit, see [[SingleUnitWML]])&lt;br /&gt;
&lt;br /&gt;
Unit animation syntax is described in [[AnimationWML]]. In addition to the animation tags described there, the following key/tags are recognized:&lt;br /&gt;
* '''advances_to''': When this unit has ''experience'' greater than or equal to ''experience'', it is replaced by a unit of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by. The special value 'null' says that the unit does not advance but gets an AMLA instead. Can be a comma-separated list of units that can be chosen from upon advancing.&lt;br /&gt;
* '''alignment''': one of lawful/neutral/chaotic/liminal (See [[TimeWML]]). Default is &amp;quot;neutral&amp;quot;.&lt;br /&gt;
* '''attacks''': the number of times that this unit can attack each turn. Default is 1.&lt;br /&gt;
* '''cost''': when a player recruits a unit of this type, the player loses ''cost'' gold. If this would cause gold to drop below 0,  the unit cannot be recruited. Default is 1.&lt;br /&gt;
* '''recall_cost''': {{DevFeature1.13|0}} the default recall cost of units of this type, overriding the recall cost set in scenario [[SideWML|[side]]] tags or the global [[GameConfigWML|[game_config]]] value. Individual units may override this value in [[SingleUnitWML|[unit]]]. A value of -1 is equivalent to not specifying this attribute. {{DevFeature1.15|0}} Units are now recalled for AI sides even if the recall_cost is larger than the unit's worth (essentially its cost, plus potentially a bonus for experience points). In 1.14 and earlier, units were not recalled by the AI in this case even if this was the only recall/recruit action possible to the AI.&lt;br /&gt;
* '''description''': (translatable) the text displayed in the unit descriptor box for this unit. Default 'No description available...'. &lt;br /&gt;
* '''do_not_list''': Not used by the game, but by tools for browsing and listing the unit tree. If this is 'yes', the unit will be ignored by these tools. {{DevFeature1.13|?}} When placing units in debug mode this unit isn't listed (but can still be placed using the :create command). This restriction is lifted in version &amp;lt;b&amp;gt;1.14.3&amp;lt;/b&amp;gt;.&lt;br /&gt;
* '''ellipse''': the ellipse image to display under the unit, which is normally team-colored. Default is &amp;quot;misc/ellipse&amp;quot;. &amp;quot;-nozoc&amp;quot; and &amp;quot;-leader&amp;quot; are automatically appended for units without zone of control and with canrecruit=yes respectively. The [http://www.wesnoth.org/macro-reference.xhtml#IS_HERO IS_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#MAKE_HERO MAKE_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#UNMAKE_HERO UNMAKE_HERO] macros change the ellipse to/back from &amp;quot;misc/ellipse-hero&amp;quot;. Finally, setting this to &amp;quot;none&amp;quot; will cause the unit to not have any ellipses displayed under it regardless of the user's preferences.&amp;lt;br/&amp;gt;WARNING: Be aware that setting this to &amp;quot;misc/ellipse-hero&amp;quot; for a unit with canrecruit=yes will result in the ellipse being &amp;quot;misc/ellipse-hero-leader&amp;quot;, which is not a supported combination (it doesn't have a graphic, and will cause error logs that the graphic is missing). This is tracked as bug [https://github.com/wesnoth/wesnoth/issues/6258 6258] on GitHub.&amp;lt;br/&amp;gt;{{DevFeature1.17|26}} canrecruit=yes is now supported with &amp;quot;misc/ellipse-hero&amp;quot;, since &amp;quot;misc/ellipse-hero-leader&amp;quot; has been added in [https://github.com/wesnoth/wesnoth/pull/8375 8375].&lt;br /&gt;
* '''experience''': When this unit has experience greater than or equal to ''experience'', it is replaced by a unit with 0 experience of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by.&lt;br /&gt;
* '''flag_rgb''': usually set by [http://www.wesnoth.org/macro-reference.xhtml#MAGENTA_IS_THE_TEAM_COLOR MAGENTA_IS_THE_TEAM_COLOR]; specifies the colours in the base flag to use for team-colouring the unit, expressed as a colour name (such as magenta) or a comma-separated list of RGB values (in hex format).&lt;br /&gt;
* '''gender''': has a value of either ''male'' or ''female'', and determines which of the keys ''male_names'' and ''female_names''  should be read. When a unit of this type is recruited, it will be randomly assigned a name by the random name generator, which will use these names as a base. If '''gender''' is not specified it defaults to ''male''.&lt;br /&gt;
* '''halo''': an image to place centered on the unit. It is drawn on top of the unit, and on top of surrounding units if the image is larger than one hex. It works similarly to the halo attribute of {{tag|InterfaceActionsWML|item}}, and it can be animated with a comma-separated list of images.&lt;br /&gt;
* '''hide_help''': (yes|no) default=no. Determines if the unit type will appear in the in-game help.&lt;br /&gt;
* '''hitpoints''': the maximum HP that the unit has, and the HP it has when it is created.&lt;br /&gt;
* '''id''': the value of the ''type'' key for units of this type. This is required and must be unique among all [unit_type] tags. An ''id'' must consist only of alphanumerics and spaces (or underscores). ''type'' keys are found in [[SingleUnitWML]] and [[FilterWML]]. For example, id=Drake Flare&lt;br /&gt;
*'''ignore_race_traits''': 'yes' or 'no' (default). Determines whether racial traits (see [[UnitsWML]]) are applied. &lt;br /&gt;
* '''image''': sets the base image of the unit, which is used on the map.&lt;br /&gt;
* '''image_icon''': sets the image used to represent the unit in areas such as the recruit dialog, attack dialog and the unit image box in the sidebar. [[ImagePathFunctions#Crop_Function|~CROP]] function can be useful here. You can see Loyalists Paladin as an example.&lt;br /&gt;
* '''level''': the amount of upkeep the unit costs.  After this unit fights, its opponent gains ''level'' experience. See also kill_experience ([[GameConfigWML]]), and leadership ([[AbilitiesWML]]).&lt;br /&gt;
* '''upkeep''': the amount of upkeep the unit costs if it differs from its level.&lt;br /&gt;
* '''movement''': the number of move points that this unit receives each turn.&lt;br /&gt;
* '''movement_type''': See [[UnitsWML#.5Bmovetype.5D|movetype]]. Note that the tags '''[movement_costs]''', '''[vision_costs]''', '''[defense]''', and '''[resistance]''' can be used to modify this movetype.&lt;br /&gt;
* '''name''': (translatable) displayed in the Status Table for units of this type.&lt;br /&gt;
* '''num_traits''': the number of traits that units of this type should receive when they are recruited, overriding the value set in the [race] tag.&lt;br /&gt;
* '''profile''': the portrait image to use for this unit type. You can also set a portrait for an individual unit instead of the whole unit type (see [[SingleUnitWML]]). The engine first looks for the image in the transparent subdirectory and if found that image is used. If not found it will use the image as-is. Depending on the size the engine will or will not scale the image, the cutoff currently is at 300x300. For images which should only be shown on the right side in the dialog append ~RIGHT() to the image.&lt;br /&gt;
** If &amp;quot;unit_image&amp;quot; is given instead of a filename, uses the unit's base image as the portrait (in the same manner that unit types without portraits do by default).&lt;br /&gt;
** If &amp;quot;none&amp;quot; is given instead of a filename, no image will be displayed.&lt;br /&gt;
* '''small_profile''': the image to use when a smaller portrait is needed than the one used for messages (e.g., in the help system). When this attribute is missing, the value of the '''profile''' attribute is used instead. When present, the heuristic for finding a transparent portrait is disabled for the '''profile''' attribute, so the correct '''profile''' should be set too. If '''profile''' is not present, '''small_profile''' is ignored. Note that image modifiers are allowed; they might be useful for cropping and rescaling a portrait:&lt;br /&gt;
 small_profile=&amp;quot;portraits/elves/transparent/marksman+female.png~CROP(0,20,380,380)~SCALE(205,205)&amp;quot;&lt;br /&gt;
 profile=&amp;quot;portraits/elves/transparent/marksman+female.png&amp;quot;&lt;br /&gt;
* '''race''': See {{tag|UnitsWML|race}}.  Also used in standard unit filter (see [[FilterWML]]). Mainline Wesnoth features following values:  bats, drake, dwarf, elf, falcon, goblin, gryphon, human, dunefolk, lizard, mechanical, merman, monster, naga, ogre, orc, troll, undead, wolf, wose. They are defined in /data/core/units.cfg.&lt;br /&gt;
* '''undead_variation''': When a unit of this type is killed by a weapon with the plague special, this variation is applied to the new plague unit that is created, whatever its type. For example, if the plague special creates Walking Corpses and undead_variation is set to &amp;quot;troll&amp;quot;, you'll get a troll Walking Corpse. Defaults to the undead_variation set in this unit type's race.&lt;br /&gt;
* '''usage''': the way that the AI should recruit this unit, as determined by the scenario designer. (See ''recruitment_pattern'', [[AiWML]]).  The following are conventions on usage:&lt;br /&gt;
** ''scout'': Fast, mobile unit meant for exploration and village grabbing.&lt;br /&gt;
** ''fighter'': Melee fighter, melee attack substantially more powerful than ranged.&lt;br /&gt;
** ''archer'': Ranged fighter, ranged attack substantially more powerful than melee.&lt;br /&gt;
** ''mixed fighter'': Melee and ranged fighter, melee and ranged attacks roughly equal.&lt;br /&gt;
** ''healer'': Specialty 'heals' or 'cures'.&lt;br /&gt;
:Note that this field primarily affects recruitment.  It also has a small effect on unit movement (the AI tries to keep scouts away from enemies, to some extent).  It does not affect the AI's behavior in combat; that is always computed from attack power and hitpoints. Non-standard usages may be used as well.&lt;br /&gt;
* '''vision''': the number of vision points to calculate the unit's sight range. Defaults to ''movement'' if not present.&lt;br /&gt;
* '''jamming''': the number of jamming points. Defaults to ''0'' if not present. See [[UnitsWML#.5Bmovetype.5D|[jamming_costs]]]&lt;br /&gt;
* '''zoc''': if &amp;quot;yes&amp;quot; the unit will have a zone of control regardless of level.  If present but set to anything other than &amp;quot;yes,&amp;quot; the unit will have no zone of control.  If the tag is omitted, zone of control is dictated by unit level (level 0 = no zoc, level 1+ = has zoc).&lt;br /&gt;
* '''die_sound''': sets the sound, which is used when the unit dies.&lt;br /&gt;
* '''healed_sound''': sets the sound used when the unit is healed in any way (default: heal.wav).&lt;br /&gt;
* '''hp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''xp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''bar_offset_x''', '''bar_offset_y''': The offset of the hp and xp bars from the normal bar position of 72x72 unit sprite.&lt;br /&gt;
&lt;br /&gt;
== After max level advancement (AMLA) ==&lt;br /&gt;
* '''[advancement]''': describes what happens to a unit when it reaches the XP required for advancement.  It is considered as an advancement in the same way as advancement described by '''advances_to'''; however, if the player chooses this advancement, the unit will have one or more effects applied to it instead of advancing.&lt;br /&gt;
** '''id''': unique identifier for this advancement; ''Required'' if there are multiple advancement options, or if ''strict_amla=no''.&lt;br /&gt;
** '''always_display''': if set to true displays the AMLA option even if it is the only available one.&lt;br /&gt;
** '''description''': a description displayed as the option for this advancement if there is another advancement option that the player must choose from; otherwise, the advancement is chosen automatically and this key is irrelevant.&lt;br /&gt;
** '''image''': an image to display next to the description in the advancement menu.&lt;br /&gt;
** '''max_times''': default 1.  The maximum times the unit can be awarded this advancement. Pass -1 for &amp;quot;unlimited&amp;quot;.&lt;br /&gt;
** '''strict_amla''':  (yes|no) default=no. Disable the AMLA if the unit can advance to another unit.&lt;br /&gt;
** '''major_amla''': (yes|no) default=no. Sets whether the unit's XP bar is blue(=yes) or purple(=no). In case of more [advancement] tags, if there is one with major_amla=yes, the XP bar will be blue.&lt;br /&gt;
** '''require_amla''': An optional list of AMLA ''id'' keys that act as prerequisites for this advancement to become available.  Order is not important, and an AMLA id can be repeated any number of times to indicate that another advancement must be chosen several times before this advancement option will become available.&lt;br /&gt;
*** example: &amp;lt;tt&amp;gt;require_amla=tough,tough,incr_damage&amp;lt;/tt&amp;gt; assumes there exist other [advancement] options called ''id=tough'' and ''id=incr_damage''.  Once ''tough'' is chosen twice and ''incr_damage'' is chosen once, then the current [advancement] will become available.&lt;br /&gt;
*** ''require_amla=tough,incr_damage,tough'' is an equivalent way of expressing this.&lt;br /&gt;
** '''exclude_amla''': {{DevFeature1.13|2}} An optional list of AMLA ''id'' keys that represent AMLAs that are mutually exclusive to this one. Order is not important, and an AMLA id can be repeated. If the unit already has any of the AMLAs that appear once in this list, then this AMLA will not be made available. If an AMLA id appears multiple times in the list, then this AMLA will be made available only if the other AMLA has been chosen less than the number of times it appears in the list. Of course, for this to really make two AMLAs mutually exclusive, you need to add ''exclude_amla'' to both AMLA defintions.&lt;br /&gt;
** '''[effect]''': A modification applied to the unit whenever this advancement is chosen.  See [[EffectWML]]&lt;br /&gt;
** '''[filter]''': A  [[StandardUnitFilter]],  the advancement will only be available when the unit passes this filter during the time the advancement dialog is shown.&lt;br /&gt;
&lt;br /&gt;
== Attacks ==&lt;br /&gt;
* '''[attack]''': one of the unit's attacks.&lt;br /&gt;
** '''description''': a translatable text for name of the attack, to be displayed to the user.&lt;br /&gt;
** '''name''': the name of the attack. Used as a default description, if ''description'' is not present, and to determine the default icon, if ''icon'' is not present (see below).  Non-translatable.  Used for the ''has_weapon'' key and animation filters; see [[StandardUnitFilter]] and [[AnimationWML]]&lt;br /&gt;
** '''type''': the damage type of the attack.  Used in determining resistance to this attack (see {{tag|UnitsWML|movetype|resistance}}). Usually this is one of ''blade'', ''pierce'', ''impact'', ''fire'', ''cold'', or ''arcane'', but it can be set to anything (as long as it contains only letters, numbers, and underscores). When using a custom type, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom damage type in the sidebar, the game will look for a file called icons/profiles/''type''.png under your addon's images folder. For example, the icon for a damage type called ''electric'' would be at images/icons/profiles/electric.png.&lt;br /&gt;
** '''[specials]''': contains the specials of the attack. See [[AbilitiesWML#The_.5Bspecials.5D_tag|AbilitiesWML]].&lt;br /&gt;
** '''icon''': the image to use as an icon for the attack in the attack choice menu, as a path relative to the images directory. Defaults to the attack's name in the attacks directory (Ex. if ''name=sword'' then default is ''icon=attacks/sword.png''). &lt;br /&gt;
** '''range''': the range of the attack.  Used to determine the enemy's retaliation, which will be of the same type. The range can be anything (as long as it contains only letters, numbers, and underscores), but the standard values are ''melee'' and ''ranged''. Units can only retaliate against attacks for which they have a corresponding attack of the same range. When using a custom range, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom range in the sidebar the game will look for a file called icons/profiles/''range''_attack.png under your addon's images folder. For example, the icon for a range called ''very_long'' would be at images/icons/profiles/very_long_attack.png.&lt;br /&gt;
** '''max_range''': maximum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''min_range''': minimum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''damage''': the damage of this attack&lt;br /&gt;
** '''number''': the number of strikes per attack this weapon has&lt;br /&gt;
** '''accuracy''': a number added to the chance to hit whenever using this weapon offensively (i.e. during a strike with this attack, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''parry''': a number deducted from the enemy chance to hit whenever using this weapon defensively (i.e. during the enemy's strike, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''movement_used''': determines how many movement points using this attack expends. By default all movement is used up, set this to 0 to make attacking with this attack expend no movement.&lt;br /&gt;
** '''attacks_used''': {{DevFeature1.17|12}} determines how many attacks this attack expends (default 1). This number is deducted from the unit's &amp;lt;tt&amp;gt;attacks_left&amp;lt;/tt&amp;gt; when they use this attack.&lt;br /&gt;
** '''attack_weight''': multiplier for total damage that the AI should use to choose which attack to use when attacking (and offer to player as default). Setting it to 0 disables the attack on attack. Until {{DevFeature1.19|2}} positive attack_weight was ignored.&lt;br /&gt;
** '''defense_weight''': used to determine which attack is used for retaliation. This affects gameplay, as the player is not allowed to determine his unit's retaliation weapon. Setting it to 0 disable the attacks on defense.&lt;br /&gt;
** '''alignment''': {{DevFeature1.19|5}} one of lawful/neutral/chaotic/liminal (See TimeWML). Default is unit alignment.&lt;br /&gt;
&lt;br /&gt;
== Other tags ==&lt;br /&gt;
* {{anchor|base_unit|'''[base_unit]'''}}: Contains one attribute, '''id''', which must be the ID of a unit type.  If specified, the UnitTypeWML for that unit is copied into this one, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Additionally, the unit will be marked as variation of the base unit in its own help page, but not in the help page of the base unit.&lt;br /&gt;
&lt;br /&gt;
* '''[abilities]''': Defines the abilities of a unit. See [[AbilitiesWML]]&lt;br /&gt;
&lt;br /&gt;
* '''[event]''': Any [event] written inside the [unit_type] tag will get included into any scenario where a unit of this type appears in. Note that such events get included when a unit of this type first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[EventWML]] and [[WML_Abilities|WML Abilities]]. {{DevFeature1.19|4}} Abilities support [event].&lt;br /&gt;
&lt;br /&gt;
* {{anchor|variation|'''[variation]'''}}: Defines a variation of a unit. Variations are invoked with an [effect] tag or the variation= attribute in [[SingleUnitWML]]. They are currently used for graphical variations (giving character sprites new weapons) but theoretically you could do anything with it.&lt;br /&gt;
** '''variation_id''': Mandatory. The value of '''variation=''' used in SingleUnitWML to choose this variant.&lt;br /&gt;
** '''variation_name''': Translatable. The name of the variation, which is displayed in the help and in debug mode. Not setting this looks bad unless combined with '''hide_help'''=yes.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to no.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All keys and tags of '''[unit_type]''', except ''[advancefrom]'', ''[base_unit]'', ''[female]'', ''[male]'', and ''[variation]''.&lt;br /&gt;
&lt;br /&gt;
* '''[male]''', '''[female]''': These can specify a variation based on gender for a unit. If these are provided, they will automatically apply based upon the gender of a unit.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to yes.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All '''[unit_type]''' tags and keys, excluding ''[advancefrom]'', ''[base_unit]'', ''[female]'', and ''[male]''.&lt;br /&gt;
* '''[trait]''': Adds an additional trait to the pool. See [[UnitsWML]] for the syntax.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|2}} see [[UnitTypeWML#Special_Notes|below]].&lt;br /&gt;
&lt;br /&gt;
== Special Notes ==&lt;br /&gt;
&lt;br /&gt;
Use of the '''[special_note]''' tags and attributes results in a bulleted list of special notes in the unit type's help page and in the sidebar tooltip for the unit type's name. Prior to 1.15.2, the old format for special notes was simply text included in the '''[unit_type]description''' attribute.&lt;br /&gt;
&lt;br /&gt;
Note that the sidebar tooltip shows the notes for the current unit, but opening the help-browser by right-clicking on a unit shows the notes for generic units of that type. These can be different if the unit has '''[modifications]'''.&lt;br /&gt;
&lt;br /&gt;
Text given in the following attributes will be collected and shown as the special notes for units and unit types:&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.15|2}} [unit_type][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|2}} [unit][special_note]note= (these are used ''instead of'' any defined in the [unit_type])&lt;br /&gt;
* {{DevFeature1.15|14}} [movetype][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|14}} [''ability tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [attack][specials][''special tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [language]special_note_damage_type_''TYPE''=&lt;br /&gt;
    &lt;br /&gt;
It's no longer necessary to put these notes in each unit_type's .cfg file, and the macros for doing so are now deprecated.&lt;br /&gt;
&lt;br /&gt;
== Removed keys ==&lt;br /&gt;
&lt;br /&gt;
These don't work any more, the documentation is left here as an aid to porting old code.&lt;br /&gt;
&lt;br /&gt;
* {{anchor|advancefrom|'''[advancefrom]'''}}: {{DevFeature1.15|4}} replaced by [[ModificationWML|[modify_unit_type]]]. Defines the previous unit type on the advancement tree. Allows a campaign-specific unit to be spliced into an already existing advancement tree.  It should generally be used only inside a campaign ifdef, to prevent changes to other campaigns. Since all multiplayer content shares MULTIPLAYER define, using advancefrom changes unit type even if the addon is not actively used. For that reason multiplayer advancefrom may only be used with unit types defined in the same addon - then everyone who has the unit has it with same advancements.  This tag makes changes to the ''advances_to'' and ''experience'' keys of a base unit to make it advance into this unit.  It takes these keys:&lt;br /&gt;
** ''unit'': the id of the base unit from which this unit advances.  This adds the unit into the list of units which ''unit'' can advance into.&lt;br /&gt;
** ''experience'': (optional) If present the experience needed to advance is set to this value. If there are more than one [advancefrom] tags referencing the same base unit within the same preprocessor scope (e.g. a campaign #ifdef) with experience= keys, the lowest value of these is chosen.  Note: this will also lower the experience required to advance to other units which the base unit can advance into.&lt;br /&gt;
: If the previous unit type makes use of '''[male]''' and/or '''[female]''' tags, then the current (new) unit type is expected to also. That is, the subtypes defined by those tags will only receive this advancement if the new type has a corresponding tag.&lt;br /&gt;
{{DevFeature1.15|4}} '''[advancefrom]''' was effectively removed in 1.15.4. The intention was to deprecate it, but  the compatibility code that was meant to support it in 1.16 was untested and nonfunctional.&lt;br /&gt;
&lt;br /&gt;
== Deprecating units ==&lt;br /&gt;
&lt;br /&gt;
A macro is provided for deprecating a unit, which uses the built-in deprecation system but hard-codes the level to 3 (meaning &amp;quot;for removal&amp;quot;). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;{DEPRECATED_UNIT old_id new_id version}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also set the new_id to an empty string if there is no replacement.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[TerrainWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73897</id>
		<title>LuaAPI/wesnoth/sides</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73897"/>
		<updated>2024-10-24T13:22:16Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* wesnoth.sides.set_id */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
The sides module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
All functions taking a side on this page (except '''get''') will accept either the integer index of the side or the [[LuaAPI/types/side|side proxy userdata]] (as returned by '''get''' or '''find''').&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_enemy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_enemy'''(''side1'', ''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side1'':'''is_enemy'''(''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Returns true if side 1 is an enemy of side 2, false otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local enemy_flag = wesnoth.sides.is_enemy(1, 3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.match_side'''(''side'', ''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Matches a side against a given [[StandardSideFilter]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.message(tostring(wesnoth.sides[1]:matches{ wml.tag.has_unit { type = &amp;quot;Troll&amp;quot; } }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.set_id ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.set_id'''(''side'', ''flag'', ''color'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''set_id('''''flag'', ''color'')&lt;br /&gt;
&lt;br /&gt;
Changes the visual identification of a side. Pass an empty string if you only want to change one of these two attributes. Both attributes can also be changed through the [[LuaAPI/types/side|side proxy]] attributes, but changing both at the same time is slightly more efficient.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Fogs over the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, but not a list of such. The ''permanent'' argument defaults to false, causing temporary fog overrides to be cleared; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Unfogs the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, though not a list of such. The ''permanent'' argument defaults to false, creating temporary fog overrides that disappear at the end of the turn; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.sides.remove_fog(1, { {5, 5}, {5, 6} }) --removes fog on 5,5 and 5,6 for side 1&lt;br /&gt;
wesnoth.sides.remove_fog(wesnoth.sides[1], { {5, 5} }) -- removes fog for first side on 5,5&lt;br /&gt;
wesnoth.sides[1]:remove_fog(wesnoth.get_locations{ x = 5, y = 5 }) --removes fog on 5,5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_fogged ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_fogged'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_fogged'''(''side'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Check if a specific location is under fog for the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Places shroud on the specified hexes for the chosen side. This merges the new shroud with any existing shroud on the map. The locations must be passed as an array of pairs, but if you want to merge in a shroud data string, you can parse it first with [[../map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.override_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.override_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''override_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Clears shroud on the specified hexes for the chosen side. This replaces any existing shroud data on the map – after calling `override_shroud`, the locations passed will be the ''only'' unshrouded locations.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Unshrouds the specified hexes for the chosen side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_shrouded ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_shrouded'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_shrouded'''(''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if the given location is under shroud from the point of view of the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.switch_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.switch_ai'''(''side'', ''file'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''switch_ai'''(''file'')&lt;br /&gt;
&lt;br /&gt;
Replaces a side's AI with the configuration from a specified file.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.append_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.append_ai'''(''side'', ''params'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''append_ai'''(''params'')&lt;br /&gt;
&lt;br /&gt;
Appends AI parameters (aspects, stages, goals) to the side's AI. The syntax for the parameters to be appended is the same as that supported by '''[modify_side]'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.add_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.add_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''add_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Adds a component to the side's AI. The path syntax is the same as that used by '''[modify_ai]'''. The component is the content of the component - it should not contain eg a toplevel '''[facet]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.change_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.change_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''change_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but replaces an existing component instead of adding a new one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.delete_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.delete_ai_component'''(''side'', ''path'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''delete_ai_component'''(''path'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but removes a component instead of adding one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.get'''(''id'') &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides'''[''id''] &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} #'''wesnoth.sides''' &amp;amp;rarr; ''number of sides''&lt;br /&gt;
&lt;br /&gt;
Returns the specified [[LuaAPI/types/side|side]], which must be a valid integer side ID.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.find'''(''filter'') &amp;amp;rarr; ''array of [[LuaAPI/types/side|sides]]''&lt;br /&gt;
&lt;br /&gt;
Returns a table array containing proxy tables for these sides matching the passed [[StandardSideFilter]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
--set gold to 0 for all sides with a leader&lt;br /&gt;
local sides = wesnoth.sides.find{ wml.tag.has_unit { canrecruit = true } }&lt;br /&gt;
for i,v in ipairs(sides) do&lt;br /&gt;
    v.gold = 0&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.iter ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.iter'''(''filter?'') &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''[[LuaAPI/types/side|side]]''&lt;br /&gt;
&lt;br /&gt;
Iterate over all sides, or sides that match a filter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.create'''() &amp;amp;rarr; ''new side number''&lt;br /&gt;
&lt;br /&gt;
Adds a new blank side to the end of the scenario sides list and returns its number.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.debug_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.debug_ai'''(''side'') &amp;amp;rarr; ''ai context table''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''debug_ai'''() &amp;amp;rarr; ''ai context table''&lt;br /&gt;
&lt;br /&gt;
Returns the AI context table for the given side. This function only exists in debug mode, and only if Wesnoth is launched with the &amp;lt;tt&amp;gt;--debug-lua&amp;lt;/tt&amp;gt; command-line argument. This allows you to inspect all the AI internals for that side, including the AI component tree and the AI module (which is instanced per side). You can also execute individual components by calling their execution or evaluation functions.&lt;br /&gt;
&lt;br /&gt;
The returned table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''ai''': The [[LuaAPI/ai|ai]] module bound to this side. Each side has a separate instance of the AI module.&lt;br /&gt;
* '''components''': The AI components tree. Each component in this tree potentially has the following subkeys:&lt;br /&gt;
** '''engine''', '''id''', '''name''': The basic info about the component - its name and ID and the engine it runs on.&lt;br /&gt;
** '''stage''', '''candidate_action''': An array of subcomponents of the specified type.&lt;br /&gt;
** '''exec''': For stages or candidate actions, a function which, when called, executes it immediately (and synchronously). Prefer calling this with the :lua command rather than from the Lua console.&lt;br /&gt;
* '''engine''': The complete contents of the Lua [engine] tag.&lt;br /&gt;
* '''params''': The contents of the [args] tag from the Lua [engine] tag.&lt;br /&gt;
* '''data''': A WML table containing persistent data used by the AI. This data is serialized as part of the Lua [engine] tag.&lt;br /&gt;
* '''update_self''': The function defined in the Lua [engine] tag. Called as &amp;lt;syntaxhighlight lang=lua inline&amp;gt;update_self(params, data)&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The above list covers only the most useful keys and is not exhaustive.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
wesnoth.debug_ai(2).ai -- returns the AI module bound to side 2&lt;br /&gt;
wesnoth.debug_ai(2).stage[another_stage].exec() -- executes the &amp;quot;another_stage&amp;quot; stage for side 2&lt;br /&gt;
wesnoth.debug_ai(2).ai.aspects.aggression -- returns the current value of the aggression aspect of the AI on side 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not rely on the precise structure of the AI context table. It is documented here as an aid to debugging, but it is ''not'' public API and may change without warning or deprecation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73896</id>
		<title>LuaAPI/wesnoth/sides</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73896"/>
		<updated>2024-10-24T13:21:35Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
The sides module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
All functions taking a side on this page (except '''get''') will accept either the integer index of the side or the [[LuaAPI/types/side|side proxy userdata]] (as returned by '''get''' or '''find''').&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_enemy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_enemy'''(''side1'', ''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side1'':'''is_enemy'''(''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Returns true if side 1 is an enemy of side 2, false otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local enemy_flag = wesnoth.sides.is_enemy(1, 3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.match_side'''(''side'', ''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Matches a side against a given [[StandardSideFilter]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.message(tostring(wesnoth.sides[1]:matches{ wml.tag.has_unit { type = &amp;quot;Troll&amp;quot; } }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.set_id ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.set_id'''(''side'', ''flag'', ''color'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''set_id('''''flag'', ''color'')&lt;br /&gt;
&lt;br /&gt;
Changes the visual identification of a side. Pass an empty string if you only want to change one of these two attributes. Both attributes can also be changed through the side proxy attributes, but changing both at the same time is slightly more efficient.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Fogs over the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, but not a list of such. The ''permanent'' argument defaults to false, causing temporary fog overrides to be cleared; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Unfogs the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, though not a list of such. The ''permanent'' argument defaults to false, creating temporary fog overrides that disappear at the end of the turn; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.sides.remove_fog(1, { {5, 5}, {5, 6} }) --removes fog on 5,5 and 5,6 for side 1&lt;br /&gt;
wesnoth.sides.remove_fog(wesnoth.sides[1], { {5, 5} }) -- removes fog for first side on 5,5&lt;br /&gt;
wesnoth.sides[1]:remove_fog(wesnoth.get_locations{ x = 5, y = 5 }) --removes fog on 5,5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_fogged ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_fogged'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_fogged'''(''side'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Check if a specific location is under fog for the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Places shroud on the specified hexes for the chosen side. This merges the new shroud with any existing shroud on the map. The locations must be passed as an array of pairs, but if you want to merge in a shroud data string, you can parse it first with [[../map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.override_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.override_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''override_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Clears shroud on the specified hexes for the chosen side. This replaces any existing shroud data on the map – after calling `override_shroud`, the locations passed will be the ''only'' unshrouded locations.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Unshrouds the specified hexes for the chosen side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_shrouded ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_shrouded'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_shrouded'''(''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if the given location is under shroud from the point of view of the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.switch_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.switch_ai'''(''side'', ''file'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''switch_ai'''(''file'')&lt;br /&gt;
&lt;br /&gt;
Replaces a side's AI with the configuration from a specified file.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.append_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.append_ai'''(''side'', ''params'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''append_ai'''(''params'')&lt;br /&gt;
&lt;br /&gt;
Appends AI parameters (aspects, stages, goals) to the side's AI. The syntax for the parameters to be appended is the same as that supported by '''[modify_side]'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.add_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.add_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''add_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Adds a component to the side's AI. The path syntax is the same as that used by '''[modify_ai]'''. The component is the content of the component - it should not contain eg a toplevel '''[facet]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.change_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.change_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''change_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but replaces an existing component instead of adding a new one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.delete_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.delete_ai_component'''(''side'', ''path'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''delete_ai_component'''(''path'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but removes a component instead of adding one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.get'''(''id'') &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides'''[''id''] &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} #'''wesnoth.sides''' &amp;amp;rarr; ''number of sides''&lt;br /&gt;
&lt;br /&gt;
Returns the specified [[LuaAPI/types/side|side]], which must be a valid integer side ID.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.find'''(''filter'') &amp;amp;rarr; ''array of [[LuaAPI/types/side|sides]]''&lt;br /&gt;
&lt;br /&gt;
Returns a table array containing proxy tables for these sides matching the passed [[StandardSideFilter]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
--set gold to 0 for all sides with a leader&lt;br /&gt;
local sides = wesnoth.sides.find{ wml.tag.has_unit { canrecruit = true } }&lt;br /&gt;
for i,v in ipairs(sides) do&lt;br /&gt;
    v.gold = 0&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.iter ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.iter'''(''filter?'') &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''[[LuaAPI/types/side|side]]''&lt;br /&gt;
&lt;br /&gt;
Iterate over all sides, or sides that match a filter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.create'''() &amp;amp;rarr; ''new side number''&lt;br /&gt;
&lt;br /&gt;
Adds a new blank side to the end of the scenario sides list and returns its number.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.debug_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.debug_ai'''(''side'') &amp;amp;rarr; ''ai context table''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''debug_ai'''() &amp;amp;rarr; ''ai context table''&lt;br /&gt;
&lt;br /&gt;
Returns the AI context table for the given side. This function only exists in debug mode, and only if Wesnoth is launched with the &amp;lt;tt&amp;gt;--debug-lua&amp;lt;/tt&amp;gt; command-line argument. This allows you to inspect all the AI internals for that side, including the AI component tree and the AI module (which is instanced per side). You can also execute individual components by calling their execution or evaluation functions.&lt;br /&gt;
&lt;br /&gt;
The returned table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''ai''': The [[LuaAPI/ai|ai]] module bound to this side. Each side has a separate instance of the AI module.&lt;br /&gt;
* '''components''': The AI components tree. Each component in this tree potentially has the following subkeys:&lt;br /&gt;
** '''engine''', '''id''', '''name''': The basic info about the component - its name and ID and the engine it runs on.&lt;br /&gt;
** '''stage''', '''candidate_action''': An array of subcomponents of the specified type.&lt;br /&gt;
** '''exec''': For stages or candidate actions, a function which, when called, executes it immediately (and synchronously). Prefer calling this with the :lua command rather than from the Lua console.&lt;br /&gt;
* '''engine''': The complete contents of the Lua [engine] tag.&lt;br /&gt;
* '''params''': The contents of the [args] tag from the Lua [engine] tag.&lt;br /&gt;
* '''data''': A WML table containing persistent data used by the AI. This data is serialized as part of the Lua [engine] tag.&lt;br /&gt;
* '''update_self''': The function defined in the Lua [engine] tag. Called as &amp;lt;syntaxhighlight lang=lua inline&amp;gt;update_self(params, data)&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The above list covers only the most useful keys and is not exhaustive.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
wesnoth.debug_ai(2).ai -- returns the AI module bound to side 2&lt;br /&gt;
wesnoth.debug_ai(2).stage[another_stage].exec() -- executes the &amp;quot;another_stage&amp;quot; stage for side 2&lt;br /&gt;
wesnoth.debug_ai(2).ai.aspects.aggression -- returns the current value of the aggression aspect of the AI on side 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not rely on the precise structure of the AI context table. It is documented here as an aid to debugging, but it is ''not'' public API and may change without warning or deprecation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73895</id>
		<title>LuaAPI/wesnoth/sides</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73895"/>
		<updated>2024-10-24T13:21:01Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* wesnoth.sides.get */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
The sides module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
All functions taking a side on this page (except '''get''') will accept either the integer index of the side or the side proxy userdata (as returned by '''get''' or '''find''').&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_enemy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_enemy'''(''side1'', ''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side1'':'''is_enemy'''(''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Returns true if side 1 is an enemy of side 2, false otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local enemy_flag = wesnoth.sides.is_enemy(1, 3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.match_side'''(''side'', ''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Matches a side against a given [[StandardSideFilter]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.message(tostring(wesnoth.sides[1]:matches{ wml.tag.has_unit { type = &amp;quot;Troll&amp;quot; } }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.set_id ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.set_id'''(''side'', ''flag'', ''color'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''set_id('''''flag'', ''color'')&lt;br /&gt;
&lt;br /&gt;
Changes the visual identification of a side. Pass an empty string if you only want to change one of these two attributes. Both attributes can also be changed through the side proxy attributes, but changing both at the same time is slightly more efficient.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Fogs over the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, but not a list of such. The ''permanent'' argument defaults to false, causing temporary fog overrides to be cleared; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Unfogs the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, though not a list of such. The ''permanent'' argument defaults to false, creating temporary fog overrides that disappear at the end of the turn; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.sides.remove_fog(1, { {5, 5}, {5, 6} }) --removes fog on 5,5 and 5,6 for side 1&lt;br /&gt;
wesnoth.sides.remove_fog(wesnoth.sides[1], { {5, 5} }) -- removes fog for first side on 5,5&lt;br /&gt;
wesnoth.sides[1]:remove_fog(wesnoth.get_locations{ x = 5, y = 5 }) --removes fog on 5,5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_fogged ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_fogged'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_fogged'''(''side'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Check if a specific location is under fog for the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Places shroud on the specified hexes for the chosen side. This merges the new shroud with any existing shroud on the map. The locations must be passed as an array of pairs, but if you want to merge in a shroud data string, you can parse it first with [[../map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.override_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.override_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''override_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Clears shroud on the specified hexes for the chosen side. This replaces any existing shroud data on the map – after calling `override_shroud`, the locations passed will be the ''only'' unshrouded locations.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Unshrouds the specified hexes for the chosen side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_shrouded ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_shrouded'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_shrouded'''(''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if the given location is under shroud from the point of view of the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.switch_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.switch_ai'''(''side'', ''file'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''switch_ai'''(''file'')&lt;br /&gt;
&lt;br /&gt;
Replaces a side's AI with the configuration from a specified file.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.append_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.append_ai'''(''side'', ''params'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''append_ai'''(''params'')&lt;br /&gt;
&lt;br /&gt;
Appends AI parameters (aspects, stages, goals) to the side's AI. The syntax for the parameters to be appended is the same as that supported by '''[modify_side]'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.add_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.add_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''add_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Adds a component to the side's AI. The path syntax is the same as that used by '''[modify_ai]'''. The component is the content of the component - it should not contain eg a toplevel '''[facet]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.change_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.change_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''change_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but replaces an existing component instead of adding a new one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.delete_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.delete_ai_component'''(''side'', ''path'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''delete_ai_component'''(''path'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but removes a component instead of adding one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.get'''(''id'') &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides'''[''id''] &amp;amp;rarr; ''[[LuaAPI/types/side|side proxy]]''&lt;br /&gt;
* {{LuaGameOnly}} #'''wesnoth.sides''' &amp;amp;rarr; ''number of sides''&lt;br /&gt;
&lt;br /&gt;
Returns the specified [[LuaAPI/types/side|side]], which must be a valid integer side ID.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.find'''(''filter'') &amp;amp;rarr; ''array of [[LuaAPI/types/side|sides]]''&lt;br /&gt;
&lt;br /&gt;
Returns a table array containing proxy tables for these sides matching the passed [[StandardSideFilter]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
--set gold to 0 for all sides with a leader&lt;br /&gt;
local sides = wesnoth.sides.find{ wml.tag.has_unit { canrecruit = true } }&lt;br /&gt;
for i,v in ipairs(sides) do&lt;br /&gt;
    v.gold = 0&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.iter ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.iter'''(''filter?'') &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''[[LuaAPI/types/side|side]]''&lt;br /&gt;
&lt;br /&gt;
Iterate over all sides, or sides that match a filter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.create'''() &amp;amp;rarr; ''new side number''&lt;br /&gt;
&lt;br /&gt;
Adds a new blank side to the end of the scenario sides list and returns its number.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.debug_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.debug_ai'''(''side'') &amp;amp;rarr; ''ai context table''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''debug_ai'''() &amp;amp;rarr; ''ai context table''&lt;br /&gt;
&lt;br /&gt;
Returns the AI context table for the given side. This function only exists in debug mode, and only if Wesnoth is launched with the &amp;lt;tt&amp;gt;--debug-lua&amp;lt;/tt&amp;gt; command-line argument. This allows you to inspect all the AI internals for that side, including the AI component tree and the AI module (which is instanced per side). You can also execute individual components by calling their execution or evaluation functions.&lt;br /&gt;
&lt;br /&gt;
The returned table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''ai''': The [[LuaAPI/ai|ai]] module bound to this side. Each side has a separate instance of the AI module.&lt;br /&gt;
* '''components''': The AI components tree. Each component in this tree potentially has the following subkeys:&lt;br /&gt;
** '''engine''', '''id''', '''name''': The basic info about the component - its name and ID and the engine it runs on.&lt;br /&gt;
** '''stage''', '''candidate_action''': An array of subcomponents of the specified type.&lt;br /&gt;
** '''exec''': For stages or candidate actions, a function which, when called, executes it immediately (and synchronously). Prefer calling this with the :lua command rather than from the Lua console.&lt;br /&gt;
* '''engine''': The complete contents of the Lua [engine] tag.&lt;br /&gt;
* '''params''': The contents of the [args] tag from the Lua [engine] tag.&lt;br /&gt;
* '''data''': A WML table containing persistent data used by the AI. This data is serialized as part of the Lua [engine] tag.&lt;br /&gt;
* '''update_self''': The function defined in the Lua [engine] tag. Called as &amp;lt;syntaxhighlight lang=lua inline&amp;gt;update_self(params, data)&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The above list covers only the most useful keys and is not exhaustive.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
wesnoth.debug_ai(2).ai -- returns the AI module bound to side 2&lt;br /&gt;
wesnoth.debug_ai(2).stage[another_stage].exec() -- executes the &amp;quot;another_stage&amp;quot; stage for side 2&lt;br /&gt;
wesnoth.debug_ai(2).ai.aspects.aggression -- returns the current value of the aggression aspect of the AI on side 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not rely on the precise structure of the AI context table. It is documented here as an aid to debugging, but it is ''not'' public API and may change without warning or deprecation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73894</id>
		<title>LuaAPI/wesnoth/sides</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/sides&amp;diff=73894"/>
		<updated>2024-10-24T13:20:01Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DevFeature1.15|3}}&lt;br /&gt;
&lt;br /&gt;
The sides module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
All functions taking a side on this page (except '''get''') will accept either the integer index of the side or the side proxy userdata (as returned by '''get''' or '''find''').&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_enemy ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_enemy'''(''side1'', ''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side1'':'''is_enemy'''(''side2'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Returns true if side 1 is an enemy of side 2, false otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local enemy_flag = wesnoth.sides.is_enemy(1, 3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.match_side'''(''side'', ''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Matches a side against a given [[StandardSideFilter]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.message(tostring(wesnoth.sides[1]:matches{ wml.tag.has_unit { type = &amp;quot;Troll&amp;quot; } }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.set_id ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.set_id'''(''side'', ''flag'', ''color'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''set_id('''''flag'', ''color'')&lt;br /&gt;
&lt;br /&gt;
Changes the visual identification of a side. Pass an empty string if you only want to change one of these two attributes. Both attributes can also be changed through the side proxy attributes, but changing both at the same time is slightly more efficient.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Fogs over the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, but not a list of such. The ''permanent'' argument defaults to false, causing temporary fog overrides to be cleared; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_fog ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_fog'''([''sides''], ''locations'', [''permanent''])&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_fog'''(''locations'', [''permanent''])&lt;br /&gt;
&lt;br /&gt;
Unfogs the specified locations for the specified sides (or all sides, if no sides are specified). You can specify sides either as a single integer or a list of integers. A side userdata also works, though not a list of such. The ''permanent'' argument defaults to false, creating temporary fog overrides that disappear at the end of the turn; if true, it affects the team's permanent fog as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.sides.remove_fog(1, { {5, 5}, {5, 6} }) --removes fog on 5,5 and 5,6 for side 1&lt;br /&gt;
wesnoth.sides.remove_fog(wesnoth.sides[1], { {5, 5} }) -- removes fog for first side on 5,5&lt;br /&gt;
wesnoth.sides[1]:remove_fog(wesnoth.get_locations{ x = 5, y = 5 }) --removes fog on 5,5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_fogged ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_fogged'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_fogged'''(''side'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Check if a specific location is under fog for the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.place_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.place_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''place_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Places shroud on the specified hexes for the chosen side. This merges the new shroud with any existing shroud on the map. The locations must be passed as an array of pairs, but if you want to merge in a shroud data string, you can parse it first with [[../map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.override_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.override_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''override_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Clears shroud on the specified hexes for the chosen side. This replaces any existing shroud data on the map – after calling `override_shroud`, the locations passed will be the ''only'' unshrouded locations.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.remove_shroud ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.remove_shroud'''(''side'', ''locations'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''remove_shroud'''(''locations'')&lt;br /&gt;
&lt;br /&gt;
Unshrouds the specified hexes for the chosen side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.is_shrouded ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.is_shrouded'''(''side'', ''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''is_shrouded'''(''location'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if the given location is under shroud from the point of view of the given side.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.switch_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.switch_ai'''(''side'', ''file'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''switch_ai'''(''file'')&lt;br /&gt;
&lt;br /&gt;
Replaces a side's AI with the configuration from a specified file.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.append_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.append_ai'''(''side'', ''params'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''append_ai'''(''params'')&lt;br /&gt;
&lt;br /&gt;
Appends AI parameters (aspects, stages, goals) to the side's AI. The syntax for the parameters to be appended is the same as that supported by '''[modify_side]'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.add_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.add_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''add_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Adds a component to the side's AI. The path syntax is the same as that used by '''[modify_ai]'''. The component is the content of the component - it should not contain eg a toplevel '''[facet]''' tag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.change_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.change_ai_component'''(''side'', ''path'', ''component'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''change_ai_component'''(''path'', ''component'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but replaces an existing component instead of adding a new one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.delete_ai_component ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.delete_ai_component'''(''side'', ''path'')&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''delete_ai_component'''(''path'')&lt;br /&gt;
&lt;br /&gt;
Like add_ai_component, but removes a component instead of adding one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.get'''(''id'') &amp;amp;rarr; ''side proxy''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides'''[''id''] &amp;amp;rarr; ''side proxy''&lt;br /&gt;
* {{LuaGameOnly}} #'''wesnoth.sides''' &amp;amp;rarr; ''number of sides''&lt;br /&gt;
&lt;br /&gt;
Returns the specified [[LuaAPI/types/side|side]], which must be a valid integer side ID.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.find'''(''filter'') &amp;amp;rarr; ''array of [[LuaAPI/types/side|sides]]''&lt;br /&gt;
&lt;br /&gt;
Returns a table array containing proxy tables for these sides matching the passed [[StandardSideFilter]]. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
--set gold to 0 for all sides with a leader&lt;br /&gt;
local sides = wesnoth.sides.find{ wml.tag.has_unit { canrecruit = true } }&lt;br /&gt;
for i,v in ipairs(sides) do&lt;br /&gt;
    v.gold = 0&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.iter ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|?}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.iter'''(''filter?'') &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''[[LuaAPI/types/side|side]]''&lt;br /&gt;
&lt;br /&gt;
Iterate over all sides, or sides that match a filter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.create'''() &amp;amp;rarr; ''new side number''&lt;br /&gt;
&lt;br /&gt;
Adds a new blank side to the end of the scenario sides list and returns its number.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.sides.debug_ai ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.sides.debug_ai'''(''side'') &amp;amp;rarr; ''ai context table''&lt;br /&gt;
* {{LuaGameOnly}} ''side'':'''debug_ai'''() &amp;amp;rarr; ''ai context table''&lt;br /&gt;
&lt;br /&gt;
Returns the AI context table for the given side. This function only exists in debug mode, and only if Wesnoth is launched with the &amp;lt;tt&amp;gt;--debug-lua&amp;lt;/tt&amp;gt; command-line argument. This allows you to inspect all the AI internals for that side, including the AI component tree and the AI module (which is instanced per side). You can also execute individual components by calling their execution or evaluation functions.&lt;br /&gt;
&lt;br /&gt;
The returned table contains the following keys:&lt;br /&gt;
&lt;br /&gt;
* '''ai''': The [[LuaAPI/ai|ai]] module bound to this side. Each side has a separate instance of the AI module.&lt;br /&gt;
* '''components''': The AI components tree. Each component in this tree potentially has the following subkeys:&lt;br /&gt;
** '''engine''', '''id''', '''name''': The basic info about the component - its name and ID and the engine it runs on.&lt;br /&gt;
** '''stage''', '''candidate_action''': An array of subcomponents of the specified type.&lt;br /&gt;
** '''exec''': For stages or candidate actions, a function which, when called, executes it immediately (and synchronously). Prefer calling this with the :lua command rather than from the Lua console.&lt;br /&gt;
* '''engine''': The complete contents of the Lua [engine] tag.&lt;br /&gt;
* '''params''': The contents of the [args] tag from the Lua [engine] tag.&lt;br /&gt;
* '''data''': A WML table containing persistent data used by the AI. This data is serialized as part of the Lua [engine] tag.&lt;br /&gt;
* '''update_self''': The function defined in the Lua [engine] tag. Called as &amp;lt;syntaxhighlight lang=lua inline&amp;gt;update_self(params, data)&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The above list covers only the most useful keys and is not exhaustive.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
wesnoth.debug_ai(2).ai -- returns the AI module bound to side 2&lt;br /&gt;
wesnoth.debug_ai(2).stage[another_stage].exec() -- executes the &amp;quot;another_stage&amp;quot; stage for side 2&lt;br /&gt;
wesnoth.debug_ai(2).ai.aspects.aggression -- returns the current value of the aggression aspect of the AI on side 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not rely on the precise structure of the AI context table. It is documented here as an aid to debugging, but it is ''not'' public API and may change without warning or deprecation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73891</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73891"/>
		<updated>2024-10-21T20:58:07Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Other tags */ 9236&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
Each '''[unit_type]''' tag defines one unit type. (for the use of [unit] to create a unit, see [[SingleUnitWML]])&lt;br /&gt;
&lt;br /&gt;
Unit animation syntax is described in [[AnimationWML]]. In addition to the animation tags described there, the following key/tags are recognized:&lt;br /&gt;
* '''advances_to''': When this unit has ''experience'' greater than or equal to ''experience'', it is replaced by a unit of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by. The special value 'null' says that the unit does not advance but gets an AMLA instead. Can be a comma-separated list of units that can be chosen from upon advancing.&lt;br /&gt;
* '''alignment''': one of lawful/neutral/chaotic/liminal (See [[TimeWML]]). Default is &amp;quot;neutral&amp;quot;.&lt;br /&gt;
* '''attacks''': the number of times that this unit can attack each turn. Default is 1.&lt;br /&gt;
* '''cost''': when a player recruits a unit of this type, the player loses ''cost'' gold. If this would cause gold to drop below 0,  the unit cannot be recruited. Default is 1.&lt;br /&gt;
* '''recall_cost''': {{DevFeature1.13|0}} the default recall cost of units of this type, overriding the recall cost set in scenario [[SideWML|[side]]] tags or the global [[GameConfigWML|[game_config]]] value. Individual units may override this value in [[SingleUnitWML|[unit]]]. A value of -1 is equivalent to not specifying this attribute. {{DevFeature1.15|0}} Units are now recalled for AI sides even if the recall_cost is larger than the unit's worth (essentially its cost, plus potentially a bonus for experience points). In 1.14 and earlier, units were not recalled by the AI in this case even if this was the only recall/recruit action possible to the AI.&lt;br /&gt;
* '''description''': (translatable) the text displayed in the unit descriptor box for this unit. Default 'No description available...'. &lt;br /&gt;
* '''do_not_list''': Not used by the game, but by tools for browsing and listing the unit tree. If this is 'yes', the unit will be ignored by these tools. {{DevFeature1.13|?}} When placing units in debug mode this unit isn't listed (but can still be placed using the :create command). This restriction is lifted in version &amp;lt;b&amp;gt;1.14.3&amp;lt;/b&amp;gt;.&lt;br /&gt;
* '''ellipse''': the ellipse image to display under the unit, which is normally team-colored. Default is &amp;quot;misc/ellipse&amp;quot;. &amp;quot;-nozoc&amp;quot; and &amp;quot;-leader&amp;quot; are automatically appended for units without zone of control and with canrecruit=yes respectively. The [http://www.wesnoth.org/macro-reference.xhtml#IS_HERO IS_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#MAKE_HERO MAKE_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#UNMAKE_HERO UNMAKE_HERO] macros change the ellipse to/back from &amp;quot;misc/ellipse-hero&amp;quot;. Finally, setting this to &amp;quot;none&amp;quot; will cause the unit to not have any ellipses displayed under it regardless of the user's preferences.&lt;br /&gt;
::WARNING: Be aware that setting this to &amp;quot;misc/ellipse-hero&amp;quot; for a unit with canrecruit=yes will result in the ellipse being &amp;quot;misc/ellipse-hero-leader&amp;quot;, which is not a supported combination (it doesn't have a graphic, and will cause error logs that the graphic is missing). This is tracked as bug [https://github.com/wesnoth/wesnoth/issues/6258 6258] on GitHub.&lt;br /&gt;
* '''experience''': When this unit has experience greater than or equal to ''experience'', it is replaced by a unit with 0 experience of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by.&lt;br /&gt;
* '''flag_rgb''': usually set by [http://www.wesnoth.org/macro-reference.xhtml#MAGENTA_IS_THE_TEAM_COLOR MAGENTA_IS_THE_TEAM_COLOR]; specifies the colours in the base flag to use for team-colouring the unit, expressed as a colour name (such as magenta) or a comma-separated list of RGB values (in hex format).&lt;br /&gt;
* '''gender''': has a value of either ''male'' or ''female'', and determines which of the keys ''male_names'' and ''female_names''  should be read. When a unit of this type is recruited, it will be randomly assigned a name by the random name generator, which will use these names as a base. If '''gender''' is not specified it defaults to ''male''.&lt;br /&gt;
* '''halo''': an image to place centered on the unit. It is drawn on top of the unit, and on top of surrounding units if the image is larger than one hex. It works similarly to the halo attribute of {{tag|InterfaceActionsWML|item}}, and it can be animated with a comma-separated list of images.&lt;br /&gt;
* '''hide_help''': (yes|no) default=no. Determines if the unit type will appear in the in-game help.&lt;br /&gt;
* '''hitpoints''': the maximum HP that the unit has, and the HP it has when it is created.&lt;br /&gt;
* '''id''': the value of the ''type'' key for units of this type. This is required and must be unique among all [unit_type] tags. An ''id'' must consist only of alphanumerics and spaces (or underscores). ''type'' keys are found in [[SingleUnitWML]] and [[FilterWML]]. For example, id=Drake Flare&lt;br /&gt;
*'''ignore_race_traits''': 'yes' or 'no' (default). Determines whether racial traits (see [[UnitsWML]]) are applied. &lt;br /&gt;
* '''image''': sets the base image of the unit, which is used on the map.&lt;br /&gt;
* '''image_icon''': sets the image used to represent the unit in areas such as the attack dialog and the unit image box in the sidebar. [[ImagePathFunctions#Crop_Function|~CROP]] function can be useful here. You can see Loyalists Paladin as an example.&lt;br /&gt;
* '''level''': the amount of upkeep the unit costs.  After this unit fights, its opponent gains ''level'' experience. See also kill_experience ([[GameConfigWML]]), and leadership ([[AbilitiesWML]]).&lt;br /&gt;
* '''upkeep''': the amount of upkeep the unit costs if it differs from its level.&lt;br /&gt;
* '''movement''': the number of move points that this unit receives each turn.&lt;br /&gt;
* '''movement_type''': See [[UnitsWML#.5Bmovetype.5D|movetype]]. Note that the tags '''[movement_costs]''', '''[vision_costs]''', '''[defense]''', and '''[resistance]''' can be used to modify this movetype.&lt;br /&gt;
* '''name''': (translatable) displayed in the Status Table for units of this type.&lt;br /&gt;
* '''num_traits''': the number of traits that units of this type should receive when they are recruited, overriding the value set in the [race] tag.&lt;br /&gt;
* '''profile''': the portrait image to use for this unit type. You can also set a portrait for an individual unit instead of the whole unit type (see [[SingleUnitWML]]). The engine first looks for the image in the transparent subdirectory and if found that image is used. If not found it will use the image as-is. Depending on the size the engine will or will not scale the image, the cutoff currently is at 300x300. For images which should only be shown on the right side in the dialog append ~RIGHT() to the image.&lt;br /&gt;
** If &amp;quot;unit_image&amp;quot; is given instead of a filename, uses the unit's base image as the portrait (in the same manner that unit types without portraits do by default).&lt;br /&gt;
** If &amp;quot;none&amp;quot; is given instead of a filename, no image will be displayed.&lt;br /&gt;
* '''small_profile''': the image to use when a smaller portrait is needed than the one used for messages (e.g., in the help system). When this attribute is missing, the value of the '''profile''' attribute is used instead. When present, the heuristic for finding a transparent portrait is disabled for the '''profile''' attribute, so the correct '''profile''' should be set too. If '''profile''' is not present, '''small_profile''' is ignored. Note that image modifiers are allowed; they might be useful for cropping and rescaling a portrait:&lt;br /&gt;
 small_profile=&amp;quot;portraits/elves/transparent/marksman+female.png~CROP(0,20,380,380)~SCALE(205,205)&amp;quot;&lt;br /&gt;
 profile=&amp;quot;portraits/elves/transparent/marksman+female.png&amp;quot;&lt;br /&gt;
* '''race''': See {{tag|UnitsWML|race}}.  Also used in standard unit filter (see [[FilterWML]]). Mainline Wesnoth features following values:  bats, drake, dwarf, elf, falcon, goblin, gryphon, human, dunefolk, lizard, mechanical, merman, monster, naga, ogre, orc, troll, undead, wolf, wose. They are defined in /data/core/units.cfg.&lt;br /&gt;
* '''undead_variation''': When a unit of this type is killed by a weapon with the plague special, this variation is applied to the new plague unit that is created, whatever its type. For example, if the plague special creates Walking Corpses and undead_variation is set to &amp;quot;troll&amp;quot;, you'll get a troll Walking Corpse. Defaults to the undead_variation set in this unit type's race.&lt;br /&gt;
* '''usage''': the way that the AI should recruit this unit, as determined by the scenario designer. (See ''recruitment_pattern'', [[AiWML]]).  The following are conventions on usage:&amp;lt;br&amp;gt; ** ''scout'': Fast, mobile unit meant for exploration and village grabbing.&amp;lt;br&amp;gt; ** ''fighter'': Melee fighter, melee attack substantially more powerful than ranged.&amp;lt;br&amp;gt; ** ''archer'': Ranged fighter, ranged attack substantially more powerful than melee.&amp;lt;br&amp;gt; ** ''mixed fighter'': Melee and ranged fighter, melee and ranged attacks roughly equal.&amp;lt;br&amp;gt; ** ''healer'': Specialty 'heals' or 'cures'.&amp;lt;br&amp;gt;Note that this field primarily affects recruitment.  It also has a small effect on unit movement (the AI tries to keep scouts away from enemies, to some extent).  It does not affect the AI's behavior in combat; that is always computed from attack power and hitpoints. Non-standard usages may be used as well.&lt;br /&gt;
* '''vision''': the number of vision points to calculate the unit's sight range. Defaults to ''movement'' if not present.&lt;br /&gt;
* '''jamming''': the number of jamming points. Defaults to ''0'' if not present. See [[UnitsWML#.5Bmovetype.5D|[jamming_costs]]]&lt;br /&gt;
* '''zoc''': if &amp;quot;yes&amp;quot; the unit will have a zone of control regardless of level.  If present but set to anything other than &amp;quot;yes,&amp;quot; the unit will have no zone of control.  If the tag is omitted, zone of control is dictated by unit level (level 0 = no zoc, level 1+ = has zoc).&lt;br /&gt;
* '''die_sound''': sets the sound, which is used when the unit dies.&lt;br /&gt;
* '''healed_sound''': sets the sound used when the unit is healed in any way (default: heal.wav).&lt;br /&gt;
* '''hp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''xp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''bar_offset_x''', '''bar_offset_y''': The offset of the hp and xp bars from the normal bar position of 72x72 unit sprite.&lt;br /&gt;
&lt;br /&gt;
== After max level advancement (AMLA) ==&lt;br /&gt;
* '''[advancement]''': describes what happens to a unit when it reaches the XP required for advancement.  It is considered as an advancement in the same way as advancement described by '''advances_to'''; however, if the player chooses this advancement, the unit will have one or more effects applied to it instead of advancing.&lt;br /&gt;
** '''id''': unique identifier for this advancement; ''Required'' if there are multiple advancement options, or if ''strict_amla=no''.&lt;br /&gt;
** '''always_display''': if set to true displays the AMLA option even if it is the only available one.&lt;br /&gt;
** '''description''': a description displayed as the option for this advancement if there is another advancement option that the player must choose from; otherwise, the advancement is chosen automatically and this key is irrelevant.&lt;br /&gt;
** '''image''': an image to display next to the description in the advancement menu.&lt;br /&gt;
** '''max_times''': default 1.  The maximum times the unit can be awarded this advancement. Pass -1 for &amp;quot;unlimited&amp;quot;.&lt;br /&gt;
** '''strict_amla''':  (yes|no) default=no. Disable the AMLA if the unit can advance to another unit.&lt;br /&gt;
** '''major_amla''': (yes|no) default=no. Sets whether the unit's XP bar is blue(=yes) or purple(=no). In case of more [advancement] tags, if there is one with major_amla=yes, the XP bar will be blue.&lt;br /&gt;
** '''require_amla''': An optional list of AMLA ''id'' keys that act as prerequisites for this advancement to become available.  Order is not important, and an AMLA id can be repeated any number of times to indicate that another advancement must be chosen several times before this advancement option will become available.&lt;br /&gt;
*** example: &amp;lt;tt&amp;gt;require_amla=tough,tough,incr_damage&amp;lt;/tt&amp;gt; assumes there exist other [advancement] options called ''id=tough'' and ''id=incr_damage''.  Once ''tough'' is chosen twice and ''incr_damage'' is chosen once, then the current [advancement] will become available.&lt;br /&gt;
*** ''require_amla=tough,incr_damage,tough'' is an equivalent way of expressing this.&lt;br /&gt;
** '''exclude_amla''': {{DevFeature1.13|2}} An optional list of AMLA ''id'' keys that represent AMLAs that are mutually exclusive to this one. Order is not important, and an AMLA id can be repeated. If the unit already has any of the AMLAs that appear once in this list, then this AMLA will not be made available. If an AMLA id appears multiple times in the list, then this AMLA will be made available only if the other AMLA has been chosen less than the number of times it appears in the list. Of course, for this to really make two AMLAs mutually exclusive, you need to add ''exclude_amla'' to both AMLA defintions.&lt;br /&gt;
** '''[effect]''': A modification applied to the unit whenever this advancement is chosen.  See [[EffectWML]]&lt;br /&gt;
** '''[filter]''': A  [[StandardUnitFilter]],  the advancement will only be available when the unit passes this filter during the time the advancement dialog is shown.&lt;br /&gt;
&lt;br /&gt;
== Attacks ==&lt;br /&gt;
* '''[attack]''': one of the unit's attacks.&lt;br /&gt;
** '''description''': a translatable text for name of the attack, to be displayed to the user.&lt;br /&gt;
** '''name''': the name of the attack. Used as a default description, if ''description'' is not present, and to determine the default icon, if ''icon'' is not present (see below).  Non-translatable.  Used for the ''has_weapon'' key and animation filters; see [[StandardUnitFilter]] and [[AnimationWML]]&lt;br /&gt;
** '''type''': the damage type of the attack.  Used in determining resistance to this attack (see {{tag|UnitsWML|movetype|resistance}}). Usually this is one of ''blade'', ''pierce'', ''impact'', ''fire'', ''cold'', or ''arcane'', but it can be set to anything (as long as it contains only letters, numbers, and underscores). When using a custom type, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom damage type in the sidebar, the game will look for a file called icons/profiles/''type''.png under your addon's images folder. For example, the icon for a damage type called ''electric'' would be at images/icons/profiles/electric.png.&lt;br /&gt;
** '''[specials]''': contains the specials of the attack. See [[AbilitiesWML#The_.5Bspecials.5D_tag|AbilitiesWML]].&lt;br /&gt;
** '''icon''': the image to use as an icon for the attack in the attack choice menu, as a path relative to the images directory. Defaults to the attack's name in the attacks directory (Ex. if ''name=sword'' then default is ''icon=attacks/sword.png''). &lt;br /&gt;
** '''range''': the range of the attack.  Used to determine the enemy's retaliation, which will be of the same type. The range can be anything (as long as it contains only letters, numbers, and underscores), but the standard values are ''melee'' and ''ranged''. Units can only retaliate against attacks for which they have a corresponding attack of the same range. When using a custom range, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom range in the sidebar the game will look for a file called icons/profiles/''range''_attack.png under your addon's images folder. For example, the icon for a range called ''very_long'' would be at images/icons/profiles/very_long_attack.png.&lt;br /&gt;
** '''max_range''': maximum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''min_range''': minimum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''damage''': the damage of this attack&lt;br /&gt;
** '''number''': the number of strikes per attack this weapon has&lt;br /&gt;
** '''accuracy''': a number added to the chance to hit whenever using this weapon offensively (i.e. during a strike with this attack, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''parry''': a number deducted from the enemy chance to hit whenever using this weapon defensively (i.e. during the enemy's strike, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''movement_used''': determines how many movement points using this attack expends. By default all movement is used up, set this to 0 to make attacking with this attack expend no movement.&lt;br /&gt;
** '''attacks_used''': {{DevFeature1.17|12}} determines how many attacks this attack expends (default 1). This number is deducted from the unit's &amp;lt;tt&amp;gt;attacks_left&amp;lt;/tt&amp;gt; when they use this attack.&lt;br /&gt;
** '''attack_weight''': multiplier for total damage that the AI should use to choose which attack to use when attacking (and offer to player as default). Setting it to 0 disables the attack on attack. Until {{DevFeature1.19|2}} positive attack_weight was ignored.&lt;br /&gt;
** '''defense_weight''': used to determine which attack is used for retaliation. This affects gameplay, as the player is not allowed to determine his unit's retaliation weapon. Setting it to 0 disable the attacks on defense.&lt;br /&gt;
** '''alignment''': {{DevFeature1.19|5}} one of lawful/neutral/chaotic/liminal (See TimeWML). Default is unit alignment.&lt;br /&gt;
&lt;br /&gt;
== Other tags ==&lt;br /&gt;
* {{anchor|base_unit|'''[base_unit]'''}}: Contains one attribute, '''id''', which must be the ID of a unit type.  If specified, the UnitTypeWML for that unit is copied into this one, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Additionally, the unit will be marked as variation of the base unit in its own help page, but not in the help page of the base unit.&lt;br /&gt;
&lt;br /&gt;
* '''[abilities]''': Defines the abilities of a unit. See [[AbilitiesWML]]&lt;br /&gt;
&lt;br /&gt;
* '''[event]''': Any [event] written inside the [unit_type] tag will get included into any scenario where a unit of this type appears in. Note that such events get included when a unit of this type first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[EventWML]] and [[WML_Abilities]]. {{DevFeature1.19|4}} Abilities support [event].&lt;br /&gt;
&lt;br /&gt;
* {{anchor|variation|'''[variation]'''}}: Defines a variation of a unit. Variations are invoked with an [effect] tag or the variation= attribute in [[SingleUnitWML]]. They are currently used for graphical variations (giving character sprites new weapons) but theoretically you could do anything with it.&lt;br /&gt;
** '''variation_id''': Mandatory. The value of '''variation=''' used in SingleUnitWML to choose this variant.&lt;br /&gt;
** '''variation_name''': Translatable. The name of the variation, which is displayed in the help and in debug mode. Not setting this looks bad unless combined with '''hide_help'''=yes.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to no.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All keys and tags of '''[unit_type]''', except ''[advancefrom]'', ''[base_unit]'', ''[female]'', ''[male]'', and ''[variation]''.&lt;br /&gt;
&lt;br /&gt;
* '''[male]''', '''[female]''': These can specify a variation based on gender for a unit. If these are provided, they will automatically apply based upon the gender of a unit.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to yes.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All '''[unit_type]''' tags and keys, excluding ''[advancefrom]'', ''[base_unit]'', ''[female]'', and ''[male]''.&lt;br /&gt;
* '''[trait]''': Adds an additional trait to the pool. See [[UnitsWML]] for the syntax.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|2}} see [[UnitTypeWML#Special_Notes|below]].&lt;br /&gt;
&lt;br /&gt;
== Special Notes ==&lt;br /&gt;
&lt;br /&gt;
Use of the '''[special_note]''' tags and attributes results in a bulleted list of special notes in the unit type's help page and in the sidebar tooltip for the unit type's name. Prior to 1.15.2, the old format for special notes was simply text included in the '''[unit_type]description''' attribute.&lt;br /&gt;
&lt;br /&gt;
Note that the sidebar tooltip shows the notes for the current unit, but opening the help-browser by right-clicking on a unit shows the notes for generic units of that type. These can be different if the unit has '''[modifications]'''.&lt;br /&gt;
&lt;br /&gt;
Text given in the following attributes will be collected and shown as the special notes for units and unit types:&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.15|2}} [unit_type][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|2}} [unit][special_note]note= (these are used ''instead of'' any defined in the [unit_type])&lt;br /&gt;
* {{DevFeature1.15|14}} [movetype][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|14}} [''ability tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [attack][specials][''special tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [language]special_note_damage_type_''TYPE''=&lt;br /&gt;
    &lt;br /&gt;
It's no longer necessary to put these notes in each unit_type's .cfg file, and the macros for doing so are now deprecated.&lt;br /&gt;
&lt;br /&gt;
== Removed keys ==&lt;br /&gt;
&lt;br /&gt;
These don't work any more, the documentation is left here as an aid to porting old code.&lt;br /&gt;
&lt;br /&gt;
* {{anchor|advancefrom|'''[advancefrom]'''}}: {{DevFeature1.15|4}} replaced by [[ModificationWML|[modify_unit_type]]]. Defines the previous unit type on the advancement tree. Allows a campaign-specific unit to be spliced into an already existing advancement tree.  It should generally be used only inside a campaign ifdef, to prevent changes to other campaigns. Since all multiplayer content shares MULTIPLAYER define, using advancefrom changes unit type even if the addon is not actively used. For that reason multiplayer advancefrom may only be used with unit types defined in the same addon - then everyone who has the unit has it with same advancements.  This tag makes changes to the ''advances_to'' and ''experience'' keys of a base unit to make it advance into this unit.  It takes these keys:&lt;br /&gt;
** ''unit'': the id of the base unit from which this unit advances.  This adds the unit into the list of units which ''unit'' can advance into.&lt;br /&gt;
** ''experience'': (optional) If present the experience needed to advance is set to this value. If there are more than one [advancefrom] tags referencing the same base unit within the same preprocessor scope (e.g. a campaign #ifdef) with experience= keys, the lowest value of these is chosen.  Note: this will also lower the experience required to advance to other units which the base unit can advance into.&lt;br /&gt;
: If the previous unit type makes use of '''[male]''' and/or '''[female]''' tags, then the current (new) unit type is expected to also. That is, the subtypes defined by those tags will only receive this advancement if the new type has a corresponding tag.&lt;br /&gt;
{{DevFeature1.15|4}} '''[advancefrom]''' was effectively removed in 1.15.4. The intention was to deprecate it, but  the compatibility code that was meant to support it in 1.16 was untested and nonfunctional.&lt;br /&gt;
&lt;br /&gt;
== Deprecating units ==&lt;br /&gt;
&lt;br /&gt;
A macro is provided for deprecating a unit, which uses the built-in deprecation system but hard-codes the level to 3 (meaning &amp;quot;for removal&amp;quot;). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;{DEPRECATED_UNIT old_id new_id version}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also set the new_id to an empty string if there is no replacement.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[TerrainWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=73890</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=73890"/>
		<updated>2024-10-21T20:50:28Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Common keys and tags for every weapon special */ 9236&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.&lt;br /&gt;
&lt;br /&gt;
Each ability or special defines an effect based on one to three units. Most abilities apply to a single unit, and '''[filter_self]''' can be used to determine when the ability is active. Weapon specials apply to two units, which can be filtered either as &amp;quot;attacker&amp;quot; and &amp;quot;defender&amp;quot; (with the obvious meaning) or as &amp;quot;self&amp;quot; and &amp;quot;other&amp;quot; – the unit that possesses the special, and that unit's opponent. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_second]'''.&lt;br /&gt;
&lt;br /&gt;
Leadership-style abilities are a more complex case, as they involve three units. Like a weapon special, there is an attacker and defender, but there is also a third unit that could be referred to as the &amp;quot;teacher&amp;quot;. The &amp;quot;teacher&amp;quot; is the unit that possesses the ability, so it is referred to as &amp;quot;self&amp;quot; in the ability. A leadership ability works by temporarily granting a weapon special to either the attacker or the defender. The unit that benefits from this is referred to as the &amp;quot;student&amp;quot;, while the unit that does not benefit is simply the &amp;quot;other&amp;quot; unit. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_second]'''.&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 of 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;
* {{DevFeature1.15|0}} All [[#The_.5Bspecials.5D_tag|weapon specials]] except for '''[plague]''', '''[heal_on_hit]''', and '''[swarm]''' can be placed in the '''[abilities]''' tag. These [[#Extra_tags_and_keys_used_by_weapon_specials_as_abilities|&amp;quot;weapon specials as abilities&amp;quot;]] will give the weapon special to all attacks the unit has.&lt;br /&gt;
* Any other tag is valid (for example '''[dummy]'''), but will result in an ability that does nothing but report it's there. '''Note:''' a dummy ability must have an id for the name and description to display.&lt;br /&gt;
* {{DevFeature1.15|3}} All the engine [[#The_.5Bspecials.5D_tag|weapon specials]] can be placed in the [abilities] tag now.&lt;br /&gt;
&lt;br /&gt;
=== Available formula variables in Abilities and Weapon Specials  ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|?}} When using formulas in abilities and weapon specials, the following formula variables are available:&lt;br /&gt;
* '''self''': (unit) the unit that has the ability&lt;br /&gt;
* '''student''': (unit) for leadership-like abilities this is the unit that is adjacent to the unit that has the ability; if affect_self=yes, this is also unit who has ability.&lt;br /&gt;
* '''attacker''': (unit) for attack-related abilities and weapon specials, this is the attacking unit during the attack.&lt;br /&gt;
* '''defender''': (unit) for attack-related abilities and weapon specials, this is the defending unit during the attack.&lt;br /&gt;
* '''other''': (unit) the unit whose stats get modified from the ability. For abilities without 'apply_to=opponent' this is always the same as 'student'.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every ability ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any ability that expects a numeric value will also accept formulas using &lt;br /&gt;
[[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses. However, do '''not''' precede those parentheses with a dollar sign like &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the ability. If omitted, the ability will be a hidden ability.&lt;br /&gt;
* '''female_name''': the (translatable) name of the ability when possessed by a female unit. Defaults to ''name'' if not specified.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the ability when inactive. Defaults to ''name'' if not specified; if the ability is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''female_name_inactive''': the (translatable) name of the ability when inactive and possessed by a female unit. Defaults to ''name_inactive'' if not specified. You should thus set ''female_name'' as well!&lt;br /&gt;
* '''description''': the (translatable) description of the ability.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the ability when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* '''affect_self''': if equal to 'yes' (default), the ability will affect the unit that has it.&lt;br /&gt;
* '''affect_allies''': if equal to 'yes', the ability will affect units from the same and allied sides in the specified adjacent hexes. If set to 'no' it will not affect own or allied sides. If not set (default) it will affect units on the same side but not from allied sides.&lt;br /&gt;
* '''affect_enemies''': if equal to 'yes' (default is 'no'), 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. ''Beware of the bug with cumulative leadership in 1.16 https://github.com/wesnoth/wesnoth/issues/6466 , more info see below, in &amp;quot;Extra keys used by the ''leadership'' ability&amp;quot; section''. {{DevFeature1.17|5}}, bug fixed.&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;
* '''halo_image''': {{DevFeature1.17|22}} if used, the halo specified showed on unit affected by ability.&lt;br /&gt;
* '''overlay_image''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit affected by ability.&lt;br /&gt;
* '''halo_image_self''': {{DevFeature1.17|22}} if used, the halo specified showed on unit who has ability when active.&lt;br /&gt;
* '''overlay_image_self''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit who has ability when active.&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] If the unit owning the ability does not match this filter, the ability will be inactive.&lt;br /&gt;
* {{anchor|affect_adjacent|'''[affect_adjacent]'''}}: an adjacent unit that does not match this filter will not receive its effects. There can be multiple [affect_adjacent] tags in a single ability; a unit needs to match any one of these to receive the effects. The side requirement of matching units is defined by the '''affect_allies''' and '''affect_enemies''' keys. If there are no [affect_adjacent] tags, then no adjacent units will receive the effects.&lt;br /&gt;
** '''adjacent''': a comma separated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''. (See [[StandardLocationFilter#Directions|notes]])&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]]. {{DevFeature1.13|2}} The variable $other_unit refers to the unit owning the ability.&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. [filter_self] takes a [[StandardUnitFilter]] as argument.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the ability will not be active and no-one will receive its affects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). In fact, it's really a shorthand for a [filter_adjacent] nested within [filter]. The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[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;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} Shortcut of [unit_type][event].&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''. ''slowed'' means poison will not take effect for adjacent units (it's not related to the weapon special &amp;quot;slows&amp;quot;).&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. Default: 0%. {{DevFeature1.17|24}} Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|0}} minimum resistance value. Default: no limit.&lt;br /&gt;
* '''add''': adds to resistance. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': subtracts from resistance.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides 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;
These keys affect the actual resistance (e.g. -20%), not the damage modifier normally used in [resistance] (e.g. 120).&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the opponent uses a matching weapon.&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;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
''Note:'' cumulative leadership with '''cumulative=yes''' and '''value=''' doesn't work in 1.16 (but fixed in 1.17.12 and later). To work around use '''add=''' or '''sub=''' key (it doesn't require cumulative) (https://github.com/wesnoth/wesnoth/issues/6466 ). If you want each instance of a ''[leadership]'' with the same id to be added you will be able to reuse '''cumulative=yes''' in 1.17.12 and later, otherwise, if you want to add the value of another ''[leadership]'' only once even with the same id in several copies, use '''add'''.&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the opponent uses a matching weapon.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[illuminates]'' ability ===&lt;br /&gt;
&lt;br /&gt;
Because this ability changes the terrain instead of units on it, affect_self, affect_allies, affect_enemies and [filter_adjacent] have no effect.&lt;br /&gt;
* '''value''': the percentage bonus to lawful units. Units with '''alignment=lawful''' do +''value'' % damage when under the influence of a unit with this ability. Units with '''alignment=chaotic''' do -''value'' % damage. Units with '''alignment=neutral''' are unaffected by this ability. Units with '''alignment=liminal''' do -(abs(''value'')) % damage. ''value'' can be a negative number; this is useful if you want to give Chaotic units an advantage instead of Lawful ones. &lt;br /&gt;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
* '''max_value''': the maximum percentage bonus given. Cannot be less than 0. Defaults to 0 if not present.&lt;br /&gt;
* '''min_value''': the minimum percentage bonus given. Cannot be greater than 0. Defaults to 0 if not present.&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;
=== Extra tags used by the ''[teleport]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''[tunnel]''' - a [[DirectActionsWML#.5Btunnel.5D|tunnel tag]] (without the remove key) defining the tunneling source and target hexes, and maybe other conditions. (It automatically applies only to the unit with the ability.)  You may use $teleport_unit inside the [tunnel][source] and [tunnel][target] tag for filtering purposes.&lt;br /&gt;
&lt;br /&gt;
=== Extra tags and keys used by weapon specials as abilities ===&lt;br /&gt;
&lt;br /&gt;
* {{anchor|filter_student|'''[filter_student]'''}}: {{DevFeature1.15|0}} If present, only the unit matching this filter, either the possessor of the ability if affect_self=yes, or an adjacent unit matching '''[filter_adjacent]''' will be affected. '''Replaces''' '''[filter_self]''' of normal weapon specials.&lt;br /&gt;
* '''overwrite_specials''': {{DevFeature1.15|13}} If present, allows a special abilities weapon with a numerical value to impose its value and ignore values of abilities or specials of the same type. If '''overwrite_specials=one_side''', the specials and abilities used by the opponent of the unit affected by the ability with this key and applied to it will not be affected. If '''overwrite_specials=both_sides''', all non-key-carrying abilities and all specials of the same type affecting the recipient unit will be affected, even if used by the opponent (used in the macro FORCE_CHANCE_TO_HIT).&lt;br /&gt;
* {{anchor|overwrite|'''[overwrite]'''}}: {{DevFeature1.17|22}} Part of '''overwrite_specials'''. Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** {{anchor|filter_specials|'''[experimental_filter_specials]'''}}: [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
* Other keys and tags appropriate to the specific weapon special.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common abilities ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:abilities.cfg macro reference]&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;
* {{DevFeature1.13|2}} ABILITY_LEADERSHIP (replaces the above leadership macros, which are now deprecated)&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;
* '''[attacks]''': modifies the number of attacks of a weapon, in using '''value''', '''add''', '''sub''', '''multiply''' or '''divide''' attributes&lt;br /&gt;
* '''[berserk]''': pushes the attack for more than one combat round, using '''value''' attribute, '''value''' is 1 by default&lt;br /&gt;
* '''[chance_to_hit]''': modifies the chance to hit of a weapon, using same standard numerical attributes as '''[attacks]'''&lt;br /&gt;
* '''[damage]''': modifies the damage of a weapon, using same attributes as '''[attacks]''' and '''[chance_to_hit]'''&lt;br /&gt;
* '''[damage_type]''' {{DevFeature1.17|23}}: changes the damage type of a weapon&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker half of the damage dealt, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 50% by default&lt;br /&gt;
* '''[firststrike]''': forces the weapon to always strike first&lt;br /&gt;
* '''[heal_on_hit]''': heals the attacker when an attack connects, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 0 by default&lt;br /&gt;
* '''[petrifies]''': turns the target to stone&lt;br /&gt;
* '''[plague]''': when used to kill an enemy, a friendly unit takes its place&lt;br /&gt;
* '''[poison]''': poisons the target&lt;br /&gt;
* '''[slow]''': slows the target&lt;br /&gt;
* '''[swarm]''': number of strikes decreases as the unit loses hitpoints&lt;br /&gt;
Any other tag is valid, but will result in a special that does nothing but report it is there.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every weapon special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any weapon special that expects a numeric value will also accept formulas using [[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the special. If omitted, the special will be hidden from the player.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the special when inactive. Defaults to ''name'' if not specified; if the special is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''description''': the (translatable) description of the special.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the special when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&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''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special {{DevFeature1.17|23}} ===&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=73889</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=73889"/>
		<updated>2024-10-21T20:50:05Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Common keys and tags for every ability */ 9236&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.&lt;br /&gt;
&lt;br /&gt;
Each ability or special defines an effect based on one to three units. Most abilities apply to a single unit, and '''[filter_self]''' can be used to determine when the ability is active. Weapon specials apply to two units, which can be filtered either as &amp;quot;attacker&amp;quot; and &amp;quot;defender&amp;quot; (with the obvious meaning) or as &amp;quot;self&amp;quot; and &amp;quot;other&amp;quot; – the unit that possesses the special, and that unit's opponent. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_second]'''.&lt;br /&gt;
&lt;br /&gt;
Leadership-style abilities are a more complex case, as they involve three units. Like a weapon special, there is an attacker and defender, but there is also a third unit that could be referred to as the &amp;quot;teacher&amp;quot;. The &amp;quot;teacher&amp;quot; is the unit that possesses the ability, so it is referred to as &amp;quot;self&amp;quot; in the ability. A leadership ability works by temporarily granting a weapon special to either the attacker or the defender. The unit that benefits from this is referred to as the &amp;quot;student&amp;quot;, while the unit that does not benefit is simply the &amp;quot;other&amp;quot; unit. When filtering on the &amp;quot;other&amp;quot; unit, you use '''[filter_second]'''.&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 of 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;
* {{DevFeature1.15|0}} All [[#The_.5Bspecials.5D_tag|weapon specials]] except for '''[plague]''', '''[heal_on_hit]''', and '''[swarm]''' can be placed in the '''[abilities]''' tag. These [[#Extra_tags_and_keys_used_by_weapon_specials_as_abilities|&amp;quot;weapon specials as abilities&amp;quot;]] will give the weapon special to all attacks the unit has.&lt;br /&gt;
* Any other tag is valid (for example '''[dummy]'''), but will result in an ability that does nothing but report it's there. '''Note:''' a dummy ability must have an id for the name and description to display.&lt;br /&gt;
* {{DevFeature1.15|3}} All the engine [[#The_.5Bspecials.5D_tag|weapon specials]] can be placed in the [abilities] tag now.&lt;br /&gt;
&lt;br /&gt;
=== Available formula variables in Abilities and Weapon Specials  ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|?}} When using formulas in abilities and weapon specials, the following formula variables are available:&lt;br /&gt;
* '''self''': (unit) the unit that has the ability&lt;br /&gt;
* '''student''': (unit) for leadership-like abilities this is the unit that is adjacent to the unit that has the ability; if affect_self=yes, this is also unit who has ability.&lt;br /&gt;
* '''attacker''': (unit) for attack-related abilities and weapon specials, this is the attacking unit during the attack.&lt;br /&gt;
* '''defender''': (unit) for attack-related abilities and weapon specials, this is the defending unit during the attack.&lt;br /&gt;
* '''other''': (unit) the unit whose stats get modified from the ability. For abilities without 'apply_to=opponent' this is always the same as 'student'.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every ability ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any ability that expects a numeric value will also accept formulas using &lt;br /&gt;
[[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses. However, do '''not''' precede those parentheses with a dollar sign like &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the ability. If omitted, the ability will be a hidden ability.&lt;br /&gt;
* '''female_name''': the (translatable) name of the ability when possessed by a female unit. Defaults to ''name'' if not specified.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the ability when inactive. Defaults to ''name'' if not specified; if the ability is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''female_name_inactive''': the (translatable) name of the ability when inactive and possessed by a female unit. Defaults to ''name_inactive'' if not specified. You should thus set ''female_name'' as well!&lt;br /&gt;
* '''description''': the (translatable) description of the ability.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the ability when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&lt;br /&gt;
* '''affect_self''': if equal to 'yes' (default), the ability will affect the unit that has it.&lt;br /&gt;
* '''affect_allies''': if equal to 'yes', the ability will affect units from the same and allied sides in the specified adjacent hexes. If set to 'no' it will not affect own or allied sides. If not set (default) it will affect units on the same side but not from allied sides.&lt;br /&gt;
* '''affect_enemies''': if equal to 'yes' (default is 'no'), 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. ''Beware of the bug with cumulative leadership in 1.16 https://github.com/wesnoth/wesnoth/issues/6466 , more info see below, in &amp;quot;Extra keys used by the ''leadership'' ability&amp;quot; section''. {{DevFeature1.17|5}}, bug fixed.&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;
* '''halo_image''': {{DevFeature1.17|22}} if used, the halo specified showed on unit affected by ability.&lt;br /&gt;
* '''overlay_image''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit affected by ability.&lt;br /&gt;
* '''halo_image_self''': {{DevFeature1.17|22}} if used, the halo specified showed on unit who has ability when active.&lt;br /&gt;
* '''overlay_image_self''': {{DevFeature1.17|22}} if used, the overlay specified showed on unit who has ability when active.&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] If the unit owning the ability does not match this filter, the ability will be inactive.&lt;br /&gt;
* {{anchor|affect_adjacent|'''[affect_adjacent]'''}}: an adjacent unit that does not match this filter will not receive its effects. There can be multiple [affect_adjacent] tags in a single ability; a unit needs to match any one of these to receive the effects. The side requirement of matching units is defined by the '''affect_allies''' and '''affect_enemies''' keys. If there are no [affect_adjacent] tags, then no adjacent units will receive the effects.&lt;br /&gt;
** '''adjacent''': a comma separated list of any combination of these directions: '''n''','''ne''','''se''','''s''','''sw''','''nw'''. (See [[StandardLocationFilter#Directions|notes]])&lt;br /&gt;
** '''[filter]''': a [[StandardUnitFilter]]. {{DevFeature1.13|2}} The variable $other_unit refers to the unit owning the ability.&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. [filter_self] takes a [[StandardUnitFilter]] as argument.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the ability will not be active and no-one will receive its affects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). In fact, it's really a shorthand for a [filter_adjacent] nested within [filter]. The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[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;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} Shortcut of [unit_type][event].&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''. ''slowed'' means poison will not take effect for adjacent units (it's not related to the weapon special &amp;quot;slows&amp;quot;).&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. Default: 0%. {{DevFeature1.17|24}} Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|0}} minimum resistance value. Default: no limit.&lt;br /&gt;
* '''add''': adds to resistance. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': subtracts from resistance.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides 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;
These keys affect the actual resistance (e.g. -20%), not the damage modifier normally used in [resistance] (e.g. 120).&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the resistance ability only takes effect when the opponent uses a matching weapon.&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;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
''Note:'' cumulative leadership with '''cumulative=yes''' and '''value=''' doesn't work in 1.16 (but fixed in 1.17.12 and later). To work around use '''add=''' or '''sub=''' key (it doesn't require cumulative) (https://github.com/wesnoth/wesnoth/issues/6466 ). If you want each instance of a ''[leadership]'' with the same id to be added you will be able to reuse '''cumulative=yes''' in 1.17.12 and later, otherwise, if you want to add the value of another ''[leadership]'' only once even with the same id in several copies, use '''add'''.&lt;br /&gt;
* '''[filter_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the owner of the ability uses a matching weapon.&lt;br /&gt;
* '''[filter_second_weapon]''': {{DevFeature1.15|0}} If present, the leadership ability only takes effect when the opponent uses a matching weapon.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[illuminates]'' ability ===&lt;br /&gt;
&lt;br /&gt;
Because this ability changes the terrain instead of units on it, affect_self, affect_allies, affect_enemies and [filter_adjacent] have no effect.&lt;br /&gt;
* '''value''': the percentage bonus to lawful units. Units with '''alignment=lawful''' do +''value'' % damage when under the influence of a unit with this ability. Units with '''alignment=chaotic''' do -''value'' % damage. Units with '''alignment=neutral''' are unaffected by this ability. Units with '''alignment=liminal''' do -(abs(''value'')) % damage. ''value'' can be a negative number; this is useful if you want to give Chaotic units an advantage instead of Lawful ones. &lt;br /&gt;
* '''add''': the cumulative percentage bonus to damage. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the cumulative percentage bonus subtracted to damage.&lt;br /&gt;
* '''multiply''': multiplies resistance value. &lt;br /&gt;
* '''divide''': divides resistance value.&lt;br /&gt;
* '''max_value''': the maximum percentage bonus given. Cannot be less than 0. Defaults to 0 if not present.&lt;br /&gt;
* '''min_value''': the minimum percentage bonus given. Cannot be greater than 0. Defaults to 0 if not present.&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;
=== Extra tags used by the ''[teleport]'' ability ===&lt;br /&gt;
&lt;br /&gt;
* '''[tunnel]''' - a [[DirectActionsWML#.5Btunnel.5D|tunnel tag]] (without the remove key) defining the tunneling source and target hexes, and maybe other conditions. (It automatically applies only to the unit with the ability.)  You may use $teleport_unit inside the [tunnel][source] and [tunnel][target] tag for filtering purposes.&lt;br /&gt;
&lt;br /&gt;
=== Extra tags and keys used by weapon specials as abilities ===&lt;br /&gt;
&lt;br /&gt;
* {{anchor|filter_student|'''[filter_student]'''}}: {{DevFeature1.15|0}} If present, only the unit matching this filter, either the possessor of the ability if affect_self=yes, or an adjacent unit matching '''[filter_adjacent]''' will be affected. '''Replaces''' '''[filter_self]''' of normal weapon specials.&lt;br /&gt;
* '''overwrite_specials''': {{DevFeature1.15|13}} If present, allows a special abilities weapon with a numerical value to impose its value and ignore values of abilities or specials of the same type. If '''overwrite_specials=one_side''', the specials and abilities used by the opponent of the unit affected by the ability with this key and applied to it will not be affected. If '''overwrite_specials=both_sides''', all non-key-carrying abilities and all specials of the same type affecting the recipient unit will be affected, even if used by the opponent (used in the macro FORCE_CHANCE_TO_HIT).&lt;br /&gt;
* {{anchor|overwrite|'''[overwrite]'''}}: {{DevFeature1.17|22}} Part of '''overwrite_specials'''. Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** {{anchor|filter_specials|'''[experimental_filter_specials]'''}}: [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
* Other keys and tags appropriate to the specific weapon special.&lt;br /&gt;
&lt;br /&gt;
=== Macros for common abilities ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:abilities.cfg macro reference]&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;
* {{DevFeature1.13|2}} ABILITY_LEADERSHIP (replaces the above leadership macros, which are now deprecated)&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;
* '''[attacks]''': modifies the number of attacks of a weapon, in using '''value''', '''add''', '''sub''', '''multiply''' or '''divide''' attributes&lt;br /&gt;
* '''[berserk]''': pushes the attack for more than one combat round, using '''value''' attribute, '''value''' is 1 by default&lt;br /&gt;
* '''[chance_to_hit]''': modifies the chance to hit of a weapon, using same standard numerical attributes as '''[attacks]'''&lt;br /&gt;
* '''[damage]''': modifies the damage of a weapon, using same attributes as '''[attacks]''' and '''[chance_to_hit]'''&lt;br /&gt;
* '''[damage_type]''' {{DevFeature1.17|23}}: changes the damage type of a weapon&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker half of the damage dealt, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 50% by default&lt;br /&gt;
* '''[firststrike]''': forces the weapon to always strike first&lt;br /&gt;
* '''[heal_on_hit]''': heals the attacker when an attack connects, using same attributes as '''[attacks]''' and '''[chance_to_hit]''', '''value''' is 0 by default&lt;br /&gt;
* '''[petrifies]''': turns the target to stone&lt;br /&gt;
* '''[plague]''': when used to kill an enemy, a friendly unit takes its place&lt;br /&gt;
* '''[poison]''': poisons the target&lt;br /&gt;
* '''[slow]''': slows the target&lt;br /&gt;
* '''[swarm]''': number of strikes decreases as the unit loses hitpoints&lt;br /&gt;
Any other tag is valid, but will result in a special that does nothing but report it is there.&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for every weapon special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|?}} All keys inside any weapon special that expects a numeric value will also accept formulas using [[Wesnoth Formula Language]]. In order to use a formula in these keys, you must enclose it in parentheses.&lt;br /&gt;
&lt;br /&gt;
* '''name''': the (translatable) name of the special. If omitted, the special will be hidden from the player.&lt;br /&gt;
* '''name_inactive''': the (translatable) name of the special when inactive. Defaults to ''name'' if not specified; if the special is supposed to be not displayed when inactive, you must explicitly set ''name_inactive'' to an empty string (nothing after the equals sign).&lt;br /&gt;
* '''description''': the (translatable) description of the special.&lt;br /&gt;
* '''description_inactive''': the (translatable) description of the special when inactive. Defaults to ''description'' if not specified.&lt;br /&gt;
* '''special_note''' {{DevFeature1.15|14}} Translatable string, which will be displayed in the unit’s help. See also [[UnitTypeWML#Special_Notes]].&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''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special {{DevFeature1.17|23}} ===&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73799</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73799"/>
		<updated>2024-09-23T15:53:14Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Attacks */ alignment&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
Each '''[unit_type]''' tag defines one unit type. (for the use of [unit] to create a unit, see [[SingleUnitWML]])&lt;br /&gt;
&lt;br /&gt;
Unit animation syntax is described in [[AnimationWML]]. In addition to the animation tags described there, the following key/tags are recognized:&lt;br /&gt;
* '''advances_to''': When this unit has ''experience'' greater than or equal to ''experience'', it is replaced by a unit of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by. The special value 'null' says that the unit does not advance but gets an AMLA instead. Can be a comma-separated list of units that can be chosen from upon advancing.&lt;br /&gt;
* '''alignment''': one of lawful/neutral/chaotic/liminal (See [[TimeWML]]). Default is &amp;quot;neutral&amp;quot;.&lt;br /&gt;
* '''attacks''': the number of times that this unit can attack each turn. Default is 1.&lt;br /&gt;
* '''cost''': when a player recruits a unit of this type, the player loses ''cost'' gold. If this would cause gold to drop below 0,  the unit cannot be recruited. Default is 1.&lt;br /&gt;
* '''recall_cost''': {{DevFeature1.13|0}} the default recall cost of units of this type, overriding the recall cost set in scenario [[SideWML|[side]]] tags or the global [[GameConfigWML|[game_config]]] value. Individual units may override this value in [[SingleUnitWML|[unit]]]. A value of -1 is equivalent to not specifying this attribute. {{DevFeature1.15|0}} Units are now recalled for AI sides even if the recall_cost is larger than the unit's worth (essentially its cost, plus potentially a bonus for experience points). In 1.14 and earlier, units were not recalled by the AI in this case even if this was the only recall/recruit action possible to the AI.&lt;br /&gt;
* '''description''': (translatable) the text displayed in the unit descriptor box for this unit. Default 'No description available...'. &lt;br /&gt;
* '''do_not_list''': Not used by the game, but by tools for browsing and listing the unit tree. If this is 'yes', the unit will be ignored by these tools. {{DevFeature1.13|?}} When placing units in debug mode this unit isn't listed (but can still be placed using the :create command). This restriction is lifted in version &amp;lt;b&amp;gt;1.14.3&amp;lt;/b&amp;gt;.&lt;br /&gt;
* '''ellipse''': the ellipse image to display under the unit, which is normally team-colored. Default is &amp;quot;misc/ellipse&amp;quot;. &amp;quot;-nozoc&amp;quot; and &amp;quot;-leader&amp;quot; are automatically appended for units without zone of control and with canrecruit=yes respectively. The [http://www.wesnoth.org/macro-reference.xhtml#IS_HERO IS_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#MAKE_HERO MAKE_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#UNMAKE_HERO UNMAKE_HERO] macros change the ellipse to/back from &amp;quot;misc/ellipse-hero&amp;quot;. Finally, setting this to &amp;quot;none&amp;quot; will cause the unit to not have any ellipses displayed under it regardless of the user's preferences.&lt;br /&gt;
::WARNING: Be aware that setting this to &amp;quot;misc/ellipse-hero&amp;quot; for a unit with canrecruit=yes will result in the ellipse being &amp;quot;misc/ellipse-hero-leader&amp;quot;, which is not a supported combination (it doesn't have a graphic, and will cause error logs that the graphic is missing). This is tracked as bug [https://github.com/wesnoth/wesnoth/issues/6258 6258] on GitHub.&lt;br /&gt;
* '''experience''': When this unit has experience greater than or equal to ''experience'', it is replaced by a unit with 0 experience of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by.&lt;br /&gt;
* '''flag_rgb''': usually set by [http://www.wesnoth.org/macro-reference.xhtml#MAGENTA_IS_THE_TEAM_COLOR MAGENTA_IS_THE_TEAM_COLOR]; specifies the colours in the base flag to use for team-colouring the unit, expressed as a colour name (such as magenta) or a comma-separated list of RGB values (in hex format).&lt;br /&gt;
* '''gender''': has a value of either ''male'' or ''female'', and determines which of the keys ''male_names'' and ''female_names''  should be read. When a unit of this type is recruited, it will be randomly assigned a name by the random name generator, which will use these names as a base. If '''gender''' is not specified it defaults to ''male''.&lt;br /&gt;
* '''halo''': an image to place centered on the unit. It is drawn on top of the unit, and on top of surrounding units if the image is larger than one hex. It works similarly to the halo attribute of {{tag|InterfaceActionsWML|item}}, and it can be animated with a comma-separated list of images.&lt;br /&gt;
* '''hide_help''': (yes|no) default=no. Determines if the unit type will appear in the in-game help.&lt;br /&gt;
* '''hitpoints''': the maximum HP that the unit has, and the HP it has when it is created.&lt;br /&gt;
* '''id''': the value of the ''type'' key for units of this type. This is required and must be unique among all [unit_type] tags. An ''id'' must consist only of alphanumerics and spaces (or underscores). ''type'' keys are found in [[SingleUnitWML]] and [[FilterWML]]. For example, id=Drake Flare&lt;br /&gt;
*'''ignore_race_traits''': 'yes' or 'no' (default). Determines whether racial traits (see [[UnitsWML]]) are applied. &lt;br /&gt;
* '''image''': sets the base image of the unit, which is used on the map.&lt;br /&gt;
* '''image_icon''': sets the image used to represent the unit in areas such as the attack dialog and the unit image box in the sidebar. [[ImagePathFunctions#Crop_Function|~CROP]] function can be useful here. You can see Loyalists Paladin as an example.&lt;br /&gt;
* '''level''': the amount of upkeep the unit costs.  After this unit fights, its opponent gains ''level'' experience. See also kill_experience ([[GameConfigWML]]), and leadership ([[AbilitiesWML]]).&lt;br /&gt;
* '''upkeep''': the amount of upkeep the unit costs if it differs from its level.&lt;br /&gt;
* '''movement''': the number of move points that this unit receives each turn.&lt;br /&gt;
* '''movement_type''': See [[UnitsWML#.5Bmovetype.5D|movetype]]. Note that the tags '''[movement_costs]''', '''[vision_costs]''', '''[defense]''', and '''[resistance]''' can be used to modify this movetype.&lt;br /&gt;
* '''name''': (translatable) displayed in the Status Table for units of this type.&lt;br /&gt;
* '''num_traits''': the number of traits that units of this type should receive when they are recruited, overriding the value set in the [race] tag.&lt;br /&gt;
* '''profile''': the portrait image to use for this unit type. You can also set a portrait for an individual unit instead of the whole unit type (see [[SingleUnitWML]]). The engine first looks for the image in the transparent subdirectory and if found that image is used. If not found it will use the image as-is. Depending on the size the engine will or will not scale the image, the cutoff currently is at 300x300. For images which should only be shown on the right side in the dialog append ~RIGHT() to the image.&lt;br /&gt;
** If &amp;quot;unit_image&amp;quot; is given instead of a filename, uses the unit's base image as the portrait (in the same manner that unit types without portraits do by default).&lt;br /&gt;
** If &amp;quot;none&amp;quot; is given instead of a filename, no image will be displayed.&lt;br /&gt;
* '''small_profile''': the image to use when a smaller portrait is needed than the one used for messages (e.g., in the help system). When this attribute is missing, the value of the '''profile''' attribute is used instead. When present, the heuristic for finding a transparent portrait is disabled for the '''profile''' attribute, so the correct '''profile''' should be set too. If '''profile''' is not present, '''small_profile''' is ignored. Note that image modifiers are allowed; they might be useful for cropping and rescaling a portrait:&lt;br /&gt;
 small_profile=&amp;quot;portraits/elves/transparent/marksman+female.png~CROP(0,20,380,380)~SCALE(205,205)&amp;quot;&lt;br /&gt;
 profile=&amp;quot;portraits/elves/transparent/marksman+female.png&amp;quot;&lt;br /&gt;
* '''race''': See {{tag|UnitsWML|race}}.  Also used in standard unit filter (see [[FilterWML]]). Mainline Wesnoth features following values:  bats, drake, dwarf, elf, falcon, goblin, gryphon, human, dunefolk, lizard, mechanical, merman, monster, naga, ogre, orc, troll, undead, wolf, wose. They are defined in /data/core/units.cfg.&lt;br /&gt;
* '''undead_variation''': When a unit of this type is killed by a weapon with the plague special, this variation is applied to the new plague unit that is created, whatever its type. For example, if the plague special creates Walking Corpses and undead_variation is set to &amp;quot;troll&amp;quot;, you'll get a troll Walking Corpse. Defaults to the undead_variation set in this unit type's race.&lt;br /&gt;
* '''usage''': the way that the AI should recruit this unit, as determined by the scenario designer. (See ''recruitment_pattern'', [[AiWML]]).  The following are conventions on usage:&amp;lt;br&amp;gt; ** ''scout'': Fast, mobile unit meant for exploration and village grabbing.&amp;lt;br&amp;gt; ** ''fighter'': Melee fighter, melee attack substantially more powerful than ranged.&amp;lt;br&amp;gt; ** ''archer'': Ranged fighter, ranged attack substantially more powerful than melee.&amp;lt;br&amp;gt; ** ''mixed fighter'': Melee and ranged fighter, melee and ranged attacks roughly equal.&amp;lt;br&amp;gt; ** ''healer'': Specialty 'heals' or 'cures'.&amp;lt;br&amp;gt;Note that this field primarily affects recruitment.  It also has a small effect on unit movement (the AI tries to keep scouts away from enemies, to some extent).  It does not affect the AI's behavior in combat; that is always computed from attack power and hitpoints. Non-standard usages may be used as well.&lt;br /&gt;
* '''vision''': the number of vision points to calculate the unit's sight range. Defaults to ''movement'' if not present.&lt;br /&gt;
* '''jamming''': the number of jamming points. Defaults to ''0'' if not present. See [[UnitsWML#.5Bmovetype.5D|[jamming_costs]]]&lt;br /&gt;
* '''zoc''': if &amp;quot;yes&amp;quot; the unit will have a zone of control regardless of level.  If present but set to anything other than &amp;quot;yes,&amp;quot; the unit will have no zone of control.  If the tag is omitted, zone of control is dictated by unit level (level 0 = no zoc, level 1+ = has zoc).&lt;br /&gt;
* '''die_sound''': sets the sound, which is used when the unit dies.&lt;br /&gt;
* '''healed_sound''': sets the sound used when the unit is healed in any way (default: heal.wav).&lt;br /&gt;
* '''hp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''xp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''bar_offset_x''', '''bar_offset_y''': The offset of the hp and xp bars from the normal bar position of 72x72 unit sprite.&lt;br /&gt;
&lt;br /&gt;
== After max level advancement (AMLA) ==&lt;br /&gt;
* '''[advancement]''': describes what happens to a unit when it reaches the XP required for advancement.  It is considered as an advancement in the same way as advancement described by '''advances_to'''; however, if the player chooses this advancement, the unit will have one or more effects applied to it instead of advancing.&lt;br /&gt;
** '''id''': unique identifier for this advancement; ''Required'' if there are multiple advancement options, or if ''strict_amla=no''.&lt;br /&gt;
** '''always_display''': if set to true displays the AMLA option even if it is the only available one.&lt;br /&gt;
** '''description''': a description displayed as the option for this advancement if there is another advancement option that the player must choose from; otherwise, the advancement is chosen automatically and this key is irrelevant.&lt;br /&gt;
** '''image''': an image to display next to the description in the advancement menu.&lt;br /&gt;
** '''max_times''': default 1.  The maximum times the unit can be awarded this advancement. Pass -1 for &amp;quot;unlimited&amp;quot;.&lt;br /&gt;
** '''strict_amla''':  (yes|no) default=no. Disable the AMLA if the unit can advance to another unit.&lt;br /&gt;
** '''major_amla''': (yes|no) default=no. Sets whether the unit's XP bar is blue(=yes) or purple(=no). In case of more [advancement] tags, if there is one with major_amla=yes, the XP bar will be blue.&lt;br /&gt;
** '''require_amla''': An optional list of AMLA ''id'' keys that act as prerequisites for this advancement to become available.  Order is not important, and an AMLA id can be repeated any number of times to indicate that another advancement must be chosen several times before this advancement option will become available.&lt;br /&gt;
*** example: &amp;lt;tt&amp;gt;require_amla=tough,tough,incr_damage&amp;lt;/tt&amp;gt; assumes there exist other [advancement] options called ''id=tough'' and ''id=incr_damage''.  Once ''tough'' is chosen twice and ''incr_damage'' is chosen once, then the current [advancement] will become available.&lt;br /&gt;
*** ''require_amla=tough,incr_damage,tough'' is an equivalent way of expressing this.&lt;br /&gt;
** '''exclude_amla''': {{DevFeature1.13|2}} An optional list of AMLA ''id'' keys that represent AMLAs that are mutually exclusive to this one. Order is not important, and an AMLA id can be repeated. If the unit already has any of the AMLAs that appear once in this list, then this AMLA will not be made available. If an AMLA id appears multiple times in the list, then this AMLA will be made available only if the other AMLA has been chosen less than the number of times it appears in the list. Of course, for this to really make two AMLAs mutually exclusive, you need to add ''exclude_amla'' to both AMLA defintions.&lt;br /&gt;
** '''[effect]''': A modification applied to the unit whenever this advancement is chosen.  See [[EffectWML]]&lt;br /&gt;
** '''[filter]''': A  [[StandardUnitFilter]],  the advancement will only be available when the unit passes this filter during the time the advancement dialog is shown.&lt;br /&gt;
&lt;br /&gt;
== Attacks ==&lt;br /&gt;
* '''[attack]''': one of the unit's attacks.&lt;br /&gt;
** '''description''': a translatable text for name of the attack, to be displayed to the user.&lt;br /&gt;
** '''name''': the name of the attack. Used as a default description, if ''description'' is not present, and to determine the default icon, if ''icon'' is not present (see below).  Non-translatable.  Used for the ''has_weapon'' key and animation filters; see [[StandardUnitFilter]] and [[AnimationWML]]&lt;br /&gt;
** '''type''': the damage type of the attack.  Used in determining resistance to this attack (see {{tag|UnitsWML|movetype|resistance}}). Usually this is one of ''blade'', ''pierce'', ''impact'', ''fire'', ''cold'', or ''arcane'', but it can be set to anything (as long as it contains only letters, numbers, and underscores). When using a custom type, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom damage type in the sidebar, the game will look for a file called icons/profiles/''type''.png under your addon's images folder. For example, the icon for a damage type called ''electric'' would be at images/icons/profiles/electric.png.&lt;br /&gt;
** '''[specials]''': contains the specials of the attack. See [[AbilitiesWML#The_.5Bspecials.5D_tag|AbilitiesWML]].&lt;br /&gt;
** '''icon''': the image to use as an icon for the attack in the attack choice menu, as a path relative to the images directory. Defaults to the attack's name in the attacks directory (Ex. if ''name=sword'' then default is ''icon=attacks/sword.png''). &lt;br /&gt;
** '''range''': the range of the attack.  Used to determine the enemy's retaliation, which will be of the same type. The range can be anything (as long as it contains only letters, numbers, and underscores), but the standard values are ''melee'' and ''ranged''. Units can only retaliate against attacks for which they have a corresponding attack of the same range. When using a custom range, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom range in the sidebar the game will look for a file called icons/profiles/''range''_attack.png under your addon's images folder. For example, the icon for a range called ''very_long'' would be at images/icons/profiles/very_long_attack.png.&lt;br /&gt;
** '''max_range''': maximum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''min_range''': minimum distance (in number of hexes) to which this attack works. Default is 1.&lt;br /&gt;
*** This currently lacks UI and AI support.&lt;br /&gt;
** '''damage''': the damage of this attack&lt;br /&gt;
** '''number''': the number of strikes per attack this weapon has&lt;br /&gt;
** '''accuracy''': a number added to the chance to hit whenever using this weapon offensively (i.e. during a strike with this attack, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''parry''': a number deducted from the enemy chance to hit whenever using this weapon defensively (i.e. during the enemy's strike, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''movement_used''': determines how many movement points using this attack expends. By default all movement is used up, set this to 0 to make attacking with this attack expend no movement.&lt;br /&gt;
** '''attacks_used''': {{DevFeature1.17|12}} determines how many attacks this attack expends (default 1). This number is deducted from the unit's &amp;lt;tt&amp;gt;attacks_left&amp;lt;/tt&amp;gt; when they use this attack.&lt;br /&gt;
** '''attack_weight''': multiplier for total damage that the AI should use to choose which attack to use when attacking (and offer to player as default). Setting it to 0 disables the attack on attack. Until {{DevFeature1.19|2}} positive attack_weight was ignored.&lt;br /&gt;
** '''defense_weight''': used to determine which attack is used for retaliation. This affects gameplay, as the player is not allowed to determine his unit's retaliation weapon. Setting it to 0 disable the attacks on defense.&lt;br /&gt;
** '''alignment''': {{DevFeature1.19|5}} one of lawful/neutral/chaotic/liminal (See TimeWML). Default is unit alignment.&lt;br /&gt;
&lt;br /&gt;
== Other tags ==&lt;br /&gt;
* {{anchor|base_unit|'''[base_unit]'''}}: Contains one attribute, '''id''', which must be the ID of a unit type.  If specified, the UnitTypeWML for that unit is copied into this one, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Additionally, the unit will be marked as variation of the base unit in its own help page, but not in the help page of the base unit.&lt;br /&gt;
&lt;br /&gt;
* '''[abilities]''': Defines the abilities of a unit. See [[AbilitiesWML]]&lt;br /&gt;
&lt;br /&gt;
* '''[event]''': Any [event] written inside the [unit_type] tag will get included into any scenario where a unit of this type appears in. Note that such events get included when a unit of this type first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[EventWML]] and [[WML_Abilities]]&lt;br /&gt;
&lt;br /&gt;
* {{anchor|variation|'''[variation]'''}}: Defines a variation of a unit. Variations are invoked with an [effect] tag or the variation= attribute in [[SingleUnitWML]]. They are currently used for graphical variations (giving character sprites new weapons) but theoretically you could do anything with it.&lt;br /&gt;
** '''variation_id''': Mandatory. The value of '''variation=''' used in SingleUnitWML to choose this variant.&lt;br /&gt;
** '''variation_name''': Translatable. The name of the variation, which is displayed in the help and in debug mode. Not setting this looks bad unless combined with '''hide_help'''=yes.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to no.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All keys and tags of '''[unit_type]''', except ''[advancefrom]'', ''[base_unit]'', ''[female]'', ''[male]'', and ''[variation]''.&lt;br /&gt;
&lt;br /&gt;
* '''[male]''', '''[female]''': These can specify a variation based on gender for a unit. If these are provided, they will automatically apply based upon the gender of a unit.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to yes.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All '''[unit_type]''' tags and keys, excluding ''[advancefrom]'', ''[base_unit]'', ''[female]'', and ''[male]''.&lt;br /&gt;
* '''[trait]''': Adds an additional trait to the pool. See [[UnitsWML]] for the syntax.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|2}} see [[UnitTypeWML#Special_Notes|below]].&lt;br /&gt;
&lt;br /&gt;
== Special Notes ==&lt;br /&gt;
&lt;br /&gt;
Use of the '''[special_note]''' tags and attributes results in a bulleted list of special notes in the unit type's help page and in the sidebar tooltip for the unit type's name. Prior to 1.15.2, the old format for special notes was simply text included in the '''[unit_type]description''' attribute.&lt;br /&gt;
&lt;br /&gt;
Note that the sidebar tooltip shows the notes for the current unit, but opening the help-browser by right-clicking on a unit shows the notes for generic units of that type. These can be different if the unit has '''[modifications]'''.&lt;br /&gt;
&lt;br /&gt;
Text given in the following attributes will be collected and shown as the special notes for units and unit types:&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.15|2}} [unit_type][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|2}} [unit][special_note]note= (these are used ''instead of'' any defined in the [unit_type])&lt;br /&gt;
* {{DevFeature1.15|14}} [movetype][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|14}} [''ability tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [attack][specials][''special tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [language]special_note_damage_type_''TYPE''=&lt;br /&gt;
    &lt;br /&gt;
It's no longer necessary to put these notes in each unit_type's .cfg file, and the macros for doing so are now deprecated.&lt;br /&gt;
&lt;br /&gt;
== Removed keys ==&lt;br /&gt;
&lt;br /&gt;
These don't work any more, the documentation is left here as an aid to porting old code.&lt;br /&gt;
&lt;br /&gt;
* {{anchor|advancefrom|'''[advancefrom]'''}}: {{DevFeature1.15|4}} replaced by [[ModificationWML|[modify_unit_type]]]. Defines the previous unit type on the advancement tree. Allows a campaign-specific unit to be spliced into an already existing advancement tree.  It should generally be used only inside a campaign ifdef, to prevent changes to other campaigns. Since all multiplayer content shares MULTIPLAYER define, using advancefrom changes unit type even if the addon is not actively used. For that reason multiplayer advancefrom may only be used with unit types defined in the same addon - then everyone who has the unit has it with same advancements.  This tag makes changes to the ''advances_to'' and ''experience'' keys of a base unit to make it advance into this unit.  It takes these keys:&lt;br /&gt;
** ''unit'': the id of the base unit from which this unit advances.  This adds the unit into the list of units which ''unit'' can advance into.&lt;br /&gt;
** ''experience'': (optional) If present the experience needed to advance is set to this value. If there are more than one [advancefrom] tags referencing the same base unit within the same preprocessor scope (e.g. a campaign #ifdef) with experience= keys, the lowest value of these is chosen.  Note: this will also lower the experience required to advance to other units which the base unit can advance into.&lt;br /&gt;
: If the previous unit type makes use of '''[male]''' and/or '''[female]''' tags, then the current (new) unit type is expected to also. That is, the subtypes defined by those tags will only receive this advancement if the new type has a corresponding tag.&lt;br /&gt;
{{DevFeature1.15|4}} '''[advancefrom]''' was effectively removed in 1.15.4. The intention was to deprecate it, but  the compatibility code that was meant to support it in 1.16 was untested and nonfunctional.&lt;br /&gt;
&lt;br /&gt;
== Deprecating units ==&lt;br /&gt;
&lt;br /&gt;
A macro is provided for deprecating a unit, which uses the built-in deprecation system but hard-codes the level to 3 (meaning &amp;quot;for removal&amp;quot;). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;{DEPRECATED_UNIT old_id new_id version}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also set the new_id to an empty string if there is no replacement.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[TerrainWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73636</id>
		<title>FilterWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73636"/>
		<updated>2024-09-04T19:15:59Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Filtering Weapons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Filtering in WML ==&lt;br /&gt;
&lt;br /&gt;
A ''filter'' is a special WML block.&lt;br /&gt;
Filters are used to describe a set of units, hexes, weapons or something else.&lt;br /&gt;
Filters are defined as matching something if all the keys in the filter match that thing.&lt;br /&gt;
For example, if a unit filter contains two keys,&lt;br /&gt;
a unit must match both of the keys in order to match the filter.&lt;br /&gt;
&lt;br /&gt;
A StandardUnit(Location, Side, ...)Filter is the place where the set of such keys and tags can appear. A StandardFilter sometimes needs an according surrounding tag but often doesn't. It should be mentioned at the place in the wiki where it's said that you can use at a certain code position a StandardFilter whether you need a surrounding tag or not.&lt;br /&gt;
&lt;br /&gt;
== Filtering Units ==&lt;br /&gt;
&lt;br /&gt;
Filters are often used in action tags (see [[EventWML]]).&lt;br /&gt;
In this case the phrase &amp;quot;standard unit filter&amp;quot; is used in place of the set of standard keys.&lt;br /&gt;
Sometimes a filter is used to find the first unit that matches the filter;&lt;br /&gt;
for example, the '''[recall]''' tag recalls that unit.&lt;br /&gt;
&lt;br /&gt;
Standard unit filters are also used in the tags '''[filter]''' and '''[filter_second]'''.&lt;br /&gt;
These are subtags of '''[event]''' which describe when the event should trigger.&lt;br /&gt;
Most event names (see [[EventWML]]) have units related to them called &amp;quot;primary unit&amp;quot; and &amp;quot;secondary unit&amp;quot;.&lt;br /&gt;
In order for an event to be triggered, ''primary unit'' must match the filter contained in '''[filter]''',&lt;br /&gt;
and ''secondary unit'' must match the filter contained in '''[filter_second]'''.&lt;br /&gt;
&lt;br /&gt;
See [[StandardUnitFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Locations ==&lt;br /&gt;
&lt;br /&gt;
As you have seen, standard unit filter can contain a location filter.&lt;br /&gt;
Several actions, such as '''[terrain]''', also use location filters.&lt;br /&gt;
Location filters are represented on this site by the phrase &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
A common use for location filters is to check the terrain of a space.&lt;br /&gt;
&lt;br /&gt;
See [[StandardLocationFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Sides ==&lt;br /&gt;
Sometimes, it's needed to get a list of sides which satisfy certain criteria. For this, a side filter can be used.&lt;br /&gt;
Side filters are represented on this site by the phrase &amp;quot;standard side filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
See [[StandardSideFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Weapons ==&lt;br /&gt;
&lt;br /&gt;
Sometimes weapons/attacks are filtered on in WML.  See also [[EventWML]], [[EffectWML]], [[AnimationWML]].&lt;br /&gt;
&lt;br /&gt;
These keys are used as filter input for attack filters.&lt;br /&gt;
&lt;br /&gt;
* '''range''': a range to filter&lt;br /&gt;
** '''melee''': only melee weapons pass &lt;br /&gt;
** '''ranged''': only ranged weapons pass &lt;br /&gt;
* '''name''': filter on the attack's name. See &amp;lt;code&amp;gt;data/units/&amp;lt;/code&amp;gt; to find the name of a particular unit's attack.&lt;br /&gt;
* '''type''': filter on the attack's type. Values are 'blade', 'pierce', 'impact', 'fire', 'cold', and 'arcane' or customised type. {{DevFeature1.17|23}} [damage_type] can change the type of damage inflicted, and this change can be detected in the filter except when it is applied from a [damage_type] which affects the filtered attack, in this case only the type before any modification by a any [damage_type] will be detectable.&lt;br /&gt;
* '''damage''': filter on damage value. Can be a specific number or a list of ranges like 'damage=0-5,7-99'&lt;br /&gt;
* '''special_id''': {{DevFeature1.15|2}} Filter on a weapon special by id, for example, &amp;lt;code&amp;gt;magical&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active.&lt;br /&gt;
* '''special_type''': {{DevFeature1.15|2}} Filter on a weapon special by tag name for example, &amp;lt;code&amp;gt;chance_to_hit&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active. For values see [[AbilitiesWML]].&lt;br /&gt;
* '''special_id_active''': {{DevFeature1.15|2}} Like '''special_id''', but true if the special is active at the current location. Does not work in 1.16. {{DevFeature1.17|17}} Works again.&lt;br /&gt;
* '''special_type_active''': {{DevFeature1.15|2}} Like '''special_type''', but true if the special is active at the current location.&lt;br /&gt;
* '''special''': filter on the attack's special power, matches both id and tag name. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''special_active''': {{DevFeature1.13|8}} Like '''special''', but true if the special is active at the current location. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''number''': {{DevFeature1.13|5}} filter on number of strikes&lt;br /&gt;
* '''parry''': {{DevFeature1.13|5}} filter on parry value&lt;br /&gt;
* '''accuracy''': {{DevFeature1.13|5}} filter on accuracy value&lt;br /&gt;
* '''movement_used''': {{DevFeature1.13|5}} filter on attack's movement cost&lt;br /&gt;
* '''attacks_used''': {{DevFeature1.17|13}} filter on attack's attack cost&lt;br /&gt;
* '''min_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''max_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''formula''': {{DevFeature1.13|5}} filter using [[Wesnoth Formula Language]]. The context object for the formula is a '''weapon object''', which supports the following keys: '''name''', '''description''', '''type''', '''icon''', '''range''', '''damage''', '''number''', '''attack_weight''', '''defense_weight''', '''accuracy''', '''parry''', '''movement_used''', '''specials'''. The '''specials''' key is a list of all the special IDs the unit possesses. Do not surround the formula in &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable. Keys supported after specific version: {{DevFeature1.17|13}} '''attacks_used'''. {{DevFeature1.19|4}} '''min_range''', '''max_range'''.&lt;br /&gt;
&lt;br /&gt;
'''[and]''', '''[or]''', and '''[not]''' subfilters are also supported.&lt;br /&gt;
&lt;br /&gt;
== Filtering Vision ==&lt;br /&gt;
&lt;br /&gt;
The '''[filter_vision]''' tag allows you to filter units or locations based on whether or not the hex is obscured by fog or shroud from the point-of-view of a viewing side, and (in the case of units) whether or not the unit is hidden (via the {{tag|AbilitiesWML|hides}} ability).&lt;br /&gt;
&lt;br /&gt;
* '''visible''':&lt;br /&gt;
** '''yes''' (default): matches when the location is not obscured by fog or shroud for the ''side'' and, when in a SUF, the unit is not hiding.&lt;br /&gt;
** '''no''': matches when the location is obscured by fog or shroud for the ''side'' or, when in a SUF, the unit is hiding.&lt;br /&gt;
* '''respect_fog''': yes or no, default yes. In a location filter (only), setting this to &amp;quot;no&amp;quot; will cause the test to ignore fog; it becomes a test for shrouded or not shrouded. &lt;br /&gt;
** When multiple viewing sides are listed, all of the sides must pass the visibility check in order for the [filter_vision] filter to return a successful match.&lt;br /&gt;
** When no viewing sides are listed, all enemy sides must pass the visibility check.&lt;br /&gt;
*'''[[StandardSideFilter]]''' tags and keys; all matching sides must be able to see the unit/location. If an empty filter, all sides (instead of only all enemy sides) match. If there is *at least one* matching side which can see the unit / location (accounting for fog / hiding / shroud) then the filter matches, and otherwise it fails to match.&lt;br /&gt;
&lt;br /&gt;
'''Example:''' This event will fire when the enemy (side 2) moves to a location within the player's (side 1's) field of vision:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=yes&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=2&lt;br /&gt;
         [filter_vision]&lt;br /&gt;
             side=1 &lt;br /&gt;
         [/filter_vision]&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=unit&lt;br /&gt;
         message=&amp;quot;I am your enemy. I know that you can see me here.&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In a location filter, this tag is only useful when the viewing side is under a fog or shroud. You ''can'' set a shroud over an AI side. This will allow you to use the vision filter from the point-of-view of an AI side. The fog/shroud does not currently affect AI movement patterns, but the AI algorithm may become constrained by fog/shroud in the future.&lt;br /&gt;
&lt;br /&gt;
== Filtering on WML data ==&lt;br /&gt;
&lt;br /&gt;
Some places allow you to filter directly on WML data. WML filters are more free-form than other filters, allowing arbitrary WML data that is to be matched. Anything between '''&amp;lt;&amp;gt;''' needs to be replaced by the actual data to be filtered for. The following conventions are possible:&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;key&amp;gt;=&amp;lt;value&amp;gt;''': Means that the key '''key''' must be present with the specified '''value'''.&lt;br /&gt;
* '''glob_on_&amp;lt;key&amp;gt;=&amp;lt;glob&amp;gt;''': {{DevFeature1.15|0}} Means that the key '''key''' must be present with a value that matches the specified glob. In a glob, the '''*''' character matches any sequence of characters, while the '''?''' character matches any single character. In addition to the obvious, this is useful for matching the absence of a key - just place '''glob_on_&amp;lt;key&amp;gt;=*''' in a '''[not]''' tag.&lt;br /&gt;
* '''[&amp;lt;some_tag&amp;gt;]''': In a WML filter, all tags contain further WML filter data as children. The presence of a tag in the filter means that the WML must have at least one tag '''some_tag''' present, and at least one of the '''some_tag''' tags must match the WML filter contained in '''[some_tag]'''.&lt;br /&gt;
* '''[not]''': The WML filter contained in '''[not]''' ''must not'' match the WML.&lt;br /&gt;
* '''[and]''': {{DevFeature1.15|0}} In addition to the main filter, the filter contained in '''[and]''' must also match the WML. In most cases this tag is not necessary (the two filters can simply be merged), but in some unusual cases (particularly when globs are involved) it might be needed to get the desired result.&lt;br /&gt;
* '''[or]''': {{DevFeature1.15|0}} Adds another filter that is allowed to match in place of the main filter. Note that when combining several WML filters with '''[or]''' tags, the first filter must not be wrapped in '''[or]''' tags - doing so would mean that the first filter is actually an empty filter, which matches everything, meaning the other '''[or]''' tags are irrelevant.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
* [[FilterWML/Examples_-_How_to_use_Filter|How To Use Filter (with examples)]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML#Animation_Filtering|Animation filtering]]&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[FilterWML/Examples - How to use Filter]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73635</id>
		<title>FilterWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73635"/>
		<updated>2024-09-04T19:13:49Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Filtering Weapons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Filtering in WML ==&lt;br /&gt;
&lt;br /&gt;
A ''filter'' is a special WML block.&lt;br /&gt;
Filters are used to describe a set of units, hexes, weapons or something else.&lt;br /&gt;
Filters are defined as matching something if all the keys in the filter match that thing.&lt;br /&gt;
For example, if a unit filter contains two keys,&lt;br /&gt;
a unit must match both of the keys in order to match the filter.&lt;br /&gt;
&lt;br /&gt;
A StandardUnit(Location, Side, ...)Filter is the place where the set of such keys and tags can appear. A StandardFilter sometimes needs an according surrounding tag but often doesn't. It should be mentioned at the place in the wiki where it's said that you can use at a certain code position a StandardFilter whether you need a surrounding tag or not.&lt;br /&gt;
&lt;br /&gt;
== Filtering Units ==&lt;br /&gt;
&lt;br /&gt;
Filters are often used in action tags (see [[EventWML]]).&lt;br /&gt;
In this case the phrase &amp;quot;standard unit filter&amp;quot; is used in place of the set of standard keys.&lt;br /&gt;
Sometimes a filter is used to find the first unit that matches the filter;&lt;br /&gt;
for example, the '''[recall]''' tag recalls that unit.&lt;br /&gt;
&lt;br /&gt;
Standard unit filters are also used in the tags '''[filter]''' and '''[filter_second]'''.&lt;br /&gt;
These are subtags of '''[event]''' which describe when the event should trigger.&lt;br /&gt;
Most event names (see [[EventWML]]) have units related to them called &amp;quot;primary unit&amp;quot; and &amp;quot;secondary unit&amp;quot;.&lt;br /&gt;
In order for an event to be triggered, ''primary unit'' must match the filter contained in '''[filter]''',&lt;br /&gt;
and ''secondary unit'' must match the filter contained in '''[filter_second]'''.&lt;br /&gt;
&lt;br /&gt;
See [[StandardUnitFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Locations ==&lt;br /&gt;
&lt;br /&gt;
As you have seen, standard unit filter can contain a location filter.&lt;br /&gt;
Several actions, such as '''[terrain]''', also use location filters.&lt;br /&gt;
Location filters are represented on this site by the phrase &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
A common use for location filters is to check the terrain of a space.&lt;br /&gt;
&lt;br /&gt;
See [[StandardLocationFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Sides ==&lt;br /&gt;
Sometimes, it's needed to get a list of sides which satisfy certain criteria. For this, a side filter can be used.&lt;br /&gt;
Side filters are represented on this site by the phrase &amp;quot;standard side filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
See [[StandardSideFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Weapons ==&lt;br /&gt;
&lt;br /&gt;
Sometimes weapons/attacks are filtered on in WML.  See also [[EventWML]], [[EffectWML]], [[AnimationWML]].&lt;br /&gt;
&lt;br /&gt;
These keys are used as filter input for attack filters.&lt;br /&gt;
&lt;br /&gt;
* '''range''': a range to filter&lt;br /&gt;
** '''melee''': only melee weapons pass &lt;br /&gt;
** '''ranged''': only ranged weapons pass &lt;br /&gt;
* '''name''': filter on the attack's name. See &amp;lt;code&amp;gt;data/units/&amp;lt;/code&amp;gt; to find the name of a particular unit's attack.&lt;br /&gt;
* '''type''': filter on the attack's type. Values are 'blade', 'pierce', 'impact', 'fire', 'cold', and 'arcane' or customised type. {{DevFeature1.17|23}} [damage_type] can change the type of damage inflicted, and this change can be detected in the filter except when it is applied from a [damage_type] which affects the filtered attack, in this case only the type before any modification by a any [damage_type] will be detectable.&lt;br /&gt;
* '''damage''': filter on damage value. Can be a specific number or a list of ranges like 'damage=0-5,7-99'&lt;br /&gt;
* '''special_id''': {{DevFeature1.15|2}} Filter on a weapon special by id, for example, &amp;lt;code&amp;gt;magical&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active.&lt;br /&gt;
* '''special_type''': {{DevFeature1.15|2}} Filter on a weapon special by tag name for example, &amp;lt;code&amp;gt;chance_to_hit&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active. For values see [[AbilitiesWML]].&lt;br /&gt;
* '''special_id_active''': {{DevFeature1.15|2}} Like '''special_id''', but true if the special is active at the current location. Does not work in 1.16. {{DevFeature1.17|17}} Works again.&lt;br /&gt;
* '''special_type_active''': {{DevFeature1.15|2}} Like '''special_type''', but true if the special is active at the current location.&lt;br /&gt;
* '''special''': filter on the attack's special power, matches both id and tag name. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''special_active''': {{DevFeature1.13|8}} Like '''special''', but true if the special is active at the current location. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''number''': {{DevFeature1.13|5}} filter on number of strikes&lt;br /&gt;
* '''parry''': {{DevFeature1.13|5}} filter on parry value&lt;br /&gt;
* '''accuracy''': {{DevFeature1.13|5}} filter on accuracy value&lt;br /&gt;
* '''movement_used''': {{DevFeature1.13|5}} filter on attack's movement cost&lt;br /&gt;
* '''attacks_used''': {{DevFeature1.17|13}} filter on attack's attack cost&lt;br /&gt;
* '''min_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''max_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''formula''': {{DevFeature1.13|5}} filter using [[Wesnoth Formula Language]]. The context object for the formula is a '''weapon object''', which supports the following keys: '''name''', '''description''', '''type''', '''icon''', '''range''', '''damage''', '''number''', '''attack_weight''', '''defense_weight''', '''accuracy''', '''parry''', '''movement_used''', '''min_range''', '''max_range''', '''specials'''. The '''specials''' key is a list of all the special IDs the unit possesses. Do not surround the formula in &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable. {{DevFeature1.17|13}} The '''attacks_used''' key is also supported.&lt;br /&gt;
&lt;br /&gt;
'''[and]''', '''[or]''', and '''[not]''' subfilters are also supported.&lt;br /&gt;
&lt;br /&gt;
== Filtering Vision ==&lt;br /&gt;
&lt;br /&gt;
The '''[filter_vision]''' tag allows you to filter units or locations based on whether or not the hex is obscured by fog or shroud from the point-of-view of a viewing side, and (in the case of units) whether or not the unit is hidden (via the {{tag|AbilitiesWML|hides}} ability).&lt;br /&gt;
&lt;br /&gt;
* '''visible''':&lt;br /&gt;
** '''yes''' (default): matches when the location is not obscured by fog or shroud for the ''side'' and, when in a SUF, the unit is not hiding.&lt;br /&gt;
** '''no''': matches when the location is obscured by fog or shroud for the ''side'' or, when in a SUF, the unit is hiding.&lt;br /&gt;
* '''respect_fog''': yes or no, default yes. In a location filter (only), setting this to &amp;quot;no&amp;quot; will cause the test to ignore fog; it becomes a test for shrouded or not shrouded. &lt;br /&gt;
** When multiple viewing sides are listed, all of the sides must pass the visibility check in order for the [filter_vision] filter to return a successful match.&lt;br /&gt;
** When no viewing sides are listed, all enemy sides must pass the visibility check.&lt;br /&gt;
*'''[[StandardSideFilter]]''' tags and keys; all matching sides must be able to see the unit/location. If an empty filter, all sides (instead of only all enemy sides) match. If there is *at least one* matching side which can see the unit / location (accounting for fog / hiding / shroud) then the filter matches, and otherwise it fails to match.&lt;br /&gt;
&lt;br /&gt;
'''Example:''' This event will fire when the enemy (side 2) moves to a location within the player's (side 1's) field of vision:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=yes&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=2&lt;br /&gt;
         [filter_vision]&lt;br /&gt;
             side=1 &lt;br /&gt;
         [/filter_vision]&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=unit&lt;br /&gt;
         message=&amp;quot;I am your enemy. I know that you can see me here.&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In a location filter, this tag is only useful when the viewing side is under a fog or shroud. You ''can'' set a shroud over an AI side. This will allow you to use the vision filter from the point-of-view of an AI side. The fog/shroud does not currently affect AI movement patterns, but the AI algorithm may become constrained by fog/shroud in the future.&lt;br /&gt;
&lt;br /&gt;
== Filtering on WML data ==&lt;br /&gt;
&lt;br /&gt;
Some places allow you to filter directly on WML data. WML filters are more free-form than other filters, allowing arbitrary WML data that is to be matched. Anything between '''&amp;lt;&amp;gt;''' needs to be replaced by the actual data to be filtered for. The following conventions are possible:&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;key&amp;gt;=&amp;lt;value&amp;gt;''': Means that the key '''key''' must be present with the specified '''value'''.&lt;br /&gt;
* '''glob_on_&amp;lt;key&amp;gt;=&amp;lt;glob&amp;gt;''': {{DevFeature1.15|0}} Means that the key '''key''' must be present with a value that matches the specified glob. In a glob, the '''*''' character matches any sequence of characters, while the '''?''' character matches any single character. In addition to the obvious, this is useful for matching the absence of a key - just place '''glob_on_&amp;lt;key&amp;gt;=*''' in a '''[not]''' tag.&lt;br /&gt;
* '''[&amp;lt;some_tag&amp;gt;]''': In a WML filter, all tags contain further WML filter data as children. The presence of a tag in the filter means that the WML must have at least one tag '''some_tag''' present, and at least one of the '''some_tag''' tags must match the WML filter contained in '''[some_tag]'''.&lt;br /&gt;
* '''[not]''': The WML filter contained in '''[not]''' ''must not'' match the WML.&lt;br /&gt;
* '''[and]''': {{DevFeature1.15|0}} In addition to the main filter, the filter contained in '''[and]''' must also match the WML. In most cases this tag is not necessary (the two filters can simply be merged), but in some unusual cases (particularly when globs are involved) it might be needed to get the desired result.&lt;br /&gt;
* '''[or]''': {{DevFeature1.15|0}} Adds another filter that is allowed to match in place of the main filter. Note that when combining several WML filters with '''[or]''' tags, the first filter must not be wrapped in '''[or]''' tags - doing so would mean that the first filter is actually an empty filter, which matches everything, meaning the other '''[or]''' tags are irrelevant.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
* [[FilterWML/Examples_-_How_to_use_Filter|How To Use Filter (with examples)]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML#Animation_Filtering|Animation filtering]]&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[FilterWML/Examples - How to use Filter]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73634</id>
		<title>FilterWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=FilterWML&amp;diff=73634"/>
		<updated>2024-09-04T19:13:21Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Filtering Weapons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Filtering in WML ==&lt;br /&gt;
&lt;br /&gt;
A ''filter'' is a special WML block.&lt;br /&gt;
Filters are used to describe a set of units, hexes, weapons or something else.&lt;br /&gt;
Filters are defined as matching something if all the keys in the filter match that thing.&lt;br /&gt;
For example, if a unit filter contains two keys,&lt;br /&gt;
a unit must match both of the keys in order to match the filter.&lt;br /&gt;
&lt;br /&gt;
A StandardUnit(Location, Side, ...)Filter is the place where the set of such keys and tags can appear. A StandardFilter sometimes needs an according surrounding tag but often doesn't. It should be mentioned at the place in the wiki where it's said that you can use at a certain code position a StandardFilter whether you need a surrounding tag or not.&lt;br /&gt;
&lt;br /&gt;
== Filtering Units ==&lt;br /&gt;
&lt;br /&gt;
Filters are often used in action tags (see [[EventWML]]).&lt;br /&gt;
In this case the phrase &amp;quot;standard unit filter&amp;quot; is used in place of the set of standard keys.&lt;br /&gt;
Sometimes a filter is used to find the first unit that matches the filter;&lt;br /&gt;
for example, the '''[recall]''' tag recalls that unit.&lt;br /&gt;
&lt;br /&gt;
Standard unit filters are also used in the tags '''[filter]''' and '''[filter_second]'''.&lt;br /&gt;
These are subtags of '''[event]''' which describe when the event should trigger.&lt;br /&gt;
Most event names (see [[EventWML]]) have units related to them called &amp;quot;primary unit&amp;quot; and &amp;quot;secondary unit&amp;quot;.&lt;br /&gt;
In order for an event to be triggered, ''primary unit'' must match the filter contained in '''[filter]''',&lt;br /&gt;
and ''secondary unit'' must match the filter contained in '''[filter_second]'''.&lt;br /&gt;
&lt;br /&gt;
See [[StandardUnitFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Locations ==&lt;br /&gt;
&lt;br /&gt;
As you have seen, standard unit filter can contain a location filter.&lt;br /&gt;
Several actions, such as '''[terrain]''', also use location filters.&lt;br /&gt;
Location filters are represented on this site by the phrase &amp;quot;standard location filter&amp;quot;.&lt;br /&gt;
A common use for location filters is to check the terrain of a space.&lt;br /&gt;
&lt;br /&gt;
See [[StandardLocationFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Sides ==&lt;br /&gt;
Sometimes, it's needed to get a list of sides which satisfy certain criteria. For this, a side filter can be used.&lt;br /&gt;
Side filters are represented on this site by the phrase &amp;quot;standard side filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
See [[StandardSideFilter]] for details.&lt;br /&gt;
&lt;br /&gt;
== Filtering Weapons ==&lt;br /&gt;
&lt;br /&gt;
Sometimes weapons/attacks are filtered on in WML.  See also [[EventWML]], [[EffectWML]], [[AnimationWML]].&lt;br /&gt;
&lt;br /&gt;
These keys are used as filter input for attack filters.&lt;br /&gt;
&lt;br /&gt;
* '''range''': a range to filter&lt;br /&gt;
** '''melee''': only melee weapons pass &lt;br /&gt;
** '''ranged''': only ranged weapons pass &lt;br /&gt;
* '''name''': filter on the attack's name. See &amp;lt;code&amp;gt;data/units/&amp;lt;/code&amp;gt; to find the name of a particular unit's attack.&lt;br /&gt;
* '''type''': filter on the attack's type. Values are 'blade', 'pierce', 'impact', 'fire', 'cold', and 'arcane' or customised type. {{DevFeature1.17|23}} [damage_type] can change the type of damage inflicted, and this change can be detected in the filter except when it is applied from a [damage_type] which affects the filtered attack, in this case only the type before any modification by a any [damage_type] will be detectable.&lt;br /&gt;
* '''damage''': filter on damage value. Can be a specific number or a list of ranges like 'damage=0-5,7-99'&lt;br /&gt;
* '''special_id''': {{DevFeature1.15|2}} Filter on a weapon special by id, for example, &amp;lt;code&amp;gt;magical&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active.&lt;br /&gt;
* '''special_type''': {{DevFeature1.15|2}} Filter on a weapon special by tag name for example, &amp;lt;code&amp;gt;chance_to_hit&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;[chance_to_hit] id=magical&amp;lt;/code&amp;gt;. True if the unit has the special, whether or not it's currently active. For values see [[AbilitiesWML]].&lt;br /&gt;
* '''special_id_active''': {{DevFeature1.15|2}} Like '''special_id''', but true if the special is active at the current location. Does not work in 1.16. {{DevFeature1.17|17}} Works again.&lt;br /&gt;
* '''special_type_active''': {{DevFeature1.15|2}} Like '''special_type''', but true if the special is active at the current location.&lt;br /&gt;
* '''special''': filter on the attack's special power, matches both id and tag name. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''special_active''': {{DevFeature1.13|8}} Like '''special''', but true if the special is active at the current location. {{DevFeature1.15|2}} Deprecated, see '''special_id''' and '''special_type''' instead.&lt;br /&gt;
* '''number''': {{DevFeature1.13|5}} filter on number of strikes&lt;br /&gt;
* '''parry''': {{DevFeature1.13|5}} filter on parry value&lt;br /&gt;
* '''accuracy''': {{DevFeature1.13|5}} filter on accuracy value&lt;br /&gt;
* '''movement_used''': {{DevFeature1.13|5}} filter on attack's movement cost&lt;br /&gt;
* '''attacks_used''': {{DevFeature1.17|13}} filter on attack's attack cost&lt;br /&gt;
* '''min_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''max_range''': {{DevFeature1.19|4}} filter on attack's range (distance)&lt;br /&gt;
* '''formula''': {{DevFeature1.13|5}} filter using [[Wesnoth Formula Language]]. The context object for the formula is a '''weapon object''', which supports the following keys: '''name''', '''description''', '''type''', '''icon''', '''range''', '''damage''', '''number''', '''attack_weight''', '''defense_weight''', '''accuracy''', '''parry''', '''movement_used''', '''specials'''. The '''specials''' key is a list of all the special IDs the unit possesses. Do not surround the formula in &amp;lt;code&amp;gt;$(...)&amp;lt;/code&amp;gt;, since that will erase the &amp;lt;tt&amp;gt;self&amp;lt;/tt&amp;gt; variable. {{DevFeature1.17|13}} The '''attacks_used''' key is also supported.&lt;br /&gt;
&lt;br /&gt;
'''[and]''', '''[or]''', and '''[not]''' subfilters are also supported.&lt;br /&gt;
&lt;br /&gt;
== Filtering Vision ==&lt;br /&gt;
&lt;br /&gt;
The '''[filter_vision]''' tag allows you to filter units or locations based on whether or not the hex is obscured by fog or shroud from the point-of-view of a viewing side, and (in the case of units) whether or not the unit is hidden (via the {{tag|AbilitiesWML|hides}} ability).&lt;br /&gt;
&lt;br /&gt;
* '''visible''':&lt;br /&gt;
** '''yes''' (default): matches when the location is not obscured by fog or shroud for the ''side'' and, when in a SUF, the unit is not hiding.&lt;br /&gt;
** '''no''': matches when the location is obscured by fog or shroud for the ''side'' or, when in a SUF, the unit is hiding.&lt;br /&gt;
* '''respect_fog''': yes or no, default yes. In a location filter (only), setting this to &amp;quot;no&amp;quot; will cause the test to ignore fog; it becomes a test for shrouded or not shrouded. &lt;br /&gt;
** When multiple viewing sides are listed, all of the sides must pass the visibility check in order for the [filter_vision] filter to return a successful match.&lt;br /&gt;
** When no viewing sides are listed, all enemy sides must pass the visibility check.&lt;br /&gt;
*'''[[StandardSideFilter]]''' tags and keys; all matching sides must be able to see the unit/location. If an empty filter, all sides (instead of only all enemy sides) match. If there is *at least one* matching side which can see the unit / location (accounting for fog / hiding / shroud) then the filter matches, and otherwise it fails to match.&lt;br /&gt;
&lt;br /&gt;
'''Example:''' This event will fire when the enemy (side 2) moves to a location within the player's (side 1's) field of vision:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=yes&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=2&lt;br /&gt;
         [filter_vision]&lt;br /&gt;
             side=1 &lt;br /&gt;
         [/filter_vision]&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=unit&lt;br /&gt;
         message=&amp;quot;I am your enemy. I know that you can see me here.&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In a location filter, this tag is only useful when the viewing side is under a fog or shroud. You ''can'' set a shroud over an AI side. This will allow you to use the vision filter from the point-of-view of an AI side. The fog/shroud does not currently affect AI movement patterns, but the AI algorithm may become constrained by fog/shroud in the future.&lt;br /&gt;
&lt;br /&gt;
== Filtering on WML data ==&lt;br /&gt;
&lt;br /&gt;
Some places allow you to filter directly on WML data. WML filters are more free-form than other filters, allowing arbitrary WML data that is to be matched. Anything between '''&amp;lt;&amp;gt;''' needs to be replaced by the actual data to be filtered for. The following conventions are possible:&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;key&amp;gt;=&amp;lt;value&amp;gt;''': Means that the key '''key''' must be present with the specified '''value'''.&lt;br /&gt;
* '''glob_on_&amp;lt;key&amp;gt;=&amp;lt;glob&amp;gt;''': {{DevFeature1.15|0}} Means that the key '''key''' must be present with a value that matches the specified glob. In a glob, the '''*''' character matches any sequence of characters, while the '''?''' character matches any single character. In addition to the obvious, this is useful for matching the absence of a key - just place '''glob_on_&amp;lt;key&amp;gt;=*''' in a '''[not]''' tag.&lt;br /&gt;
* '''[&amp;lt;some_tag&amp;gt;]''': In a WML filter, all tags contain further WML filter data as children. The presence of a tag in the filter means that the WML must have at least one tag '''some_tag''' present, and at least one of the '''some_tag''' tags must match the WML filter contained in '''[some_tag]'''.&lt;br /&gt;
* '''[not]''': The WML filter contained in '''[not]''' ''must not'' match the WML.&lt;br /&gt;
* '''[and]''': {{DevFeature1.15|0}} In addition to the main filter, the filter contained in '''[and]''' must also match the WML. In most cases this tag is not necessary (the two filters can simply be merged), but in some unusual cases (particularly when globs are involved) it might be needed to get the desired result.&lt;br /&gt;
* '''[or]''': {{DevFeature1.15|0}} Adds another filter that is allowed to match in place of the main filter. Note that when combining several WML filters with '''[or]''' tags, the first filter must not be wrapped in '''[or]''' tags - doing so would mean that the first filter is actually an empty filter, which matches everything, meaning the other '''[or]''' tags are irrelevant.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
* [[FilterWML/Examples_-_How_to_use_Filter|How To Use Filter (with examples)]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML#Animation_Filtering|Animation filtering]]&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[EventWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[FilterWML/Examples - How to use Filter]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types&amp;diff=73633</id>
		<title>LuaAPI/types</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types&amp;diff=73633"/>
		<updated>2024-09-04T19:11:31Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Race ==&lt;br /&gt;
&lt;br /&gt;
This represents a possible unit race. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''description''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The description of the race, for showing to players.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
* ''race''.'''plural_name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The name of the race, for showing to players.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''num_traits''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The number of random traits given to units of this race.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''ignore_global_traits''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether this race can receive the global traits.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''undead_variation''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The variation to transform this race to if killed by a plague attack.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''traits''' &amp;amp;rarr; ''trait list''&lt;br /&gt;
&lt;br /&gt;
The traits available to this race. Includes global traits if available. You can access specific traits by their ID, and the full trait definition is included.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''male_name_gen''' &amp;amp;rarr; ''name generator''&lt;br /&gt;
* ''race''.'''female_name_gen''' &amp;amp;rarr; ''name generator''&lt;br /&gt;
&lt;br /&gt;
The name generators for this race. These are callable userdatas that return a random name each time.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
The entire race definition as raw WML.&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
This represents a ''type'' of unit in the game, rather than a specific instance of a unit. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The name of the unit type, for displaying to the player.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''id''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The unit's ID.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''race''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The ID of the unit's race. To get the actual race object, use this to look it up in '''wesnoth.races'''.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''alignment''' &amp;amp;rarr; ''alignment''&lt;br /&gt;
&lt;br /&gt;
The unit's alignment.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''image''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''icon''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''profile''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''small_profile''' &amp;amp;rarr; ''image string''&lt;br /&gt;
&lt;br /&gt;
Various images used to represent the unit.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''max_hitpoints''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''max_moves''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''max_experience''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''cost''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''level''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''recall_cost''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
Various stats of the unit type.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''advances_to''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of unit type IDs that this unit can advance to.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''advances_from''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of unit type IDs that can advance to this unit.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''traits''' &amp;amp;rarr; ''table''&lt;br /&gt;
&lt;br /&gt;
A table of the traits that this unit type can get. The key is the trait ID and the value is the trait's full definition as a config.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''abilities''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of abilities that this unit type possesses. This is only the abilities' IDs, not their full definition.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''attacks''' &amp;amp;rarr; ''attack list''&lt;br /&gt;
&lt;br /&gt;
A list of weapons that this unit type possesses. This list can be indexed as an array, but you can also look up an attack by its ID (name field). Each attack is a [[#weapon|weapon]] userdata.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''variations''' &amp;amp;rarr; ''variation list''&lt;br /&gt;
&lt;br /&gt;
Returns a list of unit type userdata representing possible variations of this unit, including gender variations. You can look up specific variations by their ID. Male and female variations have the ID '''male''' or '''female'''.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
Returns the full unit type definition as raw WML. This can be used if you need something that's not directly supported.&lt;br /&gt;
&lt;br /&gt;
== Weapon ==&lt;br /&gt;
&lt;br /&gt;
This represents a single attack on a unit or unit type; it can also exist as an orphaned attack not attached to either a unit or unit type. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''read_only''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Indicates whether you can write to the attributes of this attack. It will be true when getting an attack from a unit type userdata.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''description''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The attack's name, for displaying to the player.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''name''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The attack's ID.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The attack's damage type.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''icon''' &amp;amp;rarr; ''image string''&lt;br /&gt;
&lt;br /&gt;
The attack's icon.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''damage''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''range''' &amp;amp;rarr; ''string''&lt;br /&gt;
* ''weapon''.'''number''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''movement_used''' &amp;amp;rarr; ''number''&lt;br /&gt;
* {{DevFeature1.17|13}} ''weapon''.'''attacks_used''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
Basic stats of the attack.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''attack_weight''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''defense_weight''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The attack's weighting values.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''accuracy''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''parry''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The defense modifications of the attack.&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.19|4}} ''weapon''.'''min_range''' &amp;amp;rarr; ''number''&lt;br /&gt;
* {{DevFeature1.19|4}} ''weapon''.'''max_range''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The attack's distance requirement between attacker and defender.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''specials''' &amp;amp;rarr; ''list of configs''&lt;br /&gt;
&lt;br /&gt;
The special abilities of this attack.&lt;br /&gt;
&lt;br /&gt;
* ''weapon'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if this attack matches the given [[StandardWeaponFilter]].&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
The entire attack as raw WML&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[LuaAPI/wesnoth#wesnoth.textdomain|translatable strings]] - a string that will be translated by the engine.&lt;br /&gt;
* [[LuaAPI/wml#wml.tovconfig|vconfig]] - a WML object that automatically substitutes variables on the fly.&lt;br /&gt;
* [[LuaAPI/types/unit|unit]] - represents a reference to Wesnoth unit on the map, on the recall list, or private to Lua.&lt;br /&gt;
* [[LuaAPI/types/side|side]] - represents a single side (player) in the game.&lt;br /&gt;
* [[LuaAPI/types/widget|widget]] - represents a GUI2 widget.&lt;br /&gt;
* [[LuaAPI/types/map|map]] - represents the game map.&lt;br /&gt;
* [[LuaAPI/types/hex|hex]] - represents a single hex on the map.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types&amp;diff=73632</id>
		<title>LuaAPI/types</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types&amp;diff=73632"/>
		<updated>2024-09-04T19:09:16Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Weapon */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Race ==&lt;br /&gt;
&lt;br /&gt;
This represents a possible unit race. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''description''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The description of the race, for showing to players.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
* ''race''.'''plural_name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The name of the race, for showing to players.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''num_traits''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The number of random traits given to units of this race.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''ignore_global_traits''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Whether this race can receive the global traits.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''undead_variation''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The variation to transform this race to if killed by a plague attack.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''traits''' &amp;amp;rarr; ''trait list''&lt;br /&gt;
&lt;br /&gt;
The traits available to this race. Includes global traits if available. You can access specific traits by their ID, and the full trait definition is included.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''male_name_gen''' &amp;amp;rarr; ''name generator''&lt;br /&gt;
* ''race''.'''female_name_gen''' &amp;amp;rarr; ''name generator''&lt;br /&gt;
&lt;br /&gt;
The name generators for this race. These are callable userdatas that return a random name each time.&lt;br /&gt;
&lt;br /&gt;
* ''race''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
The entire race definition as raw WML.&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
This represents a ''type'' of unit in the game, rather than a specific instance of a unit. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''name''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The name of the unit type, for displaying to the player.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''id''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The unit's ID.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''race''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The ID of the unit's race. To get the actual race object, use this to look it up in '''wesnoth.races'''.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''alignment''' &amp;amp;rarr; ''alignment''&lt;br /&gt;
&lt;br /&gt;
The unit's alignment.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''image''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''icon''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''profile''' &amp;amp;rarr; ''image string''&lt;br /&gt;
* ''unit_type''.'''small_profile''' &amp;amp;rarr; ''image string''&lt;br /&gt;
&lt;br /&gt;
Various images used to represent the unit.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''max_hitpoints''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''max_moves''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''max_experience''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''cost''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''level''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''unit_type''.'''recall_cost''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
Various stats of the unit type.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''advances_to''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of unit type IDs that this unit can advance to.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''advances_from''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of unit type IDs that can advance to this unit.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''traits''' &amp;amp;rarr; ''table''&lt;br /&gt;
&lt;br /&gt;
A table of the traits that this unit type can get. The key is the trait ID and the value is the trait's full definition as a config.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''abilities''' &amp;amp;rarr; ''list of strings''&lt;br /&gt;
&lt;br /&gt;
A list of abilities that this unit type possesses. This is only the abilities' IDs, not their full definition.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''attacks''' &amp;amp;rarr; ''attack list''&lt;br /&gt;
&lt;br /&gt;
A list of weapons that this unit type possesses. This list can be indexed as an array, but you can also look up an attack by its ID (name field). Each attack is a [[#weapon|weapon]] userdata.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''variations''' &amp;amp;rarr; ''variation list''&lt;br /&gt;
&lt;br /&gt;
Returns a list of unit type userdata representing possible variations of this unit, including gender variations. You can look up specific variations by their ID. Male and female variations have the ID '''male''' or '''female'''.&lt;br /&gt;
&lt;br /&gt;
* ''unit_type''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
Returns the full unit type definition as raw WML. This can be used if you need something that's not directly supported.&lt;br /&gt;
&lt;br /&gt;
== Weapon ==&lt;br /&gt;
&lt;br /&gt;
This represents a single attack on a unit or unit type; it can also exist as an orphaned attack not attached to either a unit or unit type. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''read_only''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Indicates whether you can write to the attributes of this attack. It will be true when getting an attack from a unit type userdata.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''description''' &amp;amp;rarr; ''translatable string''&lt;br /&gt;
&lt;br /&gt;
The attack's name, for displaying to the player.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''name''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The attack's ID.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
&lt;br /&gt;
The attack's damage type.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''icon''' &amp;amp;rarr; ''image string''&lt;br /&gt;
&lt;br /&gt;
The attack's icon.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''damage''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''range''' &amp;amp;rarr; ''string''&lt;br /&gt;
* ''weapon''.'''number''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''movement_used''' &amp;amp;rarr; ''number''&lt;br /&gt;
* {{DevFeature1.17|13}} ''weapon''.'''attacks_used''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
Basic stats of the attack.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''attack_weight''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''defense_weight''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The attack's weighting values.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''accuracy''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''parry''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The defense modifications of the attack.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''min_range''' &amp;amp;rarr; ''number''&lt;br /&gt;
* ''weapon''.'''max_range''' &amp;amp;rarr; ''number''&lt;br /&gt;
&lt;br /&gt;
The attack's distance requirement between attacker and defender.&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''specials''' &amp;amp;rarr; ''list of configs''&lt;br /&gt;
&lt;br /&gt;
The special abilities of this attack.&lt;br /&gt;
&lt;br /&gt;
* ''weapon'':'''matches'''(''filter'') &amp;amp;rarr; ''boolean''&lt;br /&gt;
&lt;br /&gt;
Tests if this attack matches the given [[StandardWeaponFilter]].&lt;br /&gt;
&lt;br /&gt;
* ''weapon''.'''__cfg''' &amp;amp;rarr; ''config''&lt;br /&gt;
&lt;br /&gt;
The entire attack as raw WML&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[LuaAPI/wesnoth#wesnoth.textdomain|translatable strings]] - a string that will be translated by the engine.&lt;br /&gt;
* [[LuaAPI/wml#wml.tovconfig|vconfig]] - a WML object that automatically substitutes variables on the fly.&lt;br /&gt;
* [[LuaAPI/types/unit|unit]] - represents a reference to Wesnoth unit on the map, on the recall list, or private to Lua.&lt;br /&gt;
* [[LuaAPI/types/side|side]] - represents a single side (player) in the game.&lt;br /&gt;
* [[LuaAPI/types/widget|widget]] - represents a GUI2 widget.&lt;br /&gt;
* [[LuaAPI/types/map|map]] - represents the game map.&lt;br /&gt;
* [[LuaAPI/types/hex|hex]] - represents a single hex on the map.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EffectWML&amp;diff=73631</id>
		<title>EffectWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EffectWML&amp;diff=73631"/>
		<updated>2024-09-04T19:06:47Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [effect] */ min_range, max_range&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
== [effect] ==&lt;br /&gt;
&lt;br /&gt;
The tag [effect] is used to describe one modification to a unit. Any number of [effect] tags can be used to describe a complete modification.&lt;br /&gt;
&lt;br /&gt;
Modifications are permanent changes to a unit; however using an [[DirectActionsWML#.5Bobject.5D|[object]]] with a limited ''duration'' to apply an [effect] will cause the unit to be rebuilt without the effect's effects when the duration expires. &lt;br /&gt;
&lt;br /&gt;
The following keys and subtags are always recognized:&lt;br /&gt;
* '''[filter]''': only apply this effect if the affected unit matches. See [[StandardUnitFilter]] for details.&lt;br /&gt;
* '''times''': describes how many times the effect is applied. The default is to apply the effect once. Other possible value : &amp;quot;per level&amp;quot; which means that the effect is applied level times, where level is the unit level. {{DevFeature1.13|5}} Integers are now supported for ''times''.&lt;br /&gt;
* '''apply_to''': describes what the effect actually affects. New effect types can be added with [[LuaAPI/wesnoth#wesnoth.effects]]. Some examples can be seen in [https://github.com/wesnoth/wesnoth/blob/master/data/campaigns/World_Conquest/lua/game_mechanics/effects.lua World Conquest].&lt;br /&gt;
&lt;br /&gt;
[effect] uses different keys depending on the value of '''apply_to'''.  '''apply_to''' can take the following values:&lt;br /&gt;
* {{anchor|apply_to-new_attack|'''new_attack'''}}: will use all other keys and tags as the description of an attack that will be added to the unit. See [attack] in [[UnitTypeWML#Attacks|UnitTypeWML]].&lt;br /&gt;
* {{anchor|apply_to-remove_attacks|'''remove_attacks'''}}: remove the matching attacks. All tags from the attack filter construct will be used to match the attack; see [[FilterWML#Filtering Weapons|FilterWML]]. Do not use a [filter] tag otherwise it will not work properly.&lt;br /&gt;
* {{anchor|apply_to-attack|'''attack'''}}: find an attack and modify it.  All tags from the attack filter construct will be used to match the attack; see [[FilterWML#Filtering Weapons|FilterWML]].  After that, the following keys and tags can be used to modify the attack.  Note: do not use a [filter] tag.  Just put the keys you want to filter on inside the [effect] tag.&lt;br /&gt;
** '''set_name''': change the attack's name (ie identifier).&lt;br /&gt;
** '''set_description''': change the attack's description (ie displayed name). &lt;br /&gt;
** '''set_type''': change the attack type. The standard values are '''blade''', '''pierce''', '''impact''', '''fire''', '''cold''', and '''arcane'''.&lt;br /&gt;
** '''set_range''': change the attack range. The standard values are '''ranged''' and '''melee'''.&lt;br /&gt;
** '''set_icon''': change the attack's icon.&lt;br /&gt;
** {{anchor|set_specials|'''[set_specials]'''}}: change the attack's specials. The specials to add are given exactly as in the [[AbilitiesWML#The_.5Bspecials.5D_tag|[specials]]] tag.&lt;br /&gt;
*** '''mode''': if '''append''', adds the given specials to the attack. If '''replace''', replaces the existing specials with the given ones. Default '''replace'''.&lt;br /&gt;
**** {{DevFeature1.15|3}} A deprecation warning is triggered unless the '''mode''' attribute is set, although the effect will still be '''replace'''. This is to allow the default to change in the 1.17.x series.&lt;br /&gt;
** '''remove_specials''': remove the listed specials. The value of this key is the comma-separated list of the id of the specials to remove. This key is always evaluated before a [set_specials] tags in the same [effect]&lt;br /&gt;
** '''increase_damage''': increases the attack's damage.  This can be positive or negative, so you can use it to decrease damage as well.  If it ends in a percent(''''%''''), the change in damage will be a percentage ratio of the attack's original damage.&lt;br /&gt;
** '''increase_attacks''': increases the number of attack strikes. Like '''increase_damage''', it can be positive or negative, or a percentage.&lt;br /&gt;
** '''increase_accuracy''': increases the attack accuracy; can be positive or negative, or a percentage&lt;br /&gt;
** '''increase_parry''': increases the attack parry bonus; can be positive or negative, or a percentage&lt;br /&gt;
** '''increase_movement_used''': {{DevFeature1.13|2}} increases the movement points used by the attack; can be positive or negative, or a percentage&lt;br /&gt;
** '''increase_attacks_used''': {{DevFeature1.17|13}} increases the attack points used by the attack; can be positive or negative, or a percentage&lt;br /&gt;
** '''set_damage''' {{DevFeature1.13|2}} like increase_damage, but sets the damage to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''set_attacks''' {{DevFeature1.13|2}} like increase_attacks, but sets the attacks to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''set_accuracy''' {{DevFeature1.13|2}} like increase_accuracy, but sets the accuracy to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''set_parry''' {{DevFeature1.13|2}} like increase_parry, but sets the parry to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''set_movement_used''' {{DevFeature1.13|2}} like increase_movement_used, but sets the movement used to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''set_attacks_used''' {{DevFeature1.17|13}} like increase_attacks_used, but sets the attacks used to a specific value instead of setting it relative to its original value&lt;br /&gt;
** '''attack_weight''': change the attack's attack_weight. See [attack] in [[UnitTypeWML#Attacks|UnitTypeWML]] for explanations about attack_weight.&lt;br /&gt;
** '''defense_weight''': change the attack's defense_weight. See [attack] in [[UnitTypeWML#Attacks|UnitTypeWML]] for explanations about defense_weight.&lt;br /&gt;
** '''set_min_range''' {{DevFeature1.19|4}} modify required distance between units in order to allow using attack&lt;br /&gt;
** '''set_max_range''' {{DevFeature1.19|4}} modify required distance between units in order to allow using attack&lt;br /&gt;
** '''increase_min_range''' {{DevFeature1.19|4}} modify required distance between units in order to allow using attack&lt;br /&gt;
** '''increase_max_range''' {{DevFeature1.19|4}} modify required distance between units in order to allow using attack&lt;br /&gt;
* {{anchor|apply_to-max_attacks|'''max_attacks'''}}: {{DevFeature1.13|2}} change the unit's maximum attacks per turn&lt;br /&gt;
** '''increase''': how much to increase by; can be positive or negative, or a percentage&lt;br /&gt;
* {{anchor|apply_to-hitpoints|'''hitpoints'''}}: modifies the unit's HP and/or max HP.&lt;br /&gt;
** '''increase''': the amount to increase the unit's HP.&lt;br /&gt;
** '''heal_full''': if present  and not set to &amp;quot;no&amp;quot; the unit will be put back to full HP.&lt;br /&gt;
** '''increase_total''': will increase the total HP of the unit.  Can be specified either as a negative or a positive value.  It can also be specified as a percentage of the current total; i.e. &amp;quot;-50%&amp;quot; will cut max HP in half.&lt;br /&gt;
** '''violate_maximum''': it the unit ends up with more than its max HP after these modifications, and this key is present (set to any non-null value, ex. '''yes'''), the unit's HP won't be lowered to its max HP.&lt;br /&gt;
* {{anchor|apply_to-movement|'''movement'''}}: modifies the unit's movement points.&lt;br /&gt;
** '''increase''': maximum movement is increased by this amount. It can be positive, negative, or specified as a percentage.&lt;br /&gt;
** '''set''': maximum movement is set to a specific value.&lt;br /&gt;
** '''apply_to_vision''': {{DevFeature1.15|13}} if set to '''yes''' (which is the default), then the vision points will change by the same amount. See [[#Movement_and_Vision|Movement and Vision]].&lt;br /&gt;
* {{anchor|apply_to-vision|'''vision'''}}: {{DevFeature1.13|2}} modifies the unit's vision points. Note: this has side effects described in [[#Movement_and_Vision|Movement and Vision]].&lt;br /&gt;
** '''increase''': maximum vision is increased by this amount. It can be positive, negative, or specified as a percentage.&lt;br /&gt;
** '''set''': maximum vision is set to a specific value. &lt;br /&gt;
* {{anchor|apply_to-jamming|'''jamming'''}}: {{DevFeature1.13|2}} modifies the unit's jamming points.&lt;br /&gt;
** '''increase''': maximum jamming is increased by this amount. It can be positive, negative, or specified as a percentage.&lt;br /&gt;
** '''set''': maximum jamming is set to a specific value.&lt;br /&gt;
* {{anchor|apply_to-experience|'''experience'''}}: affects the unit's current XP.&lt;br /&gt;
** '''increase''': current XP is increased by this amount. It can be positive, negative, or specified as a percentage.&lt;br /&gt;
** '''set''': current XP is set to a specific value.&lt;br /&gt;
* {{anchor|apply_to-max_experience|'''max_experience'''}}: affects the amount of XP the unit needs for the next level.&lt;br /&gt;
** '''increase''': how to change the xp; again it can be negative, positive or a percentage.&lt;br /&gt;
** '''set''': current max XP is set to a specific value.&lt;br /&gt;
* {{anchor|apply_to-loyal|'''loyal'''}}: no keys associated. The affected unit will be loyal i.e have an upkeep of 0.&lt;br /&gt;
* {{anchor|apply_to-fearless|'''fearless'''}}: Add/Remove fearless attribute.&lt;br /&gt;
** '''set''': new value for fearless (boolean). Defaults to '''yes'''.&lt;br /&gt;
* {{anchor|apply_to-healthy|'''healthy'''}}: Add/Remove healthy attribute.&lt;br /&gt;
** '''set''': new value for healthy (boolean). Defaults to '''yes'''.&lt;br /&gt;
* {{anchor|apply_to_movement_costs|'''movement_costs'''}}: speed through specific terrain is modified&lt;br /&gt;
** '''replace''': If set to &amp;quot;yes&amp;quot;, any new values replace the old ones. Otherwise, new values are added to old values (negative values allowed). Defaults to '''no'''.&lt;br /&gt;
** '''[movement_costs]''': a subtag that describes the new movement costs just like under [[UnitsWML#.5Bmovetype.5D|[movetype]]] if replace is set to &amp;quot;yes&amp;quot; or the addition if &amp;quot;no&amp;quot;.&lt;br /&gt;
* {{anchor|apply_to-vision_costs|'''vision_costs'''}}: vision through specific terrain is modified&lt;br /&gt;
** '''replace''': If set to &amp;quot;yes&amp;quot;, any new values replace the old ones. Otherwise, new values are added to old values (negative values allowed). Defaults to '''no'''.&lt;br /&gt;
** '''[vision_costs]''': a subtag that describes the new vision costs just like under [[UnitsWML#.5Bmovetype.5D|[movetype]]] if replace is set to &amp;quot;yes&amp;quot; or the addition if &amp;quot;no&amp;quot;.&lt;br /&gt;
* {{anchor|apply_to-jamming_costs|'''jamming_costs'''}}: jamming through specific terrain is modified&lt;br /&gt;
** '''replace''': If set to &amp;quot;yes&amp;quot;, any new values replace the old ones. Otherwise, new values are added to old values (negative values allowed). Defaults to '''no'''.&lt;br /&gt;
** '''[jamming_costs]''': a subtag that describes the new jamming costs just like under [[UnitsWML#.5Bmovetype.5D|[movetype]]] if replace is set to &amp;quot;yes&amp;quot; or the addition if &amp;quot;no&amp;quot;.&lt;br /&gt;
* {{anchor|apply_to-defense|'''defense'''}}: Sets the unit's chance to be hit in specific terrain (100 - the unit's defense as shown in-game). &lt;br /&gt;
** '''replace''': If set to &amp;quot;yes&amp;quot;, any new values replace the old ones. Otherwise, new values are added to old values. In most cases, adding a positive number makes the unit easier to hit, while adding a negative number makes the unit harder to hit. The new value is added to the absolute value of the old, and the sign of the old value is preserved. Defaults to '''no'''.&lt;br /&gt;
** '''[defense]''': a subtag that describes the new defense just like under [[UnitsWML#.5Bmovetype.5D|[movetype]]] if replace is set to &amp;quot;yes&amp;quot; or the addition if &amp;quot;no&amp;quot;.&lt;br /&gt;
* {{anchor|apply_to-resistance|'''resistance'''}}: Sets percent damage taken from combat (100 - the unit's resistance as shown in-game)&lt;br /&gt;
** '''replace''': If set to &amp;quot;yes&amp;quot;, any new values replace the old ones. Otherwise, new values are added to old values. Adding a positive number makes the unit take more damage, while adding a negative number makes the unit take less damage. Defaults to '''no'''.&lt;br /&gt;
** '''[resistance]''': a subtag that describes the new resistance just like under [[UnitsWML#.5Bmovetype.5D|[movetype]]] if replace is set to &amp;quot;yes&amp;quot; or the addition if &amp;quot;no&amp;quot;.&lt;br /&gt;
* {{anchor|apply_to-variation|'''variation'''}}: switches the unit into one of its variations. Similar to the '''type''' effect below, this might not behave properly outside of [advancement].&lt;br /&gt;
** '''name''': the id of the variation to invoke. &lt;br /&gt;
* {{anchor|apply_to-type|'''type'''}}: transforms the unit into a new unit_type. This does not work in [trait]; in ActionWML it's recommended to use [transform_unit] instead of an [object] with this effect. This effect cannot be undone with [remove_object].&lt;br /&gt;
** '''name''': the id of the unit_type to invoke.&lt;br /&gt;
* {{anchor|apply_to-status|'''status'''}}: modifies the status affecting the unit.&lt;br /&gt;
** '''add''': a list of status modifications to add. Beware, these may be reapplied later, such as when the unit is recalled or levels up; if in an event, you can use [[InternalActionsWML|[store_unit]]] and [[DirectActionsWML|[unstore_unit]]], modifying unit.status.name directly, to avoid this, or if you are creating the unit, you can just add it to the unit's [status] tag in the [unit] tag.  These are listed in [status], [[SingleUnitWML]].&lt;br /&gt;
** '''remove''': a list of status modifications to remove.&lt;br /&gt;
* {{anchor|apply_to-zoc|'''zoc'''}}: toggle the zone of control.&lt;br /&gt;
** '''value''': new value for zoc (boolean).&lt;br /&gt;
* {{anchor|apply_to-profile|'''profile'''}}: customize the profile of the unit. See [[UnitTypeWML]].&lt;br /&gt;
** '''portrait''': new image to display when the unit speaks.&lt;br /&gt;
** '''small_portrait''': new image to display in unit reports.&lt;br /&gt;
** '''description''': sets the text to display when hovering over the unit's type in the righthand pane.&lt;br /&gt;
** '''[special_note]''': {{DevFeature1.15|2}} Adds or removes a special note in the unit's description.&lt;br /&gt;
*** '''remove''': A boolean value specifying whether to add or remove a note. Defaults to '''no'''.&lt;br /&gt;
*** '''note''' (translatable): The text of the note you want to add or remove. If removing a note, this must be an exact match, character-for-character, for the note you want to remove, and must also be in the same textdomain.&lt;br /&gt;
*** Since the tag name is the same, notes can also be added using the standard special note macros, eg '''{NOTE_HEALS}'''.&lt;br /&gt;
*** To remove a note, you can simply suffix '''{NOTE_REMOVE}''' to the regular note macro, eg '''{NOTE_HEALS}{NOTE_REMOVE}'''.&lt;br /&gt;
* {{anchor|apply_to-new_ability|'''new_ability'''}}: Adds one or more abilities to a unit.&lt;br /&gt;
** '''[abilities]''': A subtag that contains the ability definitions.&lt;br /&gt;
* '''remove_ability''': Removes one or more abilities from a unit. Abilities are not reference counted: added, added, removed = gone.&lt;br /&gt;
** '''[abilities]''': A subtag that contains the ability definitions. Strictly speaking, all that is needed is the id= inside some tag. {{DevFeature1.17|17}} This is now deprecated, use [experimental_filter_ability] instead.&lt;br /&gt;
** {{DevFeature1.17|17}} '''[experimental_filter_ability]''': A subtag that contains the ability definitions like type of abilities, id, or other attributes like affect_self or [affect_adjacent] but not generic filter.&lt;br /&gt;
* {{anchor|apply_to-new_animation|'''new_animation'''}}: contain animations that will be added to the unit, it can contain multiple animation blocks, and a single &amp;quot;id=&amp;quot; line. That Id should be unique for each effect block and is used by the engine to reuse WML parsing, making the loading faster. See [[AnimationWML]] for further reference.&lt;br /&gt;
* {{anchor|apply_to-image_mod|'''image_mod'''}}: modify the image path function ([[ImagePathFunctions]]) of all the unit's frames. Due to a bug, the effect is permanent even inside [object]duration=turn&lt;br /&gt;
** '''replace''': replaces the image path function(s) to be used, e.g. &amp;quot;RC(magenta&amp;gt;red)&amp;quot;&lt;br /&gt;
** '''add''': adds an image path function without removing any existing ones.&lt;br /&gt;
** If needed, you can also define new [[GameConfigWML#Color_Palettes|color palettes]] here.&lt;br /&gt;
* {{anchor|apply_to-ellipse|'''ellipse'''}}: Change the image used for the unit's ellipse.&lt;br /&gt;
** '''ellipse''' : the new image base path to use. Defaults to '''misc/ellipse'''. Can be set to '''none''' to disable the ellipse. An ellipse consist of a top and bottom part so by default in the simplest case the game will look for image files misc/ellipse-top.png and misc/ellipse-bottom.png. This can get further modified based on if the unit is a leader (can_recruit), does the unit emit a zone of control (ZoC) and/or is the unit selected. For a unit that is a leader, emits no ZoC and is currently selected the used files would then be misc/ellipse-leader-nozoc-selected-top.png and misc/ellipse-leader-nozoc-selected-bottom.png.&lt;br /&gt;
* {{anchor|apply_to-halp|'''halo'''}}: Change the image used for the unit's halo.&lt;br /&gt;
** '''halo''': the new image to use.&lt;br /&gt;
* {{anchor|apply_to-overlay|'''overlay'''}}: Change the unit's overlays.&lt;br /&gt;
**'''add''': the specified overlay will be added to the unit's overlays. It can be a comma separated list with multiple overlays. ''Note: overlays added in this way cannot be removed by [remove_unit_overlay] until the effect's duration is over.''&lt;br /&gt;
**'''replace''': all the unit's overlays will be removed and replaced with the specified one. Again, it can be a comma separated list. ''Note: overlays replaced in this way cannot be modified by [unit_overlay] or [remove_unit_overlay] until the effect's duration is over.''&lt;br /&gt;
**'''remove''': {{DevFeature1.15|0}} the specified overlay will be removed from the unit's overlays. It can be a comma separated list with multiple overlays.&lt;br /&gt;
** {{DevFeature1.15|0}} [unit_overlay] and [remove_unit_overlay] are now equivalent to adding a permanent object with this effect, after checking if the unit already has / already doesn't have the overlay (effects with temporary durations will cause false positives / false negatives in this check).&lt;br /&gt;
* {{anchor|apply_to-recall_cost|'''recall_cost'''}}: {{DevFeature1.13|2}} change a unit's recall cost&lt;br /&gt;
** '''set''': set recall cost to a specific value, or a percentage of original value&lt;br /&gt;
** '''increase''': alter recall cost relative to original value; can be positive or negative, or a percentage&lt;br /&gt;
* {{anchor|apply_to-alignment|'''alignment'''}}: {{DevFeature1.13|2}} change a unit's alignment&lt;br /&gt;
** '''set''': the new alignment (one of chaotic, lawful, neutral, liminal)&lt;br /&gt;
* {{anchor|apply_to-new_advancement|'''new_advancement'''}}: {{DevFeature1.13|2}} add new advancement choices to the unit&lt;br /&gt;
** '''replace''': whether to replace existing advancement choices; if this key is set to yes, existing advancement choices are cleared only if you're adding a choice of the same type. (That is, unit type advancements are cleared only if you're adding a new unit advancement choice, and AMLA choices are cleared only if you're adding new AMLA choices.)&lt;br /&gt;
** '''types''': a comma-separated list of additional unit types the unit can advance to. ('''Note:''' If using this, you probably want to include a filter to prevent the unit from being able to advance to this type once it has already done so.)&lt;br /&gt;
** '''[advancement]''': an advancement choice to add, see [[UnitTypeWML#After_max_level_advancement_(AMLA)|AMLAs]]; you can have several of these tags to add multiple advancement choices at the same time.&lt;br /&gt;
* {{anchor|apply_to-remove_advancement|'''remove_advancement'''}}: {{DevFeature1.13|2}} remove existing advancement choices from the unit&lt;br /&gt;
** '''types''': a list of unit type advancements to remove as a possibility&lt;br /&gt;
** '''amlas''': a list of AMLA id attributes; any advancement possibility with the given id will be removed&lt;br /&gt;
* {{anchor|apply_to-level|'''level'''}}: {{DevFeature1.17|15}} change a unit's level. '''Note:''' this key is incompatible with ''times=per level''; if this combination is used, the engine reports a warning and uses ''times=1'' as fallback value&lt;br /&gt;
** '''set''': set level to a specific value; can be positive or negative, but not a percentage&lt;br /&gt;
** '''increase''': alter level relative to original value; can be positive or negative, but not a percentage&lt;br /&gt;
&lt;br /&gt;
== Movement and Vision ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth 1.14 introduced vision points; by default units have the same number of vision points as their max movement points. However, combining effects that change vision with effects that change movement had edge cases which were reworked in 1.16:&lt;br /&gt;
&lt;br /&gt;
Consider a unit with 5 mp, and default vision:&lt;br /&gt;
* It has (effectively) 5 mp and 5 vp.&lt;br /&gt;
* After (mp + 1), it will have 6 mp and 6 vp.&lt;br /&gt;
* After (vp + 2), it will have 5 mp and 7 vp.&lt;br /&gt;
&lt;br /&gt;
In 1.14, using an effect with apply_to=vision breaks the link between vision and movement:&lt;br /&gt;
* After (mp + 1) (vp + 2), it will have 6 mp and 8 vp.&lt;br /&gt;
* After (vp + 2) (mp + 1), it will have 6 mp and 7 vp.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|13}}, [effect]apply_to=movement has another attribute apply_to_vision, which defaults to true. With that change, the order that the effects are applied in doesn't matter:&lt;br /&gt;
* After (mp + 1) (vp + 2), it will have 6 mp and 8 vp.&lt;br /&gt;
* After (vp + 2) (mp + 1), it will have 6 mp and 8 vp.&lt;br /&gt;
&lt;br /&gt;
Increasing movement by 50% increases vision by (50% of movement) not by (50% of vision). For a unit that started with 6 mp and 8 vp, the following effect would give it 9 mp and 11 vp.&lt;br /&gt;
    [effect]&lt;br /&gt;
        apply_to=movement&lt;br /&gt;
        increase=50%&lt;br /&gt;
    [/effect]&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== Effect: apply_to = new_animation  ===&lt;br /&gt;
This is the only way to change animations of units after they have been placed on the map.&lt;br /&gt;
In this example, I add very simple idle animation (taken from Goblin Spearman) to the unit, which moves to hex (x=1, y=5). If you want something more complex, you need to check [[AnimationWML]] page.&lt;br /&gt;
&lt;br /&gt;
  [event]&lt;br /&gt;
    name = moveto&lt;br /&gt;
    [filter]&lt;br /&gt;
      x,y = 1,5&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [object]&lt;br /&gt;
      [filter]&lt;br /&gt;
        x,y = 1,5&lt;br /&gt;
      [/filter]&lt;br /&gt;
      [effect]&lt;br /&gt;
        apply_to = new_animation&lt;br /&gt;
        [idle_anim]&lt;br /&gt;
          {STANDARD_IDLE_FILTER}&lt;br /&gt;
          start_time=0&lt;br /&gt;
          [frame]&lt;br /&gt;
            image=&amp;quot;units/goblins/spearman-idle-[1~12].png:[150*3,300,150*8]&amp;quot;&lt;br /&gt;
          [/frame]&lt;br /&gt;
        [/idle_anim]&lt;br /&gt;
      [/effect]&lt;br /&gt;
    [/object]&lt;br /&gt;
  [/event]&lt;br /&gt;
&lt;br /&gt;
If you are going to use '''advanced WML''' and want to add animation to unit, stored in variable, then following example might help you. '''This way is not efficient if you have no additional logic like inventoriy, shops, advanced unit modifications in your add-on.''' Is is preferred to use first variant or define all needed animation in unit_type.&lt;br /&gt;
  [event]&lt;br /&gt;
    name = moveto&lt;br /&gt;
    [filter]&lt;br /&gt;
      x,y = 1,5&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [store_unit]&lt;br /&gt;
      [filter]&lt;br /&gt;
        x,y=1,5&lt;br /&gt;
      [/filter]&lt;br /&gt;
      variable = stored_unit&lt;br /&gt;
    [/store_unit]&lt;br /&gt;
    [set_variables]&lt;br /&gt;
      name = stored_unit.modifications.object&lt;br /&gt;
      [value]&lt;br /&gt;
        [effect]&lt;br /&gt;
          apply_to = new_animation&lt;br /&gt;
          [idle_anim]&lt;br /&gt;
            {STANDARD_IDLE_FILTER}&lt;br /&gt;
            start_time=0&lt;br /&gt;
            [frame]&lt;br /&gt;
              image=&amp;quot;units/goblins/spearman-idle-[1~12].png:[150*3,300,150*8]&amp;quot;&lt;br /&gt;
            [/frame]&lt;br /&gt;
          [/idle_anim]&lt;br /&gt;
        [/effect]&lt;br /&gt;
      [/value]&lt;br /&gt;
    [/set_variables]&lt;br /&gt;
    [unstore_unit]&lt;br /&gt;
      variable = stored_unit&lt;br /&gt;
    [/unstore_unit]&lt;br /&gt;
  [/event]&lt;br /&gt;
&lt;br /&gt;
== Where to Use Effects ==&lt;br /&gt;
&lt;br /&gt;
A collection of effects together makes up a &amp;quot;unit modification&amp;quot;, which is encased in one of the three types of modification tags: '''[trait]''', '''[object]''', or '''[advancement]'''. Which tag to use depends on the goal of the modification.&lt;br /&gt;
&lt;br /&gt;
* [[UnitsWML#.5Btrait.5D|Traits]] are shown in the unit details on the sidebar. They can be placed in a race or unit type to include the trait in the pool of random traits for that race or unit type, or they can be placed in the global [units] tag to add them to the global pool of random traits. (Note that this can cause out-of-sync errors in multiplayer.)&lt;br /&gt;
* [[UnitTypeWML#After_max_level_advancement_.28AMLA.29|Advancements]] are offered when a unit levels up. If a unit type has both modification advancements and regular advancements, the player can choose either each time they level up.&lt;br /&gt;
* [[DirectActionsWML#.5Bobject.5D|Objects]] are usually placed on the map or added by special events. They also have a built-in facility to automatically remove under certain conditions.&lt;br /&gt;
&lt;br /&gt;
An effect can also be placed in '''[modify_unit]''' [[DirectActionsWML#.5Bmodify_unit.5D|ActionWML]] to apply it on-the-fly without keeping a record that it has been applied. This is mainly useful for effects that change transient properties such as current hitpoints or experience. An effect applied in this way is liable to be reverted when the unit is rebuilt in the future, for example when they level up or when an object is removed.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[AnimationWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=ThemeWML&amp;diff=73513</id>
		<title>ThemeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=ThemeWML&amp;diff=73513"/>
		<updated>2024-08-10T22:30:21Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* The toplevel [theme] tag */ ref&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== The toplevel [theme] tag ==&lt;br /&gt;
&lt;br /&gt;
Themes are used both for the wesnoth game and the wesnoth editor.&lt;br /&gt;
Themes allow flexible configuration of how everything is laid out on-screen.&lt;br /&gt;
&lt;br /&gt;
The following keys are recognized in '''[theme]''':&lt;br /&gt;
* '''id''': The internal id of the theme.&lt;br /&gt;
* '''name''': Translatable theme name displayed in Preferences.&lt;br /&gt;
* '''hidden''': Boolean value (defaults to '''no'''), determines whether the theme will be displayed in Preferences or not. This can be used to prevent players from choosing themes that are not intended for use in regular gameplay.&lt;br /&gt;
* '''description''': A short description of the theme to display in Preferences.&lt;br /&gt;
&lt;br /&gt;
The only tag in '''[theme]''' is '''[[ThemeSystem|[resolution]]]''', but each theme can have multiple [resolution] tags.&lt;br /&gt;
The [resolution] tags are scanned until the first one which is of the same or lower resolution than is currently being used is found, and this is used as our theme.&lt;br /&gt;
This allows us to define themes to work differently on different resolutions, &lt;br /&gt;
and will allow us to support both high and low resolutions elegantly.&lt;br /&gt;
&lt;br /&gt;
The following keys and tags are recognized for [resolution]:&lt;br /&gt;
&lt;br /&gt;
* '''width''', '''height''': dimensions in pixels&lt;br /&gt;
&lt;br /&gt;
All subtags of [resolution] use the following keys:&lt;br /&gt;
* '''rect'''=''a,b,c,d'': defines the rectangle to display on, where a,b are top-left XY co-ordinates and c,d are bottom-right XY co-ordinates. So, for example rec=&amp;quot;0,10,20,30&amp;quot; would create a rectangle that has top left corner at the very left side of the screen, 10 pixels below the very top and is 20 pixels wide and tall. Each of a,b,c,d may be specified as:&lt;br /&gt;
** number : absolute positions&lt;br /&gt;
** ''='' : same value as the same field in reference rect (alignment with reference)&lt;br /&gt;
** +number or -number : for a and b, add this value to reference's c and d respectively (spacing from reference); for c and d, add this value to self's a and b (specify by width and height)&lt;br /&gt;
** =+number or =-number : add this value to same field in reference rect (eg. consider reference as a container box)&lt;br /&gt;
* '''ref''': id of subtag of [resolution] which is used in case of relative rect component (by default rect of (0,0,0,0))&lt;br /&gt;
* '''xanchor''', '''yanchor''': control the behavior of how this rectangle changes as the resolution changes.&lt;br /&gt;
** '''left''': its distance from the left side of the screen always remain the same, while changes in the resolution will change its size by the same amount (top for the y axis).&lt;br /&gt;
** '''right''': its size always remain the same, as well as its distance to the right side of the screen (bottom for the y axis).&lt;br /&gt;
** '''fixed''': its co-ordinates in that axis remain constant&lt;br /&gt;
** '''proportional''': its co-ordinates multiplied by the ratio of the resolution being used to the canonical resolution.&lt;br /&gt;
&lt;br /&gt;
== [main_map] ==&lt;br /&gt;
&lt;br /&gt;
defines where the main game display (i.e. all the hexagons and units) is displayed.&lt;br /&gt;
&lt;br /&gt;
== [main_map_border] ==&lt;br /&gt;
Defines the border of the main map area. It has the following keys.&lt;br /&gt;
&lt;br /&gt;
* '''border_size''': the size of the border, the value should be between 0.0 and 0.5. The images which are used by default are sized for 0.5. If the border gets smaller the images still need the same size. They're simply cut off at the right spot.&lt;br /&gt;
* '''background_image''': the filename of the image to use as background.&lt;br /&gt;
* '''tile_image''': the filename of the image to use for the _off^_usr tile. The image in the minimal can't be controlled only the image in the main map. This image must be in the terrain directory and a png image. When specifying the image the 'terrain/' prefix and '.png' suffix _must_ be ommitted.&lt;br /&gt;
&lt;br /&gt;
== [mini_map] ==&lt;br /&gt;
&lt;br /&gt;
Determines where the mini map is displayed&lt;br /&gt;
&lt;br /&gt;
== [panel] ==&lt;br /&gt;
&lt;br /&gt;
Displays an image as a panel on-screen.&lt;br /&gt;
* '''image''': the image used for the panel&lt;br /&gt;
&lt;br /&gt;
== [label] ==&lt;br /&gt;
&lt;br /&gt;
Displays a text label on screen.&lt;br /&gt;
* '''prefix''': a string that will be printed before the text in all languages&lt;br /&gt;
* '''text''': a text string id to be displayed&lt;br /&gt;
* '''postfix''': a string that will be printed after the text in all languages&lt;br /&gt;
* '''icon''': an image that will be displayed instead of the text if it is available&lt;br /&gt;
* '''font_size''': the size of font to use for the label&lt;br /&gt;
&lt;br /&gt;
== [menu] ==&lt;br /&gt;
&lt;br /&gt;
* '''title''': the id of the string to write on the button&lt;br /&gt;
* '''title_literal''': a string that will be displayed &amp;quot;as is&amp;quot; in all language after the title&lt;br /&gt;
* '''image''': the image to use if available&lt;br /&gt;
* '''is_context_menu''': if set to true this menu will not be placed, but displayed on a right click&lt;br /&gt;
* '''items''': comma separated list of actions to put in the menu. if there is only one action, it will be executed immediately and no menu will be displayed&lt;br /&gt;
** '''cycle''': move to next movable unit&lt;br /&gt;
** '''endunitturn''': consume this unit's move and cycle to the next one&lt;br /&gt;
** '''leader''': center on the leader&lt;br /&gt;
** '''undo''': undo last action&lt;br /&gt;
** '''redo''': redo undone action&lt;br /&gt;
** '''zoomin''': zoom the map in&lt;br /&gt;
** '''zoomout''': zoom the map out&lt;br /&gt;
** '''zoomdefault''': return to default zoom&lt;br /&gt;
** '''fullscreen''': switch fulscreen mode&lt;br /&gt;
** '''accelerated''': switch turbo mode&lt;br /&gt;
** '''resistance''': show resistance table of current unit&lt;br /&gt;
** '''terraintable''': show terrain table of current unit&lt;br /&gt;
** '''describeunit''': show unit description&lt;br /&gt;
** '''renameunit''': change unit name&lt;br /&gt;
** '''save''': save the game&lt;br /&gt;
** '''recruit''': recruit a unit&lt;br /&gt;
** '''repeatrecruit''': repeat last recruitement&lt;br /&gt;
** '''recall''': recall a unit from previous scenario&lt;br /&gt;
** '''endturn''': end current turn&lt;br /&gt;
** '''togglegrid''': toggle grid display&lt;br /&gt;
** '''statustable''': show status table&lt;br /&gt;
** '''mute''': mute all sounds&lt;br /&gt;
** '''speak''': send message to other players&lt;br /&gt;
** '''createunit''': debug create a unit on the map&lt;br /&gt;
** '''preferences''': open preference dialog&lt;br /&gt;
** '''objectives''': show objective window&lt;br /&gt;
** '''unitlist''': list units&lt;br /&gt;
** '''statistics''': show game statistics&lt;br /&gt;
** '''quit''': quit the game&lt;br /&gt;
** '''labelterrain''': label current location&lt;br /&gt;
** '''clearlabels''': clear all labels on map&lt;br /&gt;
** '''showenemymoves''': show grids reachable by the enemy&lt;br /&gt;
** '''bestenemymoves''': show grids reachable by the enemy with no zone of control&lt;br /&gt;
** '''editnewmap''': editor only start a new map&lt;br /&gt;
** '''editloadmap''': editor only loads an existing map&lt;br /&gt;
** '''editsavemap''': editor only saves the current map&lt;br /&gt;
** '''editsaveas''': editor only saves the current map, let you choose a filename&lt;br /&gt;
** '''editsetstartpos''': editor only set a starting position for a team&lt;br /&gt;
** '''editfloodfill''': editor only flood the map with a terrain&lt;br /&gt;
** '''toggleshroud''': toggle the &amp;quot;moving removes shroud&amp;quot; behaviour&lt;br /&gt;
** '''updateshroud''': removes all possible shroud&lt;br /&gt;
** '''AUTOSAVES''': expands to a list of all Auto-Save games prior to this one&lt;br /&gt;
&lt;br /&gt;
== [status] ==&lt;br /&gt;
&lt;br /&gt;
This tag describes the Status Table.&lt;br /&gt;
This tag contains many other tags, which determine where other game statistics, such as the current turn, and a description of selected units go.&lt;br /&gt;
For instance, the [time_of_day] tag will determine where the time of day image goes.&lt;br /&gt;
Each subtag of [status] can contain the following attributes&lt;br /&gt;
&lt;br /&gt;
** '''font_size''': the size of font to use for the status&lt;br /&gt;
** '''rect''': the rectangle as for the main_map attribute&lt;br /&gt;
** '''xanchor''': the x-wise anchoring as for the main_map attribute&lt;br /&gt;
** '''yanchor''': the y-wise anchoring as for the main_map attribute&lt;br /&gt;
** '''prefix''': the string to display before the actual status, this is the string id for internationalisation&lt;br /&gt;
** '''prefix_literal''': a string to put after the prefix, but before the label for all languages.&lt;br /&gt;
** '''postfix_literal''': a string to put after the status&lt;br /&gt;
** '''postfix''': the string to display after the postfix_literal, this is the string id for internationalisation&lt;br /&gt;
&lt;br /&gt;
the following tags are recognized for [status]:&lt;br /&gt;
* '''[unit_description]''': the user description of the current unit. Note: this tag is now obsolete&lt;br /&gt;
* '''[unit_name]''': the user description of the current unit&lt;br /&gt;
* '''[unit_type]''': the type of the current unit&lt;br /&gt;
* '''[unit_race]''': the race of the current unit&lt;br /&gt;
* '''[unit_level]''': the level of the current unit&lt;br /&gt;
* '''[unit_side]''': the side of the current unit (flag)&lt;br /&gt;
* '''[unit_traits]''': the traits of the current unit&lt;br /&gt;
* '''[unit_status]''': the status of the current unit&lt;br /&gt;
* '''[unit_alignment]''': the alignment of the current unit&lt;br /&gt;
* '''[unit_abilities]''': the abilities of the current unit&lt;br /&gt;
* '''[unit_hp]''': the HP of the current unit&lt;br /&gt;
* '''[unit_xp]''': the XP of the current unit&lt;br /&gt;
* '''[unit_moves]''': the moves remaining for the current unit&lt;br /&gt;
* '''[unit_weapons]''': the attacks of the current unit&lt;br /&gt;
* '''[unit_image]''': the icon for the current unit&lt;br /&gt;
* '''[unit_profile]''': the portait for the current unit&lt;br /&gt;
* '''[unit_advancement_options]''': the advancement(s) of the current unit appear in the tooltip of this element&lt;br /&gt;
* '''[time_of_day]''': the time of day on the current location&lt;br /&gt;
* '''[turn]''': the turn number and turn remaining&lt;br /&gt;
* '''[gold]''': the gold remaining&lt;br /&gt;
* '''[villages]''': the number of villages owned&lt;br /&gt;
* '''[num_units]''': the number of units owned&lt;br /&gt;
* '''[upkeep]''': the money needed to keep your units every turn&lt;br /&gt;
* '''[expenses]''': the money lost each turn when you don't have enough income&lt;br /&gt;
* '''[income]''': the income per turn (can be positive)&lt;br /&gt;
* '''[terrain]''': the text description of the current terrain&lt;br /&gt;
* '''[position]''': the current terrain's position&lt;br /&gt;
* '''[side_playing]''': the current playing side (flag)&lt;br /&gt;
* '''[observers]''': the current observers&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[ThemeSystem]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Wesnoth_AI_Framework&amp;diff=73404</id>
		<title>Wesnoth AI Framework</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Wesnoth_AI_Framework&amp;diff=73404"/>
		<updated>2024-08-08T19:15:56Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* AI Configuration */ seems [ai] works in [modification]&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Wesnoth AI Framework: A Composite AI ==&lt;br /&gt;
&lt;br /&gt;
The Wesnoth AI framework is that of a composite AI.  In other words, rather than the AI being one huge monolithic block, it is composed of a variety of different components which can be combined in a modular fashion (almost) at will.&lt;br /&gt;
&lt;br /&gt;
In its default configuration, Wesnoth provides a predefined combination of these components in the [[RCA AI]].  This configuration can be modified in a multitude of different ways.  Due to the modular setup, it is not only possible to add new AI behavior to before or after the default AI moves, or replace the default AI entirely, but also to insert new behavior routines in between existing components.  This can be done either in addition to or as substitutions for existing components.&lt;br /&gt;
&lt;br /&gt;
This page describes the AI components and their configuration in a general sense.  Check out [[RCA AI]] for a description of how these are assembled into the default AI and [[Wesnoth AI]] for a collection of links to pages explaining how to customize and modify the existing AI or write a completely new AI.&lt;br /&gt;
&lt;br /&gt;
== Types of AI Components ==&lt;br /&gt;
&lt;br /&gt;
The Wesnoth AI framework consists of the following types of components:&lt;br /&gt;
&lt;br /&gt;
==== Stages====&lt;br /&gt;
&lt;br /&gt;
These are the fundamental building blocks of the AI.  The AI is set up as a series of stages which are executed in the order in which they are put into the AI configuration.  In other words, all actions of the first stage are executed first, then all actions of the second stage, etc.&lt;br /&gt;
&lt;br /&gt;
While there are six different types of stages, only one of them, called the ''main_loop'' stage, is used in the default AI.  In fact, this stage is sufficient for the vast majority of custom AI applications as well.  We therefore only describe the ''main_loop'' stage and its sub-components in detail.&lt;br /&gt;
&lt;br /&gt;
==== The Candidate Actions of the ''main_loop'' Stage ====&lt;br /&gt;
&lt;br /&gt;
The ''main_loop'' stage consists of a number of candidate actions (CAs), each of which contains an evaluation and an execution function.  For each AI move, the evaluation functions of all CAs are called, with each of them returning a score.  The execution function of the CA with the highest score is then called, which results in an AI move (or in some cases, several moves) to be done.  Then all CAs are evaluated again (including the one that was just executed) and the highest scoring CA is executed, until no CA returns a valid (non-zero) score any more.&lt;br /&gt;
&lt;br /&gt;
Combining candidate actions designed for specific tasks such as attacks or village grabbing, it is possible to create entire AIs in a modular fashion.  The CAs can be put together in whatever order and combination best suits the needs of a scenario.  They do not need to be sorted in order of their evaluation scores and can even return variable scores which adapt to the situation on the map.&lt;br /&gt;
&lt;br /&gt;
For a summary of the candidate actions of the default AI, click [[RCA_AI#The_Candidate_Actions_.28CAs.29_of_the_main_loop_Stage_in_the_RCA_AI|here]].&lt;br /&gt;
&lt;br /&gt;
==== Aspects and Goals====&lt;br /&gt;
&lt;br /&gt;
Aspects are configurable input parameters used to customize a candidate action's behavior.  They are implemented as the the return values of functions that are called by the CAs of the RCA AI.  They can also be called and taken into account by custom CAs, but that is not necessarily always the case.  For example, some of the [[Micro AIs]] respect some of the RCA AI aspects (such as ''avoid''), but not all do.&lt;br /&gt;
&lt;br /&gt;
The return values of the aspect functions can be defined and/or customized using both [[AiWML|WML]] or [[LuaAI#Dynamic_Lua_Aspects|Lua]].&lt;br /&gt;
&lt;br /&gt;
Goals are used similarly to aspects in that they also affect the behavior of the default AI.  They can be used to customize the directions into which the default AI moves its units.  However, both their [[AiWML#AI_Targets_and_Goals|syntax]] and their internal implementation (see below) are different from those of the aspects.&lt;br /&gt;
&lt;br /&gt;
Check out the [[RCA AI]] page for details on which aspects and goals exist and how they are used by the default AI.&lt;br /&gt;
&lt;br /&gt;
==== Engines====&lt;br /&gt;
&lt;br /&gt;
Engines assemble the configurations provided for the individual components of the AI into usable code and execute this code.  In recent Wesnoth versions, you do not need to worry about the engines any more, they are always defined and active by default.  It is sufficient to know that the components can be written in three different languages, C++, Lua and Formula AI (FAI).  Information on how to do this is provided in the links of the [[Wesnoth AI]] page.&lt;br /&gt;
&lt;br /&gt;
It is worth noting that some stages are only set up for specific engines (see below), while the candidate actions, aspects and goals of the ''main_loop'' stage can be written in any of the three languages and can be combined arbitrarily.&lt;br /&gt;
&lt;br /&gt;
== AI Configuration ==&lt;br /&gt;
&lt;br /&gt;
The Wesnoth AIs are assembled from configurations provided in several different places:&lt;br /&gt;
* The default AI parameters in a variety of configuration files in the 'data/ai/' directory&lt;br /&gt;
* Optional [ai] or [modify_ai] tags in era configurations&lt;br /&gt;
* Optional [ai] or [modify_ai] tags in modification configurations&lt;br /&gt;
* Optional [ai] or [modify_ai] tags in multiplayer faction configurations&lt;br /&gt;
* Optional [ai] or [modify_ai] tags in scenario configurations&lt;br /&gt;
* Optional [ai] tags in individual unit definitions (ie in the [unit] tag) - note that this option may be removed or drastically changed in the future&lt;br /&gt;
&lt;br /&gt;
When the game is created, all these config snippets are merged into a single configuration stored in form of an [ai] tag.  Then, aspects with the same ids are merged.  During the game, whenever a [modify_ai] tag is acted upon (for example in an event), it is added into the existing AI configuration in the same way.&lt;br /&gt;
&lt;br /&gt;
In the following, we describe the syntax of the [ai] tag.  We first show the top-level keys and tags that can be used.  Details on the use of the tags for the individual components follow after that, together with examples and links to more information for each component.&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Top-level Elements ==&lt;br /&gt;
&lt;br /&gt;
AI configurations are set up and stored using the [ai] tag.  It has the following top-level elements, which are described in more detail in the remaining sections of this page.&lt;br /&gt;
&lt;br /&gt;
*'''description'''=&amp;quot;&amp;quot;: (translatable string)  This is the text displayed in the MP setup menu when choosing an AI for a computer player. It is only relevant for reusable AI configurations, for example in [[EraWML]].&lt;br /&gt;
*'''id'''=&amp;quot;&amp;quot;: (string) The id of the [ai] config snippet.  This was originally meant to make it possible to remove [ai] configurations selectively during a game.  However, due to the merging process described above, this information is lost.  The id is therefore meaningless in the current implementation of the AI. {{DevFeature1.13|5}} This id can now be referenced by ''ai_algorithm'' in order to set the base AI algorithm to build on. It is only relevant for reusable AI configurations, for example in [[EraWML]].&lt;br /&gt;
*'''ai_algorithm''': (string) This used to instruct Wesnoth to load a different AI engine instead of the composite AI. {{DevFeature1.13|5}} It now specifies a default AI configuration to load; any AI available at the multiplayer select screen can be chosen, or AIs defined in other addons. It must reference the id attribute of another [ai] tag. It defaults to ai_default_rca; other possible values include experimental_ai and idle_ai. Specifying the ID of an AI defined in ''data/ai/ais/'' or ''/data/ai/dev/'' is roughly equivalent to macro-including that file in your side configuration just above the opening [ai] tag, except that the AI configuration will be loaded on the fly (similar to using [modify_side]switch_ai) rather than included in the preprocessed WML. Additional aspects, stages, and so on can still be added to the [ai] tag as normal.&lt;br /&gt;
*'''mp_rank''': (integer) {{DevFeature1.15|0}} A value that determines in which order available AIs are displayed in the multiplayer selection menu. AIs are listed in ascending order of mp_rank (smallest values first). The mainline default (RCA) AI and Experimental AI have values of 1000 and 1010, respectively, meaning that custom AIs with mp_rank less than 1000 will be listed before any of the default AIs. AIs that do not contain an mp_rank line are shown at the end of the list. It is only relevant for reusable AI configurations, for example in [[EraWML]].&lt;br /&gt;
*'''version'''=&amp;quot;&amp;quot;: (string) This key is currently still needed to distinguish whether aspects are defined using ''standard'' or ''composite'' syntax in the [ai] tag.  If it is omitted, standard syntax is used.  If set to '10703' or '10710', the engine uses composite syntax.  However, '''we are in the process of removing this distinction'''.  When that is done, both types of syntax can be used without needing the ''version'' key, even mixed together inside the same [ai] tag.  We will also deprecate this key when that happens. {{DevFeature1.13|5}} The version key is no longer recognized and will be mistaken as an attempt to set a non-existent &amp;quot;version&amp;quot; aspect. The key should not normally be required even prior to 1.13.5, however.&lt;br /&gt;
*'''[stage]''': Configuration of the stage(s) used in the AI.  Several [stage] tags can be used, even several stages of the same type.  They are executed in the order in which they are put into the [ai] tag.&lt;br /&gt;
*'''[aspect]''': Configuration of the aspects to be used by the AI.  These are in composite aspect format.&lt;br /&gt;
** Most aspects can also be provided using the simpler syntax explained at [[AiWML]].&lt;br /&gt;
*'''[goal]''': Configuration of the goals to be used by the AI.&lt;br /&gt;
*'''[engine]''': This tag used to be needed for the Lua AI engine.  It is not required any more, the Lua engine is created automatically now, just as the two other engines.  If you need information on how this works, check out the [[Lua_AI_Legacy_Methods_Howto|Lua AI legacy documentation]]. Note that this tag is still used internally, so it will almost certainly not be removed in the future.&lt;br /&gt;
*'''[modify_ai]''': The [modify_ai] tag can specify modifications to be applied to the AI immediately. This is the preferred way to add a candidate action to the RCA AI, but can also be used for any other type of modification that [[DirectActionsWML#.5Bmodify_ai.5D|modify_ai]] supports.&lt;br /&gt;
*'''[micro_ai]''': Add a [micro_ai] at initialization time. See [[Micro AIs]] for details. This is equivalent to adding the micro AI at prestart. The side and action keys are not supported here.&lt;br /&gt;
*'''formula'''=&amp;quot;&amp;quot;: (string) Formula AI code to be executed by the AI.  We recommend not using this any more, and it is not guaranteed to continue working.  See the [[Formula_AI_Howto|Formula AI legacy documentation]] for more information. {{DevFeature1.13|5}} As of version 1.13.5 this key is ''definitely not'' recognized at this level. It has likely not been recognized for some time prior to this, as well.&lt;br /&gt;
*'''time_of_day''', '''turns''', '''engine''': {{DevFeature1.13|5}} Specifies default values for aspects given as attributes or simple tags. (Simple tags are tags that do not contain either a value= attribute or a [value] subtag, with the exception that [attacks] is never a simple tag.) This is available prior to 1.13.5, but more limited; the engine attribute is probably more limited, and there might be problems mixing this syntax with fully-specified composite aspects in the same [ai] tag. (That can easily be worked around in a side configuration by splitting the [ai] tag in two.)&lt;br /&gt;
*'''Other tags and attributes''': {{DevFeature1.13|5}} Any other tag or attribute found is assumed to be a simplified aspect. More details about this syntax is given in the section on aspects later on this page. Some of this syntax is available prior to 1.13.5, but it has been generalized in 1.13.5 to automatically work for any compatible aspect. See [[AIWML]] for a list of these tags and attributes.&lt;br /&gt;
&lt;br /&gt;
If no '''ai_algorithm''' is specified, normally the game will automatically load in the default AI, as if you had specified '''ai_algorithm=ai_default_rca'''. However, if there is a '''[stage]''' tag, then this behaviour is disabled and the AI will be built from a blank slate. This special behaviour only comes into play if '''ai_algorithm''' is omitted entirely.&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Stages ==&lt;br /&gt;
&lt;br /&gt;
The [ai] tag can contain one or several stages defined in [stage] tags.  If the AI configuration contains several stages, they are executed in the order in which they are put into the [ai] tag.&lt;br /&gt;
&lt;br /&gt;
While there are six different types of stages available, all AI functionality possible in Wesnoth can be achieved using only a single one, the candidate action evaluation loop stage.  In the default setup, this stage has ''id'' 'main_loop' and we generally simply refer to it as the ''main_loop'' stage.&lt;br /&gt;
&lt;br /&gt;
Other stages exist mostly for legacy reasons from the times in the AI development when the ''main_loop'' stage did not exist yet.  They are currently still functional and kept for backward compatibility reasons, but they are not maintained any more and might be removed in a future Wesnoth release cycle.  We therefore recommend that all custom AI development is done using the ''main_loop'' stage only.&lt;br /&gt;
&lt;br /&gt;
All stages support the '''id''' and '''engine''' tags. The latter defaults to cpp, and can be omitted in this case; the former is a unique identifier which is required if you want to later remove or modify the stage with [modify_ai]. If '''engine'''=cpp, an additional '''name''' tag is required, which tells the game which C++ AI algorithm to use. Currently the only valid values are 'ai_default_rca::candidate_action_evaluation_loop' and 'empty'. The 'empty' stage does nothing at all and should generally not be required.&lt;br /&gt;
&lt;br /&gt;
=== ''main_loop'' Stage Configuration ===&lt;br /&gt;
&lt;br /&gt;
For the ''main_loop'' stage, the [ai] tag contains the following elements:&lt;br /&gt;
&lt;br /&gt;
*'''name''': This must be set to 'ai_default_rca::candidate_action_evaluation_loop', so that the AI knows that this is the ''main_loop'' stage.&lt;br /&gt;
*'''id''': (string)  This is the identifier of the AI.  It is usually set to 'main_loop', but can take on any value.  It only matters if you are planning to remove or modify the stage during a scenario. Note that adding or removing a candidate action counts as a modification.&lt;br /&gt;
*'''engine'''=cpp: (string)  This must be set to 'cpp', which is also the default value.  It can therefore be omitted.&lt;br /&gt;
*'''[candidate_action]''': Candidate action configuration tags.  See [[#The_.5Bai.5D_Tag_.E2.80.94_Candidate_Actions|below]] for details.&lt;br /&gt;
*'''[args]''': {{DevFeature1.13|5}} Lua engine only; specifies arguments to pass to the stage's execution function. This works similarly to the [args] in candidate actions.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* As an example, the configuration of the ''main_loop'' stage of the default AI is shown [[RCA_AI#RCA_AI_Stage_Configuration|here]].&lt;br /&gt;
* Candidate actions can use any of the three available engines.  Just because the stage uses the ''cpp'' engine does not mean that the CAs need to do so as well.  See [[#The_.5Bcandidate_action.5D_Tag|below]] for an example.&lt;br /&gt;
* While that should rarely ever be necessary, it is possible to include several ''main_loop'' stage definitions in the same [ai] tag.&lt;br /&gt;
** This is done by putting several [stage] tags into the same [ai] tag&lt;br /&gt;
** The AI engine then evaluates the CAs of the first stage in the usual way, until no CA returns a valid score any more.&lt;br /&gt;
** After the first stage is finished, it moves on to the second stage and repeats the process, until all stages have finished.  This ends the AI turn.&lt;br /&gt;
** Obviously, this only makes sense if the sets of CAs of the different stages are not identical (although individual CAs might appear in several stages).&lt;br /&gt;
&lt;br /&gt;
=== Recruitment Stage ===&lt;br /&gt;
&lt;br /&gt;
There is a specialized configurable recruitment stage.  However, this stage uses the recruitment functions of the old ''Default AI'' (the one used before the RCA AI existed).  Anything that can be done with this stage, and more, can now also be done with the ''recruitment'' candidate action using the [[AI_Recruitment#Aspect_recruitment_instructions|''recruitment_instruction'' aspect]].  It should therefore never be necessary to use this stage and we do not describe it here.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This stage has now been removed. Any use of this stage within the old ''recruitment'' aspect should still continue to work, as the syntax of this stage is compatible with the ''recruitment_instructions'' aspect and ''recruitment'' is now considered a synonym of that newer aspect. Straight uses of this stage, however, will no longer function.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Stages ===&lt;br /&gt;
&lt;br /&gt;
Four other stages are also available.  They do, however, not provide any functionality that is not also possible with the ''main_loop'' stage, only different ways of achieving the same functionality.  We therefore only list them here for completeness, with brief examples and links to legacy documentation.&lt;br /&gt;
&lt;br /&gt;
Note that both this documentation and the stages themselves might be removed at some point.&lt;br /&gt;
&lt;br /&gt;
==== Lua stage ====&lt;br /&gt;
&lt;br /&gt;
Executes Lua code by calling a function created inside a Lua engine. Whatever element is returned by the code in the Lua [engine] tag is accessible here as an upvalue.&lt;br /&gt;
So, for example, &amp;lt;syntaxhighlight lang='lua' inline&amp;gt;(...):execute()&amp;lt;/syntaxhighlight&amp;gt; calls &amp;lt;syntaxhighlight lang='lua' inline&amp;gt;whatever_is_returned_by_lua_engine:execute()&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[stage]&lt;br /&gt;
    engine=&amp;quot;lua&amp;quot;&lt;br /&gt;
    code= &amp;quot;(...):execute()&amp;quot;&lt;br /&gt;
[/stage]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the [[Lua_AI_Legacy_Methods_Howto#Using_the_Lua_Stage|Lua AI legacy documentation]].&lt;br /&gt;
&lt;br /&gt;
==== Formula AI Side Formulas Stage ====&lt;br /&gt;
&lt;br /&gt;
This stage executes a given Formula AI side formula.  Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[stage]&lt;br /&gt;
    engine=fai&lt;br /&gt;
    name=side_formulas&lt;br /&gt;
    move=&amp;quot;write_your_formula_here&amp;quot;&lt;br /&gt;
[/stage]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the [[Formula_AI_Howto#Setting_up_the_Formula_AI_side_formulas_Stage|Formula AI legacy documentation]].&lt;br /&gt;
&lt;br /&gt;
==== Formula AI Unit Formulas Stage ====&lt;br /&gt;
&lt;br /&gt;
This stage takes no parameters and executes all Formula AI formulas which are attached to units.  Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[stage]&lt;br /&gt;
    engine=fai&lt;br /&gt;
    name=unit_formulas&lt;br /&gt;
[/stage]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the [[Formula_AI_Howto#Setting_up_the_Formula_AI_unit_formulas_Stage|Formula AI legacy documentation]].&lt;br /&gt;
&lt;br /&gt;
==== Fallback stage ====&lt;br /&gt;
&lt;br /&gt;
Fall back to another AI.  Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[stage] &lt;br /&gt;
    id=fallback&lt;br /&gt;
    name=testing_ai_default::fallback&lt;br /&gt;
    [ai]&lt;br /&gt;
       ai_algorithm=default_ai&lt;br /&gt;
    [/ai]&lt;br /&gt;
[/stage]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This example shows how to set up a stage to fall back to the old ''Default AI''.  This was useful when it was not clear yet how well the RCA AI would work and whether it would suddenly stop in the middle of the CA evaluation loop.  There is really no reason to use a fallback stage any more these days, especially since it is also possible to simply add another stage to the AI configuration (without that having to be a fallback stage).&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This stage has now been removed since the RCA AI is now the only algorithm and thus there's nothing else to fallback to.&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Candidate Actions ==&lt;br /&gt;
&lt;br /&gt;
The ''main_loop'' stage (and only this stage) can contain an assortment of candidate actions.  They are evaluated and executed in the manner explained [[Wesnoth_AI_Framework#The_Candidate_Actions_of_the_main_loop_Stage|above]].  This section explains how to configure the [candidate_action] tag that goes into the [stage] tag of the ''main_loop'' stage.&lt;br /&gt;
&lt;br /&gt;
All three engines can, in principle, be used to [[Creating_Custom_AIs#Setting_Up_a_Custom_AI|write custom CAs]].  However, only the use of Lua CAs is recommended for this purpose.  Using the ''cpp'' engine has the obvious problem of requiring changes to the Wesnoth source code.  Formula AI CAs are discouraged for the same reasons why we do not recommend using Formula AI stages any more.&lt;br /&gt;
&lt;br /&gt;
=== The [candidate_action] Tag ===&lt;br /&gt;
&lt;br /&gt;
The [candidate_action] tag can contain the following keys:&lt;br /&gt;
&lt;br /&gt;
*'''engine''': This key is required for Wesnoth to know which engine the CA should be processed with.  Possible values are 'cpp', 'lua' and 'fai'.&lt;br /&gt;
*'''id''': The id of the CA is, in principle, optional.  However, it is needed if you want to remove or change the CA after its initial definition.&lt;br /&gt;
*'''name''': The CAs of the default AI are identified by their name, making this a required key for the ''cpp'' engine.  Check [[RCA_AI#Available_Candidate_Actions|here]] for the names of the available default CAs.  The key is optional for other engines.&lt;br /&gt;
*'''max_score''': The maximum score the CA evaluation function might return.  This parameter is optional, but it is useful to reduce the AI move evaluation time.  During each iteration through the evaluation loop, the ''main_loop'' stage only evaluates CAs with ''max_score'' larger than that of the highest-scoring CA found so far during this iteration.  For that same reason, it also makes sense to order CAs by decreasing ''max_score'' in the [stage] tag, even though that is not technically necessary.&lt;br /&gt;
*'''score''': (''cpp'' engine only) The score returned by the CA.  Note that this means that ''cpp'' engine CAs always have fixed scores.&lt;br /&gt;
*'''[filter_own]''': {{DevFeature1.15|3}} The AI units participating in this candidate action can be restricted to only the units defined in this tag.  See the [[AiWML#Filtering_which_Units_Participate_in_which_Actions|AiWML page]] for more information and an example. The content of this tag is [[Creating_Custom_AIs#Creating_Custom_Candidate_Actions|available to both the evaluation and execution function as a WML table]]. This tag is optional. If it is omitted, all AI units are used. (''cpp'' and ''lua'' CAs only; ''fai'' CAs have a different mechanism.)&lt;br /&gt;
&lt;br /&gt;
In addition, [[Creating_Custom_AIs#Creating_Custom_Candidate_Actions|Lua CAs]] also contain the following keys:&lt;br /&gt;
*'''location''': File name, including path, of the AI code for the CA.&lt;br /&gt;
*'''eval_parms''', '''exec_parms''': (deprecated) The parameters to be passed to the evaluation and execution functions of the AI.  These need to be in form of a [[LuaWML#Encoding_WML_objects_into_Lua_tables|Lua table]], without the outer curly brackets.  They are [[Creating_Custom_AIs#Creating_Custom_Candidate_Actions|passed to these functions]] as the second argument, ''cfg''.&lt;br /&gt;
*'''sticky''', '''unit_x''', '''unit_y''': Specifies that this is a [[Lua_AI_Legacy_Methods_Howto#Behavior_.28Sticky.29_Candidate_Actions|behavioral candidate action]] that is automatically removed once the unit on the given location dies.&lt;br /&gt;
*'''[args]''': {{DevFeature1.13|5}} This replaces eval_parms and exec_parms, which are now deprecated and will be removed in a later version. The content of this tag is available to both the evaluation and execution function as a WML table. Details at the link above.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
&lt;br /&gt;
* The syntax for Lua CAs has evolved a fair bit, and some of the older syntaxes are still supported. They are deprecated, however, and may be removed in a future version.&lt;br /&gt;
** If you need information on the old syntax, check out the [[Lua_AI_Legacy_Methods_Howto|Lua AI legacy documentation]].&lt;br /&gt;
* The current syntax was originally called ''external Lua CAs''.  However, as this has now become the standard, we drop the ''external'' and simply call them ''Lua CAs''.&lt;br /&gt;
* Formula AI CAs contain some additional keys.  As we do not recommend using the ''fai'' engine any more, we do not describe this syntax here and refer to the [[Formula_AI_Howto|Formula AI legacy documentation]] instead. &lt;br /&gt;
&lt;br /&gt;
Here are examples of [candidate_action] tag uses:&lt;br /&gt;
&lt;br /&gt;
'''Combat CA''' of the default AI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[candidate_action]&lt;br /&gt;
    id=combat&lt;br /&gt;
    engine=cpp&lt;br /&gt;
    name=ai_default_rca::combat_phase&lt;br /&gt;
    max_score=100000&lt;br /&gt;
    score=100000&lt;br /&gt;
[/candidate_action]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Lua AI CA''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[candidate_action]&lt;br /&gt;
    engine=lua&lt;br /&gt;
    name=return_guardian_bob&lt;br /&gt;
    id=return_guardian_bob&lt;br /&gt;
    max_score=100010&lt;br /&gt;
    location=&amp;quot;~add-ons/my_addon/lua/return_guardian.lua&amp;quot;&lt;br /&gt;
    [args]&lt;br /&gt;
        id=Bob&lt;br /&gt;
        return_x=10&lt;br /&gt;
        return_y=15&lt;br /&gt;
    [/args]&lt;br /&gt;
[/candidate_action]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Available Candidate Actions ===&lt;br /&gt;
&lt;br /&gt;
* '''''cpp''''' '''engine''': The available CAs of the default AI are given [[RCA_AI#Available_Candidate_Actions|here]].&lt;br /&gt;
* '''''lua''''' '''engine''': The [[Micro AIs]] are written using Lua CAs, which can be used either as they are or as templates for [[Creating_Custom_AIs#Setting_Up_a_Custom_AI|creating your own CAs]].  They can be found [https://github.com/wesnoth/wesnoth/tree/master/data/ai/micro_ais/cas here].&lt;br /&gt;
* '''''fai''''' '''engine''': As we said above, we do not recommend using the ''fai'' engine any more for creating custom CAs.  However, if you want to do so, a few simple Formula AI CA examples can be found in the [[Formula_AI_Howto|Formula AI legacy documentation]].&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Aspects == &lt;br /&gt;
&lt;br /&gt;
The values of aspects are used by the candidate actions of the default AI as parameters influencing the AI behavior.  Thus, for the most part, they only apply to the CAs of the default AI.  It is, however, possible to write Lua CAs which query certain aspects and take them into account.  For example, some of the [[Micro AIs]] respect some of the default aspects.&lt;br /&gt;
&lt;br /&gt;
A huge number of aspects are available for the default AI.  They are therefore given [[AiWML|their own page]].  Only the syntax and internal structure of the aspect configuration is shown here.&lt;br /&gt;
&lt;br /&gt;
There are two types of syntax for defining aspects.  In the following, we slowly walk you through these using increasingly complex examples, with the full definition of all the possible key and tags listed at the end of this section.&lt;br /&gt;
&lt;br /&gt;
The vast majority of aspects can be defined using a straight-forward syntax of simply defining their values using keys or tags.  These are sometimes referred to as ''simple'' aspects, though the simplicity is in the syntax rather than a feature of the aspect. (In actual fact, this syntax defines facets of a ''composite'' aspect.)  Examples are&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[ai]&lt;br /&gt;
    time_of_day=dawn&lt;br /&gt;
    aggression=0.765&lt;br /&gt;
[/ai]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[ai]&lt;br /&gt;
    [avoid]&lt;br /&gt;
        terrain=W*&lt;br /&gt;
    [/avoid]&lt;br /&gt;
[ai]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For simple aspect syntax, several additional keys are available in addition to the aspect names themselves, '''time_of_day''' (as shown in the example above), '''turns''' and {{DevFeature1.13|5}} '''engine'''.  These are also explained at [[AiWML]], but these keys basically affect all aspects defined in this simple syntax. {{DevFeature1.13|5}} Currently, every aspect except the attacks aspect can be defined in this way. Prior to 1.13.5, there were also a few other aspects that could not be defined in this way.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} Occasionally, a more complex structure is required. Any aspect name can be used as a tag which contains the contents of a [facet] tag. Thus, the above two examples could also be implemented like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[ai]&lt;br /&gt;
    [aggression]&lt;br /&gt;
        time_of_day=dawn&lt;br /&gt;
        value=0.765&lt;br /&gt;
    [/aggression]&lt;br /&gt;
    [avoid]&lt;br /&gt;
        [value]&lt;br /&gt;
            terrain=W*&lt;br /&gt;
        [/value]&lt;br /&gt;
    [/avoid]&lt;br /&gt;
[/ai]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This syntax has the advantage of allowing you to set the facet ID as well as the invalidate keys, if desired. They are not affected by toplevel ''turns'', ''time_of_day'', and ''engine'' keys. However, they expand in a very similar way to the simpler syntax - that is, they define a facet of a composite aspect. In the case of aspects that require a tag in both syntaxes (such as ''avoid''), it's the presence of [value] that disambiguates them.&lt;br /&gt;
&lt;br /&gt;
The third way of defining an aspect is to use the full syntax, which is sometimes called ''complex aspects'', though this is merely a feature of the syntax and not something inherent to any given aspect. All simple aspects expand to equivalent complex aspects, after all. A complex aspect uses the following keys:&lt;br /&gt;
*'''engine'''=cpp: The engine to use for this tag. This can usually be omitted.&lt;br /&gt;
*'''id''': A unique identifier for the aspect. This is mainly used for [modify_ai].&lt;br /&gt;
*'''name''': Only required for the ''cpp'' engine. Possible values are ''standard_aspect'', ''composite_aspect'', ''lua_aspect'', and ''ai_default_rca::aspect_attacks''. Most of these values are only valid with the cpp engine, while ''lua_aspect'' is only valid with the Lua engine. A sensible default is normally chosen, allowing this to be omitted. {{DevFeature1.13|5}} Prior to 1.13.5, some of these values would not work in certain contexts, but in 1.13.5, any valid value may be used here in any aspect context.&lt;br /&gt;
*'''invalidate_on_*''' keys: These four keys are primarily for advanced usage. They are described in more detail below.&lt;br /&gt;
&lt;br /&gt;
A complex aspect contains additional keys and tags based on the value of its name attribute. Standard aspects contain either a '''value''' attribute or a '''[value]''' tag which specifies the attribute's value. The attack aspect contains the '''[filter_own]''' and '''[filter_enemy]''' tags, as described [[AiWML#Filtering_Combat_with_the_attacks_Aspect|here]]. Lua aspects contain additional keys as defined [[LuaAI#Dynamic_Lua_Aspects|here]]. And composite aspects contain the following additional tags:&lt;br /&gt;
*'''[facet]''': A sub-aspect which will be taken as the value of the aspect, unless its '''turns''' and '''time_of_day''' keys do not match. {{DevFeature1.13|5}} Formerly this had to be a standard aspect, but as of 1.13.5 it can be any type of aspect, such as a composite aspect or a Lua aspect.&lt;br /&gt;
*'''[default]''': A sub-aspect which will specifies the default value of the aspect, which is used if there are no facets or if all facets are inactive. {{DevFeature1.13|5}} Formerly this had to be a standard aspect, but as of 1.13.5 it can be any type of aspect, such as a composite aspect or a Lua aspect. '''Note: Overriding the default aspect is generally not recommended. It's just as easy to simply add an unconditional facet instead.'''&lt;br /&gt;
&lt;br /&gt;
At the toplevel within the [ai] tag, complex aspects are defined by an [aspect] tag containing the various keys and tags that define the aspect. Typically, these toplevel aspects are composite aspects, meaning that they contain facets to specify the actual value of the aspect (though they can easily be changed to Lua aspects {{DevFeature1.13|5}} or standard aspects). The '''id''' attribute in an [aspect] tag ''must'' be a valid aspect name, otherwise it will give an error and be ignored.&lt;br /&gt;
&lt;br /&gt;
Let's try to explain this using the aggression example from above.  If we wanted to define that using the complex aspect syntax, it would look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[ai]&lt;br /&gt;
    [aspect]&lt;br /&gt;
        id=aggression&lt;br /&gt;
        [facet]&lt;br /&gt;
            id=custom_aggression # Can be used to remove this facet later&lt;br /&gt;
            time_of_day=dawn&lt;br /&gt;
            value=0.765&lt;br /&gt;
        [/facet]&lt;br /&gt;
    [/aspect]&lt;br /&gt;
[/ai]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The most important part is that the composite aspect structure uses so-called ''facets'', which contain the value of the aspect.  If the aspect is a single scalar value, such as in this example, that value is assigned using the '''value''' key.  If it is a tag, such as [avoid], the content of the tag is added inside a '''[value]''' tag.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[facet]&lt;br /&gt;
    engine=cpp&lt;br /&gt;
    id=custom_avoid&lt;br /&gt;
    name=standard_aspect&lt;br /&gt;
    [value]&lt;br /&gt;
        terrain=W*&lt;br /&gt;
    [/value]&lt;br /&gt;
[/facet]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That’s it for the most practical purposes, although there a few more parameters in the full aspect configuration:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[aspect]&lt;br /&gt;
    engine=cpp&lt;br /&gt;
    id=aggression&lt;br /&gt;
    invalidate_on_gamestate_change=no&lt;br /&gt;
    invalidate_on_minor_gamestate_change=no&lt;br /&gt;
    invalidate_on_tod_change=yes&lt;br /&gt;
    invalidate_on_turn_start=yes&lt;br /&gt;
    name=composite_aspect&lt;br /&gt;
    [facet]&lt;br /&gt;
        engine=cpp&lt;br /&gt;
        id=&lt;br /&gt;
        invalidate_on_gamestate_change=no&lt;br /&gt;
        invalidate_on_minor_gamestate_change=no&lt;br /&gt;
        invalidate_on_tod_change=yes&lt;br /&gt;
        invalidate_on_turn_start=yes&lt;br /&gt;
        name=standard_aspect&lt;br /&gt;
        time_of_day=dawn&lt;br /&gt;
        turns=&lt;br /&gt;
        value=0.765&lt;br /&gt;
    [/facet]&lt;br /&gt;
    [default]&lt;br /&gt;
        engine=cpp&lt;br /&gt;
        id=custom_aggression&lt;br /&gt;
        invalidate_on_gamestate_change=no&lt;br /&gt;
        invalidate_on_minor_gamestate_change=no&lt;br /&gt;
        invalidate_on_tod_change=yes&lt;br /&gt;
        invalidate_on_turn_start=yes&lt;br /&gt;
        name=standard_aspect&lt;br /&gt;
        time_of_day=dawn&lt;br /&gt;
        turns=&lt;br /&gt;
        value=0.4&lt;br /&gt;
    [/default]&lt;br /&gt;
[/aspect]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the full list of keys and tags inside the [aspect] tag is as follows:&lt;br /&gt;
* '''engine'''=cpp: The engine processing the aspect.  Most often this is 'cpp', which is also the default and can therefore be omitted, but it is also possible to define dynamic Lua aspects.  These have the syntax [[Wesnoth_AI_Framework#Dynamic_Lua_Aspects|shown below]]. (Note: engine=fai is not supported for aspects.)&lt;br /&gt;
* '''id''': This must be set to the aspect name (yes, name) shown at [[AiWML]].&lt;br /&gt;
* '''name'''=composite_aspect: As described above.&lt;br /&gt;
* '''invalidate_on_turn_start'''=&amp;quot;yes&amp;quot;: (boolean) If &amp;quot;yes&amp;quot;, the value of this aspect is invalidated at the start of each AI turn.&lt;br /&gt;
* '''invalidate_on_tod_change'''=&amp;quot;yes&amp;quot;: (boolean) If &amp;quot;yes&amp;quot;, the value of this aspect is invalidated when the absolute time of day bonus changes anywhere on the map.  This implies invalidate_on_turn_start. {{DevFeature1.13|5}} Before 1.13.5, this was not implemented.&lt;br /&gt;
* '''invalidate_on_gamestate_change'''=&amp;quot;no&amp;quot;: (boolean) If &amp;quot;yes&amp;quot;, the value of this aspect is invalidated on each game state change (on turn start, move, attack, recruit, etc.).  This implies invalidate_on_turn_start.&lt;br /&gt;
* '''invalidate_on_minor_gamestate_change'''=&amp;quot;no&amp;quot;: (boolean) If &amp;quot;yes&amp;quot;, the value of this aspect is invalidated on each minor game state change (on set unit variable, etc). This implies invalidate_on_gamestate_change. (Currently this is not implemented.)&lt;br /&gt;
* '''code''': (Lua engine only)  If the aspect is defined dynamically in Lua, this key contains the Lua code to be executed.  See [[Wesnoth_AI_Framework#Dynamic_Lua_Aspects|below]].&lt;br /&gt;
* '''[facet]''' or '''[default]''': These tags define the aspect values.  '''[default]''' contains the default value assigned to the aspect at the start of the game.  It cannot be modified or deleted.  '''[facet]''' tags contain the custom values for the aspect and override the value from [default].  If there are several [facet] tags, the most recent one active at the current time of day and turn number is applied.  The tags contain the following keys:&lt;br /&gt;
** '''engine''': Same as above, overrides the key with same name in the [aspect] tag&lt;br /&gt;
** '''id''': This has a different meaning from the [aspect] tag ''id'' key.  It can be freely chosen and is only needed if you plan to [[Modifying_AI_Components#Modifying_Standard_Aspects|modify or remove]] the aspect at a later time.  If not, the ''id'' can be omitted. Not used in the [default] tag.&lt;br /&gt;
** The different '''invalidation keys''': They have the same meaning as those under the [aspect] tag, but apply only to this facet.&lt;br /&gt;
** '''name''': Possible values include 'standard_aspect' and 'composite_aspect', as described above.  The engine chooses the correct value automatically, so you never have to worry about this unless you're doing something unusual.&lt;br /&gt;
** '''time_of_day''' and '''turns''': Define when the aspect is active.  See [[AiWML#Defining_Aspects_and_Goals_of_the_RCA_AI|here]] for details. Not valid in '''[default]'''.&lt;br /&gt;
** '''value''' or '''[value]''': This, finally, is the actual value the facet returns.  See the examples above for syntax.&lt;br /&gt;
&lt;br /&gt;
All of this is admittedly a bit complex.  This is done because there are a couple aspects which require all these keys and customization functionality.  In the vast majority of cases, you do not have to worry about this and can simply use the ''standard'' aspect syntax of the first two examples.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If unsure, the easiest way to see the full configuration for any given aspect (or any other AI component, in fact) is either in savefiles, or in-game by typing &amp;lt;code&amp;gt;:inspect&amp;lt;/code&amp;gt; in debug mode and choosing 'ai config full' for a team.&lt;br /&gt;
&lt;br /&gt;
==== Some more on the invalidation keys ====&lt;br /&gt;
&lt;br /&gt;
A few of the aspects return a significant amount of information, as opposed to only a single value (such as ''aggression'') or an array of locations (such as ''avoid'').  For example, the [[AiWML#Filtering_Combat_with_the_attacks_Aspect|''attacks'' aspect]] returns a list of possible attacks of the filtered attacker/target unit pairs, together with ratings for many different aspects of these attacks.  This list, originally established at the beginning of the AI turn, is not valid any more after the first attack has been performed and needs to be reset.  The AI does this by &amp;quot;invalidating&amp;quot; the aspect, after which the aspect information is calculated anew the next time the aspect is queried by a candidate action.&lt;br /&gt;
&lt;br /&gt;
If you check out the default values of the invalidation keys, you see that, in the default configuration, information stored about aspects is reevaluated &amp;lt;u&amp;gt;only&amp;lt;/u&amp;gt; at the beginning of each AI turn and when the time of day changes.  It is not reevaluated by default after the game state changes (such as after an attack) during the AI turn.  This works for most aspects, but not for the ''attacks'' aspect (and it might not be sufficient for all custom aspects either).  This is the reason why &amp;lt;code&amp;gt;invalidate_on_gamestate_change=yes&amp;lt;/code&amp;gt; needs to be set explicitly for the ''attacks'' aspect as [[AiWML#Filtering_Combat_with_the_attacks_Aspect|shown here]].&lt;br /&gt;
&lt;br /&gt;
As a final comment, you can see at that link that the ''attacks'' aspect is also an exception in that its configuration and definition do not contain a value key or [value] tag, but '''[filter_own]''' and '''[filter_enemy]''' tags. If you look at the configuration in the inspector, you will also see that it has ''name=ai_default_rca::aspect_attacks'' instead of ''standard_aspect''. In other words, the attacks aspect is never a standard aspect (though it can be a composite or {{DevFeature1.13|5}} Lua aspect).&lt;br /&gt;
&lt;br /&gt;
==== Dynamic Lua Aspects ====&lt;br /&gt;
&lt;br /&gt;
It is also possible to [[LuaAI#Dynamic_Lua_Aspects|define aspects dynamically in Lua]].  In that case, no [default] and [facet] tags are added to the configuration.  They are replaced by the '''code''' key used to define the aspect.  For the second example given at the link above, the configuration looks like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[aspect]&lt;br /&gt;
    code=&amp;lt;&amp;lt;&lt;br /&gt;
        local value = wesnoth.current.turn / 10.&lt;br /&gt;
        return value&lt;br /&gt;
    &amp;gt;&amp;gt;&lt;br /&gt;
    engine=lua&lt;br /&gt;
    id=aggression&lt;br /&gt;
    invalidate_on_gamestate_change=no&lt;br /&gt;
    invalidate_on_minor_gamestate_change=no&lt;br /&gt;
    invalidate_on_tod_change=yes&lt;br /&gt;
    invalidate_on_turn_start=yes&lt;br /&gt;
    name=lua_aspect&lt;br /&gt;
[/aspect]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's also possible to put all of that ''in'' a [facet] tag, rather than in an [aspect] tag – this would allow the Lua aspect to take effect only at certain times of day, for example.&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Goals == &lt;br /&gt;
&lt;br /&gt;
Goals are essentially a special type of aspect, in that they are used to customize the behavior of the default (RCA) AI.  However as [[RCA_AI#RCA_AI_Aspect_and_Goal_Configuration|described here]], the default goals are not stored in configuration files.  Similarly, custom goals are stored in a different format in the AI configuration than the aspects.  Fortunately, this format is the same as that used for [[AiWML#Examples_of_.5Bgoal.5D_Tag_Usage|defining custom goals]].  See the examples given there for syntax.&lt;br /&gt;
&lt;br /&gt;
== The [ai] Tag — Engines == &lt;br /&gt;
&lt;br /&gt;
As stated above, it is not necessary to define engines any more these days.  Just for reference, we list the possible attributes of the [engine] tag here nevertheless.&lt;br /&gt;
&lt;br /&gt;
* '''id''': (string) Optional id of the engine.&lt;br /&gt;
* '''engine'''=cpp: (string) The type of engine used to parse this [engine] config snippet. This will always be cpp, since the lua and fai engines are not equipped for parsing [engine] tags.&lt;br /&gt;
* '''name'''=cpp: (string) Name of the [engine]. Must be a valid engine name (cpp, lua, or fai).&lt;br /&gt;
* '''code''': If &amp;lt;code&amp;gt;name=lua&amp;lt;/code&amp;gt; only.  The Lua code to add to the engine.  See the [[Lua_AI_Legacy_Methods_Howto#Lua_AI_Setup|old method for setting up custom Lua CAs]] for details. It should generally &amp;lt;code&amp;gt;return ...&amp;lt;/code&amp;gt; or similar - if it doesn't, other components using the Lua engine may not be able to function correctly.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Wesnoth AI]]&lt;br /&gt;
* [[AiWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:AI]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=73332</id>
		<title>DirectActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=DirectActionsWML&amp;diff=73332"/>
		<updated>2024-07-28T18:06:01Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [cancel_action] */&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. They can be used inside of [[EventWML|events]].&lt;br /&gt;
&lt;br /&gt;
The following tags are actions:&lt;br /&gt;
&lt;br /&gt;
=== [endlevel] ===&lt;br /&gt;
Ends the scenario.&lt;br /&gt;
* '''result''': before the scenario is over, all events with ''name=result'' are triggered. If ''result=victory'', the player progresses to the next level (i.e., the next scenario in single player); if ''result=defeat'', the game returns to the main menu. &lt;br /&gt;
&lt;br /&gt;
When the result is &amp;quot;victory&amp;quot; the following keys can 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. {{DevFeature1.13|2}} Alternatively, a number, defining the bonus multiple (1.0 meaning full).&lt;br /&gt;
* '''carryover_report''': whether the player should receive a summary of the scenario outcome, the default is carryover_report=yes.&lt;br /&gt;
* '''save''': whether a start-of-scenario save should be created for the next scenario, the default is save=yes. Do not confuse this with saving of replays for the current scenario.&lt;br /&gt;
* '''replay_save''': whether a replay save for the current scenario is allowed, the default is replay_save=yes. If yes, the player's settings in preferences will be used to determine if a replay is saved. If no, will override and not save a replay.&lt;br /&gt;
* '''linger_mode''': If ...=yes, the screen is greyed out and there's the possibility to save before advancing to the next scenario, the default is linger_mode=yes.&lt;br /&gt;
* '''reveal_map''': (Multiplayer only) (Default is 'yes') If 'no', shroud doesn't disappear when game ended.&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;
* '''carryover_percentage''': 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''': if yes the gold will be added to the starting gold the next scenario, if no the next scenario will start with the amount of the current scenario (after taxes) or the minimum in the next scenario. Default is no.&lt;br /&gt;
* '''music''': (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_credits''': Whether to display the credits screen at the end of a single-player campaign. Defaults to ''yes''. 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''': (translatable) 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''': 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;
* &amp;lt;strike&amp;gt;'''[next_scenario_settings]''': Any tags or attribute children of this optional argument to [endlevel] are merged into the scenario/multiplayer tag of the *next* scenario. This allows you to e.g. reconfigure the [side] tags or settings, just before load. &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* &amp;lt;strike&amp;gt;'''[next_scenario_append]''': Any tags of this optional argument are appended at high level to the next scenario. This is most appropriate for [event] tags, although you may find other uses. Example test scenario for these features: https://gna.org/support/download.php?file_id=20119 &amp;lt;/strike&amp;gt; This feature was removed in 1.11.17, it might be redesigned and reintroduced.&lt;br /&gt;
* '''[result]''' {{DevFeature1.13|0}} Allows specification of a side specific result, this is for competitive multiplayer scenarios/campaigns where it might happen that one player wins but another player loses.  The following attributes are accepted and have the same effect as in '''[endlevel]''':&lt;br /&gt;
** '''result'''&lt;br /&gt;
** '''bonus'''&lt;br /&gt;
** '''carryover_percentage'''&lt;br /&gt;
** '''carryover_add'''&lt;br /&gt;
&lt;br /&gt;
And there is also&lt;br /&gt;
** '''side''' The number of the side for which these results should apply.&lt;br /&gt;
&lt;br /&gt;
=== [unit] ===&lt;br /&gt;
Creates a unit (either on the map, on a recall list, or into a variable for later use.)  For syntax see [[SingleUnitWML]].&lt;br /&gt;
* {{Short Note:Predefined Macro|GENERIC_UNIT}}&lt;br /&gt;
&lt;br /&gt;
This tag can also recall an existing unit, which happens when:&lt;br /&gt;
* the '''id=''' attribute is used&lt;br /&gt;
* a unit with that '''id=''' already exists&lt;br /&gt;
* (might be unnecessary) the existing unit is on the side's recall list&lt;br /&gt;
in this case, the unit is recalled at the '''x,y=''' or '''location_id=''' given, and any other data in the tag is ignored.&lt;br /&gt;
&lt;br /&gt;
Campaign authors: a usual way to recall plot-necessary heroes is to use a macro with the data for creating that hero. This helps during debugging, because you can skip to scenarios and the recall-or-create functionality means that any units which are normally met in a previous scenario are automatically created (otherwise some scenarios may be an instant loss). This can only be used for units that must survive the previous scenarios, as it would recreate units if they died in a previous scenario.&lt;br /&gt;
For example,&lt;br /&gt;
[https://github.com/wesnoth/wesnoth/blob/1.14.7/data/campaigns/Heir_To_The_Throne/utils/httt_utils.cfg#L685 HttT's NEED_DELFADOR macro].&lt;br /&gt;
&lt;br /&gt;
=== [recall] ===&lt;br /&gt;
Recalls a unit taking into account any [[SingleUnitWML|filter_recall]] of the leader.   The unit is recalled free of charge, and is placed near its leader, e.g., if multiple leaders are present, near the first found which would be able to normally recall it.&lt;br /&gt;
&lt;br /&gt;
If neither a valid map location is provided nor a leader on the map would be able to recall it, the tag is ignored.&lt;br /&gt;
 &lt;br /&gt;
* [[StandardUnitFilter]]: the first matching unit will be recalled.  If no units match this tag is ignored. Do not use a [filter] tag. If a comma separated list is given, every unit currently considered for recall is checked against all the types (not each single one of the types against all units).&lt;br /&gt;
* '''x,y''': the unit is placed here instead of next to the leader.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to recall to. Used instead of '''x,y'''.&lt;br /&gt;
* '''show''': yes/no, default yes: whether the unit is animated (faded in) or instantly displayed&lt;br /&gt;
* '''fire_event''': boolean yes|no (default no); whether any according prerecall or recall events shall be fired.&lt;br /&gt;
* '''check_passability''': (boolean yes|no, default yes): If yes, checks for terrain passability when placing the unit (a nearby passable hex is chosen).&lt;br /&gt;
* '''[secondary_unit]''': {{DevFeature1.13|?}} If present and show=yes, a matching unit will be chosen and their recruiting animation played.&lt;br /&gt;
&lt;br /&gt;
=== [teleport] ===&lt;br /&gt;
Teleports a unit on map. {{Short Note:Predefined Macro|TELEPORT_UNIT}}&lt;br /&gt;
* '''[filter]''': [[StandardUnitFilter]] the first unit matching this filter will be teleported.&lt;br /&gt;
* '''x,y''': the hex to teleport to. If that hex is occupied, the closest unoccupied hex will be used instead.&lt;br /&gt;
* '''location_id''': {{DevFeature1.15|0}} the name of a special map location to teleport to. Used instead of '''x,y'''.&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;
* '''check_passability''': (boolean yes|no, default yes): normally, units will not be teleported into terrain that is impassable for them. Setting this attribute to &amp;quot;no&amp;quot; permits it.&lt;br /&gt;
&lt;br /&gt;
(Note: There is also a ability named teleport, see [[AbilitiesWML]].)&lt;br /&gt;
&lt;br /&gt;
=== [terrain_mask] ===&lt;br /&gt;
Changes the terrain on the map.  See [[TerrainMaskWML]].&lt;br /&gt;
&lt;br /&gt;
=== [terrain] ===&lt;br /&gt;
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;
* [[StandardLocationFilter]]. This [[StandardLocationFilter]]'s terrain= key is used for the new terrain, filtering by terrain can be done with a nested [[StandardLocationFilter]]: [and]terrain=terrain_string_to_be_filtered_for.&lt;br /&gt;
* '''layer''': (overlay|base|both, default=both) only change the specified layer.&lt;br /&gt;
* '''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;
* '''location_id''': This key sets a string as a way to mark the hex or hexes for later reference.  It is very similar to the leader starting position, and can also be set that way in the map editor.&lt;br /&gt;
&lt;br /&gt;
If you want to remove the overlays from a terrain and leave only the base, use:&lt;br /&gt;
 layer=overlay&lt;br /&gt;
 terrain=&amp;quot;^&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages is that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [gold] ===&lt;br /&gt;
Gives sides 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. Can be a comma-separated list of sides. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [unstore_unit] ===&lt;br /&gt;
Creates a unit from a game variable, and activates it on the playing field or recall list.  This must be a specific variable describing a unit, and may not be an array (if it is, only the first unit will be unstored).&lt;br /&gt;
&lt;br /&gt;
This may be useful in different contexts:&lt;br /&gt;
* To update a unit on the map after having edited its WML. This usage is common, but discouraged - if possible, you should use [[#.5Bmodify_unit.5B|[modify_unit]]] or [[#.5Bobject.5B|[object]]] instead.&lt;br /&gt;
* To place a previously-defined unit into the scenario, if it was directly defined in a WML variable, using [unit] with the key '''to_variable'''. This usage is rather uncommon.&lt;br /&gt;
* To place a unit back into the game that was removed earlier, for example a hero that leaves the party for awhile and then comes back.&lt;br /&gt;
&lt;br /&gt;
The variable is not cleared. To unstore units from an array variable, iterate over the array. See [[VariablesWML]] and [[VariablesWML/How to use variables]] for more information about variable usage. See also [[InternalActionsWML#.5Bstore_unit.5D|[store_unit]]], [[ConditionalActionsWML|For]], [[ConditionalActionsWML#.5Bwhile.5D|[while]]] and [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]].&lt;br /&gt;
&lt;br /&gt;
The tag takes the following keys:&lt;br /&gt;
* '''variable''': This is required to indicate the name of the variable to read the unit from.&lt;br /&gt;
* '''Placement keys''':&lt;br /&gt;
** '''x''' ,'''y''': By default, the unit will be placed at the location specified in the variable, but if these keys are present, the unit will be placed at that location instead. To place the unit on the recall list of its side, use '''x,y=recall,recall'''. (If you want to change the said, you need to first update ''$unit.side'' in the variable before unstoring.)&lt;br /&gt;
** '''location_id''': {{DevFeature1.15|0}} The name of a special map location to unstore to. Used instead of '''x,y'''.&lt;br /&gt;
** '''find_vacant''' (yes|no, default no): 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;
** '''check_passability''' (yes|no, default yes): Only relevant if '''find_vacant=yes'''. In that case, this determines whether game will try to find a passable tile for the unit. If set to no, the unit may be placed on an impassable tile. Note that if both '''find_vacant''' and '''check_passability''' are set, then the unit's position may be shifted even if there is not a unit on the target space, if that space is not passable for the unit.&lt;br /&gt;
* '''Animation keys''' (these determine the visual effect of how the unit is placed or updated):&lt;br /&gt;
** '''text''': (translatable) A floating text to display above the unit, such as a damage amount.&lt;br /&gt;
** '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
** '''red''', '''green''', '''blue''': (default=0,0,0) the color of the text. 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;
** '''animate''': (boolean yes|no, default yes) Determines whether to play any animations associated with the unstore. Currently this only affects the advancement animation (&amp;quot;levelout&amp;quot; and &amp;quot;levelin&amp;quot;, defaulting to a fade to white and back) if the unit ends up advancing.&lt;br /&gt;
* '''Side-effect keys''' (these directly modify the behaviour of the action):&lt;br /&gt;
** '''advance''': (default=yes) if yes the unit is advanced if it has enough XP. When modifying XP, make sure to do it from inside a [[EventWML#Multiplayer_safety|synchronized event]] or it may lead to OOS errors, especially when several advancement paths exist. Note that advance and post advance events are called, so infinite loops can happen.&lt;br /&gt;
** '''fire_event''' (yes|no, default no): Whether any advance/post advance events shall be fired if an advancement takes place. This also affects whether the unit placed event is fired.&lt;br /&gt;
&lt;br /&gt;
Units can be unstored with negative (or zero) hit points. This can be useful if modifying a unit in its last_breath event (as the unit's death is already the next step), but tends to look wrong in other cases. In particular, it is possible to have units with negative hit points in play. Such units are aberrations, subject to unusual behavior as the game compensates for them. (For example, such units are currently automatically hit&amp;amp;mdash;and killed&amp;amp;mdash;in combat.) The details of the unusual behavior are subject to change between stable releases without warning.&lt;br /&gt;
&lt;br /&gt;
=== [allow_recruit] ===&lt;br /&gt;
Allows a side to recruit units it couldn't previously recruit. Any leader on this side will now be able to recruit the new units.&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. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [allow_extra_recruit] ===&lt;br /&gt;
Allows a leader to recruit units it couldn't previously recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[allow_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_recruit] ===&lt;br /&gt;
Prevents a side from recruiting units it could previously recruit. No leader on this side will be able to recruit the specified units anymore, unless that leader has the same unit in their personal '''extra_recruit''' list.&lt;br /&gt;
* '''type''': the types of units that the side can no longer recruit. {{DevFeature1.13|0}} If omitted, all recruits for matching sides will be disallowed.&lt;br /&gt;
* '''side''': (default=1) the number of the side that may no longer recruit the units. This can be a comma-separated list note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_extra_recruit] ===&lt;br /&gt;
Prevents a leader from recruiting units it could previously recruit. This won't prevent the leader from recruiting that unit if the unit is in the '''[side]recruit=''' list – you must use '''[disallow_recruit]''' in that case.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can no longer recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [set_recruit] ===&lt;br /&gt;
Sets the units a side can recruit. Any leader on this side will now be able to recruit these units.&lt;br /&gt;
* '''recruit''': the types of units that the side can now recruit.&lt;br /&gt;
* '''side''': The number of the side that is having its recruitment set. This can be a comma-separated list.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [set_extra_recruit] === &lt;br /&gt;
Sets the units a leader can recruit.&lt;br /&gt;
These types are in addition to the types the leader can recruit because of '''[side]recruit=''' and '''[set_recruit]'''.&lt;br /&gt;
* '''extra_recruit''': the types of units that the leader can now recruit.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': All units matching this filter are modified. Does not match on recall list units.&lt;br /&gt;
&lt;br /&gt;
=== [modify_side] ===&lt;br /&gt;
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. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* '''income''': the income given at the begining of each turn.&lt;br /&gt;
* '''recruit''': a list of unit types, replacing the side's current recruitment list.&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;
* '''side_name''': {{DevFeature1.13|?}} a translatable string representing the side leader's description.&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. warning: in multiplayer, changing the controller of a side might result in OOS during some events like, for example 'side_turn_end'; see [https://github.com/wesnoth/wesnoth/issues/2563 issue #2563].&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;
* '''hidden''': a boolean string specifying whether side is shown in status table.&lt;br /&gt;
* '''color''': a team color range specification, name (e.g. &amp;quot;red&amp;quot;, &amp;quot;blue&amp;quot;), or number (e.g. &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;) for this side. The default color range names, numbers, and definitions can be found in data/core/team_colors.cfg.&lt;br /&gt;
* '''[ai]''': sets/changes AI parameters for the side. Only parameters that are specified in the tag are changed, this does not reset others to their default values. Uses the same syntax as described in [[AiWML]].  Note that [modify_side][ai] works for all simple AI parameters and some, but not all, of the composite ones. If in doubt, use [[AiWML#Adding_and_Deleting_Aspects_with_the_.5Bmodify_ai.5D_Tag|[modify_ai]]]] instead, which always works. {{DevFeature1.13|?}} If this contains an '''ai_algorithm''', the AI parameters will be reset to those of the indicated AI before adding any additional parameters included in the tag. In other words, this allows replacing the AI config rather than appending to it.&lt;br /&gt;
* '''switch_ai''': replaces a side ai with a new AI from specified file(ignoring those AI parameters above). Path to file follows the usual WML convention.&lt;br /&gt;
* '''reset_maps''': If set to &amp;quot;yes&amp;quot;, then the shroud is spread to all hexes, covering the parts of the map that had already been explored by the side, including hexes currently seen. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if shroud is on, but this is evaluated after shroud= (and before shroud_data=).&lt;br /&gt;
* '''reset_view''': If set to &amp;quot;yes&amp;quot;, then the fog of war is spread to all hexes, covering the parts of the map that had already been seen this turn by the side, including hexes currently seen, excluding hexes affected by multi-turn {{tag|DirectActionsWML|lift_fog}}. (Seen hexes will be cleared at the end of most events; they can also be manually cleared with {{tag|InterfaceActionsWML|redraw}}.) This is only effective if fog is on, but this is evaluated after fog=.&lt;br /&gt;
* '''share_maps''': change the share_maps side attribute. Be sure to use shroud=yes for that side and have it as an ally&lt;br /&gt;
* '''share_view''': change the share_view side attribute. Be sure to use fog=yes for that side and have it as an ally&lt;br /&gt;
* '''share_vision''': change both the above at the same time&lt;br /&gt;
* '''shroud_data''': changes to the side's shroud, using the same format as when defining the [side].&lt;br /&gt;
* '''suppress_end_turn_confirmation''': Boolean value controlling whether or not a player is asked for confirmation when skipping a turn.&lt;br /&gt;
* '''scroll_to_leader''': Boolean value controlling whether or not the game view scrolls to the side leader at the start of their turn when present.&lt;br /&gt;
* '''flag''': Flag animation for villages owned by this side (see [[SideWML|[side]]]).&lt;br /&gt;
* '''flag_icon''': Flag icon used for this side in the status bar (see [[SideWML|[side]]]).&lt;br /&gt;
* '''village_support''': The number of unit levels this side is able to support (does not pay upkeep on) per village it controls.&lt;br /&gt;
* '''defeat_condition''' {{DevFeature1.13|0}}: When the side is considered defeated (see [[SideWML|[side]]]).&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the side; uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* '''[variables]''' {{DevFeature1.15|3}} The contents of this tag is merged into the side's variables.&lt;br /&gt;
&lt;br /&gt;
=== [modify_turns] ===&lt;br /&gt;
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;
* '''current''': changes the current turn number after applying turn limit modifications, if any. It is not possible to change the turn number to exceed the turn limit (1 &amp;lt;= current turns &amp;lt;= max turns).&lt;br /&gt;
&lt;br /&gt;
=== [allow_end_turn] ===&lt;br /&gt;
Allows human players to end their turn through the user interface if they were previously affected by the '''[disallow_end_turn]''' action. This action doesn't take any arguments.&lt;br /&gt;
&lt;br /&gt;
=== [disallow_end_turn] ===&lt;br /&gt;
Disallows human players to end their turn through the user interface. This action doesn't require arguments.&lt;br /&gt;
* '''reason''' (translatable): {{DevFeature1.15|0}} Allows to optionally specify a reason.&lt;br /&gt;
&lt;br /&gt;
=== [capture_village] ===&lt;br /&gt;
Changes the ownership of a village.&lt;br /&gt;
* [[StandardLocationFilter]]: all village locations matching the filter are affected.&lt;br /&gt;
* '''side''': the side that takes control of the village. This side needs to have a leader (canrecruit=yes). If the side key is not given, the village will become neutral (unless [filter_side] is present, in which case that side fiter decides, see below).&lt;br /&gt;
* '''[filter_side]''' with [[StandardSideFilter]] tags and keys as arguments; if both this tag and inline side= are present it's an error. Otherwise, the first matching side gets ownership (or the village becomes neutral if none match).&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default: no): Whether any capture events shall be fired.&lt;br /&gt;
&lt;br /&gt;
=== [kill] ===&lt;br /&gt;
Removes all units (including units in a recall list) that match the filter from the game.&lt;br /&gt;
* [[StandardUnitFilter]]: Selection criterion; do not use a [filter] tag.&lt;br /&gt;
* '''animate''' (default 'no'): if 'yes', displays the unit dying (fading away). {{DevFeature1.13|8}} If '''[secondary_unit]''' is given, also plays the victory animation of that unit.&lt;br /&gt;
* '''fire_event''' (default 'no'): if 'yes', triggers any appropriate 'die' events (See [[EventWML]]). Note that events are only fired for killed units that have been on the map (as opposed to recall list).&lt;br /&gt;
* '''[secondary_unit]''' with a [[StandardUnitFilter]] as argument. Do not use a [filter] tag. Has an effect only if fire_event=yes ({{DevFeature1.13|8}} or if it has a victory animation and animate=yes). The first on-map unit matching the filter becomes second_unit in any fired die and last breath events. If an on-map unit matches and if there are several units killed with a single [kill] tag, second_unit is this same unit for all of them. If no on-map unit matches or [secondary_unit] isn't present, the variable second_unit in each of the die and last breath events is always the same as the variable unit (the dying unit).&lt;br /&gt;
* '''[primary_attack]''' {{DevFeature1.13|8}} The attacker's weapon to use for matching the animation. Useful for example on the wose, whose death animation depends on the damage type it was killed by. If a secondary unit is specified, this is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the unit. However, if there is no secondary unit specified, it is instead treated as an [[UnitTypeWML#Attacks|weapon definition]], and the animation will be run as if an imaginary unit possessing that weapon was the attacker.&lt;br /&gt;
* '''[secondary_attack]''' {{DevFeature1.13|8}} Similar to the above, but for the defender's weapon. This is taken as a [[StandardWeaponFilter]] and used to find a matching weapon on the dying unit.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit] ===&lt;br /&gt;
Moves a unit along a path on the map. The path can be specified exactly, or as a series of waypoints that the unit will pass through.&lt;br /&gt;
* [[StandardUnitFilter]] as argument; do not use a [filter] tag. All units matching the filter are moved. If the target location is occupied, the nearest free location is chosen.&lt;br /&gt;
* '''to_x''' (unsigned integer): The units are moved to this x coordinate. Can be a comma-separated list, in which case the unit follows this given path during the move.&lt;br /&gt;
* '''to_y''' (unsigned integer): The units are moved to this y coordinate. Can be a comma-separated list.&lt;br /&gt;
* '''dir''' (string): {{DevFeature1.15|0}} Performs a relative movement instead of an absolute movement. For example, dir=n,n,nw will move two spaces north and then one space to the northwest. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''to_location''': {{DevFeature1.15|0}} Moves matching units to locations placed in the map editor with the &amp;quot;New Location&amp;quot; button. Can be a comma-separated list. This is used instead of '''to_x''' and '''to_y'''.&lt;br /&gt;
* '''check_passability''' (boolean yes|no, default yes): Whether the terrain the unit is moved to should be checked for suiting the unit. (If it does not, a nearby suitable hex is chosen.)&lt;br /&gt;
* '''force_scroll''': Whether to scroll the map or not even when [[InterfaceActionsWML#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to using [[InterfaceActionsWML#.5Bmove_unit_fake.5D|[move_unit_fake]]]'s default value.&lt;br /&gt;
* '''clear_shroud''': {{DevFeature1.15|0}} (boolean yes|no, default no) Whether to remove shroud and fog after the unit was moved, but before events are fired. It will not clear all alongside the path, only around the target destination.&lt;br /&gt;
* '''fire_event''' (boolean yes|no, default no): Whether any according moveto events shall be fired. The target location ($x1, $y1 in the event) may not be the same location that the unit was tried to be moved to, if the original target location is occupied or impassable.&lt;br /&gt;
&lt;br /&gt;
=== [modify_ai] ===&lt;br /&gt;
Changes AI objects (aspects, goals, candidate actions or stages) for a specified side. See [[Modifying_AI_Components#The_.5Bmodify_ai.5D_Tag|Modifying AI Components]] for full description.&lt;br /&gt;
&lt;br /&gt;
* '''action''' (string): Takes values 'add', 'change', 'delete' or 'try_delete' to do just that for the AI object.&lt;br /&gt;
* '''path''' (string): Describes which AI object is to be modified.  &lt;br /&gt;
* '''[facet]''', '''[goal]''', '''[candidate_action]''' or '''[stage]''': Details about the AI object to be modified.&lt;br /&gt;
* [[StandardSideFilter]] tags and keys; default for empty side= is all sides, as usual in a SSF.&lt;br /&gt;
&lt;br /&gt;
=== [modify_unit] ===&lt;br /&gt;
works similar to the MODIFY_UNIT macro.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. All units matching this filter are modified. Matches on recall list units too.&lt;br /&gt;
* '''[object]''', '''[trait]''', {{DevFeature1.13|5}} '''[advancement]''' - The given modifications will be immediately applied to all units matching the filter. ([object] is described further [[#.5Bobject.5D|below]])&lt;br /&gt;
** '''delayed_variable_substitution''' {{DevFeature1.13|5}} (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object], [trait], or [advancement] is not variable-substituted at execution time of the event containing this [modify_unit]. You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
** Do not use a '''[modifications]''' tag, as this may skip some of the special-case handling for newly added objects, traits and advancements, and will potentially overwrite existing modifications.&lt;br /&gt;
* '''[effect]''' {{DevFeature1.13|6}} Applies the effect directly to the unit. See [[EffectWML]].&lt;br /&gt;
* '''[set_variable]''', '''[clear_variable]''' {{DevFeature1.15|3}} Sets or clears a variable within the unit (saved inside the unit's [variables] tag); uses the same syntax as [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] or [[InternalActionsWML#.5Bclear_variable.5D|[clear_variable]]] in ActionWML.&lt;br /&gt;
* Accepts generally the syntax inside of wml unit variables created by [store_unit] which can be viewed in a savefile or by using the [[CommandMode|inspect command]]. Cannot remove things or add/alter unit animations. Subtags with the same name must be written in the correct order to match them with the tag they are supposed to modify. Note that keys will be processed in arbitrary order, which may cause problems if you use formulas that depend on other formulas. To work around this you may need to use the tag twice with the same filter.&lt;br /&gt;
example usage (see also the test scenario):&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[modify_unit]&lt;br /&gt;
  [filter]&lt;br /&gt;
    x,y=38,6&lt;br /&gt;
  [/filter]&lt;br /&gt;
  hitpoints=10&lt;br /&gt;
  {TRAIT_HEALTHY}&lt;br /&gt;
[/modify_unit]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit which is currently modified is accessible via $this_unit, e.g. hitpoints = &amp;quot;$($this_unit.hitpoints / 2)&amp;quot; to set the hitpoints of all units to half of their particular maxima. This this_unit variable is independent from the this_unit variable available in the SUF used to determine which units to modify (first all matching units are gathered, and then all those are modified).&lt;br /&gt;
&lt;br /&gt;
Modifying a unit ''may'' trigger an advancement event if the experience is set higher than the max_experience. However, this behaviour should not be relied upon to happen under all circumstances; if it's desired, the event should be triggered separately, for example with '''[transform_unit]'''.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Some some properties of the units are reset sometimes (for example when the unit advances or when [remove_object] is called), so it's usually better to change them with [object] ([object] inside [modify_unit]) than to change those properties directly via [modify_unit]. The following properties are _not_ reset in [remove_object] and are thus safe to use directly in [modify_unit]:&lt;br /&gt;
* '''side'''&lt;br /&gt;
* '''gender'''&lt;br /&gt;
* '''name'''&lt;br /&gt;
* '''canrecruit'''&lt;br /&gt;
* '''unrenamable'''&lt;br /&gt;
* '''extra_recruit'''&lt;br /&gt;
* '''[variables]'''&lt;br /&gt;
* '''facing'''&lt;br /&gt;
* '''x, y'''&lt;br /&gt;
* '''goto_x, goto_y'''&lt;br /&gt;
* '''hitpoints'''&lt;br /&gt;
* '''experience'''&lt;br /&gt;
* '''moves'''&lt;br /&gt;
* '''[status]'''&lt;br /&gt;
* '''attacks_left'''&lt;br /&gt;
* '''role'''&lt;br /&gt;
&lt;br /&gt;
=== [transform_unit] ===&lt;br /&gt;
Transforms every unit on the map matching the filter to the given unit type. Keeps intact hit points, experience and status. If the unit is transformed to a non-living type (undead or mechanical), it will be also unpoisoned. Hit points will be changed if necessary to respect the transformed unit's maximum hit points. Regardless of anything else, the unit will be rebuilt. Thus, transforming a unit to its current type is a way to force a rebuild, for example after manually removing a modification.&lt;br /&gt;
* [[StandardUnitFilter]]: do not use a [filter] tag.&lt;br /&gt;
* '''transform_to''': the unit type in which all the units matching the filter will be transformed. If missing, the units will follow their normal advancement.&lt;br /&gt;
&lt;br /&gt;
=== [petrify] ===&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are petrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [unpetrify] ===&lt;br /&gt;
* [[StandardUnitFilter]] as an argument. Do not use a [filter] tag. All units matching this filter are unpetrified. Recall list units are included.&lt;br /&gt;
&lt;br /&gt;
=== [object] ===&lt;br /&gt;
Gives some unit an object which modifies their stats in some way. This tag can also be used in places that don't support ActionWML, such as [[#.5Bmodify_unit.5D|[modify_unit]]] or [[SingleUnitWML|[unit][modifications]]]. The following is supported in all these places:&lt;br /&gt;
* '''[effect]''': one or more effect elements may be listed.  See [[EffectWML]] for a description of [effect].&lt;br /&gt;
* '''duration''':&lt;br /&gt;
**if 'scenario', effects only last until the end of the scenario.&lt;br /&gt;
**if 'forever' or not set, effects never wear off.&lt;br /&gt;
** if 'turn', effects only last until the start of the unit's next turn (when the unit refreshes movement and attacks). (Like other start-of-turn behavior, objects with a duration of &amp;quot;turn&amp;quot; won't expire before turn 2.)&lt;br /&gt;
** {{DevFeature1.13|1}} if 'turn end', effects only last until the end of the unit's next turn (exactly like the slowed status).&lt;br /&gt;
* Other keys, such as '''id''', may be used to remove the object later, but are not used by the engine. An '''[object]''' tag can contain any arbitrary data that may be helpful to identify the object to remove later using a [[FilterWML#Filtering_on_WML_data|WML filter]].&lt;br /&gt;
&lt;br /&gt;
The following is supported only when using '''[object]''' as ActionWML:&lt;br /&gt;
* '''id''': (Optional) By default, an object with a defined ID can only be picked up once per scenario, even if it is removed later or first_time_only=no is set for the event. You can remove this restriction by setting take_only_once=no. For filtering objects, it might be simpler to use a custom key such as item_id. The id string can contain only letters, numbers and underscores. The ID is also commonly used to manually remove the object later, for example with [[#.5Bremove_object.5D|[remove_object]]].&lt;br /&gt;
* '''take_only_once''': (default yes) {{DevFeature1.13|6}} If set to &amp;quot;no&amp;quot;, the object's ID does not prevent it from being taken more than once.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean yes|no, default no): If set to &amp;quot;yes&amp;quot;, the wml block contained in this [object] is not variable-substituted at execution time of the event where this [object] is within.  You need this for any effect that uses variable substitution or when using [effect][filter] with a $this_unit. {{DevFeature1.13|9}} This is no longer needed when adding ABILITY_TELEPORT, ABILITY_LEADERSHIP or SPECIAL_BACKSTAB.&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument. The first unit found that matches the filter will be given the object. Only on-map units are considered. If no unit matches or no [filter] is supplied, it tries to apply the object to the unit at the $x1,$y1 location of the event where this [object] is in. The case of no unit being at that spot is handled in the same way as no unit matching a given filter ([else] commands executed, cannot_use_message displayed). Note that units on the recall list will not be checked. To add an [object] to a unit on the recall list you have to use '''[modify_unit][object]'''.&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 '''[remove_item]''' tag, but you could probably put any tags that otherwise work in a [then] tag.&lt;br /&gt;
* '''[else]''': a subtag that lets you execute actions if the filter conditions are *not* met.&lt;br /&gt;
* '''silent''': whether or not messages should be suppressed. Default is &amp;quot;no&amp;quot;. {{DevFeature1.13|2}} If no description is provided, this defaults to yes, but can still be overridden.&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;
* '''description''': (translatable) displayed as a message of the image.&lt;br /&gt;
* '''cannot_use_message''': (translatable) displayed instead of '''description''' if no unit passes the filter test.&lt;br /&gt;
&lt;br /&gt;
=== [remove_object] ===&lt;br /&gt;
{{DevFeature1.13|6}}&lt;br /&gt;
&lt;br /&gt;
Removes an object from matching units.&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching objects removed. Use no [filter] tag.&lt;br /&gt;
* '''object_id''': The id of the object to be removed.&lt;br /&gt;
&lt;br /&gt;
Note that some unit properties are not restored ideally, e.g. current unit's health reversion might not work as expected (max_hitpoints will though). {{DevFeature1.15|0}} This was fixed.&lt;br /&gt;
&lt;br /&gt;
Note that [remove_object] works the following way: &lt;br /&gt;
&lt;br /&gt;
# Remove the object from the unit&lt;br /&gt;
# Rebuild the unit to make the changes effective.&lt;br /&gt;
&lt;br /&gt;
Step 2 implies that changes done for example via [modify_unit] (or via the [store_unit] + [set_variable] + [unstore_unit] technique) will be reset if those changes change a property that is a property of the unit type. See the note under [[#.5Bmodify_unit.5D|[modify_unit]]] to get a list of properties that can safely be changed via [modify_unit].&lt;br /&gt;
&lt;br /&gt;
=== [remove_trait] ===&lt;br /&gt;
{{DevFeature1.15|2}}&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter]]: All units on the map (but not the recall list) matching the filter have matching traits removed. Use no [filter] tag.&lt;br /&gt;
* '''trait_id''': The id of the trait to be removed. See [[UnitsWML#.5Btrait.5D|[trait]]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list of sides. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles for which shroud should be removed&lt;br /&gt;
&lt;br /&gt;
=== [place_shroud] ===&lt;br /&gt;
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. This can be a comma-separated list. note: Default side=1 for empty side= is deprecated.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] as argument&lt;br /&gt;
* [[StandardLocationFilter]]: the range of tiles on which shroud should be placed&lt;br /&gt;
&lt;br /&gt;
=== [lift_fog] ===&lt;br /&gt;
Lifts the fog of war from parts of the map for a certain side (only relevant for sides that have fog=yes), allowing a player to witness what occurs there even if that player has no units within vision range.&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the tiles from which fog should be lifted.&lt;br /&gt;
* '''multiturn''': ''yes/no, default:no''. The default (not multiturn) causes fog to be removed in the same way that normal vision works; the cleared tiles will remain cleared until fog is recalculated (which normally happens when a side ends its turn). When multiturn is set to &amp;quot;yes&amp;quot;, the cleared tiles remain clear until {{tag||reset_fog}} cancels the clearing. This allows tiles to remain clear for multiple turns, or to be refogged before the end of the current turn (without also refogging all tiles). Multiturn lifted fog is not shared with allies (even when share_vision=all).&lt;br /&gt;
&lt;br /&gt;
=== [reset_fog] ===&lt;br /&gt;
The primary use of this tag is to remove multiturn lifted fog (created by {{tag||lift_fog}}), which causes the fog to reset to what it would have been had WML not interfered. (That is, hexes that a side's units could not see at any point this turn will be re-fogged, while seen hexes remain defogged.)&lt;br /&gt;
* '''[filter_side]''' with a [[StandardSideFilter]] indicating which sides should be affected.&lt;br /&gt;
* [[StandardLocationFilter]]: the fog reset will be restricted to these tiles.&lt;br /&gt;
* '''reset_view''': ''yes/no, default: no'' If set to &amp;quot;yes&amp;quot;, then in addition to removing multiturn fog, the side's current view is canceled (independent of the SLF). This means that all hexes will become fogged for the side unless multiturn fog exists outside the tiles selected by the SLF. Normally, one would want the currently seen hexes to become clear of fog; this is done automatically at the end of many events, and it can be done manually with {{tag|InterfaceActionsWML|redraw}}.&lt;br /&gt;
Omitting both the SSF and the SLF would cancel all earlier uses of [lift_fog].&lt;br /&gt;
Additionally setting reset_view=&amp;quot;yes&amp;quot; would cause the side's entire map to be fogged (unless an ally keeps hexes clear by sharing its view).&lt;br /&gt;
&lt;br /&gt;
=== [allow_undo] ===&lt;br /&gt;
Normally when an event with a handler fires, the player's undo stack is cleared, preventing all actions performed so far from being undone. Including this tag in the event handler prevents the stack from being cleared for this reason, allowing the player to undo actions. (However, the stack might still be cleared for other reasons, such as fog being cleared or combat occurring.) In the common cases, this means '''[allow_undo]''' allows the current action to be undone even though an event was handled. There is a less common case, though &amp;amp;mdash; specifically when handling a menu item, where there is no current action &amp;amp;mdash; and in this case, '''[allow_undo]''' means merely that earlier actions can still be undone.&lt;br /&gt;
* Using this tag in a menu item has an additional side effect in 1.11. Starting with version 1.11.1, executing a WML menu item normally counts as doing something as far as the &amp;quot;you have not started your turn yet&amp;quot; dialog is concerned. However, a menu item whose handler includes '''[allow_undo]''' will not count.&lt;br /&gt;
&lt;br /&gt;
The types of actions that can be undone are movement, recalling, and dismissing a unit from the recall list. If an action is undone, only the position (or existence) of the involved unit will be restored; any altered variables or changes to the game will remain changed after the action 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 action the first time.&lt;br /&gt;
* Although recalling can be undone, recruitment can not be undone; this seems to apply even when the recruit's traits are not randomly-generated (tested on 1.12.6 and 1.14.4+dev).&lt;br /&gt;
&lt;br /&gt;
If an '''[event]''' uses both '''[allow_undo]''' and [[InternalActionsWML#.5Bfire_event.5D|'''[fire_event]''']] then the '''[allow_undo]''' must be after the '''[fire_event]'''.&lt;br /&gt;
&lt;br /&gt;
Due to a bug in 1.12 ([http://web.archive.org/web/20170330000414/http://gna.org/bugs/?23323 https://gna.org/bugs/?23323]) '''[allow_undo]''' should not be used in events that use one of the following things because it might cause OOS: &lt;br /&gt;
* [message] with [option]s&lt;br /&gt;
* [get_global_variable]&lt;br /&gt;
* wesnoth.synchronize_choice&lt;br /&gt;
&lt;br /&gt;
While in 1.13 using '''[allow_undo]''' together with those things won't give you a guaranteed OOS, there are some non-obvious situations where it will, for example assume the following event:&lt;br /&gt;
&lt;br /&gt;
   [event]&lt;br /&gt;
     name=&amp;quot;moveto&amp;quot;&lt;br /&gt;
     [message]&lt;br /&gt;
       message = &amp;quot;message&amp;quot;&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 1&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
       [option]&lt;br /&gt;
         label = &amp;quot;option 2&amp;quot;&lt;br /&gt;
         [command]&lt;br /&gt;
         [/command]&lt;br /&gt;
       [/option]&lt;br /&gt;
     [/message]&lt;br /&gt;
     [allow_undo]&lt;br /&gt;
     [/allow_undo]&lt;br /&gt;
   [/event]&lt;br /&gt;
&lt;br /&gt;
It will cause OOS when the message is undone: since the event is already executed (erased) on one client only , the clients will disagree about how many choices happen during the next moveto action.&lt;br /&gt;
&lt;br /&gt;
=== [on_undo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Contains commands to execute when the player undoes the action which triggered the parent event.&lt;br /&gt;
*'''delayed_variable_substitution''' {{DevFeature1.13|5}}: ''yes/no, default no (always no before 1.13.5)'' As in [[EventWML]], specifies whether to perform variable substitution when the parent event is run, or when the contents are run. If delayed substitution is used, [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] from the parent event context are available, but may occasionally have unexpected values. (In particular, $unit.x and $unit.y may not have the expected value when undoing a move event, though $x1 and $y1 should be correct.)&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
It is not clear where whether the actionwml in [on_undo] in executed before or after the action is undone. Also, specially for enter/leave_hex events the units position when executing the [on_undo] code is usually different than when executing the original event. The recommended way to work around these issues is to refer to the unit by id instead of position and store all other needed information variables as 'upvalues'. You can also move the actual undo code to an external event. For example&lt;br /&gt;
 [event]&lt;br /&gt;
   name=&amp;quot;undo_blah&amp;quot;&lt;br /&gt;
   first_time_only=no&lt;br /&gt;
   [store_unit]&lt;br /&gt;
     id=&amp;quot;$moved_unit_id&amp;quot;&lt;br /&gt;
   [/store_unit]&lt;br /&gt;
   ... do undo stuff stuff&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 ... in some other event&lt;br /&gt;
   [on_undo]&lt;br /&gt;
     # store ''upvalues&lt;br /&gt;
     {VARIABLE moved_unit_id $unit.id}&lt;br /&gt;
     # call actual undo handler&lt;br /&gt;
     [fire_event]&lt;br /&gt;
       name = &amp;quot;undo_blah&amp;quot;&lt;br /&gt;
     [/fire_event]&lt;br /&gt;
   [on_undo]&lt;br /&gt;
&lt;br /&gt;
=== [on_redo] ===&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
Same as [on_undo], except executes the commands on redo. Note that the parent event is not triggered again on a redo.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} [on_redo] is deprecated and has no effect anymore.&lt;br /&gt;
&lt;br /&gt;
Note that [on_redo] is not guaranteed to be called when redoing an action, the engine might also decide to just fire the original events again.&lt;br /&gt;
&lt;br /&gt;
=== [cancel_action] ===&lt;br /&gt;
Although Wesnoth 1.12 does not have this tag, it is the default behavior of '''enter_hex'''/'''exit_hex''' [event] in that version.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}} In this version, [cancel_action] is recognised, but has no effect (a bug).&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
In an '''enter_hex'''/'''exit_hex''' [event], interrupt the movement, leaving the unit where it is. This is intended to be used with an event that gives the player new information, to let the player choose whether to change their plans. For example, if the player has commanded a unit to move from (1,1) to (3,3) and attack a unit on (4,4); then a [cancel_action] inside an '''enter_hex''' [event] on (2,2) would make the unit stop on (2,2). A [cancel_action] inside an enter_hex [event] on (3,3) would let the player choose whether to attack.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|0}}&lt;br /&gt;
In a '''capture'''/'''moveto''' [event], interrupt the attack.&lt;br /&gt;
&lt;br /&gt;
=== [heal_unit] ===&lt;br /&gt;
Heal a unit. The variable '''$heal_amount''' will be set to the exact number of points healed (i.e can be less than the parameter '''amount''' if the unit is fully healed). $heal_amount contains only the number of hitpoints the first unit that was found got healed. When the variable is not needed, use {CLEAR_VARIABLE heal_amount} after this tag.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}} The '''$heal_amount''' variable is no longer set. Use the '''variable''' key instead.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] All matching on-map units are healed. If no filter is supplied, it is tried to take the unit at $x1, $y1.&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] all the units matching the filter ''and'' having the ''heals'' ability will have their animation played (if ''animate'' is set to yes) for each of the units healed.&lt;br /&gt;
*  '''amount''': (integer, default full) the maximum points the unit(s) will be healed. This can't be used to set the unit's hitpoints below 1 or above the unit's maximum hitpoints. If &amp;quot;full&amp;quot;, it fully heals the unit.&lt;br /&gt;
*  '''animate''': a boolean which indicate if the healing animations must be played. (default no)&lt;br /&gt;
*  '''moves''': (integer, default 0) The maximum current movement points the units will be &amp;quot;healed&amp;quot;. Can't set below 0 or above max_moves. If &amp;quot;full&amp;quot;, sets moves to max_moves.&lt;br /&gt;
* '''restore_attacks''': (boolean, default no) Whether the units' attacks_left should be reset to their max_attacks (usually 1).&lt;br /&gt;
* '''restore_statuses''': (boolean, default yes) Whether standard statuses should be reset to &amp;quot;no&amp;quot;. This affects poisoned, slowed, petrified and unhealable.&lt;br /&gt;
* '''variable''': {{DevFeature1.17|0}} creates an array with the given name; each item of the array has two fields, ''id='' (the ID of the unit being healed) and ''heal_amount='' (the amount of HPs the unit has been healed by).&lt;br /&gt;
&lt;br /&gt;
=== [harm_unit] ===&lt;br /&gt;
Harms every unit matching the filter, for the specific damage amount. When harming multiple units, the special variable '''$this_unit''' can be used to access the current unit being harmed. This obviously does not work inside the filters though, as they give '''$this_unit''' a different meaning.&lt;br /&gt;
*  '''[filter]''': [[StandardUnitFilter]] all matching units will be harmed (required).&lt;br /&gt;
*  '''[filter_second]''': [[StandardUnitFilter]] if present, the first matching unit will attack all the units matching the filter above.&lt;br /&gt;
*  '''amount''': the amount of damage that will be done (required).&lt;br /&gt;
*  '''alignment''': (default neutral) applies an alignment to the damage, this means that if alignment=chaotic, the damage will be increased at night and reduced at day.&lt;br /&gt;
*  '''damage_type''': if present, amount will be altered by unit resistance to the damage type specified.&lt;br /&gt;
*  '''kill''': (default yes) if yes, when a harmed unit goes to or below 0 HP, it is killed; if no its HP are set to 1.&lt;br /&gt;
*  '''fire_event''': (default no) if yes, when a unit is killed by harming, the corresponding events are fired.  If yes, also the corresponding advance and post advance events are fired.&lt;br /&gt;
*  '''animate''': (default no) if yes, scrolls to each unit before harming it and plays its defense (or attack, if it's the harmer) and death animations. Special values supported, other than the usual yes and no, are &amp;quot;attacker&amp;quot;, that means only the harmer will be animated, and &amp;quot;defender&amp;quot;, that means only the harmed units will be animated. If the supplied value is yes, attacker or defender also advancement animations are played.&lt;br /&gt;
*  '''[primary_attack], [secondary_attack]''': these set the weapon against which the harmed units will defend, and that the harming unit will use to attack, respectively (notice this is the opposite of '''[filter]''' and '''[filter_second]''' above). This allows for playing specific defense and attack animations. Both tags are expected to contain a [[FilterWML#Filtering_Weapons|Standard Weapon Filter]].&lt;br /&gt;
*  '''delay''': if animate=yes, sets the delay (in milliseconds, default 500) between each unit harming.&lt;br /&gt;
*  '''variable''': if present, the damage caused to the unit, altered by resistances, will be stored in a WML array with the given name, under the ''harm_amount='' key. {{DevFeature1.17|0}} Each item of the array also has an ''id='' key, which contains the ID of the unit being harmed.&lt;br /&gt;
*  '''poisoned, slowed, petrified, unhealable''': (default no) if yes, every harmed unit that doesn't already have such status will have it set.&lt;br /&gt;
*  '''experience''': (default yes) If there is a harmer, experience will be attributed similar to regular combat. Can take list of values. When any value is provided, all unspecified experience types default to not giving experience. Supported values: {{DevFeature1.17|25}} until that version only experience=yes and experience=no are supported&lt;br /&gt;
** no - none of involved units get any experience (this value only works if it is the only value in list)&lt;br /&gt;
** kill - the harming unit receives experience based on level of harmed unit in attack which kills harmed unit&lt;br /&gt;
** attack - the harming unit receives experience based on level of harmed unit in attack which does not kill harmed unit, or in attack which kills harmed unit while kill experience is disabled&lt;br /&gt;
** defend - the unit being harmed receives experience based on level of harming unit in attack which does not kill harmed unit&lt;br /&gt;
** fight - short form of experience=attack,defend&lt;br /&gt;
** yes - short form of experience=kill,attack,defend&lt;br /&gt;
*  '''resistance_multiplier''': the harmed unit's resistance is multiplied by the supplied value; this means that a value lower than 1 increases it, and a value greater than 1 decreases it. Default value is 1, that means no modification.&lt;br /&gt;
&lt;br /&gt;
=== [time_area] ===&lt;br /&gt;
How a day should progress in a given area. Everywhere not specified in a [time_area] tag is affected by the [time] tags in the [scenario] tag.&lt;br /&gt;
* [[StandardLocationFilter]]: the locations to affect. ''note: only for [event][time_area]s - at scenario toplevel [time_area] does not support [[StandardLocationFilter]], only location ranges''&lt;br /&gt;
* '''[time]''': one or more tags describing the new schedule, see [[TimeWML]].&lt;br /&gt;
* '''id''': an unique identifier assigned to a time_area. Optional, unless you want to remove the time_area later or reference it from a location filter elsewhere. Can be a comma-separated list when removing time_areas, 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;
* '''current_time''': The time slot number (starting with zero) active at the creation of the area.&lt;br /&gt;
&lt;br /&gt;
''Example:'' (caves in parts of a map)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[time_area]&lt;br /&gt;
    id = cave_area&lt;br /&gt;
    x = 1-2,4-5&lt;br /&gt;
    y = 1-2,1-2&lt;br /&gt;
    {UNDERGROUND}&lt;br /&gt;
[/time_area]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifying an id allows the area to be referenced from location filters. Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
    [time_area]&lt;br /&gt;
        id = glyphs&lt;br /&gt;
        x = 9,14&lt;br /&gt;
        y = 11,3&lt;br /&gt;
    [/time_area]&lt;br /&gt;
    [event]&lt;br /&gt;
        name = moveto&lt;br /&gt;
        first_time_only=no&lt;br /&gt;
        [filter]&lt;br /&gt;
            side = 1&lt;br /&gt;
            [filter_location]&lt;br /&gt;
                area = glyphs&lt;br /&gt;
            [/filter_location]&lt;br /&gt;
        [/filter]&lt;br /&gt;
        # Do something, for example healing the unit&lt;br /&gt;
    [/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [remove_time_area] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
This is a syntactic shortcut for [time_area] remove=.&lt;br /&gt;
* '''id''': Comma-separated list of time area ids to remove.&lt;br /&gt;
&lt;br /&gt;
=== [end_turn] ===&lt;br /&gt;
End the current side's turn. The current event is finished before the turn is ended. Also, if the current event (where the tag appears) has been fired by another event, that event (and the complete stack of other possible parent events) is ended before [end_turn] comes into affect. Also, events following the event stack that fired [end_turn] are not omitted (e.g. [end_turn] is used by a side turn event and a turn refresh event does something afterwards).&lt;br /&gt;
&lt;br /&gt;
=== [replace_map] ===&lt;br /&gt;
&lt;br /&gt;
Replaces the entire map.&lt;br /&gt;
* '''map_data''': Content of a wesnoth map file. (This key used to be just '''map='''.) Example:&lt;br /&gt;
 map_data=&amp;quot;{campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map}&amp;quot;&lt;br /&gt;
* '''map_file''': {{DevFeature1.13|?}} Path to a Wesnoth map file; can be used instead of '''map'''. The file will be loaded when the tag is executed, rather than being embedded wholesale in the preprocessed WML. Example:&lt;br /&gt;
 map_file=campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map&lt;br /&gt;
{{DevFeature1.15|3}} If the file is not found directly, it will be searched for in the [[BinaryPathWML|[binary_path]]]. Assuming a standard campaign or add-on layout, the example above can be replaced by:&lt;br /&gt;
 map_file=01_The_Elves_Besieged.map&lt;br /&gt;
* '''expand''': if 'yes', allows the map size to increase. The expansion direction is currently always bottom-right.&lt;br /&gt;
* '''shrink''': if 'yes', allows the map size to decrease. If the map size is reduced, any units that would no longer be on the map due to its coordinates no longer existing will be put into the recall list.&lt;br /&gt;
Note: When a hex changes from a village terrain to a non-village terrain, and a team owned that village it loses that village. When a hex changes from a non-village terrain to a village terrain and there is a unit on that hex it does not automatically capture the village. The reason for not capturing villages it that there are too many choices to make; should a unit lose its movement points, should capture events be fired. It is easier to do this as wanted by the author in WML.&lt;br /&gt;
&lt;br /&gt;
=== [replace_schedule] ===&lt;br /&gt;
Replace the time of day schedule of the entire scenario.&lt;br /&gt;
* [[TimeWML]]: the new schedule.&lt;br /&gt;
* '''current_time''': The time slot number (starting with zero) active at schedule replacement. ('''NB''': due to https://github.com/wesnoth/wesnoth/issues/5757 this attribute is ignored in versions 1.16.*. The fix was delivered in 1.17.* but wasn't backported due to backward-compatibility requirements)&lt;br /&gt;
&lt;br /&gt;
=== [tunnel] ===&lt;br /&gt;
&lt;br /&gt;
Create a tunnel between some locations, later usable by units to move from source hex to target hex (using the movement cost of unit on the target terrain).&lt;br /&gt;
&lt;br /&gt;
'''Behavior Change as of Wesnoth 1.13.6:''' Vision is now possible (and enabled by default) through tunnels and allied units on the exit hex do not block a tunnel by default any more. This is done in order for moves through tunnels to be consistent with other moves. The previous behavior can still be accomplished by using the new optional keys listed below.&lt;br /&gt;
&lt;br /&gt;
* '''[filter]''': (required) [[StandardUnitFilter]] the units which can use the tunnel. Leave empty for &amp;quot;all units&amp;quot;.&lt;br /&gt;
* '''[source]''': (required) [[StandardLocationFilter]] the source hex(es).&lt;br /&gt;
* '''[target]''': (required) [[StandardLocationFilter]] the target hex(es).&lt;br /&gt;
* '''id''': (optional) identifier for the tunnel, to allow removing.&lt;br /&gt;
* '''remove''': (boolean, default: no)  If yes, removes all defined tunnels with the same ID (then only id= is necessary).&lt;br /&gt;
* '''bidirectional''': (boolean, default: yes) If yes, creates also a tunnel in the other direction. &lt;br /&gt;
* '''always_visible''': (boolean, default: no) If yes, the possible movement of enemies under fog can be seen.&lt;br /&gt;
* '''allow_vision''': (boolean, default: yes) {{DevFeature1.13|6}} If no, vision through a tunnel is not possible. Note that in that case the tunnel cannot be used if the tunnel exit is under shroud (which previously was ''always'' the case).&lt;br /&gt;
* '''pass_allied_units''': (boolean, default: yes) {{DevFeature1.13|6}} If no, allied (including own) units on the exit hex block a tunnel.&lt;br /&gt;
* '''delayed_variable_substitution''' (boolean, default: yes): If yes, the WML block contained in this [tunnel] is not variable-substituted at execution time of the event where this [tunnel] is within. Instead, variables are substituted when the tunnel is used by a unit. See [[EventWML#Nested_Events]]&lt;br /&gt;
&lt;br /&gt;
(Note: The tunnel tag can also be used inside the [[AbilitiesWML|[teleport]]] ability, without remove= and id=).&lt;br /&gt;
&lt;br /&gt;
=== [do_command] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Executes a command, specified using the same syntax as a [command] tag in [[ReplayWML]]. Not all [command]'s are valid: only these are accepted&lt;br /&gt;
&lt;br /&gt;
* [attack]&lt;br /&gt;
* [move]&lt;br /&gt;
* [recruit]&lt;br /&gt;
* [recall]&lt;br /&gt;
* [disband]&lt;br /&gt;
* [fire_event]&lt;br /&gt;
* [lua_ai] {{DevFeature1.13|12}} This has been removed and is replaced with [custom_command]&lt;br /&gt;
&lt;br /&gt;
The tags corresponding to player actions generally use the same codepath as if a player had ordered it. That means for example that only moves that player would be allowed to do are possible, and movement is interrupted when sighting enemy unit.&lt;br /&gt;
&lt;br /&gt;
One purpose of this tag is to allow scripting of noninteractive scenarios -- without a tag like this, this might require elaborate mechanisms to coerce ais in order to test these code paths.&lt;br /&gt;
&lt;br /&gt;
This command should be replay safe if it is either invoked in a synced context, ''or'' invoked in code that is never synced, like AI code, a select event, or a menu item with `synced = false`. However, if you use desynchronized logic ''during'' an event that is otherwise synced, invoking [do_command] based on that desynchronized logic will result in out-of-sync errors during the replay; in this case, you must explicitly synchronize which command to do using something like the lua function wesnoth.sync.evaluate_single.&lt;br /&gt;
&lt;br /&gt;
=== [put_to_recall_list] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}}&lt;br /&gt;
&lt;br /&gt;
Puts a unit to the recall list of its side.&lt;br /&gt;
* '''[[StandardUnitFilter]]''': the unit(s) to get put to the recall list.&lt;br /&gt;
* '''heal''': (default=no) Whether the unit should be refreshed, similar to the unit moving to the recall list at the end of a scenario.&lt;br /&gt;
&lt;br /&gt;
=== [set_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified achievement as completed and shows a popup stating it's been completed. The popup is not shown if the achievement has already been achieved.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
&lt;br /&gt;
=== [set_sub_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|17}}&lt;br /&gt;
&lt;br /&gt;
Sets the specified sub-achievement as completed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''sub_id''': The id of the sub-achievement.&lt;br /&gt;
&lt;br /&gt;
=== [progress_achievement] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|13}}&lt;br /&gt;
&lt;br /&gt;
Progress an achievement by the specified amount, with an optional limit for how far the achievement can be progressed.&lt;br /&gt;
&lt;br /&gt;
* '''content_for''': The [[AchievementsWML#.5Bachievement_group.5D|[achievement_group]]] that this achievement is part of.&lt;br /&gt;
* '''id''': The id of the achievement.&lt;br /&gt;
* '''amount''': The amount to increment the achievement.&lt;br /&gt;
* '''limit''': (optional) Using this attribute will prevent achievements from progressing past this value.&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 [https://www.wesnoth.org/macro-reference.html 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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73290</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73290"/>
		<updated>2024-07-21T23:10:36Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Attacks */ attack_weight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Unit Type ==&lt;br /&gt;
&lt;br /&gt;
Each '''[unit_type]''' tag defines one unit type. (for the use of [unit] to create a unit, see [[SingleUnitWML]])&lt;br /&gt;
&lt;br /&gt;
Unit animation syntax is described in [[AnimationWML]]. In addition to the animation tags described there, the following key/tags are recognized:&lt;br /&gt;
* '''advances_to''': When this unit has ''experience'' greater than or equal to ''experience'', it is replaced by a unit of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by. The special value 'null' says that the unit does not advance but gets an AMLA instead. Can be a comma-separated list of units that can be chosen from upon advancing.&lt;br /&gt;
* '''alignment''': one of lawful/neutral/chaotic/liminal (See [[TimeWML]]). Default is &amp;quot;neutral&amp;quot;.&lt;br /&gt;
* '''attacks''': the number of times that this unit can attack each turn. Default is 1.&lt;br /&gt;
* '''cost''': when a player recruits a unit of this type, the player loses ''cost'' gold. If this would cause gold to drop below 0,  the unit cannot be recruited. Default is 1.&lt;br /&gt;
* '''recall_cost''': {{DevFeature1.13|0}} the default recall cost of units of this type, overriding the recall cost set in scenario [[SideWML|[side]]] tags or the global [[GameConfigWML|[game_config]]] value. Individual units may override this value in [[SingleUnitWML|[unit]]]. A value of -1 is equivalent to not specifying this attribute. {{DevFeature1.15|0}} Units are now recalled for AI sides even if the recall_cost is larger than the unit's worth (essentially its cost, plus potentially a bonus for experience points). In 1.14 and earlier, units were not recalled by the AI in this case even if this was the only recall/recruit action possible to the AI.&lt;br /&gt;
* '''description''': (translatable) the text displayed in the unit descriptor box for this unit. Default 'No description available...'. &lt;br /&gt;
* '''do_not_list''': Not used by the game, but by tools for browsing and listing the unit tree. If this is 'yes', the unit will be ignored by these tools. {{DevFeature1.13|?}} When placing units in debug mode this unit isn't listed (but can still be placed using the :create command). This restriction is lifted in version &amp;lt;b&amp;gt;1.14.3&amp;lt;/b&amp;gt;.&lt;br /&gt;
* '''ellipse''': the ellipse image to display under the unit, which is normally team-colored. Default is &amp;quot;misc/ellipse&amp;quot;. &amp;quot;-nozoc&amp;quot; and &amp;quot;-leader&amp;quot; are automatically appended for units without zone of control and with canrecruit=yes respectively. The [http://www.wesnoth.org/macro-reference.xhtml#IS_HERO IS_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#MAKE_HERO MAKE_HERO]/[http://www.wesnoth.org/macro-reference.xhtml#UNMAKE_HERO UNMAKE_HERO] macros change the ellipse to/back from &amp;quot;misc/ellipse-hero&amp;quot;. Finally, setting this to &amp;quot;none&amp;quot; will cause the unit to not have any ellipses displayed under it regardless of the user's preferences.&lt;br /&gt;
::WARNING: Be aware that setting this to &amp;quot;misc/ellipse-hero&amp;quot; for a unit with canrecruit=yes will result in the ellipse being &amp;quot;misc/ellipse-hero-leader&amp;quot;, which is not a supported combination (it doesn't have a graphic, and will cause error logs that the graphic is missing). This is tracked as bug [https://github.com/wesnoth/wesnoth/issues/6258 6258] on GitHub.&lt;br /&gt;
* '''experience''': When this unit has experience greater than or equal to ''experience'', it is replaced by a unit with 0 experience of the type that the value of ''advances_to'' refers to. All modifications that have been done to the unit are applied to the unit it is replaced by.&lt;br /&gt;
* '''flag_rgb''': usually set by [http://www.wesnoth.org/macro-reference.xhtml#MAGENTA_IS_THE_TEAM_COLOR MAGENTA_IS_THE_TEAM_COLOR]; specifies the colours in the base flag to use for team-colouring the unit, expressed as a colour name (such as magenta) or a comma-separated list of RGB values (in hex format).&lt;br /&gt;
* '''gender''': has a value of either ''male'' or ''female'', and determines which of the keys ''male_names'' and ''female_names''  should be read. When a unit of this type is recruited, it will be randomly assigned a name by the random name generator, which will use these names as a base. If '''gender''' is not specified it defaults to ''male''.&lt;br /&gt;
* '''halo''': an image to place centered on the unit. It is drawn on top of the unit, and on top of surrounding units if the image is larger than one hex. It works similarly to the halo attribute of {{tag|InterfaceActionsWML|item}}, and it can be animated with a comma-separated list of images.&lt;br /&gt;
* '''hide_help''': (yes|no) default=no. Determines if the unit type will appear in the in-game help.&lt;br /&gt;
* '''hitpoints''': the maximum HP that the unit has, and the HP it has when it is created.&lt;br /&gt;
* '''id''': the value of the ''type'' key for units of this type. This is required and must be unique among all [unit_type] tags. An ''id'' must consist only of alphanumerics and spaces (or underscores). ''type'' keys are found in [[SingleUnitWML]] and [[FilterWML]]. For example, id=Drake Flare&lt;br /&gt;
*'''ignore_race_traits''': 'yes' or 'no' (default). Determines whether racial traits (see [[UnitsWML]]) are applied. &lt;br /&gt;
* '''image''': sets the base image of the unit, which is used on the map.&lt;br /&gt;
* '''image_icon''': sets the image used to represent the unit in areas such as the attack dialog and the unit image box in the sidebar. [[ImagePathFunctions#Crop_Function|~CROP]] function can be useful here. You can see Loyalists Paladin as an example.&lt;br /&gt;
* '''level''': the amount of upkeep the unit costs.  After this unit fights, its opponent gains ''level'' experience. See also kill_experience ([[GameConfigWML]]), and leadership ([[AbilitiesWML]]).&lt;br /&gt;
* '''upkeep''': the amount of upkeep the unit costs if it differs from its level.&lt;br /&gt;
* '''movement''': the number of move points that this unit receives each turn.&lt;br /&gt;
* '''movement_type''': See [[UnitsWML#.5Bmovetype.5D|movetype]]. Note that the tags '''[movement_costs]''', '''[vision_costs]''', '''[defense]''', and '''[resistance]''' can be used to modify this movetype.&lt;br /&gt;
* '''name''': (translatable) displayed in the Status Table for units of this type.&lt;br /&gt;
* '''num_traits''': the number of traits that units of this type should receive when they are recruited, overriding the value set in the [race] tag.&lt;br /&gt;
* '''profile''': the portrait image to use for this unit type. You can also set a portrait for an individual unit instead of the whole unit type (see [[SingleUnitWML]]). The engine first looks for the image in the transparent subdirectory and if found that image is used. If not found it will use the image as-is. Depending on the size the engine will or will not scale the image, the cutoff currently is at 300x300. For images which should only be shown on the right side in the dialog append ~RIGHT() to the image.&lt;br /&gt;
** If &amp;quot;unit_image&amp;quot; is given instead of a filename, uses the unit's base image as the portrait (in the same manner that unit types without portraits do by default).&lt;br /&gt;
** If &amp;quot;none&amp;quot; is given instead of a filename, no image will be displayed.&lt;br /&gt;
* '''small_profile''': the image to use when a smaller portrait is needed than the one used for messages (e.g., in the help system). When this attribute is missing, the value of the '''profile''' attribute is used instead. When present, the heuristic for finding a transparent portrait is disabled for the '''profile''' attribute, so the correct '''profile''' should be set too. If '''profile''' is not present, '''small_profile''' is ignored. Note that image modifiers are allowed; they might be useful for cropping and rescaling a portrait:&lt;br /&gt;
 small_profile=&amp;quot;portraits/elves/transparent/marksman+female.png~CROP(0,20,380,380)~SCALE(205,205)&amp;quot;&lt;br /&gt;
 profile=&amp;quot;portraits/elves/transparent/marksman+female.png&amp;quot;&lt;br /&gt;
* '''race''': See {{tag|UnitsWML|race}}.  Also used in standard unit filter (see [[FilterWML]]). Mainline Wesnoth features following values:  bats, drake, dwarf, elf, falcon, goblin, gryphon, human, dunefolk, lizard, mechanical, merman, monster, naga, ogre, orc, troll, undead, wolf, wose. They are defined in /data/core/units.cfg.&lt;br /&gt;
* '''undead_variation''': When a unit of this type is killed by a weapon with the plague special, this variation is applied to the new plague unit that is created, whatever its type. For example, if the plague special creates Walking Corpses and undead_variation is set to &amp;quot;troll&amp;quot;, you'll get a troll Walking Corpse. Defaults to the undead_variation set in this unit type's race.&lt;br /&gt;
* '''usage''': the way that the AI should recruit this unit, as determined by the scenario designer. (See ''recruitment_pattern'', [[AiWML]]).  The following are conventions on usage:&amp;lt;br&amp;gt; ** ''scout'': Fast, mobile unit meant for exploration and village grabbing.&amp;lt;br&amp;gt; ** ''fighter'': Melee fighter, melee attack substantially more powerful than ranged.&amp;lt;br&amp;gt; ** ''archer'': Ranged fighter, ranged attack substantially more powerful than melee.&amp;lt;br&amp;gt; ** ''mixed fighter'': Melee and ranged fighter, melee and ranged attacks roughly equal.&amp;lt;br&amp;gt; ** ''healer'': Specialty 'heals' or 'cures'.&amp;lt;br&amp;gt;Note that this field primarily affects recruitment.  It also has a small effect on unit movement (the AI tries to keep scouts away from enemies, to some extent).  It does not affect the AI's behavior in combat; that is always computed from attack power and hitpoints. Non-standard usages may be used as well.&lt;br /&gt;
* '''vision''': the number of vision points to calculate the unit's sight range. Defaults to ''movement'' if not present.&lt;br /&gt;
* '''jamming''': the number of jamming points. Defaults to ''0'' if not present. See [[UnitsWML#.5Bmovetype.5D|[jamming_costs]]]&lt;br /&gt;
* '''zoc''': if &amp;quot;yes&amp;quot; the unit will have a zone of control regardless of level.  If present but set to anything other than &amp;quot;yes,&amp;quot; the unit will have no zone of control.  If the tag is omitted, zone of control is dictated by unit level (level 0 = no zoc, level 1+ = has zoc).&lt;br /&gt;
* '''die_sound''': sets the sound, which is used when the unit dies.&lt;br /&gt;
* '''healed_sound''': sets the sound used when the unit is healed in any way (default: heal.wav).&lt;br /&gt;
* '''hp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''xp_bar_scaling''': Overrides the attribute in ([[GameConfigWML]]).&lt;br /&gt;
* '''bar_offset_x''', '''bar_offset_y''': The offset of the hp and xp bars from the normal bar position of 72x72 unit sprite.&lt;br /&gt;
&lt;br /&gt;
== After max level advancement (AMLA) ==&lt;br /&gt;
* '''[advancement]''': describes what happens to a unit when it reaches the XP required for advancement.  It is considered as an advancement in the same way as advancement described by '''advances_to'''; however, if the player chooses this advancement, the unit will have one or more effects applied to it instead of advancing.&lt;br /&gt;
** '''id''': unique identifier for this advancement; ''Required'' if there are multiple advancement options, or if ''strict_amla=no''.&lt;br /&gt;
** '''always_display''': if set to true displays the AMLA option even if it is the only available one.&lt;br /&gt;
** '''description''': a description displayed as the option for this advancement if there is another advancement option that the player must choose from; otherwise, the advancement is chosen automatically and this key is irrelevant.&lt;br /&gt;
** '''image''': an image to display next to the description in the advancement menu.&lt;br /&gt;
** '''max_times''': default 1.  The maximum times the unit can be awarded this advancement. Pass -1 for &amp;quot;unlimited&amp;quot;.&lt;br /&gt;
** '''strict_amla''':  (yes|no) default=no. Disable the AMLA if the unit can advance to another unit.&lt;br /&gt;
** '''major_amla''': (yes|no) default=no. Sets whether the unit's XP bar is blue(=yes) or purple(=no). In case of more [advancement] tags, if there is one with major_amla=yes, the XP bar will be blue.&lt;br /&gt;
** '''require_amla''': An optional list of AMLA ''id'' keys that act as prerequisites for this advancement to become available.  Order is not important, and an AMLA id can be repeated any number of times to indicate that another advancement must be chosen several times before this advancement option will become available.&lt;br /&gt;
*** example: &amp;lt;tt&amp;gt;require_amla=tough,tough,incr_damage&amp;lt;/tt&amp;gt; assumes there exist other [advancement] options called ''id=tough'' and ''id=incr_damage''.  Once ''tough'' is chosen twice and ''incr_damage'' is chosen once, then the current [advancement] will become available.&lt;br /&gt;
*** ''require_amla=tough,incr_damage,tough'' is an equivalent way of expressing this.&lt;br /&gt;
** '''exclude_amla''': {{DevFeature1.13|2}} An optional list of AMLA ''id'' keys that represent AMLAs that are mutually exclusive to this one. Order is not important, and an AMLA id can be repeated. If the unit already has any of the AMLAs that appear once in this list, then this AMLA will not be made available. If an AMLA id appears multiple times in the list, then this AMLA will be made available only if the other AMLA has been chosen less than the number of times it appears in the list. Of course, for this to really make two AMLAs mutually exclusive, you need to add ''exclude_amla'' to both AMLA defintions.&lt;br /&gt;
** '''[effect]''': A modification applied to the unit whenever this advancement is chosen.  See [[EffectWML]]&lt;br /&gt;
** '''[filter]''': A  [[StandardUnitFilter]],  the advancement will only be available when the unit passes this filter during the time the advancement dialog is shown.&lt;br /&gt;
&lt;br /&gt;
== Attacks ==&lt;br /&gt;
* '''[attack]''': one of the unit's attacks.&lt;br /&gt;
** '''description''': a translatable text for name of the attack, to be displayed to the user.&lt;br /&gt;
** '''name''': the name of the attack. Used as a default description, if ''description'' is not present, and to determine the default icon, if ''icon'' is not present (see below).  Non-translatable.  Used for the ''has_weapon'' key and animation filters; see [[StandardUnitFilter]] and [[AnimationWML]]&lt;br /&gt;
** '''type''': the damage type of the attack.  Used in determining resistance to this attack (see {{tag|UnitsWML|movetype|resistance}}). Usually this is one of ''blade'', ''pierce'', ''impact'', ''fire'', ''cold'', or ''arcane'', but it can be set to anything (as long as it contains only letters, numbers, and underscores). When using a custom type, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom damage type in the sidebar, the game will look for a file called icons/profiles/''type''.png under your addon's images folder. For example, the icon for a damage type called ''electric'' would be at images/icons/profiles/electric.png.&lt;br /&gt;
** '''[specials]''': contains the specials of the attack. See [[AbilitiesWML#The_.5Bspecials.5D_tag|AbilitiesWML]].&lt;br /&gt;
** '''icon''': the image to use as an icon for the attack in the attack choice menu, as a path relative to the images directory. Defaults to the attack's name in the attacks directory (Ex. if ''name=sword'' then default is ''icon=attacks/sword.png''). &lt;br /&gt;
** '''range''': the range of the attack.  Used to determine the enemy's retaliation, which will be of the same type. The range can be anything (as long as it contains only letters, numbers, and underscores), but the standard values are ''melee'' and ''ranged''. Units can only retaliate against attacks for which they have a corresponding attack of the same range. When using a custom range, you will need to set its user-visible name using [[LanguageWML]]. {{DevFeature1.15|0}} When showing the icon for a custom range in the sidebar the game will look for a file called icons/profiles/''range''_attack.png under your addon's images folder. For example, the icon for a range called ''very_long'' would be at images/icons/profiles/very_long_attack.png.&lt;br /&gt;
** '''damage''': the damage of this attack&lt;br /&gt;
** '''number''': the number of strikes per attack this weapon has&lt;br /&gt;
** '''accuracy''': a number added to the chance to hit whenever using this weapon offensively (i.e. during a strike with this attack, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''parry''': a number deducted from the enemy chance to hit whenever using this weapon defensively (i.e. during the enemy's strike, regardless of who initiated the combat); negative values work too&lt;br /&gt;
** '''movement_used''': determines how many movement points using this attack expends. By default all movement is used up, set this to 0 to make attacking with this attack expend no movement.&lt;br /&gt;
** '''attacks_used''': {{DevFeature1.17|12}} determines how many attacks this attack expends (default 1). This number is deducted from the unit's &amp;lt;tt&amp;gt;attacks_left&amp;lt;/tt&amp;gt; when they use this attack.&lt;br /&gt;
** '''attack_weight''': multiplier for total damage that the AI should use to choose which attack to use when attacking (and offer to player as default). Setting it to 0 disables the attack on attack. Until {{DevFeature1.19|2}} positive attack_weight was ignored.&lt;br /&gt;
** '''defense_weight''': used to determine which attack is used for retaliation. This affects gameplay, as the player is not allowed to determine his unit's retaliation weapon. Setting it to 0 disable the attacks on defense.&lt;br /&gt;
&lt;br /&gt;
== Other tags ==&lt;br /&gt;
* {{anchor|base_unit|'''[base_unit]'''}}: Contains one attribute, '''id''', which must be the ID of a unit type.  If specified, the UnitTypeWML for that unit is copied into this one, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Additionally, the unit will be marked as variation of the base unit in its own help page, but not in the help page of the base unit.&lt;br /&gt;
&lt;br /&gt;
* '''[abilities]''': Defines the abilities of a unit. See [[AbilitiesWML]]&lt;br /&gt;
&lt;br /&gt;
* '''[event]''': Any [event] written inside the [unit_type] tag will get included into any scenario where a unit of this type appears in. Note that such events get included when a unit of this type first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[EventWML]] and [[WML_Abilities]]&lt;br /&gt;
&lt;br /&gt;
* {{anchor|variation|'''[variation]'''}}: Defines a variation of a unit. Variations are invoked with an [effect] tag or the variation= attribute in [[SingleUnitWML]]. They are currently used for graphical variations (giving character sprites new weapons) but theoretically you could do anything with it.&lt;br /&gt;
** '''variation_id''': Mandatory. The value of '''variation=''' used in SingleUnitWML to choose this variant.&lt;br /&gt;
** '''variation_name''': Translatable. The name of the variation, which is displayed in the help and in debug mode. Not setting this looks bad unless combined with '''hide_help'''=yes.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to no.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All keys and tags of '''[unit_type]''', except ''[advancefrom]'', ''[base_unit]'', ''[female]'', ''[male]'', and ''[variation]''.&lt;br /&gt;
&lt;br /&gt;
* '''[male]''', '''[female]''': These can specify a variation based on gender for a unit. If these are provided, they will automatically apply based upon the gender of a unit.&lt;br /&gt;
** '''inherit''': if ''yes'', inherits all the properties of the base unit, as if by [[InternalActionsWML#.5Bset_variables.5D|[set_variables]mode=merge]]. Defaults to yes.&lt;br /&gt;
*** The '''id''' key is always inherited, regardless of the value of '''inherit'''.&lt;br /&gt;
** All '''[unit_type]''' tags and keys, excluding ''[advancefrom]'', ''[base_unit]'', ''[female]'', and ''[male]''.&lt;br /&gt;
* '''[trait]''': Adds an additional trait to the pool. See [[UnitsWML]] for the syntax.&lt;br /&gt;
* '''[special_note]''' {{DevFeature1.15|2}} see [[UnitTypeWML#Special_Notes|below]].&lt;br /&gt;
&lt;br /&gt;
== Special Notes ==&lt;br /&gt;
&lt;br /&gt;
Use of the '''[special_note]''' tags and attributes results in a bulleted list of special notes in the unit type's help page and in the sidebar tooltip for the unit type's name. Prior to 1.15.2, the old format for special notes was simply text included in the '''[unit_type]description''' attribute.&lt;br /&gt;
&lt;br /&gt;
Note that the sidebar tooltip shows the notes for the current unit, but opening the help-browser by right-clicking on a unit shows the notes for generic units of that type. These can be different if the unit has '''[modifications]'''.&lt;br /&gt;
&lt;br /&gt;
Text given in the following attributes will be collected and shown as the special notes for units and unit types:&lt;br /&gt;
&lt;br /&gt;
* {{DevFeature1.15|2}} [unit_type][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|2}} [unit][special_note]note= (these are used ''instead of'' any defined in the [unit_type])&lt;br /&gt;
* {{DevFeature1.15|14}} [movetype][special_note]note=&lt;br /&gt;
* {{DevFeature1.15|14}} [''ability tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [attack][specials][''special tag name'']special_note=&lt;br /&gt;
* {{DevFeature1.15|14}} [language]special_note_damage_type_''TYPE''=&lt;br /&gt;
    &lt;br /&gt;
It's no longer necessary to put these notes in each unit_type's .cfg file, and the macros for doing so are now deprecated.&lt;br /&gt;
&lt;br /&gt;
== Removed keys ==&lt;br /&gt;
&lt;br /&gt;
These don't work any more, the documentation is left here as an aid to porting old code.&lt;br /&gt;
&lt;br /&gt;
* {{anchor|advancefrom|'''[advancefrom]'''}}: {{DevFeature1.15|4}} replaced by [[ModificationWML|[modify_unit_type]]]. Defines the previous unit type on the advancement tree. Allows a campaign-specific unit to be spliced into an already existing advancement tree.  It should generally be used only inside a campaign ifdef, to prevent changes to other campaigns. Since all multiplayer content shares MULTIPLAYER define, using advancefrom changes unit type even if the addon is not actively used. For that reason multiplayer advancefrom may only be used with unit types defined in the same addon - then everyone who has the unit has it with same advancements.  This tag makes changes to the ''advances_to'' and ''experience'' keys of a base unit to make it advance into this unit.  It takes these keys:&lt;br /&gt;
** ''unit'': the id of the base unit from which this unit advances.  This adds the unit into the list of units which ''unit'' can advance into.&lt;br /&gt;
** ''experience'': (optional) If present the experience needed to advance is set to this value. If there are more than one [advancefrom] tags referencing the same base unit within the same preprocessor scope (e.g. a campaign #ifdef) with experience= keys, the lowest value of these is chosen.  Note: this will also lower the experience required to advance to other units which the base unit can advance into.&lt;br /&gt;
: If the previous unit type makes use of '''[male]''' and/or '''[female]''' tags, then the current (new) unit type is expected to also. That is, the subtypes defined by those tags will only receive this advancement if the new type has a corresponding tag.&lt;br /&gt;
{{DevFeature1.15|4}} '''[advancefrom]''' was effectively removed in 1.15.4. The intention was to deprecate it, but  the compatibility code that was meant to support it in 1.16 was untested and nonfunctional.&lt;br /&gt;
&lt;br /&gt;
== Deprecating units ==&lt;br /&gt;
&lt;br /&gt;
A macro is provided for deprecating a unit, which uses the built-in deprecation system but hard-codes the level to 3 (meaning &amp;quot;for removal&amp;quot;). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;{DEPRECATED_UNIT old_id new_id version}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also set the new_id to an empty string if there is no replacement.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[AnimationWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
* [[TerrainWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=73213</id>
		<title>InterfaceActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=73213"/>
		<updated>2024-07-10T13:40:47Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [message] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Interface actions ==&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], interface actions are actions that do not have a direct 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;
== [inspect] ==&lt;br /&gt;
This user interface instantly displays the gamestate inspector dialog at the current scenario state (the same one that can be brought up with [[CommandMode|the ''':inspect''' command]]), which can be used to inspect the values of WML variables, AI configuration, recall lists, and more.&lt;br /&gt;
&lt;br /&gt;
* '''name''': optional attribute to specify the name of this gamestate inspector dialog. It is just a label to help differentiate between different invocations of gamestate inspector dialog.&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. Do not use a [filter] tag. 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 id 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;
* '''male_message''', '''female_message''': {{DevFeature1.13|2}} (translatable) Used instead of ''message'' if the unit's gender matches. Never used if there is no unit (ie ''speaker=narrator''). {{DevFeature1.13|6}} This matches the primary unit, not the secondary unit.&lt;br /&gt;
* '''wait_description''': {{DevFeature1.13|2}} the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]).&lt;br /&gt;
* '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
* '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number.&lt;br /&gt;
* '''image''': (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side. &lt;br /&gt;
** {{DevFeature1.13|0}} &amp;lt;b&amp;gt;none:&amp;lt;/b&amp;gt; display no image&lt;br /&gt;
* '''mirror''': {{DevFeature1.13|5}}whether to mirror the image specified by the '''image''' attribute.&lt;br /&gt;
* '''second_image''': {{DevFeature1.13|6}}same as the '''image''' attribute, but the image is displayed on the right of the message text. {{DevFeature1.17|7}}not working anymore, but there is plan to fix it eventually https://github.com/wesnoth/wesnoth/issues/8770&lt;br /&gt;
* '''second_mirror''': {{DevFeature1.13|6}}same as '''mirror''', but for the '''second_image''' attribute.&lt;br /&gt;
* '''image_pos''': {{DevFeature1.13|5}} whether to show the image on the left or right; supercedes the use of ~RIGHT() described above&lt;br /&gt;
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors.&lt;br /&gt;
* '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''.&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Boolean specifying whether to highlight the speaker. Defaults to ''yes''.&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;
* '''voice''', '''male_voice''', '''female_voice''': {{DevFeature1.13|?}} a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for '''message'''. They are never used when the speaker is the narrator - only '''voice''' is used in that case.&lt;br /&gt;
* {{anchor|message-option|'''[option]'''}}: No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events''&lt;br /&gt;
** '''message''': (translatable) the text displayed for the option. {{DevFeature1.15|1}} This is now a synonym for '''description='''.&lt;br /&gt;
** '''image''', '''label''', '''description''', '''default''': See [[DescriptionWML#WML_Format|DescriptionWML]].&lt;br /&gt;
** '''value''': {{DevFeature1.13|?}} Gives the option a value to be stored in a variable.&lt;br /&gt;
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
** '''[command]''': an element containing actions which are executed if the option is selected.&lt;br /&gt;
* '''variable''': {{DevFeature1.13|?}} If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has '''[show_if]''' condition evaluated as false, then it is hidden and excluded from the indexing.&lt;br /&gt;
* {{anchor|message-text_input|'''[text_input]'''}}: there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events''&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_length''': 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;
* Check [[EventWML#Multiplayer_safety]] to find out in which events you can safely use '''[option]''' and '''[text_input]''' without causing OOS.&lt;br /&gt;
&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
'''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [https://docs.gtk.org/Pango/pango_markup.html#pango-markup Pango markup formatting codes].&lt;br /&gt;
&lt;br /&gt;
Prefer to use single quotes (') instead of double quotes (&amp;quot;) within the formatting string, as double quotes would need to be escaped in WML (&amp;quot;&amp;quot;). Escaping markup can be done with [https://github.com/wesnoth/wesnoth/blob/9daa10a9f27c5a95520e871417bbd72aa52aa688/src/font/pango/escape.hpp#L38-L42 HTML entities].&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to write &amp;quot;You are victorious!&amp;quot; in large, italic, gold letters, you might write it this way:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;span color='#BCB088' size='large' font-style='italic'&amp;gt;You are victorious!&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are the codes taken from the Pango markup formatting guide:&lt;br /&gt;
&lt;br /&gt;
*'''font''', '''font_desc''': A font description string, such as &amp;quot;Sans Italic 12&amp;quot;.&lt;br /&gt;
*'''font_family''', '''face''': A font family name.&lt;br /&gt;
*'''font_size''', '''size''': Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.&lt;br /&gt;
*'''font_style''', '''style''': One of 'normal', 'oblique', 'italic'.&lt;br /&gt;
*'''font_weight''', '''weight''': One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.&lt;br /&gt;
*'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'.&lt;br /&gt;
*'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.&lt;br /&gt;
*'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's [https://github.com/GNOME/pango/blob/main/tools/rgb.txt rgb.txt] file.&lt;br /&gt;
*'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''underline''': One of 'none', 'single', 'double', 'low', 'error'.&lt;br /&gt;
*'''underline_color''': The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''rise''': Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.&lt;br /&gt;
*'''strikethrough''': 'true' or 'false' whether to strike through the text.&lt;br /&gt;
*'''strikethrough_color''': The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'&lt;br /&gt;
*'''fallback''': 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.&lt;br /&gt;
*'''letter_spacing''': Inter-letter spacing in 1024ths of a point.&lt;br /&gt;
*'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'.&lt;br /&gt;
*'''gravity_hint''': One of 'natural', 'strong', 'line'.&lt;br /&gt;
&lt;br /&gt;
The following pango attributes are also available directly as attributes of the '''[message]''' tag:&lt;br /&gt;
{{DevFeature1.13|4}}&lt;br /&gt;
&lt;br /&gt;
*'''font'''&lt;br /&gt;
*'''font_family'''&lt;br /&gt;
*'''font_size'''&lt;br /&gt;
*'''font_style'''&lt;br /&gt;
*'''font_weight'''&lt;br /&gt;
*'''font_variant'''&lt;br /&gt;
*'''font_stretch'''&lt;br /&gt;
*'''color'''&lt;br /&gt;
*'''bgcolor'''&lt;br /&gt;
*'''underline'''&lt;br /&gt;
*'''underline_color'''&lt;br /&gt;
*'''rise'''&lt;br /&gt;
*'''strikethrough'''&lt;br /&gt;
*'''strikethrough_color'''&lt;br /&gt;
*'''fallback'''&lt;br /&gt;
*'''letter_spacing'''&lt;br /&gt;
*'''gravity'''&lt;br /&gt;
*'''gravity_hint'''&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;
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. note: There are side-specific objectives and default objectives, which are used in case a side doesn't have specific ones. Specifying 0 sets the default ones.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Sets the objectives of all matching sides to these passed specifications (the rest of this [objectives] tag). If no sides (such as when passing side=0) or all sides match, sets the default objectives, and the side specific ones for the matching sides otherwise.&lt;br /&gt;
* '''bullet''': Default '• '. Replaces the default bullet, with whatever is passed, for all objectives, gold carryover notes, and notes defined with [note].&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. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''defeat_string''': Default ' _ &amp;quot;Defeat:&amp;quot;', this text precedes the defeat objectives. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''gold_carryover_string''': Default ' _ &amp;quot;Gold carryover:&amp;quot;', this text precedes the gold carryover information.&lt;br /&gt;
* '''notes_string''': Default ' _ &amp;quot;Notes:&amp;quot;', this text precedes the notes.&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;
* '''delayed_variable_substitution''': {{DevFeature1.13|8}} If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed.&lt;br /&gt;
&lt;br /&gt;
Tags of '''[objectives]''':&lt;br /&gt;
* {{anchor|objectives-objective|'''[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;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block.&lt;br /&gt;
** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255' for winning objectives, '0' for losing objectives. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''description''': text for the specific win or loss condition.&lt;br /&gt;
** '''caption''': a text which will be displayed above the ''description''. This can be used to display a subcategory of objectives below ''victory_string'' or ''defeat_string''.&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;
** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no.&lt;br /&gt;
** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only, or when manually opening the scenario objectives.&lt;br /&gt;
* {{anchor|objectives-gold_carryover|'''[gold_carryover]'''}}: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives].&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '192'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned.&lt;br /&gt;
** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned.&lt;br /&gt;
** '''[show_if]''': {{DevFeature1.13|11}} Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at '''[show_objectives]''' time only.&lt;br /&gt;
* {{anchor|objectives-note|'''[note]'''}}: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key.&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire note, including the bullet.&lt;br /&gt;
** '''blue''': Default '255'. Overrides the default blue coloring of the entire note, including the bullet.&lt;br /&gt;
** '''description''': the text of the note.&lt;br /&gt;
** '''[show_if]''': The note will not be shown if the specified condition isn't met. Conditional notes are refreshed at '''[show_objectives]''' time only.&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. The menu items can be set and modified during any event, for example during &amp;quot;start&amp;quot; or &amp;quot;prestart&amp;quot; events. The user can also assign hotkeys to these WML commands unless specified otherwise. When the hotkey is pressed the event will be fired/filtered at the current mouse position.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth.&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. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters.&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, defaults to &amp;quot;buttons/WML-custom.png&amp;quot;&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. {{DevFeature1.13|6}} ''needs_select=yes'' is deprecated, consider using manual variable syncing with [sync_variable].&lt;br /&gt;
* '''synced''' {{DevFeature1.13|1}}: if ''no'' (default ''yes'') the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with ''synced=no'' will cause OOS&lt;br /&gt;
* '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. &lt;br /&gt;
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) 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 [[StandardLocationFilter]] similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations.&lt;br /&gt;
* '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:&lt;br /&gt;
** '''key''': a string that contains the key to assign to this.&lt;br /&gt;
** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''':  boolean values.&lt;br /&gt;
** '''repeat_on_hold''' {{DevFeature1.13|12}}: if ''yes'' (default ''no''), holding the hotkey will repeat the action continuously, unless it blocks input with something like '''[message]'''. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.&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;
** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item.&lt;br /&gt;
&lt;br /&gt;
== [clear_menu_item] ==&lt;br /&gt;
&lt;br /&gt;
Removes a menu item from the scenario.&lt;br /&gt;
Normally menu items are, including all their defining wml, automatically carried over between scenarios. This tag prevents this. (The behavior is comparable to set_variable/clear_variable).&lt;br /&gt;
* '''id''': (string): id of the menu item to clear. Can be a comma-separated list.&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;
&lt;br /&gt;
=== [change_theme] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Change the current interface theme.&lt;br /&gt;
&lt;br /&gt;
* '''theme''': The ID of the new theme. Use &amp;lt;code&amp;gt;theme=&amp;lt;/code&amp;gt; (empty key) to switch back to the theme that the player has selected in Preferences. On &amp;lt;b&amp;gt;1.14.2&amp;lt;/b&amp;gt; and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine).&lt;br /&gt;
&lt;br /&gt;
=== [item] ===&lt;br /&gt;
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. (only for [event][item]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ImagePathFunctions#Blit_Function|BLIT]] the image onto &amp;lt;tt&amp;gt;misc/blank-hex.png&amp;lt;/tt&amp;gt; (a blank 72x72 image).)''&lt;br /&gt;
* '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image (https://github.com/wesnoth/wesnoth/issues/1219).&lt;br /&gt;
* '''name''' an id that can be used to remove the item.&lt;br /&gt;
''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100''&lt;br /&gt;
or equivalently (requires Wesnoth 1.11.2+):&lt;br /&gt;
''halo=scenery/fire[1~8].png:100''&lt;br /&gt;
* '''team_name''': 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. {{DevFeature1.15|0}} In 1.14 the '''[side]team_name''' attribute was expected to be a substring of this '''team_name'''. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* '''visible_in_fog''': whether the item should be visible through fog or not. Default yes.&lt;br /&gt;
* '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items.&lt;br /&gt;
* '''[filter_team]''': {{DevFeature1.15|0}} A [[StandardSideFilter]]. Set '''team_name''' to the union of all '''[side]team_name''' attributes of all sides that match the SSF. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* {{DevFeature1.15|0}} If both '''team_name''' and '''[filter_team]''' are set, '''team_name''' is ignored.&lt;br /&gt;
&lt;br /&gt;
=== [remove_item] ===&lt;br /&gt;
Removes any graphical items on a given hex.&lt;br /&gt;
* [[StandardLocationFilter]]: the hexes to remove items from&lt;br /&gt;
* '''image''': if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any [[ImagePathFunctions|image path functions]] appended to the original image name.)&lt;br /&gt;
&lt;br /&gt;
=== [print] ===&lt;br /&gt;
Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered.&lt;br /&gt;
* '''text''': (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one.&lt;br /&gt;
* '''size''': (default=12) the pointsize of the font to use&lt;br /&gt;
* '''duration''': the length of time to display the text for.&lt;br /&gt;
** (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms.&lt;br /&gt;
** {{DevFeature1.15|4}} This is measured in milliseconds. Don't use the default value, because it's a mere 50ms.&lt;br /&gt;
** {{DevFeature1.15|14}} The default is 5000 milliseconds.&lt;br /&gt;
** {{DevFeature1.15|14}} The string '''unlimited''' displays the text until it's removed by another [print] tag.&lt;br /&gt;
* '''color''': (default '''0,0,0''') three comma-separated values giving the red, green and blue values (0-255).&lt;br /&gt;
* '''red''', '''green''', '''blue''': deprecated, use color=0,0,0 instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit_fake] ===&lt;br /&gt;
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;
* '''gender''': the gender of the fake unit. Example: gender=female&lt;br /&gt;
* '''variation''': the variation of the fake unit. Example: variation=undead&lt;br /&gt;
* '''image_mods''': [[ImagePathFunctions|image path functions]] sequence to be applied on the fake unit.&lt;br /&gt;
* '''force_scroll''':  Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_units_fake] ===&lt;br /&gt;
moves multiple images of units along paths on the map. These units are moved in lockstep.&lt;br /&gt;
* '''force_scroll''': {{DevFeature1.15|0}} Has the same meaning as in [move_unit_fake] but a different default.&lt;br /&gt;
* '''[fake_unit]''': A fake unit to move&lt;br /&gt;
** '''type''': the type of 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;
** '''skip_steps''': the number of steps to skip before this unit starts moving&lt;br /&gt;
&lt;br /&gt;
=== [hide_unit] ===&lt;br /&gt;
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit.&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will be hidden&lt;br /&gt;
&lt;br /&gt;
=== [unhide_unit] ===&lt;br /&gt;
Stops the currently hidden units from being hidden.&lt;br /&gt;
* [[StandardUnitFilter]]: Only the matching units will be unhidden&lt;br /&gt;
&lt;br /&gt;
=== [lock_view] ===&lt;br /&gt;
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game.&lt;br /&gt;
&lt;br /&gt;
This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally.&lt;br /&gt;
&lt;br /&gt;
=== [unlock_view] ===&lt;br /&gt;
Unlocks gamemap view scrolling for human players.&lt;br /&gt;
&lt;br /&gt;
=== [scroll] ===&lt;br /&gt;
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;
* '''side''': the side or sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to] ===&lt;br /&gt;
Scroll to a given hex&lt;br /&gt;
* [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex being scrolled to (defaults to ''no'').&lt;br /&gt;
* '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to_unit] ===&lt;br /&gt;
Scroll to a given unit&lt;br /&gt;
* [[StandardUnitFilter]]; do not use a [filter] subtag.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex the unit is on (defaults to ''no'').&lt;br /&gt;
* '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
* '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [select_unit] ===&lt;br /&gt;
Selects a given unit.&lt;br /&gt;
* [[StandardUnitFilter]]: The first unit found will be selected.&lt;br /&gt;
* '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.)&lt;br /&gt;
* '''highlight''': whether the unit's current hex should be highlighted (def. ''yes'').&lt;br /&gt;
&lt;br /&gt;
'''Note:''' fire_event does not appear to work in 1.14 or 1.16.&lt;br /&gt;
&lt;br /&gt;
=== [sound]===&lt;br /&gt;
Plays a sound&lt;br /&gt;
* '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly.&lt;br /&gt;
* '''repeat''': repeats the sound for a specified additional number of times (default=0)&lt;br /&gt;
&lt;br /&gt;
=== [sound_source] ===&lt;br /&gt;
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 ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are fogged&lt;br /&gt;
* '''check_shrouded''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are shrouded&lt;br /&gt;
* '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source&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;
&lt;br /&gt;
=== [story] ===&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Shows the story screen.&lt;br /&gt;
* '''title''': Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title.&lt;br /&gt;
* '''[part]''', '''[if]''', '''[switch]''', '''[wml_message]''', '''[deprecated_message]''' : See [[IntroWML]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_sound_source] ===&lt;br /&gt;
Removes a previously defined sound source.&lt;br /&gt;
* '''id''': the identification key of the sound source to remove&lt;br /&gt;
&lt;br /&gt;
=== [music] ===&lt;br /&gt;
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;
&lt;br /&gt;
=== [volume] ===&lt;br /&gt;
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100:  &lt;br /&gt;
* '''music''':  Changes the music volume.&lt;br /&gt;
* '''sound''':  Changes the sound volume.&lt;br /&gt;
&lt;br /&gt;
=== [color_adjust] ===&lt;br /&gt;
Adjust the color tint of terrain, by adjusting time-of-day coloring.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color&lt;br /&gt;
&lt;br /&gt;
=== [screen_fade] ===&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from 0 to 255, the final overlay color (defaults to 0,0,0)&lt;br /&gt;
* '''alpha''': value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen.&lt;br /&gt;
* '''duration''': the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate.&lt;br /&gt;
&lt;br /&gt;
=== [delay] ===&lt;br /&gt;
Pauses the game.&lt;br /&gt;
* '''time''': the time to pause in milliseconds&lt;br /&gt;
* '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game.&lt;br /&gt;
&lt;br /&gt;
=== [redraw] ===&lt;br /&gt;
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;
* '''clear_shroud''' (boolean yes|no, default no): If yes, clears fog and shroud around existing units. 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;
* '''[[StandardSideFilter]]''': the sides for which to recalculate fog and shroud.&lt;br /&gt;
* '''side''': If used (forces clear_shroud=yes), clears fog and shroud for that side.&lt;br /&gt;
&lt;br /&gt;
=== [unit_overlay] ===&lt;br /&gt;
Sets an image that will be drawn over a particular unit, and follow it around&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter])&lt;br /&gt;
* '''image''': the image to place on the unit&lt;br /&gt;
* '''object_id''': object id to use, defaults to the '''image''' key with an &amp;quot;overlay_&amp;quot; prefix; this allows using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']]&lt;br /&gt;
* '''duration''': object duration&lt;br /&gt;
&lt;br /&gt;
=== [remove_unit_overlay] ===&lt;br /&gt;
Removes a particular overlayed image from a unit&lt;br /&gt;
* [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter])&lt;br /&gt;
* '''image''': the image to remove from the unit&lt;br /&gt;
* '''object_id''': object id to use&lt;br /&gt;
Using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271&lt;br /&gt;
&lt;br /&gt;
=== [animate_unit] ===&lt;br /&gt;
Uses an 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 custom animation in the unit description (see the '''[extra_anim]''' description in [[AnimationWML]]). Standard animations can be triggered with the following keywords: ''leading recruited standing idling levelout levelin healing healed poisoned movement defend attack death victory pre_teleport post_teleport''&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument, 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. Takes a weapon filter as argument, see [[FilterWML]].&lt;br /&gt;
* '''[secondary_attack]''': Similar to '''[primary_attack]'''. May be needed to trigger a defense animation correctly, if there are more than one animations available for the defending unit.&lt;br /&gt;
* '''hits''': yes/no/hit/miss/kill: which according variation of a attack/defense animation shall be chosen (required)&lt;br /&gt;
* '''text''': a text to hover during the animation &lt;br /&gt;
* '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
* '''red''': red value for the text color (0-255)&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''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar)&lt;br /&gt;
* '''[animate]''': a sub block with the same syntax as '''[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 hex the unit should be facing when animated&lt;br /&gt;
&lt;br /&gt;
=== [label] ===&lt;br /&gt;
Places a label on the map.&lt;br /&gt;
* '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''text''': what the label should say. If you put an empty string &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location.&lt;br /&gt;
* '''team_name''': if specified, the label will only be visible to the given team.&lt;br /&gt;
* '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255.&lt;br /&gt;
* '''visible_in_fog''': whether the label should be visible through fog or not. Default yes.&lt;br /&gt;
* '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no.&lt;br /&gt;
* '''immutable''': whether this label is protected from being removed or changed by players. Default yes.&lt;br /&gt;
* '''category''': the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox.&lt;br /&gt;
* '''tooltip''': A tooltip visible when mouseovering the hex the label is on&lt;br /&gt;
* '''side''': the number of the side that placed the label. Can be 0 for labels placed by WML.&lt;br /&gt;
&lt;br /&gt;
=== [floating_text]===&lt;br /&gt;
Floats text (similar to the damage and healing numbers) on the given locations.&lt;br /&gt;
* [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units).&lt;br /&gt;
* '''text''': the text to display.&lt;br /&gt;
&lt;br /&gt;
The default text color is &amp;lt;span style=&amp;quot;color: #6b8cff;&amp;quot;&amp;gt;'''#6b8cff'''&amp;lt;/span&amp;gt;. To change the color, use [[#Formatting|Pango markup]]. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Float some golden yellow text at 20,20.&lt;br /&gt;
[floating_text]&lt;br /&gt;
   x,y=20,20&lt;br /&gt;
   text=&amp;quot;&amp;lt;span color='#cccc33'&amp;gt;&amp;quot; + _ &amp;quot;Your text here&amp;quot; + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
[/floating_text]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [deprecated_message] ===&lt;br /&gt;
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;
* '''level''': {{DevFeature1.13|10}} The deprecation level, a number from 1 to 3.&lt;br /&gt;
* '''what''': {{DevFeature1.13|10}} The name of the thing being deprecated. Use this instead of '''message''' if possible; a stock message will be generated from it. Use '''message''' only if more information is required; it will be appended to the stock message. This should not be translatable&lt;br /&gt;
* '''version''': {{DevFeature1.13|10}} For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does ''not'' indicate the version in which it became deprecated. &lt;br /&gt;
&lt;br /&gt;
The meanings of the deprecation levels are as follows:&lt;br /&gt;
&lt;br /&gt;
# Deprecated, but will only be removed if absolutely necessary. The '''version''' key is ignored.&lt;br /&gt;
# It will be removed no earlier than a specified version.&lt;br /&gt;
# It will be removed in the next stable version&lt;br /&gt;
# It has already been removed, leaving just a stub to inform users of how to update their code.&lt;br /&gt;
&lt;br /&gt;
Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The '''message''' can be translatable, but does not need to be.&lt;br /&gt;
&lt;br /&gt;
=== [wml_message] ===&lt;br /&gt;
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. 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;
* '''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;
&lt;br /&gt;
Note: As of 1.9.4/1.9.5 (r48805) the following &amp;quot;loggers&amp;quot; should work: If in [wml_message]: err/error, warn/wrn/warning, debug/dbg; using the :log command: Only the long forms error, warning, info and debug (this part gathered by trying rather than source inspecting). The long forms are most likely also the only ones working when starting wesnoth with --log-&amp;lt;level&amp;gt;=wml.&lt;br /&gt;
For log level warning or error (as during normal play), only wml_messages with logger error or warning display (for both). With logger info or debug, additionally wml_messages with logger info or debug display (for both).&lt;br /&gt;
&lt;br /&gt;
=== [test_condition] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why.&lt;br /&gt;
&lt;br /&gt;
* '''result''': Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass.&lt;br /&gt;
* '''logger''': Same as for [wml_message]. Defaults to &amp;quot;warning&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [open_help] ===&lt;br /&gt;
Opens the in-game help.&lt;br /&gt;
* '''topic''': the id of the topic to open&lt;br /&gt;
&lt;br /&gt;
Examples of ids:&lt;br /&gt;
* unit_Mage&lt;br /&gt;
* unit_Dark Adept&lt;br /&gt;
* weaponspecial_charge&lt;br /&gt;
* terrain_human_castle&lt;br /&gt;
&lt;br /&gt;
The engine will print the topic ids if run from the command line with the ''--log-debug=help'' option.&lt;br /&gt;
&lt;br /&gt;
=== [show_objectives] ===&lt;br /&gt;
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.)&lt;br /&gt;
* '''side''': the side to show the objectives. If not set, all sides are used.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Tag affects the matching sides instead of just all or the one given by the integer value of the side= key.&lt;br /&gt;
&lt;br /&gt;
=== [chat] ===&lt;br /&gt;
Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: [[LuaWML:Display#wesnoth.message]]. {{DevFeature1.13|9}} can be visible for observers.&lt;br /&gt;
* '''speaker''': (default=&amp;quot;WML&amp;quot;) A string for the name of the sender of the message.&lt;br /&gt;
* '''message''': The message that should be displayed.&lt;br /&gt;
* '''observable''' (boolean yes|no, default yes): {{DevFeature1.13|9}} Whether the message is displayed for observers.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once.&lt;br /&gt;
&lt;br /&gt;
=== [zoom] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map.&lt;br /&gt;
&lt;br /&gt;
* '''factor''': The new zoom factor, measured as a multiple of the base zoom.&lt;br /&gt;
* '''relative''': If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no.&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;
* '''{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;
* '''{QUAKE &amp;lt;soundfile&amp;gt;}''' Creates a tremor-like screenshake and plays &amp;lt;soundfile&amp;gt;. For example, '''{QUAKE (rumble.ogg)}'''.&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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=73212</id>
		<title>InterfaceActionsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=InterfaceActionsWML&amp;diff=73212"/>
		<updated>2024-07-09T20:32:52Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* [message] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Interface actions ==&lt;br /&gt;
&lt;br /&gt;
Part of [[ActionWML]], interface actions are actions that do not have a direct 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;
== [inspect] ==&lt;br /&gt;
This user interface instantly displays the gamestate inspector dialog at the current scenario state (the same one that can be brought up with [[CommandMode|the ''':inspect''' command]]), which can be used to inspect the values of WML variables, AI configuration, recall lists, and more.&lt;br /&gt;
&lt;br /&gt;
* '''name''': optional attribute to specify the name of this gamestate inspector dialog. It is just a label to help differentiate between different invocations of gamestate inspector dialog.&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. Do not use a [filter] tag. 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 id 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;
* '''male_message''', '''female_message''': {{DevFeature1.13|2}} (translatable) Used instead of ''message'' if the unit's gender matches. Never used if there is no unit (ie ''speaker=narrator''). {{DevFeature1.13|6}} This matches the primary unit, not the secondary unit.&lt;br /&gt;
* '''wait_description''': {{DevFeature1.13|2}} the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]).&lt;br /&gt;
* '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
* '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number.&lt;br /&gt;
* '''image''': (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side. &lt;br /&gt;
** {{DevFeature1.13|0}} &amp;lt;b&amp;gt;none:&amp;lt;/b&amp;gt; display no image&lt;br /&gt;
* '''mirror''': {{DevFeature1.13|5}}whether to mirror the image specified by the '''image''' attribute.&lt;br /&gt;
* '''second_image''': {{DevFeature1.13|6}}same as the '''image''' attribute, but the image is displayed on the right of the message text. {{DevFeature1.17|7}}not supported anymore&lt;br /&gt;
* '''second_mirror''': {{DevFeature1.13|6}}same as '''mirror''', but for the '''second_image''' attribute.&lt;br /&gt;
* '''image_pos''': {{DevFeature1.13|5}} whether to show the image on the left or right; supercedes the use of ~RIGHT() described above&lt;br /&gt;
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors.&lt;br /&gt;
* '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''.&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Boolean specifying whether to highlight the speaker. Defaults to ''yes''.&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;
* '''voice''', '''male_voice''', '''female_voice''': {{DevFeature1.13|?}} a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for '''message'''. They are never used when the speaker is the narrator - only '''voice''' is used in that case.&lt;br /&gt;
* {{anchor|message-option|'''[option]'''}}: No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events''&lt;br /&gt;
** '''message''': (translatable) the text displayed for the option. {{DevFeature1.15|1}} This is now a synonym for '''description='''.&lt;br /&gt;
** '''image''', '''label''', '''description''', '''default''': See [[DescriptionWML#WML_Format|DescriptionWML]].&lt;br /&gt;
** '''value''': {{DevFeature1.13|?}} Gives the option a value to be stored in a variable.&lt;br /&gt;
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]])&lt;br /&gt;
** '''[command]''': an element containing actions which are executed if the option is selected.&lt;br /&gt;
* '''variable''': {{DevFeature1.13|?}} If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has '''[show_if]''' condition evaluated as false, then it is hidden and excluded from the indexing.&lt;br /&gt;
* {{anchor|message-text_input|'''[text_input]'''}}: there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events''&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_length''': 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;
* Check [[EventWML#Multiplayer_safety]] to find out in which events you can safely use '''[option]''' and '''[text_input]''' without causing OOS.&lt;br /&gt;
&lt;br /&gt;
=== Formatting ===&lt;br /&gt;
'''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [https://docs.gtk.org/Pango/pango_markup.html#pango-markup Pango markup formatting codes].&lt;br /&gt;
&lt;br /&gt;
Prefer to use single quotes (') instead of double quotes (&amp;quot;) within the formatting string, as double quotes would need to be escaped in WML (&amp;quot;&amp;quot;). Escaping markup can be done with [https://github.com/wesnoth/wesnoth/blob/9daa10a9f27c5a95520e871417bbd72aa52aa688/src/font/pango/escape.hpp#L38-L42 HTML entities].&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to write &amp;quot;You are victorious!&amp;quot; in large, italic, gold letters, you might write it this way:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;lt;span color='#BCB088' size='large' font-style='italic'&amp;gt;You are victorious!&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are the codes taken from the Pango markup formatting guide:&lt;br /&gt;
&lt;br /&gt;
*'''font''', '''font_desc''': A font description string, such as &amp;quot;Sans Italic 12&amp;quot;.&lt;br /&gt;
*'''font_family''', '''face''': A font family name.&lt;br /&gt;
*'''font_size''', '''size''': Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.&lt;br /&gt;
*'''font_style''', '''style''': One of 'normal', 'oblique', 'italic'.&lt;br /&gt;
*'''font_weight''', '''weight''': One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.&lt;br /&gt;
*'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'.&lt;br /&gt;
*'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.&lt;br /&gt;
*'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's [https://github.com/GNOME/pango/blob/main/tools/rgb.txt rgb.txt] file.&lt;br /&gt;
*'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''underline''': One of 'none', 'single', 'double', 'low', 'error'.&lt;br /&gt;
*'''underline_color''': The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'.&lt;br /&gt;
*'''rise''': Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.&lt;br /&gt;
*'''strikethrough''': 'true' or 'false' whether to strike through the text.&lt;br /&gt;
*'''strikethrough_color''': The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'&lt;br /&gt;
*'''fallback''': 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.&lt;br /&gt;
*'''letter_spacing''': Inter-letter spacing in 1024ths of a point.&lt;br /&gt;
*'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'.&lt;br /&gt;
*'''gravity_hint''': One of 'natural', 'strong', 'line'.&lt;br /&gt;
&lt;br /&gt;
The following pango attributes are also available directly as attributes of the '''[message]''' tag:&lt;br /&gt;
{{DevFeature1.13|4}}&lt;br /&gt;
&lt;br /&gt;
*'''font'''&lt;br /&gt;
*'''font_family'''&lt;br /&gt;
*'''font_size'''&lt;br /&gt;
*'''font_style'''&lt;br /&gt;
*'''font_weight'''&lt;br /&gt;
*'''font_variant'''&lt;br /&gt;
*'''font_stretch'''&lt;br /&gt;
*'''color'''&lt;br /&gt;
*'''bgcolor'''&lt;br /&gt;
*'''underline'''&lt;br /&gt;
*'''underline_color'''&lt;br /&gt;
*'''rise'''&lt;br /&gt;
*'''strikethrough'''&lt;br /&gt;
*'''strikethrough_color'''&lt;br /&gt;
*'''fallback'''&lt;br /&gt;
*'''letter_spacing'''&lt;br /&gt;
*'''gravity'''&lt;br /&gt;
*'''gravity_hint'''&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;
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. note: There are side-specific objectives and default objectives, which are used in case a side doesn't have specific ones. Specifying 0 sets the default ones.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Sets the objectives of all matching sides to these passed specifications (the rest of this [objectives] tag). If no sides (such as when passing side=0) or all sides match, sets the default objectives, and the side specific ones for the matching sides otherwise.&lt;br /&gt;
* '''bullet''': Default '• '. Replaces the default bullet, with whatever is passed, for all objectives, gold carryover notes, and notes defined with [note].&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. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''defeat_string''': Default ' _ &amp;quot;Defeat:&amp;quot;', this text precedes the defeat objectives. Can be set to &amp;quot;&amp;quot; too.&lt;br /&gt;
* '''gold_carryover_string''': Default ' _ &amp;quot;Gold carryover:&amp;quot;', this text precedes the gold carryover information.&lt;br /&gt;
* '''notes_string''': Default ' _ &amp;quot;Notes:&amp;quot;', this text precedes the notes.&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;
* '''delayed_variable_substitution''': {{DevFeature1.13|8}} If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed.&lt;br /&gt;
&lt;br /&gt;
Tags of '''[objectives]''':&lt;br /&gt;
* {{anchor|objectives-objective|'''[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;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block.&lt;br /&gt;
** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255' for winning objectives, '0' for losing objectives. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''description''': text for the specific win or loss condition.&lt;br /&gt;
** '''caption''': a text which will be displayed above the ''description''. This can be used to display a subcategory of objectives below ''victory_string'' or ''defeat_string''.&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;
** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no.&lt;br /&gt;
** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only, or when manually opening the scenario objectives.&lt;br /&gt;
* {{anchor|objectives-gold_carryover|'''[gold_carryover]'''}}: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives].&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''blue''': Default '192'. Overrides the default blue coloring of the entire objective, including the bullet.&lt;br /&gt;
** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned.&lt;br /&gt;
** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned.&lt;br /&gt;
** '''[show_if]''': {{DevFeature1.13|11}} Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at '''[show_objectives]''' time only.&lt;br /&gt;
* {{anchor|objectives-note|'''[note]'''}}: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key.&lt;br /&gt;
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block.&lt;br /&gt;
** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet.&lt;br /&gt;
** '''green''': Default '255'. Overrides the default green coloring of the entire note, including the bullet.&lt;br /&gt;
** '''blue''': Default '255'. Overrides the default blue coloring of the entire note, including the bullet.&lt;br /&gt;
** '''description''': the text of the note.&lt;br /&gt;
** '''[show_if]''': The note will not be shown if the specified condition isn't met. Conditional notes are refreshed at '''[show_objectives]''' time only.&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. The menu items can be set and modified during any event, for example during &amp;quot;start&amp;quot; or &amp;quot;prestart&amp;quot; events. The user can also assign hotkeys to these WML commands unless specified otherwise. When the hotkey is pressed the event will be fired/filtered at the current mouse position.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth.&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. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters.&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, defaults to &amp;quot;buttons/WML-custom.png&amp;quot;&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. {{DevFeature1.13|6}} ''needs_select=yes'' is deprecated, consider using manual variable syncing with [sync_variable].&lt;br /&gt;
* '''synced''' {{DevFeature1.13|1}}: if ''no'' (default ''yes'') the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with ''synced=no'' will cause OOS&lt;br /&gt;
* '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. &lt;br /&gt;
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) 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 [[StandardLocationFilter]] similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations.&lt;br /&gt;
* '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:&lt;br /&gt;
** '''key''': a string that contains the key to assign to this.&lt;br /&gt;
** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''':  boolean values.&lt;br /&gt;
** '''repeat_on_hold''' {{DevFeature1.13|12}}: if ''yes'' (default ''no''), holding the hotkey will repeat the action continuously, unless it blocks input with something like '''[message]'''. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.&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;
** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item.&lt;br /&gt;
&lt;br /&gt;
== [clear_menu_item] ==&lt;br /&gt;
&lt;br /&gt;
Removes a menu item from the scenario.&lt;br /&gt;
Normally menu items are, including all their defining wml, automatically carried over between scenarios. This tag prevents this. (The behavior is comparable to set_variable/clear_variable).&lt;br /&gt;
* '''id''': (string): id of the menu item to clear. Can be a comma-separated list.&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;
&lt;br /&gt;
=== [change_theme] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Change the current interface theme.&lt;br /&gt;
&lt;br /&gt;
* '''theme''': The ID of the new theme. Use &amp;lt;code&amp;gt;theme=&amp;lt;/code&amp;gt; (empty key) to switch back to the theme that the player has selected in Preferences. On &amp;lt;b&amp;gt;1.14.2&amp;lt;/b&amp;gt; and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine).&lt;br /&gt;
&lt;br /&gt;
=== [item] ===&lt;br /&gt;
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. (only for [event][item]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ImagePathFunctions#Blit_Function|BLIT]] the image onto &amp;lt;tt&amp;gt;misc/blank-hex.png&amp;lt;/tt&amp;gt; (a blank 72x72 image).)''&lt;br /&gt;
* '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image (https://github.com/wesnoth/wesnoth/issues/1219).&lt;br /&gt;
* '''name''' an id that can be used to remove the item.&lt;br /&gt;
''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100''&lt;br /&gt;
or equivalently (requires Wesnoth 1.11.2+):&lt;br /&gt;
''halo=scenery/fire[1~8].png:100''&lt;br /&gt;
* '''team_name''': 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. {{DevFeature1.15|0}} In 1.14 the '''[side]team_name''' attribute was expected to be a substring of this '''team_name'''. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* '''visible_in_fog''': whether the item should be visible through fog or not. Default yes.&lt;br /&gt;
* '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items.&lt;br /&gt;
* '''[filter_team]''': {{DevFeature1.15|0}} A [[StandardSideFilter]]. Set '''team_name''' to the union of all '''[side]team_name''' attributes of all sides that match the SSF. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]])&lt;br /&gt;
* {{DevFeature1.15|0}} If both '''team_name''' and '''[filter_team]''' are set, '''team_name''' is ignored.&lt;br /&gt;
&lt;br /&gt;
=== [remove_item] ===&lt;br /&gt;
Removes any graphical items on a given hex.&lt;br /&gt;
* [[StandardLocationFilter]]: the hexes to remove items from&lt;br /&gt;
* '''image''': if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any [[ImagePathFunctions|image path functions]] appended to the original image name.)&lt;br /&gt;
&lt;br /&gt;
=== [print] ===&lt;br /&gt;
Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered.&lt;br /&gt;
* '''text''': (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one.&lt;br /&gt;
* '''size''': (default=12) the pointsize of the font to use&lt;br /&gt;
* '''duration''': the length of time to display the text for.&lt;br /&gt;
** (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms.&lt;br /&gt;
** {{DevFeature1.15|4}} This is measured in milliseconds. Don't use the default value, because it's a mere 50ms.&lt;br /&gt;
** {{DevFeature1.15|14}} The default is 5000 milliseconds.&lt;br /&gt;
** {{DevFeature1.15|14}} The string '''unlimited''' displays the text until it's removed by another [print] tag.&lt;br /&gt;
* '''color''': (default '''0,0,0''') three comma-separated values giving the red, green and blue values (0-255).&lt;br /&gt;
* '''red''', '''green''', '''blue''': deprecated, use color=0,0,0 instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_unit_fake] ===&lt;br /&gt;
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;
* '''gender''': the gender of the fake unit. Example: gender=female&lt;br /&gt;
* '''variation''': the variation of the fake unit. Example: variation=undead&lt;br /&gt;
* '''image_mods''': [[ImagePathFunctions|image path functions]] sequence to be applied on the fake unit.&lt;br /&gt;
* '''force_scroll''':  Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead.&lt;br /&gt;
&lt;br /&gt;
=== [move_units_fake] ===&lt;br /&gt;
moves multiple images of units along paths on the map. These units are moved in lockstep.&lt;br /&gt;
* '''force_scroll''': {{DevFeature1.15|0}} Has the same meaning as in [move_unit_fake] but a different default.&lt;br /&gt;
* '''[fake_unit]''': A fake unit to move&lt;br /&gt;
** '''type''': the type of 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;
** '''skip_steps''': the number of steps to skip before this unit starts moving&lt;br /&gt;
&lt;br /&gt;
=== [hide_unit] ===&lt;br /&gt;
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit.&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will be hidden&lt;br /&gt;
&lt;br /&gt;
=== [unhide_unit] ===&lt;br /&gt;
Stops the currently hidden units from being hidden.&lt;br /&gt;
* [[StandardUnitFilter]]: Only the matching units will be unhidden&lt;br /&gt;
&lt;br /&gt;
=== [lock_view] ===&lt;br /&gt;
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game.&lt;br /&gt;
&lt;br /&gt;
This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}} This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally.&lt;br /&gt;
&lt;br /&gt;
=== [unlock_view] ===&lt;br /&gt;
Unlocks gamemap view scrolling for human players.&lt;br /&gt;
&lt;br /&gt;
=== [scroll] ===&lt;br /&gt;
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;
* '''side''': the side or sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to] ===&lt;br /&gt;
Scroll to a given hex&lt;br /&gt;
* [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex being scrolled to (defaults to ''no'').&lt;br /&gt;
* '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [scroll_to_unit] ===&lt;br /&gt;
Scroll to a given unit&lt;br /&gt;
* [[StandardUnitFilter]]; do not use a [filter] subtag.&lt;br /&gt;
* '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default.&lt;br /&gt;
* '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no'').&lt;br /&gt;
* '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex the unit is on (defaults to ''no'').&lt;br /&gt;
* '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
* '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.&lt;br /&gt;
&lt;br /&gt;
=== [select_unit] ===&lt;br /&gt;
Selects a given unit.&lt;br /&gt;
* [[StandardUnitFilter]]: The first unit found will be selected.&lt;br /&gt;
* '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.)&lt;br /&gt;
* '''highlight''': whether the unit's current hex should be highlighted (def. ''yes'').&lt;br /&gt;
&lt;br /&gt;
'''Note:''' fire_event does not appear to work in 1.14 or 1.16.&lt;br /&gt;
&lt;br /&gt;
=== [sound]===&lt;br /&gt;
Plays a sound&lt;br /&gt;
* '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly.&lt;br /&gt;
* '''repeat''': repeats the sound for a specified additional number of times (default=0)&lt;br /&gt;
&lt;br /&gt;
=== [sound_source] ===&lt;br /&gt;
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 ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are fogged&lt;br /&gt;
* '''check_shrouded''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are shrouded&lt;br /&gt;
* '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source&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;
&lt;br /&gt;
=== [story] ===&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Shows the story screen.&lt;br /&gt;
* '''title''': Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title.&lt;br /&gt;
* '''[part]''', '''[if]''', '''[switch]''', '''[wml_message]''', '''[deprecated_message]''' : See [[IntroWML]].&lt;br /&gt;
&lt;br /&gt;
=== [remove_sound_source] ===&lt;br /&gt;
Removes a previously defined sound source.&lt;br /&gt;
* '''id''': the identification key of the sound source to remove&lt;br /&gt;
&lt;br /&gt;
=== [music] ===&lt;br /&gt;
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;
&lt;br /&gt;
=== [volume] ===&lt;br /&gt;
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100:  &lt;br /&gt;
* '''music''':  Changes the music volume.&lt;br /&gt;
* '''sound''':  Changes the sound volume.&lt;br /&gt;
&lt;br /&gt;
=== [color_adjust] ===&lt;br /&gt;
Adjust the color tint of terrain, by adjusting time-of-day coloring.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color&lt;br /&gt;
&lt;br /&gt;
=== [screen_fade] ===&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects.&lt;br /&gt;
* '''red''', '''green''', '''blue''': values from 0 to 255, the final overlay color (defaults to 0,0,0)&lt;br /&gt;
* '''alpha''': value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen.&lt;br /&gt;
* '''duration''': the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate.&lt;br /&gt;
&lt;br /&gt;
=== [delay] ===&lt;br /&gt;
Pauses the game.&lt;br /&gt;
* '''time''': the time to pause in milliseconds&lt;br /&gt;
* '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game.&lt;br /&gt;
&lt;br /&gt;
=== [redraw] ===&lt;br /&gt;
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;
* '''clear_shroud''' (boolean yes|no, default no): If yes, clears fog and shroud around existing units. 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;
* '''[[StandardSideFilter]]''': the sides for which to recalculate fog and shroud.&lt;br /&gt;
* '''side''': If used (forces clear_shroud=yes), clears fog and shroud for that side.&lt;br /&gt;
&lt;br /&gt;
=== [unit_overlay] ===&lt;br /&gt;
Sets an image that will be drawn over a particular unit, and follow it around&lt;br /&gt;
* [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter])&lt;br /&gt;
* '''image''': the image to place on the unit&lt;br /&gt;
* '''object_id''': object id to use, defaults to the '''image''' key with an &amp;quot;overlay_&amp;quot; prefix; this allows using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']]&lt;br /&gt;
* '''duration''': object duration&lt;br /&gt;
&lt;br /&gt;
=== [remove_unit_overlay] ===&lt;br /&gt;
Removes a particular overlayed image from a unit&lt;br /&gt;
* [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter])&lt;br /&gt;
* '''image''': the image to remove from the unit&lt;br /&gt;
* '''object_id''': object id to use&lt;br /&gt;
Using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271&lt;br /&gt;
&lt;br /&gt;
=== [animate_unit] ===&lt;br /&gt;
Uses an 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 custom animation in the unit description (see the '''[extra_anim]''' description in [[AnimationWML]]). Standard animations can be triggered with the following keywords: ''leading recruited standing idling levelout levelin healing healed poisoned movement defend attack death victory pre_teleport post_teleport''&lt;br /&gt;
* '''[filter]''' with a [[StandardUnitFilter]] as argument, 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. Takes a weapon filter as argument, see [[FilterWML]].&lt;br /&gt;
* '''[secondary_attack]''': Similar to '''[primary_attack]'''. May be needed to trigger a defense animation correctly, if there are more than one animations available for the defending unit.&lt;br /&gt;
* '''hits''': yes/no/hit/miss/kill: which according variation of a attack/defense animation shall be chosen (required)&lt;br /&gt;
* '''text''': a text to hover during the animation &lt;br /&gt;
* '''male_text''', '''female_text''': {{DevFeature1.13|2}} (translatable) gender-specific versions of the above&lt;br /&gt;
* '''red''': red value for the text color (0-255)&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''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar)&lt;br /&gt;
* '''[animate]''': a sub block with the same syntax as '''[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 hex the unit should be facing when animated&lt;br /&gt;
&lt;br /&gt;
=== [label] ===&lt;br /&gt;
Places a label on the map.&lt;br /&gt;
* '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support)&lt;br /&gt;
* '''text''': what the label should say. If you put an empty string &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location.&lt;br /&gt;
* '''team_name''': if specified, the label will only be visible to the given team.&lt;br /&gt;
* '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255.&lt;br /&gt;
* '''visible_in_fog''': whether the label should be visible through fog or not. Default yes.&lt;br /&gt;
* '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no.&lt;br /&gt;
* '''immutable''': whether this label is protected from being removed or changed by players. Default yes.&lt;br /&gt;
* '''category''': the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox.&lt;br /&gt;
* '''tooltip''': A tooltip visible when mouseovering the hex the label is on&lt;br /&gt;
* '''side''': the number of the side that placed the label. Can be 0 for labels placed by WML.&lt;br /&gt;
&lt;br /&gt;
=== [floating_text]===&lt;br /&gt;
Floats text (similar to the damage and healing numbers) on the given locations.&lt;br /&gt;
* [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units).&lt;br /&gt;
* '''text''': the text to display.&lt;br /&gt;
&lt;br /&gt;
The default text color is &amp;lt;span style=&amp;quot;color: #6b8cff;&amp;quot;&amp;gt;'''#6b8cff'''&amp;lt;/span&amp;gt;. To change the color, use [[#Formatting|Pango markup]]. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Float some golden yellow text at 20,20.&lt;br /&gt;
[floating_text]&lt;br /&gt;
   x,y=20,20&lt;br /&gt;
   text=&amp;quot;&amp;lt;span color='#cccc33'&amp;gt;&amp;quot; + _ &amp;quot;Your text here&amp;quot; + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
[/floating_text]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [deprecated_message] ===&lt;br /&gt;
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;
* '''level''': {{DevFeature1.13|10}} The deprecation level, a number from 1 to 3.&lt;br /&gt;
* '''what''': {{DevFeature1.13|10}} The name of the thing being deprecated. Use this instead of '''message''' if possible; a stock message will be generated from it. Use '''message''' only if more information is required; it will be appended to the stock message. This should not be translatable&lt;br /&gt;
* '''version''': {{DevFeature1.13|10}} For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does ''not'' indicate the version in which it became deprecated. &lt;br /&gt;
&lt;br /&gt;
The meanings of the deprecation levels are as follows:&lt;br /&gt;
&lt;br /&gt;
# Deprecated, but will only be removed if absolutely necessary. The '''version''' key is ignored.&lt;br /&gt;
# It will be removed no earlier than a specified version.&lt;br /&gt;
# It will be removed in the next stable version&lt;br /&gt;
# It has already been removed, leaving just a stub to inform users of how to update their code.&lt;br /&gt;
&lt;br /&gt;
Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The '''message''' can be translatable, but does not need to be.&lt;br /&gt;
&lt;br /&gt;
=== [wml_message] ===&lt;br /&gt;
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. 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;
* '''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;
&lt;br /&gt;
Note: As of 1.9.4/1.9.5 (r48805) the following &amp;quot;loggers&amp;quot; should work: If in [wml_message]: err/error, warn/wrn/warning, debug/dbg; using the :log command: Only the long forms error, warning, info and debug (this part gathered by trying rather than source inspecting). The long forms are most likely also the only ones working when starting wesnoth with --log-&amp;lt;level&amp;gt;=wml.&lt;br /&gt;
For log level warning or error (as during normal play), only wml_messages with logger error or warning display (for both). With logger info or debug, additionally wml_messages with logger info or debug display (for both).&lt;br /&gt;
&lt;br /&gt;
=== [test_condition] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|2}}&lt;br /&gt;
&lt;br /&gt;
Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why.&lt;br /&gt;
&lt;br /&gt;
* '''result''': Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass.&lt;br /&gt;
* '''logger''': Same as for [wml_message]. Defaults to &amp;quot;warning&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== [open_help] ===&lt;br /&gt;
Opens the in-game help.&lt;br /&gt;
* '''topic''': the id of the topic to open&lt;br /&gt;
&lt;br /&gt;
Examples of ids:&lt;br /&gt;
* unit_Mage&lt;br /&gt;
* unit_Dark Adept&lt;br /&gt;
* weaponspecial_charge&lt;br /&gt;
* terrain_human_castle&lt;br /&gt;
&lt;br /&gt;
The engine will print the topic ids if run from the command line with the ''--log-debug=help'' option.&lt;br /&gt;
&lt;br /&gt;
=== [show_objectives] ===&lt;br /&gt;
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.)&lt;br /&gt;
* '''side''': the side to show the objectives. If not set, all sides are used.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys: Tag affects the matching sides instead of just all or the one given by the integer value of the side= key.&lt;br /&gt;
&lt;br /&gt;
=== [chat] ===&lt;br /&gt;
Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: [[LuaWML:Display#wesnoth.message]]. {{DevFeature1.13|9}} can be visible for observers.&lt;br /&gt;
* '''speaker''': (default=&amp;quot;WML&amp;quot;) A string for the name of the sender of the message.&lt;br /&gt;
* '''message''': The message that should be displayed.&lt;br /&gt;
* '''observable''' (boolean yes|no, default yes): {{DevFeature1.13|9}} Whether the message is displayed for observers.&lt;br /&gt;
* '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once.&lt;br /&gt;
&lt;br /&gt;
=== [zoom] ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|8}}&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map.&lt;br /&gt;
&lt;br /&gt;
* '''factor''': The new zoom factor, measured as a multiple of the base zoom.&lt;br /&gt;
* '''relative''': If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no.&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;
* '''{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;
* '''{QUAKE &amp;lt;soundfile&amp;gt;}''' Creates a tremor-like screenshake and plays &amp;lt;soundfile&amp;gt;. For example, '''{QUAKE (rumble.ogg)}'''.&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;br /&gt;
[[Category: ActionsWML]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Wesnoth_Formula_Language&amp;diff=73210</id>
		<title>Wesnoth Formula Language</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Wesnoth_Formula_Language&amp;diff=73210"/>
		<updated>2024-07-08T12:41:33Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* rotate_loc_around */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Wesnoth Formula Language is a functional language used to evaluate expressions within the game engine. The most common use of WFL is in the [[VariablesWML#Variable_Substitution|&amp;lt;code&amp;gt;$(formula)&amp;lt;/code&amp;gt; substitution]] syntax, which allows the use of formulas wherever variables are parsed, but it can also be used in [[FilterWML|filters]], [[GUIToolkit|GUI2 dialogs]], [[AbilitiesWML|unit abilities]] and even [[FormulaAI|AI]].&lt;br /&gt;
&lt;br /&gt;
All formulas should be enclosed in quotes, as in this example: &amp;lt;code&amp;gt;key = &amp;quot;(formula-expression)&amp;quot;&amp;lt;/code&amp;gt;. This avoids issues concerning the interpretation of the plus sign, which has a special meaning in WML. Some locations (for example unit abilities) require you to enclose the formula in parentheses, taking the value as a simple number otherwise, but others (such as filters) do not require the parentheses.&lt;br /&gt;
&lt;br /&gt;
Generally, you do not use a &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; to introduce a formula. The &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; introduces a variable substitution, which is a separate concept from formulas (but allows using a formula if you wish) and works in many, but not all, places where simple text is used. See [[VariablesWML#Variable Substitution|VariablesWML]] for more information about this.&lt;br /&gt;
&lt;br /&gt;
== Data Types and Operators ==&lt;br /&gt;
&lt;br /&gt;
=== Numbers ===&lt;br /&gt;
&lt;br /&gt;
The most common use of WFL is for simple calculations involving numbers. For this, the standard arithmetic operators (&amp;lt;code&amp;gt;+ - * / %&amp;lt;/code&amp;gt;) work as you would expect, performing addition, subtraction, multiplication, division, and remainder. The only caveat to watch out for is that &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; rounds down when used on integers. For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;5 / 2&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;. To avoid this, make sure at least one of the numbers includes a decimal point - &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;5.0 / 2&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;2.5&amp;lt;/code&amp;gt;. Note that WFL supports only three decimal places of precision; beyond that it will still be rounded down. (So &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;1.0 / 16&amp;lt;/syntaxhighlight&amp;gt; will evaluate to &amp;lt;code&amp;gt;0.062&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;0.0625&amp;lt;/code&amp;gt;.) The &amp;lt;code&amp;gt;^&amp;lt;/code&amp;gt; operator performs exponentiation (raising to a power) - for example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;2 ^ 3&amp;lt;/syntaxhighlight&amp;gt; evaluates to &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The modulus operator only works if both operands are integers. {{DevFeature1.13|5}} This is no longer the case as of 1.13.5.&lt;br /&gt;
&lt;br /&gt;
You can also use the standard comparison operators (&amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;=&amp;lt;/code&amp;gt;) on numbers. This is often useful in unit filters - for example, a formula of &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;hitpoints &amp;lt; max_hitpoints / 2&amp;lt;/syntaxhighlight&amp;gt; will match only if the unit is at less than half health. Comparison operators return 1 for true and 0 for false; there is no boolean type.&lt;br /&gt;
&lt;br /&gt;
One final numeric operator exists - the dice roll. The syntax &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;3d12&amp;lt;/syntaxhighlight&amp;gt; will roll three 12-sided dice and return the sum of the results. Note however that this is not multiplayer-safe, so using it can and will produce OOS errors. {{DevFeature1.13|5}} The dice operator is now synced and should be safe for use in multiplayer contexts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' {{DevFeature1.13|5}} Some numeric operations will return null instead of a number. This usually involves the exponentiation operator - for example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;(-2) ^ 0.5&amp;lt;/syntaxhighlight&amp;gt; attempts to take the square root of -2, which doesn't exist, so it returns null to indicate this. Dividing by zero also returns null, as well as certain [[#Numeric Functions|math functions]] in appropriate circumstances.&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
WFL also supports strings, which must be enclosed in single quotes (&amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;'like this'&amp;lt;/syntaxhighlight&amp;gt;). The comparison operators (&amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;=&amp;lt;/code&amp;gt;) also work on strings, performing lexicographical comparison (ie, alphabetical order). The comparison is case sensitive.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
Strings can be concatenated with the concatenation operator &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt;. They also support interpolations enclosed in square brackets, the contents of which can be any valid formula. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'Some text: [a + b]' where a = 12, b = 10&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
results in the string &amp;lt;code&amp;gt;Some text: 22&amp;lt;/code&amp;gt;. (The &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; operator is explained [[#Variables|below]].)&lt;br /&gt;
&lt;br /&gt;
If you need to include a literal square bracket in a string, write &amp;lt;code&amp;gt;[(]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;[)]&amp;lt;/code&amp;gt;. For a literal single quote, you can write &amp;lt;code&amp;gt;[']&amp;lt;/code&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'[(]It[']s bracketed![)]'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
results in the string &amp;lt;code&amp;gt;[It's bracketed!]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can index the characters or words of a string with the following syntax:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'Hello World'.char[4]&lt;br /&gt;
'Hello World'.word[1]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These return &amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;World&amp;lt;/code&amp;gt;, respectively. A third option is also available, &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt;, which splits the string on commas but allows parentheses to prevent a portion of the string from being split up. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
'First Item,Second Item,Third Item'.item[1]&lt;br /&gt;
'a,b,(c,d,e),f,g'.item[2]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These return &amp;lt;code&amp;gt;Second Item&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;(c,d,e)&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Lists ===&lt;br /&gt;
&lt;br /&gt;
A list is a sequence of values represented as square brackets, [], surrounding a comma-separated list. For instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[ 1, 5, 'abc' ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The comparison operators work on lists, performing lexicographical comparison. A specific list index can be obtained with the indexing operator, like this: &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;my_list[index]&amp;lt;/syntaxhighlight&amp;gt;. The first element of a list is numbered 0.&lt;br /&gt;
&lt;br /&gt;
There are four ''vector operators'' (&amp;lt;code&amp;gt;.+ .- .* ./&amp;lt;/code&amp;gt;) that perform entrywise operations on lists. For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;[1,2,3] .+ [12,2,8]&amp;lt;/syntaxhighlight&amp;gt; produces &amp;lt;code&amp;gt;[13,4,11]&amp;lt;/code&amp;gt;. Both lists must be of the same length to use these operators, and of course, they must contain only numbers.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
A negative list index now counts from the end of the list - &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; refers to the last element. You can check if an element exists in a list using the &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; operator. Lists can also be joined with the concatenation operator &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt;, and sliced using the range operator &amp;lt;code&amp;gt;~&amp;lt;/code&amp;gt;. In fact, the range operator produces a list of consecutive numbers, and in fact any list of numbers can be used to index a list - the result is to take the elements at the requested indices, in order. Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[1, 7, 'abc', 2.5, 'foobar', 127][1~3]&lt;br /&gt;
(10~20)[[0,-1]]&lt;br /&gt;
[1, 7, 'abc', 2.5, 'foobar', 127][[2,4]]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These result in the following lists:&lt;br /&gt;
&lt;br /&gt;
 [7, 'abc', 2.5]&lt;br /&gt;
 [10,20]&lt;br /&gt;
 ['abc', 'foobar']&lt;br /&gt;
&lt;br /&gt;
=== Maps ===&lt;br /&gt;
&lt;br /&gt;
A map is a sequence of key-value pairs. For example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
[12 -&amp;gt; 'Hello', [1,2] -&amp;gt; 9, 'abc' -&amp;gt; 1.5]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The comparison operators work on maps. A specific element of a map can be obtained with the indexing operation. In the above example, the following conditions are all true (assuming the map is in a variable called &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self[12] = 'Hello'&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self[[1,2]] = 9&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;self['abc'] = 1.5&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
You can now use the &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; operator to test if a key exists in the map. You can also access string keys using the dot operator &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; as long as they are valid identifiers. (Valid identifiers contain letters and underscores only; no digits are permitted.)&lt;br /&gt;
&lt;br /&gt;
Note that the selection indexing that lists use is ''not'' valid for maps - a list can be used as a key, after all.&lt;br /&gt;
&lt;br /&gt;
=== Objects ===&lt;br /&gt;
&lt;br /&gt;
An object is a container containing additional variables (see [[#Variables|below]] for further explanation of variables) which are not in the global scope. The ''dot operator'' can be used to evaluate a formula in the object's scope. For example, suppose ''u'' is a unit object referring to your leader, who is an Elvish Ranger who has taken 12 damage (thus has 30 hit points). Then &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u.hitpoints&amp;lt;/syntaxhighlight&amp;gt; will evaluate to the number 30. For a more advanced example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u . (hitpoints &amp;lt; max_hitpoints - 10)&amp;lt;/syntaxhighlight&amp;gt; will evaluate to true if the unit has taken more than 10 damage, which in this example, it has. (This could also be written &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;u.hitpoints &amp;lt; u.max_hitpoints - 10&amp;lt;/syntaxhighlight&amp;gt; if you prefer; this enters the scope twice, instead of once, but the result is identical.)&lt;br /&gt;
&lt;br /&gt;
Objects generally cannot be created directly by the code - they are created for you by the game when formulas are called in certain contexts. However, there are two types of object that ''can'' be created by your code. The first is the location object, which has variables ''x'' and ''y''; it can be created by the [[#loc|&amp;lt;code&amp;gt;loc()&amp;lt;/code&amp;gt;]] function. The second is the map pair object, which is returned (or used internally) by several of the built-in functions and has variables ''key'' and ''value''.&lt;br /&gt;
&lt;br /&gt;
=== Other Types and Operators ===&lt;br /&gt;
&lt;br /&gt;
There is one other basic type in WFL - the null type, which is used to mean &amp;quot;no value&amp;quot;. It will be returned if you attempt to perform an invalid operation, such as dividing a string. It is also returned by the built-in &amp;lt;code&amp;gt;null()&amp;lt;/code&amp;gt; function, which allows you to test if a value is null by writing &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;value = null()&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logical operators &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; can be used to connect conditional expressions, and the unary operator &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt; negates them. Note that &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; is inclusive - &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;A or B&amp;lt;/syntaxhighlight&amp;gt; is false only if both ''A'' and ''B'' are false. These operators consider &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or null to be false, while all other values count as true. The [[#if|&amp;lt;code&amp;gt;if()&amp;lt;/code&amp;gt;]] function also follows the same rules to determine whether a value is true or false.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Programmers familiar with other languages may occasionally be surprised by the fact that &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; do not short-circuit (which would mean that they will never evaluate their second argument if they can know their result solely from the first argument). This should not be a problem in general formula usage, since functions do not have side-effects, but it could make a difference when using the debug functions.&lt;br /&gt;
&lt;br /&gt;
=== Operator Precedence ===&lt;br /&gt;
&lt;br /&gt;
The precedence of various operators is, more or less, what you'd expect - you can write something like &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a + b * 2 &amp;lt;= 5 and n - m / 4 &amp;gt; 7&amp;lt;/syntaxhighlight&amp;gt; and the engine will do what you expect - first multiplication and division, then addition and subtraction, then comparison, and finally logical conjunction. The only thing to watch out for is when chaining exponentiation - all operators are left associative, so &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a ^ b ^ c&amp;lt;/syntaxhighlight&amp;gt; will be evaluated as &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;(a ^ b) ^ c&amp;lt;/syntaxhighlight&amp;gt; instead of &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;a ^ (b ^ c)&amp;lt;/syntaxhighlight&amp;gt; like you would expect. {{DevFeature1.13|5}} This has been fixed - exponentiation is now right-associative.&lt;br /&gt;
&lt;br /&gt;
The full precedence list is as follows, from lowest to highest; operators on the same line have equal precedence.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clauses&lt;br /&gt;
# &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt;&lt;br /&gt;
# Comparison operators &amp;lt;code&amp;gt;= != &amp;lt; &amp;lt;= &amp;gt; &amp;gt;= in&amp;lt;/code&amp;gt;&lt;br /&gt;
# Range-generating operator &amp;lt;code&amp;gt;~&amp;lt;/code&amp;gt;&lt;br /&gt;
# Additive operators &amp;lt;code&amp;gt;+ - ..&amp;lt;/code&amp;gt;&lt;br /&gt;
# Multiplicative operators &amp;lt;code&amp;gt;* /&amp;lt;/code&amp;gt;&lt;br /&gt;
# Modulus &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt;&lt;br /&gt;
# Exponentiation &amp;lt;code&amp;gt;^&amp;lt;/code&amp;gt;&lt;br /&gt;
# Dice operator &amp;lt;code&amp;gt;d&amp;lt;/code&amp;gt;&lt;br /&gt;
# Dot operator &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Variables ==&lt;br /&gt;
&lt;br /&gt;
Formulas may have a variety of variables, depending on the context in which they are evaluated. A string substitution formula like &amp;lt;code&amp;gt;$(3 + 5)&amp;lt;/code&amp;gt; has no variables, but a [[StandardUnitFilter|unit filter]] formula has variables such as &amp;lt;code&amp;gt;hitpoints&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;max_hitpoints&amp;lt;/code&amp;gt; which contain various properties of the unit being tested (the same unit which is also referred to in variable substitution as &amp;lt;code&amp;gt;$this_unit&amp;lt;/code&amp;gt;). The special variable &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; typically refers to the &amp;quot;global context&amp;quot; - in the case of a unit filter formula, the unit itself. This means for example that &amp;lt;code&amp;gt;self.hitpoints&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hitpoints&amp;lt;/code&amp;gt; are equivalent when used in a unit filter formula. In a string substitution formula (the &amp;lt;code&amp;gt;$(formula)&amp;lt;/code&amp;gt; syntax), &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; is null. Because of this, you should prefer not to use the substitution syntax in places where formulas are specifically supported.&lt;br /&gt;
&lt;br /&gt;
A formula may declare additional variables using a &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clause. This assigns a meaning to any unknown variables in the preceding formula. The general syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;formula&amp;gt; where &amp;lt;variable&amp;gt; = &amp;lt;value&amp;gt; [, &amp;lt;variable&amp;gt; = value ...]&lt;br /&gt;
&lt;br /&gt;
This functions similarly to an operator, so if desired, you could have multiple where clauses in a single formula. Note that all variables in WFL are read-only - they are variables because they may have different values depending on the context in which the formula is evaluated, but for a given context, they are constant. A variable that has not been assigned a value is considered to have a value of null. Variables are lazily-evaluated - if a where clause declares a variable that is never used, the expression assigned to it will never be evaluated. (This only really matters if it contains a call to a debug function.)&lt;br /&gt;
&lt;br /&gt;
Variable names can contain letters and underscores only. In particular, they cannot contain digits. Also, names are case-sensitive, so ''y'' and ''Y'' refer to two different variables. The following names are reserved and cannot be used for the name of a variable or function:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;d&amp;lt;/tt&amp;gt; - dice operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;or&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; - containment operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;def&amp;lt;/tt&amp;gt; - defines a function&lt;br /&gt;
* &amp;lt;tt&amp;gt;and&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;not&amp;lt;/tt&amp;gt; - logical operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;fai&amp;lt;/tt&amp;gt; - deprecated synonym of &amp;lt;tt&amp;gt;wfl&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;wfl&amp;lt;/tt&amp;gt; - declares filename&lt;br /&gt;
* &amp;lt;tt&amp;gt;where&amp;lt;/tt&amp;gt; - declares variables&lt;br /&gt;
* &amp;lt;tt&amp;gt;faiend&amp;lt;/tt&amp;gt; - deprecated synonym of &amp;lt;tt&amp;gt;wflend&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;wflend&amp;lt;/tt&amp;gt; - closes file scope&lt;br /&gt;
* &amp;lt;tt&amp;gt;functions&amp;lt;/tt&amp;gt; - lists all defined functions&lt;br /&gt;
&lt;br /&gt;
=== Documentation of some common objects ===&lt;br /&gt;
&lt;br /&gt;
* [[StandardUnitFilter#Wesnoth_Formula_Language|unit objects]]&lt;br /&gt;
* [[FilterWML#Filtering_Weapons|weapon objects]]&lt;br /&gt;
* [[StandardLocationFilter#Wesnoth_Formula_Language|terrain objects]]&lt;br /&gt;
* [[StandardSideFilter#Wesnoth_Formula_Language|side objects]]&lt;br /&gt;
* [[ImagePathFunctions#CHAN:_General function|pixel objects]]&lt;br /&gt;
* [[ConditionalActionsWML#.5Bvariable.5D|WML objects]]&lt;br /&gt;
* [[EventWML#filter_formula|game state objects]]&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
&lt;br /&gt;
Sometimes with particularly complicated formulas, it may be useful to document what's going on inline. Of course, you can use WML comments to do this, but in some cases it may be useful to put some comments in the middle of the formula. This is easily done - simply enclose them in &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; characters, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
#This is a Wesnoth Formula Language comment.#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the final &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; - unlike WML, WFL requires this to indicate where the comment ends.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
There are several predefined functions in the Wesnoth Formula Language, and if these are not enough, it is possible to define your own functions. The special variable &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;functions&amp;lt;/syntaxhighlight&amp;gt; always evaluates to a list of all known function names. This is mainly useful only as a debugging tool, though.&lt;br /&gt;
&lt;br /&gt;
To define a function, you use the &amp;lt;code&amp;gt;def&amp;lt;/code&amp;gt; keyword. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def sgn(x) if(x &amp;lt; 0, -1, x &amp;gt; 0, 1, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This defines a function called &amp;lt;code&amp;gt;sgn&amp;lt;/code&amp;gt; which returns the sign of the input number. The semicolon marks the end of the function. It's optional if there's nothing else following the function, but in practice this will very rarely be the case.&lt;br /&gt;
&lt;br /&gt;
Function names have the same limitation as variable names – they can contain only letters numbers, and underscores, and cannot contain digits.&lt;br /&gt;
&lt;br /&gt;
You can select one of the function's arguments to be the &amp;quot;default&amp;quot; argument. If an object is passed to the default argument, then any attributes of that object are directly accessible in the global scope. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def is_badly_wounded(u*) hitpoints &amp;lt; max_hitpoints / 2;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function takes a unit and returns 1 if it is at less than half hitpoints. The &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; indicates the default argument, without which it would instead have to be defined like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def is_badly_wounded(u) u.hitpoints &amp;lt; u.max_hitpoints / 2;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's important to remember that the function body has access to no variables other than its parameters. For example, the following function would not work (in an AI context) even though the my_leader variable is defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
def endangers_leader(u) distance_between(u.loc, my_leader.loc) &amp;lt; u.moves;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is because the body of the function can't see the my_leader variable. To make this work, you would need to pass in my_leader as an additional parameter.&lt;br /&gt;
&lt;br /&gt;
'''Note: Prior to 1.14, function definitions only work in AI code and GUI2 code.'''&lt;br /&gt;
&lt;br /&gt;
== Files ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
On occasion, you may find yourself working with formulas complex enough to split them out into a separate file. The formula engine normally assumes that it is executing inline code and reports errors accordingly, but you can tell it to enter a file scope using the special &amp;lt;code&amp;gt;wfl&amp;lt;/code&amp;gt; keyword. The convention is to frame your code, so that any file looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
wfl 'filename.wfl'&lt;br /&gt;
&lt;br /&gt;
# Put whatever code you need here, possibly including function definitions. #&lt;br /&gt;
&lt;br /&gt;
wflend&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The matching &amp;lt;code&amp;gt;wflend&amp;lt;/code&amp;gt; is required.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This functionality was available prior to 1.13.5 using keywords &amp;lt;code&amp;gt;fai&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;faiend&amp;lt;/code&amp;gt;. These keywords are now deprecated, but still work.&lt;br /&gt;
&lt;br /&gt;
== Core Functions ==&lt;br /&gt;
&lt;br /&gt;
Many of the core functions exhibit two features that (as of 1.13.4) cannot be used in user-defined functions. The first is the ability to accept a varying number of arguments - some core functions accept any number of arguments, while others have a few optional arguments. The second is that arguments are lazily-evaluated, and in some cases some arguments will not be evaluated at all, while others may be evaluated multiple times with different variable values. The description of each function will explain how and when its arguments are evaluated.&lt;br /&gt;
&lt;br /&gt;
Most of the core functions can be used from any formula. However, there are some that are only available in formulas that have access to the game state. These functions can be used in [[FilterWML]] formulas and [[AbilitiesWML]] formulas, but not in GUI formulas and substitution formulas (using &amp;lt;tt&amp;gt;$&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== Conditional Functions ===&lt;br /&gt;
&lt;br /&gt;
There are two functions which return one of their input values based on some condition - the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; function, and the &amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt; function. Both evaluate only as many parameters as is needed to determine which value to return. In particular, parameters that are neither returned nor part of the condition will never be evaluated.&lt;br /&gt;
&lt;br /&gt;
==== if ====&lt;br /&gt;
&lt;br /&gt;
* if(''condition'', ''if true'' [, ''condition 2'', ''if true 2'', ...] [, ''otherwise''])&lt;br /&gt;
&lt;br /&gt;
This function first evaluates the ''condition'', which is a formula. If it evaluates to true, then the function evaluates and returns the ''if true'' parameter; otherwise, it tries the next condition (if any) with the same result. If none of the conditions evaluate to true, then it returns the ''otherwise'' parameter if present, or &amp;lt;code&amp;gt;null()&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
For instance, an AI that recruits Wolf Riders on the first turn, and Orcish Grunts thereafter might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
if(turn = 1, recruit('Wolf Rider'), recruit('Orcish Grunt'))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== switch ====&lt;br /&gt;
&lt;br /&gt;
* switch(''formula'', ''value 1'', ''outcome 1'' [, ... , ''value N'', ''outcome N''] [, ''default outcome''])&lt;br /&gt;
&lt;br /&gt;
The switch function first evaluates the input ''formula'', and then checks if it is equal to any of the specified ''values''. If matching value is found, the ''outcome'' assigned to it is returned; if not, then function returns either ''default outcome'' (if specified) or null.&lt;br /&gt;
&lt;br /&gt;
=== Numeric Functions ===&lt;br /&gt;
&lt;br /&gt;
Several basic math functions are available. These generally work equally on integer and decimal values.&lt;br /&gt;
&lt;br /&gt;
==== abs ====&lt;br /&gt;
&lt;br /&gt;
* abs(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value of an input number; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
abs( -5 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return 5.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== acos ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* acos(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arccosine of the input number, in degrees.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== asin ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* asin(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arcsine of the input number, in degrees.&lt;br /&gt;
&lt;br /&gt;
==== atan ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* atan(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the arctangent of the input number, in degrees.&lt;br /&gt;
==== as_decimal ====&lt;br /&gt;
&lt;br /&gt;
* as_decimal(''number'')&lt;br /&gt;
&lt;br /&gt;
Ensures that the number is a decimal rather than an integer; useful if you're dividing two unknown values and want to ensure that the result is a decimal.&lt;br /&gt;
&lt;br /&gt;
==== cbrt ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* cbrt(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the cube root of the input number. This is better than using the exponentiation operator, because it will give the correct result for negative numbers.&lt;br /&gt;
&lt;br /&gt;
==== ceil ====&lt;br /&gt;
&lt;br /&gt;
* ceil(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the ceiling of the specified number, ie rounding it up to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== clamp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}}&lt;br /&gt;
&lt;br /&gt;
* clamp(''number'', ''min'', ''max'')&lt;br /&gt;
&lt;br /&gt;
Combines min and max into a single call. If ''number'' is less than ''min'', returns ''min''; if it's greater than ''max'', returns ''max''. Otherwise, returns ''number''.&lt;br /&gt;
&lt;br /&gt;
==== cos ====&lt;br /&gt;
&lt;br /&gt;
* cos(''angle'')&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== exp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* exp(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the exponential of the input number, which is the constant ''e'' raised to the specified power.&lt;br /&gt;
&lt;br /&gt;
==== floor ====&lt;br /&gt;
&lt;br /&gt;
* floor(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the floor of the specified number, ie rounding it down to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== frac ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* frac(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the fractional part of the specified number.&lt;br /&gt;
&lt;br /&gt;
==== hypot ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* hypot(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Returns the hypoteneuse length of a triangle with sides ''x'' and ''y''.&lt;br /&gt;
&lt;br /&gt;
==== lerp ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|0}}&lt;br /&gt;
&lt;br /&gt;
* lerp(''min'', ''max'', ''fraction'')&lt;br /&gt;
&lt;br /&gt;
Returns a linear interpolation between ''min'' and ''max'' according to the specified ''fraction''.&lt;br /&gt;
&lt;br /&gt;
==== log ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* log(''number'', [, ''base''])&lt;br /&gt;
&lt;br /&gt;
Returns the logarithm of the input number. If ''base'' is omitted, it returns the natural logarithm; otherwise, the logarithm to the specified base.&lt;br /&gt;
&lt;br /&gt;
==== max ====&lt;br /&gt;
&lt;br /&gt;
* max(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
Returns the largest number from the list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
max([2, 8, -10, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== min ====&lt;br /&gt;
&lt;br /&gt;
* min(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
Returns the smallest number from the list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
min( [ 3, 7, -2, 6] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return &amp;lt;code&amp;gt;-2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} This now works on decimals as well as integers.&lt;br /&gt;
&lt;br /&gt;
==== pi ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* pi()&lt;br /&gt;
&lt;br /&gt;
Returns pi.&lt;br /&gt;
&lt;br /&gt;
==== root ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* root(''number'', ''base'')&lt;br /&gt;
&lt;br /&gt;
Returns the root of the input number, to the specified base. This is better than using the exponentiation operator, because it will give the correct result for negative numbers and odd bases (for example, the fifth root of -32, which is -2).&lt;br /&gt;
&lt;br /&gt;
==== round ====&lt;br /&gt;
&lt;br /&gt;
* round(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the specified number rounded to the nearest integer.&lt;br /&gt;
&lt;br /&gt;
==== sgn ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* sgn(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the sign of the number, ie -1 if it is negative, 1 if it is positive, and 0 if it is zero.&lt;br /&gt;
&lt;br /&gt;
==== sin ====&lt;br /&gt;
&lt;br /&gt;
* sin(''angle'')&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== sqrt ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* sqrt(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the input number.&lt;br /&gt;
&lt;br /&gt;
==== sum ====&lt;br /&gt;
&lt;br /&gt;
* sum(''list of numbers'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates to the sum of the numbers in the ''list of numbers''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sum([ 2, 5, 8])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;15&amp;lt;/code&amp;gt;, and:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sum(map(my_units, max_hitpoints - hitpoints))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
finds the total damage your units have taken.&lt;br /&gt;
&lt;br /&gt;
==== tan ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* tan(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the given angle, which is specified in degrees.&lt;br /&gt;
&lt;br /&gt;
==== trunc ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* trunc(''number'')&lt;br /&gt;
&lt;br /&gt;
Returns the truncation of the specified number, ie rounding it towards zero. This is different from floor when applied to negative numbers - floor(-7.5) gives -8, but trunc(-7.5) gives -7.&lt;br /&gt;
&lt;br /&gt;
==== wave ====&lt;br /&gt;
&lt;br /&gt;
* wave(''number'')&lt;br /&gt;
&lt;br /&gt;
Given a numeric value V, this returns:&lt;br /&gt;
&lt;br /&gt;
  sin(2*pi*V)&lt;br /&gt;
&lt;br /&gt;
=== String Functions ===&lt;br /&gt;
&lt;br /&gt;
There are a few useful functions for manipulating strings.&lt;br /&gt;
&lt;br /&gt;
==== concatenate ====&lt;br /&gt;
&lt;br /&gt;
* concatenate(''value1''[, ''value2'', ...])&lt;br /&gt;
&lt;br /&gt;
Converts each of its arguments to a string, and concatenates the result together into a single string.&lt;br /&gt;
&lt;br /&gt;
==== contains_string ====&lt;br /&gt;
&lt;br /&gt;
* contains_string(''string'', ''search_string'')&lt;br /&gt;
&lt;br /&gt;
Returns 1 if ''search_string'' can be found within ''string'' (as a substring), 0 otherwise. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
contains_string( 'Testing', 'ing' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== length ====&lt;br /&gt;
&lt;br /&gt;
* length(''string'')&lt;br /&gt;
&lt;br /&gt;
Returns the length of the input string.&lt;br /&gt;
&lt;br /&gt;
==== find_string ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* find_string(''string'', ''search_string'')&lt;br /&gt;
&lt;br /&gt;
Returns the index at which ''search_string'' starts within ''string'' (as a substring), or -1 if it is not found. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
find_string( 'Testing', 'ing' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== replace ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* replace(''string'', ''offset'', [''size'',] ''replacement'')&lt;br /&gt;
&lt;br /&gt;
Returns a new string obtained by replacing a portion of the input ''string'' with the contents of the ''replacement'' string. The ''offset'' and ''size'' work the same as for &amp;lt;code&amp;gt;substring&amp;lt;/code&amp;gt;. Examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', 4, 5, 'dumb')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -9, 4, 'sleeping')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -9, 'brook!')&lt;br /&gt;
replace('The quick brown fox jumps over the lazy dog!', -6, -4, 'yellow')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return the following strings:&lt;br /&gt;
&lt;br /&gt;
 'The dumb brown fox jumps over the lazy dog!'&lt;br /&gt;
 'The quick brown fox jumps over the sleeping dog!'&lt;br /&gt;
 'The quick brown fox jumps over the brook!'&lt;br /&gt;
 'The quick brown fox jumps over the yellow dog!'&lt;br /&gt;
&lt;br /&gt;
==== substring ====&lt;br /&gt;
&lt;br /&gt;
* substring(''string'', ''offset''[, ''size''])&lt;br /&gt;
&lt;br /&gt;
Extracts a substring from the given input string. The ''offset'' specifies the first character to extract; the first character is &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, and negative values count from the end, so the last character is &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt;. If specified, the ''size'' indicates the total number of characters to extract; it cannot be negative. If omitted, all characters from the ''offset'' to the end of the string are returned. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', 4, 5)&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -9, 4)&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -9)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return &amp;lt;code&amp;gt;'quick'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'lazy'&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;'lazy dog!'&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The ''size'' can now be negative. This means to count backwards from the given ''offset'' (but always including the given offset, so a ''size'' of -1 gives the same result as 1). For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
substring('The quick brown fox jumps over the lazy dog!', -6, -4)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'lazy'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== List and Map Functions ===&lt;br /&gt;
&lt;br /&gt;
This section contains functions that directly manipulate a map or list.&lt;br /&gt;
&lt;br /&gt;
==== head ====&lt;br /&gt;
&lt;br /&gt;
* head(''list'' [, ''count''])&lt;br /&gt;
&lt;br /&gt;
Returns the first item from the ''list''; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
head([5, 7, 9])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;, and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
head( [ 'Orc', 'Human' ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'Orc'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} If a second argument is given, it returns a list containing the first ''count'' elements from the ''list''. Note that &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;head(L)&amp;lt;/syntaxhighlight&amp;gt; is different from &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;head(L,1)&amp;lt;/syntaxhighlight&amp;gt; - the former returns the first element, while the latter returns a list containing only the first element.&lt;br /&gt;
&lt;br /&gt;
==== index_of ====&lt;br /&gt;
&lt;br /&gt;
* index_of(''value'', ''list'')&lt;br /&gt;
&lt;br /&gt;
This function will return the first index where ''value'' can be found in the input ''list''. It will return -1 if the value is not found in the ''list'.&lt;br /&gt;
&lt;br /&gt;
==== keys ====&lt;br /&gt;
&lt;br /&gt;
* keys(''map'')&lt;br /&gt;
&lt;br /&gt;
Extracts the key values from an input ''map'' and returns them as a list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
keys(['Elvish Fighter' -&amp;gt; 50, 'Elvish Archer' -&amp;gt; 60])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns&lt;br /&gt;
&lt;br /&gt;
 ['Elvish Fighter', 'Elvish Archer']&lt;br /&gt;
&lt;br /&gt;
==== size ====&lt;br /&gt;
&lt;br /&gt;
* size(''list'')&lt;br /&gt;
&lt;br /&gt;
This function returns the number of elements in the ''list''.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;size([5, 7, 9])&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; and &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;size(['Archer', 'Fighter'])&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== sort ====&lt;br /&gt;
&lt;br /&gt;
* sort(''list'', ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates to a result list sorted according to the comparison ''formula'' for each item &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and its successor &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;. For instance, sorting units according to hitpoints would be done by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
sort(my_units, a.hitpoints &amp;gt; b.hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To sort them in the reverse order, simply use &amp;lt;code&amp;gt;&amp;amp;lt;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== tail ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* tail(''list'' [, ''count''])&lt;br /&gt;
&lt;br /&gt;
Returns the last item from the ''list''; for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tail([5, 7, 9])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt;, and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tail( [ 'Orc', 'Human' ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns &amp;lt;code&amp;gt;'Human'&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a second argument is given, it returns a list containing the last ''count'' elements from the ''list''. Note that &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;tail(L)&amp;lt;/syntaxhighlight&amp;gt; is different from &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;tail(L,1)&amp;lt;/syntaxhighlight&amp;gt; - the former returns the last element, while the latter returns a list containing only the last element.&lt;br /&gt;
&lt;br /&gt;
==== tolist ====&lt;br /&gt;
&lt;br /&gt;
* tolist(''map'')&lt;br /&gt;
&lt;br /&gt;
This function takes a map and return a list of key-value pair objects. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tolist(['Elf' -&amp;gt; 10, 'Dwarf' -&amp;gt; 20])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return:&lt;br /&gt;
&lt;br /&gt;
 [{key-&amp;gt;'Elf',value-&amp;gt;10}, {key-&amp;gt;'Dwarf',value-&amp;gt;20}]&lt;br /&gt;
&lt;br /&gt;
==== tomap ====&lt;br /&gt;
&lt;br /&gt;
* tomap(''list A'' [, ''list B''])&lt;br /&gt;
&lt;br /&gt;
This function takes one or two ''lists'' as input and returns a map. If only one list is specified, then the function will evaluate this list, count how many similar elements are found within the list, and return a map with keys being these elements, and values being a number representing how many of them the list contains. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tomap(['elf', 'dwarf', 'elf', 'elf', 'human', 'human'])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return:&lt;br /&gt;
&lt;br /&gt;
 ['elf' -&amp;gt; 3, 'dwarf' -&amp;gt; 1, 'human' -&amp;gt; 2]&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} However, if all the elements are key-value pairs such as those created by ''pair'' or ''tolist'', then this function will invert the effect of ''tolist'' and return the original map which would have produced the input list as output when passed to ''tolist''. If only some elements are key-value pairs, those elements will be directly converted into key-value pairs in the resulting map, while other values will be treated as described above.&lt;br /&gt;
&lt;br /&gt;
If two lists are specified, then the elements of the first one will be used as a keys, and the elements of the second one as a values, when creating an output map. Note that these input lists must be of the same length. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
tomap(['elf', 'dwarf' ], [10, 20])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in:&lt;br /&gt;
&lt;br /&gt;
 ['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20]&lt;br /&gt;
&lt;br /&gt;
==== values ====&lt;br /&gt;
&lt;br /&gt;
* values(''map'')&lt;br /&gt;
&lt;br /&gt;
Extracts the values assigned to keys from an input ''map'' and returns them as a list. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
values(['Elvish Fighter' -&amp;gt; 50, 'Elvish Archer' -&amp;gt; 60])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns&lt;br /&gt;
&lt;br /&gt;
 [50, 60]&lt;br /&gt;
&lt;br /&gt;
=== List-processing Functions ===&lt;br /&gt;
&lt;br /&gt;
This section covers functions that operate on maps or lists by applying one or more formulas in succession to each element. Most return another map or list, &amp;lt;code&amp;gt;reduce&amp;lt;/code&amp;gt; instead combines all the elements into a single result.&lt;br /&gt;
&lt;br /&gt;
==== choose ====&lt;br /&gt;
&lt;br /&gt;
* choose(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function evaluates ''formula'' for each item in the ''input'' (which can be a list or a map). It will return the first item to which ''formula'' gave the highest value. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
choose(my_units, level)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
gives back the unit with the highest level.&lt;br /&gt;
&lt;br /&gt;
The implicit input when evaluating a mapping/filtering function's ''formula'' component will be that specific item under evaluation (in this example one of &amp;quot;my_units&amp;quot;), and it can be explicitly referenced as &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; when necessary. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
When evaluating a map, we can reference each key by &amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt; and each value by &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;. In this case, the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable is this key-value pair. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
choose(['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20 ], value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return a key-value pair &lt;br /&gt;
&lt;br /&gt;
 {key-&amp;gt;'dwarf', value-&amp;gt;20}&lt;br /&gt;
&lt;br /&gt;
The curly braces are used in output to indicate that this is an object, not a map. It is not valid WFL syntax.&lt;br /&gt;
&lt;br /&gt;
==== filter ====&lt;br /&gt;
&lt;br /&gt;
* filter(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on each item in the ''input'' (which can be a list or a map). It will evaluate to a list or map which only contains items that the ''formula'' was true for. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
filter(my_units, hitpoints &amp;lt; max_hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return all of your units which have less than maximum hitpoints. For instance this could be used if looking for candidates for healing.&lt;br /&gt;
&lt;br /&gt;
==== find ====&lt;br /&gt;
 &lt;br /&gt;
* find(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run &amp;lt;formula&amp;gt; on each item in the &amp;lt;input&amp;gt; (which can be a list or a map) and will return the first item for which &amp;lt;formula&amp;gt; was true. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
find(units, type = 'Elvish Archer' )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will return the first unit of type 'Elvish Archer'.&lt;br /&gt;
&lt;br /&gt;
==== map ====&lt;br /&gt;
&lt;br /&gt;
* map(''input'', [''self_name'',] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on each item in the ''input'' (which can be a list or a map), and evaluate to a new list or map or a map, which contains the same number of items as in ''input'', with the formulas run on each item. The optional &amp;lt;self_name&amp;gt; parameter can be used to give a different name to the &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; variable. When run on a map, the resulting map has the same keys as the input map, but with the values updated to the results of the ''formula''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map([10,20], self*self)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map([10,20], 'value', value*value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will both result in [100, 400]. The formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(my_units, hitpoints)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will give a list back with the number of hitpoints each unit has. This is more useful in conjunction with other functions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(['elf' -&amp;gt; 10, 'dwarf' -&amp;gt; 20 ], value*2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above will produce ['elf' -&amp;gt; 20, 'dwarf' -&amp;gt; 40]. Note that in case of a map data type, the &amp;lt;code&amp;gt;map&amp;lt;/code&amp;gt; function can only modify the value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
map(tomap([3,5,8,8]), value+key*100)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above will produce &amp;lt;code&amp;gt;[3 -&amp;gt; 301, 5 -&amp;gt; 502, 8 -&amp;gt; 801]&amp;lt;/code&amp;gt;. This can be used to take a list and make a map containing pairs &amp;lt;code&amp;gt;[element_from_that_list -&amp;gt; f(element_from_that_list,number_of_repetitions_of_that_element_in_that_list)]&amp;lt;/code&amp;gt; where &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; is an arbitrary function.&lt;br /&gt;
&lt;br /&gt;
==== reduce ====&lt;br /&gt;
&lt;br /&gt;
* reduce(''list'', [''identity'', ] ''formula'')&lt;br /&gt;
&lt;br /&gt;
This function will run the ''formula'' on the first and second members of the ''list'', then on the result and the third member and so on until the list is depleted. The final result is then returned. The two variables used in the ''formula'' are always 'a' and 'b'.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;reduce([1,2,3,4], a+b)&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;syntaxhighlight lang='wfl' inline&amp;gt;reduce([9,4,8,2], 10*a+b)&amp;lt;/syntaxhighlight&amp;gt; returns &amp;lt;code&amp;gt;9482&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The new ''identity'' argument specifies the starting value (which is null or 0 by default). If ''list'' is empty, then ''identity'' is returned. Otherwise, the list will be considered as if ''identity'' were an extra first element. For example, to calculate the product of a list of numbers, you might do something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
reduce(your_list, 1, a * b)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will return 1 if the list is empty, as expected - the product of no numbers is 1. If the list is not empty, adding 1 to the list will have no effect, since it is the multiplicative identity.&lt;br /&gt;
&lt;br /&gt;
==== take_while ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* take_while(''list'', ''formula'')&lt;br /&gt;
&lt;br /&gt;
Evaluates the ''formula'' for each element of the ''list'' until it finds one for which it evaluates to false, then returns a list of all elements up to but not including that element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
take_while([1,5,3,6,3,7,9,5,6,4,12,2,53,2,1], self &amp;lt; 10)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns the list &amp;lt;code&amp;gt;[1,5,3,6,3,7,9,5,6,4]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== zip ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* zip(''list1'', ... , ''listN'')&lt;br /&gt;
* zip(''list of lists'')&lt;br /&gt;
&lt;br /&gt;
Takes a list of lists and generates a new list of lists such that list ''n'' contains element ''n'' of each of the original lists, in order. If the lists are not all of the same length, it treats them as if they were padded on the end with null values so that they are all the length of the longest list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
zip([1,2,3],[4,5,6])&lt;br /&gt;
zip([1,4],[2,5],[3,6])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
return &amp;lt;code&amp;gt;[[1,4],[2,5],[3,6]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[1,2,3],[4,5,6]]&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Location Functions ===&lt;br /&gt;
&lt;br /&gt;
Functions for working with locations on a hex map.&lt;br /&gt;
&lt;br /&gt;
==== adjacent_locs ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* adjacent_locs(''center'')&lt;br /&gt;
&lt;br /&gt;
Returns a list of all locations adjacent to the specified location. When called from a formula with access to the game state, it automatically excludes locations that don't exist on the map. Otherwise, it operates as if on an infinite map. This means you should generally not expect the returned list to contain exactly 6 elements.&lt;br /&gt;
&lt;br /&gt;
==== are_adjacent ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* are_adjacent(''loc1'', ''loc2'')&lt;br /&gt;
&lt;br /&gt;
Check if two locations are adjacent. Returns 1 (true) or 0 (false).&lt;br /&gt;
&lt;br /&gt;
==== direction_from ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* direction_from(''start'', ''direction'', [''distance''])&lt;br /&gt;
&lt;br /&gt;
Returns the hex reached by travelling in the specified direction from a starting hex for a certain distance (default 1 hex).&lt;br /&gt;
&lt;br /&gt;
==== distance_between ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* distance_between(''start'', ''end'')&lt;br /&gt;
&lt;br /&gt;
Returns the distance between the locations ''start'' and ''end'', which must be location objects such as those created by &amp;lt;code&amp;gt;loc()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This function was already available in FormulaAI prior to 1.13.5; however, from 1.13.5 onward it is available to all formulas.&lt;br /&gt;
&lt;br /&gt;
==== loc ====&lt;br /&gt;
&lt;br /&gt;
* loc(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Creates and returns a location object with the specified coordinates. If assigned to a variable ''pos'' (eg with a &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt; clause), the individual coordinates can be accessed as &amp;lt;code&amp;gt;pos.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pos.y&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== locations_in_radius ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* locations_in_radius(''center'', ''radius'')&lt;br /&gt;
&lt;br /&gt;
Returns a list of all locations within a given radius of the specified center hex.&lt;br /&gt;
Only locations on the map will be returned.&lt;br /&gt;
&lt;br /&gt;
==== relative_dir ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}}&lt;br /&gt;
&lt;br /&gt;
* relative_dir(''loc1'', ''loc2'')&lt;br /&gt;
&lt;br /&gt;
Returns the direction you need to travel to progress from one location to another. The returned location is one of the six possible directions on the Wesnoth hex map, or an empty string if both locations are the same.&lt;br /&gt;
&lt;br /&gt;
==== rotate_loc_around ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|9}} but returns wrong result until {{DevFeature1.19|2}}&lt;br /&gt;
&lt;br /&gt;
* rotate_loc_around(''center'', ''loc'', ''angle'')&lt;br /&gt;
&lt;br /&gt;
Rotates a location around a given center to produce a new location. The angle is an integer between -6 and 6, which can be understood as a multiple of 60 degrees.&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Functions ===&lt;br /&gt;
&lt;br /&gt;
Some functions really don't fit into any category. They are all listed here.&lt;br /&gt;
&lt;br /&gt;
==== null ====&lt;br /&gt;
&lt;br /&gt;
* null([''arguments''])&lt;br /&gt;
&lt;br /&gt;
Evaluates each of its arguments (if any) in order, then returns null. Since formulas generally do not have side-effects, there is little point in specifying any arguments unless you are writing AI code (where several functions do have side-effects).&lt;br /&gt;
&lt;br /&gt;
==== pair ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* pair(''key'', ''value'')&lt;br /&gt;
&lt;br /&gt;
Creates a key-value pair object, the same as those created by the ''tolist'' function.&lt;br /&gt;
&lt;br /&gt;
==== reverse ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* reverse(''string or list'')&lt;br /&gt;
&lt;br /&gt;
Returns the input string or list backwards.&lt;br /&gt;
&lt;br /&gt;
==== type ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}}&lt;br /&gt;
&lt;br /&gt;
* type(''anything'')&lt;br /&gt;
&lt;br /&gt;
Returns the type of its input as a string. Possible results are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;'integer'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'decimal'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'string'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'list'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'map'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'null'&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;'object'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging Functions ===&lt;br /&gt;
&lt;br /&gt;
There are also a few functions that can be useful for debugging formulas, for example by displaying intermediate results to the screen. Note that this breaks the general rule that functions do not have side-effects.&lt;br /&gt;
&lt;br /&gt;
==== debug ====&lt;br /&gt;
&lt;br /&gt;
* debug([''formula''])&lt;br /&gt;
&lt;br /&gt;
Starts a GUI formula AI debugger when evaluating a formula. It takes a formula, evaluates it and returns the result unchanged. '''Note:''' this does not appear to work in 1.13.3.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|5}} The formula allows you to step through the formula one operation at a time, viewing the current stack and execution trace. As of 1.13.5, you need to enable [[CommandMode|debug mode]] to use the debugger; otherwise, it will simply be skipped.&lt;br /&gt;
&lt;br /&gt;
==== debug_print ====&lt;br /&gt;
&lt;br /&gt;
'''you need to enable formula log (--log-info='scripting/formula') to see the result of this call'''&lt;br /&gt;
&lt;br /&gt;
* debug_print([''explanation'' ,] ''formula'' )&lt;br /&gt;
&lt;br /&gt;
This function can be used for debugging a formula. It takes a ''formula'', writes its result to the console, and returns it unchanged. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_print([1, 2, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in printing to the console&lt;br /&gt;
&lt;br /&gt;
 [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
and returning the same.&lt;br /&gt;
&lt;br /&gt;
We can specify an optional parameter ''explanation'' that helps to distinguish between multiple ''debug_print'' calls in the same formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_print('My array: ', [1, 2, 3])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will write in the console:&lt;br /&gt;
&lt;br /&gt;
 My array: [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
and return&lt;br /&gt;
&lt;br /&gt;
 [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
==== debug_profile ====&lt;br /&gt;
&lt;br /&gt;
* debug_profile(''formula'' [, ''explanation''])&lt;br /&gt;
&lt;br /&gt;
Evaluates the formula 1000 times and prints (as with debug_print) a number indicating the average time required to evaluate the formula. Mainly intended for internal testing, but could occasionally be useful for people working with complicated formulas. The optional ''explanation'' argument is used in the same way as in debug_print.&lt;br /&gt;
&lt;br /&gt;
==== debug_float ====&lt;br /&gt;
&lt;br /&gt;
* debug_float(''location'', [''explanation'',] ''formula'' )&lt;br /&gt;
&lt;br /&gt;
This function can be used for debugging a formula. It takes a formula, floats a label containing the result on the hex specified (in the same way damage is displayed) and returns it unchanged. Note that the ''location'' here is an object type; it can be created with the &amp;lt;code&amp;gt;[[#loc|loc()]]&amp;lt;/code&amp;gt; function. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_float(me.loc, me.id)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will make a label containing the id of the unit ''me'' float over the unit.&lt;br /&gt;
&lt;br /&gt;
Return value is also the unit id.&lt;br /&gt;
&lt;br /&gt;
We can specify an optional parameter ''explanation'' that helps to distinguish between multiple ''debug_float'' calls in the same formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
debug_float( me.loc, 'id: ', me.id )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will float the following label&lt;br /&gt;
&lt;br /&gt;
 id: unit_id&lt;br /&gt;
&lt;br /&gt;
and return the unit id.&lt;br /&gt;
&lt;br /&gt;
==== dir ====&lt;br /&gt;
&lt;br /&gt;
* dir(''object'')&lt;br /&gt;
&lt;br /&gt;
This function return a list of all attributes in ''object''. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wfl'&amp;gt;&lt;br /&gt;
dir(my_leader)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in the following output:&lt;br /&gt;
&lt;br /&gt;
 [ 'x', 'y', 'loc', 'id', 'type', 'name', 'leader', 'undead', 'traits', 'attacks', 'abilities', 'hitpoints',&lt;br /&gt;
 'max_hitpoints', 'experience', 'max_experience', 'level', 'total_movement', 'movement_left', 'attacks_left',&lt;br /&gt;
 'side', 'states', 'cost', 'usage', 'vars']&lt;br /&gt;
&lt;br /&gt;
This command is useful in the formula command line, to get information about the attributes of different types of data.&lt;br /&gt;
&lt;br /&gt;
=== Game State Functions ===&lt;br /&gt;
&lt;br /&gt;
These are functions that access the game state. Therefore, they are not available in all formulas, as described above.&lt;br /&gt;
&lt;br /&gt;
==== base_tod_bonus ====&lt;br /&gt;
&lt;br /&gt;
* base_tod_bonus([''loc'', [''turn'']])&lt;br /&gt;
&lt;br /&gt;
Evaluates the base time-of-day bonus, excluding the effect of illumination from abilities or terrain. If no turn is specified, the current turn is used. If no location is specified, the bonus is calculated for the global schedule without taking any time areas into account, but if a location is specified, it will account for any time areas that might affect that location.&lt;br /&gt;
&lt;br /&gt;
==== chance_to_hit ====&lt;br /&gt;
&lt;br /&gt;
* chance_to_hit(''unit'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the base chance for the unit to be hit if it moved to the given location or terrain. This is essentially the inverse of its defense. It is returned as an integer between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
==== defense_on ====&lt;br /&gt;
&lt;br /&gt;
* defense_on(''unit'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the defense that the unit would have if it moved to the given location or terrain. It is returned as an integer between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
==== enemy_of ====&lt;br /&gt;
&lt;br /&gt;
* enemy_of(''self'', ''other'')&lt;br /&gt;
&lt;br /&gt;
Determines whether two units are enemies. Returns 1 (true) or 0 (false).&lt;br /&gt;
&lt;br /&gt;
==== get_unit_type ====&lt;br /&gt;
&lt;br /&gt;
* get_unit_type(''id'')&lt;br /&gt;
&lt;br /&gt;
Returns an object describing the specified unit type, or null if no such unit type exists. A unit type object has many of the same keys as a unit, excluding those that are expected to change over time such as &amp;lt;tt&amp;gt;hitpoints&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== jamming_cost ====&lt;br /&gt;
&lt;br /&gt;
* jamming_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the jamming cost for the unit to block vision on the given location terrain.&lt;br /&gt;
&lt;br /&gt;
==== movement_cost ====&lt;br /&gt;
&lt;br /&gt;
* movement_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the movement cost for the unit to enter the given location or terrain.&lt;br /&gt;
&lt;br /&gt;
==== resistance_on ====&lt;br /&gt;
&lt;br /&gt;
* resistance_on(''unit'', ''location'', ''type'', [''attacker''])&lt;br /&gt;
&lt;br /&gt;
Calculates the unit's resistance to the given damage type when standing on the specified location. If specified, the ''attacker'' parameter should be 1 to indicate that the unit is the attacker, or 0 to indicate that it is the defender, as this status can affect resistances. By default, it is assumed to be the defender.&lt;br /&gt;
&lt;br /&gt;
This is returned not as the raw resistance set in WML, but the actual resistance that the player sees, so it ranges between -100 and 100.&lt;br /&gt;
&lt;br /&gt;
==== tod_bonus ====&lt;br /&gt;
&lt;br /&gt;
* tod_bonus([''loc'', [''turn'']])&lt;br /&gt;
&lt;br /&gt;
Evaluates the final time-of-day bonus, accounting for the effect of illumination from abilities or terrain. If no turn is specified, the current turn is used. If no location is specified, the bonus is calculated for the global schedule without taking any time areas into account, but if a location is specified, it will account for any time areas that might affect that location.&lt;br /&gt;
&lt;br /&gt;
==== unit_at ====&lt;br /&gt;
&lt;br /&gt;
* unit_at(''location'')&lt;br /&gt;
&lt;br /&gt;
Returns the unit on the given location, or null if there is no unit there.&lt;br /&gt;
&lt;br /&gt;
==== vision_cost ====&lt;br /&gt;
&lt;br /&gt;
* vision_cost(''unit or unit type'', ''location or terrain'')&lt;br /&gt;
&lt;br /&gt;
Calculates the vision cost for the unit to see through the given location or terrain.&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=73208</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=73208"/>
		<updated>2024-07-07T09:05:36Z</updated>

		<summary type="html">&lt;p&gt;Laela: /* Multiplayer safety */&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 [[ActionWML|actions]] which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer] 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;
'''Lexicon side note:''' ''The word &amp;quot;event&amp;quot; in the [event] tag itself may be considered an abbreviation of the term &amp;quot;event handler&amp;quot; because it is technically not a game &amp;quot;event&amp;quot; but an event '''handler''' for the game events fired with the given 'name'. However, this distinction is usually unimportant in most discussions and the event handlers are therefore simply referred to as &amp;quot;events&amp;quot; in this documentation.''&lt;br /&gt;
&lt;br /&gt;
=== The 'name' Key (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=&amp;lt;value&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This key defines which game event or trigger your [event] tag will be handling. This 'name' key should not be confused with a descriptive comment; it is rather a precise value which must match the predefined game event's name to be valid.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=attacker misses,defender misses&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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;
All predefined event types are listed below, along with a description of when this value will cause the event to be triggered, in the [[#Predefined_Events_Without_Filters|Predefined Events Without Filters]] and [[#Predefined_Events_With_Filters|Predefined Events With Filters]] sections. Any value ''not'' listed there is a custom event name which can be triggered only by a '''[fire_event]''' tag somewhere else. &lt;br /&gt;
&lt;br /&gt;
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;
==== Variables in the name ====&lt;br /&gt;
&lt;br /&gt;
If the name contains variables, they will be substituted each time the event is triggered. For example, '''name=turn $disaster_turn''' will only trigger if the turn number is currently equal to whatever number is stored in the variable '''$disaster_turn'''; updating the variable will adjust the turn that the event triggers on. However, if the variable contents contains a comma, it won't be parsed after substitution. Since an event name can't contain a comma, this means the event will never trigger.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Commas resulting from variable substitution are now parsed. If you write '''name=$important_event''' and the variable '''$important_event''' contains the text &amp;quot;capture,die&amp;quot;, the event will trigger on either a death or a village capture.&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. Also, custom events come very handy in [[Wml_optimisation]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# The following is the definition of a custom event &amp;quot;unit recruited&amp;quot;&lt;br /&gt;
[event]&lt;br /&gt;
    name=unit_recruited&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=unit&lt;br /&gt;
        message=_ &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
[/event]&lt;br /&gt;
&lt;br /&gt;
# This is a standard recruit event that triggers whenever a unit is recruited by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recruit&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # And now a fire_event tag is used to trigger the previously defined event. To use&lt;br /&gt;
    # &amp;quot;speaker=unit&amp;quot; in the fired event, it's also necessary to specify the [primary_unit].&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # As a result, every time side 1 recruits a unit, this unit says &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can have more code after the '''[fire_event]''', which will run after the fired event has happened.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# This is a standard recall event that triggers whenever a unit is recalled by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recall&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # Fire the custom event, exactly as the in recruit event&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # After that event has happened, the remaining code in this event is run&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=second_unit&lt;br /&gt;
        message=_ &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
    # As a result, every time side 1 recalls a unit, the recalled unit says&lt;br /&gt;
    # &amp;quot;Reporting for duty!&amp;quot;, and the leader replies &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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 trigger every time the criteria are met instead of only the first time.&lt;br /&gt;
&lt;br /&gt;
==== id ====&lt;br /&gt;
: If an id is specified, then the event will not be added if another event with the same id already exists. An id will also allow the event to be removed, see below. Supplying a non-empty id= is mandatory in case of a [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
==== remove ====&lt;br /&gt;
: Removes an event instead of adding a new one. This key takes a [[ConditionalActionsWML#Boolean_Values|boolean]]; if yes, does the same as a [[InternalActionsWML#.5Bremove_event.5D|[remove_event]]] with the same id= value, and the other attributes of this event tag are ignored.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} May be a comma separated list.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|7}} Prints a deprecation warning recommending to use [remove_event] instead.&lt;br /&gt;
&lt;br /&gt;
==== priority ====&lt;br /&gt;
: {{DevFeature1.17|20}} If several '[event]' tags have the same name, then any with a high priority value will be triggered before events with a lower priority value. Negative numbers are also supported, to run after events without a priority (as the attribute defaults to zero). For events with equal priority, the order is determined by the order in which the events were added.&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 based on the weapon used by the primary unit. This is usable in the events ''attack'', ''attacker hits'', ''attacker misses'', ''defender hits'', ''defender misses'', ''attack end'', ''last breath'', and ''die''. For more information and filter keys, see [[FilterWML#Filtering Weapons|Filtering Weapons]]. The most commonly used keys are the following.&lt;br /&gt;
:* '''name''': the name of the weapon used.&lt;br /&gt;
:* '''range''': the range of the weapon used.&lt;br /&gt;
:* '''special_id''': filter on the attack's weapon special id.&lt;br /&gt;
:* '''special_type''': filter on the attack's weapon special type.&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_id_active''': filter on the attack's weapon special id active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_type_active''': filter on the attack's weapon special type active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
&lt;br /&gt;
==== [filter_second_attack] ====&lt;br /&gt;
: Like [filter_attack], but for the weapon used by the secondary unit.&lt;br /&gt;
&lt;br /&gt;
==== [filter_condition] ====&lt;br /&gt;
: This tag makes sense inside any sort of event - even those that don't have units, or custom events,... The event will only trigger if this condition evaluates to true.&lt;br /&gt;
:* [[ConditionalActionsWML#Condition_Tags|Condition Tags]]&lt;br /&gt;
: note: This tag is meant to be used when the firing of an event shall be based on variables/conditions which cannot be retrieved from the filtered units.&lt;br /&gt;
&lt;br /&gt;
==== [filter_side] ====&lt;br /&gt;
: The current side (usually the side $side_number) must match the passed [[StandardSideFilter]] for the event to fire.&lt;br /&gt;
:* SSF tags and keys as arguments as described in [[StandardSideFilter]].&lt;br /&gt;
: note: This tag makes most sense in side turn and turn refresh events. However, all wml events have a current side so one could also prevent e.g. a moveto event from firing if you put a [filter_side] tag there and the moving unit's side doesn't match.&lt;br /&gt;
&lt;br /&gt;
==== [insert_tag] ====&lt;br /&gt;
: An '''[insert_tag]''' that expands to any of the above filter tags will result in the filter being loaded from the variable each time the game checks if the event should fire. This can result in the event's filter varying from turn to turn.&lt;br /&gt;
&lt;br /&gt;
==== filter_formula ====&lt;br /&gt;
:{{DevFeature1.17|6}}&lt;br /&gt;
: Similar to [filter_condition], but the condition is expressed in [[Wesnoth Formula Language]]. The formula has access to the following keys:&lt;br /&gt;
:*Event information:&lt;br /&gt;
:**'''event''' - the event name&lt;br /&gt;
:**'''event_id''' - the event's unique ID&lt;br /&gt;
:**'''event_data''' - additional information specific to the event, such as owner_side or damage_inflicted, or anything passed in '''[fire_event][data]'''.&lt;br /&gt;
:**'''loc''', '''unit''' - primary event location and unit&lt;br /&gt;
:**'''second_loc''', '''second_unit''' - secondary event location and unit&lt;br /&gt;
:**'''weapon''', '''second_weapon''' - primary and secondary weapon&lt;br /&gt;
:*Gamestate information:&lt;br /&gt;
:**'''turn_number'''&lt;br /&gt;
:**'''time_of_day''' - the time of day ID&lt;br /&gt;
:**'''side_number''' - currently active side&lt;br /&gt;
:**'''sides''' - a list of all sides&lt;br /&gt;
:**'''units''' - a list of all units on the map&lt;br /&gt;
:**'''map''' - the entire game map as a two-dimensional array&lt;br /&gt;
&lt;br /&gt;
==== delayed_variable_substitution ====&lt;br /&gt;
: This key is only relevant inside of a [[#Delayed Variable Substitution_2|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 [[ActionWML|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;
More details in [[ActionWML]]. Actions can also be dynamically inserted via '''[insert_tag]'''.&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;
In multiplayer it is only safe to use WML that might require synchronization with other players because of input or random numbers (like [message] with input or options or [unstore_unit] where a unit might advance) in the following events. This is because in these cases WML needs data from other players to work right and/or do the same thing for all players. This data is only available after a network synchronization.&lt;br /&gt;
&lt;br /&gt;
List of synchronized events:&lt;br /&gt;
* moveto&lt;br /&gt;
* enter hex&lt;br /&gt;
* exit hex&lt;br /&gt;
* sighted&lt;br /&gt;
* last breath &lt;br /&gt;
* menu item X&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;
* pre advance&lt;br /&gt;
* post advance &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;
* unit hits&lt;br /&gt;
* unit misses&lt;br /&gt;
* start&lt;br /&gt;
* prestart (prestart are synced but [message][option] &amp;amp; [unstore_unit] advancement choices will do a random decision because UI things don't work during prestart events.)&lt;br /&gt;
* new turn &lt;br /&gt;
* side turn &lt;br /&gt;
* turn X &lt;br /&gt;
* side X turn &lt;br /&gt;
* side X turn Y &lt;br /&gt;
* turn refresh&lt;br /&gt;
* side turn end&lt;br /&gt;
* side X turn end&lt;br /&gt;
* side turn X end&lt;br /&gt;
* side X turn Y end&lt;br /&gt;
* turn end&lt;br /&gt;
* turn X end&lt;br /&gt;
* {{DevFeature1.13|0}} enemies defeated&lt;br /&gt;
* {{DevFeature1.13|0}} time over&lt;br /&gt;
* {{DevFeature1.13|10}} victory&lt;br /&gt;
* {{DevFeature1.13|10}} defeat&lt;br /&gt;
* {{DevFeature1.13|0}} scenario_end&lt;br /&gt;
The following are &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; synced:&lt;br /&gt;
* select&lt;br /&gt;
* preload&lt;br /&gt;
* victory {{DevFeature1.13|10}} local_victory&lt;br /&gt;
* defeat {{DevFeature1.13|10}} local_defeat&lt;br /&gt;
* ai turn&lt;br /&gt;
&lt;br /&gt;
If an event is not listed here, ask someone to be sure.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility of events that are normally synchronized when fired by the engine but can be non-synchronized when fired by WML tags from non-synchronized event. So when you are using them you must be extra careful. For example [unstore_unit] may trigger a 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;
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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
=== Event IDs ===&lt;br /&gt;
&lt;br /&gt;
This problem can be avoided by setting an '''id''' on the event, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
#define DOUBLE&lt;br /&gt;
    [event]&lt;br /&gt;
        name=multiply_by_2&lt;br /&gt;
        id=doubler_event&lt;br /&gt;
        {VARIABLE_OP 2_becomes_4 multiply 2}&lt;br /&gt;
    [/event]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Events with the same ID will only be accepted once by the engine no matter how many times they are included, and will only be saved once to the scenario's savefile.  Events with an ID can also be removed by using the '''remove''' key, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    id=doubler_event&lt;br /&gt;
    remove=yes&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that WML is encountered (at toplevel or after created from another event), the event with this ID is removed from the scenario wml, thus firing it has no effect.  After an event is removed, it can still be re-added later.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events Without Filters ==&lt;br /&gt;
&lt;br /&gt;
These events do not take filter parameters (except [filter_condition] which works for all events).&lt;br /&gt;
&lt;br /&gt;
=== preload ===&lt;br /&gt;
&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.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a game is started, saved, and then reloaded, the preload event will fire two times while playing.  However, it will only fire once when viewing the replay. If the preload event alters the gamestate the second time it fired while playing (when loading the saved game) then it can result in Out Of Sync errors.&lt;br /&gt;
&lt;br /&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;
&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.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers after the map is shown but before the scenario begins -- before players can 'do' anything.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers at the start of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. 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;
=== turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. The WML variable '''side_number''' will contain the side that ended their turn.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of turn ''X''.&lt;br /&gt;
&lt;br /&gt;
=== side turn ===&lt;br /&gt;
&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;
&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. Note that this event might be called several times per turn in case that fallbacks to human or droiding is involved. I.e. it happens at the middle of turn of human side 1 if the human player droids his side. It happens after the selection of ai to play the turn but before AI is told that new turn has come.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''  ''This event can break replays if it is used improperly. The ai turn event does not fire during replays. The intention is only to guide the AI to make choices (movements, attacks) which are then saved to the replay.''&lt;br /&gt;
&lt;br /&gt;
=== turn refresh ===&lt;br /&gt;
&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. WML variable '''side_number''' holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
Note that the turn refresh event does occur on turn 1, even though healing, income and unit refreshing do not.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the start of turn ''X''. It's the first side initialization event. &lt;br /&gt;
&lt;br /&gt;
Side initialization events go in the order of: &lt;br /&gt;
&lt;br /&gt;
# '''turn ''X''''' &lt;br /&gt;
# '''new turn''' &lt;br /&gt;
# '''side turn''' &lt;br /&gt;
# '''side ''X'' turn''' &lt;br /&gt;
# '''side turn ''X''''' &lt;br /&gt;
# '''side ''X'' turn ''Y''''' &lt;br /&gt;
# '''turn refresh''' &lt;br /&gt;
# '''side ''X'' turn refresh''' &lt;br /&gt;
# '''turn ''X'' refresh''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' refresh'''&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ''Y'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of turn ''Y'' of side X &lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any turn of side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any side on turn X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side X turn Y refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X on turn Y&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers for any side at the refresh of turn X.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers after a side ends its turn. Like side turn, there are also some variations for specific combinations of side number and turn number. Here is the order in which the turn end events trigger:&lt;br /&gt;
&lt;br /&gt;
# '''side turn end''' &lt;br /&gt;
# '''side ''X'' turn end''' &lt;br /&gt;
# '''side turn ''X'' end''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' end''' &lt;br /&gt;
# '''turn end''' &lt;br /&gt;
# '''turn ''X'' end''' &lt;br /&gt;
&lt;br /&gt;
=== time over ===&lt;br /&gt;
&lt;br /&gt;
Triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
&lt;br /&gt;
=== enemies defeated ===&lt;br /&gt;
&lt;br /&gt;
Triggers when all sides that are not defeated are allied and if there is at least one human (or human networked) side among them. Especially this event triggers in a situaltion that would normaly cause a victory due to enemies defeated. (regardless of whether this was disabled with victory_when_enemies_defeated=no). &lt;br /&gt;
&lt;br /&gt;
=== local_victory ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 and earlier, the event described here is '''victory''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the player's side won. If it fires as a result of an '''[endlevel]''' tag, the event is processed before the line after the '''[endlevel]]''' tag. The event is not synchronized, as in networked mp it is possible to have different results for different players.&lt;br /&gt;
&lt;br /&gt;
=== local_defeat ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 are earlier, the event described here is '''defeat''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
Functions identically to '''local_victory''', except that the player's side lost.&lt;br /&gt;
&lt;br /&gt;
=== victory ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''victory''' event is equivalent to 1.14's '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game will proceed to the next scenario. In multiplayer, this means that it will fire on all players' clients, even for players who received a '''local_defeat''', as long as the game continues to the next scenario. This event is synchronized.&lt;br /&gt;
&lt;br /&gt;
It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:next_level&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.&lt;br /&gt;
&lt;br /&gt;
=== defeat ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''defeat''' event is equivalent to 1.14's '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game resulted in a game-over other than victoriously reaching the end of a campaign (including single-scenario campaigns). Synchronization (including bug #4667) is the same as '''victory'''.&lt;br /&gt;
&lt;br /&gt;
=== scenario_end ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|10}} This event fires immediately after '''victory''' or '''defeat'''; it is synchronized, but is also affected by bug #4667.&lt;br /&gt;
&lt;br /&gt;
Note: in 1.13.0 - 1.13.9 this event was added as a synchronized alternative to the events that are, since 1.13.10, called local_victory or local_defeat.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events With Filters ==&lt;br /&gt;
&lt;br /&gt;
Filters (except [filter_condition] which is for all sorts of events) 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]]. weapon and second_weapon variables are available inside attack, attacker_hits, defender_hits, unit_hits, die and last_breath events. See [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== moveto ===&lt;br /&gt;
&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. If the unit moves to a village, the capture event will be fired before this event. &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 undo other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.'' $x2 and $y2 refer to the hex the unit came from.&lt;br /&gt;
&lt;br /&gt;
=== sighted ===&lt;br /&gt;
&lt;br /&gt;
A '''sighted''' event is triggered by a unit becoming visible to a side (other than the unit's own side). This is mostly useful when the side seeing the unit uses [[fog of war]] or [[shroud]], but they still fire even when fog/shroud is not in use, and they do take into account the {{tag2|AbilitiesWML#The_.5Babilities.5D_tag|hides}} ability (for a moving unit and for ambushers). The ''primary unit'' is the unit that became visible, and the ''secondary unit'' belongs to the side that now sees the primary unit. In some cases, sighted events can be delayed from when they &amp;quot;should&amp;quot; occur. If that happens, the secondary unit will be filtered as if it was at the location where the event &amp;quot;should&amp;quot; have occurred, and ''x2,y2'' will store that location (not the current position of the secondary unit). To understand when sighted events fire, it is helpful to distinguish the times the acting unit sights other units from the times when the acting unit is sighted.&lt;br /&gt;
&lt;br /&gt;
An acting unit can sight other units when it is recruited, recalled, leveled, or moved, and when fog or shroud is cleared from occupied hexes as a result. In these cases, the acting unit is always the ''secondary unit''. For the first three actions, there are two events associated with the action; clearing occurs between these events, but any sighted events are fired after the second event. (For example, when a unit is recruited, the ''prerecruit'' event fires, then fog is cleared, then the ''recruit'' event fires, then ''sighted'' events fire.) For movement, the sighted events fire between ''enter_hex'' and ''exit_hex'' events, but sometimes sighted events are postponed until the moving unit reaches a good place to stop (e.g. not in an occupied hex). As a major exception to the above, players have the option to delay shroud (and fog) updates. If the player delays shroud updates, sighted events are also delayed until the shroud is updated.&lt;br /&gt;
&lt;br /&gt;
An acting unit can be sighted by other sides when it is recruited, recalled, leveled (in rare cases), or moved. In these cases, the acting unit is always the ''primary unit''. These events fire after sightings by the acting unit (unless the player delayed shroud updates). For the first two, the sighted event fires for all sides that can see the unit, other than the unit's own side (even if those sides use neither fog nor shroud). For leveling units, sides that could see the unit before it leveled are excluded. (This is why these events are rare &amp;amp;ndash; the leveling unit must have lost a [hides] ability as a result of leveling in order to be seen after, but not before, leveling.) For movement, a sighted event is fired for each side that could see the unit after movement, but not before. In particular, only the starting and ending hexes are considered; a unit that moves through seen hexes but ends movement in a fogged hex does not trigger a sighted event for itself. In all cases where the acting unit is sighted, a (single) ''secondary unit'' is chosen from the sighting team. This choice should be considered arbitrary, but units within their sight range of the acting unit are chosen in preference to units further away. You may want to use [filter_second] in order to restrict a sighted event in a single player scenario to only being triggered by the player and not by other non-allied sides.&lt;br /&gt;
&lt;br /&gt;
Sighted events are not triggered by a ''hides'' ability becoming inactive, unless it becomes inactive due to that unit's movement or to that unit ambushing another. (To detect a ''nightstalk'' ability becoming inactive due to time of day, use a ''new_turn'' event. Custom ''hides'' abilities might need similar handling.)&lt;br /&gt;
&lt;br /&gt;
Sighted events have some special caveats for WML authors. First and foremost, {{tag|DirectActionsWML|allow_undo}} should generally be avoided in sighted events. It can be used if current unit positions have no bearing on the event, but otherwise it could cause a replay to go out of sync if a player delays shroud updates and undoes a move. This should not be an onerous restriction, though, as clearing fog will block the ability to undo, regardless of what happens within an event. Secondly, it is currently possible for WML to kill a unit involved in a sighted event before that event fires. If that happens, filters on the killed unit will not match anything and the event may seem to have not fired.&lt;br /&gt;
&lt;br /&gt;
=== enter_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex entered during movement, with $x1,$y1 identifying the hex entered and $x2,$y2 identifying the previous hex (just exited). In Wesnoth 1.12, the movement will be interrupted, stopping the unit where it is; this behavior can be avoided by using the {{tag|DirectActionsWML|allow_undo}} tag or `NO_INTERRUPT_NO_UNDO` macro. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the entered hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (7ca5a0df, just before 1.13.11), if the hex is occupied then $unit contains the occupying unit, not the moving unit.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (1.16.2), if the hex is occupied then $unit does contain the moving unit.&lt;br /&gt;
&lt;br /&gt;
=== exit_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex exited during movement, with $x1,$y1 identifying the hex exited and $x2,$y2 identifying the next hex (to be entered). If this event is handled without using {{tag|DirectActionsWML|allow_undo}}, then movement is interrupted, stopping the unit where it is. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the exited hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
=== pre attack {{DevFeature1.17|7}}===&lt;br /&gt;
&lt;br /&gt;
Similar to '''attack''', but is triggered before calculating the number of attacks and the movement of the unit. Can be used for modifications, which affect these values.&lt;br /&gt;
&lt;br /&gt;
=== attack ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit attacks the secondary unit. Variables $weapon and $second_weapon contain weapons used for this attack by primary and secondary units respectively for all attack-related events (attack_end, attacker_hits, attacker_misses, defender_hits, defender_misses, die and last_breath).&lt;br /&gt;
&lt;br /&gt;
=== attack end ===&lt;br /&gt;
&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;
&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;
&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;
&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;
&lt;br /&gt;
Same as ''defender hits'', but is triggered when the defender misses.&lt;br /&gt;
&lt;br /&gt;
=== unit hits {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the the primary unit (either attacker or defender) hits the secondary unit (the other). The value of the WML variable '''damage_inflicted''' is set to the number of hitpoints inflicted by the primary unit.&lt;br /&gt;
&lt;br /&gt;
Compared to ''defender hits'', primary and secondary units are swapped. &lt;br /&gt;
&lt;br /&gt;
=== unit misses {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Same as ''unit hits'', but is triggered when the unit misses.&lt;br /&gt;
&lt;br /&gt;
=== petrified ===&lt;br /&gt;
Triggers when the primary unit is hit by an attack with the 'petrifies' ability (See ''petrifies'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'petrifies' ability).&lt;br /&gt;
&lt;br /&gt;
=== last breath ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered. Use this instead of name=die when you want the primary unit to make a final [message]. &lt;br /&gt;
&lt;br /&gt;
=== die ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit. ''Note: The primary unit is not removed from the game until the end of this event. The primary unit can still be manipulated, will block other units from taking its hex, and will still be found by standard unit filters (except [have_unit]). To prevent this behavior, you can use [kill] to remove the unit immediately. However, this will stop any (still unfired) other events that also match the unit from firing afterwards, so use with caution.'' If you want to the primary unit to make a final [message], use name=last_breath, see above.&lt;br /&gt;
&lt;br /&gt;
=== capture ===&lt;br /&gt;
&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. This event will be fired before the moveto event. Villages becoming neutral (via [capture_village]) do not fire capture events. The variable $owner_side contains the previous owner side of the village. 0 means neutral.&lt;br /&gt;
&lt;br /&gt;
=== recruit ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit). (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;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== recall ===&lt;br /&gt;
&lt;br /&gt;
Triggers after the primary unit is recalled (by the secondary unit).&lt;br /&gt;
&lt;br /&gt;
=== prerecall ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recalled (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just before the primary unit is going to advance to another unit, or advance by AMLA. (This is after the player selects which advancement, if there is a choice). If this event removes the unit, changes the unit's type, or reduces the unit's experience below what it needs to advance, then the advancement is aborted. This also applies to advancement by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== pre advance ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} Triggers before the unit advancement dialog is shown. If this event removes the unit or reduces the unit's experience below what it needs to advance, then the advancement is aborted.&lt;br /&gt;
&lt;br /&gt;
Care needs to be taken when tags that may trigger advancement themselves are used in this event. For example '''[transform_unit]''', '''[unstore_unit]''', '''[modify_unit]''' etc.&lt;br /&gt;
&lt;br /&gt;
=== post advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just after the primary unit has advanced to another unit, or advance by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== select ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is selected. Prior to version 1.11, this also triggered when a move was interrupted, 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;
&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;
=== unit placed {{DevFeature1.13|3}}===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is placed on the map, regardless of method. This includes but might not be limited to:&lt;br /&gt;
* Leaders and units placed in side definitions (fired once for every unit right before prestart events)&lt;br /&gt;
* Recruited and recalled units&lt;br /&gt;
* Units placed on the map with the [unit] tag ('''not''' units created directly onto a recall list or variable)&lt;br /&gt;
* Units placed by the wesnoth.put_unit() Lua function&lt;br /&gt;
* Units placed by :to_map in Lua (which is a shortcut for the above)&lt;br /&gt;
* Units created via debug mode&lt;br /&gt;
* Units created by plague &lt;br /&gt;
* Every use of [unstore_unit], when ''fire_event'' is set to ''yes'' (default is ''no'')&lt;br /&gt;
* Units moved on map with [move_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units matching the filter of [petrify], [unpetrify] or [harm_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units who receive a bonus from the feeding ability every time except the first, before {{DevFeature1.15|8}}&lt;br /&gt;
This event is solely intended for special cases where no other event types suffice, for example if you must immediately apply a modification to every unit that ever appears. The event does '''not''' keep track of which units it has previously fired for, but can fire an unlimited number of times for the same unit as long the unit is &amp;quot;placed&amp;quot; several times and the event filter doesn't prevent it.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    name=last breath&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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way of doing this would be to create a single moveto event with a '''[filter_condition]''' statement to check for turn number but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[filter_condition]''' statements. Using '''[if]''' tags is also an option especially if your event has '''first_time_only=yes'''.&lt;br /&gt;
&lt;br /&gt;
=== Delayed Variable Substitution Example ===&lt;br /&gt;
&lt;br /&gt;
This code will display a message showing the turn number on which the nested ''moveto'' event happens.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, the following example is identical to the first two in that it will display a message showing the turn number 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multiple Nested Events ===&lt;br /&gt;
&lt;br /&gt;
Every delayed_variable_substitution=no causes a variable substitution run on the subevent where it occurs at the spawn time of this event and on all following subevents. For any specific event, variable substitution happens at least one time when the event is executed. For each delayed=no key appearing in itself or in an event of an &amp;quot;older&amp;quot; generation, which is not the toplevel event, an additional variable substitution run is made.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event] # parent&lt;br /&gt;
    name=turn 2&lt;br /&gt;
    # delayed_variable_substitution=no # In the parent event, delayed= has no effect.&lt;br /&gt;
 &lt;br /&gt;
    [event] # child&lt;br /&gt;
        name=turn 3&lt;br /&gt;
        delayed_variable_substitution=no # Causes variable substitution in the child, grandchild and great-grandchild event&lt;br /&gt;
        # at execution time of the parent event = spawn time of the child event.&lt;br /&gt;
&lt;br /&gt;
        [event]# grandchild&lt;br /&gt;
            name=turn 4&lt;br /&gt;
            delayed_variable_substitution=yes # no variable substitution in the grandchild and great-grandchild event&lt;br /&gt;
            # at execution time of the child event = spawn time of the grandchild event&lt;br /&gt;
&lt;br /&gt;
            [event] # great-grandchild&lt;br /&gt;
                name=turn 5&lt;br /&gt;
                {DEBUG_MSG $turn_number} # output: 2 - value from the variable substitution at execution time of the parent event,&lt;br /&gt;
                # caused by delayed=no in the child event&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $||turn_number}# output: &amp;quot;$turn_number&amp;quot;&lt;br /&gt;
                # Each variable substitution transforms a &amp;quot;$|&amp;quot; to a &amp;quot;$&amp;quot; (except when no | left).&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $|turn_number}# output: 5 - from the variable substitution at execution time&lt;br /&gt;
                # of the great-grandchild event&lt;br /&gt;
            [/event]&lt;br /&gt;
        [/event]&lt;br /&gt;
    [/event]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=73178</id>
		<title>EventWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=EventWML&amp;diff=73178"/>
		<updated>2024-06-28T22:20:35Z</updated>

		<summary type="html">&lt;p&gt;Laela: unit hits, unit misses&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 [[ActionWML|actions]] which trigger at a certain point in a scenario. When used in a [scenario] tag (also includes [multiplayer] 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;
'''Lexicon side note:''' ''The word &amp;quot;event&amp;quot; in the [event] tag itself may be considered an abbreviation of the term &amp;quot;event handler&amp;quot; because it is technically not a game &amp;quot;event&amp;quot; but an event '''handler''' for the game events fired with the given 'name'. However, this distinction is usually unimportant in most discussions and the event handlers are therefore simply referred to as &amp;quot;events&amp;quot; in this documentation.''&lt;br /&gt;
&lt;br /&gt;
=== The 'name' Key (Mandatory) ===&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=&amp;lt;value&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This key defines which game event or trigger your [event] tag will be handling. This 'name' key should not be confused with a descriptive comment; it is rather a precise value which must match the predefined game event's name to be valid.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
name=attacker misses,defender misses&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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;
All predefined event types are listed below, along with a description of when this value will cause the event to be triggered, in the [[#Predefined_Events_Without_Filters|Predefined Events Without Filters]] and [[#Predefined_Events_With_Filters|Predefined Events With Filters]] sections. Any value ''not'' listed there is a custom event name which can be triggered only by a '''[fire_event]''' tag somewhere else. &lt;br /&gt;
&lt;br /&gt;
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;
==== Variables in the name ====&lt;br /&gt;
&lt;br /&gt;
If the name contains variables, they will be substituted each time the event is triggered. For example, '''name=turn $disaster_turn''' will only trigger if the turn number is currently equal to whatever number is stored in the variable '''$disaster_turn'''; updating the variable will adjust the turn that the event triggers on. However, if the variable contents contains a comma, it won't be parsed after substitution. Since an event name can't contain a comma, this means the event will never trigger.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
Commas resulting from variable substitution are now parsed. If you write '''name=$important_event''' and the variable '''$important_event''' contains the text &amp;quot;capture,die&amp;quot;, the event will trigger on either a death or a village capture.&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. Also, custom events come very handy in [[Wml_optimisation]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# The following is the definition of a custom event &amp;quot;unit recruited&amp;quot;&lt;br /&gt;
[event]&lt;br /&gt;
    name=unit_recruited&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=unit&lt;br /&gt;
        message=_ &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
[/event]&lt;br /&gt;
&lt;br /&gt;
# This is a standard recruit event that triggers whenever a unit is recruited by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recruit&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # And now a fire_event tag is used to trigger the previously defined event. To use&lt;br /&gt;
    # &amp;quot;speaker=unit&amp;quot; in the fired event, it's also necessary to specify the [primary_unit].&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # As a result, every time side 1 recruits a unit, this unit says &amp;quot;Reporting for duty!&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can have more code after the '''[fire_event]''', which will run after the fired event has happened.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
# This is a standard recall event that triggers whenever a unit is recalled by side 1&lt;br /&gt;
[event]&lt;br /&gt;
    name=recall&lt;br /&gt;
    first_time_only=no&lt;br /&gt;
    [filter]&lt;br /&gt;
    [/filter]&lt;br /&gt;
    [filter_second]&lt;br /&gt;
        side=1&lt;br /&gt;
    [/filter_second]&lt;br /&gt;
&lt;br /&gt;
    # Fire the custom event, exactly as the in recruit event&lt;br /&gt;
    [fire_event]&lt;br /&gt;
        name=unit_recruited&lt;br /&gt;
        [primary_unit]&lt;br /&gt;
            id=$unit.id&lt;br /&gt;
        [/primary_unit]&lt;br /&gt;
    [/fire_event]&lt;br /&gt;
 &lt;br /&gt;
    # After that event has happened, the remaining code in this event is run&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=second_unit&lt;br /&gt;
        message=_ &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
    # As a result, every time side 1 recalls a unit, the recalled unit says&lt;br /&gt;
    # &amp;quot;Reporting for duty!&amp;quot;, and the leader replies &amp;quot;Glad to have you back&amp;quot;&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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 trigger every time the criteria are met instead of only the first time.&lt;br /&gt;
&lt;br /&gt;
==== id ====&lt;br /&gt;
: If an id is specified, then the event will not be added if another event with the same id already exists. An id will also allow the event to be removed, see below. Supplying a non-empty id= is mandatory in case of a [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
==== remove ====&lt;br /&gt;
: Removes an event instead of adding a new one. This key takes a [[ConditionalActionsWML#Boolean_Values|boolean]]; if yes, does the same as a [[InternalActionsWML#.5Bremove_event.5D|[remove_event]]] with the same id= value, and the other attributes of this event tag are ignored.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} May be a comma separated list.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|7}} Prints a deprecation warning recommending to use [remove_event] instead.&lt;br /&gt;
&lt;br /&gt;
==== priority ====&lt;br /&gt;
: {{DevFeature1.17|20}} If several '[event]' tags have the same name, then any with a high priority value will be triggered before events with a lower priority value. Negative numbers are also supported, to run after events without a priority (as the attribute defaults to zero). For events with equal priority, the order is determined by the order in which the events were added.&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 based on the weapon used by the primary unit. This is usable in the events ''attack'', ''attacker hits'', ''attacker misses'', ''defender hits'', ''defender misses'', ''attack end'', ''last breath'', and ''die''. For more information and filter keys, see [[FilterWML#Filtering Weapons|Filtering Weapons]]. The most commonly used keys are the following.&lt;br /&gt;
:* '''name''': the name of the weapon used.&lt;br /&gt;
:* '''range''': the range of the weapon used.&lt;br /&gt;
:* '''special_id''': filter on the attack's weapon special id.&lt;br /&gt;
:* '''special_type''': filter on the attack's weapon special type.&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_id_active''': filter on the attack's weapon special id active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
:* {{DevFeature1.17|15}} '''special_type_active''': filter on the attack's weapon special type active(encoded in [specials] or [abilities] tags).&lt;br /&gt;
&lt;br /&gt;
==== [filter_second_attack] ====&lt;br /&gt;
: Like [filter_attack], but for the weapon used by the secondary unit.&lt;br /&gt;
&lt;br /&gt;
==== [filter_condition] ====&lt;br /&gt;
: This tag makes sense inside any sort of event - even those that don't have units, or custom events,... The event will only trigger if this condition evaluates to true.&lt;br /&gt;
:* [[ConditionalActionsWML#Condition_Tags|Condition Tags]]&lt;br /&gt;
: note: This tag is meant to be used when the firing of an event shall be based on variables/conditions which cannot be retrieved from the filtered units.&lt;br /&gt;
&lt;br /&gt;
==== [filter_side] ====&lt;br /&gt;
: The current side (usually the side $side_number) must match the passed [[StandardSideFilter]] for the event to fire.&lt;br /&gt;
:* SSF tags and keys as arguments as described in [[StandardSideFilter]].&lt;br /&gt;
: note: This tag makes most sense in side turn and turn refresh events. However, all wml events have a current side so one could also prevent e.g. a moveto event from firing if you put a [filter_side] tag there and the moving unit's side doesn't match.&lt;br /&gt;
&lt;br /&gt;
==== [insert_tag] ====&lt;br /&gt;
: An '''[insert_tag]''' that expands to any of the above filter tags will result in the filter being loaded from the variable each time the game checks if the event should fire. This can result in the event's filter varying from turn to turn.&lt;br /&gt;
&lt;br /&gt;
==== filter_formula ====&lt;br /&gt;
:{{DevFeature1.17|6}}&lt;br /&gt;
: Similar to [filter_condition], but the condition is expressed in [[Wesnoth Formula Language]]. The formula has access to the following keys:&lt;br /&gt;
:*Event information:&lt;br /&gt;
:**'''event''' - the event name&lt;br /&gt;
:**'''event_id''' - the event's unique ID&lt;br /&gt;
:**'''event_data''' - additional information specific to the event, such as owner_side or damage_inflicted, or anything passed in '''[fire_event][data]'''.&lt;br /&gt;
:**'''loc''', '''unit''' - primary event location and unit&lt;br /&gt;
:**'''second_loc''', '''second_unit''' - secondary event location and unit&lt;br /&gt;
:**'''weapon''', '''second_weapon''' - primary and secondary weapon&lt;br /&gt;
:*Gamestate information:&lt;br /&gt;
:**'''turn_number'''&lt;br /&gt;
:**'''time_of_day''' - the time of day ID&lt;br /&gt;
:**'''side_number''' - currently active side&lt;br /&gt;
:**'''sides''' - a list of all sides&lt;br /&gt;
:**'''units''' - a list of all units on the map&lt;br /&gt;
:**'''map''' - the entire game map as a two-dimensional array&lt;br /&gt;
&lt;br /&gt;
==== delayed_variable_substitution ====&lt;br /&gt;
: This key is only relevant inside of a [[#Delayed Variable Substitution_2|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 [[ActionWML|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;
More details in [[ActionWML]]. Actions can also be dynamically inserted via '''[insert_tag]'''.&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;
In multiplayer it is only safe to use WML that might require synchronization with other players because of input or random numbers (like [message] with input or options or [unstore_unit] where a unit might advance) in the following events. This is because in these cases WML needs data from other players to work right and/or do the same thing for all players. This data is only available after a network synchronization.&lt;br /&gt;
&lt;br /&gt;
List of synchronized events:&lt;br /&gt;
* moveto&lt;br /&gt;
* enter hex&lt;br /&gt;
* exit hex&lt;br /&gt;
* sighted&lt;br /&gt;
* last breath &lt;br /&gt;
* menu item X&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;
* pre advance&lt;br /&gt;
* post advance &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;
* start&lt;br /&gt;
* prestart (prestart are synced but [message][option] &amp;amp; [unstore_unit] advancement choices will do a random decision because UI things don't work during prestart events.)&lt;br /&gt;
* new turn &lt;br /&gt;
* side turn &lt;br /&gt;
* turn X &lt;br /&gt;
* side X turn &lt;br /&gt;
* side X turn Y &lt;br /&gt;
* turn refresh&lt;br /&gt;
* side turn end&lt;br /&gt;
* side X turn end&lt;br /&gt;
* side turn X end&lt;br /&gt;
* side X turn Y end&lt;br /&gt;
* turn end&lt;br /&gt;
* turn X end&lt;br /&gt;
* {{DevFeature1.13|0}} enemies defeated&lt;br /&gt;
* {{DevFeature1.13|0}} time over&lt;br /&gt;
* {{DevFeature1.13|10}} victory&lt;br /&gt;
* {{DevFeature1.13|10}} defeat&lt;br /&gt;
* {{DevFeature1.13|0}} scenario_end&lt;br /&gt;
The following are &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; synced:&lt;br /&gt;
* select&lt;br /&gt;
* preload&lt;br /&gt;
* victory {{DevFeature1.13|10}} local_victory&lt;br /&gt;
* defeat {{DevFeature1.13|10}} local_defeat&lt;br /&gt;
* ai turn&lt;br /&gt;
&lt;br /&gt;
If an event is not listed here, ask someone to be sure.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility of events that are normally synchronized when fired by the engine but can be non-synchronized when fired by WML tags from non-synchronized event. So when you are using them you must be extra careful. For example [unstore_unit] may trigger a 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;
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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
=== Event IDs ===&lt;br /&gt;
&lt;br /&gt;
This problem can be avoided by setting an '''id''' on the event, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
#define DOUBLE&lt;br /&gt;
    [event]&lt;br /&gt;
        name=multiply_by_2&lt;br /&gt;
        id=doubler_event&lt;br /&gt;
        {VARIABLE_OP 2_becomes_4 multiply 2}&lt;br /&gt;
    [/event]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Events with the same ID will only be accepted once by the engine no matter how many times they are included, and will only be saved once to the scenario's savefile.  Events with an ID can also be removed by using the '''remove''' key, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    id=doubler_event&lt;br /&gt;
    remove=yes&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that WML is encountered (at toplevel or after created from another event), the event with this ID is removed from the scenario wml, thus firing it has no effect.  After an event is removed, it can still be re-added later.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events Without Filters ==&lt;br /&gt;
&lt;br /&gt;
These events do not take filter parameters (except [filter_condition] which works for all events).&lt;br /&gt;
&lt;br /&gt;
=== preload ===&lt;br /&gt;
&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.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a game is started, saved, and then reloaded, the preload event will fire two times while playing.  However, it will only fire once when viewing the replay. If the preload event alters the gamestate the second time it fired while playing (when loading the saved game) then it can result in Out Of Sync errors.&lt;br /&gt;
&lt;br /&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;
&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.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers after the map is shown but before the scenario begins -- before players can 'do' anything.&lt;br /&gt;
&lt;br /&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;
&lt;br /&gt;
Triggers at the start of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. 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;
=== turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of every turn (not side turn). See also [[#first_time_only|first_time_only=no]]. The WML variable '''side_number''' will contain the side that ended their turn.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' end ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the end of turn ''X''.&lt;br /&gt;
&lt;br /&gt;
=== side turn ===&lt;br /&gt;
&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;
&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. Note that this event might be called several times per turn in case that fallbacks to human or droiding is involved. I.e. it happens at the middle of turn of human side 1 if the human player droids his side. It happens after the selection of ai to play the turn but before AI is told that new turn has come.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''  ''This event can break replays if it is used improperly. The ai turn event does not fire during replays. The intention is only to guide the AI to make choices (movements, attacks) which are then saved to the replay.''&lt;br /&gt;
&lt;br /&gt;
=== turn refresh ===&lt;br /&gt;
&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. WML variable '''side_number''' holds the number of this side.&lt;br /&gt;
&lt;br /&gt;
Note that the turn refresh event does occur on turn 1, even though healing, income and unit refreshing do not.&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
Triggers at the start of turn ''X''. It's the first side initialization event. &lt;br /&gt;
&lt;br /&gt;
Side initialization events go in the order of: &lt;br /&gt;
&lt;br /&gt;
# '''turn ''X''''' &lt;br /&gt;
# '''new turn''' &lt;br /&gt;
# '''side turn''' &lt;br /&gt;
# '''side ''X'' turn''' &lt;br /&gt;
# '''side turn ''X''''' &lt;br /&gt;
# '''side ''X'' turn ''Y''''' &lt;br /&gt;
# '''turn refresh''' &lt;br /&gt;
# '''side ''X'' turn refresh''' &lt;br /&gt;
# '''turn ''X'' refresh''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' refresh'''&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ''Y'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of turn ''Y'' of side X &lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any turn of side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn ''X'' ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the start of any side on turn X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side X turn Y refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X on turn Y&lt;br /&gt;
&lt;br /&gt;
=== side ''X'' turn refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers at the turn refresh for side X&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== turn ''X'' refresh ===&lt;br /&gt;
&lt;br /&gt;
This event triggers for any side at the refresh of turn X.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ''Of course, [[#first_time_only|first_time_only=no]] is needed for this event to be triggered more than once.''&lt;br /&gt;
&lt;br /&gt;
=== side turn end ===&lt;br /&gt;
&lt;br /&gt;
Triggers after a side ends its turn. Like side turn, there are also some variations for specific combinations of side number and turn number. Here is the order in which the turn end events trigger:&lt;br /&gt;
&lt;br /&gt;
# '''side turn end''' &lt;br /&gt;
# '''side ''X'' turn end''' &lt;br /&gt;
# '''side turn ''X'' end''' &lt;br /&gt;
# '''side ''X'' turn ''Y'' end''' &lt;br /&gt;
# '''turn end''' &lt;br /&gt;
# '''turn ''X'' end''' &lt;br /&gt;
&lt;br /&gt;
=== time over ===&lt;br /&gt;
&lt;br /&gt;
Triggers on turn ''turns''. (''turns'' is specified in [scenario])&lt;br /&gt;
&lt;br /&gt;
=== enemies defeated ===&lt;br /&gt;
&lt;br /&gt;
Triggers when all sides that are not defeated are allied and if there is at least one human (or human networked) side among them. Especially this event triggers in a situaltion that would normaly cause a victory due to enemies defeated. (regardless of whether this was disabled with victory_when_enemies_defeated=no). &lt;br /&gt;
&lt;br /&gt;
=== local_victory ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 and earlier, the event described here is '''victory''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the player's side won. If it fires as a result of an '''[endlevel]''' tag, the event is processed before the line after the '''[endlevel]]''' tag. The event is not synchronized, as in networked mp it is possible to have different results for different players.&lt;br /&gt;
&lt;br /&gt;
=== local_defeat ===&lt;br /&gt;
&lt;br /&gt;
In Wesnoth 1.12 are earlier, the event described here is '''defeat''', {{DevFeature1.13|10}} in 1.14 the event described here is '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
Functions identically to '''local_victory''', except that the player's side lost.&lt;br /&gt;
&lt;br /&gt;
=== victory ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''victory''' event is equivalent to 1.14's '''local_victory'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game will proceed to the next scenario. In multiplayer, this means that it will fire on all players' clients, even for players who received a '''local_defeat''', as long as the game continues to the next scenario. This event is synchronized.&lt;br /&gt;
&lt;br /&gt;
It helps debugging if the victory event allows you to safely advance to any of the possible next maps after using the &amp;quot;:next_level&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.&lt;br /&gt;
&lt;br /&gt;
=== defeat ===&lt;br /&gt;
&lt;br /&gt;
This section describes a new event Wesnoth 1.14. In 1.12 and earlier, the '''defeat''' event is equivalent to 1.14's '''local_defeat'''.&lt;br /&gt;
&lt;br /&gt;
This event will be fired at the end of a scenario, if the game resulted in a game-over other than victoriously reaching the end of a campaign (including single-scenario campaigns). Synchronization (including bug #4667) is the same as '''victory'''.&lt;br /&gt;
&lt;br /&gt;
=== scenario_end ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|10}} This event fires immediately after '''victory''' or '''defeat'''; it is synchronized, but is also affected by bug #4667.&lt;br /&gt;
&lt;br /&gt;
Note: in 1.13.0 - 1.13.9 this event was added as a synchronized alternative to the events that are, since 1.13.10, called local_victory or local_defeat.&lt;br /&gt;
&lt;br /&gt;
== Predefined Events With Filters ==&lt;br /&gt;
&lt;br /&gt;
Filters (except [filter_condition] which is for all sorts of events) 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]]. weapon and second_weapon variables are available inside attack, attacker_hits, defender_hits, unit_hits, die and last_breath events. See [[VariablesWML#Automatically_Stored_Variables|automatically stored variables]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== moveto ===&lt;br /&gt;
&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. If the unit moves to a village, the capture event will be fired before this event. &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 undo other changes to the game caused by the event. Thus it is up to the scenario designer to use this tag correctly.'' $x2 and $y2 refer to the hex the unit came from.&lt;br /&gt;
&lt;br /&gt;
=== sighted ===&lt;br /&gt;
&lt;br /&gt;
A '''sighted''' event is triggered by a unit becoming visible to a side (other than the unit's own side). This is mostly useful when the side seeing the unit uses [[fog of war]] or [[shroud]], but they still fire even when fog/shroud is not in use, and they do take into account the {{tag2|AbilitiesWML#The_.5Babilities.5D_tag|hides}} ability (for a moving unit and for ambushers). The ''primary unit'' is the unit that became visible, and the ''secondary unit'' belongs to the side that now sees the primary unit. In some cases, sighted events can be delayed from when they &amp;quot;should&amp;quot; occur. If that happens, the secondary unit will be filtered as if it was at the location where the event &amp;quot;should&amp;quot; have occurred, and ''x2,y2'' will store that location (not the current position of the secondary unit). To understand when sighted events fire, it is helpful to distinguish the times the acting unit sights other units from the times when the acting unit is sighted.&lt;br /&gt;
&lt;br /&gt;
An acting unit can sight other units when it is recruited, recalled, leveled, or moved, and when fog or shroud is cleared from occupied hexes as a result. In these cases, the acting unit is always the ''secondary unit''. For the first three actions, there are two events associated with the action; clearing occurs between these events, but any sighted events are fired after the second event. (For example, when a unit is recruited, the ''prerecruit'' event fires, then fog is cleared, then the ''recruit'' event fires, then ''sighted'' events fire.) For movement, the sighted events fire between ''enter_hex'' and ''exit_hex'' events, but sometimes sighted events are postponed until the moving unit reaches a good place to stop (e.g. not in an occupied hex). As a major exception to the above, players have the option to delay shroud (and fog) updates. If the player delays shroud updates, sighted events are also delayed until the shroud is updated.&lt;br /&gt;
&lt;br /&gt;
An acting unit can be sighted by other sides when it is recruited, recalled, leveled (in rare cases), or moved. In these cases, the acting unit is always the ''primary unit''. These events fire after sightings by the acting unit (unless the player delayed shroud updates). For the first two, the sighted event fires for all sides that can see the unit, other than the unit's own side (even if those sides use neither fog nor shroud). For leveling units, sides that could see the unit before it leveled are excluded. (This is why these events are rare &amp;amp;ndash; the leveling unit must have lost a [hides] ability as a result of leveling in order to be seen after, but not before, leveling.) For movement, a sighted event is fired for each side that could see the unit after movement, but not before. In particular, only the starting and ending hexes are considered; a unit that moves through seen hexes but ends movement in a fogged hex does not trigger a sighted event for itself. In all cases where the acting unit is sighted, a (single) ''secondary unit'' is chosen from the sighting team. This choice should be considered arbitrary, but units within their sight range of the acting unit are chosen in preference to units further away. You may want to use [filter_second] in order to restrict a sighted event in a single player scenario to only being triggered by the player and not by other non-allied sides.&lt;br /&gt;
&lt;br /&gt;
Sighted events are not triggered by a ''hides'' ability becoming inactive, unless it becomes inactive due to that unit's movement or to that unit ambushing another. (To detect a ''nightstalk'' ability becoming inactive due to time of day, use a ''new_turn'' event. Custom ''hides'' abilities might need similar handling.)&lt;br /&gt;
&lt;br /&gt;
Sighted events have some special caveats for WML authors. First and foremost, {{tag|DirectActionsWML|allow_undo}} should generally be avoided in sighted events. It can be used if current unit positions have no bearing on the event, but otherwise it could cause a replay to go out of sync if a player delays shroud updates and undoes a move. This should not be an onerous restriction, though, as clearing fog will block the ability to undo, regardless of what happens within an event. Secondly, it is currently possible for WML to kill a unit involved in a sighted event before that event fires. If that happens, filters on the killed unit will not match anything and the event may seem to have not fired.&lt;br /&gt;
&lt;br /&gt;
=== enter_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex entered during movement, with $x1,$y1 identifying the hex entered and $x2,$y2 identifying the previous hex (just exited). In Wesnoth 1.12, the movement will be interrupted, stopping the unit where it is; this behavior can be avoided by using the {{tag|DirectActionsWML|allow_undo}} tag or `NO_INTERRUPT_NO_UNDO` macro. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the entered hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (7ca5a0df, just before 1.13.11), if the hex is occupied then $unit contains the occupying unit, not the moving unit.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' At the time of writing (1.16.2), if the hex is occupied then $unit does contain the moving unit.&lt;br /&gt;
&lt;br /&gt;
=== exit_hex ===&lt;br /&gt;
&lt;br /&gt;
Triggers for each hex exited during movement, with $x1,$y1 identifying the hex exited and $x2,$y2 identifying the next hex (to be entered). If this event is handled without using {{tag|DirectActionsWML|allow_undo}}, then movement is interrupted, stopping the unit where it is. {{DevFeature1.13|11}} movement is not interrupted unless the {{tag|DirectActionsWML|cancel_action}} tag is used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This event behaves a bit unusually if the hex is occupied (and the moving unit is simply passing through). When this happens, $x1,$y1 is still the hex where the event was triggered, but the moving unit (stored in $unit) will be located somewhere earlier in the route (the most recent unoccupied hex). That is, $x1,$y1 will not equal $unit.x,$unit.y (a condition that can be used to detect when the exited hex is occupied). The moving unit will have already spent its movement points to enter the event's hex even though it is has not actually moved from the most recent unoccupied hex.&lt;br /&gt;
&lt;br /&gt;
=== pre attack {{DevFeature1.17|7}}===&lt;br /&gt;
&lt;br /&gt;
Similar to '''attack''', but is triggered before calculating the number of attacks and the movement of the unit. Can be used for modifications, which affect these values.&lt;br /&gt;
&lt;br /&gt;
=== attack ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit attacks the secondary unit. Variables $weapon and $second_weapon contain weapons used for this attack by primary and secondary units respectively for all attack-related events (attack_end, attacker_hits, attacker_misses, defender_hits, defender_misses, die and last_breath).&lt;br /&gt;
&lt;br /&gt;
=== attack end ===&lt;br /&gt;
&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;
&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;
&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;
&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;
&lt;br /&gt;
Same as ''defender hits'', but is triggered when the defender misses.&lt;br /&gt;
&lt;br /&gt;
=== unit hits {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the the primary unit (either attacker or defender) hits the secondary unit (the other). The value of the WML variable '''damage_inflicted''' is set to the number of hitpoints inflicted by the primary unit.&lt;br /&gt;
&lt;br /&gt;
Compared to ''defender hits'', primary and secondary units are swapped. &lt;br /&gt;
&lt;br /&gt;
=== unit misses {{DevFeature1.19|2}} ===&lt;br /&gt;
&lt;br /&gt;
Same as ''unit hits'', but is triggered when the unit misses.&lt;br /&gt;
&lt;br /&gt;
=== petrified ===&lt;br /&gt;
Triggers when the primary unit is hit by an attack with the 'petrifies' ability (See ''petrifies'', [[AbilitiesWML]]) by the secondary unit (the unit with the 'petrifies' ability).&lt;br /&gt;
&lt;br /&gt;
=== last breath ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit, but before the death animation is triggered. Use this instead of name=die when you want the primary unit to make a final [message]. &lt;br /&gt;
&lt;br /&gt;
=== die ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is killed by the secondary unit. ''Note: The primary unit is not removed from the game until the end of this event. The primary unit can still be manipulated, will block other units from taking its hex, and will still be found by standard unit filters (except [have_unit]). To prevent this behavior, you can use [kill] to remove the unit immediately. However, this will stop any (still unfired) other events that also match the unit from firing afterwards, so use with caution.'' If you want to the primary unit to make a final [message], use name=last_breath, see above.&lt;br /&gt;
&lt;br /&gt;
=== capture ===&lt;br /&gt;
&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. This event will be fired before the moveto event. Villages becoming neutral (via [capture_village]) do not fire capture events. The variable $owner_side contains the previous owner side of the village. 0 means neutral.&lt;br /&gt;
&lt;br /&gt;
=== recruit ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit). (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;
&lt;br /&gt;
Triggers when the primary unit is recruited (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== recall ===&lt;br /&gt;
&lt;br /&gt;
Triggers after the primary unit is recalled (by the secondary unit).&lt;br /&gt;
&lt;br /&gt;
=== prerecall ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is recalled (by the secondary unit) but before it is displayed.&lt;br /&gt;
&lt;br /&gt;
=== advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just before the primary unit is going to advance to another unit, or advance by AMLA. (This is after the player selects which advancement, if there is a choice). If this event removes the unit, changes the unit's type, or reduces the unit's experience below what it needs to advance, then the advancement is aborted. This also applies to advancement by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== pre advance ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|0}} Triggers before the unit advancement dialog is shown. If this event removes the unit or reduces the unit's experience below what it needs to advance, then the advancement is aborted.&lt;br /&gt;
&lt;br /&gt;
Care needs to be taken when tags that may trigger advancement themselves are used in this event. For example '''[transform_unit]''', '''[unstore_unit]''', '''[modify_unit]''' etc.&lt;br /&gt;
&lt;br /&gt;
=== post advance ===&lt;br /&gt;
&lt;br /&gt;
Triggers just after the primary unit has advanced to another unit, or advance by AMLA.&lt;br /&gt;
&lt;br /&gt;
=== select ===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is selected. Prior to version 1.11, this also triggered when a move was interrupted, 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;
&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;
=== unit placed {{DevFeature1.13|3}}===&lt;br /&gt;
&lt;br /&gt;
Triggers when the primary unit is placed on the map, regardless of method. This includes but might not be limited to:&lt;br /&gt;
* Leaders and units placed in side definitions (fired once for every unit right before prestart events)&lt;br /&gt;
* Recruited and recalled units&lt;br /&gt;
* Units placed on the map with the [unit] tag ('''not''' units created directly onto a recall list or variable)&lt;br /&gt;
* Units placed by the wesnoth.put_unit() Lua function&lt;br /&gt;
* Units placed by :to_map in Lua (which is a shortcut for the above)&lt;br /&gt;
* Units created via debug mode&lt;br /&gt;
* Units created by plague &lt;br /&gt;
* Every use of [unstore_unit], when ''fire_event'' is set to ''yes'' (default is ''no'')&lt;br /&gt;
* Units moved on map with [move_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units matching the filter of [petrify], [unpetrify] or [harm_unit] before {{DevFeature1.15|8}}&lt;br /&gt;
* Units who receive a bonus from the feeding ability every time except the first, before {{DevFeature1.15|8}}&lt;br /&gt;
This event is solely intended for special cases where no other event types suffice, for example if you must immediately apply a modification to every unit that ever appears. The event does '''not''' keep track of which units it has previously fired for, but can fire an unlimited number of times for the same unit as long the unit is &amp;quot;placed&amp;quot; several times and the event filter doesn't prevent it.&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;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event]&lt;br /&gt;
    name=last breath&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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way of doing this would be to create a single moveto event with a '''[filter_condition]''' statement to check for turn number but using nested '''[event]''' tags is a convenient shortcut to accomplish this task without resorting to '''[filter_condition]''' statements. Using '''[if]''' tags is also an option especially if your event has '''first_time_only=yes'''.&lt;br /&gt;
&lt;br /&gt;
=== Delayed Variable Substitution Example ===&lt;br /&gt;
&lt;br /&gt;
This code will display a message showing the turn number on which the nested ''moveto'' event happens.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, the following example is identical to the first two in that it will display a message showing the turn number 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;
&amp;lt;syntaxhighlight lang='wml'&amp;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;
        [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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multiple Nested Events ===&lt;br /&gt;
&lt;br /&gt;
Every delayed_variable_substitution=no causes a variable substitution run on the subevent where it occurs at the spawn time of this event and on all following subevents. For any specific event, variable substitution happens at least one time when the event is executed. For each delayed=no key appearing in itself or in an event of an &amp;quot;older&amp;quot; generation, which is not the toplevel event, an additional variable substitution run is made.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='wml'&amp;gt;&lt;br /&gt;
[event] # parent&lt;br /&gt;
    name=turn 2&lt;br /&gt;
    # delayed_variable_substitution=no # In the parent event, delayed= has no effect.&lt;br /&gt;
 &lt;br /&gt;
    [event] # child&lt;br /&gt;
        name=turn 3&lt;br /&gt;
        delayed_variable_substitution=no # Causes variable substitution in the child, grandchild and great-grandchild event&lt;br /&gt;
        # at execution time of the parent event = spawn time of the child event.&lt;br /&gt;
&lt;br /&gt;
        [event]# grandchild&lt;br /&gt;
            name=turn 4&lt;br /&gt;
            delayed_variable_substitution=yes # no variable substitution in the grandchild and great-grandchild event&lt;br /&gt;
            # at execution time of the child event = spawn time of the grandchild event&lt;br /&gt;
&lt;br /&gt;
            [event] # great-grandchild&lt;br /&gt;
                name=turn 5&lt;br /&gt;
                {DEBUG_MSG $turn_number} # output: 2 - value from the variable substitution at execution time of the parent event,&lt;br /&gt;
                # caused by delayed=no in the child event&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $||turn_number}# output: &amp;quot;$turn_number&amp;quot;&lt;br /&gt;
                # Each variable substitution transforms a &amp;quot;$|&amp;quot; to a &amp;quot;$&amp;quot; (except when no | left).&lt;br /&gt;
&lt;br /&gt;
                {DEBUG_MSG $|turn_number}# output: 5 - from the variable substitution at execution time&lt;br /&gt;
                # of the great-grandchild event&lt;br /&gt;
            [/event]&lt;br /&gt;
        [/event]&lt;br /&gt;
    [/event]&lt;br /&gt;
[/event]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions/Updating&amp;diff=72770</id>
		<title>Template:Lua Functions/Updating</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions/Updating&amp;diff=72770"/>
		<updated>2024-04-26T20:45:49Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Reference how this page was made.&lt;br /&gt;
&lt;br /&gt;
For each relevant LuaAPI page run javascript&lt;br /&gt;
&amp;lt;syntaxhighlight lang='js'&amp;gt;&lt;br /&gt;
[...document.querySelectorAll('.toclevel-2 .toctext')].map(e =&amp;gt; e.innerText).filter(s =&amp;gt; s.startsWith('wesnoth') || s.startsWith('wml') || s.startsWith('gui') || s.startsWith('location_set') || s.startsWith('functional') || s.startsWith('stringx') || s.startsWith('mathx') || s.startsWith('filesystem') || s.startsWith('ai') || s.startsWith('utils') || s.startsWith('unit_test')) + &amp;quot; @ &amp;quot; + document.location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Put output to separate lines of data.txt and run python&lt;br /&gt;
&amp;lt;syntaxhighlight lang='py'&amp;gt;&lt;br /&gt;
with open(&amp;quot;data.txt&amp;quot;) as f:&lt;br /&gt;
    print(&amp;quot;&amp;quot;&amp;quot;{| class=&amp;quot;reference-sidebar&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;span class=&amp;quot;editlink&amp;quot;&amp;gt;&amp;amp;#91;[{{SERVER}}{{localurl:Template:Lua Functions|action=edit}} edit]&amp;amp;#93;&amp;lt;/span&amp;gt;'''Lua Functions'''&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
    sections = {}&lt;br /&gt;
    for line in f:&lt;br /&gt;
        line = line.strip().strip(&amp;quot;'&amp;quot;)&lt;br /&gt;
        line = line.replace(&amp;quot;,wesnoth.audio,wesnoth.achievements,wesnoth.game_events,wesnoth.map,wesnoth.interface,wesnoth.paths,wesnoth.schedule,wesnoth.sides,wesnoth.sync,wesnoth.units&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
        methods, url = line.split(&amp;quot; @ &amp;quot;)&lt;br /&gt;
        url = url.removeprefix(&amp;quot;https://wiki.wesnoth.org/&amp;quot;)&lt;br /&gt;
        header = url.removeprefix(&amp;quot;LuaAPI/&amp;quot;).replace(&amp;quot;/&amp;quot;,&amp;quot;.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        sections[header] = []&lt;br /&gt;
        for method in sorted(methods.split(&amp;quot;,&amp;quot;)):&lt;br /&gt;
            methodWithoutLocation = method.split(&amp;quot;.&amp;quot;)[-1]&lt;br /&gt;
            row = &amp;quot;[[{}#{}|{}]]&amp;lt;br&amp;gt;&amp;quot;.format(url, method, method)&lt;br /&gt;
            sections[header].append(row)&lt;br /&gt;
&lt;br /&gt;
    for header in sorted(sections, key=lambda x: '_'+x if x.startswith('wesnoth') else x):&lt;br /&gt;
        print(&amp;quot;|-\n|''{}''&amp;quot;.format(header))&lt;br /&gt;
        for row in sections[header]:&lt;br /&gt;
            print(row)&lt;br /&gt;
    print(&amp;quot;&amp;quot;&amp;quot;|}&amp;lt;includeonly&amp;gt;[[Category:Lua Reference]]&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;A box with all the Lua functions, each one linking to the page and section they are described in. It was generated using [[/Updating|this method]]. This box should be included in [[LuaAPI|Lua reference]] page.&amp;lt;/noinclude&amp;gt;&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions&amp;diff=72769</id>
		<title>Template:Lua Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions&amp;diff=72769"/>
		<updated>2024-04-26T20:45:16Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;reference-sidebar&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;span class=&amp;quot;editlink&amp;quot;&amp;gt;&amp;amp;#91;[{{SERVER}}{{localurl:Template:Lua Functions|action=edit}} edit]&amp;amp;#93;&amp;lt;/span&amp;gt;'''Lua Functions'''&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth''&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.as_text|wesnoth.as_text]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.colors|wesnoth.colors]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.compile_formula|wesnoth.compile_formula]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.current|wesnoth.current]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.current_version|wesnoth.current_version]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.custom_synced_commands|wesnoth.custom_synced_commands]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.deprecate_api|wesnoth.deprecate_api]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.deprecated_message|wesnoth.deprecated_message]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.dofile|wesnoth.dofile]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.effects|wesnoth.effects]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.eval_formula|wesnoth.eval_formula]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.game_config|wesnoth.game_config]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.get_language|wesnoth.get_language]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.log|wesnoth.log]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.micro_ais|wesnoth.micro_ais]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.ms_since_init|wesnoth.ms_since_init]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.name_generator|wesnoth.name_generator]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.named_tuple|wesnoth.named_tuple]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.persistent_tags|wesnoth.persistent_tags]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.print_attributes|wesnoth.print_attributes]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.races|wesnoth.races]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.require|wesnoth.require]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.scenario|wesnoth.scenario]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.simulate_combat|wesnoth.simulate_combat]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.terrain_types|wesnoth.terrain_types]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.textdomain|wesnoth.textdomain]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.type|wesnoth.type]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.unit_types|wesnoth.unit_types]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.version|wesnoth.version]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.wml_actions|wesnoth.wml_actions]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.wml_conditionals|wesnoth.wml_conditionals]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.achievements''&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.get|wesnoth.achievements.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.has|wesnoth.achievements.has]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.has_sub_achievement|wesnoth.achievements.has_sub_achievement]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.progress|wesnoth.achievements.progress]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.set|wesnoth.achievements.set]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.set_sub_achievement|wesnoth.achievements.set_sub_achievement]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.audio''&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list|wesnoth.audio.music_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.add|wesnoth.audio.music_list.add]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.all|wesnoth.audio.music_list.all]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.clear|wesnoth.audio.music_list.clear]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.current|wesnoth.audio.music_list.current]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.next|wesnoth.audio.music_list.next]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.play|wesnoth.audio.music_list.play]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.previous|wesnoth.audio.music_list.previous]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.remove|wesnoth.audio.music_list.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.volume|wesnoth.audio.music_list.volume]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.play|wesnoth.audio.play]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.sources|wesnoth.audio.sources]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.volume|wesnoth.audio.volume]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.game_events''&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add|wesnoth.game_events.add]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_menu|wesnoth.game_events.add_menu]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_repeating|wesnoth.game_events.add_repeating]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_wml|wesnoth.game_events.add_wml]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire|wesnoth.game_events.fire]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire_by_id|wesnoth.game_events.fire_by_id]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_event|wesnoth.game_events.on_event]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_load|wesnoth.game_events.on_load]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_action|wesnoth.game_events.on_mouse_action]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_button|wesnoth.game_events.on_mouse_button]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_move|wesnoth.game_events.on_mouse_move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_save|wesnoth.game_events.on_save]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.remove|wesnoth.game_events.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.interface''&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_chat_message|wesnoth.interface.add_chat_message]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_hex_overlay|wesnoth.interface.add_hex_overlay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_item_halo|wesnoth.interface.add_item_halo]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_item_image|wesnoth.interface.add_item_image]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_overlay_text|wesnoth.interface.add_overlay_text]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.allow_end_turn|wesnoth.interface.allow_end_turn]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.clear_chat_messages|wesnoth.interface.clear_chat_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.color_adjust|wesnoth.interface.color_adjust]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.delay|wesnoth.interface.delay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.deselect_hex|wesnoth.interface.deselect_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.end_turn|wesnoth.interface.end_turn]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.float_label|wesnoth.interface.float_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_displayed_unit|wesnoth.interface.get_displayed_unit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_hovered_hex|wesnoth.interface.get_hovered_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_items|wesnoth.interface.get_items]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_selected_hex|wesnoth.interface.get_selected_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_viewing_side|wesnoth.interface.get_viewing_side]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.handle_user_interact|wesnoth.interface.handle_user_interact]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.highlight_hex|wesnoth.interface.highlight_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.is_locked|wesnoth.interface.is_locked]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.is_skipping_messages|wesnoth.interface.is_skipping_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.lock|wesnoth.interface.lock]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.remove_hex_overlay|wesnoth.interface.remove_hex_overlay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.remove_item|wesnoth.interface.remove_item]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.scroll|wesnoth.interface.scroll]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.scroll_to_hex|wesnoth.interface.scroll_to_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.select_unit|wesnoth.interface.select_unit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.skip_messages|wesnoth.interface.skip_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.zoom|wesnoth.interface.zoom]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.map''&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.add_label|wesnoth.map.add_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.are_hexes_adjacent|wesnoth.map.are_hexes_adjacent]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.create|wesnoth.map.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.distance_between|wesnoth.map.distance_between]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.find|wesnoth.map.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.generate|wesnoth.map.generate]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.generate_height_map|wesnoth.map.generate_height_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get|wesnoth.map.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_adjacent_hexes|wesnoth.map.get_adjacent_hexes]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_area|wesnoth.map.get_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_direction|wesnoth.map.get_direction]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_hexes_in_radius|wesnoth.map.get_hexes_in_radius]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_label|wesnoth.map.get_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_owner|wesnoth.map.get_owner]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_relative_dir|wesnoth.map.get_relative_dir]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.iter|wesnoth.map.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.make_bitmap|wesnoth.map.make_bitmap]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.matches|wesnoth.map.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.on_board|wesnoth.map.on_board]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.on_border|wesnoth.map.on_border]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.place_area|wesnoth.map.place_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.read_location|wesnoth.map.read_location]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.remove_area|wesnoth.map.remove_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.remove_label|wesnoth.map.remove_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.rotate_right_around_center|wesnoth.map.rotate_right_around_center]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.set_owner|wesnoth.map.set_owner]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.split_terrain_code|wesnoth.map.split_terrain_code]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.terrain_mask|wesnoth.map.terrain_mask]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.paths''&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_cost_map|wesnoth.paths.find_cost_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_path|wesnoth.paths.find_path]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_reach|wesnoth.paths.find_reach]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_vacant_hex|wesnoth.paths.find_vacant_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_vision_range|wesnoth.paths.find_vision_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.schedule''&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.get_illumination|wesnoth.schedule.get_illumination]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.get_time_of_day|wesnoth.schedule.get_time_of_day]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.replace|wesnoth.schedule.replace]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.sides''&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.add_ai_component|wesnoth.sides.add_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.append_ai|wesnoth.sides.append_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.change_ai_component|wesnoth.sides.change_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.create|wesnoth.sides.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.debug_ai|wesnoth.sides.debug_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.delete_ai_component|wesnoth.sides.delete_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.find|wesnoth.sides.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.get|wesnoth.sides.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_enemy|wesnoth.sides.is_enemy]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_fogged|wesnoth.sides.is_fogged]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_shrouded|wesnoth.sides.is_shrouded]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.iter|wesnoth.sides.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.matches|wesnoth.sides.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.override_shroud|wesnoth.sides.override_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.place_fog|wesnoth.sides.place_fog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.place_shroud|wesnoth.sides.place_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.remove_fog|wesnoth.sides.remove_fog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.remove_shroud|wesnoth.sides.remove_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.set_id|wesnoth.sides.set_id]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.switch_ai|wesnoth.sides.switch_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.sync''&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.evaluate_multiple|wesnoth.sync.evaluate_multiple]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.evaluate_single|wesnoth.sync.evaluate_single]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.invoke_command|wesnoth.sync.invoke_command]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.run_unsynced|wesnoth.sync.run_unsynced]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.units''&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.unit.resistance_against|wesnoth.unit.resistance_against]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.ability|wesnoth.units.ability]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.add_modification|wesnoth.units.add_modification]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.advance|wesnoth.units.advance]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.chance_to_be_hit|wesnoth.units.chance_to_be_hit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.clone|wesnoth.units.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.create|wesnoth.units.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.create_animator|wesnoth.units.create_animator]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.defense_on|wesnoth.units.defense_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.erase|wesnoth.units.erase]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.extract|wesnoth.units.extract]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find|wesnoth.units.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_attack|wesnoth.units.find_attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_on_map|wesnoth.units.find_on_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_on_recall|wesnoth.units.find_on_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.get|wesnoth.units.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.get_hovered|wesnoth.units.get_hovered]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.jamming_on|wesnoth.units.jamming_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.matches|wesnoth.units.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.movement_on|wesnoth.units.movement_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.remove_modifications|wesnoth.units.remove_modifications]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.scroll_to|wesnoth.units.scroll_to]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.select|wesnoth.units.select]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.to_map|wesnoth.units.to_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.to_recall|wesnoth.units.to_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.transform|wesnoth.units.transform]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.vision_on|wesnoth.units.vision_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''ai''&lt;br /&gt;
[[LuaAPI/ai#ai.aspects|ai.aspects]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.attack|ai.attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_attack|ai.check_attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_move|ai.check_move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_recall|ai.check_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_recruit|ai.check_recruit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_stopunit|ai.check_stopunit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.fallback_human|ai.fallback_human]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.get_attacks|ai.get_attacks]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.get_targets|ai.get_targets]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.move|ai.move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.move_full|ai.move_full]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.read_only|ai.read_only]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.recall|ai.recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.recruit|ai.recruit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.side|ai.side]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_all|ai.stopunit_all]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_attacks|ai.stopunit_attacks]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_moves|ai.stopunit_moves]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.suitable_keep|ai.suitable_keep]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''filesystem''&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.canonical_path|filesystem.canonical_path]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.have_asset|filesystem.have_asset]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.have_file|filesystem.have_file]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.image_size|filesystem.image_size]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.read_file|filesystem.read_file]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.resolve_asset|filesystem.resolve_asset]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''functional''&lt;br /&gt;
[[LuaAPI/functional#functional.choose|functional.choose]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.choose_map|functional.choose_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.filter|functional.filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.filter_map|functional.filter_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.find|functional.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.find_map|functional.find_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.map|functional.map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.map_array|functional.map_array]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.reduce|functional.reduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.take_while|functional.take_while]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.zip|functional.zip]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''gui''&lt;br /&gt;
[[LuaAPI/gui#gui.add_widget_definition|gui.add_widget_definition]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.get_user_choice|gui.get_user_choice]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_dialog|gui.show_dialog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_help|gui.show_help]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_inspector|gui.show_inspector]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_lua_console|gui.show_lua_console]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_menu|gui.show_menu]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_narration|gui.show_narration]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_popup|gui.show_popup]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_prompt|gui.show_prompt]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_story|gui.show_story]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.widget|gui.widget]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''location_set''&lt;br /&gt;
[[LuaAPI/location_set#location_set.clear|location_set.clear]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.clone|location_set.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.create|location_set.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.diff|location_set.diff]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.empty|location_set.empty]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.filter|location_set.filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.get|location_set.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.insert|location_set.insert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.inter|location_set.inter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.inter_merge|location_set.inter_merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.invert|location_set.invert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.iter|location_set.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_map|location_set.of_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_pairs|location_set.of_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_raw|location_set.of_raw]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_shroud_data|location_set.of_shroud_data]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_triples|location_set.of_triples]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_wml_var|location_set.of_wml_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.random|location_set.random]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.remove|location_set.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.size|location_set.size]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.stable_iter|location_set.stable_iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.symm|location_set.symm]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_map|location_set.to_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_pairs|location_set.to_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_shroud_data|location_set.to_shroud_data]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_stable_pairs|location_set.to_stable_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_triples|location_set.to_triples]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_wml_var|location_set.to_wml_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.union|location_set.union]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.union_merge|location_set.union_merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''mathx''&lt;br /&gt;
[[LuaAPI/mathx#mathx.clamp|mathx.clamp]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.lerp|mathx.lerp]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.random|mathx.random]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.random_choice|mathx.random_choice]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.round|mathx.round]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.shuffle|mathx.shuffle]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''stringx''&lt;br /&gt;
[[LuaAPI/stringx#stringx.anim_split|stringx.anim_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.escaped_split|stringx.escaped_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.format_conjunct_list|stringx.format_conjunct_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.format_disjunct_list|stringx.format_disjunct_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.iter_range|stringx.iter_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.iter_ranges|stringx.iter_ranges]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.join|stringx.join]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.join_map|stringx.join_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.map_split|stringx.map_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.parenthetical_split|stringx.parenthetical_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.parse_range|stringx.parse_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.quoted_split|stringx.quoted_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.split|stringx.split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.trim|stringx.trim]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.vformat|stringx.vformat]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''unit_test''&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert|unit_test.assert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_approx_equal|unit_test.assert_approx_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_contains|unit_test.assert_contains]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_equal|unit_test.assert_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_greater|unit_test.assert_greater]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_greater_equal|unit_test.assert_greater_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_in_range|unit_test.assert_in_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_less|unit_test.assert_less]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_less_equal|unit_test.assert_less_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_not_equal|unit_test.assert_not_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_nothrow|unit_test.assert_nothrow]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_throws|unit_test.assert_throws]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_throws_with|unit_test.assert_throws_with]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.fail|unit_test.fail]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.finish|unit_test.finish]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.fire_wml_menu_item|unit_test.fire_wml_menu_item]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.log|unit_test.log]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.succeed|unit_test.succeed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.tostring|unit_test.tostring]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wml''&lt;br /&gt;
[[LuaAPI/wml#wml.all_variables|wml.all_variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.get|wml.array_access.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.get_proxy|wml.array_access.get_proxy]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.set|wml.array_access.set]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_variables|wml.array_variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.attribute_count|wml.attribute_count]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_array|wml.child_array]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_count|wml.child_count]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_range|wml.child_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.clone|wml.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.diff|wml.diff]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.equal|wml.equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.error|wml.error]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.eval_conditional|wml.eval_conditional]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.find_child|wml.find_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.fire|wml.fire]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.get_child|wml.get_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.get_nth_child|wml.get_nth_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.interpolate|wml.interpolate]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.literal|wml.literal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.load|wml.load]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.matches_filter|wml.matches_filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.merge|wml.merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.parse|wml.parse]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.parsed|wml.parsed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.patch|wml.patch]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.remove_child|wml.remove_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.remove_children|wml.remove_children]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.shallow_literal|wml.shallow_literal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.shallow_parsed|wml.shallow_parsed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tag|wml.tag]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tostring|wml.tostring]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tovconfig|wml.tovconfig]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.valid|wml.valid]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.variables|wml.variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.variables_proxy|wml.variables_proxy]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wml-utils''&lt;br /&gt;
[[LuaAPI/wml-utils#utils.check_key|utils.check_key]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.get_sides|utils.get_sides]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.handle_event_commands|utils.handle_event_commands]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.optional_side_filter|utils.optional_side_filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.scoped_var|utils.scoped_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.set_exiting|utils.set_exiting]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.vwriter|utils.vwriter]]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&amp;lt;includeonly&amp;gt;[[Category:Lua Reference]]&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;A box with all the Lua functions, each one linking to the page and section they are described in. It was generated using [[/Updating|this method]]. This box should be included in [[LuaAPI|Lua reference]] page.&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI&amp;diff=72738</id>
		<title>LuaAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI&amp;diff=72738"/>
		<updated>2024-04-23T20:41:38Z</updated>

		<summary type="html">&lt;p&gt;Laela: Include Lua_Functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Lua_Functions}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
All Lua API functionality is available in one of several global module tables, as well as some global functions which form the basic Lua API. Wesnoth uses [http://www.lua.org/manual/5.4/manual.html Lua 5.4] which is documented in detail on the Lua website.&lt;br /&gt;
&lt;br /&gt;
This page documents the modules, functions, and other APIs available for use when writing Lua for Wesnoth. For information on how to tell the engine about your Lua code, see [[LuaWML]].&lt;br /&gt;
&lt;br /&gt;
== Conventions used in this manual ==&lt;br /&gt;
&lt;br /&gt;
On this page and any page linked from it, variable values will be shown in italic type, while literal names will be shown in bold type. Variable values may be parameters, self values, indexes, or field names on a table. Return values will be indicated by a right arrow (&amp;amp;rarr;) followed by a list of names in italics. The arrow will be omitted for a function that returns nothing. Optional portions will be enclosed in square brackets. The commas for optional parameters will not be included in the brackets, even though they must be omitted if the optional parameter is omitted.&lt;br /&gt;
&lt;br /&gt;
===== Functions =====&lt;br /&gt;
&lt;br /&gt;
For example, the following line would be seen in the documentation of a function that returns two values and has an optional parameter:&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.some_function'''(''some_parameter'', [''some_optional_parameter'']) &amp;amp;rarr; ''first_return_value'', ''second_return_value''&lt;br /&gt;
&lt;br /&gt;
===== Methods =====&lt;br /&gt;
&lt;br /&gt;
The following example documents a function that can be called as a method on a ''some_value'', taking one additional parameter and returning one value.&lt;br /&gt;
&lt;br /&gt;
* ''some_value'':'''some_method'''(''some_parameter'') &amp;amp;rarr; ''some_new_value''&lt;br /&gt;
&lt;br /&gt;
===== Variadic Functions =====&lt;br /&gt;
&lt;br /&gt;
Functions that take a variable number of parameters or return a variable number of values where the specific meaning of the parameters is unspecified will use the string &amp;quot;...&amp;quot; to indicate this. For example:&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.variadic_function'''(''required_param'', [...])&lt;br /&gt;
* '''wesnoth.get_several_values'''(''param'') &amp;amp;rarr; ...&lt;br /&gt;
&lt;br /&gt;
The first of these takes a variable number of parameters, but requires at least one parameter. The second takes one parameter and returns a variable number of values.&lt;br /&gt;
&lt;br /&gt;
===== Member Variables =====&lt;br /&gt;
&lt;br /&gt;
Not all documented APIs are functions. When documenting userdata types, as well as some complex tables returned by API functions, the following syntax is used for member variables. The right arrow may be replaced with a left arrow (&amp;amp;larr;) if it is write-only, or a double-ended arrow (&amp;amp;harr;) if it is read-write. Read-only members may return multiple values. The following examples document a read-write member, a read-only member that returns two values, and a write-only member respectively.&lt;br /&gt;
&lt;br /&gt;
* ''some_value''.'''some_member''' &amp;amp;harr; ''result''&lt;br /&gt;
* ''some_value''.'''read_only_member''' &amp;amp;rarr; ''first_result'', ''second_result''&lt;br /&gt;
* ''some_value''.'''write_only_member''' &amp;amp;larr; ''input''&lt;br /&gt;
&lt;br /&gt;
===== Operators =====&lt;br /&gt;
&lt;br /&gt;
Custom types in Lua can overload operators with new functionality. Some examples of how these would be documented:&lt;br /&gt;
&lt;br /&gt;
* #'''wesnoth.list_like_object''' &amp;amp;rarr; ''number of somethings''&lt;br /&gt;
* '''wesnoth.list_like_object'''[''index''] &amp;amp;harr; ''a something definition table''&lt;br /&gt;
* ''comparable_value'' == ''comparable_value'' &amp;amp;rarr; ''whether they are equal''&lt;br /&gt;
* ''operable_value'' + ''operable_value'' &amp;amp;rarr; ''result''&lt;br /&gt;
&lt;br /&gt;
The first example documents that you can get the length of that object. The same format would be used for other unary operators as well.&lt;br /&gt;
&lt;br /&gt;
The second example documents that you can index the object with arbitrary values. Whether the index needs to be a number would usually be mentioned in the detailed description, although the placeholder name may also make it clear. This example could also use a single-directional arrow to indicate that it is read-only or write-only.&lt;br /&gt;
&lt;br /&gt;
The third example documents that you can compare two values of that type with the equality operator, and the fourth example documents that you can add two values of that type together with the addition operator.&lt;br /&gt;
&lt;br /&gt;
===== Iterators =====&lt;br /&gt;
&lt;br /&gt;
For functions that return an iterator, a double arrow indicates the values yielded when you use the iterator in a for loop. The following example documents a function returning an iterator that yields three values.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.some_function'''() &amp;amp;rarr; ''iterator'' &amp;amp;rArr; ''a'', ''b'', ''c''&lt;br /&gt;
&lt;br /&gt;
===== Hooks =====&lt;br /&gt;
&lt;br /&gt;
Some parts of the API are so-called ''hooks'', meaning that you define a function in a special location and it has some effect on the game. The following example documents a hook which takes one parameter and returns a value. Usually the double-ended arrow is used for hooks, but some may be write-only.&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.some_table'''.''name'' &amp;amp;harr; '''function'''(''parameter'') &amp;amp;rarr; ''expected return value''&lt;br /&gt;
&lt;br /&gt;
===== Context Specifiers =====&lt;br /&gt;
&lt;br /&gt;
Many functions and variables are only available in certain contexts. Currently, there are three possible contexts - plugins, map generators, and the game. Most Lua will run in the game kernel. If a function is only available in certain contexts, that will be indicated with an icon at the beginning of the definition. For example:&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_exclusive_function'''(''parameter'') &amp;amp;rarr; ''result''&lt;br /&gt;
&lt;br /&gt;
The possible icons are:&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} Available in the game context. Most Lua in Wesnoth runs in the game context, which is initialized when a game begins and destroyed upon victory or loss.&lt;br /&gt;
* {{LuaMapOnly}} Available in the map generation context. This context is created at the game creation screen, generally to generate a map for a scenario.&lt;br /&gt;
* {{LuaPluginOnly}} Available in the plugins context. There is only one plugins context, which is initialized when Wesnoth launches and remains valid until it shuts down. A plugin is a Lua script loaded via the command-line option &amp;lt;tt&amp;gt;--plugin&amp;lt;/tt&amp;gt; that runs as a coroutine in parallel with the game UI. It can automatically connect to a server and host or join a game. This API is documented at [[LuaPluginAPI]].&lt;br /&gt;
&lt;br /&gt;
== Built-in Modules ==&lt;br /&gt;
&lt;br /&gt;
The following built-in Lua modules are available:&lt;br /&gt;
&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.1 basic] — except &amp;lt;tt&amp;gt;dofile&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;require&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;loadfile&amp;lt;/tt&amp;gt;; also note that &amp;lt;tt&amp;gt;print&amp;lt;/tt&amp;gt; redirects to the Lua console interface rather than standard output; you can use &amp;lt;tt&amp;gt;std_print&amp;lt;/tt&amp;gt; if you need the default Lua behavior.&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.2 coroutine]&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.4 string]&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.5 utf8]&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.6 table]&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.7 math] — note that &amp;lt;tt&amp;gt;math.random&amp;lt;/tt&amp;gt; is unsafe for MP usage; wesnoth provides a separate MP-safe random function&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.9 os] — only the &amp;lt;tt&amp;gt;clock&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;date&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;time&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;difftime&amp;lt;/tt&amp;gt; functions are available (but keep in mind that they are not MP safe)&lt;br /&gt;
* [http://www.lua.org/manual/5.4/manual.html#6.10 debug] — only the &amp;lt;tt&amp;gt;traceback&amp;lt;/tt&amp;gt; function is available&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Modules ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth also provides several modules of its own, some of which are loaded by default while others require you to load them as needed. Note: APIs named '''wesnoth.something''', for example [[LuaAPI/wesnoth#wesnoth.scenario|wesnoth.scenario]], might be part of Core and not a separate module.&lt;br /&gt;
&lt;br /&gt;
* [[LuaAPI/wesnoth|wesnoth]] (Core) - The &amp;lt;tt&amp;gt;wesnoth&amp;lt;/tt&amp;gt; module contains most of the core Wesnoth API. It is always loaded and available.&lt;br /&gt;
** [[LuaAPI/wesnoth/interface|wesnoth.interface]] (Game Interface) - {{DevFeature1.15|0}} The &amp;lt;tt&amp;gt;interface&amp;lt;/tt&amp;gt; submodule contains functions for querying or manipulating the in-game UI.&lt;br /&gt;
** [[LuaAPI/wesnoth/units|wesnoth.units]] (Units) - {{DevFeature1.15|0}} The &amp;lt;tt&amp;gt;units&amp;lt;/tt&amp;gt; submodule contains functions for manipulating units on the map or recall list.&lt;br /&gt;
** [[LuaAPI/wesnoth/schedule|wesnoth.schedule]] (Schedule) - {{DevFeature1.15|14}} The &amp;lt;tt&amp;gt;schedule&amp;lt;/tt&amp;gt; submodule contains functions for manipulating the time of day schedule in the scenario.&lt;br /&gt;
** [[LuaAPI/wesnoth/sides|wesnoth.sides]] (Sides) - {{DevFeature1.15|3}} The &amp;lt;tt&amp;gt;sides&amp;lt;/tt&amp;gt; submodule contains functions for manipulating sides in the scenario.&lt;br /&gt;
** [[LuaAPI/wesnoth/sync|wesnoth.sync]] (Synchronization) - {{DevFeature1.15|3}} The &amp;lt;tt&amp;gt;sync&amp;lt;/tt&amp;gt; submodule contains functions for keeping multiplayer games synchronized.&lt;br /&gt;
** [[LuaAPI/wesnoth/map|wesnoth.map]] (Game Map) - {{DevFeature1.15|11}} The &amp;lt;tt&amp;gt;map&amp;lt;/tt&amp;gt; submodule contains functions for querying and manipulating the game map.&lt;br /&gt;
** [[LuaAPI/wesnoth/audio|wesnoth.audio]] (Audio) - {{DevFeature1.15|13}} The &amp;lt;tt&amp;gt;audio&amp;lt;/tt&amp;gt; submodule contains functions for playing music and sound effects.&lt;br /&gt;
** [[LuaAPI/wesnoth/paths|wesnoth.paths]] (Pathfinding) - {{DevFeature1.15|14}} The &amp;lt;tt&amp;gt;paths&amp;lt;/tt&amp;gt; submodule contains functions related to pathfinding.&lt;br /&gt;
** [[LuaAPI/wesnoth/game_events|wesnoth.game_events]] (Event Handling) - The &amp;lt;tt&amp;gt;game_events&amp;lt;/tt&amp;gt; submodule contains functions and hooks related to event handling.&lt;br /&gt;
** [[LuaAPI/wesnoth/achievements|wesnoth.achievements]] (Achievements Support) - {{DevFeature1.17|13}} The &amp;lt;tt&amp;gt;achievements&amp;lt;/tt&amp;gt; submodule contains functions for checking and setting achievements.&lt;br /&gt;
* [[LuaAPI/gui|gui]] (User Interface) - {{DevFeature1.15|0}} The &amp;lt;tt&amp;gt;gui&amp;lt;/tt&amp;gt; module contains routines for showing dialogs on the screen. It does ''not'' contain anything for manipulating the in-game UI, however.&lt;br /&gt;
** [[LuaAPI/gui/widget|gui.widget]] (GUI Widget Support) - {{DevFeature1.15|6}} The &amp;lt;tt&amp;gt;widget&amp;lt;/tt&amp;gt; submodule contains routines for operating on dialog widgets. Since they take a widget reference an argument, they can only be called while a dialog is onscreen.&lt;br /&gt;
* [[LuaAPI/wml|wml]] (WML Tables) - The &amp;lt;tt&amp;gt;wml&amp;lt;/tt&amp;gt; module contains functions for working with WML tables.&lt;br /&gt;
* [[LuaAPI/location_set|location_set]] (Location Sets) - A module for working with sets of locations, optionally associating data to each location. Not loaded by default.&lt;br /&gt;
* [[LuaAPI/functional|functional]] - Higher-order functions module. Not loaded by default.&lt;br /&gt;
* [[LuaAPI/stringx|stringx]] - Additional string support functions, to augment the built-in string module.&lt;br /&gt;
* [[LuaAPI/mathx|mathx]] - {{DevFeature1.15|13}} Additional math and randomization support functions, to augment the built-in math module.&lt;br /&gt;
* [[LuaAPI/filesystem|filesystem]] - {{DevFeature1.15|13}} Functions that allow read-only access to arbitrary files in the data folder.&lt;br /&gt;
* [[LuaAPI/ai|ai]] - Functions that instruct the AI on how to move.&lt;br /&gt;
* [[LuaAPI/wml-utils|wml-utils]] - Useful functions for implementing custom WML tags.&lt;br /&gt;
* [[LuaAPI/unit_test|unit_test]] - Functions that can be used to write unit tests; only available in [test] scenarios.&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Types ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth defines a large number of ''userdata'' types, some of which are quite common and complex. Most of them are documented alongside the function that creates them, but some of the most common or complex ones are listed below.&lt;br /&gt;
&lt;br /&gt;
* [[LuaAPI/wesnoth#wesnoth.textdomain|translatable strings]] - a string that will be translated by the engine.&lt;br /&gt;
* [[LuaAPI/wml#wml.tovconfig|vconfig]] - a WML object that automatically substitutes variables on the fly.&lt;br /&gt;
* [[LuaAPI/types/unit|unit]] - represents a reference to Wesnoth unit on the map, on the recall list, or private to Lua.&lt;br /&gt;
* [[LuaAPI/types#Weapon|weapon]] - represents a unit's weapon.&lt;br /&gt;
* [[LuaAPI/types#Race|race]] - represents a unit's race.&lt;br /&gt;
* [[LuaAPI/types#Unit_Type|unit type]] - represents a unit's type.&lt;br /&gt;
* [[LuaAPI/types/side|side]] - represents a single side (player) in the game.&lt;br /&gt;
* [[LuaAPI/types/widget|widget]] - represents a GUI2 widget.&lt;br /&gt;
* [[LuaAPI/types/map|map]] - represents the game map.&lt;br /&gt;
* [[LuaAPI/types/hex|hex]] - represents a single hex on the map.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[LuaAPI/UpdatingFrom14]]&lt;br /&gt;
* [[LuaAPI/old]] - The reference for the 1.14 Lua API, which may be useful if porting older add-ons&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference|*]]&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions/Updating&amp;diff=72731</id>
		<title>Template:Lua Functions/Updating</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions/Updating&amp;diff=72731"/>
		<updated>2024-04-19T18:06:53Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Reference how this page was made.&lt;br /&gt;
&lt;br /&gt;
For each relevant LuaAPI page run javascript&lt;br /&gt;
&amp;lt;syntaxhighlight lang='js'&amp;gt;&lt;br /&gt;
[...document.querySelectorAll('.toclevel-2 .toctext')].map(e =&amp;gt; e.innerText).filter(s =&amp;gt; s.startsWith('wesnoth') || s.startsWith('wml') || s.startsWith('gui') || s.startsWith('location_set') || s.startsWith('functional') || s.startsWith('stringx') || s.startsWith('mathx') || s.startsWith('filesystem') || s.startsWith('ai') || s.startsWith('utils') || s.startsWith('unit_test')) + &amp;quot; @ &amp;quot; + document.location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Put output to separate lines of data.txt and run python&lt;br /&gt;
&amp;lt;syntaxhighlight lang='py'&amp;gt;&lt;br /&gt;
with open(&amp;quot;data.txt&amp;quot;) as f:&lt;br /&gt;
    print('{|class=&amp;quot;reference-sidebar&amp;quot;')&lt;br /&gt;
    sections = {}&lt;br /&gt;
    for line in f:&lt;br /&gt;
        line = line.strip().strip(&amp;quot;'&amp;quot;)&lt;br /&gt;
        line = line.replace(&amp;quot;,wesnoth.audio,wesnoth.achievements,wesnoth.game_events,wesnoth.map,wesnoth.interface,wesnoth.paths,wesnoth.schedule,wesnoth.sides,wesnoth.sync,wesnoth.units&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
        methods, url = line.split(&amp;quot; @ &amp;quot;)&lt;br /&gt;
        url = url.removeprefix(&amp;quot;https://wiki.wesnoth.org/&amp;quot;)&lt;br /&gt;
        header = url.removeprefix(&amp;quot;LuaAPI/&amp;quot;).replace(&amp;quot;/&amp;quot;,&amp;quot;.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        sections[header] = []&lt;br /&gt;
        for method in sorted(methods.split(&amp;quot;,&amp;quot;)):&lt;br /&gt;
            methodWithoutLocation = method.split(&amp;quot;.&amp;quot;)[-1]&lt;br /&gt;
            row = &amp;quot;[[{}#{}|{}]]&amp;lt;br&amp;gt;&amp;quot;.format(url, method, method)&lt;br /&gt;
            sections[header].append(row)&lt;br /&gt;
&lt;br /&gt;
    for header in sorted(sections, key=lambda x: '_'+x if x.startswith('wesnoth') else x):&lt;br /&gt;
        print(&amp;quot;|-\n|''{}''&amp;quot;.format(header))&lt;br /&gt;
        for row in sections[header]:&lt;br /&gt;
            print(row)&lt;br /&gt;
    print('|}')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions&amp;diff=72730</id>
		<title>Template:Lua Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions&amp;diff=72730"/>
		<updated>2024-04-19T17:56:02Z</updated>

		<summary type="html">&lt;p&gt;Laela: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{|class=&amp;quot;reference-sidebar&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth''&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.as_text|wesnoth.as_text]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.colors|wesnoth.colors]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.compile_formula|wesnoth.compile_formula]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.current|wesnoth.current]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.current_version|wesnoth.current_version]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.custom_synced_commands|wesnoth.custom_synced_commands]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.deprecate_api|wesnoth.deprecate_api]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.deprecated_message|wesnoth.deprecated_message]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.dofile|wesnoth.dofile]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.effects|wesnoth.effects]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.eval_formula|wesnoth.eval_formula]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.game_config|wesnoth.game_config]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.get_language|wesnoth.get_language]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.log|wesnoth.log]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.micro_ais|wesnoth.micro_ais]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.ms_since_init|wesnoth.ms_since_init]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.name_generator|wesnoth.name_generator]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.named_tuple|wesnoth.named_tuple]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.persistent_tags|wesnoth.persistent_tags]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.print_attributes|wesnoth.print_attributes]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.races|wesnoth.races]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.require|wesnoth.require]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.scenario|wesnoth.scenario]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.simulate_combat|wesnoth.simulate_combat]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.terrain_types|wesnoth.terrain_types]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.textdomain|wesnoth.textdomain]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.type|wesnoth.type]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.unit_types|wesnoth.unit_types]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.version|wesnoth.version]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.wml_actions|wesnoth.wml_actions]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth#wesnoth.wml_conditionals|wesnoth.wml_conditionals]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.achievements''&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.get|wesnoth.achievements.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.has|wesnoth.achievements.has]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.has_sub_achievement|wesnoth.achievements.has_sub_achievement]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.progress|wesnoth.achievements.progress]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.set|wesnoth.achievements.set]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/achievements#wesnoth.achievements.set_sub_achievement|wesnoth.achievements.set_sub_achievement]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.audio''&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list|wesnoth.audio.music_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.add|wesnoth.audio.music_list.add]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.all|wesnoth.audio.music_list.all]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.clear|wesnoth.audio.music_list.clear]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.current|wesnoth.audio.music_list.current]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.next|wesnoth.audio.music_list.next]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.play|wesnoth.audio.music_list.play]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.previous|wesnoth.audio.music_list.previous]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.remove|wesnoth.audio.music_list.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.music_list.volume|wesnoth.audio.music_list.volume]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.play|wesnoth.audio.play]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.sources|wesnoth.audio.sources]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/audio#wesnoth.audio.volume|wesnoth.audio.volume]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.game_events''&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add|wesnoth.game_events.add]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_menu|wesnoth.game_events.add_menu]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_repeating|wesnoth.game_events.add_repeating]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.add_wml|wesnoth.game_events.add_wml]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire|wesnoth.game_events.fire]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.fire_by_id|wesnoth.game_events.fire_by_id]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_event|wesnoth.game_events.on_event]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_load|wesnoth.game_events.on_load]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_action|wesnoth.game_events.on_mouse_action]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_button|wesnoth.game_events.on_mouse_button]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_mouse_move|wesnoth.game_events.on_mouse_move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.on_save|wesnoth.game_events.on_save]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/game_events#wesnoth.game_events.remove|wesnoth.game_events.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.interface''&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_chat_message|wesnoth.interface.add_chat_message]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_hex_overlay|wesnoth.interface.add_hex_overlay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_item_halo|wesnoth.interface.add_item_halo]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_item_image|wesnoth.interface.add_item_image]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.add_overlay_text|wesnoth.interface.add_overlay_text]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.allow_end_turn|wesnoth.interface.allow_end_turn]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.clear_chat_messages|wesnoth.interface.clear_chat_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.color_adjust|wesnoth.interface.color_adjust]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.delay|wesnoth.interface.delay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.deselect_hex|wesnoth.interface.deselect_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.end_turn|wesnoth.interface.end_turn]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.float_label|wesnoth.interface.float_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_displayed_unit|wesnoth.interface.get_displayed_unit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_hovered_hex|wesnoth.interface.get_hovered_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_items|wesnoth.interface.get_items]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_selected_hex|wesnoth.interface.get_selected_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.get_viewing_side|wesnoth.interface.get_viewing_side]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.handle_user_interact|wesnoth.interface.handle_user_interact]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.highlight_hex|wesnoth.interface.highlight_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.is_locked|wesnoth.interface.is_locked]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.is_skipping_messages|wesnoth.interface.is_skipping_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.lock|wesnoth.interface.lock]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.remove_hex_overlay|wesnoth.interface.remove_hex_overlay]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.remove_item|wesnoth.interface.remove_item]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.scroll|wesnoth.interface.scroll]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.scroll_to_hex|wesnoth.interface.scroll_to_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.select_unit|wesnoth.interface.select_unit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.skip_messages|wesnoth.interface.skip_messages]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/interface#wesnoth.interface.zoom|wesnoth.interface.zoom]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.map''&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.add_label|wesnoth.map.add_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.are_hexes_adjacent|wesnoth.map.are_hexes_adjacent]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.create|wesnoth.map.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.distance_between|wesnoth.map.distance_between]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.find|wesnoth.map.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.generate|wesnoth.map.generate]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.generate_height_map|wesnoth.map.generate_height_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get|wesnoth.map.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_adjacent_hexes|wesnoth.map.get_adjacent_hexes]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_area|wesnoth.map.get_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_direction|wesnoth.map.get_direction]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_hexes_in_radius|wesnoth.map.get_hexes_in_radius]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_label|wesnoth.map.get_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_owner|wesnoth.map.get_owner]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.get_relative_dir|wesnoth.map.get_relative_dir]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.iter|wesnoth.map.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.make_bitmap|wesnoth.map.make_bitmap]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.matches|wesnoth.map.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.on_board|wesnoth.map.on_board]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.on_border|wesnoth.map.on_border]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.parse_bitmap|wesnoth.map.parse_bitmap]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.place_area|wesnoth.map.place_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.read_location|wesnoth.map.read_location]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.remove_area|wesnoth.map.remove_area]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.remove_label|wesnoth.map.remove_label]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.rotate_right_around_center|wesnoth.map.rotate_right_around_center]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.set_owner|wesnoth.map.set_owner]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.split_terrain_code|wesnoth.map.split_terrain_code]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/map#wesnoth.map.terrain_mask|wesnoth.map.terrain_mask]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.paths''&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_cost_map|wesnoth.paths.find_cost_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_path|wesnoth.paths.find_path]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_reach|wesnoth.paths.find_reach]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_vacant_hex|wesnoth.paths.find_vacant_hex]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/paths#wesnoth.paths.find_vision_range|wesnoth.paths.find_vision_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.schedule''&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.get_illumination|wesnoth.schedule.get_illumination]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.get_time_of_day|wesnoth.schedule.get_time_of_day]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/schedule#wesnoth.schedule.replace|wesnoth.schedule.replace]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.sides''&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.add_ai_component|wesnoth.sides.add_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.append_ai|wesnoth.sides.append_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.change_ai_component|wesnoth.sides.change_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.create|wesnoth.sides.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.debug_ai|wesnoth.sides.debug_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.delete_ai_component|wesnoth.sides.delete_ai_component]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.find|wesnoth.sides.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.get|wesnoth.sides.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_enemy|wesnoth.sides.is_enemy]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_fogged|wesnoth.sides.is_fogged]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.is_shrouded|wesnoth.sides.is_shrouded]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.iter|wesnoth.sides.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.matches|wesnoth.sides.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.override_shroud|wesnoth.sides.override_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.place_fog|wesnoth.sides.place_fog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.place_shroud|wesnoth.sides.place_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.remove_fog|wesnoth.sides.remove_fog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.remove_shroud|wesnoth.sides.remove_shroud]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.set_id|wesnoth.sides.set_id]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sides#wesnoth.sides.switch_ai|wesnoth.sides.switch_ai]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.sync''&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.evaluate_multiple|wesnoth.sync.evaluate_multiple]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.evaluate_single|wesnoth.sync.evaluate_single]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.invoke_command|wesnoth.sync.invoke_command]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/sync#wesnoth.sync.run_unsynced|wesnoth.sync.run_unsynced]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wesnoth.units''&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.unit.resistance_against|wesnoth.unit.resistance_against]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.ability|wesnoth.units.ability]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.add_modification|wesnoth.units.add_modification]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.advance|wesnoth.units.advance]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.chance_to_be_hit|wesnoth.units.chance_to_be_hit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.clone|wesnoth.units.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.create|wesnoth.units.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.create_animator|wesnoth.units.create_animator]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.defense_on|wesnoth.units.defense_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.erase|wesnoth.units.erase]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.extract|wesnoth.units.extract]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find|wesnoth.units.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_attack|wesnoth.units.find_attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_on_map|wesnoth.units.find_on_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.find_on_recall|wesnoth.units.find_on_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.get|wesnoth.units.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.get_hovered|wesnoth.units.get_hovered]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.jamming_on|wesnoth.units.jamming_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.matches|wesnoth.units.matches]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.movement_on|wesnoth.units.movement_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.remove_modifications|wesnoth.units.remove_modifications]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.scroll_to|wesnoth.units.scroll_to]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.select|wesnoth.units.select]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.to_map|wesnoth.units.to_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.to_recall|wesnoth.units.to_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.transform|wesnoth.units.transform]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wesnoth/units#wesnoth.units.vision_on|wesnoth.units.vision_on]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''ai''&lt;br /&gt;
[[LuaAPI/ai#ai.aspects|ai.aspects]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.attack|ai.attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_attack|ai.check_attack]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_move|ai.check_move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_recall|ai.check_recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_recruit|ai.check_recruit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.check_stopunit|ai.check_stopunit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.fallback_human|ai.fallback_human]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.get_attacks|ai.get_attacks]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.get_targets|ai.get_targets]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.move|ai.move]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.move_full|ai.move_full]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.read_only|ai.read_only]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.recall|ai.recall]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.recruit|ai.recruit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.side|ai.side]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_all|ai.stopunit_all]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_attacks|ai.stopunit_attacks]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.stopunit_moves|ai.stopunit_moves]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/ai#ai.suitable_keep|ai.suitable_keep]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''filesystem''&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.canonical_path|filesystem.canonical_path]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.have_asset|filesystem.have_asset]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.have_file|filesystem.have_file]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.image_size|filesystem.image_size]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.read_file|filesystem.read_file]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/filesystem#filesystem.resolve_asset|filesystem.resolve_asset]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''functional''&lt;br /&gt;
[[LuaAPI/functional#functional.choose|functional.choose]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.choose_map|functional.choose_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.filter|functional.filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.filter_map|functional.filter_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.find|functional.find]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.find_map|functional.find_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.map|functional.map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.map_array|functional.map_array]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.reduce|functional.reduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.take_while|functional.take_while]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/functional#functional.zip|functional.zip]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''gui''&lt;br /&gt;
[[LuaAPI/gui#gui.add_widget_definition|gui.add_widget_definition]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.get_user_choice|gui.get_user_choice]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_dialog|gui.show_dialog]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_help|gui.show_help]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_inspector|gui.show_inspector]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_lua_console|gui.show_lua_console]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_menu|gui.show_menu]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_narration|gui.show_narration]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_popup|gui.show_popup]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_prompt|gui.show_prompt]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.show_story|gui.show_story]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/gui#gui.widget|gui.widget]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''location_set''&lt;br /&gt;
[[LuaAPI/location_set#location_set.clear|location_set.clear]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.clone|location_set.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.create|location_set.create]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.diff|location_set.diff]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.empty|location_set.empty]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.filter|location_set.filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.get|location_set.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.insert|location_set.insert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.inter|location_set.inter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.inter_merge|location_set.inter_merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.invert|location_set.invert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.iter|location_set.iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_map|location_set.of_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_pairs|location_set.of_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_raw|location_set.of_raw]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_shroud_data|location_set.of_shroud_data]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_triples|location_set.of_triples]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.of_wml_var|location_set.of_wml_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.random|location_set.random]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.remove|location_set.remove]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.size|location_set.size]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.stable_iter|location_set.stable_iter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.symm|location_set.symm]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_map|location_set.to_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_pairs|location_set.to_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_shroud_data|location_set.to_shroud_data]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_stable_pairs|location_set.to_stable_pairs]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_triples|location_set.to_triples]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.to_wml_var|location_set.to_wml_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.union|location_set.union]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/location_set#location_set.union_merge|location_set.union_merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''mathx''&lt;br /&gt;
[[LuaAPI/mathx#mathx.clamp|mathx.clamp]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.lerp|mathx.lerp]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.random|mathx.random]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.random_choice|mathx.random_choice]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.round|mathx.round]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/mathx#mathx.shuffle|mathx.shuffle]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''stringx''&lt;br /&gt;
[[LuaAPI/stringx#stringx.anim_split|stringx.anim_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.escaped_split|stringx.escaped_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.format_conjunct_list|stringx.format_conjunct_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.format_disjunct_list|stringx.format_disjunct_list]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.iter_range|stringx.iter_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.iter_ranges|stringx.iter_ranges]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.join|stringx.join]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.join_map|stringx.join_map]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.map_split|stringx.map_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.parenthetical_split|stringx.parenthetical_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.parse_range|stringx.parse_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.quoted_split|stringx.quoted_split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.split|stringx.split]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.trim|stringx.trim]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/stringx#stringx.vformat|stringx.vformat]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''unit_test''&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert|unit_test.assert]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_approx_equal|unit_test.assert_approx_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_contains|unit_test.assert_contains]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_equal|unit_test.assert_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_greater|unit_test.assert_greater]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_greater_equal|unit_test.assert_greater_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_in_range|unit_test.assert_in_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_less|unit_test.assert_less]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_less_equal|unit_test.assert_less_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_not_equal|unit_test.assert_not_equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_nothrow|unit_test.assert_nothrow]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_throws|unit_test.assert_throws]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.assert_throws_with|unit_test.assert_throws_with]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.fail|unit_test.fail]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.finish|unit_test.finish]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.fire_wml_menu_item|unit_test.fire_wml_menu_item]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.log|unit_test.log]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.succeed|unit_test.succeed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/unit_test#unit_test.tostring|unit_test.tostring]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wml''&lt;br /&gt;
[[LuaAPI/wml#wml.all_variables|wml.all_variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.get|wml.array_access.get]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.get_proxy|wml.array_access.get_proxy]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_access.set|wml.array_access.set]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.array_variables|wml.array_variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.attribute_count|wml.attribute_count]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_array|wml.child_array]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_count|wml.child_count]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.child_range|wml.child_range]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.clone|wml.clone]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.diff|wml.diff]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.equal|wml.equal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.error|wml.error]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.eval_conditional|wml.eval_conditional]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.find_child|wml.find_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.fire|wml.fire]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.get_child|wml.get_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.get_nth_child|wml.get_nth_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.interpolate|wml.interpolate]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.literal|wml.literal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.load|wml.load]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.matches_filter|wml.matches_filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.merge|wml.merge]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.parse|wml.parse]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.parsed|wml.parsed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.patch|wml.patch]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.remove_child|wml.remove_child]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.remove_children|wml.remove_children]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.shallow_literal|wml.shallow_literal]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.shallow_parsed|wml.shallow_parsed]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tag|wml.tag]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tostring|wml.tostring]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.tovconfig|wml.tovconfig]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.valid|wml.valid]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.variables|wml.variables]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml#wml.variables_proxy|wml.variables_proxy]]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|''wml-utils''&lt;br /&gt;
[[LuaAPI/wml-utils#utils.check_key|utils.check_key]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.get_sides|utils.get_sides]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.handle_event_commands|utils.handle_event_commands]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.optional_side_filter|utils.optional_side_filter]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.scoped_var|utils.scoped_var]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.set_exiting|utils.set_exiting]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[LuaAPI/wml-utils#utils.vwriter|utils.vwriter]]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Laela</name></author>
		
	</entry>
</feed>