<?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=ZombieKnight</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=ZombieKnight"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/ZombieKnight"/>
	<updated>2026-05-03T02:41:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74800</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74800"/>
		<updated>2026-02-05T21:05:02Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Extra keys used by the [regenerate] 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;
* '''[defense]''' {{DevFeature1.19|16}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' .&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;
* '''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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]]. If not defined, falls back to '''id'''. Used to add this ability via '''abilities_list''' key in '''[unit_type]''' or '''[effect]apply_to=new_ability'''.&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]''': 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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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;
=== Common keys and tags for abilities with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[leadership]''', '''[heals]''', '''[regenerate]''',and '''[illuminates]''' abilities take values that specify how those abilities modify their respective base values.&lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority ability to use as its base the value returned by a lower-priority ability of the same type; for example a negative priority will cause the value to be calculated before checking whether the mainline marksman ability should override it. The value is arbitrary, but generally -10 is chosen to allow for another (not yet known) ability to be placed in between the known ones. Default: 0.&lt;br /&gt;
* '''cumulative''': if set to 'yes', the [leadership] value will be added to another [leadership] value= same if have same id=, for other abilities, the highest value between value= or base_value will be chosen.&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 ''[heals]'' and ''[regenerate]'' abilities ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': When the healed unit is poisoned, then unit takes usual poison damage instead. Interaction with poison can be changed with these values:&lt;br /&gt;
** ''cured'' - stops poison damage and heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - stops poison damage instead of healing&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value.&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;
* Use common keys and tags for abilities with a 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 and tags used by the ''[defense]'' ability ===&lt;br /&gt;
* '''value''': set defense to this value. Warning, the chance to be hit decrease when value of ability increase.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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. If you use [affect_adjacent] the terrain under and adjacent to adjacent unit will be changed.&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;
* Use Common keys and tags for abilities with a 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;
* '''radius''': {{DevFeature1.19|15}} defines the radius of the ability, by default only the terrain the user is on and adjacent hexes are affected, but this can now be extended to a radius defined by '''radius''' ; if '''radius'''=all_map then the whole map will be affected.&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. &lt;br /&gt;
* '''[filter_adjacent_student]''': {{DevFeature1.19|10}} if an adjacent unit to student 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_student]. The variables $this_unit and $other_unit both work as you'd expect. Multiple [filter_adjacent_student] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} determines the distance of units that can be filtered and not just adjacent units, '''radius''' is set to 1 by default. {{DevFeature1.19|18}} '''[filter_adjacent_student]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_adjacent_student_location]''': {{DevFeature1.19|10}} like [filter_adjacent_student], but filters on locations instead of units. This is a shorthand for [filter_student][filter_location][filter_adjacent_location]. {{DevFeature1.19|18}} '''[filter_adjacent_student_location]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&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;
** '''description_affected''': {{DevFeature1.17|13}} becomes the '''description''' of the weapon special, without changing the '''description''' of the ability&lt;br /&gt;
** '''name_affected''': {{DevFeature1.17|13}} becomes the '''name''' of the weapon special, without changing the '''name''' of the 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;
* '''[defense]''' {{DevFeature1.19|15}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' {{DevFeature1.19|16}} [defense] is no longer a weapon special but an ability.&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker '''value''' percentage 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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this weapon special, used for the registry under [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. If not defined, falls back to '''id'''. Used to add this weapon special via '''[unit_type][attack]specials_list''', or via [[EffectWML]].&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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]] and ''count'' is no longer required.&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority special to use as its base the value returned by a lower-priority special of the same type. Default: 0.&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. This value can be used via the PO variable '''$type''' inside translatable string keys, such as '''description'''.&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74799</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74799"/>
		<updated>2026-02-05T21:04:53Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Extra keys used by the [heals] 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;
* '''[defense]''' {{DevFeature1.19|16}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' .&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;
* '''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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]]. If not defined, falls back to '''id'''. Used to add this ability via '''abilities_list''' key in '''[unit_type]''' or '''[effect]apply_to=new_ability'''.&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]''': 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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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;
=== Common keys and tags for abilities with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[leadership]''', '''[heals]''', '''[regenerate]''',and '''[illuminates]''' abilities take values that specify how those abilities modify their respective base values.&lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority ability to use as its base the value returned by a lower-priority ability of the same type; for example a negative priority will cause the value to be calculated before checking whether the mainline marksman ability should override it. The value is arbitrary, but generally -10 is chosen to allow for another (not yet known) ability to be placed in between the known ones. Default: 0.&lt;br /&gt;
* '''cumulative''': if set to 'yes', the [leadership] value will be added to another [leadership] value= same if have same id=, for other abilities, the highest value between value= or base_value will be chosen.&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 ''[heals]'' and ''[regenerate]'' abilities ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': When the healed unit is poisoned, then unit takes usual poison damage instead. Interaction with poison can be changed with these values:&lt;br /&gt;
** ''cured'' - stops poison damage and heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - stops poison damage instead of healing&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[regenerate]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': {{DevFeature1.19|?}} changes the behavior when the healed unit is poisoned. possible values are: &lt;br /&gt;
** ''cured'' - heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - does prevent poison damage, but doesn't remove it and doesn't heal the unit&lt;br /&gt;
** ''left empty, or with any other value'' - does not prevent the poison damage and does not heal, when poison is present&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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 and tags used by the ''[defense]'' ability ===&lt;br /&gt;
* '''value''': set defense to this value. Warning, the chance to be hit decrease when value of ability increase.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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. If you use [affect_adjacent] the terrain under and adjacent to adjacent unit will be changed.&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;
* Use Common keys and tags for abilities with a 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;
* '''radius''': {{DevFeature1.19|15}} defines the radius of the ability, by default only the terrain the user is on and adjacent hexes are affected, but this can now be extended to a radius defined by '''radius''' ; if '''radius'''=all_map then the whole map will be affected.&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. &lt;br /&gt;
* '''[filter_adjacent_student]''': {{DevFeature1.19|10}} if an adjacent unit to student 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_student]. The variables $this_unit and $other_unit both work as you'd expect. Multiple [filter_adjacent_student] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} determines the distance of units that can be filtered and not just adjacent units, '''radius''' is set to 1 by default. {{DevFeature1.19|18}} '''[filter_adjacent_student]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_adjacent_student_location]''': {{DevFeature1.19|10}} like [filter_adjacent_student], but filters on locations instead of units. This is a shorthand for [filter_student][filter_location][filter_adjacent_location]. {{DevFeature1.19|18}} '''[filter_adjacent_student_location]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&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;
** '''description_affected''': {{DevFeature1.17|13}} becomes the '''description''' of the weapon special, without changing the '''description''' of the ability&lt;br /&gt;
** '''name_affected''': {{DevFeature1.17|13}} becomes the '''name''' of the weapon special, without changing the '''name''' of the 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;
* '''[defense]''' {{DevFeature1.19|15}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' {{DevFeature1.19|16}} [defense] is no longer a weapon special but an ability.&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker '''value''' percentage 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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this weapon special, used for the registry under [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. If not defined, falls back to '''id'''. Used to add this weapon special via '''[unit_type][attack]specials_list''', or via [[EffectWML]].&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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]] and ''count'' is no longer required.&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority special to use as its base the value returned by a lower-priority special of the same type. Default: 0.&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. This value can be used via the PO variable '''$type''' inside translatable string keys, such as '''description'''.&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74784</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74784"/>
		<updated>2026-01-29T09:42:48Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Extra keys used by the [regenerate] 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;
* '''[defense]''' {{DevFeature1.19|16}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' .&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;
* '''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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]]. If not defined, falls back to '''id'''. Used to add this ability via '''abilities_list''' key in '''[unit_type]''' or '''[effect]apply_to=new_ability'''.&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]''': 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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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;
=== Common keys and tags for abilities with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[leadership]''', '''[heals]''', '''[regenerate]''',and '''[illuminates]''' abilities take values that specify how those abilities modify their respective base values.&lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority ability to use as its base the value returned by a lower-priority ability of the same type; for example a negative priority will cause the value to be calculated before checking whether the mainline marksman ability should override it. The value is arbitrary, but generally -10 is chosen to allow for another (not yet known) ability to be placed in between the known ones. Default: 0.&lt;br /&gt;
* '''cumulative''': if set to 'yes', the [leadership] value will be added to another [leadership] value= same if have same id=, for other abilities, the highest value between value= or base_value will be chosen.&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 ''[heals]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': {{DevFeature1.19|?}} changes the behavior when the healed unit is poisoned. possible values are: &lt;br /&gt;
** ''cured'' - heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - does prevent poison damage, but doesn't remove it and doesn't heal the unit&lt;br /&gt;
** ''left empty, or with any other value'' - does not prevent the poison damage and does not heal, when poison is present&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[regenerate]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': {{DevFeature1.19|?}} changes the behavior when the healed unit is poisoned. possible values are: &lt;br /&gt;
** ''cured'' - heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - does prevent poison damage, but doesn't remove it and doesn't heal the unit&lt;br /&gt;
** ''left empty, or with any other value'' - does not prevent the poison damage and does not heal, when poison is present&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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 and tags used by the ''[defense]'' ability ===&lt;br /&gt;
* '''value''': set defense to this value. Warning, the chance to be hit decrease when value of ability increase.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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. If you use [affect_adjacent] the terrain under and adjacent to adjacent unit will be changed.&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;
* Use Common keys and tags for abilities with a 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;
* '''radius''': {{DevFeature1.19|15}} defines the radius of the ability, by default only the terrain the user is on and adjacent hexes are affected, but this can now be extended to a radius defined by '''radius''' ; if '''radius'''=all_map then the whole map will be affected.&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. &lt;br /&gt;
* '''[filter_adjacent_student]''': {{DevFeature1.19|10}} if an adjacent unit to student 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_student]. The variables $this_unit and $other_unit both work as you'd expect. Multiple [filter_adjacent_student] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} determines the distance of units that can be filtered and not just adjacent units, '''radius''' is set to 1 by default. {{DevFeature1.19|18}} '''[filter_adjacent_student]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_adjacent_student_location]''': {{DevFeature1.19|10}} like [filter_adjacent_student], but filters on locations instead of units. This is a shorthand for [filter_student][filter_location][filter_adjacent_location]. {{DevFeature1.19|18}} '''[filter_adjacent_student_location]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&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;
** '''description_affected''': {{DevFeature1.17|13}} becomes the '''description''' of the weapon special, without changing the '''description''' of the ability&lt;br /&gt;
** '''name_affected''': {{DevFeature1.17|13}} becomes the '''name''' of the weapon special, without changing the '''name''' of the 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;
* '''[defense]''' {{DevFeature1.19|15}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' {{DevFeature1.19|16}} [defense] is no longer a weapon special but an ability.&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker '''value''' percentage 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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this weapon special, used for the registry under [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. If not defined, falls back to '''id'''. Used to add this weapon special via '''[unit_type][attack]specials_list''', or via [[EffectWML]].&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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]] and ''count'' is no longer required.&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority special to use as its base the value returned by a lower-priority special of the same type. Default: 0.&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. This value can be used via the PO variable '''$type''' inside translatable string keys, such as '''description'''.&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74783</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74783"/>
		<updated>2026-01-29T09:42:34Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Extra keys used by the [heals] 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;
* '''[defense]''' {{DevFeature1.19|16}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' .&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;
* '''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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]]. If not defined, falls back to '''id'''. Used to add this ability via '''abilities_list''' key in '''[unit_type]''' or '''[effect]apply_to=new_ability'''.&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]''': 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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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;
=== Common keys and tags for abilities with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[leadership]''', '''[heals]''', '''[regenerate]''',and '''[illuminates]''' abilities take values that specify how those abilities modify their respective base values.&lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority ability to use as its base the value returned by a lower-priority ability of the same type; for example a negative priority will cause the value to be calculated before checking whether the mainline marksman ability should override it. The value is arbitrary, but generally -10 is chosen to allow for another (not yet known) ability to be placed in between the known ones. Default: 0.&lt;br /&gt;
* '''cumulative''': if set to 'yes', the [leadership] value will be added to another [leadership] value= same if have same id=, for other abilities, the highest value between value= or base_value will be chosen.&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 ''[heals]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': {{DevFeature1.19|?}} changes the behavior when the healed unit is poisoned. possible values are: &lt;br /&gt;
** ''cured'' - heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - does prevent poison damage, but doesn't remove it and doesn't heal the unit&lt;br /&gt;
** ''left empty, or with any other value'' - does not prevent the poison damage and does not heal, when poison is present&lt;br /&gt;
&lt;br /&gt;
* Use common keys and tags for abilities with a value.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[regenerate]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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 and tags used by the ''[defense]'' ability ===&lt;br /&gt;
* '''value''': set defense to this value. Warning, the chance to be hit decrease when value of ability increase.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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. If you use [affect_adjacent] the terrain under and adjacent to adjacent unit will be changed.&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;
* Use Common keys and tags for abilities with a 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;
* '''radius''': {{DevFeature1.19|15}} defines the radius of the ability, by default only the terrain the user is on and adjacent hexes are affected, but this can now be extended to a radius defined by '''radius''' ; if '''radius'''=all_map then the whole map will be affected.&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. &lt;br /&gt;
* '''[filter_adjacent_student]''': {{DevFeature1.19|10}} if an adjacent unit to student 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_student]. The variables $this_unit and $other_unit both work as you'd expect. Multiple [filter_adjacent_student] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} determines the distance of units that can be filtered and not just adjacent units, '''radius''' is set to 1 by default. {{DevFeature1.19|18}} '''[filter_adjacent_student]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_adjacent_student_location]''': {{DevFeature1.19|10}} like [filter_adjacent_student], but filters on locations instead of units. This is a shorthand for [filter_student][filter_location][filter_adjacent_location]. {{DevFeature1.19|18}} '''[filter_adjacent_student_location]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&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;
** '''description_affected''': {{DevFeature1.17|13}} becomes the '''description''' of the weapon special, without changing the '''description''' of the ability&lt;br /&gt;
** '''name_affected''': {{DevFeature1.17|13}} becomes the '''name''' of the weapon special, without changing the '''name''' of the 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;
* '''[defense]''' {{DevFeature1.19|15}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' {{DevFeature1.19|16}} [defense] is no longer a weapon special but an ability.&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker '''value''' percentage 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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this weapon special, used for the registry under [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. If not defined, falls back to '''id'''. Used to add this weapon special via '''[unit_type][attack]specials_list''', or via [[EffectWML]].&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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]] and ''count'' is no longer required.&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority special to use as its base the value returned by a lower-priority special of the same type. Default: 0.&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. This value can be used via the PO variable '''$type''' inside translatable string keys, such as '''description'''.&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74782</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74782"/>
		<updated>2026-01-29T09:41:47Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Extra keys used by the [heals] 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;
* '''[defense]''' {{DevFeature1.19|16}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' .&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;
* '''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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]]. If not defined, falls back to '''id'''. Used to add this ability via '''abilities_list''' key in '''[unit_type]''' or '''[effect]apply_to=new_ability'''.&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]''': 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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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;
=== Common keys and tags for abilities with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[leadership]''', '''[heals]''', '''[regenerate]''',and '''[illuminates]''' abilities take values that specify how those abilities modify their respective base values.&lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority ability to use as its base the value returned by a lower-priority ability of the same type; for example a negative priority will cause the value to be calculated before checking whether the mainline marksman ability should override it. The value is arbitrary, but generally -10 is chosen to allow for another (not yet known) ability to be placed in between the known ones. Default: 0.&lt;br /&gt;
* '''cumulative''': if set to 'yes', the [leadership] value will be added to another [leadership] value= same if have same id=, for other abilities, the highest value between value= or base_value will be chosen.&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 ''[heals]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* '''poison''': {{DevFeature1.19|?}} changes the behavior when the healed unit is poisoned.&lt;br /&gt;
possible values: &lt;br /&gt;
** ''cured'' - heals the poison instead of healing&lt;br /&gt;
** ''slowed'' - does prevent poison damage, but doesn't remove it and doesn't heal the unit&lt;br /&gt;
** ''left empty, or with any other value'' - does not prevent the poison damage and does not heal, when poison is present&lt;br /&gt;
* Use common keys and tags for abilities with a value.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[regenerate]'' ability ===&lt;br /&gt;
* '''value''': the amount healed.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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 and tags used by the ''[defense]'' ability ===&lt;br /&gt;
* '''value''': set defense to this value. Warning, the chance to be hit decrease when value of ability increase.&lt;br /&gt;
* Use common keys and tags for abilities with a value&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;
* Use common keys and tags for abilities with a 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. If you use [affect_adjacent] the terrain under and adjacent to adjacent unit will be changed.&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;
* Use Common keys and tags for abilities with a 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;
* '''radius''': {{DevFeature1.19|15}} defines the radius of the ability, by default only the terrain the user is on and adjacent hexes are affected, but this can now be extended to a radius defined by '''radius''' ; if '''radius'''=all_map then the whole map will be affected.&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. &lt;br /&gt;
* '''[filter_adjacent_student]''': {{DevFeature1.19|10}} if an adjacent unit to student 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_student]. The variables $this_unit and $other_unit both work as you'd expect. Multiple [filter_adjacent_student] can be provided, all of which must pass for the ability to activate.&lt;br /&gt;
** '''radius''': {{DevFeature1.19|13}} determines the distance of units that can be filtered and not just adjacent units, '''radius''' is set to 1 by default. {{DevFeature1.19|18}} '''[filter_adjacent_student]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&lt;br /&gt;
* '''[filter_adjacent_student_location]''': {{DevFeature1.19|10}} like [filter_adjacent_student], but filters on locations instead of units. This is a shorthand for [filter_student][filter_location][filter_adjacent_location]. {{DevFeature1.19|18}} '''[filter_adjacent_student_location]''' is removed because having multiple shorthands requires giving them specific names for abilities used as weapons, and it's even simpler to use the [[StandardUnitFilter]].&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;
** '''description_affected''': {{DevFeature1.17|13}} becomes the '''description''' of the weapon special, without changing the '''description''' of the ability&lt;br /&gt;
** '''name_affected''': {{DevFeature1.17|13}} becomes the '''name''' of the weapon special, without changing the '''name''' of the 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;
* '''[defense]''' {{DevFeature1.19|15}}: modifies the chances of being hit by the opponent's weapon, this value can be modified by the parry attribute, the accuracy attribute of the opponent's weapon, or by their special weapon '''[chance_to_hit]'''. Be careful, the more you increase the value, the less chance the opponent has of hitting you. Using same standard numerical attributes as '''[attacks]''' {{DevFeature1.19|16}} [defense] is no longer a weapon special but an ability.&lt;br /&gt;
* '''[disable]''': disables the weapon&lt;br /&gt;
* '''[drains]''': heals the attacker '''value''' percentage 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;
* '''unique_id''': {{DevFeature1.19|18}} A unique identifier for this weapon special, used for the registry under [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. If not defined, falls back to '''id'''. Used to add this weapon special via '''[unit_type][attack]specials_list''', or via [[EffectWML]].&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. {{DevFeature1.19|18}} '''filter_adjacent''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]] and ''count'' is no longer required.&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]. {{DevFeature1.19|18}} '''filter_adjacent_location''' is deprecated and will likely be removed in version 1.21, since a version already exists in the [[StandardUnitFilter]].&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. Available inside translatable strings as '''$value'''.&lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]]. Available inside translatable strings as '''$add'''.&lt;br /&gt;
* '''sub''': the number to subtract from the base value. Available inside translatable strings as '''$sub'''.&lt;br /&gt;
* '''multiply''': this multiplies the base value. Available inside translatable strings as '''$multiply'''.&lt;br /&gt;
* '''divide''': this divides the base value. Available inside translatable strings as '''$divide'''.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit. Available inside translatable strings as '''$max_value'''.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit. Available inside translatable strings as '''$min_value'''.&lt;br /&gt;
* '''priority''': {{DevFeature1.19|19}}  This attribute allows a higher-priority special to use as its base the value returned by a lower-priority special of the same type. Default: 0.&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. This value can be used via the PO variable '''$type''' inside translatable string keys, such as '''description'''.&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/game_events&amp;diff=73922</id>
		<title>LuaAPI/wesnoth/game events</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/game_events&amp;diff=73922"/>
		<updated>2024-11-03T12:38:06Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* wesnoth.game_events.fire */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;game_events&amp;lt;/tt&amp;gt; module contains functions for manipulating game event handlers and hooks that can be used for registering low-level game events.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.add ===&lt;br /&gt;
&lt;br /&gt;
Registers a new event handler, as [[EventWML]]. This function is the most flexible method of adding an event, which exposes all the available options via the options table, but there are also two other ways to add an event – [[#wesnoth.game_events.add_repeating|add_repeating]] is suitable for quick, recurring events, or [[#wesnoth.game_events.add_menu|add_menu]] for menu items, while [[#wesnoth.game_events.add_wml|add_wml]] is the underlying mechanism of the event tag and mostly exists just for quick compatibility.&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.add'''(''options table'')&lt;br /&gt;
&lt;br /&gt;
Registers an event handler in the scenario. The argument is a table containing several optional named arguments. The possible arguments are:&lt;br /&gt;
&lt;br /&gt;
* '''name''': The name of the event to handle. This can be a string (a single event name, a comma-separated list, or an expression of WML variables that can expand to one or more event names) or a table of event names as individual strings (which can also possibly contain WML variables). Default is usually an empty string, but note that either a name or ID is required. If '''menu_item''' is true, the name defaults to &amp;quot;menu item id&amp;quot;, where &amp;quot;id&amp;quot; is the same ID as below.&lt;br /&gt;
* '''id''': The event ID, used to remove it later; also, if an event with the same ID is already registered, then this event will be ignored and will not be registered. Default is an empty string. Required if '''menu_item''' is true. Note that either a name or ID is required for any event.&lt;br /&gt;
* '''menu_item''': True if this is a menu item (an ID is required); this means removing the menu item will automatically remove this event. Default false. Note that this does not, by itself, mean the event will be triggered when the menu item is selected. The '''name''' determines when the event is triggered.&lt;br /&gt;
* '''first_time_only''': Controls whether this event will fire more than once. Default true, meaning that it fires only once and is then removed.&lt;br /&gt;
* '''priority''': Events execute in order of decreasing priority, and secondarily in order of addition.&lt;br /&gt;
* '''filter''': Filters that, if not passed, will prevent the event from firing. There are three possible formats for this:&lt;br /&gt;
** A WML table with filter tags and attributes (like an [event] tag with no action content and no name or id). In this case the filters are parsed in the same way as they would be for an [event] tag. It can contain any supported event filter tag, or '''[insert_tag]''' tags that expand to a supported event filter tag.&lt;br /&gt;
** A table of the form &amp;lt;syntaxhighlight lang=lua inline&amp;gt;{filter_type = filter_contents}&amp;lt;/syntaxhighlight&amp;gt;. The possible filter types are: '''formula''', '''condition''', '''side''', '''unit''', '''second_unit''', '''attack''', and '''second_attack'''. The '''formula''' filter is a string containing [[Wesnoth Formula Language]] code, while all other filters can either be a WML table containing the filter contents, or a string containing the name of a WML variable to load the filter from. In the second case, the variable will be read at event handling time, not at registration time, so modifying the variable will dynamically alter the event's filter. This is equivalent to using '''[insert_tag]''' (and delayed variable substitution, if nested) to define the filter in [[EventWML]].&lt;br /&gt;
** A function that optionally takes a WML table as argument and returns a boolean value.&lt;br /&gt;
* '''filter_args''': An optional WML table that will be passed to the '''filter''' function. This is used only if the '''filter''' is a function.&lt;br /&gt;
* '''content''': The content of the event. If '''action''' is specified, this is a WML table passed verbatim to that function when the event fires. If '''action''' is not specified, this will be interpreted as ActionWML to be executed when the event fires.&lt;br /&gt;
* '''action''': The function to call when the event triggers. It can take a WML table as argument (the '''content''') but does not return anything.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.add_repeating ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.add_repeating'''(''event name'', ''handler function'', [''priority''], [''on undo function''])&lt;br /&gt;
&lt;br /&gt;
Registers a recurring event (as &amp;lt;syntaxhighlight lang=wml inline&amp;gt;[event]first_time_only=no&amp;lt;/syntaxhighlight&amp;gt;) with the specified event name which will call the function when it triggers. The event name is the same as the '''name''' key in the options table in [[#wesnoth.game_events.add|game_events.add]].&lt;br /&gt;
&lt;br /&gt;
The handler function takes no argument and returns nothing.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.add_menu ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.add_menu'''(''menu item id'', ''handler function'')&lt;br /&gt;
&lt;br /&gt;
Registers a recurring event for a menu item. The first argument is the menu item ID, rather than an event name, so it cannot be an array or contain any commas. (TODO: Can it contain variables?) The event will be automatically linked to the menu item with the same ID and will be removed from the scenario if that menu item is removed. It will trigger when the menu item is selected.&lt;br /&gt;
&lt;br /&gt;
The handler function takes no argument and returns nothing.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.add_wml ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.add_wml'''(''event config'')&lt;br /&gt;
&lt;br /&gt;
This is simply the underlying implementation of the event tag. The argument is the entire content of an event tag. It will parse name, id, delayed_variable_substitution, first_time_only, filters, and [[ActionWML]] from this config and use that to register an event.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.remove ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.remove'''(''id'')&lt;br /&gt;
&lt;br /&gt;
Removes the event handler with the given ID, if it exists. If it does not exist, this does nothing.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.fire ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.fire'''(''name'', [''first location'', [''second location'']], [''event data'']) &amp;amp;rarr; ''processed?''&lt;br /&gt;
&lt;br /&gt;
Fires all events with the given name, passing any specified data into the event. If the locations passed in have a unit on them, that unit will become the primary or secondary unit of the event. The event data is a config that can contain arbitrary data.&lt;br /&gt;
&lt;br /&gt;
The most common use of event data is to pass in the weapons for an attack event - to do this, add a '''first''' and '''second''' (weapon) tag to the config. Other data used by built-in events includes the '''damage_inflicted''' value in an attack hit event, or the '''owner_side''' value in a village capture event. For custom events, you can put anything you want in here.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.fire_by_id ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.fire'''(''id'', [''first location'', [''second location'']], [''event data'']) &amp;amp;rarr; ''processed?''&lt;br /&gt;
&lt;br /&gt;
Same as [[#wesnoth.game_events.fire|fire]], but triggers the event with a specific ID instead of all events with the given name.&lt;br /&gt;
&lt;br /&gt;
== Hooks ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_event ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_event''' &amp;amp;harr; '''function'''(''event_name'')&lt;br /&gt;
&lt;br /&gt;
This is a lower-level method of handling events. It triggers on all events before any registered event handlers and is passed the name of the event as its sole parameter - the rest of the event info is available via [[../#wesnoth.current|'''wesnoth.current.event_context''']]. This hook is called before any registered event handlers (eg [event] tags) for the event. The event names passed to '''on_event''' always use underscores instead of spaces.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' a on_event handler will not prevent undoing of that event, so if your callback intends to change the game state, you will need to take extra care to avoid out-of-sync errors. The easiest way is to have the callback register a new event with the same name, which will have the side-effect of disallowing undo. Since '''on_event''' is called before the event is fully processed, this new event will be triggered as soon as the callback exits. You could even wrap this functionality into a function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function disallow_undo()&lt;br /&gt;
	wesnoth.wml_actions.event { name = wesnoth.current.event_context.name }&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_load ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_load''' &amp;amp;harr; '''function'''(''scenario wml'')&lt;br /&gt;
&lt;br /&gt;
This is a lower-level method of handling the load game event and the [[../#wesnoth.persistent_tags|'''wesnoth.persistent_tags''']] mechanism. It is called whenever the game is loaded, before the on_load event is triggered. If overriding this, be sure to call the original version of the function, as '''wesnoth.persistent_tags''' also depends on this event.&lt;br /&gt;
&lt;br /&gt;
The scenario WML passed to this function is not the complete WML of the scenario but only the tags that the core Wesnoth engine does not know how to handle. You will never find an [event] or [side] tag in this table, for example. Although some core tags are already handled using this mechanism, you should not rely on this - for example, reading [item] tags in '''on_load''' is not guaranteed to work in future versions. The following is a list of all such tags:&lt;br /&gt;
&lt;br /&gt;
 color_palette   color_range  display  end_level_data  era           event             generator&lt;br /&gt;
 item            label        lua      menu_item       modification  modify_unit_type  music&lt;br /&gt;
 next_item_name  objectives   options  side            sound_source  story             terrain_graphics&lt;br /&gt;
 time            time_area    tunnel   undo_stack      used_item     variables&lt;br /&gt;
&lt;br /&gt;
'''Note:''' since the '''on_load''' hook is called very early in the scenario, it cannot be set inside a [lua] tag in an [event], not even a '''preload''' one - it's called even before '''preload''' fires. It can only be set inside a [lua] tag outside an event, either at [scenario] level or global.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_save ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_save''' &amp;amp;harr; '''function'''() &amp;amp;rarr; ''scenario wml''&lt;br /&gt;
&lt;br /&gt;
The counterpart to '''on_load''', this function is called whenever the game is saved. Any returned WML is merged into the scenario WML in the saved game. Usually the higher-level [[../#wesnoth.persistent_tags|'''wesnoth.persistent_tags''']] mechanism is recommended instead of overriding this directly. If overriding this, be sure to call the original version of the function, as '''wesnoth.persistent_tags''' also depends on this event.&lt;br /&gt;
&lt;br /&gt;
This callback can only be used to add ''custom'' data to the saved game. You can't use it to add extra data that the engine already knows about, such as events or sides, as such tags will be ignored when merging the result into the saved game WML. Although some core tags are already handled using this mechanism, you should not rely on this - for example, adding [item] tags in '''on_save''' is not guaranteed to work in future versions. See the '''on_load''' description above for a complete list of these tags.&lt;br /&gt;
&lt;br /&gt;
Here's an example of how to use '''on_load''' and '''on_save''' to handle a custom tag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
-- some value that survives save/load cycles, but that is not forwarded to the next level&lt;br /&gt;
local level_local_data = 0&lt;br /&gt;
&lt;br /&gt;
local old_on_load = wesnoth.game_event.on_load&lt;br /&gt;
function wesnoth.game_event.on_load(cfg)&lt;br /&gt;
    for i, tag in ipairs(cfg) do&lt;br /&gt;
        if tag[1] == &amp;quot;my_data&amp;quot; then&lt;br /&gt;
            -- recover the value stored in the savefile&lt;br /&gt;
            level_local_data = tag[2].value&lt;br /&gt;
            -- erase the child, since it has been handled&lt;br /&gt;
            table.remove(cfg, i)&lt;br /&gt;
            break&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- call the previous hook, in case there are still some containers in the savefile&lt;br /&gt;
    old_on_load(cfg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local old_on_save = wesnoth.game_events.on_save&lt;br /&gt;
function wesnoth.game_events.on_save()&lt;br /&gt;
    -- call the previous hook, in case it had some containers to store&lt;br /&gt;
    local cfg = old_on_save()&lt;br /&gt;
    -- add our own container to them&lt;br /&gt;
    table.insert(cfg, wml.tag.my_data{ value = level_local_data })&lt;br /&gt;
    -- tell the engine to store them in the savefile&lt;br /&gt;
    return cfg&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_mouse_action ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_mouse_action''' &amp;amp;harr; '''function'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
This function is called whenever the user left clicks on a hex, and is passed the coordinates of the clicked hex. This could be used for many purposes, such as a true long-ranged attack, but it has some problems.&lt;br /&gt;
&lt;br /&gt;
The callback does ''not'' cancel the normal action that would have occurred as a result of the click, such as selecting or moving a unit. Furthermore, if the ''on_mouse_action'' callback takes some time to execute, it's possible the mouse moves during this time, and when the callback has completed, the action taken depends on the ''new'' position of the mouse, rather than the position that was originally clicked. Because of this bug, it is probably a bad idea to display any sort of animation in this callback or do anything that takes time.&lt;br /&gt;
&lt;br /&gt;
In addition, this callback is unsynced, so it is not safe for use in multiplayer games unless you do [[LuaAPI/wesnoth/sync#wesnoth.sync.evaluate_single|manual sychronization]].&lt;br /&gt;
&lt;br /&gt;
Some discussion of the problems with this callback can be found in [https://github.com/wesnoth/wesnoth/issues/2325 this enhancement request].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_mouse_button ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|22}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_mouse_button''' &amp;amp;harr; '''function'''(''x'', ''y'', ''button'', ''event'') &amp;amp;rarr; ''consume?''&lt;br /&gt;
&lt;br /&gt;
Registers a handler for mouse button events occurring on a valid map tile and when the UI is in a normal play state. It does not receive notification for any events on a GUI, the minimap, or when a message is up.&lt;br /&gt;
&lt;br /&gt;
* '''x''', '''y''': The map coordinates the event occurred on&lt;br /&gt;
* '''button''': The name of the button as a string, which will be one of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;left&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;middle&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;right&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;mouse4&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, or &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;mouse5&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
* '''event''': One of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;down&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;up&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;, or &amp;lt;syntaxhighlight lang=lua inline&amp;gt;&amp;quot;click&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The usual order of events is down, up, and then click. However, left and middle clicks ''currently'' occur at the mouse down, so the order is different for these two. The most common use case will be to handle click events and ignore the rest. The callback may ''consume'' a click event, preventing the game engine from invoking it's default action, by returning ''true''. The return value when called for down or up events is ignored.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Order of button events&lt;br /&gt;
|-&lt;br /&gt;
! Button&lt;br /&gt;
! Order&lt;br /&gt;
|-&lt;br /&gt;
| left&lt;br /&gt;
| down, click, up&lt;br /&gt;
|-&lt;br /&gt;
| middle&lt;br /&gt;
| down, click, up&lt;br /&gt;
|-&lt;br /&gt;
| right&lt;br /&gt;
| down, up, click&lt;br /&gt;
|-&lt;br /&gt;
| mouse4&lt;br /&gt;
| down, up, click&lt;br /&gt;
|-&lt;br /&gt;
| mouse5&lt;br /&gt;
| down, up, click&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At this time, there is no Lua support for drag and drop events. When a right, mouse4 or mouse5 down occurs on one tile, but then an up event on a different one (i.e., the mouse is dragged), there will be no click event. For a proper click event, both down and up must occur on the same tile. While this restriction is not currently possible with left and middle clicks, the behavior may be changed in a future release so that all mouse button events are handled consistently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''WARNING'''&amp;lt;/big&amp;gt;: ''Your event handler should be as brief as possible!'' It should check for the exact events it is looking for and immediately return false for all others. It should not attempt to display any messages, ask the user questions, pontificate the meaning of life, sell memorabilia on ebay, etc. Any intensive operations (requiring more than a few milliseconds) should be delegated to a [https://www.lua.org/pil/9.1.html coroutine] or otherwise scheduled to occur later (e.g., setting by a &amp;quot;flag&amp;quot; variable).&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;wesnoth.game_events.on_mouse_button = function(x, y, button, event)&lt;br /&gt;
    if not (button == &amp;quot;right&amp;quot; and event == &amp;quot;click&amp;quot;) then&lt;br /&gt;
        return false&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Do stuff here&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.game_events.on_mouse_move ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.game_events.on_mouse_move''' &amp;amp;harr; '''function'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
This function is called when the mouse moves. More specifically, it's called whenever the currently hovered hex changes. This callback does not share most of the shortcomings of the '''on_mouse_action''' callback, but it is still unsynced.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/units&amp;diff=73915</id>
		<title>LuaAPI/wesnoth/units</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/units&amp;diff=73915"/>
		<updated>2024-11-01T17:59:19Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* wesnoth.units.to_map */&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;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
The entire units module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.advance ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.advance'''(''unit'', [''animate'', ''fire_events''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''advance'''([''animate'', ''fire_events''])&lt;br /&gt;
&lt;br /&gt;
Advances the unit (and shows the advance unit dialog if needed) if the unit has enough XP. This function should be called after modifying the unit's experience directly. A similar function is called by Wesnoth internally after unit combat. The second argument is a boolean value that specifies whether the advancement should be animated. The third argument is a boolean value that specifies whether advancement related events should be fired.&lt;br /&gt;
&lt;br /&gt;
This function only works for units on the map.&lt;br /&gt;
&lt;br /&gt;
This function can also trigger multiple advancements if the unit has enough XP.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.clone ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.clone'''(''unit'') → ''copy of unit''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''clone'''()&lt;br /&gt;
&lt;br /&gt;
Creates a private unit from another unit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- extract a unit from the map&lt;br /&gt;
local u = wesnoth.units.find_on_map{ type = &amp;quot;Thug&amp;quot; }[1]:clone()&lt;br /&gt;
wesnoth.units.erase(u.x, u.y) -- note: not the same as u:erase(), which would be an error&lt;br /&gt;
-- u is still valid at this point&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.erase ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.erase'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.erase'''(''x'', ''y'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''erase'''()&lt;br /&gt;
&lt;br /&gt;
Erases a unit from the map. After calling this on a unit, the unit is no longer valid. Does not work on private units - this usage will raise an error.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.extract ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.extract'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''extract'''()&lt;br /&gt;
&lt;br /&gt;
Removes a unit from the map or from a recall list and makes it private.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- remove all the units from the recall list of side 1 and put them in a WML container&lt;br /&gt;
local list = {}&lt;br /&gt;
for i,u in ipairs(wesnoth.units.find_on_recall{ side = 1 }) do&lt;br /&gt;
    u:extract()&lt;br /&gt;
    table.insert(list, u.__cfg)&lt;br /&gt;
end&lt;br /&gt;
wml.array_access.set(&amp;quot;player_recall_list&amp;quot;, list)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: if the unit is on the map, this is just a shortcut for calling [[#wesnoth.units.clone]] and then [[#wesnoth.units.erase]]. It is, however, the only way to remove a unit from a recall list without putting it on the map.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.matches'''(''unit'', ''filter'', [''other_unit'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.matches'''(''unit'', ''filter'', [''location'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''matches'''(''filter'', [''other_unit'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''matches'''(''filter'', [''location'']) → ''matched?''&lt;br /&gt;
&lt;br /&gt;
Returns true if the given unit matches the WML filter passed as the second argument. If ''other_unit'' is specified, it is used for the ''$other_unit'' auto-stored variable in the filter. Otherwise, this variable is not stored for the filter. If an extra ''location'' is specified, the filter matches as if the unit were at that location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
assert(unit.canrecruit == wesnoth.units.matches(unit, { canrecruit = true }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_attack ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_attack'''(''unit'', ''filter'') &amp;amp;rarr; ''attack''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''find_attack'''(''filter'') &amp;amp;rarr; ''attack''&lt;br /&gt;
&lt;br /&gt;
Returns the first attack that matches the given [[StandardWeaponFilter]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.to_map ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_map'''(''unit'' [,''fire_event''])&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_map'''(''unit'', ''x'', ''y'' [,''fire_event''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''to_map'''([''x'', ''y'' [,''fire_event'']])&lt;br /&gt;
&lt;br /&gt;
Places a unit on the map. This unit is described either by a WML table or by a proxy unit (to use the third form, it must be a proxy). Coordinates can be passed as additional arguments; otherwise the table is expected to have two fields '''x''' and '''y''', which indicate where the unit will be placed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- create a unit with random traits, then erase it&lt;br /&gt;
wesnoth.units.to_map({ type = &amp;quot;Elvish Lady&amp;quot; }, 17, 42)&lt;br /&gt;
wesnoth.units.erase(17, 42)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the argument is a proxy unit, no duplicate is created. In particular, if the unit was private or on a recall list, it no longer is; and if the unit was on the map, it has been moved to the new location. Note: passing a WML table is just a shortcut for calling [[#wesnoth.units.create]] and then putting the resulting unit on the map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- move the leader back to the top-left corner&lt;br /&gt;
wesnoth.units.find_on_map({ canrecruit = true })[1]:to_map(1, 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If x,y is a village, this function does not capture it (as of 1.14). Use [[LuaWML/Sides#wesnoth.set_village_owner|wesnoth.set_village_owner(x, y, unit.side)]] if that's what you want.&lt;br /&gt;
&lt;br /&gt;
'''Caution:''' Using this function will trigger unit placed events. While this may be correct in most cases, there are some cases where it shouldn't, especially if the code is inside the definition of a custom WML tag — it would be an unexpected side-effect from the users point. To work around this, ''false'' can be passed additionally as the last argument. This is what is used internally for some tags such as [move_unit], [harm_unit], [unpetrify] or the feeding ability and is not officially part of the API.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.to_recall ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_recall'''(''unit'', [''side''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''to_recall'''([''side''])&lt;br /&gt;
&lt;br /&gt;
Places a unit on a recall list. This unit is described either by a WML table or by a proxy unit (to use the third form, it must be a proxy). The side of the recall list is given by the second argument if present, or by the side of the unit otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- put the unit at location 17,42 on the recall list for side 2&lt;br /&gt;
wesnoth.units.find_on_map{ x= 17, y = 42 })[1]:to_recall(2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the argument is a proxy unit, no duplicate is created. In particular, if the unit was private or on the map, it no longer is. Note: passing a WML table is just a shortcut for calling [[#wesnoth.units.create]] and then putting the resulting unit on a recall list.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.rebuild ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.rebuild'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''rebuild'''()&lt;br /&gt;
&lt;br /&gt;
Immediately rebuilds the unit from its unit type and modifications, discarding any alterations to non-transient attributes. Does not reset transient attributes such as the units current hitpoints, moves, or experience.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.transform ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.transform'''(''unit'', ''to_type'', [''to_variation''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''transform'''(''to_type'', [''to_variation''])&lt;br /&gt;
&lt;br /&gt;
Changes the type of a unit and adjust attributes accordingly. Note that hit points are only changed if necessary to accommodate the new maximum hit points. Poison is automatically removed if the transformed unit is immune.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local ev = wesnoth.current.event_context&lt;br /&gt;
local u = wesnoth.units.find_on_map{x=ev.x1, y=ev.y1}[1]&lt;br /&gt;
u:transform(&amp;quot;Spearman&amp;quot;)&lt;br /&gt;
-- If a full heal is desired:&lt;br /&gt;
u.hitpoints = u.max_hitpoints&lt;br /&gt;
u.status.poisoned = false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.select ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.select_unit]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.scroll_to ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.scroll_to_hex]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.ability ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.ability'''(''unit'', ''ability_tag'') → ''affected''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''ability'''(''ability_tag'') → ''affected''&lt;br /&gt;
&lt;br /&gt;
Returns true if the unit is currently affected by an ability with this given tag name. This means that the ability could be owned by the unit itself, or by an adjacent unit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
function has_teleport(u)&lt;br /&gt;
    return u:ability(&amp;quot;teleport&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.chance_to_be_hit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.chance_to_be_hit'''(''unit'', ''terrain_code'') → ''hit chance''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''chance_to_be_hit'''(''terrain_code'') → ''hit chance''&lt;br /&gt;
&lt;br /&gt;
Returns the chance that a unit will be hit on a particular terrain (based on its defence).&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.defense_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.defense_on'''(''unit'', ''terrain_code'') → ''defense value''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''defense_on'''(''terrain_code'') → ''defense value''&lt;br /&gt;
&lt;br /&gt;
Returns the defense of a unit on a particular terrain. (Note: it is the actual defense. So the lower it is, the weaker the unit is.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local flat_defense = u:defense_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.resistance_against ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.resistance_against'''(''unit'', ''damage_type'', [''as_attacker''], [''x'', ''y'']) → ''resistance value''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''resistance_against'''(''damage_type'', [''as_attacker''], [''x'', ''y'']) → ''resistance value''&lt;br /&gt;
&lt;br /&gt;
Returns the resistance of a unit against an attack type. (Note: it is the actual resistance. So the lower it is, the weaker the unit is.) The third argument indicates whether the unit is the attacker. Last arguments are the coordinates of an optional map location (for the purpose of taking abilities into account).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local fire_resistance = u:resistance_against(&amp;quot;fire&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.jamming_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.jamming_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''jamming_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the jamming cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local jam_cost = u:jamming_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.movement_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.movement_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''movement_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the movement cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local move_cost = u:movement_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.vision_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.vision_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''vision_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the vision cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local see_cost = u:vision_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.add_modification ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.add_modification'''(''unit'', ''type'', ''effects'', [''write_to_mods''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''add_modification'''(''type'', ''effects'', [''write_to_mods''])&lt;br /&gt;
&lt;br /&gt;
Modifies a given unit. It needs to be a proxy unit. The second argument is the type of the modification (one of &amp;quot;trait&amp;quot;, &amp;quot;object&amp;quot;, or &amp;quot;advancement&amp;quot;). The option &amp;quot;advancement&amp;quot; applies effects as if the unit would advance (e.g. AMLA effects). The third argument is a WML table describing the effect, so mostly containing '''[effect]''' children. See [[EffectWML]] for details about effects. If ''write_to_mods'' false, causes it to not write the modification tag to the unit's [modifications] (as would be done with an [object] with no_write=true).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local T = wml.tag&lt;br /&gt;
local u = wesnoth.units.find_on_map{ canrecruit = true }[1]&lt;br /&gt;
local effects = {&lt;br /&gt;
  id = &amp;quot;my_effect_id&amp;quot;,&lt;br /&gt;
  T.effect { &lt;br /&gt;
    apply_to = &amp;quot;image_mod&amp;quot;, &lt;br /&gt;
    replace = &amp;quot;RC(red&amp;gt;blue)&amp;quot; &lt;br /&gt;
  },&lt;br /&gt;
  T.effect {&lt;br /&gt;
    apply_to = &amp;quot;new_animation&amp;quot;,&lt;br /&gt;
    T.standing_animation {&lt;br /&gt;
      -- AnimationWML&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
} &lt;br /&gt;
u:add_modification(&amp;quot;object&amp;quot;, effects)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.remove_modifications ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.remove_modifications'''(''unit'', ''filter'', [''type''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''remove_modifications'''(''filter'', [''type''])&lt;br /&gt;
&lt;br /&gt;
Modifies a given unit. The unit needs to be a proxy unit. The second argument is a filter for the modifications to remove. It takes the same syntax as [[FilterWML#Filtering_on_WML_data|[filter_wml]]]; all matching modifications will be removed. The third argument is the type (tag name) of the modifications to search for; it defaults to &amp;quot;object&amp;quot;, but you can also pass &amp;quot;trait&amp;quot; or &amp;quot;advancement&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local u = wesnoth.units.find_on_map{ canrecruit = true }[1]&lt;br /&gt;
u:remove_modifications({ id = &amp;quot;my_effect_id&amp;quot; })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.create_animator ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.create_animator()'''&lt;br /&gt;
&lt;br /&gt;
Returns an object that can be used to set up and run an animation. The object has three methods:&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''run()'''&lt;br /&gt;
&lt;br /&gt;
Runs the animation. Implicitly clears the animator.&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''clear()'''&lt;br /&gt;
&lt;br /&gt;
Clears any units previously added to the animation.&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''add(''unit'', ''flag'', ''hits'', ''params'')'''&lt;br /&gt;
&lt;br /&gt;
Adds a unit to the animation. The ''flag'' specifies which [[AnimationWML#Common_animation_events_used_by_the_engine|animation]] to play, and the ''hits'' parameter is required for attack animations to specify which variant of the animation to play. Possible keys in ''params'' are:&lt;br /&gt;
&lt;br /&gt;
* '''facing''': A location. The animation will be played with the unit facing that location.&lt;br /&gt;
&lt;br /&gt;
facing is currently not implemented/working.  See https://github.com/wesnoth/wesnoth/issues/9032&lt;br /&gt;
&lt;br /&gt;
* '''value''': Either a number or a list of two numbers. Use this to pass ''value'' and/or ''value_second'' to default animations that use them.&lt;br /&gt;
* '''with_bars''': Whether to show HP bars and such while the animation plays.&lt;br /&gt;
* '''text''': Text to float as the animation plays.&lt;br /&gt;
* '''color''': Color of the floating text - a list of red, green, blue.&lt;br /&gt;
* '''primary''': The primary weapon to use for the animation. Must be a Lua unit attack proxy.&lt;br /&gt;
* '''secondary''': The secondary weapon to use for the animation.&lt;br /&gt;
&lt;br /&gt;
Normal usage is to create it, call '''add''' one or more times, then call '''run'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.create'''(''unit_info'') → ''unit''&lt;br /&gt;
&lt;br /&gt;
Creates a private unit from a WML table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local u = wesnoth.units.create{ type = &amp;quot;White Mage&amp;quot;, gender = &amp;quot;female&amp;quot; }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_on_map ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'') → ''array of units''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'', ''fake_location'') → ''array of units''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'', ''other_unit'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns an array of all the units on the map matching the WML filter passed as the first argument. See [[StandardUnitFilter]] for details about filters. If a second unit is passed, it can be referenced via the $other_unit variable in the main filter as well as via the &amp;quot;other&amp;quot; variable in WFL formulas used in the main filter. If a location is passed, the filter is run as if the unit were at that location (rather than its real location). This affects things such as [filter_adjacent] and ability_active, and should work even for a unit on the recall list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local leaders_on_side_two = wesnoth.units.find_on_map{ side = 2, canrecruit = true }&lt;br /&gt;
local name_of_leader = leaders_on_side_two[1].name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_on_recall ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_recall'''(''filter'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns an array of all the units on the recall lists matching the WML filter passed as the first argument.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find'''(''filter'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns a list of all units matching the WML filter, both those on the map and those on the recall lists. It is a shorthand for calling both '''find_on_map''' and '''find_on_recall''' and combining the resulting arrays.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get'''(''x'', ''y'') → ''unit or nil''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get'''(''id'') → ''unit or nil''&lt;br /&gt;
&lt;br /&gt;
Returns the unit at the given location or with the given ID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local args = ...&lt;br /&gt;
local unit = wesnoth.units.get(args.x1, args.y1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.get_hovered ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.get_displayed_unit]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/interface&amp;diff=73910</id>
		<title>LuaAPI/wesnoth/interface</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/interface&amp;diff=73910"/>
		<updated>2024-10-29T14:09:34Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* wesnoth.interface.add_item_image */&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;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
The entire interface module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
== Interface functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.delay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.delay'''(''milliseconds'')&lt;br /&gt;
&lt;br /&gt;
Delays the engine for a period of time, specified in milliseconds.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.delay(500)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.deselect_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.deselect_hex'''()&lt;br /&gt;
&lt;br /&gt;
Reverses any highlight_hex call, leaving all locations unhighlighted. Takes no arguments.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.highlight_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.highlight_hex'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Draws an outline around the specified hex.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.select_unit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.select_unit'''(''x'', ''y'', [''show_movement'', [''fire_events'']])&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.select'''(''unit'', [''show_movement'', [''fire_events'']])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''select'''([''show_movement'', [''fire_events'']])&lt;br /&gt;
&lt;br /&gt;
Selects the given unit in the game map as if the player had clicked on it.&lt;br /&gt;
Argument 3: boolean, whether to show the movement range of any unit on that location (def: true)&lt;br /&gt;
Argument 4: boolean, whether to fire any select events (def: false).&lt;br /&gt;
&lt;br /&gt;
This function is available under two different names, but the possible arguments are the same in both cases. In other words, '''wesnoth.units.select''' can be called with a location instead of a unit, and '''wesnoth.interface.select_unit''' can be called with a unit instead of a location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.select_unit(14, 6, true, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If called without arguments, this function deselects the current unit from the map as long as the mouse cursor is not on its hex. It will continue to be displayed on the UI sidebar in any case.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.float_label ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.float_label'''(''x'', ''y'', ''text'')&lt;br /&gt;
&lt;br /&gt;
Pops some text above a map tile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.float_label(unit.x, unit.y, &amp;quot;&amp;lt;span color='#ff0000'&amp;gt;Ouch&amp;lt;/span&amp;gt;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_displayed_unit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_displayed_unit'''() → ''unit''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get_hovered'''() → ''unit''&lt;br /&gt;
&lt;br /&gt;
Returns a proxy to the unit currently displayed in the side pane of the user interface, if any.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local name = tostring(wesnoth.interface.get_displayed_unit().name)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_hovered_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_hovered_hex'''() → ''x'', ''y''&lt;br /&gt;
&lt;br /&gt;
Returns the two coordinates of the currently hovered tile, that is, where the mouse cursor is located. This is mostly useful for defining command-mode helpers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_selected_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_selected_hex'''() → ''x'', ''y''&lt;br /&gt;
&lt;br /&gt;
Returns the two coordinates of the currently selected (highlighted) tile. This is mostly useful for defining command-mode helpers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function chg_unit(attr, val)&lt;br /&gt;
   local x, y = wesnoth.interface.get_selected_hex()&lt;br /&gt;
   if not x then wesnoth.message(&amp;quot;Error&amp;quot;, &amp;quot;No unit selected.&amp;quot;); return end&lt;br /&gt;
   wesnoth.units.modify({ x = x, y = y }, { [attr] = val })&lt;br /&gt;
end&lt;br /&gt;
-- Function chg_unit can be used in command mode to modify unit attributes on the fly:&lt;br /&gt;
--   :lua chg_unit(&amp;quot;status.poisoned&amp;quot;, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_viewing_side ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_viewing_side'''() &amp;amp;rarr; ''side'', ''full_vision''&lt;br /&gt;
&lt;br /&gt;
Returns the viewing side of the current client in a multiplayer game.&lt;br /&gt;
&lt;br /&gt;
For a player participating in the game, this will always be the side that they control, or, if they control multiple sides, the one they most recently had control over. However, for an observer client, this will return the currently-active side instead.&lt;br /&gt;
&lt;br /&gt;
The second return value indicates whether the current client has full vision. This can only happen in replays or for observers.&lt;br /&gt;
&lt;br /&gt;
For obvious reasons, use of this function can easily cause out-of-sync errors. Use with care.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.lock===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.lock'''(''lock'')&lt;br /&gt;
&lt;br /&gt;
Locks or unlocks gamemap view scrolling for human players. If true is passed as the first parameter, the view is locked; pass false to unlock.&lt;br /&gt;
&lt;br /&gt;
Human players cannot scroll the gamemap view as long as it is locked, but Lua or WML actions such as wesnoth.scroll_to_hex still can; the locked/unlocked state is preserved when saving the current game. 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;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.lock_view(true)&lt;br /&gt;
wesnoth.interface.scroll_to_hex(12, 14, false, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.is_locked ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.is_locked'''() → ''locked?''&lt;br /&gt;
&lt;br /&gt;
Returns a boolean indicating whether gamemap view scrolling is currently locked.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.scroll_to_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.scroll_to_hex'''(''x'', ''y'', [''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.scroll_to'''(''unit'', [''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''scroll_to'''([''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
&lt;br /&gt;
Scrolls the map to the given location. If true is passed as the third parameter, scrolling is disabled if the tile is hidden under the fog. If true is passed as the fourth parameter, the view instantly warps to the location regardless of the scroll speed setting in Preferences. If true is passed as the fifth parameter, no scrolling occurs if the target location is already visible onscreen. It is also possible to pass a unit instead of a pair of tile coordinates (regardless of which module the function is called from).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local u = wesnoth.units.get &amp;quot;hero&amp;quot;&lt;br /&gt;
u:scroll_to()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.scroll ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.scroll'''(''dx'', ''dy'')&lt;br /&gt;
&lt;br /&gt;
Scrolls the map by the given amount, which may be either positive or negative.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.zoom ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.zoom'''(''factor'', [''relative'']) → ''new_zoom''&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map. If relative is false, which is the default, it simply sets the zoom level. If relative is true, it zooms relative to the current zoom level. So, for example, if the zoom level is currently 0.5, then&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(2)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
sets it to 2, while&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(2, true)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
sets it to 1 (2 * 0.5).&lt;br /&gt;
&lt;br /&gt;
This function also returns the resulting zoom level. Because of this, you can call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(1, true)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to simply get the current zoom level.&lt;br /&gt;
&lt;br /&gt;
Note that this function cannot zoom to a level that the user would not be able to reach from the UI. Attempting to do so will simply select the nearest allowed zoom level.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.skip_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.skip_messages'''([''skip?''])&lt;br /&gt;
&lt;br /&gt;
Sets the skip messages flag. By default it sets it to true, but you can also pass false to unset the flag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.is_skipping_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.is_skipping_messages'''()&lt;br /&gt;
&lt;br /&gt;
Returns true if messages are currently being skipped, for example because the player has chosen to skip replay, or has pressed escape to dismiss a message.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_chat_message ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_chat_message'''([''speaker'',] ''message'')&lt;br /&gt;
&lt;br /&gt;
Displays a string in the onscreen chat. The chat line speaker is &amp;quot;Lua&amp;quot; by default, but it can be changed by passing a string before the message.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.add_chat_message &amp;quot;Hello World!&amp;quot; -- will result in &amp;quot;&amp;lt;Lua&amp;gt; Hello World!&amp;quot;&lt;br /&gt;
wesnoth.interface.add_chat_message(&amp;quot;Big Brother&amp;quot;, &amp;quot;I'm watching you.&amp;quot;) -- will result in &amp;quot;&amp;lt;Big Brother&amp;gt; I'm watching you.&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See also [[LuaAPI/wml#wml.error|wml.error]] for displaying error messages.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.clear_chat_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.clear_chat_messages'''()&lt;br /&gt;
&lt;br /&gt;
Removes all messages from the onscreen chat, including error messages.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_item_image ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_item_image'''(''location'', ''filename'')&lt;br /&gt;
&lt;br /&gt;
Places an image at a given location and registers it as a WML ''[item]'' would do, so that it can be restored after save/load. Note that the location must be passed as separate x and y coordinates, as in the example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.add_item_image(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_item_halo ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_item_halo'''(''location'', ''filename'')&lt;br /&gt;
&lt;br /&gt;
Behaves the same as [[#wesnoth.interface.add_item_image]] but for halos.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.remove_item ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.remove_item'''(''location'', [''filename''])&lt;br /&gt;
&lt;br /&gt;
Removes an overlay set by [[#wesnoth.interface.add_item_image]] or [[#wesnoth.interface.add_item_halo]]. If no filename is provided, all the overlays on a given tile are removed. Note that the location must be passed as separate x and y coordinates, as in the example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.remove_item(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_items ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_items'''(''location'') &amp;amp;rarr; ''array of item tables''&lt;br /&gt;
&lt;br /&gt;
Get all items placed on the specified location. Note that the location must be passed as separate x and y coordinates.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_hex_overlay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.add_hex_overlay'''(''location'', ''item_wml'')&lt;br /&gt;
&lt;br /&gt;
Places a hex overlay (either an image or a halo) on the given location. The overlay is described by a table supporting the same fields as [[InterfaceActionsWML|[item]]]. This is a lower-level version of the item functions above. Note that the overlay is not kept over save/load cycles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.add_hex_overlay(17, 42, { image = &amp;quot;items/orcish-flag.png&amp;quot; })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.remove_hex_overlay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.remove_hex_overlay'''(''location'', [''filename''])&lt;br /&gt;
&lt;br /&gt;
Removes all the overlays at the given location, including any added by '''wesnoth.interface.add_item_halo''' or '''wesnoth.interface.add_item_image''' (however, such a removal will not be kept over save/load cycles). If a filename is passed as a third argument, only this overlay (either image or halo) is removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.remove_hex_overlay(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.end_turn ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.end_turn'''([''next_side''])&lt;br /&gt;
&lt;br /&gt;
Immediately ends the current side's turn. By default, the next sequential side will gain control, but if you pass an argument that side gains control instead.&lt;br /&gt;
&lt;br /&gt;
The ''next_side'' can either be a valid side number, or a valid side number plus the total number of sides in the scenario. In the latter case, this function also increases the turn counter by 1.&lt;br /&gt;
&lt;br /&gt;
Using this, it's entirely possible to pass control around without ever increasing the turn counter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.allow_end_turn ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.allow_end_turn'''(''allow'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.allow_end_turn'''(''reason'')&lt;br /&gt;
&lt;br /&gt;
Enables or disables ending the turn in the UI. You can optionally pass a translatable string to show to the player if they attempt to do so anyway. It will be shown to the player without any additional framing, so it should normally be phrased similar to &amp;quot;You cannot end your turn because...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To allow the player to end their turn again, just pass '''true'''. If you pass '''false''', a default message will be shown.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.color_adjust ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.color_adjust'''(''red'', ''green'', ''blue'')&lt;br /&gt;
&lt;br /&gt;
Adjust the screen tint. (0,0,0) is no tint, and possible values range from -255 to 255.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_overlay_text ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|3}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_overlay_text'''(''text'' [, ''options'']) &amp;amp;rarr; ''text handle''&lt;br /&gt;
&lt;br /&gt;
Adds a text overlay to the screen that does not move with the map. [[Pango formatting]] is supported. The ''options'' table supports the following keys:&lt;br /&gt;
&lt;br /&gt;
* ''size'' - The font size.&lt;br /&gt;
* ''max_width'' - Sets the maximum width the text can occupy on the screen, either in screen units (pixels) or as a percentage (a string ending in &amp;lt;tt&amp;gt;%&amp;lt;/tt&amp;gt;). If the text is too long to fit in that width, it will automatically be word-wrapped. Defaults to 100%.&lt;br /&gt;
* ''color'' - The text color, either as a six-digit hex string (no leading &amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) or an array of three integers (red, green, and blue).&lt;br /&gt;
* ''bgcolor'' - If present, a background in this color is placed behind the text to enhance readability. This works like the background behind chat messages, but can be any colour. It is formatted the same as ''color''. If omitted, the background is fully transparent (ie, there is no background).&lt;br /&gt;
* ''bgalpha'' - If a background colour is specified, this sets its transparency. The default is fully opaque.&lt;br /&gt;
* ''duration'' - How long the text should be displayed, in milliseconds, or the string &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'unlimited'&amp;lt;/syntaxhighlight&amp;gt; for an infinite duration. Defaults to two seconds.&lt;br /&gt;
* ''fade_time'' - When the label is removed, either explicitly or because its duration expired, this is the time it takes to fade out, in milliseconds. A value of 0 means the label disappears instantly. Defaults to 100.&lt;br /&gt;
* ''halign'' - Where to anchor the text horizontally on the screen. Must be one of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'left', 'center', 'right'&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
* ''valign'' - Where to anchor the text vertically on the screen. Must be one of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'top', 'center', 'bottom'&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
* ''location'' - The screen offset where the text should be placed, relative to the specified anchor. Defaults to (0,0).&lt;br /&gt;
&lt;br /&gt;
The text handle returned from this function supports the following method calls:&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''move'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Moves the text to a new location on the screen. The provided ''x'' and ''y'' are offsets from its current location.&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''remove'''([''fade_time''])&lt;br /&gt;
&lt;br /&gt;
Remove the text from the screen, optionally overriding the fade-out time.&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''replace'''(''text'', ''options'') &amp;amp;rarr; ''handle''&lt;br /&gt;
&lt;br /&gt;
Replaces the text with new text. Options are the same as in ''add_overlay_text'', and the returned handle is the same one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.handle_user_interact ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.handle_user_interact'''()&lt;br /&gt;
&lt;br /&gt;
Handle user interaction with the game interface. This can be inserted into Lua code that takes a long time to execute in order to prevent the user interface from freezing.&lt;br /&gt;
&lt;br /&gt;
== wesnoth.interface.game_display ==&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.game_display'''.''theme_item'' &amp;amp;harr; '''function'''() &amp;amp;rarr; ''wml table of theme elements''&lt;br /&gt;
&lt;br /&gt;
This is an associative table linking item names to functions that describe the content of the in-game user interface. These functions are called with no arguments whenever the user interface is refreshed, and must return a WML table containing '''[element]''' children. Each subtag shall contain either a '''text''' or an '''image''' field that is displayed to the user. It can also contain a '''tooltip''' field that is displayed to the user when moused over, and a '''help''' field that points to the help section that is displayed when the user clicks on the theme item.&lt;br /&gt;
&lt;br /&gt;
Note that the '''wesnoth.interface.game_display''' cannot be iterated using '''pairs''' or '''next''' to retrieve the items from the current theme. However, built-in items ''can'' be recovered as long as their name is known. The example below shows how to modify the ''unit_status'' item to display a custom status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local old_unit_status = wesnoth.interface.game_display.unit_status&lt;br /&gt;
function wesnoth.interface.game_display.unit_status()&lt;br /&gt;
    local _ = wesnoth.textdomain &amp;quot;mydomain&amp;quot;&lt;br /&gt;
    local u = wesnoth.interface.get_displayed_unit()&lt;br /&gt;
    if not u then return {} end&lt;br /&gt;
    local s = old_unit_status()&lt;br /&gt;
    if u.status.entangled then&lt;br /&gt;
        table.insert(s, wml.tag.element {&lt;br /&gt;
            image = &amp;quot;entangled.png&amp;quot;,&lt;br /&gt;
            tooltip = _&amp;quot;entangled: This unit is entangled. It cannot move but it can still attack.&amp;quot;&lt;br /&gt;
        })&lt;br /&gt;
    end&lt;br /&gt;
    return s&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The things that would need to be to modified in the above code are:&lt;br /&gt;
&lt;br /&gt;
* the domain of your addon (&amp;quot;mydomain&amp;quot;), assuming that you are using translations. Otherwise just remove the underscore in the tooltip line.&lt;br /&gt;
* the name of the status (u.status.entangled). Note that if the attribute happens to be inside [variables], so be it: u.variables.whatever.&lt;br /&gt;
* the path to the image (&amp;quot;entangled.png&amp;quot;).&lt;br /&gt;
* the tooltip of the status (&amp;quot;entangled: This unit ...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
The following is a list of valid entries in '''wesnoth.interface.game_display''' which will have an effect in the game, together with sample output and a brief description of their use.&lt;br /&gt;
&lt;br /&gt;
=== unit_name ===&lt;br /&gt;
&lt;br /&gt;
Shows the name of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_type ===&lt;br /&gt;
&lt;br /&gt;
Shows the type of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_race ===&lt;br /&gt;
&lt;br /&gt;
Shows the race of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_side ===&lt;br /&gt;
&lt;br /&gt;
Shows the side number and team color of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_level ===&lt;br /&gt;
&lt;br /&gt;
Shows the level of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_amla ===&lt;br /&gt;
&lt;br /&gt;
Similar to unit_advancement_options but shows AMLAs only.&lt;br /&gt;
&lt;br /&gt;
=== unit_traits ===&lt;br /&gt;
&lt;br /&gt;
Shows the list of trait names for the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_status ===&lt;br /&gt;
&lt;br /&gt;
Shows the status icons for statuses afflicting the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_alignment ===&lt;br /&gt;
&lt;br /&gt;
Shows the alignment of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_abilities ===&lt;br /&gt;
&lt;br /&gt;
Shows the ability names of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_hp ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum hit points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_xp ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and target experience points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_advancement_options ===&lt;br /&gt;
&lt;br /&gt;
Shows the options the unit the mouse is hovering over has for advancement, including both level ups and AMLAs. This item is not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
=== unit_defense ===&lt;br /&gt;
&lt;br /&gt;
Shows the defense of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_vision ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum vision points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_moves ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum movement points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_weapons ===&lt;br /&gt;
&lt;br /&gt;
Shows the available weapons of the unit the mouse is hovering over. The default generator expresses each weapon line (basic details, specials, etc) as a separate &amp;lt;code&amp;gt;element&amp;lt;/code&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  image=&amp;quot;melee.png&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  image=&amp;quot;arcane.png&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;6×3 holy sword&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  # This is empty if the range and type icons both exist.&lt;br /&gt;
  text=&amp;quot;melee-arcane&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
# If the weapon has accuracy or parry...&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;+20%/-10%&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;Accuracy: +20%&lt;br /&gt;
Parry: -10%&lt;br /&gt;
&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
# If the weapon has special abilities...&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;magical&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== unit_image ===&lt;br /&gt;
&lt;br /&gt;
Shows the sprite of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_profile ===&lt;br /&gt;
&lt;br /&gt;
Shows the portrait of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== selected_unit ===&lt;br /&gt;
&lt;br /&gt;
Nearly every item beginning with '''unit_''' has a corresponding item beginning with '''selected_unit_''', which describes the currently-selected unit (if any) rather than the unit the mouse is hovering over. These items are not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
There is no '''selected_unit_amla''' however.&lt;br /&gt;
&lt;br /&gt;
=== highlighted_unit_weapons ===&lt;br /&gt;
&lt;br /&gt;
This is almost the same as '''selected_unit_weapons''' but with slightly different logic of choosing which unit to show.&lt;br /&gt;
&lt;br /&gt;
=== tod_stats and selected_tod_stats ===&lt;br /&gt;
&lt;br /&gt;
Shows the time of day stats for the hex the mouse is hovering over or the hex the selected unit is on. The time of day stats shows the counter of your position in the schedule as well as the entire cycle.&lt;br /&gt;
&lt;br /&gt;
=== time_of_day and selected_time_of_day ===&lt;br /&gt;
&lt;br /&gt;
Shows the time of day image for the hex the mouse is hovering over or the hex the selected unit is on.&lt;br /&gt;
&lt;br /&gt;
=== unit_box ===&lt;br /&gt;
&lt;br /&gt;
This is an experimental item that combines a unit display and the time of day.&lt;br /&gt;
&lt;br /&gt;
=== turn ===&lt;br /&gt;
&lt;br /&gt;
Shows the current turn count.&lt;br /&gt;
&lt;br /&gt;
=== gold ===&lt;br /&gt;
&lt;br /&gt;
Shows the amount of gold for the active side.&lt;br /&gt;
&lt;br /&gt;
=== villages ===&lt;br /&gt;
&lt;br /&gt;
Shows the number of villages owned by the active side.&lt;br /&gt;
&lt;br /&gt;
=== num_units ===&lt;br /&gt;
&lt;br /&gt;
Shows the number of units owned by the active side.&lt;br /&gt;
&lt;br /&gt;
=== upkeep ===&lt;br /&gt;
&lt;br /&gt;
Shows the upkeep and expenses for the active side.&lt;br /&gt;
&lt;br /&gt;
=== income ===&lt;br /&gt;
&lt;br /&gt;
Shows the income for the active side&lt;br /&gt;
&lt;br /&gt;
=== terrain_info ===&lt;br /&gt;
&lt;br /&gt;
Shows the icons of the terrain on hex the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== terrain &amp;lt;!--and selected_terrain--&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- selected_terrain commented out here because at time of last edit it was commented out in the source code --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shows the name of the terrain on the hex the mouse is hovering over&amp;lt;!-- or the hex the selected unit is on--&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;Grassland (Flat)&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== position ===&lt;br /&gt;
&lt;br /&gt;
Shows the map coordinates of the hex the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== zoom_level ===&lt;br /&gt;
&lt;br /&gt;
Shows the zoom level as a percentage. This item is not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
=== side_playing ===&lt;br /&gt;
&lt;br /&gt;
Shows the active side's flag.&lt;br /&gt;
&lt;br /&gt;
=== observers ===&lt;br /&gt;
&lt;br /&gt;
When there is no observer, it returns an empty table. When there are observers, it returns:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  tooltip=&amp;quot;Observers&lt;br /&gt;
&amp;lt;observer1&amp;gt;&lt;br /&gt;
&amp;lt;observer2&amp;gt;&lt;br /&gt;
&amp;quot;&lt;br /&gt;
  image=&amp;quot;misc/eye.png&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== report_clock ===&lt;br /&gt;
&lt;br /&gt;
This returns the current time in HH:MM format according to the user's preferences, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;22:32&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== report_countdown ===&lt;br /&gt;
&lt;br /&gt;
This returns the current chess-timer countdown in MM:SS format for the player's turn, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;12:43&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on the time limit, the text may also be colored using [[Pango formatting|Pango markup]].&lt;br /&gt;
&lt;br /&gt;
If there is no time limit set then it forwards to [[#wesnoth.interface.game_display.report_clock|report_clock]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/interface&amp;diff=73909</id>
		<title>LuaAPI/wesnoth/interface</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/interface&amp;diff=73909"/>
		<updated>2024-10-29T14:08:54Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* wesnoth.interface.add_item_halo */&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;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
The entire interface module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
== Interface functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.delay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.delay'''(''milliseconds'')&lt;br /&gt;
&lt;br /&gt;
Delays the engine for a period of time, specified in milliseconds.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.delay(500)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.deselect_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.deselect_hex'''()&lt;br /&gt;
&lt;br /&gt;
Reverses any highlight_hex call, leaving all locations unhighlighted. Takes no arguments.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.highlight_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.highlight_hex'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Draws an outline around the specified hex.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.select_unit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.select_unit'''(''x'', ''y'', [''show_movement'', [''fire_events'']])&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.select'''(''unit'', [''show_movement'', [''fire_events'']])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''select'''([''show_movement'', [''fire_events'']])&lt;br /&gt;
&lt;br /&gt;
Selects the given unit in the game map as if the player had clicked on it.&lt;br /&gt;
Argument 3: boolean, whether to show the movement range of any unit on that location (def: true)&lt;br /&gt;
Argument 4: boolean, whether to fire any select events (def: false).&lt;br /&gt;
&lt;br /&gt;
This function is available under two different names, but the possible arguments are the same in both cases. In other words, '''wesnoth.units.select''' can be called with a location instead of a unit, and '''wesnoth.interface.select_unit''' can be called with a unit instead of a location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.select_unit(14, 6, true, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If called without arguments, this function deselects the current unit from the map as long as the mouse cursor is not on its hex. It will continue to be displayed on the UI sidebar in any case.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.float_label ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.float_label'''(''x'', ''y'', ''text'')&lt;br /&gt;
&lt;br /&gt;
Pops some text above a map tile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.float_label(unit.x, unit.y, &amp;quot;&amp;lt;span color='#ff0000'&amp;gt;Ouch&amp;lt;/span&amp;gt;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_displayed_unit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_displayed_unit'''() → ''unit''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get_hovered'''() → ''unit''&lt;br /&gt;
&lt;br /&gt;
Returns a proxy to the unit currently displayed in the side pane of the user interface, if any.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local name = tostring(wesnoth.interface.get_displayed_unit().name)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_hovered_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_hovered_hex'''() → ''x'', ''y''&lt;br /&gt;
&lt;br /&gt;
Returns the two coordinates of the currently hovered tile, that is, where the mouse cursor is located. This is mostly useful for defining command-mode helpers.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_selected_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_selected_hex'''() → ''x'', ''y''&lt;br /&gt;
&lt;br /&gt;
Returns the two coordinates of the currently selected (highlighted) tile. This is mostly useful for defining command-mode helpers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function chg_unit(attr, val)&lt;br /&gt;
   local x, y = wesnoth.interface.get_selected_hex()&lt;br /&gt;
   if not x then wesnoth.message(&amp;quot;Error&amp;quot;, &amp;quot;No unit selected.&amp;quot;); return end&lt;br /&gt;
   wesnoth.units.modify({ x = x, y = y }, { [attr] = val })&lt;br /&gt;
end&lt;br /&gt;
-- Function chg_unit can be used in command mode to modify unit attributes on the fly:&lt;br /&gt;
--   :lua chg_unit(&amp;quot;status.poisoned&amp;quot;, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_viewing_side ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_viewing_side'''() &amp;amp;rarr; ''side'', ''full_vision''&lt;br /&gt;
&lt;br /&gt;
Returns the viewing side of the current client in a multiplayer game.&lt;br /&gt;
&lt;br /&gt;
For a player participating in the game, this will always be the side that they control, or, if they control multiple sides, the one they most recently had control over. However, for an observer client, this will return the currently-active side instead.&lt;br /&gt;
&lt;br /&gt;
The second return value indicates whether the current client has full vision. This can only happen in replays or for observers.&lt;br /&gt;
&lt;br /&gt;
For obvious reasons, use of this function can easily cause out-of-sync errors. Use with care.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.lock===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.lock'''(''lock'')&lt;br /&gt;
&lt;br /&gt;
Locks or unlocks gamemap view scrolling for human players. If true is passed as the first parameter, the view is locked; pass false to unlock.&lt;br /&gt;
&lt;br /&gt;
Human players cannot scroll the gamemap view as long as it is locked, but Lua or WML actions such as wesnoth.scroll_to_hex still can; the locked/unlocked state is preserved when saving the current game. 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;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.lock_view(true)&lt;br /&gt;
wesnoth.interface.scroll_to_hex(12, 14, false, true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.is_locked ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.is_locked'''() → ''locked?''&lt;br /&gt;
&lt;br /&gt;
Returns a boolean indicating whether gamemap view scrolling is currently locked.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.scroll_to_hex ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.scroll_to_hex'''(''x'', ''y'', [''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.scroll_to'''(''unit'', [''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''scroll_to'''([''only_if_visible'', [''instant'', [''only_if_needed'']]])&lt;br /&gt;
&lt;br /&gt;
Scrolls the map to the given location. If true is passed as the third parameter, scrolling is disabled if the tile is hidden under the fog. If true is passed as the fourth parameter, the view instantly warps to the location regardless of the scroll speed setting in Preferences. If true is passed as the fifth parameter, no scrolling occurs if the target location is already visible onscreen. It is also possible to pass a unit instead of a pair of tile coordinates (regardless of which module the function is called from).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local u = wesnoth.units.get &amp;quot;hero&amp;quot;&lt;br /&gt;
u:scroll_to()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.scroll ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.scroll'''(''dx'', ''dy'')&lt;br /&gt;
&lt;br /&gt;
Scrolls the map by the given amount, which may be either positive or negative.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.zoom ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.zoom'''(''factor'', [''relative'']) → ''new_zoom''&lt;br /&gt;
&lt;br /&gt;
Changes the zoom level of the map. If relative is false, which is the default, it simply sets the zoom level. If relative is true, it zooms relative to the current zoom level. So, for example, if the zoom level is currently 0.5, then&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(2)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
sets it to 2, while&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(2, true)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
sets it to 1 (2 * 0.5).&lt;br /&gt;
&lt;br /&gt;
This function also returns the resulting zoom level. Because of this, you can call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua inline&amp;gt;wesnoth.zoom(1, true)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to simply get the current zoom level.&lt;br /&gt;
&lt;br /&gt;
Note that this function cannot zoom to a level that the user would not be able to reach from the UI. Attempting to do so will simply select the nearest allowed zoom level.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.skip_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.skip_messages'''([''skip?''])&lt;br /&gt;
&lt;br /&gt;
Sets the skip messages flag. By default it sets it to true, but you can also pass false to unset the flag.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.is_skipping_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.is_skipping_messages'''()&lt;br /&gt;
&lt;br /&gt;
Returns true if messages are currently being skipped, for example because the player has chosen to skip replay, or has pressed escape to dismiss a message.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_chat_message ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_chat_message'''([''speaker'',] ''message'')&lt;br /&gt;
&lt;br /&gt;
Displays a string in the onscreen chat. The chat line speaker is &amp;quot;Lua&amp;quot; by default, but it can be changed by passing a string before the message.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.add_chat_message &amp;quot;Hello World!&amp;quot; -- will result in &amp;quot;&amp;lt;Lua&amp;gt; Hello World!&amp;quot;&lt;br /&gt;
wesnoth.interface.add_chat_message(&amp;quot;Big Brother&amp;quot;, &amp;quot;I'm watching you.&amp;quot;) -- will result in &amp;quot;&amp;lt;Big Brother&amp;gt; I'm watching you.&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See also [[LuaAPI/wml#wml.error|wml.error]] for displaying error messages.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.clear_chat_messages ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.clear_chat_messages'''()&lt;br /&gt;
&lt;br /&gt;
Removes all messages from the onscreen chat, including error messages.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_item_image ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.place_item_image'''(''location'', ''filename'')&lt;br /&gt;
&lt;br /&gt;
Places an image at a given location and registers it as a WML ''[item]'' would do, so that it can be restored after save/load. Note that the location must be passed as separate x and y coordinates, as in the example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.place_item_image(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_item_halo ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_item_halo'''(''location'', ''filename'')&lt;br /&gt;
&lt;br /&gt;
Behaves the same as [[#wesnoth.interface.add_item_image]] but for halos.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.remove_item ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.remove_item'''(''location'', [''filename''])&lt;br /&gt;
&lt;br /&gt;
Removes an overlay set by [[#wesnoth.interface.add_item_image]] or [[#wesnoth.interface.add_item_halo]]. If no filename is provided, all the overlays on a given tile are removed. Note that the location must be passed as separate x and y coordinates, as in the example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.remove_item(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.get_items ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.get_items'''(''location'') &amp;amp;rarr; ''array of item tables''&lt;br /&gt;
&lt;br /&gt;
Get all items placed on the specified location. Note that the location must be passed as separate x and y coordinates.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_hex_overlay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.add_hex_overlay'''(''location'', ''item_wml'')&lt;br /&gt;
&lt;br /&gt;
Places a hex overlay (either an image or a halo) on the given location. The overlay is described by a table supporting the same fields as [[InterfaceActionsWML|[item]]]. This is a lower-level version of the item functions above. Note that the overlay is not kept over save/load cycles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.add_hex_overlay(17, 42, { image = &amp;quot;items/orcish-flag.png&amp;quot; })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.remove_hex_overlay ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.remove_hex_overlay'''(''location'', [''filename''])&lt;br /&gt;
&lt;br /&gt;
Removes all the overlays at the given location, including any added by '''wesnoth.interface.add_item_halo''' or '''wesnoth.interface.add_item_image''' (however, such a removal will not be kept over save/load cycles). If a filename is passed as a third argument, only this overlay (either image or halo) is removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
wesnoth.interface.remove_hex_overlay(17, 42, &amp;quot;items/orcish-flag.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.end_turn ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.end_turn'''([''next_side''])&lt;br /&gt;
&lt;br /&gt;
Immediately ends the current side's turn. By default, the next sequential side will gain control, but if you pass an argument that side gains control instead.&lt;br /&gt;
&lt;br /&gt;
The ''next_side'' can either be a valid side number, or a valid side number plus the total number of sides in the scenario. In the latter case, this function also increases the turn counter by 1.&lt;br /&gt;
&lt;br /&gt;
Using this, it's entirely possible to pass control around without ever increasing the turn counter.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.allow_end_turn ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.allow_end_turn'''(''allow'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.allow_end_turn'''(''reason'')&lt;br /&gt;
&lt;br /&gt;
Enables or disables ending the turn in the UI. You can optionally pass a translatable string to show to the player if they attempt to do so anyway. It will be shown to the player without any additional framing, so it should normally be phrased similar to &amp;quot;You cannot end your turn because...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To allow the player to end their turn again, just pass '''true'''. If you pass '''false''', a default message will be shown.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.color_adjust ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.color_adjust'''(''red'', ''green'', ''blue'')&lt;br /&gt;
&lt;br /&gt;
Adjust the screen tint. (0,0,0) is no tint, and possible values range from -255 to 255.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.add_overlay_text ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|3}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.add_overlay_text'''(''text'' [, ''options'']) &amp;amp;rarr; ''text handle''&lt;br /&gt;
&lt;br /&gt;
Adds a text overlay to the screen that does not move with the map. [[Pango formatting]] is supported. The ''options'' table supports the following keys:&lt;br /&gt;
&lt;br /&gt;
* ''size'' - The font size.&lt;br /&gt;
* ''max_width'' - Sets the maximum width the text can occupy on the screen, either in screen units (pixels) or as a percentage (a string ending in &amp;lt;tt&amp;gt;%&amp;lt;/tt&amp;gt;). If the text is too long to fit in that width, it will automatically be word-wrapped. Defaults to 100%.&lt;br /&gt;
* ''color'' - The text color, either as a six-digit hex string (no leading &amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) or an array of three integers (red, green, and blue).&lt;br /&gt;
* ''bgcolor'' - If present, a background in this color is placed behind the text to enhance readability. This works like the background behind chat messages, but can be any colour. It is formatted the same as ''color''. If omitted, the background is fully transparent (ie, there is no background).&lt;br /&gt;
* ''bgalpha'' - If a background colour is specified, this sets its transparency. The default is fully opaque.&lt;br /&gt;
* ''duration'' - How long the text should be displayed, in milliseconds, or the string &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'unlimited'&amp;lt;/syntaxhighlight&amp;gt; for an infinite duration. Defaults to two seconds.&lt;br /&gt;
* ''fade_time'' - When the label is removed, either explicitly or because its duration expired, this is the time it takes to fade out, in milliseconds. A value of 0 means the label disappears instantly. Defaults to 100.&lt;br /&gt;
* ''halign'' - Where to anchor the text horizontally on the screen. Must be one of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'left', 'center', 'right'&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
* ''valign'' - Where to anchor the text vertically on the screen. Must be one of &amp;lt;syntaxhighlight lang=lua inline&amp;gt;'top', 'center', 'bottom'&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
* ''location'' - The screen offset where the text should be placed, relative to the specified anchor. Defaults to (0,0).&lt;br /&gt;
&lt;br /&gt;
The text handle returned from this function supports the following method calls:&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''move'''(''x'', ''y'')&lt;br /&gt;
&lt;br /&gt;
Moves the text to a new location on the screen. The provided ''x'' and ''y'' are offsets from its current location.&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''remove'''([''fade_time''])&lt;br /&gt;
&lt;br /&gt;
Remove the text from the screen, optionally overriding the fade-out time.&lt;br /&gt;
&lt;br /&gt;
* ''handle'':'''replace'''(''text'', ''options'') &amp;amp;rarr; ''handle''&lt;br /&gt;
&lt;br /&gt;
Replaces the text with new text. Options are the same as in ''add_overlay_text'', and the returned handle is the same one.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.interface.handle_user_interact ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|6}}&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.handle_user_interact'''()&lt;br /&gt;
&lt;br /&gt;
Handle user interaction with the game interface. This can be inserted into Lua code that takes a long time to execute in order to prevent the user interface from freezing.&lt;br /&gt;
&lt;br /&gt;
== wesnoth.interface.game_display ==&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.interface.game_display'''.''theme_item'' &amp;amp;harr; '''function'''() &amp;amp;rarr; ''wml table of theme elements''&lt;br /&gt;
&lt;br /&gt;
This is an associative table linking item names to functions that describe the content of the in-game user interface. These functions are called with no arguments whenever the user interface is refreshed, and must return a WML table containing '''[element]''' children. Each subtag shall contain either a '''text''' or an '''image''' field that is displayed to the user. It can also contain a '''tooltip''' field that is displayed to the user when moused over, and a '''help''' field that points to the help section that is displayed when the user clicks on the theme item.&lt;br /&gt;
&lt;br /&gt;
Note that the '''wesnoth.interface.game_display''' cannot be iterated using '''pairs''' or '''next''' to retrieve the items from the current theme. However, built-in items ''can'' be recovered as long as their name is known. The example below shows how to modify the ''unit_status'' item to display a custom status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
local old_unit_status = wesnoth.interface.game_display.unit_status&lt;br /&gt;
function wesnoth.interface.game_display.unit_status()&lt;br /&gt;
    local _ = wesnoth.textdomain &amp;quot;mydomain&amp;quot;&lt;br /&gt;
    local u = wesnoth.interface.get_displayed_unit()&lt;br /&gt;
    if not u then return {} end&lt;br /&gt;
    local s = old_unit_status()&lt;br /&gt;
    if u.status.entangled then&lt;br /&gt;
        table.insert(s, wml.tag.element {&lt;br /&gt;
            image = &amp;quot;entangled.png&amp;quot;,&lt;br /&gt;
            tooltip = _&amp;quot;entangled: This unit is entangled. It cannot move but it can still attack.&amp;quot;&lt;br /&gt;
        })&lt;br /&gt;
    end&lt;br /&gt;
    return s&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The things that would need to be to modified in the above code are:&lt;br /&gt;
&lt;br /&gt;
* the domain of your addon (&amp;quot;mydomain&amp;quot;), assuming that you are using translations. Otherwise just remove the underscore in the tooltip line.&lt;br /&gt;
* the name of the status (u.status.entangled). Note that if the attribute happens to be inside [variables], so be it: u.variables.whatever.&lt;br /&gt;
* the path to the image (&amp;quot;entangled.png&amp;quot;).&lt;br /&gt;
* the tooltip of the status (&amp;quot;entangled: This unit ...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
The following is a list of valid entries in '''wesnoth.interface.game_display''' which will have an effect in the game, together with sample output and a brief description of their use.&lt;br /&gt;
&lt;br /&gt;
=== unit_name ===&lt;br /&gt;
&lt;br /&gt;
Shows the name of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_type ===&lt;br /&gt;
&lt;br /&gt;
Shows the type of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_race ===&lt;br /&gt;
&lt;br /&gt;
Shows the race of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_side ===&lt;br /&gt;
&lt;br /&gt;
Shows the side number and team color of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_level ===&lt;br /&gt;
&lt;br /&gt;
Shows the level of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_amla ===&lt;br /&gt;
&lt;br /&gt;
Similar to unit_advancement_options but shows AMLAs only.&lt;br /&gt;
&lt;br /&gt;
=== unit_traits ===&lt;br /&gt;
&lt;br /&gt;
Shows the list of trait names for the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_status ===&lt;br /&gt;
&lt;br /&gt;
Shows the status icons for statuses afflicting the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_alignment ===&lt;br /&gt;
&lt;br /&gt;
Shows the alignment of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_abilities ===&lt;br /&gt;
&lt;br /&gt;
Shows the ability names of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_hp ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum hit points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_xp ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and target experience points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_advancement_options ===&lt;br /&gt;
&lt;br /&gt;
Shows the options the unit the mouse is hovering over has for advancement, including both level ups and AMLAs. This item is not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
=== unit_defense ===&lt;br /&gt;
&lt;br /&gt;
Shows the defense of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_vision ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum vision points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_moves ===&lt;br /&gt;
&lt;br /&gt;
Shows the current and maximum movement points of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_weapons ===&lt;br /&gt;
&lt;br /&gt;
Shows the available weapons of the unit the mouse is hovering over. The default generator expresses each weapon line (basic details, specials, etc) as a separate &amp;lt;code&amp;gt;element&amp;lt;/code&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  image=&amp;quot;melee.png&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  image=&amp;quot;arcane.png&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;6×3 holy sword&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
[element]&lt;br /&gt;
  # This is empty if the range and type icons both exist.&lt;br /&gt;
  text=&amp;quot;melee-arcane&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
# If the weapon has accuracy or parry...&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;+20%/-10%&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;Accuracy: +20%&lt;br /&gt;
Parry: -10%&lt;br /&gt;
&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
# If the weapon has special abilities...&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;magical&amp;quot;&lt;br /&gt;
  tooltip=&amp;quot;...stuff...&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== unit_image ===&lt;br /&gt;
&lt;br /&gt;
Shows the sprite of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== unit_profile ===&lt;br /&gt;
&lt;br /&gt;
Shows the portrait of the unit the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== selected_unit ===&lt;br /&gt;
&lt;br /&gt;
Nearly every item beginning with '''unit_''' has a corresponding item beginning with '''selected_unit_''', which describes the currently-selected unit (if any) rather than the unit the mouse is hovering over. These items are not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
There is no '''selected_unit_amla''' however.&lt;br /&gt;
&lt;br /&gt;
=== highlighted_unit_weapons ===&lt;br /&gt;
&lt;br /&gt;
This is almost the same as '''selected_unit_weapons''' but with slightly different logic of choosing which unit to show.&lt;br /&gt;
&lt;br /&gt;
=== tod_stats and selected_tod_stats ===&lt;br /&gt;
&lt;br /&gt;
Shows the time of day stats for the hex the mouse is hovering over or the hex the selected unit is on. The time of day stats shows the counter of your position in the schedule as well as the entire cycle.&lt;br /&gt;
&lt;br /&gt;
=== time_of_day and selected_time_of_day ===&lt;br /&gt;
&lt;br /&gt;
Shows the time of day image for the hex the mouse is hovering over or the hex the selected unit is on.&lt;br /&gt;
&lt;br /&gt;
=== unit_box ===&lt;br /&gt;
&lt;br /&gt;
This is an experimental item that combines a unit display and the time of day.&lt;br /&gt;
&lt;br /&gt;
=== turn ===&lt;br /&gt;
&lt;br /&gt;
Shows the current turn count.&lt;br /&gt;
&lt;br /&gt;
=== gold ===&lt;br /&gt;
&lt;br /&gt;
Shows the amount of gold for the active side.&lt;br /&gt;
&lt;br /&gt;
=== villages ===&lt;br /&gt;
&lt;br /&gt;
Shows the number of villages owned by the active side.&lt;br /&gt;
&lt;br /&gt;
=== num_units ===&lt;br /&gt;
&lt;br /&gt;
Shows the number of units owned by the active side.&lt;br /&gt;
&lt;br /&gt;
=== upkeep ===&lt;br /&gt;
&lt;br /&gt;
Shows the upkeep and expenses for the active side.&lt;br /&gt;
&lt;br /&gt;
=== income ===&lt;br /&gt;
&lt;br /&gt;
Shows the income for the active side&lt;br /&gt;
&lt;br /&gt;
=== terrain_info ===&lt;br /&gt;
&lt;br /&gt;
Shows the icons of the terrain on hex the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== terrain &amp;lt;!--and selected_terrain--&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- selected_terrain commented out here because at time of last edit it was commented out in the source code --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shows the name of the terrain on the hex the mouse is hovering over&amp;lt;!-- or the hex the selected unit is on--&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;Grassland (Flat)&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== position ===&lt;br /&gt;
&lt;br /&gt;
Shows the map coordinates of the hex the mouse is hovering over.&lt;br /&gt;
&lt;br /&gt;
=== zoom_level ===&lt;br /&gt;
&lt;br /&gt;
Shows the zoom level as a percentage. This item is not used in the default theme.&lt;br /&gt;
&lt;br /&gt;
=== side_playing ===&lt;br /&gt;
&lt;br /&gt;
Shows the active side's flag.&lt;br /&gt;
&lt;br /&gt;
=== observers ===&lt;br /&gt;
&lt;br /&gt;
When there is no observer, it returns an empty table. When there are observers, it returns:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  tooltip=&amp;quot;Observers&lt;br /&gt;
&amp;lt;observer1&amp;gt;&lt;br /&gt;
&amp;lt;observer2&amp;gt;&lt;br /&gt;
&amp;quot;&lt;br /&gt;
  image=&amp;quot;misc/eye.png&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== report_clock ===&lt;br /&gt;
&lt;br /&gt;
This returns the current time in HH:MM format according to the user's preferences, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;22:32&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== report_countdown ===&lt;br /&gt;
&lt;br /&gt;
This returns the current chess-timer countdown in MM:SS format for the player's turn, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[element]&lt;br /&gt;
  text=&amp;quot;12:43&amp;quot;&lt;br /&gt;
[/element]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on the time limit, the text may also be colored using [[Pango formatting|Pango markup]].&lt;br /&gt;
&lt;br /&gt;
If there is no time limit set then it forwards to [[#wesnoth.interface.game_display.report_clock|report_clock]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73576</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73576"/>
		<updated>2024-08-27T11:39:56Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Attacks */&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;
&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73575</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73575"/>
		<updated>2024-08-27T11:39:21Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Attacks */&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;
&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73574</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=73574"/>
		<updated>2024-08-27T11:38:53Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* Attacks */&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;
&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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Template:Lua_Functions&amp;diff=73403</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=73403"/>
		<updated>2024-08-08T06:37:50Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: &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.units.resistance_against|wesnoth.units.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>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/units&amp;diff=73402</id>
		<title>LuaAPI/wesnoth/units</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/wesnoth/units&amp;diff=73402"/>
		<updated>2024-08-07T18:00:42Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: &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;
{{DevFeature1.15|0}}&lt;br /&gt;
&lt;br /&gt;
The entire units module is only available in the game. It is not available to plugins or map generators.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.advance ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.advance'''(''unit'', [''animate'', ''fire_events''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''advance'''([''animate'', ''fire_events''])&lt;br /&gt;
&lt;br /&gt;
Advances the unit (and shows the advance unit dialog if needed) if the unit has enough XP. This function should be called after modifying the unit's experience directly. A similar function is called by Wesnoth internally after unit combat. The second argument is a boolean value that specifies whether the advancement should be animated. The third argument is a boolean value that specifies whether advancement related events should be fired.&lt;br /&gt;
&lt;br /&gt;
This function only works for units on the map.&lt;br /&gt;
&lt;br /&gt;
This function can also trigger multiple advancements if the unit has enough XP.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.clone ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.clone'''(''unit'') → ''copy of unit''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''clone'''()&lt;br /&gt;
&lt;br /&gt;
Creates a private unit from another unit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- extract a unit from the map&lt;br /&gt;
local u = wesnoth.units.find_on_map{ type = &amp;quot;Thug&amp;quot; }[1]:clone()&lt;br /&gt;
wesnoth.units.erase(u.x, u.y) -- note: not the same as u:erase(), which would be an error&lt;br /&gt;
-- u is still valid at this point&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.erase ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.erase'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.erase'''(''x'', ''y'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''erase'''()&lt;br /&gt;
&lt;br /&gt;
Erases a unit from the map. After calling this on a unit, the unit is no longer valid. Does not work on private units - this usage will raise an error.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.extract ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.extract'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''extract'''()&lt;br /&gt;
&lt;br /&gt;
Removes a unit from the map or from a recall list and makes it private.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- remove all the units from the recall list of side 1 and put them in a WML container&lt;br /&gt;
local list = {}&lt;br /&gt;
for i,u in ipairs(wesnoth.units.find_on_recall{ side = 1 }) do&lt;br /&gt;
    u:extract()&lt;br /&gt;
    table.insert(list, u.__cfg)&lt;br /&gt;
end&lt;br /&gt;
wml.array_access.set(&amp;quot;player_recall_list&amp;quot;, list)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: if the unit is on the map, this is just a shortcut for calling [[#wesnoth.units.clone]] and then [[#wesnoth.units.erase]]. It is, however, the only way to remove a unit from a recall list without putting it on the map.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.matches ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.matches'''(''unit'', ''filter'', [''other_unit'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.matches'''(''unit'', ''filter'', [''location'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''matches'''(''filter'', [''other_unit'']) → ''matched?''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''matches'''(''filter'', [''location'']) → ''matched?''&lt;br /&gt;
&lt;br /&gt;
Returns true if the given unit matches the WML filter passed as the second argument. If ''other_unit'' is specified, it is used for the ''$other_unit'' auto-stored variable in the filter. Otherwise, this variable is not stored for the filter. If an extra ''location'' is specified, the filter matches as if the unit were at that location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
assert(unit.canrecruit == wesnoth.units.matches(unit, { canrecruit = true }))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_attack ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_attack'''(''unit'', ''filter'') &amp;amp;rarr; ''attack''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''find_attack'''(''filter'') &amp;amp;rarr; ''attack''&lt;br /&gt;
&lt;br /&gt;
Returns the first attack that matches the given [[StandardWeaponFilter]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.to_map ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_map'''(''unit'')&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_map'''(''unit'', ''x'', ''y'')&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''to_map'''([''x'', ''y''])&lt;br /&gt;
&lt;br /&gt;
Places a unit on the map. This unit is described either by a WML table or by a proxy unit (to use the third form, it must be a proxy). Coordinates can be passed as additional arguments; otherwise the table is expected to have two fields '''x''' and '''y''', which indicate where the unit will be placed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- create a unit with random traits, then erase it&lt;br /&gt;
wesnoth.units.to_map({ type = &amp;quot;Elvish Lady&amp;quot; }, 17, 42)&lt;br /&gt;
wesnoth.units.erase(17, 42)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the argument is a proxy unit, no duplicate is created. In particular, if the unit was private or on a recall list, it no longer is; and if the unit was on the map, it has been moved to the new location. Note: passing a WML table is just a shortcut for calling [[#wesnoth.units.create]] and then putting the resulting unit on the map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- move the leader back to the top-left corner&lt;br /&gt;
wesnoth.units.find_on_map({ canrecruit = true })[1]:to_map(1, 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If x,y is a village, this function does not capture it (as of 1.14). Use [[LuaWML/Sides#wesnoth.set_village_owner|wesnoth.set_village_owner(x, y, unit.side)]] if that's what you want.&lt;br /&gt;
&lt;br /&gt;
'''Caution:''' Using this function will trigger unit placed events. While this may be correct in most cases, there are some cases where it shouldn't, especially if the code is inside the definition of a custom WML tag — it would be an unexpected side-effect from the users point. To work around this, ''false'' can be passed additionally as the last argument. This is what is used internally for some tags such as [move_unit], [harm_unit], [unpetrify] or the feeding ability and is not officially part of the API.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.to_recall ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.to_recall'''(''unit'', [''side''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''to_recall'''([''side''])&lt;br /&gt;
&lt;br /&gt;
Places a unit on a recall list. This unit is described either by a WML table or by a proxy unit (to use the third form, it must be a proxy). The side of the recall list is given by the second argument if present, or by the side of the unit otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
-- put the unit at location 17,42 on the recall list for side 2&lt;br /&gt;
wesnoth.units.find_on_map{ x= 17, y = 42 })[1]:to_recall(2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the argument is a proxy unit, no duplicate is created. In particular, if the unit was private or on the map, it no longer is. Note: passing a WML table is just a shortcut for calling [[#wesnoth.units.create]] and then putting the resulting unit on a recall list.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.transform ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.transform'''(''unit'', ''to_type'', [''to_variation''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''transform'''(''to_type'', [''to_variation''])&lt;br /&gt;
&lt;br /&gt;
Changes the type of a unit and adjust attributes accordingly. Note that hit points are only changed if necessary to accommodate the new maximum hit points. Poison is automatically removed if the transformed unit is immune.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local ev = wesnoth.current.event_context&lt;br /&gt;
local u = wesnoth.units.find_on_map{x=ev.x1, y=ev.y1}[1]&lt;br /&gt;
u:transform(&amp;quot;Spearman&amp;quot;)&lt;br /&gt;
-- If a full heal is desired:&lt;br /&gt;
u.hitpoints = u.max_hitpoints&lt;br /&gt;
u.status.poisoned = false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.select ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.select_unit]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.scroll_to ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.scroll_to_hex]].&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.ability ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.ability'''(''unit'', ''ability_tag'') → ''affected''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''ability'''(''ability_tag'') → ''affected''&lt;br /&gt;
&lt;br /&gt;
Returns true if the unit is currently affected by an ability with this given tag name. This means that the ability could be owned by the unit itself, or by an adjacent unit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
function has_teleport(u)&lt;br /&gt;
    return u:ability(&amp;quot;teleport&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.chance_to_be_hit ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.chance_to_be_hit'''(''unit'', ''terrain_code'') → ''hit chance''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''chance_to_be_hit'''(''terrain_code'') → ''hit chance''&lt;br /&gt;
&lt;br /&gt;
Returns the chance that a unit will be hit on a particular terrain (based on its defence).&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.defense_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.defense_on'''(''unit'', ''terrain_code'') → ''defense value''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''defense_on'''(''terrain_code'') → ''defense value''&lt;br /&gt;
&lt;br /&gt;
Returns the defense of a unit on a particular terrain. (Note: it is the actual defense. So the lower it is, the weaker the unit is.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local flat_defense = u:defense_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.resistance_against ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.resistance_against'''(''unit'', ''damage_type'', [''as_attacker''], [''x'', ''y'']) → ''resistance value''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''resistance_against'''(''damage_type'', [''as_attacker''], [''x'', ''y'']) → ''resistance value''&lt;br /&gt;
&lt;br /&gt;
Returns the resistance of a unit against an attack type. (Note: it is the actual resistance. So the lower it is, the weaker the unit is.) The third argument indicates whether the unit is the attacker. Last arguments are the coordinates of an optional map location (for the purpose of taking abilities into account).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local fire_resistance = u:resistance_against(&amp;quot;fire&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.jamming_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.jamming_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''jamming_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the jamming cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local jam_cost = u:jamming_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.movement_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.movement_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''movement_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the movement cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local move_cost = u:movement_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.vision_on ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.vision_on'''(''unit'', ''terrain_code'') → ''cost''&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''vision_on'''(''terrain_code'') → ''cost''&lt;br /&gt;
&lt;br /&gt;
Returns the vision cost of a unit on a particular terrain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local see_cost = u:vision_on(&amp;quot;Gt&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.add_modification ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.add_modification'''(''unit'', ''type'', ''effects'', [''write_to_mods''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''add_modification'''(''type'', ''effects'', [''write_to_mods''])&lt;br /&gt;
&lt;br /&gt;
Modifies a given unit. It needs to be a proxy unit. The second argument is the type of the modification (one of &amp;quot;trait&amp;quot;, &amp;quot;object&amp;quot;, or &amp;quot;advancement&amp;quot;). The option &amp;quot;advancement&amp;quot; applies effects as if the unit would advance (e.g. AMLA effects). The third argument is a WML table describing the effect, so mostly containing '''[effect]''' children. See [[EffectWML]] for details about effects. If ''write_to_mods'' false, causes it to not write the modification tag to the unit's [modifications] (as would be done with an [object] with no_write=true).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local T = wml.tag&lt;br /&gt;
local u = wesnoth.units.find_on_map{ canrecruit = true }[1]&lt;br /&gt;
local effects = {&lt;br /&gt;
  id = &amp;quot;my_effect_id&amp;quot;,&lt;br /&gt;
  T.effect { &lt;br /&gt;
    apply_to = &amp;quot;image_mod&amp;quot;, &lt;br /&gt;
    replace = &amp;quot;RC(red&amp;gt;blue)&amp;quot; &lt;br /&gt;
  },&lt;br /&gt;
  T.effect {&lt;br /&gt;
    apply_to = &amp;quot;new_animation&amp;quot;,&lt;br /&gt;
    T.standing_animation {&lt;br /&gt;
      -- AnimationWML&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
} &lt;br /&gt;
u:add_modification(&amp;quot;object&amp;quot;, effects)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.remove_modifications ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.remove_modifications'''(''unit'', ''filter'', [''type''])&lt;br /&gt;
* {{LuaGameOnly}} ''unit'':'''remove_modifications'''(''filter'', [''type''])&lt;br /&gt;
&lt;br /&gt;
Modifies a given unit. The unit needs to be a proxy unit. The second argument is a filter for the modifications to remove. It takes the same syntax as [[FilterWML#Filtering_on_WML_data|[filter_wml]]]; all matching modifications will be removed. The third argument is the type (tag name) of the modifications to search for; it defaults to &amp;quot;object&amp;quot;, but you can also pass &amp;quot;trait&amp;quot; or &amp;quot;advancement&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local u = wesnoth.units.find_on_map{ canrecruit = true }[1]&lt;br /&gt;
u:remove_modifications({ id = &amp;quot;my_effect_id&amp;quot; })&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.create_animator ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.create_animator()'''&lt;br /&gt;
&lt;br /&gt;
Returns an object that can be used to set up and run an animation. The object has three methods:&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''run()'''&lt;br /&gt;
&lt;br /&gt;
Runs the animation. Implicitly clears the animator.&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''clear()'''&lt;br /&gt;
&lt;br /&gt;
Clears any units previously added to the animation.&lt;br /&gt;
&lt;br /&gt;
* ''animator'':'''add(''unit'', ''flag'', ''hits'', ''params'')'''&lt;br /&gt;
&lt;br /&gt;
Adds a unit to the animation. The ''flag'' specifies which [[AnimationWML#Common_animation_events_used_by_the_engine|animation]] to play, and the ''hits'' parameter is required for attack animations to specify which variant of the animation to play. Possible keys in ''params'' are:&lt;br /&gt;
&lt;br /&gt;
* '''facing''': A location. The animation will be played with the unit facing that location.&lt;br /&gt;
&lt;br /&gt;
facing is currently not implemented/working.  See https://github.com/wesnoth/wesnoth/issues/9032&lt;br /&gt;
&lt;br /&gt;
* '''value''': Either a number or a list of two numbers. Use this to pass ''value'' and/or ''value_second'' to default animations that use them.&lt;br /&gt;
* '''with_bars''': Whether to show HP bars and such while the animation plays.&lt;br /&gt;
* '''text''': Text to float as the animation plays.&lt;br /&gt;
* '''color''': Color of the floating text - a list of red, green, blue.&lt;br /&gt;
* '''primary''': The primary weapon to use for the animation. Must be a Lua unit attack proxy.&lt;br /&gt;
* '''secondary''': The secondary weapon to use for the animation.&lt;br /&gt;
&lt;br /&gt;
Normal usage is to create it, call '''add''' one or more times, then call '''run'''.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.create ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.create'''(''unit_info'') → ''unit''&lt;br /&gt;
&lt;br /&gt;
Creates a private unit from a WML table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local u = wesnoth.units.create{ type = &amp;quot;White Mage&amp;quot;, gender = &amp;quot;female&amp;quot; }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_on_map ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'') → ''array of units''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'', ''fake_location'') → ''array of units''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_map'''(''filter'', ''other_unit'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns an array of all the units on the map matching the WML filter passed as the first argument. See [[StandardUnitFilter]] for details about filters. If a second unit is passed, it can be referenced via the $other_unit variable in the main filter as well as via the &amp;quot;other&amp;quot; variable in WFL formulas used in the main filter. If a location is passed, the filter is run as if the unit were at that location (rather than its real location). This affects things such as [filter_adjacent] and ability_active, and should work even for a unit on the recall list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local leaders_on_side_two = wesnoth.units.find_on_map{ side = 2, canrecruit = true }&lt;br /&gt;
local name_of_leader = leaders_on_side_two[1].name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find_on_recall ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find_on_recall'''(''filter'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns an array of all the units on the recall lists matching the WML filter passed as the first argument.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.find ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.find'''(''filter'') → ''array of units''&lt;br /&gt;
&lt;br /&gt;
Returns a list of all units matching the WML filter, both those on the map and those on the recall lists. It is a shorthand for calling both '''find_on_map''' and '''find_on_recall''' and combining the resulting arrays.&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.get ===&lt;br /&gt;
&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get'''(''x'', ''y'') → ''unit or nil''&lt;br /&gt;
* {{LuaGameOnly}} '''wesnoth.units.get'''(''id'') → ''unit or nil''&lt;br /&gt;
&lt;br /&gt;
Returns the unit at the given location or with the given ID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
local args = ...&lt;br /&gt;
local unit = wesnoth.units.get(args.x1, args.y1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== wesnoth.units.get_hovered ===&lt;br /&gt;
&lt;br /&gt;
Alias of [[LuaAPI/wesnoth/interface#wesnoth.interface.get_displayed_unit]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Sandbox&amp;diff=73341</id>
		<title>Sandbox</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Sandbox&amp;diff=73341"/>
		<updated>2024-07-29T05:29:26Z</updated>

		<summary type="html">&lt;p&gt;ZombieKnight: /* [awesometag] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Do not remove --&amp;gt;&lt;br /&gt;
The sandbox is for editing and formatting experiments. If you are already logged in, click on the &amp;quot;Edit&amp;quot; link above to experiment yourself!&lt;br /&gt;
[[Category:Wesnoth Wiki]]&lt;br /&gt;
&amp;lt;!--Edit below this line --&amp;gt;&lt;br /&gt;
== Widget definition ==&lt;br /&gt;
&lt;br /&gt;
This page describes the definition of all widgets in the toolkit. Every&lt;br /&gt;
widget has some parts in common, first of all; every definition has the&lt;br /&gt;
following fields.&lt;br /&gt;
&lt;br /&gt;
=== Label ===&lt;br /&gt;
&lt;br /&gt;
A label displays a text, the text can be wrapped but no scrollbars are provided.&lt;br /&gt;
&lt;br /&gt;
Although the label itself has no event interaction it still has two states.&lt;br /&gt;
The reason is that labels are often used as visual indication of the state&lt;br /&gt;
of the widget it labels.&lt;br /&gt;
&lt;br /&gt;
Note: The above is outdated, if &amp;quot;link_aware&amp;quot; is enabled then there is interaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following states exist:&lt;br /&gt;
* state_enabled, the label is enabled.&lt;br /&gt;
* state_disabled, the label is disabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| link_aware&lt;br /&gt;
| [[GUIVariable#f_bool|f_bool]]&lt;br /&gt;
| false&lt;br /&gt;
| Whether the label is link aware. This means it is rendered with links highlighted, and responds to click events on those links.&lt;br /&gt;
|-&lt;br /&gt;
| link_color&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| #ffff00&lt;br /&gt;
| The color to render links with. This string will be used verbatim in pango markup for each link.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
== Widget instance ==&lt;br /&gt;
&lt;br /&gt;
Inside a grid (which is inside all container widgets) a widget is&lt;br /&gt;
instantiated. With this instantiation some more variables of a widget can&lt;br /&gt;
be tuned. This page will describe what can be tuned.&lt;br /&gt;
&lt;br /&gt;
=== Label ===&lt;br /&gt;
&lt;br /&gt;
A label displays a text, the text can be wrapped but no scrollbars are provided.&lt;br /&gt;
&lt;br /&gt;
List with the label specific variables:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| wrap&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| false&lt;br /&gt;
| Is wrapping enabled for the label.&lt;br /&gt;
|-&lt;br /&gt;
| characters_per_line&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| Sets the maximum number of characters per line. The amount is an approximate since the width of a character differs. E.g. iii is smaller than MMM. When the value is non-zero it also implies can_wrap is true. When having long strings wrapping them can increase readability, often 66 characters per line is considered the optimum for a one column text. text_alignment &amp;amp; h_align &amp;amp; &amp;quot;left&amp;quot; &amp;amp; How is the text aligned in the label.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
== [awesometag] ==&lt;br /&gt;
The '''[awesometag]''' is used to do awesome things.&lt;br /&gt;
&lt;br /&gt;
* '''awesomekey''': A place to put an awesome value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
Awesome example:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
[awesometag]&lt;br /&gt;
   awesomekey=awesomevalue&lt;br /&gt;
   [fire_event]&lt;br /&gt;
      name=awesome_event&lt;br /&gt;
   [/fire_event]&lt;br /&gt;
[/awesometag]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
Comment by '''Dreadnough''': They have a great core with versatile Spearman and fast Cavalry. Depending on the situation they can add highly specialised units such as Heavy Infantry, Mages, Meremen and Horseman. Finally their fencers can slip through enemy ranks and enable breakthroughs or disrupt the enemy's movement. As a lawful faction, they depend very much on the time of day, which results in dynamic unit movement.&lt;br /&gt;
&lt;br /&gt;
Comment by '''ForestDragon''': Rebels. Well, female elves are certainly quite attractive. For example, the marksman line.&lt;br /&gt;
&lt;br /&gt;
Comment by '''Elven''': Northerners have simple strategy. Kill weak units, poison and kill strong units. You can have a lot of units, make some a level 2 units and never retreat, never surrender!&lt;br /&gt;
&lt;br /&gt;
Comment by '''patience_reloaded''': Undead due to their reliability when used correctly: Ghosts are very hard for most normal units (especially melee ones) to kill quick, most of the faction is poison-resistant, and due to having fixed traits, you know exactly what you get when you recruit them.&lt;br /&gt;
&lt;br /&gt;
Comment by '''Hsaelt''': Knalgans i like because they can take punishment and deliver punishment. Good HP, good damage outputs on units like gryphons and those guys with firearms. No real weaknesses in res good defence on hills mountains and those are commonplace&lt;br /&gt;
&lt;br /&gt;
Comment by '''Knightmare''': (Plays Drakes) Fire and Blood.&lt;br /&gt;
&lt;br /&gt;
Comment by '''Computer_player''': I love dunefolk because they bring something different to the table and out of the factions closest to being mainlined, they are the one with the most work done. I really like the dynamic of the Dunefolk (Khalifate long ago) faction, however I am waiting to play Dunefolk proper with the next stable version.&lt;br /&gt;
&lt;br /&gt;
Comment by '''egallager''': Check out the [[ReferenceWML]] page. [[User:Egallager|Egallager]] ([[User talk:Egallager|talk]]) 03:34, 8 May 2023 (UTC)&lt;br /&gt;
&lt;br /&gt;
Comment by '''ZombieKnight''': Personally I like Saurians: Great sand and swamp defense in combination with three most useful specials in the game (skirmisher, heals +8 and magical) and both physical and magical attack you got all you'll ever need.&lt;br /&gt;
&lt;br /&gt;
(1.18 they got four new friends into the team ;) )&lt;/div&gt;</summary>
		<author><name>ZombieKnight</name></author>
		
	</entry>
</feed>