<?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=Bssarkar</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=Bssarkar"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Bssarkar"/>
	<updated>2026-04-26T13:27:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=GrammarWML&amp;diff=75000</id>
		<title>GrammarWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GrammarWML&amp;diff=75000"/>
		<updated>2026-04-25T13:12:13Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Help Markup */ typofix: XMl -&amp;gt; XML&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
This page contains a formal grammar of the Wesnoth domain-specific languages, including WML and its preprocessor. It does not attempt to capture any of the ways that the Wesnoth engine may interpret a string, such as WML variable substitution. It also doesn't fully capture the potential consequences of macros, for example the use of unbalanced WML tags. The syntax used is [https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form Extended Backus-Naur form]:&lt;br /&gt;
&lt;br /&gt;
* Every rule is of the form &amp;lt;tt&amp;gt;nonterminal = rule ;&amp;lt;/tt&amp;gt; with a terminating semicolon.&lt;br /&gt;
* Comments are enclosed in &amp;lt;tt&amp;gt;(* these *)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Literal values are enclosed in either double or single quotes. There is no special syntax inside quotes.&lt;br /&gt;
* &amp;lt;tt&amp;gt;(...)&amp;lt;/tt&amp;gt; can be used for grouping.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N * A&amp;lt;/tt&amp;gt; where N is a number means &amp;quot;exactly N instances of A&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[A]&amp;lt;/tt&amp;gt; means &amp;quot;zero or one instances of A&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;{A}&amp;lt;/tt&amp;gt; means &amp;quot;zero or more instances of A&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;A , B&amp;lt;/tt&amp;gt; means &amp;quot;A followed by B&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;A | B&amp;lt;/tt&amp;gt; means &amp;quot;either A or B&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;A - B&amp;lt;/tt&amp;gt; means &amp;quot;A but not B&amp;quot;.]&lt;br /&gt;
* Some special values are enclosed in &amp;lt;tt&amp;gt;?...?&amp;lt;/tt&amp;gt;. This document uses the following special values:&lt;br /&gt;
** &amp;lt;tt&amp;gt;?newline?&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;?tab?&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;?space?&amp;lt;/tt&amp;gt; represent the named non-printable characters.&lt;br /&gt;
** &amp;lt;tt&amp;gt;?unicode?&amp;lt;/tt&amp;gt; represents any valid Unicode character.&lt;br /&gt;
** &amp;lt;tt&amp;gt;?digit?&amp;lt;/tt&amp;gt; represents any decimal digit.&lt;br /&gt;
** &amp;lt;tt&amp;gt;?hexdigit?&amp;lt;/tt&amp;gt; represents any hexadecimal digit.&lt;br /&gt;
** &amp;lt;tt&amp;gt;?letter?&amp;lt;/tt&amp;gt; represents any ASCII Latin letter in either uppercase or lowercase.&lt;br /&gt;
&lt;br /&gt;
== WML Preprocessor ==&lt;br /&gt;
&lt;br /&gt;
The WML preprocessor knows little of the grammar of the WML language itself; it is primarily just a text-substitution engine. Currently this is just a draft and may not be entirely accurate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
preproc_doc = {preproc_directive | preproc_line} ;&lt;br /&gt;
preproc_directive = simple_directive | macro_definition | if_block ;&lt;br /&gt;
preproc_line = {preproc_text} , ['&amp;lt;'] , [comment] , ?newline? ;&lt;br /&gt;
preproc_text = preproc_char | '&amp;lt;' , preproc_char | '&amp;lt;&amp;lt;' , macro_free_text , '&amp;gt;&amp;gt;' | macro_inclusion ;&lt;br /&gt;
preproc_char = char - ('&amp;lt;' | '{' | '#' | ?newline?) ;&lt;br /&gt;
macro_free_text = {macro_free_char | '&amp;gt;' , macro_free_char} ;&lt;br /&gt;
macro_free_char = char - '&amp;gt;' ; (* Note: this can include newlines! *)&lt;br /&gt;
macro_inclusion = '{' , macro_name , {req_ws , macro_argument} , '}' ;&lt;br /&gt;
macro_name = macro_name_char , {macro_name_char}&lt;br /&gt;
macro_name_char = char - ('}' | ws) ;&lt;br /&gt;
macro_argument = macro_component , {macro_component}&lt;br /&gt;
macro_component = macro_name&lt;br /&gt;
                | macro_inclusion&lt;br /&gt;
                | '(' , [preproc_doc] , ')'&lt;br /&gt;
                | ['_'] , opt_ws , '&amp;quot;' , {quoted_char | macro_inclusion} , '&amp;quot;'&lt;br /&gt;
                | '&amp;lt;&amp;lt;' , macro_free_text , '&amp;gt;&amp;gt;'&lt;br /&gt;
                ;&lt;br /&gt;
quoted_char = char - ( '}' | '&amp;quot;' ) | '&amp;quot;&amp;quot;' ;&lt;br /&gt;
comment = opt_ws , '#' , {comment_char} , ?newline? ;&lt;br /&gt;
comment_char = char - ?newline? ;&lt;br /&gt;
ws = ?space? | ?tab?&lt;br /&gt;
opt_ws = {ws}&lt;br /&gt;
req_ws = ws , {ws}&lt;br /&gt;
simple_directive = '#undef' , req_ws , macro_name , opt_ws , ?newline?&lt;br /&gt;
                 | ('#warning' | '#error') req_ws , {comment_char} , ?newline? ;&lt;br /&gt;
macro_definition = '#define' , req_ws , macro_name , {req_ws macro_name} , ?newline? , {opt_arg_definition} , {macro_content} , '#enddef' , ?newline? ;&lt;br /&gt;
macro_content = simple_directive | if_block | preproc_line ;&lt;br /&gt;
opt_arg_definition = '#arg' , req_ws , macro_name , ?newline? , {macro_content} , '#endarg' , ?newline? ;&lt;br /&gt;
if_block = (ifdef_header | ifver_header | ifhave_header) , ?newline? , preproc_doc ['#else' , ?newline? , preproc_doc] '#endif' , ?newline? ;&lt;br /&gt;
ifdef_header = ('#ifdef' | '#ifndef') , req_ws , macro_name ;&lt;br /&gt;
ifver_header = ('#ifver' | '#ifnver') , req_ws , macro_name , opt_ws , comparison_op , opt_ws , version_string ;&lt;br /&gt;
ifhave_header = ('#ifhave' | '#ifnhave') , req_ws , comment_char ;&lt;br /&gt;
comparison_op = '&amp;lt;' | '&amp;lt;=' | '==' | '!=' | '&amp;gt;=' | '&amp;gt;' ;&lt;br /&gt;
version_string = integer , ['.' , integer] ;&lt;br /&gt;
integer = ?digit? , {?digit?} ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WML ==&lt;br /&gt;
&lt;br /&gt;
This grammar describes WML '''after''' the preprocessor is finished with it, and as such does not account for macros, preprocessor directives, or comments. It also assumes tokenization has already occurred and thus does not specify whitespace, except for newlines. Note that it omits the requirement for opening and closing tags to match.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
wml_doc = {wml_tag | wml_attribute} ;&lt;br /&gt;
wml_tag = '[' , ['+'] , wml_name , ']' , wml_doc , '[/' , wml_name , ']' ;&lt;br /&gt;
wml_name = wml_id_char , {wml_id_char} ;&lt;br /&gt;
wml_attribute = [textdomain] , wml_key_sequence , '=' , wml_value , ?newline? ;&lt;br /&gt;
wml_key_sequence = wml_name , {',' , wml_name} ;&lt;br /&gt;
wml_value = wml_value_component , {'+' , [?newline? , [textdomain]] , wml_value_component} ;&lt;br /&gt;
wml_value_component = text | ['_'] , (string | raw_string) ;&lt;br /&gt;
text = {?unicode? - '+' | '&amp;quot;' | ?newline?} ;&lt;br /&gt;
string = '&amp;quot;' . {?unicode? - '&amp;quot;' | '&amp;quot;&amp;quot;'} , '&amp;quot;' ;&lt;br /&gt;
raw_string = '&amp;lt;&amp;lt;' , {?unicode? - '&amp;gt;' | '&amp;gt;' , ?unicode? - '&amp;gt;'} , '&amp;gt;&amp;gt;' ;&lt;br /&gt;
textdomain = '#textdomain' domain_char , {domain_char} , ?newline? ;&lt;br /&gt;
wml_id_char = ?letter? | ?digit? | '_' ;&lt;br /&gt;
domain_char = wml_id_char | '-' ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WML Substitutions ==&lt;br /&gt;
&lt;br /&gt;
This grammar describes the syntax of WML substitutions, the syntax used to specify that variables should be substituted into the value of a WML attribute. The grammar here describes a single placeholder, without regard to the fact that they can be nested. Thus, parsing a string using this grammar would only succeed if done from right to left ''while'' performing the substitutions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
wml_substitution = wml_var | wml_formula | '$|' ;&lt;br /&gt;
wml_var = '$' , wml_var_path , [wml_var_default | '|'] ;&lt;br /&gt;
wml_var_path = {wml_var_name , [wml_var_index] , '.'} , wml_var_name ;&lt;br /&gt;
wml_var_name = wml_id_char, {wml_id_char} ; (* wml_id_char is defined in the WML grammar, above *)&lt;br /&gt;
wml_var_index = '[' , ?digit? , {?digit?} , ']' ;&lt;br /&gt;
wml_var_default = '?' , default_char, {default_char} , '|' ;&lt;br /&gt;
default_char = ?unicode? - '|' ;&lt;br /&gt;
wml_formula = '$' , '(' , wfl_document , ')' ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Context-free Grammars ==&lt;br /&gt;
&lt;br /&gt;
This grammar describes the syntax of a [[Context-free grammar]] used for random text generation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
grammar = production , {production} ;&lt;br /&gt;
production = symbol , '=' , alternative , {'|' , alternative} , ?newline? ;&lt;br /&gt;
symbol = symbol_char , {symbol_char} ;&lt;br /&gt;
symbol_char = ?letter? | ?digit? | '_' ; (* Unsure on this, need to check it *)&lt;br /&gt;
alternative = {terminal} ;&lt;br /&gt;
terminal = '{' , symbol , '}' | '{!}' | '{(}' | '{)}' | (?unicode? - '}') ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Formula Language ==&lt;br /&gt;
&lt;br /&gt;
This grammar describes the syntax of the [[Wesnoth Formula Language]]. Though it specifies the format of comments and file markers, they are not integrated into the main grammar since it treats the equivalently to whitespace. The grammar may not be completely accurate to the actual in-game parser.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
wfl_comment = '#' , {wfl_comment_char} , '#' ;&lt;br /&gt;
wfl_comment_char = ?unicode? - '#' ;&lt;br /&gt;
wfl_file_run = 'wfl' , wfl_string , wfl_file_content , 'wflend' ;&lt;br /&gt;
wfl_file_content = {?any token? - 'wflend'} ;&lt;br /&gt;
wfl_document = {wfl_function_definition} , wfl_formula ;&lt;br /&gt;
wfl_function_definition = 'def' , wfl_name , '(' , [wfl_function_args] , ')' , wfl_formula , ';' ;&lt;br /&gt;
wfl_function_args = wfl_function_arg , {',' , wfl_function_arg} ;&lt;br /&gt;
wfl_function_arg = wfl_name , ['*'] ;&lt;br /&gt;
wfl_formula = ['not'] , where_expression | bracketed_expression ;&lt;br /&gt;
bracketed_expression = '(' , wfl_formula , ')' ;&lt;br /&gt;
where_expression = (boolean_or_expression | bracketed_expression) , {'where' , wfl_variables} ;&lt;br /&gt;
wfl_variables = wfl_variable , {',' , wfl_variable} ;&lt;br /&gt;
wfl_variable = wfl_name , '=' , wfl_formula ;&lt;br /&gt;
boolean_or_expression = (boolean_and_expression | bracketed_expression) , {'or' , wfl_formula} ;&lt;br /&gt;
boolean_and_expression = (comparison_expression | bracketed_expression) , {'and' , wfl_formula} ;&lt;br /&gt;
comparison_expression = (containment_expression | bracketed_expression) , {comparison_op , wfl_formula} ;&lt;br /&gt;
comparison_op = '=' | '!=' | '&amp;lt;' | '&amp;gt;' | '&amp;lt;=' | '&amp;gt;=' ;&lt;br /&gt;
containment_expression = (range_expression | bracketed_expression) , {'in' , wfl_formula} ;&lt;br /&gt;
range_expression = (additive_expression | bracketed_expression) , {'~' , wfl_formula} ;&lt;br /&gt;
additive_expression = [negation_op] , (multiplicative_expression | bracketed_expression) , {additive_op , wfl_formula} ;&lt;br /&gt;
negation_op = '-' | '+' ;&lt;br /&gt;
additive_op = '-' | '+' | '..' ;&lt;br /&gt;
multiplicative_expression := (exponent_expression | bracketed_expression) , {multiplicative_op , wfl_formula} ;&lt;br /&gt;
muliplicative_op = '*' | '/' | '%' ;&lt;br /&gt;
exponent_expression = {wfl_formula , '^'} , (dice_expression | bracketed_expression) ;&lt;br /&gt;
dice_expression = (dot_expression | bracketed_expression) , {'d' , wfl_formula} ;&lt;br /&gt;
dot_expression = (wfl_value | bracketed_expression) , {'.' , wfl_formula} ;&lt;br /&gt;
wfl_value = 'functions' | wfl_name | wfl_number | wfl_string | wfl_container | wfl_function_call ;&lt;br /&gt;
wfl_name = wfl_id_char , {wfl_id_char} ;&lt;br /&gt;
wfl_id_char = ?letter? | '_' ; (* Note: digits are NOT allowed! *)&lt;br /&gt;
wfl_number = ?digit? , {?digit?} , ['.' , ?digit? , {?digit?}] ;&lt;br /&gt;
wfl_string = &amp;quot;'&amp;quot; , {wfl_string_char | wfl_string_subst | wfl_string_escape} , &amp;quot;'&amp;quot; ;&lt;br /&gt;
wfl_string_char = ?unicode? - (&amp;quot;'&amp;quot; | &amp;quot;[&amp;quot;) ;&lt;br /&gt;
wfl_string_subst = '[' , wfl_formula , ']' ;&lt;br /&gt;
wfl_string_escape = &amp;quot;[']&amp;quot; | '[(]' | '[)]' ;&lt;br /&gt;
wfl_container = '[' , ['-&amp;gt;' | wfl_expression_list | wfl_key_value_list] , ']' ;&lt;br /&gt;
wfl_expression_list = wfl_formula , {',' , wfl_formula} ;&lt;br /&gt;
wfl_key_value_list = wml_key_value , {',' , wml_key_value} ;&lt;br /&gt;
wml_key_value = wfl_formula , '-&amp;gt;' , wfl_formula ;&lt;br /&gt;
wfl_function_call = wfl_name , '(' , [wfl_expression_list] , ')' ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Help Markup ==&lt;br /&gt;
&lt;br /&gt;
This grammar defines the [[help markup]] used in Wesnoth help topics and GUI2 rich labels. It's ''almost'' HTML and ''almost'' XML but not quite either.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
document = {text | tag} ;&lt;br /&gt;
text = {literal | entity | escape} ;&lt;br /&gt;
literal = ?unicode? - ('&amp;lt;' , '&amp;amp;' , '\') ;&lt;br /&gt;
escape = '\' , ?unicode? ;&lt;br /&gt;
entity = '&amp;amp;#' , ?digit? , {?digit?} , ';'&lt;br /&gt;
       | '&amp;amp;#x' , ?hexdigit? , {?hexdigit?} , ';'&lt;br /&gt;
       | '&amp;amp;' , name , ';'&lt;br /&gt;
       ;&lt;br /&gt;
tag = '&amp;lt;' , name , {attribute} , '/' '&amp;gt;' (* Self-closing tag, XML-style *)&lt;br /&gt;
    | '&amp;lt;' , name , {attribute} , '&amp;gt;' , document , '&amp;lt;/' , name , '&amp;gt;' (* HTML-style tag, nestable *)&lt;br /&gt;
    | '&amp;lt;' , name , '&amp;gt;' , {attribute} , [text] , '&amp;lt;/' , name , '&amp;gt;' (* Old-style tag, not nestable *)&lt;br /&gt;
    ;&lt;br /&gt;
attribute = name , ['=' , attribute_value] ;&lt;br /&gt;
attribute_value = {?unicode? - (&amp;quot;'&amp;quot; | '&amp;quot;' | ?space?)} (* Unquoted value *)&lt;br /&gt;
                | &amp;quot;'&amp;quot; , text - &amp;quot;'&amp;quot; , &amp;quot;'&amp;quot;&lt;br /&gt;
                | '&amp;quot;' , text - '&amp;quot;' , '&amp;quot;'&lt;br /&gt;
                ;&lt;br /&gt;
name = name_char , {name_char} ;&lt;br /&gt;
name_char = ?letter? | ?digit? | '_'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive Values ==&lt;br /&gt;
&lt;br /&gt;
This grammar describes progressive strings and numbers used by animation frames.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=ebnf&amp;gt;&lt;br /&gt;
range_integer = digits , ['~' , digits] , [timing] ;&lt;br /&gt;
progressive_integer = range_integer , {',' , range_integer} ;&lt;br /&gt;
&lt;br /&gt;
range_real = digits , ['.' , digits] , ['~' , digits , [',' , digits]] , [timing] ;&lt;br /&gt;
progressive_real = range_real , {',' , range_real} ;&lt;br /&gt;
&lt;br /&gt;
range_string = {literal | expansion_list} , [timing | ':' , expansion_list] ;&lt;br /&gt;
progressive_string = range_string , {',' , range_string} ;&lt;br /&gt;
literal = ?unicode? - ('[' | ',' | ':') ; (* Colon actually might be permitted, not sure *)&lt;br /&gt;
expansion_list = '[' , expansion , {',' , expansion} , ']' ;&lt;br /&gt;
expansion = range_integer | digits , '*' , digits ;&lt;br /&gt;
&lt;br /&gt;
digits = digit , {digit} ;&lt;br /&gt;
timing = ':' , digits ;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74970</id>
		<title>CompatibilityBreakingChanges</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74970"/>
		<updated>2026-04-13T11:36:24Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* 1.19.22 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This lists removed WML functionality and helpful hints for avoiding pitfalls.&lt;br /&gt;
&lt;br /&gt;
The previous list is available [https://forums.wesnoth.org/viewtopic.php?t=58532 here].&lt;br /&gt;
&lt;br /&gt;
== Compatibility breaking changes between 1.18 and 1.19/1.20 ==&lt;br /&gt;
* The following macros were removed ([https://github.com/wesnoth/wesnoth/pull/11126 #11126])&lt;br /&gt;
** EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
** NO_EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
** NO_GOLD_CARRYOVER_NOTE&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_100&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_40&lt;br /&gt;
** NEW_GOLD_CARRYOVER_NOTE_20&lt;br /&gt;
** MISSILE_FRAME_FIREBALL&lt;br /&gt;
** MESSAGE&lt;br /&gt;
** STORY_PART_SPEECH&lt;br /&gt;
** LOYAL_UNDEAD_UNIT&lt;br /&gt;
** ON_SIGHTING&lt;br /&gt;
** MAKE_AI_SIDE_PERSISTENT&lt;br /&gt;
** DRAKE_FLYING_ANIM&lt;br /&gt;
** NO_INTERRUPT_NO_UNDO&lt;br /&gt;
** ENABLE_NIGHTBLADE&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74969</id>
		<title>CompatibilityBreakingChanges</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74969"/>
		<updated>2026-04-13T11:21:09Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Removed (#11126) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== 1.19.22 ==&lt;br /&gt;
=== Removed macros ===&lt;br /&gt;
==== Removed ([https://github.com/wesnoth/wesnoth/pull/11126 #11126]) ====&lt;br /&gt;
* EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
* NO_EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
* NO_GOLD_CARRYOVER_NOTE&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_100&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_40&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_20&lt;br /&gt;
* MISSILE_FRAME_FIREBALL&lt;br /&gt;
* MESSAGE&lt;br /&gt;
* STORY_PART_SPEECH&lt;br /&gt;
* LOYAL_UNDEAD_UNIT&lt;br /&gt;
* ON_SIGHTING&lt;br /&gt;
* MAKE_AI_SIDE_PERSISTENT&lt;br /&gt;
* DRAKE_FLYING_ANIM&lt;br /&gt;
* NO_INTERRUPT_NO_UNDO&lt;br /&gt;
* ENABLE_NIGHTBLADE&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74968</id>
		<title>CompatibilityBreakingChanges</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74968"/>
		<updated>2026-04-13T11:20:40Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Removed in #11126 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== 1.19.22 ==&lt;br /&gt;
=== Removed macros ===&lt;br /&gt;
==== Removed (#11126) ====&lt;br /&gt;
* EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
* NO_EARLY_FINISH_BONUS_NOTE&lt;br /&gt;
* NO_GOLD_CARRYOVER_NOTE&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_100&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_40&lt;br /&gt;
* NEW_GOLD_CARRYOVER_NOTE_20&lt;br /&gt;
* MISSILE_FRAME_FIREBALL&lt;br /&gt;
* MESSAGE&lt;br /&gt;
* STORY_PART_SPEECH&lt;br /&gt;
* LOYAL_UNDEAD_UNIT&lt;br /&gt;
* ON_SIGHTING&lt;br /&gt;
* MAKE_AI_SIDE_PERSISTENT&lt;br /&gt;
* DRAKE_FLYING_ANIM&lt;br /&gt;
* NO_INTERRUPT_NO_UNDO&lt;br /&gt;
* ENABLE_NIGHTBLADE&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74967</id>
		<title>CompatibilityBreakingChanges</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=CompatibilityBreakingChanges&amp;diff=74967"/>
		<updated>2026-04-13T11:19:05Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: List removed macros in #11126&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== 1.19.22 ==&lt;br /&gt;
=== Removed macros ===&lt;br /&gt;
==== Removed in #11126 ====&lt;br /&gt;
* `EARLY_FINISH_BONUS_NOTE`&lt;br /&gt;
* `NO_EARLY_FINISH_BONUS_NOTE`&lt;br /&gt;
* `NO_GOLD_CARRYOVER_NOTE`&lt;br /&gt;
* `NEW_GOLD_CARRYOVER_NOTE_100`&lt;br /&gt;
* `NEW_GOLD_CARRYOVER_NOTE_40`&lt;br /&gt;
* `NEW_GOLD_CARRYOVER_NOTE_20`&lt;br /&gt;
* `MISSILE_FRAME_FIREBALL`&lt;br /&gt;
* `MESSAGE`&lt;br /&gt;
* `STORY_PART_SPEECH`&lt;br /&gt;
* `LOYAL_UNDEAD_UNIT`&lt;br /&gt;
* `ON_SIGHTING`&lt;br /&gt;
* `MAKE_AI_SIDE_PERSISTENT`&lt;br /&gt;
* `DRAKE_FLYING_ANIM`&lt;br /&gt;
* `NO_INTERRUPT_NO_UNDO`&lt;br /&gt;
* `ENABLE_NIGHTBLADE`&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Bssarkar&amp;diff=74965</id>
		<title>User:Bssarkar</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Bssarkar&amp;diff=74965"/>
		<updated>2026-04-11T11:42:46Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: draft deprecation policy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Revised Deprecation Policy ==&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
* Keep the codebase clean and maintainable.&lt;br /&gt;
* Provide clear expectations for UMC authors.&lt;br /&gt;
* Ensure deprecation messages remain credible by tying them to actual removal.&lt;br /&gt;
&lt;br /&gt;
== Deprecation Lifecycle ==&lt;br /&gt;
=== Marking Deprecated ===&lt;br /&gt;
* When an API or feature is obsolete, mark it deprecated immediately.&lt;br /&gt;
* Deprecation message must include: version deprecated, recommended replacement, and planned removal version.&lt;br /&gt;
&lt;br /&gt;
=== Minimum Deprecation Period ===&lt;br /&gt;
* Deprecated features remain for one stable release cycle.&lt;br /&gt;
* During this period, warnings are shown with migration guidance.&lt;br /&gt;
&lt;br /&gt;
=== Sunset Clause ===&lt;br /&gt;
* After one stable release, the feature is scheduled for removal in the next release.&lt;br /&gt;
* No indefinite wrappers. “Deprecated” always means “will be removed.”&lt;br /&gt;
&lt;br /&gt;
=== Removal ===&lt;br /&gt;
* Features are removed as scheduled, even if some UMCs still rely on them.&lt;br /&gt;
* Routine cleanup is a valid reason for removal — no need to wait for a blocking obstacle.&lt;br /&gt;
&lt;br /&gt;
== Support for UMC Authors ==&lt;br /&gt;
* '''Migration Tools:''' wmllint/wmlscope must be updated to suggest or apply fixes automatically.&lt;br /&gt;
* '''Documentation:''' Wiki entries must clearly list deprecated features, replacements, and removal timelines.&lt;br /&gt;
* '''Major Versions:''' For large‑scale removals, major version bumps (e.g., 2.0) provide a clean slate.&lt;br /&gt;
&lt;br /&gt;
== Enforcement ==&lt;br /&gt;
* Deprecation without removal is not allowed.&lt;br /&gt;
* Consensus is required to '''delay''' removal, not to perform it.&lt;br /&gt;
* Developers are empowered to perform routine cleanup without prolonged debate.&lt;br /&gt;
&lt;br /&gt;
== Refuting Common Objections ==&lt;br /&gt;
* '''“Deprecation messages are helpful.”'''  &lt;br /&gt;
** True, but only if they are credible. If removal never happens, the message is misleading.  &lt;br /&gt;
** Warnings that never resolve train UMC authors to ignore them, undermining trust in tools.  &lt;br /&gt;
** Messages stay helpful only when backed by action: clear timelines and actual removal.&lt;br /&gt;
&lt;br /&gt;
* '''“Wrappers are harmless.”'''  &lt;br /&gt;
** Wrappers accumulate and clutter the codebase, making it harder to maintain.  &lt;br /&gt;
** They give a false sense of safety while delaying modernization.  &lt;br /&gt;
** Routine cleanup prevents technical debt from piling up.&lt;br /&gt;
&lt;br /&gt;
* '''“UMC authors need stability.”'''  &lt;br /&gt;
** Stability comes from predictability, not indefinite legacy.  &lt;br /&gt;
** Clear removal timelines and migration tools give authors confidence.  &lt;br /&gt;
** Indefinite deprecation leaves authors in limbo, forcing piecemeal porting anyway.&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This policy makes deprecation meaningful. UMC authors get clear timelines and migration guidance, while developers can keep the codebase lean. Wrappers and indefinite deprecation are eliminated, ensuring that “deprecated” is a real lifecycle stage rather than a cosmetic label.&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Bssarkar&amp;diff=74964</id>
		<title>User:Bssarkar</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Bssarkar&amp;diff=74964"/>
		<updated>2026-04-11T11:38:04Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: new deprecation policy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Revised Deprecation Policy =&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
* Keep the codebase clean and maintainable.&lt;br /&gt;
* Provide clear expectations for UMC authors.&lt;br /&gt;
* Ensure deprecation messages remain credible by tying them to actual removal.&lt;br /&gt;
&lt;br /&gt;
== Deprecation Lifecycle ==&lt;br /&gt;
# '''Marking Deprecated'''&lt;br /&gt;
   * When an API or feature is obsolete, mark it deprecated immediately.&lt;br /&gt;
   * Deprecation message must include: version deprecated, recommended replacement, and planned removal version.&lt;br /&gt;
&lt;br /&gt;
# '''Minimum Deprecation Period'''&lt;br /&gt;
   * Deprecated features remain for one stable release cycle.&lt;br /&gt;
   * During this period, warnings are shown with migration guidance.&lt;br /&gt;
&lt;br /&gt;
# '''Sunset Clause'''&lt;br /&gt;
   * After one stable release, the feature is scheduled for removal in the next release.&lt;br /&gt;
   * No indefinite wrappers. “Deprecated” always means “will be removed.”&lt;br /&gt;
&lt;br /&gt;
# '''Removal'''&lt;br /&gt;
   * Features are removed as scheduled, even if some UMCs still rely on them.&lt;br /&gt;
   * Routine cleanup is a valid reason for removal — no need to wait for a blocking obstacle.&lt;br /&gt;
&lt;br /&gt;
== Support for UMC Authors ==&lt;br /&gt;
* '''Migration Tools:''' wmllint/wmlscope must be updated to suggest or apply fixes automatically.&lt;br /&gt;
* '''Documentation:''' Wiki entries must clearly list deprecated features, replacements, and removal timelines.&lt;br /&gt;
* '''Major Versions:''' For large‑scale removals, major version bumps (e.g., 2.0) provide a clean slate.&lt;br /&gt;
&lt;br /&gt;
== Enforcement ==&lt;br /&gt;
* Deprecation without removal is not allowed.&lt;br /&gt;
* Consensus is required to '''delay''' removal, not to perform it.&lt;br /&gt;
* Developers are empowered to perform routine cleanup without prolonged debate.&lt;br /&gt;
&lt;br /&gt;
== Refuting Common Objections ==&lt;br /&gt;
* '''“Deprecation messages are helpful.”'''  &lt;br /&gt;
  – True, but only if they are credible. If removal never happens, the message is misleading.  &lt;br /&gt;
  – Warnings that never resolve train UMC authors to ignore them, undermining trust in tools.  &lt;br /&gt;
  – Messages stay helpful only when backed by action: clear timelines and actual removal.&lt;br /&gt;
&lt;br /&gt;
* '''“Wrappers are harmless.”'''  &lt;br /&gt;
  – Wrappers accumulate and clutter the codebase, making it harder to maintain.  &lt;br /&gt;
  – They give a false sense of safety while delaying modernization.  &lt;br /&gt;
  – Routine cleanup prevents technical debt from piling up.&lt;br /&gt;
&lt;br /&gt;
* '''“UMC authors need stability.”'''  &lt;br /&gt;
  – Stability comes from predictability, not indefinite legacy.  &lt;br /&gt;
  – Clear removal timelines and migration tools give authors confidence.  &lt;br /&gt;
  – Indefinite deprecation leaves authors in limbo, forcing piecemeal porting anyway.&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This policy makes deprecation meaningful. UMC authors get clear timelines and migration guidance, while developers can keep the codebase lean. Wrappers and indefinite deprecation are eliminated, ensuring that “deprecated” is a real lifecycle stage rather than a cosmetic label.&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74960</id>
		<title>PreprocessorRef</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74960"/>
		<updated>2026-04-07T14:14:32Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Macro inclusions */ mention that space inside &amp;quot;&amp;quot; is preserved&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth loads just one configuration file directly: '''data/_main.cfg'''. However, the '''WML preprocessor''' allows the inclusion of more files. Whenever a WML file is read by Wesnoth, it is passed through the preprocessor.&lt;br /&gt;
&lt;br /&gt;
The preprocessor can interpret a simple language of string expansions known as ''macros''. A macro should always be defined '''before''' the place where it needs to be used.&lt;br /&gt;
&lt;br /&gt;
The preprocessor is applied recursively, so included files will be parsed for macros, and after macro expansion will be parsed for macros again, and so on. As a result, you should not write a recursive macro that references itself, because it will cause errors (but, alas, not necessarily error messages).&lt;br /&gt;
&lt;br /&gt;
== Preprocessor directives ==&lt;br /&gt;
&lt;br /&gt;
The following directives are used to create and use ''macros'', i.e. shortcuts which reduce repetition of information. See [https://www.wesnoth.org/macro-reference.html the macro reference] for the list of predefined core macros.&lt;br /&gt;
&lt;br /&gt;
Macros have scoping rules such that addons have separate preprocessing contexts, meaning that they can be overridden however an author of UMC wishes to override them, without worrying about breaking other add-ons.&lt;br /&gt;
&lt;br /&gt;
The preprocessor has changed several times, so don't expect old Wesnoth versions to behave exactly the same as the current stable and development series.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In multiplayer scenarios, these directives will appear to work only for the host and not for other clients. This is because the preprocessor is run only on the host, and the clients receive the resultant WML from the server. It's particularly important to keep this in mind before using preprocessor conditionals.&lt;br /&gt;
&lt;br /&gt;
=== #define ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax: #define ''symbol'' [''parameters''] ''&amp;lt;newline&amp;gt;'' ''substitution'' #enddef'''&lt;br /&gt;
&lt;br /&gt;
All subsequent occurences of '''{''symbol'' [''arguments'']}''' (see below) will be replaced by the contents of the ''substitution'' block, with all occurrences of any parameter {''parameter''} within ''substitution'' replaced by the corresponding value in ''arguments''. &amp;lt;code&amp;gt;#define-#enddef&amp;lt;/code&amp;gt; blocks cannot be nested inside another &amp;lt;code&amp;gt;#define&amp;lt;/code&amp;gt;, as of Wesnoth 1.19.&lt;br /&gt;
&lt;br /&gt;
As an example, the ENEMY_UNIT macro for the [[#Macro inclusions|macro inclusion]] example below could be defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define ENEMY_UNIT TYPE X Y&lt;br /&gt;
## the ordering above is important, since the preprocessor does not distinguish&lt;br /&gt;
## data into different types; only the ordering is used to determine which&lt;br /&gt;
## arguments apply to which parameters.&lt;br /&gt;
[unit]&lt;br /&gt;
    type={TYPE} ## the unit will be of type TYPE, so different&lt;br /&gt;
                ## instantiations&lt;br /&gt;
                ## of this macro can create different units.&lt;br /&gt;
    x={X}&lt;br /&gt;
    y={Y}&lt;br /&gt;
    side=2 ## the unit will be an enemy, regardless of the parameter&lt;br /&gt;
           ## values. This reduces &amp;quot;repetition of information&amp;quot;,&lt;br /&gt;
           ## since it is no longer necessary to specify&lt;br /&gt;
           ## each created unit as an enemy.&lt;br /&gt;
[/unit]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(See [[SingleUnitWML]] for further information on creating units using WML.)&lt;br /&gt;
&lt;br /&gt;
'''Important note:''' Although macros may look like they're simplifying the code, they do not help with wml bloating. Macros are very good at ''disguising'' WML bloat, but they do nothing to ''alleviate'' it. So instead of using macros to generate redundant and repetitive instructions, you should be considering how to eliminate redundancy through programming techniques of abstraction. The most popular way to improve your code is using custom [[EventWML|events]] and [[InternalActionsWML#.5Bfire_event.5D|fire_event]] tags. See also: [[Wml_optimisation|WML Optimisation]].&lt;br /&gt;
&lt;br /&gt;
==== Whitespace in Macros ====&lt;br /&gt;
&lt;br /&gt;
When expanding a macro, '''''all''''' whitespace in the definition of the macro is preserved. The &amp;lt;tt&amp;gt;#arg&amp;lt;/tt&amp;gt; declarations for optional arguments are removed including the final newline. The body of the optional argument (the default value) is similarly processed just as if it were a macro, so all whitespace is preserved.&lt;br /&gt;
&lt;br /&gt;
There are two main practical implications of these rules:&lt;br /&gt;
&lt;br /&gt;
* When using a macro to define simple constants to be used inline in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#enddef&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_CONSTANT&lt;br /&gt;
42#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* If using a macro inside a quoted string, you should not indent the contents of the macro, as the indentation will be preserved upon macro substitution.&lt;br /&gt;
* Similarly if you use an optional argument in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#endarg&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg OPTIONAL_ARG&lt;br /&gt;
default#endarg&lt;br /&gt;
  key = &amp;quot;composite {OPTIONAL_ARG} value&amp;quot;&lt;br /&gt;
#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #arg ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|7}} &lt;br /&gt;
&lt;br /&gt;
'''Syntax: #arg ''symbol'' ''&amp;lt;newline&amp;gt;'' ''default value'' #endarg'''&lt;br /&gt;
&lt;br /&gt;
Defines an optional argument for a macro along with its default value. Optional arguments can be used to make a macro more flexible and to allow its user to specify certain parameters only when necessary.&lt;br /&gt;
&lt;br /&gt;
For example, one could define a shortcut macro for [message] with only one required argument (the text displayed), but several optional ones:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MESSAGE TEXT&lt;br /&gt;
&lt;br /&gt;
#arg SPEAKER_ID&lt;br /&gt;
narrator#endarg&lt;br /&gt;
&lt;br /&gt;
#arg CAPTION&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg SOUND&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg IMG&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
[message]&lt;br /&gt;
    speaker={SPEAKER_ID}&lt;br /&gt;
    message={TEXT}&lt;br /&gt;
    caption={CAPTION}&lt;br /&gt;
    sound={SOUND}&lt;br /&gt;
    image={IMG}&lt;br /&gt;
[/message]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The caller of the macro can then decide which, if any, of the default values to override:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;Halt!&amp;quot; SPEAKER_ID=&amp;quot;Guard Captain&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Two days pass...&amp;quot; IMG=wesnoth-icon.png SOUND=ambient/morning.ogg}&lt;br /&gt;
{MESSAGE _&amp;quot;...&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Welcome!&amp;quot; CAPTION=_&amp;quot;Elóndra's shop of wonders&amp;quot; IMG=portraits/elves/shyde.png}&lt;br /&gt;
{MESSAGE _&amp;quot;*smash*&amp;quot; SPEAKER_ID=&amp;quot;Bridge Troll&amp;quot; SOUND=mace.ogg}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multiline optional argument defined and called as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg MULTILINE&lt;br /&gt;
[some_tag]&lt;br /&gt;
    some_attribute = &amp;quot;some value&amp;quot;&lt;br /&gt;
[/some_tag]&lt;br /&gt;
#endarg&lt;br /&gt;
...&lt;br /&gt;
#enddef&lt;br /&gt;
&lt;br /&gt;
{MY_MACRO (MULTILINE=[other_tag]&lt;br /&gt;
    other_attribute = &amp;quot;other value&amp;quot;&lt;br /&gt;
[/other_tag])}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' As with #enddef, the final line break before #endarg is included in the default value. This means that if the symbol is used in the middle of a line, you should place the #endarg immediately after the value has ended, without a line break in between.&lt;br /&gt;
&lt;br /&gt;
=== #undef ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#undef ''symbol'' '''&lt;br /&gt;
&lt;br /&gt;
Removes the previous definition of the macro named ''symbol''. Wesnoth expects this to be done when overriding an existing macro, and will warn you if you redefine an existing macro without an explicit #undef before it.&lt;br /&gt;
&lt;br /&gt;
=== Inclusion directive {} ===&lt;br /&gt;
&lt;br /&gt;
This directive can be used to include macros, single files or sets of files from a target directory.&lt;br /&gt;
&lt;br /&gt;
==== File/directory inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''path''}'''&lt;br /&gt;
&lt;br /&gt;
Includes the file with the specified ''path'', which will in turn run the preprocessor on it and perform any required substitutions or inclusions within it. The ''path'' may not contain ''..'' or the inclusion will be skipped.&lt;br /&gt;
&lt;br /&gt;
The exact location in which the ''path'' will be resolved will depend on its prefix:&lt;br /&gt;
&lt;br /&gt;
* '''{''path''}''': If ''path'' isn't a known macro (see below), the game will assume it's a relative path to a file in the main game '''data/''' directory and include it.&lt;br /&gt;
* '''{~''path''}''': As above, but instead of the game data directory, the path is resolved relative to the user '''data/''' directory, where user made add-ons can normally be found.&lt;br /&gt;
* '''{./''path''}''': The path is resolved relative to the location of the current file containing this inclusion.&lt;br /&gt;
&lt;br /&gt;
Information for locating the user data and game data directories can be found in [[EditingWesnoth]].&lt;br /&gt;
&lt;br /&gt;
Forward slashes ('''/''') should '''always''' be used as the path delimiter, even if your platform uses a different symbol such as colons (''':''') or backslashes ('''\''')! It is also very important to respect the '''actual letter case''' used to name files and directories for compatibility with case-sensitive filesystems on Unix-based operating systems.&lt;br /&gt;
&lt;br /&gt;
When ''path'' points to a directory instead of a file, the preprocessor will include all files found within with the '''.cfg''' extension, in alphabetical order; files without this extension (such as '''.map''' or '''.png''' files) are ignored.&lt;br /&gt;
&lt;br /&gt;
Some directories are handled in a special fashion according to their contents:&lt;br /&gt;
&lt;br /&gt;
* If there's a file named '''_main.cfg''' in the target directory, only that file will be included and preprocessed. It may include other files from its own directory or subdirectories within it, of course. This is used for managing WML directories as self-contained packages, like user made add-ons.&lt;br /&gt;
* If there are files named '''_main.cfg''' in subdirectories of the target and there isn't one in the target itself, they will be all preprocessed. Given the following layout:&lt;br /&gt;
 dir/&lt;br /&gt;
 dir/a/_main.cfg&lt;br /&gt;
 dir/a/other.cfg&lt;br /&gt;
 dir/b/_main.cfg&lt;br /&gt;
 dir/b/other.cfg&lt;br /&gt;
 dir/other.cfg&lt;br /&gt;
Using '''{dir}''' will cause dir/a/_main.cfg, dir/b/_main.cfg and dir/other.cfg to be included.&lt;br /&gt;
* If there's a file named '''_final.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''after'' all the other files in the directory.&lt;br /&gt;
* If there's a file named '''_initial.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''before'' all the other files in the directory.&lt;br /&gt;
&lt;br /&gt;
==== Macro inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''symbol'' [''arguments''] [''optional arguments'']}'''&lt;br /&gt;
&lt;br /&gt;
If the macro named ''symbol'' is defined, the preprocessor will replace this instruction by the expression ''symbol'' was previously defined as, using ''arguments'' as parameters. The number of normal arguments must be exactly the same as in the original definition or an error will occur. Optional arguments can only be placed '''after''' all normal arguments, however they can be specified in any order desired.&lt;br /&gt;
&lt;br /&gt;
You can create multiple word arguments by using parentheses to delimit the contents. If they are already quoted, space inside quotes will be preserved even without parentheses. For example, in '''{ENEMY_UNIT Wolf Rider 18 24}''' the four words will be interpreted as separate arguments and cause the preprocessor to fail since the macro was defined above with only three; instead, you should use '''{ENEMY_UNIT (Wolf Rider) 18 24}'''.&lt;br /&gt;
&lt;br /&gt;
Optional arguments can also be delimited by placing parentheses, however they must be placed around both the argument name '''and''' content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; (SPEAKER_ID=Bridge Troll) } # Correct&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; SPEAKER_ID=(Bridge Troll) } # Wrong&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way even complex arguments can be passed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MODIFY_UNIT (&lt;br /&gt;
    [filter_adjacent]&lt;br /&gt;
        canrecruit=yes&lt;br /&gt;
    [/filter_adjacent]&lt;br /&gt;
    ) side 2}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the name of an existing macro as the name of a macro argument is possible, but the argument will always take precedence over the original macro:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define VARIABLE&lt;br /&gt;
#enddef&lt;br /&gt;
#define MACRO VARIABLE&lt;br /&gt;
    {VARIABLE} # is calling for the argument, not for the macro above&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #ifdef and #ifndef ===&lt;br /&gt;
&lt;br /&gt;
Unlike the other preprocessor directives, '''#ifdef''' and '''#ifndef''' are not mere conveniences. They are often necessary to distinguish between different gameplay modes or difficulties (see [[#Built-in macros|Built-in macros]] below).&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifdef ''symbol'' ''substitution-if-defined'' [#else ''substitution-if-not-defined'' ] #endif'''&lt;br /&gt;
&lt;br /&gt;
If ''symbol'' has been defined with '''#define''' or as a built-in macro, the whole block will be replaced by ''substitution-if-defined''.  If not, it will be replaced by ''substitution-if-not-defined'' if it is available.&lt;br /&gt;
&lt;br /&gt;
'''#ifndef''' is the exact opposite of '''#ifdef''', reversing the logic:&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifndef ''symbol'' ''substitution-if-not-defined''  [#else ''substitution-if-defined''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifhave and #ifnhave ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifhave ''path'' ''substitution-if-path-exists'' [#else ''substitution-if-path-does-not-exist''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Checks for the existence of a file. Uses the same relative paths as [[#Inclusion_directive_.7B.7D|include directives]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifhave ~add-ons/My_Addon/_main.cfg&lt;br /&gt;
    {MY_ADDON_MACROS}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnhave'''  does the opposite of '''#ifhave''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnhave ''path'' ''substitution-if-path-does-not-exist'' [#else ''substitution-if-path-exists''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifver and #ifnver ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-met'' [#else ''substitution-if-condition-not-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Compares a version number defined in a macro against an argument for conditional block inclusions, like ''#ifdef'' and ''#ifhave''. ''operator'' is one of ''=='' (equal), ''!='' (not equal), ''&amp;lt;'' (less), ''&amp;lt;='' (less or equal), ''&amp;gt;'' (greater), ''&amp;gt;='' (greater or equal). The specified ''symbol'' should have been previously defined as plain text without more macro inclusions within it, and it must not require any arguments.&lt;br /&gt;
&lt;br /&gt;
Versions with text suffixes are sorted in binary order and come after all versions with the same number. The most common suffixes begin with &amp;quot;+&amp;quot;, but as this represents multiple possible versions, comparing versions against it is not recommended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;gt;= 1.9.7+&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7+, 1.9.8 or later!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#else&lt;br /&gt;
#ifver WESNOTH_VERSION == 1.9.7&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7, and I’ll include some workaround code for bug #9001!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#endif&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnver'''  does the opposite of '''#ifver''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-not-met'' [#else ''substitution-if-condition-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #error ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#error [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to fail unconditionally upon encountering the line. For add-ons, this will cause the game to display an error and return to the titlescreen if the add-on is required for the user's action (such as playing a campaign or loading a saved game). For core WML, this will cause the game to quit entirely.&lt;br /&gt;
&lt;br /&gt;
Please note that in spite of the example below, it is '''not''' advisable to use this mechanism in published add-ons for version or feature-checking, since the message is not displayed in a form that permits translation and the additional trace information may confuse players. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#error This add-on does not support Wesnoth 1.11.10!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #warning ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#warning [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to emit a warning upon encountering the line. The message will '''only''' be relayed to stderr, not to the player in the game UI. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#warning On Wesnoth 1.11.9 or earlier, bug workarounds enabled!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #deprecated ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 1 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 2 ''version'' [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 3 ''version'' [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 4 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
The first argument is the deprecation level, while ''version'' is the Wesnoth version where this deprecated file/macro is supposed to be removed. ''message'' is the optional deprecation message. The recommended usage is to provide ''message''.&lt;br /&gt;
&lt;br /&gt;
The effect of this directive depends on whether it appears within a macro definition.&lt;br /&gt;
&lt;br /&gt;
* If it appears at file level, outside any macro definition, then it immediately outputs a warning saying that the file is deprecated, with the provided message. Multiple '''#deprecated''' directives at toplevel in a single file will result in separate messages.&lt;br /&gt;
* If it appears inside a macro definition ('''#define ... #enddef'''), then it doesn't output anything. Instead, it marks the macro as deprecated. When that macro is later used, only then will the preprocessor output a warning saying that the macro is deprecated, with the provided message. Multiple '''#deprecated''' directives within a single macro will be merged into one message.&lt;br /&gt;
&lt;br /&gt;
Note that deprecation messages will only appear if they have been set to. {{DevFeature1.13|12}} This can be done by enabling debug mode, or by going to Advanced Preferences and setting the log-level for the deprecation logdomain. (This can also be done on the command-line.)&lt;br /&gt;
&lt;br /&gt;
If you provide a deprecation level of 2 or 3, it is required to indicate the earliest version in which the feature could be removed. However, if you provide a deprecation level of 1 or 4, any provided ''version'' will instead be parsed as part of the message, so you will probably not want to provide one at all. Other deprecation levels are not valid. See the documentation for [[InterfaceActionsWML#.5Bdeprecated_message.5D|[deprecated_message]]] for the meaning of the various ''level'' values.&lt;br /&gt;
&lt;br /&gt;
== Built-in macros ==&lt;br /&gt;
&lt;br /&gt;
The following macros are automatically defined with empty contents (unless specified otherwise) by the game engine depending on the configuration or gameplay mode.&lt;br /&gt;
&lt;br /&gt;
Note that except during an actual game, '''MULTIPLAYER''', '''EDITOR''' and previous campaign defines, are not guaranteed to be undefined, especially when coming back to the titlescreen. So it is not enough to hide contents inside of an #ifdef to prevent them from being seen by the campaign selection dialog, for example for multiplayer specific '''[campaign]'''s or '''[modification]'''s '''type=mp''' must be used. &lt;br /&gt;
&lt;br /&gt;
* A campaign define symbol (see ''define'' in [[CampaignWML]]): defined when playing a single-player campaign.&lt;br /&gt;
* A campaign difficulty level, usually '''EASY''', '''NORMAL''' or '''HARD''' (see ''difficulties'' in [[CampaignWML]]): defined according to the chosen difficulty when starting a single-player campaign, also stored in saved games.&lt;br /&gt;
* '''MULTIPLAYER''': defined when in multiplayer mode.&lt;br /&gt;
* '''EDITOR''': defined when running the built-in map editor.&lt;br /&gt;
* '''DEBUG_MODE''': defined when the game has been launched in debug mode (i.e. with '''-d''' or '''--debug''' in the command line). Can also be set by typing &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; to bring up [[CommandMode]], then typing &amp;lt;code&amp;gt;debug&amp;lt;/code&amp;gt;, and then restarting the scenario.&lt;br /&gt;
* '''APPLE''': defined while processing the main game data when running on Mac OS X. This primarily exists to switch Control for Command in hotkeys, which is why there are no defines for other platforms.&lt;br /&gt;
* '''WESNOTH_VERSION''': defined containing just the game version number when running the WML preprocessor.&lt;br /&gt;
* '''CURRENT_FILE''': Expands to the name of the current WML file.&lt;br /&gt;
* '''CURRENT_DIRECTORY''': Expands to the preprocessor path of the parent directory for the current WML file (e.g. for &amp;lt;code&amp;gt;&amp;amp;lt;user data dir&amp;amp;gt;/data/add-ons/My_Addon/_main.cfg&amp;lt;/code&amp;gt; this evaluates to &amp;lt;code&amp;gt;~add-ons/My_Addon&amp;lt;/code&amp;gt;). &lt;br /&gt;
* '''LEFT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;{&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''RIGHT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;}&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''SCHEMA_VALIDATION''': defined if the validator is being run.&lt;br /&gt;
* '''__WMLUNITS__''': defined when the tool to create [https://units.wesnoth.org units.wesnoth.org] is being run.&lt;br /&gt;
&lt;br /&gt;
A ''very large'' number of additional macros are provided as part of the default game core WML. For a full list of those, check the [https://www.wesnoth.org/macro-reference.html macro reference].&lt;br /&gt;
&lt;br /&gt;
== Command-line preprocessor ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
Or the short form:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: -p ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
You can specify a list of predefined defines with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-defines=DEFINE1,DEFINE2,etc'''&lt;br /&gt;
&lt;br /&gt;
comma separated list of defines to be used by '--preprocess' command. If 'SKIP_CORE' is in the define list the data/core won't be preprocessed.&lt;br /&gt;
&lt;br /&gt;
The command will first preprocess '''data/core/macros''' and '''data/core/terrain-graphics''', and afterwards the specified path. You can specify a single file to be preprocessed (if you want to preprocess multiple separate files, you'll need to run a different command line for each one), or an entire directory, which will be preprocessed according to the rules used by the inclusion directive above.&lt;br /&gt;
&lt;br /&gt;
The resulting preprocessed files will be written in the target directory. There will be two types of files: .cfg files --- the normal ones, and .plain files containing line markers and textdomain changes.&lt;br /&gt;
&lt;br /&gt;
If by chance, the simple macro define doesn't suffice, you can use:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-input-macros &amp;lt;file&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
To import an existing file that contains macros, and they will be available in the defines database before processing the specified files.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility to export the preprocessed defines/macro list with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-output-macros [&amp;lt;target file&amp;gt;]'''&lt;br /&gt;
&lt;br /&gt;
This file could be fed to the 'input-macros' argument next time you run it. For example, a scenario would be: parsing just the core first time, and for the intended target files, you would add SKIP_CORE but import the generated macros file - that will be faster than preprocessing the core again. If the target file is not specified, the output file will be _MACROS_.cfg in the target directory of the preprocess's command.&lt;br /&gt;
&lt;br /&gt;
If ''file/directory'' and ''target directory'' are not absolute paths, they will be considered relative to the current directory.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&lt;br /&gt;
* Preprocess the entire tutorial dir, and write the results in the ~/result folder:&lt;br /&gt;
 -p ~/wesnoth/data/campaigns/tutorial ~/result&lt;br /&gt;
* Add the MULTIPLAYER define to the list and preprocess a scenario's config file:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign/scenarios/01_First_Scenario.cfg ~/result --preprocess-defines=MULTIPLAYER&lt;br /&gt;
* Add the MY_CAMPAIGN and HARD defines before preprocessing a campaign's files:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign ~/result --preprocess-defines=MY_CAMPAIGN,HARD&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
 -p data/gui/macros/_initial.cfg  /tmp --preprocess-output-macros=macros&lt;br /&gt;
 -p myfile.cfg ~/result --preprocess-input-macros=/tmp/macros&lt;br /&gt;
&lt;br /&gt;
When it starts getting complicated, such as a file that depends on multiple other files, it is probably easiest to simply &amp;quot;include&amp;quot; the dependencies:&lt;br /&gt;
&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
  Add {gui/macros/_initial.cfg} to the beginning of  myfile.cfg&lt;br /&gt;
  -p myfile.cfg ~/result&lt;br /&gt;
&lt;br /&gt;
If you want a more detailed (and potentially overwhelming) log, you can simply add the switches '''--log-debug=all''' or '''--log-info=all''' to the command line, so you can see how things are preprocessed in detail.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[SyntaxWML]] (explains relationship between comments and preprocessor directives)&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74957</id>
		<title>PreprocessorRef</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74957"/>
		<updated>2026-04-04T05:52:41Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* #deprecated */  version is actually mandatory for deprecation levels 2/3&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth loads just one configuration file directly: '''data/_main.cfg'''. However, the '''WML preprocessor''' allows the inclusion of more files. Whenever a WML file is read by Wesnoth, it is passed through the preprocessor.&lt;br /&gt;
&lt;br /&gt;
The preprocessor can interpret a simple language of string expansions known as ''macros''. A macro should always be defined '''before''' the place where it needs to be used.&lt;br /&gt;
&lt;br /&gt;
The preprocessor is applied recursively, so included files will be parsed for macros, and after macro expansion will be parsed for macros again, and so on. As a result, you should not write a recursive macro that references itself, because it will cause errors (but, alas, not necessarily error messages).&lt;br /&gt;
&lt;br /&gt;
== Preprocessor directives ==&lt;br /&gt;
&lt;br /&gt;
The following directives are used to create and use ''macros'', i.e. shortcuts which reduce repetition of information. See [https://www.wesnoth.org/macro-reference.html the macro reference] for the list of predefined core macros.&lt;br /&gt;
&lt;br /&gt;
Macros have scoping rules such that addons have separate preprocessing contexts, meaning that they can be overridden however an author of UMC wishes to override them, without worrying about breaking other add-ons.&lt;br /&gt;
&lt;br /&gt;
The preprocessor has changed several times, so don't expect old Wesnoth versions to behave exactly the same as the current stable and development series.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In multiplayer scenarios, these directives will appear to work only for the host and not for other clients. This is because the preprocessor is run only on the host, and the clients receive the resultant WML from the server. It's particularly important to keep this in mind before using preprocessor conditionals.&lt;br /&gt;
&lt;br /&gt;
=== #define ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax: #define ''symbol'' [''parameters''] ''&amp;lt;newline&amp;gt;'' ''substitution'' #enddef'''&lt;br /&gt;
&lt;br /&gt;
All subsequent occurences of '''{''symbol'' [''arguments'']}''' (see below) will be replaced by the contents of the ''substitution'' block, with all occurrences of any parameter {''parameter''} within ''substitution'' replaced by the corresponding value in ''arguments''. &amp;lt;code&amp;gt;#define-#enddef&amp;lt;/code&amp;gt; blocks cannot be nested inside another &amp;lt;code&amp;gt;#define&amp;lt;/code&amp;gt;, as of Wesnoth 1.19.&lt;br /&gt;
&lt;br /&gt;
As an example, the ENEMY_UNIT macro for the [[#Macro inclusions|macro inclusion]] example below could be defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define ENEMY_UNIT TYPE X Y&lt;br /&gt;
## the ordering above is important, since the preprocessor does not distinguish&lt;br /&gt;
## data into different types; only the ordering is used to determine which&lt;br /&gt;
## arguments apply to which parameters.&lt;br /&gt;
[unit]&lt;br /&gt;
    type={TYPE} ## the unit will be of type TYPE, so different&lt;br /&gt;
                ## instantiations&lt;br /&gt;
                ## of this macro can create different units.&lt;br /&gt;
    x={X}&lt;br /&gt;
    y={Y}&lt;br /&gt;
    side=2 ## the unit will be an enemy, regardless of the parameter&lt;br /&gt;
           ## values. This reduces &amp;quot;repetition of information&amp;quot;,&lt;br /&gt;
           ## since it is no longer necessary to specify&lt;br /&gt;
           ## each created unit as an enemy.&lt;br /&gt;
[/unit]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(See [[SingleUnitWML]] for further information on creating units using WML.)&lt;br /&gt;
&lt;br /&gt;
'''Important note:''' Although macros may look like they're simplifying the code, they do not help with wml bloating. Macros are very good at ''disguising'' WML bloat, but they do nothing to ''alleviate'' it. So instead of using macros to generate redundant and repetitive instructions, you should be considering how to eliminate redundancy through programming techniques of abstraction. The most popular way to improve your code is using custom [[EventWML|events]] and [[InternalActionsWML#.5Bfire_event.5D|fire_event]] tags. See also: [[Wml_optimisation|WML Optimisation]].&lt;br /&gt;
&lt;br /&gt;
==== Whitespace in Macros ====&lt;br /&gt;
&lt;br /&gt;
When expanding a macro, '''''all''''' whitespace in the definition of the macro is preserved. The &amp;lt;tt&amp;gt;#arg&amp;lt;/tt&amp;gt; declarations for optional arguments are removed including the final newline. The body of the optional argument (the default value) is similarly processed just as if it were a macro, so all whitespace is preserved.&lt;br /&gt;
&lt;br /&gt;
There are two main practical implications of these rules:&lt;br /&gt;
&lt;br /&gt;
* When using a macro to define simple constants to be used inline in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#enddef&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_CONSTANT&lt;br /&gt;
42#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* If using a macro inside a quoted string, you should not indent the contents of the macro, as the indentation will be preserved upon macro substitution.&lt;br /&gt;
* Similarly if you use an optional argument in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#endarg&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg OPTIONAL_ARG&lt;br /&gt;
default#endarg&lt;br /&gt;
  key = &amp;quot;composite {OPTIONAL_ARG} value&amp;quot;&lt;br /&gt;
#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #arg ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|7}} &lt;br /&gt;
&lt;br /&gt;
'''Syntax: #arg ''symbol'' ''&amp;lt;newline&amp;gt;'' ''default value'' #endarg'''&lt;br /&gt;
&lt;br /&gt;
Defines an optional argument for a macro along with its default value. Optional arguments can be used to make a macro more flexible and to allow its user to specify certain parameters only when necessary.&lt;br /&gt;
&lt;br /&gt;
For example, one could define a shortcut macro for [message] with only one required argument (the text displayed), but several optional ones:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MESSAGE TEXT&lt;br /&gt;
&lt;br /&gt;
#arg SPEAKER_ID&lt;br /&gt;
narrator#endarg&lt;br /&gt;
&lt;br /&gt;
#arg CAPTION&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg SOUND&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg IMG&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
[message]&lt;br /&gt;
    speaker={SPEAKER_ID}&lt;br /&gt;
    message={TEXT}&lt;br /&gt;
    caption={CAPTION}&lt;br /&gt;
    sound={SOUND}&lt;br /&gt;
    image={IMG}&lt;br /&gt;
[/message]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The caller of the macro can then decide which, if any, of the default values to override:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;Halt!&amp;quot; SPEAKER_ID=&amp;quot;Guard Captain&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Two days pass...&amp;quot; IMG=wesnoth-icon.png SOUND=ambient/morning.ogg}&lt;br /&gt;
{MESSAGE _&amp;quot;...&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Welcome!&amp;quot; CAPTION=_&amp;quot;Elóndra's shop of wonders&amp;quot; IMG=portraits/elves/shyde.png}&lt;br /&gt;
{MESSAGE _&amp;quot;*smash*&amp;quot; SPEAKER_ID=&amp;quot;Bridge Troll&amp;quot; SOUND=mace.ogg}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multiline optional argument defined and called as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg MULTILINE&lt;br /&gt;
[some_tag]&lt;br /&gt;
    some_attribute = &amp;quot;some value&amp;quot;&lt;br /&gt;
[/some_tag]&lt;br /&gt;
#endarg&lt;br /&gt;
...&lt;br /&gt;
#enddef&lt;br /&gt;
&lt;br /&gt;
{MY_MACRO (MULTILINE=[other_tag]&lt;br /&gt;
    other_attribute = &amp;quot;other value&amp;quot;&lt;br /&gt;
[/other_tag])}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' As with #enddef, the final line break before #endarg is included in the default value. This means that if the symbol is used in the middle of a line, you should place the #endarg immediately after the value has ended, without a line break in between.&lt;br /&gt;
&lt;br /&gt;
=== #undef ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#undef ''symbol'' '''&lt;br /&gt;
&lt;br /&gt;
Removes the previous definition of the macro named ''symbol''. Wesnoth expects this to be done when overriding an existing macro, and will warn you if you redefine an existing macro without an explicit #undef before it.&lt;br /&gt;
&lt;br /&gt;
=== Inclusion directive {} ===&lt;br /&gt;
&lt;br /&gt;
This directive can be used to include macros, single files or sets of files from a target directory.&lt;br /&gt;
&lt;br /&gt;
==== File/directory inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''path''}'''&lt;br /&gt;
&lt;br /&gt;
Includes the file with the specified ''path'', which will in turn run the preprocessor on it and perform any required substitutions or inclusions within it. The ''path'' may not contain ''..'' or the inclusion will be skipped.&lt;br /&gt;
&lt;br /&gt;
The exact location in which the ''path'' will be resolved will depend on its prefix:&lt;br /&gt;
&lt;br /&gt;
* '''{''path''}''': If ''path'' isn't a known macro (see below), the game will assume it's a relative path to a file in the main game '''data/''' directory and include it.&lt;br /&gt;
* '''{~''path''}''': As above, but instead of the game data directory, the path is resolved relative to the user '''data/''' directory, where user made add-ons can normally be found.&lt;br /&gt;
* '''{./''path''}''': The path is resolved relative to the location of the current file containing this inclusion.&lt;br /&gt;
&lt;br /&gt;
Information for locating the user data and game data directories can be found in [[EditingWesnoth]].&lt;br /&gt;
&lt;br /&gt;
Forward slashes ('''/''') should '''always''' be used as the path delimiter, even if your platform uses a different symbol such as colons (''':''') or backslashes ('''\''')! It is also very important to respect the '''actual letter case''' used to name files and directories for compatibility with case-sensitive filesystems on Unix-based operating systems.&lt;br /&gt;
&lt;br /&gt;
When ''path'' points to a directory instead of a file, the preprocessor will include all files found within with the '''.cfg''' extension, in alphabetical order; files without this extension (such as '''.map''' or '''.png''' files) are ignored.&lt;br /&gt;
&lt;br /&gt;
Some directories are handled in a special fashion according to their contents:&lt;br /&gt;
&lt;br /&gt;
* If there's a file named '''_main.cfg''' in the target directory, only that file will be included and preprocessed. It may include other files from its own directory or subdirectories within it, of course. This is used for managing WML directories as self-contained packages, like user made add-ons.&lt;br /&gt;
* If there are files named '''_main.cfg''' in subdirectories of the target and there isn't one in the target itself, they will be all preprocessed. Given the following layout:&lt;br /&gt;
 dir/&lt;br /&gt;
 dir/a/_main.cfg&lt;br /&gt;
 dir/a/other.cfg&lt;br /&gt;
 dir/b/_main.cfg&lt;br /&gt;
 dir/b/other.cfg&lt;br /&gt;
 dir/other.cfg&lt;br /&gt;
Using '''{dir}''' will cause dir/a/_main.cfg, dir/b/_main.cfg and dir/other.cfg to be included.&lt;br /&gt;
* If there's a file named '''_final.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''after'' all the other files in the directory.&lt;br /&gt;
* If there's a file named '''_initial.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''before'' all the other files in the directory.&lt;br /&gt;
&lt;br /&gt;
==== Macro inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''symbol'' [''arguments''] [''optional arguments'']}'''&lt;br /&gt;
&lt;br /&gt;
If the macro named ''symbol'' is defined, the preprocessor will replace this instruction by the expression ''symbol'' was previously defined as, using ''arguments'' as parameters. The number of normal arguments must be exactly the same as in the original definition or an error will occur. Optional arguments can only be placed '''after''' all normal arguments, however they can be specified in any order desired.&lt;br /&gt;
&lt;br /&gt;
You can create multiple word arguments by using parentheses to delimit the contents. For example, in '''{ENEMY_UNIT Wolf Rider 18 24}''' the four words will be interpreted as separate arguments and cause the preprocessor to fail since the macro was defined above with only three; instead, you should use '''{ENEMY_UNIT (Wolf Rider) 18 24}'''.&lt;br /&gt;
&lt;br /&gt;
Optional arguments can also be delimited by placing parentheses, however they must be placed around both the argument name '''and''' content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; (SPEAKER_ID=Bridge Troll) } # Correct&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; SPEAKER_ID=(Bridge Troll) } # Wrong&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way even complex arguments can be passed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MODIFY_UNIT (&lt;br /&gt;
    [filter_adjacent]&lt;br /&gt;
        canrecruit=yes&lt;br /&gt;
    [/filter_adjacent]&lt;br /&gt;
    ) side 2}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the name of an existing macro as the name of a macro argument is possible, but the argument will always take precedence over the original macro:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define VARIABLE&lt;br /&gt;
#enddef&lt;br /&gt;
#define MACRO VARIABLE&lt;br /&gt;
    {VARIABLE} # is calling for the argument, not for the macro above&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #ifdef and #ifndef ===&lt;br /&gt;
&lt;br /&gt;
Unlike the other preprocessor directives, '''#ifdef''' and '''#ifndef''' are not mere conveniences. They are often necessary to distinguish between different gameplay modes or difficulties (see [[#Built-in macros|Built-in macros]] below).&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifdef ''symbol'' ''substitution-if-defined'' [#else ''substitution-if-not-defined'' ] #endif'''&lt;br /&gt;
&lt;br /&gt;
If ''symbol'' has been defined with '''#define''' or as a built-in macro, the whole block will be replaced by ''substitution-if-defined''.  If not, it will be replaced by ''substitution-if-not-defined'' if it is available.&lt;br /&gt;
&lt;br /&gt;
'''#ifndef''' is the exact opposite of '''#ifdef''', reversing the logic:&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifndef ''symbol'' ''substitution-if-not-defined''  [#else ''substitution-if-defined''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifhave and #ifnhave ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifhave ''path'' ''substitution-if-path-exists'' [#else ''substitution-if-path-does-not-exist''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Checks for the existence of a file. Uses the same relative paths as [[#Inclusion_directive_.7B.7D|include directives]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifhave ~add-ons/My_Addon/_main.cfg&lt;br /&gt;
    {MY_ADDON_MACROS}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnhave'''  does the opposite of '''#ifhave''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnhave ''path'' ''substitution-if-path-does-not-exist'' [#else ''substitution-if-path-exists''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifver and #ifnver ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-met'' [#else ''substitution-if-condition-not-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Compares a version number defined in a macro against an argument for conditional block inclusions, like ''#ifdef'' and ''#ifhave''. ''operator'' is one of ''=='' (equal), ''!='' (not equal), ''&amp;lt;'' (less), ''&amp;lt;='' (less or equal), ''&amp;gt;'' (greater), ''&amp;gt;='' (greater or equal). The specified ''symbol'' should have been previously defined as plain text without more macro inclusions within it, and it must not require any arguments.&lt;br /&gt;
&lt;br /&gt;
Versions with text suffixes are sorted in binary order and come after all versions with the same number. The most common suffixes begin with &amp;quot;+&amp;quot;, but as this represents multiple possible versions, comparing versions against it is not recommended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;gt;= 1.9.7+&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7+, 1.9.8 or later!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#else&lt;br /&gt;
#ifver WESNOTH_VERSION == 1.9.7&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7, and I’ll include some workaround code for bug #9001!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#endif&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnver'''  does the opposite of '''#ifver''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-not-met'' [#else ''substitution-if-condition-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #error ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#error [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to fail unconditionally upon encountering the line. For add-ons, this will cause the game to display an error and return to the titlescreen if the add-on is required for the user's action (such as playing a campaign or loading a saved game). For core WML, this will cause the game to quit entirely.&lt;br /&gt;
&lt;br /&gt;
Please note that in spite of the example below, it is '''not''' advisable to use this mechanism in published add-ons for version or feature-checking, since the message is not displayed in a form that permits translation and the additional trace information may confuse players. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#error This add-on does not support Wesnoth 1.11.10!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #warning ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#warning [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to emit a warning upon encountering the line. The message will '''only''' be relayed to stderr, not to the player in the game UI. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#warning On Wesnoth 1.11.9 or earlier, bug workarounds enabled!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #deprecated ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 1 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 2 ''version'' [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 3 ''version'' [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 4 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
The first argument is the deprecation level, while ''version'' is the Wesnoth version where this deprecated file/macro is supposed to be removed. ''message'' is the optional deprecation message. The recommended usage is to provide ''message''.&lt;br /&gt;
&lt;br /&gt;
The effect of this directive depends on whether it appears within a macro definition.&lt;br /&gt;
&lt;br /&gt;
* If it appears at file level, outside any macro definition, then it immediately outputs a warning saying that the file is deprecated, with the provided message. Multiple '''#deprecated''' directives at toplevel in a single file will result in separate messages.&lt;br /&gt;
* If it appears inside a macro definition ('''#define ... #enddef'''), then it doesn't output anything. Instead, it marks the macro as deprecated. When that macro is later used, only then will the preprocessor output a warning saying that the macro is deprecated, with the provided message. Multiple '''#deprecated''' directives within a single macro will be merged into one message.&lt;br /&gt;
&lt;br /&gt;
Note that deprecation messages will only appear if they have been set to. {{DevFeature1.13|12}} This can be done by enabling debug mode, or by going to Advanced Preferences and setting the log-level for the deprecation logdomain. (This can also be done on the command-line.)&lt;br /&gt;
&lt;br /&gt;
If you provide a deprecation level of 2 or 3, it is required to indicate the earliest version in which the feature could be removed. However, if you provide a deprecation level of 1 or 4, any provided ''version'' will instead be parsed as part of the message, so you will probably not want to provide one at all. Other deprecation levels are not valid. See the documentation for [[InterfaceActionsWML#.5Bdeprecated_message.5D|[deprecated_message]]] for the meaning of the various ''level'' values.&lt;br /&gt;
&lt;br /&gt;
== Built-in macros ==&lt;br /&gt;
&lt;br /&gt;
The following macros are automatically defined with empty contents (unless specified otherwise) by the game engine depending on the configuration or gameplay mode.&lt;br /&gt;
&lt;br /&gt;
Note that except during an actual game, '''MULTIPLAYER''', '''EDITOR''' and previous campaign defines, are not guaranteed to be undefined, especially when coming back to the titlescreen. So it is not enough to hide contents inside of an #ifdef to prevent them from being seen by the campaign selection dialog, for example for multiplayer specific '''[campaign]'''s or '''[modification]'''s '''type=mp''' must be used. &lt;br /&gt;
&lt;br /&gt;
* A campaign define symbol (see ''define'' in [[CampaignWML]]): defined when playing a single-player campaign.&lt;br /&gt;
* A campaign difficulty level, usually '''EASY''', '''NORMAL''' or '''HARD''' (see ''difficulties'' in [[CampaignWML]]): defined according to the chosen difficulty when starting a single-player campaign, also stored in saved games.&lt;br /&gt;
* '''MULTIPLAYER''': defined when in multiplayer mode.&lt;br /&gt;
* '''EDITOR''': defined when running the built-in map editor.&lt;br /&gt;
* '''DEBUG_MODE''': defined when the game has been launched in debug mode (i.e. with '''-d''' or '''--debug''' in the command line). Can also be set by typing &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; to bring up [[CommandMode]], then typing &amp;lt;code&amp;gt;debug&amp;lt;/code&amp;gt;, and then restarting the scenario.&lt;br /&gt;
* '''APPLE''': defined while processing the main game data when running on Mac OS X. This primarily exists to switch Control for Command in hotkeys, which is why there are no defines for other platforms.&lt;br /&gt;
* '''WESNOTH_VERSION''': defined containing just the game version number when running the WML preprocessor.&lt;br /&gt;
* '''CURRENT_FILE''': Expands to the name of the current WML file.&lt;br /&gt;
* '''CURRENT_DIRECTORY''': Expands to the preprocessor path of the parent directory for the current WML file (e.g. for &amp;lt;code&amp;gt;&amp;amp;lt;user data dir&amp;amp;gt;/data/add-ons/My_Addon/_main.cfg&amp;lt;/code&amp;gt; this evaluates to &amp;lt;code&amp;gt;~add-ons/My_Addon&amp;lt;/code&amp;gt;). &lt;br /&gt;
* '''LEFT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;{&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''RIGHT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;}&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''SCHEMA_VALIDATION''': defined if the validator is being run.&lt;br /&gt;
* '''__WMLUNITS__''': defined when the tool to create [https://units.wesnoth.org units.wesnoth.org] is being run.&lt;br /&gt;
&lt;br /&gt;
A ''very large'' number of additional macros are provided as part of the default game core WML. For a full list of those, check the [https://www.wesnoth.org/macro-reference.html macro reference].&lt;br /&gt;
&lt;br /&gt;
== Command-line preprocessor ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
Or the short form:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: -p ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
You can specify a list of predefined defines with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-defines=DEFINE1,DEFINE2,etc'''&lt;br /&gt;
&lt;br /&gt;
comma separated list of defines to be used by '--preprocess' command. If 'SKIP_CORE' is in the define list the data/core won't be preprocessed.&lt;br /&gt;
&lt;br /&gt;
The command will first preprocess '''data/core/macros''' and '''data/core/terrain-graphics''', and afterwards the specified path. You can specify a single file to be preprocessed (if you want to preprocess multiple separate files, you'll need to run a different command line for each one), or an entire directory, which will be preprocessed according to the rules used by the inclusion directive above.&lt;br /&gt;
&lt;br /&gt;
The resulting preprocessed files will be written in the target directory. There will be two types of files: .cfg files --- the normal ones, and .plain files containing line markers and textdomain changes.&lt;br /&gt;
&lt;br /&gt;
If by chance, the simple macro define doesn't suffice, you can use:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-input-macros &amp;lt;file&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
To import an existing file that contains macros, and they will be available in the defines database before processing the specified files.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility to export the preprocessed defines/macro list with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-output-macros [&amp;lt;target file&amp;gt;]'''&lt;br /&gt;
&lt;br /&gt;
This file could be fed to the 'input-macros' argument next time you run it. For example, a scenario would be: parsing just the core first time, and for the intended target files, you would add SKIP_CORE but import the generated macros file - that will be faster than preprocessing the core again. If the target file is not specified, the output file will be _MACROS_.cfg in the target directory of the preprocess's command.&lt;br /&gt;
&lt;br /&gt;
If ''file/directory'' and ''target directory'' are not absolute paths, they will be considered relative to the current directory.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&lt;br /&gt;
* Preprocess the entire tutorial dir, and write the results in the ~/result folder:&lt;br /&gt;
 -p ~/wesnoth/data/campaigns/tutorial ~/result&lt;br /&gt;
* Add the MULTIPLAYER define to the list and preprocess a scenario's config file:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign/scenarios/01_First_Scenario.cfg ~/result --preprocess-defines=MULTIPLAYER&lt;br /&gt;
* Add the MY_CAMPAIGN and HARD defines before preprocessing a campaign's files:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign ~/result --preprocess-defines=MY_CAMPAIGN,HARD&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
 -p data/gui/macros/_initial.cfg  /tmp --preprocess-output-macros=macros&lt;br /&gt;
 -p myfile.cfg ~/result --preprocess-input-macros=/tmp/macros&lt;br /&gt;
&lt;br /&gt;
When it starts getting complicated, such as a file that depends on multiple other files, it is probably easiest to simply &amp;quot;include&amp;quot; the dependencies:&lt;br /&gt;
&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
  Add {gui/macros/_initial.cfg} to the beginning of  myfile.cfg&lt;br /&gt;
  -p myfile.cfg ~/result&lt;br /&gt;
&lt;br /&gt;
If you want a more detailed (and potentially overwhelming) log, you can simply add the switches '''--log-debug=all''' or '''--log-info=all''' to the command line, so you can see how things are preprocessed in detail.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[SyntaxWML]] (explains relationship between comments and preprocessor directives)&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74956</id>
		<title>Android</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74956"/>
		<updated>2026-04-04T03:12:34Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Playing controls */ mention reachmap not vanishing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This pages contains some specific information about the Battle for Wesnoth new Android port (1.19+)&lt;br /&gt;
&lt;br /&gt;
== Playing controls ==&lt;br /&gt;
* Tap a unit to select/deselect it. (After deselection, the reachmap won't vanish, but it was deselected, so if you touch another unit the reachmap will change.)&lt;br /&gt;
* Tap a unit, then tap the target hex to show defense stats of that unit and footsteps. (Similar to hover on PC)&lt;br /&gt;
* Tap a unit, then double tap on the target hex to move it. Alternative, you can drag along the path to choose the exact path which the unit is supposed to move by.&lt;br /&gt;
* Drag from attacker unit towards attacked unit to attack.&lt;br /&gt;
* Long press on any hex to show the Right-click context menu that has Recruit/Recall etc.&lt;br /&gt;
&lt;br /&gt;
== The Settings menu (Splash screen) ==&lt;br /&gt;
&lt;br /&gt;
== Logs and debugging steps ==&lt;br /&gt;
* Install adb (Android Debug Bridge) on your computer. Search internet for information about your OS. Install drivers for your phone/tablet if necessary.&lt;br /&gt;
* Enable Developer Mode on your Android device (phone/tablet). Again, the internet is your friend. On newer devices, you need tap Settings &amp;gt; About Phone &amp;gt; Build Number 7 times until it says &amp;quot;You are now a developer&amp;quot;, then go into the Setting &amp;gt; System &amp;gt; Developer Options (newly appeared), and find &amp;quot;USB Debugging&amp;quot; in the menu and turn that on.&lt;br /&gt;
* Connect phone to PC. Do &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; or similar from a terminal/command prompt to see if your device appears on the list and is authorized. Tap ok on your phone if any permission request appears.&lt;br /&gt;
* Run &amp;lt;code&amp;gt;adb logcat -c&amp;lt;/code&amp;gt; (clears existing logs), then &amp;lt;code&amp;gt;adb logcat &amp;gt; log.txt&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; and copy from terminal). Run Wesnoth on phone. Reproduce the crash.&lt;br /&gt;
* stop &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; on PC, and attach the &amp;lt;code&amp;gt;log.txt&amp;lt;/code&amp;gt; to your issue report on github along with detailed steps of the bug, and use the Android label.&lt;br /&gt;
&lt;br /&gt;
(Note: adb can be &amp;lt;code&amp;gt;./adb.exe&amp;lt;/code&amp;gt; on Windows. Use internet for help on any of the steps if needed, this is supposed to be a preliminary guideline. Steps might slightly differ based on manufacturer or Android version.)&lt;br /&gt;
&lt;br /&gt;
=== Enabling taps ===&lt;br /&gt;
It is useful for debugging purposes, especially if you're sharing a screen recording of your bug, to show where you're tapping on the screen in the screen recording. See [https://discussio.zendesk.com/hc/en-gb/articles/4625151970065-How-to-Show-Taps-for-Mobile-Screen-Sharing-on-Android here] for how to enable that.&lt;br /&gt;
&lt;br /&gt;
=== Turning off Developer Mode ===&lt;br /&gt;
Go to System &amp;gt; Developer Options and turn off  the '''Use developer options''' toggle.&lt;br /&gt;
&lt;br /&gt;
== Dev Notes ==&lt;br /&gt;
=== Package manifest (manifest.txt) and download status file (status.properties) ===&lt;br /&gt;
{{DevFeature1.19|19}}&lt;br /&gt;
&lt;br /&gt;
The package manifest file (&amp;lt;code&amp;gt;manifest.txt&amp;lt;/code&amp;gt;) is a file on the Wesnoth sourceforge site that the Android Wesnoth client reads to figure out available packages for download. For example, for Wesnoth 1.19.19 it is located here: [https://sourceforge.net/projects/wesnoth/files/wesnoth/wesnoth-1.19.19/android-data/manifest.txt/download manifest.txt]. This path is mostly hardcoded [https://github.com/wesnoth/wesnoth/blob/ff3ad482074d2698762cffcad08660c77ea1bb2c/packaging/android/app/src/main/java/org/wesnoth/Wesnoth/InitActivity.java#L66-L67 here] with only the version code part changing per release.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;status.properties&amp;lt;/code&amp;gt; file is generated by the Android client to track details of downloaded packages, and is created inside &amp;lt;code&amp;gt;/sdcard/Android/data/org.wesnoth.Wesnoth/files/gamedata&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Version Code scheme (1191601001 - post 1.19.16 fixup) ===&lt;br /&gt;
&amp;lt;code&amp;gt;MmmPPppVVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; - Major version code, so far at 1; since the max versionCode is 21000000 it can go up to 2&lt;br /&gt;
* &amp;lt;code&amp;gt;mm&amp;lt;/code&amp;gt; - Minor version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;PP&amp;lt;/code&amp;gt; - Patch version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;pp&amp;lt;/code&amp;gt; - Android patch version/any other use.&lt;br /&gt;
* &amp;lt;code&amp;gt;VVV&amp;lt;/code&amp;gt; - Reserved for ABI/Variants.&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Rest unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
=== New Version Code scheme draft ===&lt;br /&gt;
This is but one possible idea among many, and is not final.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;MSUUmmPPppVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* 1 - Major version code. Wesnoth's version's first digit is almost always 1, but the max versionCode is 21000000 so it can go upto 2 if needed.&lt;br /&gt;
* S - store identifier (must be greater than 2 to allow upgrade from previous scheme.) For example:&lt;br /&gt;
** &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; - F-Droid&lt;br /&gt;
** &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; - Google Play&lt;br /&gt;
** Others if needed.&lt;br /&gt;
* UU - unused/unspecified.&lt;br /&gt;
* mm - Minor version&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* pp - Android Patch version&lt;br /&gt;
* VV - ABI/Variants&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Last but one digit - Unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
E.g., 1.20.14 with hotfix 1, Fdroid, arm64 ABI would be: &amp;lt;code&amp;gt;120020140102&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Other version code scheme drafts ===&lt;br /&gt;
&lt;br /&gt;
Given that we only have 10 digits to work with (max being 2.1e9, which is signed INT_MAX with some margin), the above scheme is not possible. The PR to remove/disable the existing version codes on f-droid has been rejected, so we're probably stuck with version codes &amp;gt; 1.19e9. &lt;br /&gt;
The highest version code currently (2025-10-02) in use is 1191601002.&lt;br /&gt;
&lt;br /&gt;
Further constraints are:&lt;br /&gt;
* version codes should go up&lt;br /&gt;
* each ABI needs its own version code&lt;br /&gt;
* we may have multiple APK releases for one &amp;quot;regular wesnoth version&amp;quot; to fix android-only issues (android patch version)&lt;br /&gt;
* we may have builds that differ per store (F-droid creates the file /data/dist with contents &amp;quot;F-Droid&amp;quot; during the build process)&lt;br /&gt;
* we may want various variants of builds, that is, a &amp;quot;clean&amp;quot; build, a build with google play integrations, a build with a different integration, and so on. This may or may not be tied to the store the APK is distributed on&lt;br /&gt;
&lt;br /&gt;
Drafts of possible approaches:&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;MMMPPpxxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
* MMM - Combined Major/Minor: 1.19 = 119, but each subsequent minor *or* major bump increases this number by 1. This remains visually the same until 2.0 happens.&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* p - Android patch version&lt;br /&gt;
* V - Build variant (0 is clean, 1 might be google play integrations. Could be a bitfield or an enum)&lt;br /&gt;
* A - ABI (as above)&lt;br /&gt;
* x - Unspecified, available for expanding these fields or adding other flags&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1220320002&amp;lt;/code&amp;gt; would be version 1.22 (or 2.0 or 2.2, but 2 stables from 1.18), patch 3, android patch 2, default (clean) variant, arm64&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMMPPpVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Basically the same thing, just shifted to the right by eating up the unspecified digits, and with the first digits fixed to 12. Leaves 8 &amp;quot;additional epochs&amp;quot; available for future expansion.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1212203202&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMPPpxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Removes the major version digit, freeing up 1 digit. Not functionally different from the major-minor scheme, but reduces the number of available version bumps until epoch change.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1222032002&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74952</id>
		<title>PreprocessorRef</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74952"/>
		<updated>2026-03-29T16:36:11Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* #deprecated */ Add more explanation about #deprecated arguments, and mention optionality&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth loads just one configuration file directly: '''data/_main.cfg'''. However, the '''WML preprocessor''' allows the inclusion of more files. Whenever a WML file is read by Wesnoth, it is passed through the preprocessor.&lt;br /&gt;
&lt;br /&gt;
The preprocessor can interpret a simple language of string expansions known as ''macros''. A macro should always be defined '''before''' the place where it needs to be used.&lt;br /&gt;
&lt;br /&gt;
The preprocessor is applied recursively, so included files will be parsed for macros, and after macro expansion will be parsed for macros again, and so on. As a result, you should not write a recursive macro that references itself, because it will cause errors (but, alas, not necessarily error messages).&lt;br /&gt;
&lt;br /&gt;
== Preprocessor directives ==&lt;br /&gt;
&lt;br /&gt;
The following directives are used to create and use ''macros'', i.e. shortcuts which reduce repetition of information. See [https://www.wesnoth.org/macro-reference.html the macro reference] for the list of predefined core macros.&lt;br /&gt;
&lt;br /&gt;
Macros have scoping rules such that addons have separate preprocessing contexts, meaning that they can be overridden however an author of UMC wishes to override them, without worrying about breaking other add-ons.&lt;br /&gt;
&lt;br /&gt;
The preprocessor has changed several times, so don't expect old Wesnoth versions to behave exactly the same as the current stable and development series.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In multiplayer scenarios, these directives will appear to work only for the host and not for other clients. This is because the preprocessor is run only on the host, and the clients receive the resultant WML from the server. It's particularly important to keep this in mind before using preprocessor conditionals.&lt;br /&gt;
&lt;br /&gt;
=== #define ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax: #define ''symbol'' [''parameters''] ''&amp;lt;newline&amp;gt;'' ''substitution'' #enddef'''&lt;br /&gt;
&lt;br /&gt;
All subsequent occurences of '''{''symbol'' [''arguments'']}''' (see below) will be replaced by the contents of the ''substitution'' block, with all occurrences of any parameter {''parameter''} within ''substitution'' replaced by the corresponding value in ''arguments''. &amp;lt;code&amp;gt;#define-#enddef&amp;lt;/code&amp;gt; blocks cannot be nested inside another &amp;lt;code&amp;gt;#define&amp;lt;/code&amp;gt;, as of Wesnoth 1.19.&lt;br /&gt;
&lt;br /&gt;
As an example, the ENEMY_UNIT macro for the [[#Macro inclusions|macro inclusion]] example below could be defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define ENEMY_UNIT TYPE X Y&lt;br /&gt;
## the ordering above is important, since the preprocessor does not distinguish&lt;br /&gt;
## data into different types; only the ordering is used to determine which&lt;br /&gt;
## arguments apply to which parameters.&lt;br /&gt;
[unit]&lt;br /&gt;
    type={TYPE} ## the unit will be of type TYPE, so different&lt;br /&gt;
                ## instantiations&lt;br /&gt;
                ## of this macro can create different units.&lt;br /&gt;
    x={X}&lt;br /&gt;
    y={Y}&lt;br /&gt;
    side=2 ## the unit will be an enemy, regardless of the parameter&lt;br /&gt;
           ## values. This reduces &amp;quot;repetition of information&amp;quot;,&lt;br /&gt;
           ## since it is no longer necessary to specify&lt;br /&gt;
           ## each created unit as an enemy.&lt;br /&gt;
[/unit]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(See [[SingleUnitWML]] for further information on creating units using WML.)&lt;br /&gt;
&lt;br /&gt;
'''Important note:''' Although macros may look like they're simplifying the code, they do not help with wml bloating. Macros are very good at ''disguising'' WML bloat, but they do nothing to ''alleviate'' it. So instead of using macros to generate redundant and repetitive instructions, you should be considering how to eliminate redundancy through programming techniques of abstraction. The most popular way to improve your code is using custom [[EventWML|events]] and [[InternalActionsWML#.5Bfire_event.5D|fire_event]] tags. See also: [[Wml_optimisation|WML Optimisation]].&lt;br /&gt;
&lt;br /&gt;
==== Whitespace in Macros ====&lt;br /&gt;
&lt;br /&gt;
When expanding a macro, '''''all''''' whitespace in the definition of the macro is preserved. The &amp;lt;tt&amp;gt;#arg&amp;lt;/tt&amp;gt; declarations for optional arguments are removed including the final newline. The body of the optional argument (the default value) is similarly processed just as if it were a macro, so all whitespace is preserved.&lt;br /&gt;
&lt;br /&gt;
There are two main practical implications of these rules:&lt;br /&gt;
&lt;br /&gt;
* When using a macro to define simple constants to be used inline in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#enddef&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_CONSTANT&lt;br /&gt;
42#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* If using a macro inside a quoted string, you should not indent the contents of the macro, as the indentation will be preserved upon macro substitution.&lt;br /&gt;
* Similarly if you use an optional argument in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#endarg&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg OPTIONAL_ARG&lt;br /&gt;
default#endarg&lt;br /&gt;
  key = &amp;quot;composite {OPTIONAL_ARG} value&amp;quot;&lt;br /&gt;
#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #arg ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|7}} &lt;br /&gt;
&lt;br /&gt;
'''Syntax: #arg ''symbol'' ''&amp;lt;newline&amp;gt;'' ''default value'' #endarg'''&lt;br /&gt;
&lt;br /&gt;
Defines an optional argument for a macro along with its default value. Optional arguments can be used to make a macro more flexible and to allow its user to specify certain parameters only when necessary.&lt;br /&gt;
&lt;br /&gt;
For example, one could define a shortcut macro for [message] with only one required argument (the text displayed), but several optional ones:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MESSAGE TEXT&lt;br /&gt;
&lt;br /&gt;
#arg SPEAKER_ID&lt;br /&gt;
narrator#endarg&lt;br /&gt;
&lt;br /&gt;
#arg CAPTION&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg SOUND&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg IMG&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
[message]&lt;br /&gt;
    speaker={SPEAKER_ID}&lt;br /&gt;
    message={TEXT}&lt;br /&gt;
    caption={CAPTION}&lt;br /&gt;
    sound={SOUND}&lt;br /&gt;
    image={IMG}&lt;br /&gt;
[/message]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The caller of the macro can then decide which, if any, of the default values to override:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;Halt!&amp;quot; SPEAKER_ID=&amp;quot;Guard Captain&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Two days pass...&amp;quot; IMG=wesnoth-icon.png SOUND=ambient/morning.ogg}&lt;br /&gt;
{MESSAGE _&amp;quot;...&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Welcome!&amp;quot; CAPTION=_&amp;quot;Elóndra's shop of wonders&amp;quot; IMG=portraits/elves/shyde.png}&lt;br /&gt;
{MESSAGE _&amp;quot;*smash*&amp;quot; SPEAKER_ID=&amp;quot;Bridge Troll&amp;quot; SOUND=mace.ogg}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multiline optional argument defined and called as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg MULTILINE&lt;br /&gt;
[some_tag]&lt;br /&gt;
    some_attribute = &amp;quot;some value&amp;quot;&lt;br /&gt;
[/some_tag]&lt;br /&gt;
#endarg&lt;br /&gt;
...&lt;br /&gt;
#enddef&lt;br /&gt;
&lt;br /&gt;
{MY_MACRO (MULTILINE=[other_tag]&lt;br /&gt;
    other_attribute = &amp;quot;other value&amp;quot;&lt;br /&gt;
[/other_tag])}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' As with #enddef, the final line break before #endarg is included in the default value. This means that if the symbol is used in the middle of a line, you should place the #endarg immediately after the value has ended, without a line break in between.&lt;br /&gt;
&lt;br /&gt;
=== #undef ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#undef ''symbol'' '''&lt;br /&gt;
&lt;br /&gt;
Removes the previous definition of the macro named ''symbol''. Wesnoth expects this to be done when overriding an existing macro, and will warn you if you redefine an existing macro without an explicit #undef before it.&lt;br /&gt;
&lt;br /&gt;
=== Inclusion directive {} ===&lt;br /&gt;
&lt;br /&gt;
This directive can be used to include macros, single files or sets of files from a target directory.&lt;br /&gt;
&lt;br /&gt;
==== File/directory inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''path''}'''&lt;br /&gt;
&lt;br /&gt;
Includes the file with the specified ''path'', which will in turn run the preprocessor on it and perform any required substitutions or inclusions within it. The ''path'' may not contain ''..'' or the inclusion will be skipped.&lt;br /&gt;
&lt;br /&gt;
The exact location in which the ''path'' will be resolved will depend on its prefix:&lt;br /&gt;
&lt;br /&gt;
* '''{''path''}''': If ''path'' isn't a known macro (see below), the game will assume it's a relative path to a file in the main game '''data/''' directory and include it.&lt;br /&gt;
* '''{~''path''}''': As above, but instead of the game data directory, the path is resolved relative to the user '''data/''' directory, where user made add-ons can normally be found.&lt;br /&gt;
* '''{./''path''}''': The path is resolved relative to the location of the current file containing this inclusion.&lt;br /&gt;
&lt;br /&gt;
Information for locating the user data and game data directories can be found in [[EditingWesnoth]].&lt;br /&gt;
&lt;br /&gt;
Forward slashes ('''/''') should '''always''' be used as the path delimiter, even if your platform uses a different symbol such as colons (''':''') or backslashes ('''\''')! It is also very important to respect the '''actual letter case''' used to name files and directories for compatibility with case-sensitive filesystems on Unix-based operating systems.&lt;br /&gt;
&lt;br /&gt;
When ''path'' points to a directory instead of a file, the preprocessor will include all files found within with the '''.cfg''' extension, in alphabetical order; files without this extension (such as '''.map''' or '''.png''' files) are ignored.&lt;br /&gt;
&lt;br /&gt;
Some directories are handled in a special fashion according to their contents:&lt;br /&gt;
&lt;br /&gt;
* If there's a file named '''_main.cfg''' in the target directory, only that file will be included and preprocessed. It may include other files from its own directory or subdirectories within it, of course. This is used for managing WML directories as self-contained packages, like user made add-ons.&lt;br /&gt;
* If there are files named '''_main.cfg''' in subdirectories of the target and there isn't one in the target itself, they will be all preprocessed. Given the following layout:&lt;br /&gt;
 dir/&lt;br /&gt;
 dir/a/_main.cfg&lt;br /&gt;
 dir/a/other.cfg&lt;br /&gt;
 dir/b/_main.cfg&lt;br /&gt;
 dir/b/other.cfg&lt;br /&gt;
 dir/other.cfg&lt;br /&gt;
Using '''{dir}''' will cause dir/a/_main.cfg, dir/b/_main.cfg and dir/other.cfg to be included.&lt;br /&gt;
* If there's a file named '''_final.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''after'' all the other files in the directory.&lt;br /&gt;
* If there's a file named '''_initial.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''before'' all the other files in the directory.&lt;br /&gt;
&lt;br /&gt;
==== Macro inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''symbol'' [''arguments''] [''optional arguments'']}'''&lt;br /&gt;
&lt;br /&gt;
If the macro named ''symbol'' is defined, the preprocessor will replace this instruction by the expression ''symbol'' was previously defined as, using ''arguments'' as parameters. The number of normal arguments must be exactly the same as in the original definition or an error will occur. Optional arguments can only be placed '''after''' all normal arguments, however they can be specified in any order desired.&lt;br /&gt;
&lt;br /&gt;
You can create multiple word arguments by using parentheses to delimit the contents. For example, in '''{ENEMY_UNIT Wolf Rider 18 24}''' the four words will be interpreted as separate arguments and cause the preprocessor to fail since the macro was defined above with only three; instead, you should use '''{ENEMY_UNIT (Wolf Rider) 18 24}'''.&lt;br /&gt;
&lt;br /&gt;
Optional arguments can also be delimited by placing parentheses, however they must be placed around both the argument name '''and''' content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; (SPEAKER_ID=Bridge Troll) } # Correct&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; SPEAKER_ID=(Bridge Troll) } # Wrong&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way even complex arguments can be passed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MODIFY_UNIT (&lt;br /&gt;
    [filter_adjacent]&lt;br /&gt;
        canrecruit=yes&lt;br /&gt;
    [/filter_adjacent]&lt;br /&gt;
    ) side 2}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the name of an existing macro as the name of a macro argument is possible, but the argument will always take precedence over the original macro:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define VARIABLE&lt;br /&gt;
#enddef&lt;br /&gt;
#define MACRO VARIABLE&lt;br /&gt;
    {VARIABLE} # is calling for the argument, not for the macro above&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #ifdef and #ifndef ===&lt;br /&gt;
&lt;br /&gt;
Unlike the other preprocessor directives, '''#ifdef''' and '''#ifndef''' are not mere conveniences. They are often necessary to distinguish between different gameplay modes or difficulties (see [[#Built-in macros|Built-in macros]] below).&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifdef ''symbol'' ''substitution-if-defined'' [#else ''substitution-if-not-defined'' ] #endif'''&lt;br /&gt;
&lt;br /&gt;
If ''symbol'' has been defined with '''#define''' or as a built-in macro, the whole block will be replaced by ''substitution-if-defined''.  If not, it will be replaced by ''substitution-if-not-defined'' if it is available.&lt;br /&gt;
&lt;br /&gt;
'''#ifndef''' is the exact opposite of '''#ifdef''', reversing the logic:&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifndef ''symbol'' ''substitution-if-not-defined''  [#else ''substitution-if-defined''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifhave and #ifnhave ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifhave ''path'' ''substitution-if-path-exists'' [#else ''substitution-if-path-does-not-exist''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Checks for the existence of a file. Uses the same relative paths as [[#Inclusion_directive_.7B.7D|include directives]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifhave ~add-ons/My_Addon/_main.cfg&lt;br /&gt;
    {MY_ADDON_MACROS}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnhave'''  does the opposite of '''#ifhave''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnhave ''path'' ''substitution-if-path-does-not-exist'' [#else ''substitution-if-path-exists''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifver and #ifnver ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-met'' [#else ''substitution-if-condition-not-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Compares a version number defined in a macro against an argument for conditional block inclusions, like ''#ifdef'' and ''#ifhave''. ''operator'' is one of ''=='' (equal), ''!='' (not equal), ''&amp;lt;'' (less), ''&amp;lt;='' (less or equal), ''&amp;gt;'' (greater), ''&amp;gt;='' (greater or equal). The specified ''symbol'' should have been previously defined as plain text without more macro inclusions within it, and it must not require any arguments.&lt;br /&gt;
&lt;br /&gt;
Versions with text suffixes are sorted in binary order and come after all versions with the same number. The most common suffixes begin with &amp;quot;+&amp;quot;, but as this represents multiple possible versions, comparing versions against it is not recommended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;gt;= 1.9.7+&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7+, 1.9.8 or later!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#else&lt;br /&gt;
#ifver WESNOTH_VERSION == 1.9.7&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7, and I’ll include some workaround code for bug #9001!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#endif&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnver'''  does the opposite of '''#ifver''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-not-met'' [#else ''substitution-if-condition-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #error ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#error [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to fail unconditionally upon encountering the line. For add-ons, this will cause the game to display an error and return to the titlescreen if the add-on is required for the user's action (such as playing a campaign or loading a saved game). For core WML, this will cause the game to quit entirely.&lt;br /&gt;
&lt;br /&gt;
Please note that in spite of the example below, it is '''not''' advisable to use this mechanism in published add-ons for version or feature-checking, since the message is not displayed in a form that permits translation and the additional trace information may confuse players. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#error This add-on does not support Wesnoth 1.11.10!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #warning ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#warning [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to emit a warning upon encountering the line. The message will '''only''' be relayed to stderr, not to the player in the game UI. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#warning On Wesnoth 1.11.9 or earlier, bug workarounds enabled!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #deprecated ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 1 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 2 [''version'' ''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 3 [''version'' ''message'']'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 4 [''message'']'''&lt;br /&gt;
&lt;br /&gt;
The first argument is the deprecation level, while ''message'' is the optional deprecation message, and ''version'' is the optional Wesnoth version where this deprecated file/macro is supposed to be removed. (Although optional, the recommended usage is to provide ''message'' and ''version''.)&lt;br /&gt;
&lt;br /&gt;
The effect of this directive depends on whether it appears within a macro definition.&lt;br /&gt;
&lt;br /&gt;
* If it appears at file level, outside any macro definition, then it immediately outputs a warning saying that the file is deprecated, with the provided message. Multiple '''#deprecated''' directives at toplevel in a single file will result in separate messages.&lt;br /&gt;
* If it appears inside a macro definition ('''#define ... #enddef'''), then it doesn't output anything. Instead, it marks the macro as deprecated. When that macro is later used, only then will the preprocessor output a warning saying that the macro is deprecated, with the provided message. Multiple '''#deprecated''' directives within a single macro will be merged into one message.&lt;br /&gt;
&lt;br /&gt;
Note that deprecation messages will only appear if they have been set to. {{DevFeature1.13|12}} This can be done by enabling debug mode, or by going to Advanced Preferences and setting the log-level for the deprecation logdomain. (This can also be done on the command-line.)&lt;br /&gt;
&lt;br /&gt;
If you provide a deprecation level of 2 or 3, it is required to indicate the earliest version in which the feature could be removed. However, if you provide a deprecation level of 1 or 4, any provided ''version'' will instead be parsed as part of the message, so you will probably not want to provide one at all. Other deprecation levels are not valid. See the documentation for [[InterfaceActionsWML#.5Bdeprecated_message.5D|[deprecated_message]]] for the meaning of the various ''level'' values.&lt;br /&gt;
&lt;br /&gt;
== Built-in macros ==&lt;br /&gt;
&lt;br /&gt;
The following macros are automatically defined with empty contents (unless specified otherwise) by the game engine depending on the configuration or gameplay mode.&lt;br /&gt;
&lt;br /&gt;
Note that except during an actual game, '''MULTIPLAYER''', '''EDITOR''' and previous campaign defines, are not guaranteed to be undefined, especially when coming back to the titlescreen. So it is not enough to hide contents inside of an #ifdef to prevent them from being seen by the campaign selection dialog, for example for multiplayer specific '''[campaign]'''s or '''[modification]'''s '''type=mp''' must be used. &lt;br /&gt;
&lt;br /&gt;
* A campaign define symbol (see ''define'' in [[CampaignWML]]): defined when playing a single-player campaign.&lt;br /&gt;
* A campaign difficulty level, usually '''EASY''', '''NORMAL''' or '''HARD''' (see ''difficulties'' in [[CampaignWML]]): defined according to the chosen difficulty when starting a single-player campaign, also stored in saved games.&lt;br /&gt;
* '''MULTIPLAYER''': defined when in multiplayer mode.&lt;br /&gt;
* '''EDITOR''': defined when running the built-in map editor.&lt;br /&gt;
* '''DEBUG_MODE''': defined when the game has been launched in debug mode (i.e. with '''-d''' or '''--debug''' in the command line). Can also be set by typing &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; to bring up [[CommandMode]], then typing &amp;lt;code&amp;gt;debug&amp;lt;/code&amp;gt;, and then restarting the scenario.&lt;br /&gt;
* '''APPLE''': defined while processing the main game data when running on Mac OS X. This primarily exists to switch Control for Command in hotkeys, which is why there are no defines for other platforms.&lt;br /&gt;
* '''WESNOTH_VERSION''': defined containing just the game version number when running the WML preprocessor.&lt;br /&gt;
* '''CURRENT_FILE''': Expands to the name of the current WML file.&lt;br /&gt;
* '''CURRENT_DIRECTORY''': Expands to the preprocessor path of the parent directory for the current WML file (e.g. for &amp;lt;code&amp;gt;&amp;amp;lt;user data dir&amp;amp;gt;/data/add-ons/My_Addon/_main.cfg&amp;lt;/code&amp;gt; this evaluates to &amp;lt;code&amp;gt;~add-ons/My_Addon&amp;lt;/code&amp;gt;). &lt;br /&gt;
* '''LEFT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;{&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''RIGHT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;}&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''SCHEMA_VALIDATION''': defined if the validator is being run.&lt;br /&gt;
* '''__WMLUNITS__''': defined when the tool to create [https://units.wesnoth.org units.wesnoth.org] is being run.&lt;br /&gt;
&lt;br /&gt;
A ''very large'' number of additional macros are provided as part of the default game core WML. For a full list of those, check the [https://www.wesnoth.org/macro-reference.html macro reference].&lt;br /&gt;
&lt;br /&gt;
== Command-line preprocessor ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
Or the short form:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: -p ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
You can specify a list of predefined defines with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-defines=DEFINE1,DEFINE2,etc'''&lt;br /&gt;
&lt;br /&gt;
comma separated list of defines to be used by '--preprocess' command. If 'SKIP_CORE' is in the define list the data/core won't be preprocessed.&lt;br /&gt;
&lt;br /&gt;
The command will first preprocess '''data/core/macros''' and '''data/core/terrain-graphics''', and afterwards the specified path. You can specify a single file to be preprocessed (if you want to preprocess multiple separate files, you'll need to run a different command line for each one), or an entire directory, which will be preprocessed according to the rules used by the inclusion directive above.&lt;br /&gt;
&lt;br /&gt;
The resulting preprocessed files will be written in the target directory. There will be two types of files: .cfg files --- the normal ones, and .plain files containing line markers and textdomain changes.&lt;br /&gt;
&lt;br /&gt;
If by chance, the simple macro define doesn't suffice, you can use:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-input-macros &amp;lt;file&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
To import an existing file that contains macros, and they will be available in the defines database before processing the specified files.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility to export the preprocessed defines/macro list with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-output-macros [&amp;lt;target file&amp;gt;]'''&lt;br /&gt;
&lt;br /&gt;
This file could be fed to the 'input-macros' argument next time you run it. For example, a scenario would be: parsing just the core first time, and for the intended target files, you would add SKIP_CORE but import the generated macros file - that will be faster than preprocessing the core again. If the target file is not specified, the output file will be _MACROS_.cfg in the target directory of the preprocess's command.&lt;br /&gt;
&lt;br /&gt;
If ''file/directory'' and ''target directory'' are not absolute paths, they will be considered relative to the current directory.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&lt;br /&gt;
* Preprocess the entire tutorial dir, and write the results in the ~/result folder:&lt;br /&gt;
 -p ~/wesnoth/data/campaigns/tutorial ~/result&lt;br /&gt;
* Add the MULTIPLAYER define to the list and preprocess a scenario's config file:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign/scenarios/01_First_Scenario.cfg ~/result --preprocess-defines=MULTIPLAYER&lt;br /&gt;
* Add the MY_CAMPAIGN and HARD defines before preprocessing a campaign's files:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign ~/result --preprocess-defines=MY_CAMPAIGN,HARD&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
 -p data/gui/macros/_initial.cfg  /tmp --preprocess-output-macros=macros&lt;br /&gt;
 -p myfile.cfg ~/result --preprocess-input-macros=/tmp/macros&lt;br /&gt;
&lt;br /&gt;
When it starts getting complicated, such as a file that depends on multiple other files, it is probably easiest to simply &amp;quot;include&amp;quot; the dependencies:&lt;br /&gt;
&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
  Add {gui/macros/_initial.cfg} to the beginning of  myfile.cfg&lt;br /&gt;
  -p myfile.cfg ~/result&lt;br /&gt;
&lt;br /&gt;
If you want a more detailed (and potentially overwhelming) log, you can simply add the switches '''--log-debug=all''' or '''--log-info=all''' to the command line, so you can see how things are preprocessed in detail.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[SyntaxWML]] (explains relationship between comments and preprocessor directives)&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Maintenance_tools&amp;diff=74922</id>
		<title>Maintenance tools</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Maintenance_tools&amp;diff=74922"/>
		<updated>2026-03-24T11:14:32Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* wmllint */ Explain no-icon flag based on code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Wesnoth source code distribution includes a couple of tools intended to help authors maintain campaigns, faction &amp;amp; unit packs, and other WML resources. These&lt;br /&gt;
are:&lt;br /&gt;
 &lt;br /&gt;
; wmlscope: a cross-reference lister, useful for finding unresolved macro and resource-file references.&lt;br /&gt;
&lt;br /&gt;
; wmllint: a utility for sanity-checking WML syntax and porting your old WML to the current version of WML.  &lt;br /&gt;
&lt;br /&gt;
; wmlindent: a utility for reindenting WML to a uniform style.&lt;br /&gt;
&lt;br /&gt;
; GUI.pyw: a graphical interface&lt;br /&gt;
&lt;br /&gt;
== General Information ==&lt;br /&gt;
&lt;br /&gt;
You will need a Python 3 interpreter on your system to use these tools.  Linux, *BSD, and Mac OS/X should already have Python 3 installed; for Windows it's a free download&lt;br /&gt;
from http://www.python.org.  You will also need to know how to run command-line tools on your system.&lt;br /&gt;
&lt;br /&gt;
If you're working with Debian or Ubuntu you might have to install the package wesnoth-1.16-tools (or the convenient version).&lt;br /&gt;
 sudo apt install wesnoth-1.16-tools&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All three tools will require you to supply a &amp;lt;i&amp;gt;directory list&amp;lt;/i&amp;gt;.  This is a set of directories containing the WML files you want to work on.&lt;br /&gt;
&lt;br /&gt;
This page is intended as documentation for users.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;Note to Windows Users:&amp;lt;/u&amp;gt; This means you have to run it from the '''Command Line'''. The command line may be reached by hitting Start, then Run, then &amp;quot;cmd&amp;quot; or &amp;quot;command&amp;quot; depending on your version of Windows.&lt;br /&gt;
&lt;br /&gt;
Example uses:&lt;br /&gt;
 python wmllint path\to\files&lt;br /&gt;
 python wmlindent path\to\files&lt;br /&gt;
&lt;br /&gt;
Another example:&lt;br /&gt;
 &amp;quot;C:\Program Files\Python3.7\python.exe&amp;quot; data\tools\wmllint --dryrun data\core data\{multiplayer,themes} data\campaigns &lt;br /&gt;
(You have to specify the full directory path to the executable if you don't have your environment variables set up correctly).&lt;br /&gt;
The first thing you type is the path to your python executable, followed by a space. The second thing you type is the path to the desired script to run, followed by a space. The third thing you type is the path to the folder (or file) to be processed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''A convenient way of running wmllint''' on Linux (Debian or Ubuntu) and Windows in comparison, '''Linux''':&lt;br /&gt;
&lt;br /&gt;
Assuming we're working with wesnoth 1.16 or more advanced versions.&lt;br /&gt;
 python3 /usr/share/games/wesnoth/1.16/data/tools/wmllint --dryrun /usr/share/games/wesnoth/1.16/data/core ~/.local/share/wesnoth/1.16/data/add-ons/A_Simple_Campaign 1&amp;gt;wmllint-run.log 2&amp;gt;wmllint-err.log&lt;br /&gt;
I have these commands inside of a file named&lt;br /&gt;
 wmllint_dryrun_ASC.sh&lt;br /&gt;
and execute it by opening a shell (=terminal, console, command window, bash,...), navigating into the directory with that file and typing&lt;br /&gt;
 bash wmllint_dryrun_ASC.sh&lt;br /&gt;
The python3 command should be automatically known on Debian. The path to the script tells the python interpreter what to execute. --dryrun: A wmllint option, see below. The path to the core files is needed to let wmllint know about e.g. defined core units, followed by the path to the add-on that shall be checked; the last two commands cause the result of the wmllint usage to be written into those files in the same directory as the script.&lt;br /&gt;
'''Windows''', this is logically exactly the same as the Linux shell script above, so if you are on a Mac you can probably conclude how you need to adapt the paths:&lt;br /&gt;
 E:\Python37\python.exe E:\Programme\Wesnoth_1.16_git\data\tools\wmllint --dryrun E:\Programme\Wesnoth_1.16_git\data\core E:\Programme\Wesnoth_1.16_git\userdata\data\add-ons\A_Simple_Campaign 1&amp;gt;wmllint-run.log 2&amp;gt;wmllint-err.log&lt;br /&gt;
This is the content of a .txt file, whose extension I rename to .bat and double-click onto it. Opening a command window is not needed this way.&lt;br /&gt;
Since Python isn't natively installed on windows and I don't have environment variables set, the full path to python.exe is given. If your directories contain spaces it may help to include the path in quotes:&lt;br /&gt;
 &amp;quot;C:\Programs\Battle for Wesnoth 1.16\data\tools\wmllint&amp;quot;&lt;br /&gt;
Remember that you do not need to enter all of the commands/paths at once. If it doesn't work, start with only &amp;quot;python&amp;quot; or &amp;quot;C:\Python37\python.exe&amp;quot; or the like and interpret the error messages that you get. If you get an &amp;quot;unknown command&amp;quot;, python isn't installed or environment variables aren't set correctly. After that, you can add the later commands one by one.&lt;br /&gt;
&lt;br /&gt;
== wmlscope ==&lt;br /&gt;
&lt;br /&gt;
The main use for &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; is to find WML macro references without definitions and references to resource files (sounds and images) that don't exist.  These are difficult to spot from in-game because they usually result in silence or a missing image rather than actual broken game logic (see [https://github.com/wesnoth/wesnoth/issues/5332 issue 5332] for more info).  They may happen because of typos in your WML, or because the name of a macro or the location of a resource file changed between versions of the game.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; also checks macro invocations for consistency.  It will complain&lt;br /&gt;
if a macro is called with the wrong number of arguments.  In most cases it can deduce information about the type of the literal expected to be passed to a given macro argument by looking at the name of the formal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;wikitable&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Meaning&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Formals requiring this type&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Literals of this type&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;side&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a single side number&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SIDE, *_SIDE, SIDE[0-9]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a numeric or &amp;quot;global&amp;quot;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;numeric&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a numeric integer literal&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SIDE, X, Y, RED, GREEN, BLUE, TURN, PROB, LAYER, TIME, *_SIDE, *NUMBER, *AMOUNT, *COST, *RADIUS, *_X, *_Y, *_INCREMENT, *_FACTOR, *_TIME, *_SIZE, DURATION&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;\-?[0-9]+&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;percentage&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a percentage&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;*PERCENTAGE&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a numeric or 0\.[0-9]+&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;position&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a single x,y coordinate&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;POSITION, *_POSITION, BASE&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;-?[0-9]+,-?[0-9]+&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;span&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a set of coordinates or coordinate ranges&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;*_SPAN&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a numeric, position or ([0-9]+\-[0-9]+,?|[0-9]+,?)+&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;alliance&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a set of side numbers&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SIDES, *_SIDES&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a span, or the empty string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;range&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;an attack range&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;RANGE&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;quot;melee&amp;quot; or &amp;quot;ranged&amp;quot;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;alignment&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;an alignment keyword&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;ALIGN&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;quot;lawful&amp;quot; or &amp;quot;neutral&amp;quot; or &amp;quot;chaotic&amp;quot;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;types&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a set of unit types&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;TYPES&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a shortname, name, or anything that contains spaces and matches no other type&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;terrain_pattern&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a set of terrain codes to filter&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;ADJACENT*, TERRAINLIST*, *TERRAIN_PATTERN, RESTRICTING&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a terrain_code or name&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;terrain_code&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a single terrain code, perhaps with overlay&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;TERRAIN*, *TERRAIN&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a shortname or (\*|[A-Z][a-z]+)\^([A-Z][a-z\\|/]+\Z)?&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;shortname&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a terrain code or a short, capitalized variable name&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[A-Z][a-z][a-z]?&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;name&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a name or identifier&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;NAME, VAR, IMAGESTEM, ID, FLAG, *_NAME, *_ID, NAMESPACE, BUILDER, *_VAR&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;anything without spaces that matches no other type&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;optional_string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a string value (may be empty)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;ID_STRING, NAME_STRING, DESCRIPTION, IPF&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a string, or the empty string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a nonempty string not matching any of the preceding types&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;STRING, TYPE, TEXT, *_STRING, *_TYPE, *_TEXT&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a shortname, a name, a stringliteral, or anything that contains spaces and matches no other type&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;stringliteral&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a string in doublequotes or a translated string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;quot;.*&amp;quot; or _.* but not _[a-z].*&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;image&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;an image path, perhaps with [[ImagePathFunctionWML|image path functions]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;*IMAGE, PROFILE&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[A-Za-z0-9{}.][A-Za-z0-9_/+{}.-]*\.(png|jpg)(?=(~.*)?)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;sound&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a music or sound filename&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;MUSIC, SOUND&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;string ending with &amp;quot;.wav&amp;quot; or &amp;quot;.ogg&amp;quot;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;filter&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[FilterWML|WML filter]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;FILTER&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;any non-quoted string containing &amp;quot;=&amp;quot;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;WML&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;arbitrary WML fragment&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;WML, *_WML&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;any non-quoted string containing &amp;quot;=&amp;quot;, or the empty string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;affix&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a prefix, suffix, or infix for a variable name&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;AFFIX, *AFFIX, POSTFIX, ROTATION&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;a shortname or name, or the empty string&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;any&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;anything&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;*VALUE, [ARS][0-9]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;anything&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the actual argument is a macro call {.*}, then it matches any formal.  Otherwise, if the formal has an identifiable type, &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; will complain if the actual literal does not match it.&lt;br /&gt;
&lt;br /&gt;
The argument type check only works in macro calls that fit on a single line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; has many options for changing the reports it generates; the more advanced ones are intended for Wesnoth developers.  Invocations for the most commonly useful reports it generates are included in &amp;lt;i&amp;gt;data/tools/Makefile&amp;lt;/i&amp;gt; of the source distribution. Here are some of those reports:&lt;br /&gt;
&lt;br /&gt;
; make unresolved: Report on unresolved macro calls and resource references; also report macro argument-type mismatches.  (This is what you are most likely to want to do). &lt;br /&gt;
&lt;br /&gt;
; make all: Report all macro and resource file references, not just unresolved ones.&lt;br /&gt;
&lt;br /&gt;
; make collisions: Report on duplicate resource files.&lt;br /&gt;
&lt;br /&gt;
For more advanced users, or those who want to understand what the canned Makefile invocations are doing, here is a summary of &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt;'s options. Some of the more advanced options will require you to understand &lt;br /&gt;
[http://docs.python.org/lib/re-syntax.html Python regular expressions].&lt;br /&gt;
&lt;br /&gt;
; -h, --help:                 Emit a help message and quit&lt;br /&gt;
; -c, --crossreference:       Report resolved macro references (implies &amp;lt;tt&amp;gt;-w 1&amp;lt;/tt&amp;gt;)&lt;br /&gt;
; -C, --collisions:           Report duplicate resource files   &lt;br /&gt;
; -d, --deflist:              Make definition list.  (This one is for campaign server maintainers.)&lt;br /&gt;
; -e &amp;lt;i&amp;gt;regexp&amp;lt;/i&amp;gt;, --exclude &amp;lt;i&amp;gt;regexp&amp;lt;/i&amp;gt;:   Ignore files matching the specified regular expression. &lt;br /&gt;
; -f &amp;lt;i&amp;gt;dir&amp;lt;/i&amp;gt;, --from &amp;lt;i&amp;gt;dir&amp;lt;/i&amp;gt;:         Report only on macros defined under &amp;lt;i&amp;gt;dir&amp;lt;/i&amp;gt;&lt;br /&gt;
; -l, --listfiles:            List files that will be processed&lt;br /&gt;
; -r &amp;lt;i&amp;gt;ddd&amp;lt;/i&amp;gt;, --refcount=&amp;lt;i&amp;gt;ddd&amp;lt;/i&amp;gt;:     Report only on macros with references in exactly &amp;lt;i&amp;gt;ddd&amp;lt;/i&amp;gt; files.&lt;br /&gt;
; -t &amp;lt;i&amp;gt;TYPELIST&amp;lt;/i&amp;gt;, --typelist &amp;lt;i&amp;gt;TYPELIST&amp;lt;/i&amp;gt;: List actual &amp;amp; formal argtypes for calls in fname&lt;br /&gt;
; -u, --unresolved:           Report unresolved macro references&lt;br /&gt;
; -w, --warnlevel:            Set to 1 to warn of duplicate macro definitions&lt;br /&gt;
; -p, --progress:             Show progress&lt;br /&gt;
; --force-used reg:           Ignore reference count 0 on names matching regexp&lt;br /&gt;
; --extracthelp:              Extract help from macro definition comments.&lt;br /&gt;
; --unchecked:                Report all macros with untyped formals.&lt;br /&gt;
; --version:                  show program's version number and exit&lt;br /&gt;
&lt;br /&gt;
These options are used with a list of directories as arguments; if none is given,&lt;br /&gt;
&amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; behaves as though the current directory had been specified as a&lt;br /&gt;
single argument.  Each directory is treated as a separate domain for&lt;br /&gt;
macro and resource visibility purposes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; recognizes two kinds of namespace, exporting and non-exporting.&lt;br /&gt;
Exporting namespaces make all their resources and macro names&lt;br /&gt;
globally visible.  You can make a namespace exporting by embedding&lt;br /&gt;
a comment like this in it:&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: export=yes&lt;br /&gt;
&lt;br /&gt;
Wesnoth core data is an exporting namespace.  Campaigns are non-exporting;&lt;br /&gt;
they should contain the declaration&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: export=no&lt;br /&gt;
&lt;br /&gt;
somewhere.  &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; will complain when it sees a namespace with no export&lt;br /&gt;
property, then treat it as non-exporting.&lt;br /&gt;
&lt;br /&gt;
You can tell &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; to ignore stretches of config files&lt;br /&gt;
with the following magic comments:&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: start ignoring&lt;br /&gt;
    # wmlscope: stop ignoring&lt;br /&gt;
&lt;br /&gt;
Similarly, you can tell &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; to ignore multiple or duplicate macro&lt;br /&gt;
definitions in a range of lines with the following magic comments:&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: start conditionals&lt;br /&gt;
    # wmlscope: stop conditionals&lt;br /&gt;
&lt;br /&gt;
The following magic comment:&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: prune FOOBAR&lt;br /&gt;
&lt;br /&gt;
will cause &amp;lt;tt&amp;gt;wmlscope&amp;lt;/tt&amp;gt; to forget about all but one of the definitions of&lt;br /&gt;
&amp;lt;tt&amp;gt;FOOBAR&amp;lt;/tt&amp;gt; it has seen.  This will be useful mainly for symbols that have&lt;br /&gt;
different definitions enabled by an &amp;lt;tt&amp;gt;#ifdef&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Due to a preprocessor limitation, inline macros cannot contain a documentation&lt;br /&gt;
string. If you need to document these macros in the HTML macro reference, you&lt;br /&gt;
can use the following directive:&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: docstring FOOBAR&lt;br /&gt;
&lt;br /&gt;
The docstring for the FOOBAR macro will be collected until a non-comment line,&lt;br /&gt;
a &amp;lt;tt&amp;gt;#define&amp;lt;/tt&amp;gt; or another &amp;lt;tt&amp;gt;# wmlscope: docstring&amp;lt;/tt&amp;gt; are found. External&lt;br /&gt;
docstrings '''''must''''' be defined before the macro to which they refer; defining&lt;br /&gt;
two or more external docstrings keeps only the most recent one, but having both an&lt;br /&gt;
external and an internal docstring is allowed (in this case, the internal one&lt;br /&gt;
will be appended to the external one in the macro reference).&lt;br /&gt;
&lt;br /&gt;
This tool does catch one kind of implicit reference: if an attack name&lt;br /&gt;
is specified but no icon is given, the attack icon will default to&lt;br /&gt;
a name generated from the attack name.  This behavior can be suppressed&lt;br /&gt;
by adding a magic comment containing the string &amp;quot;no-icon&amp;quot; to the &amp;lt;tt&amp;gt;name=&amp;lt;/tt&amp;gt;&lt;br /&gt;
line.&lt;br /&gt;
&lt;br /&gt;
The checking done by this tool has a couple of flaws:&lt;br /&gt;
&lt;br /&gt;
(1) It doesn't actually evaluate file inclusions.  Instead, any&lt;br /&gt;
macro definition satisfies any macro call made under the same&lt;br /&gt;
directory.  Exception: when an &amp;lt;tt&amp;gt;#undef&amp;lt;/tt&amp;gt; is detected, the macro is&lt;br /&gt;
tagged local and not visible outside the span of lines where it was&lt;br /&gt;
defined.&lt;br /&gt;
&lt;br /&gt;
(2) It doesn't read &amp;lt;tt&amp;gt;[binary_path]&amp;lt;/tt&amp;gt; tags, as this would require&lt;br /&gt;
implementing a WML parser.  Instead, it assumes that a resource-file&lt;br /&gt;
reference can be satisfied by any matching image file from anywhere&lt;br /&gt;
in the same directory it came from.  The resources under the '''''first'''''&lt;br /&gt;
directory argument (only) are visible everywhere.&lt;br /&gt;
&lt;br /&gt;
(3) A reference with embedded {}s in a macro will have the macro's&lt;br /&gt;
formal args substituted in at WML evaluation time.  Instead, this&lt;br /&gt;
tool treats each {} as a .* wildcard and considers the reference to&lt;br /&gt;
match '''''every''''' resource filename that matches that pattern.&lt;br /&gt;
Under appropriate circumstances this might report a resource filename&lt;br /&gt;
statically matching the pattern as having been referenced even&lt;br /&gt;
though none of the actual macro calls would actually generate it.&lt;br /&gt;
&lt;br /&gt;
Problems (1) and (2) imply that this tool might conceivably report&lt;br /&gt;
that a reference has been satisfied when under actual&lt;br /&gt;
WML-interpreter rules it has not.&lt;br /&gt;
&lt;br /&gt;
The reporting format is compatible with GNU Emacs compile mode.&lt;br /&gt;
&lt;br /&gt;
For debugging purposes, an in-line comment of the form&lt;br /&gt;
&lt;br /&gt;
    # wmlscope: warnlevel NNN&lt;br /&gt;
&lt;br /&gt;
sets the warning level.&lt;br /&gt;
&lt;br /&gt;
== wmllint ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; is a tool for migrating your WML to the current version.  It handles two problems: &lt;br /&gt;
&lt;br /&gt;
* Resource files and macro names may change between versions of the game. &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; knows about these changes and will tweak your WML to fit where it can.&lt;br /&gt;
&lt;br /&gt;
* Between 1.2.x and 1.3.1 the terrain-coding system used in map files underwent a major change. It changed again in a minor way between 1.3.1 and 1.3.2. If you port such old code, use &amp;lt;tt&amp;gt;wmllint-1.4&amp;lt;/tt&amp;gt;, which is located in the same directory as &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;. It will translate your maps for you, unless you use custom terrains in which case you will have to do it by hand.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; also performs various sanity-checking operations, reporting:&lt;br /&gt;
&lt;br /&gt;
* unbalanced tags&lt;br /&gt;
* strings that need a translation mark and do not have them&lt;br /&gt;
* strings that have a translation mark and should not&lt;br /&gt;
* translatable strings containing macro references &lt;br /&gt;
* filter references by description= (id= in 1.5) not matched by an actual unit&lt;br /&gt;
* abilities or traits without matching special notes, or vice-versa&lt;br /&gt;
* consistency between recruit= and recruitment_pattern= instances&lt;br /&gt;
* double space after punctuation in translatable strings.&lt;br /&gt;
* unknown races or movement types in units&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; takes a directory-path argument specifying the WML directories to work on.  It will modify any cfg and map files under those directories that need to be changed.  Here is a summary of its options:&lt;br /&gt;
&lt;br /&gt;
; -h, --help:                 Emit a help message and quit.&lt;br /&gt;
; -c, --clean:                Clean up -bak files.&lt;br /&gt;
; -D, --diffs:                Display diffs between converted and unconverted files.&lt;br /&gt;
; -d, --dryrun:               List changes (-v) but don't perform them.&lt;br /&gt;
; -r, --revert:               Revert the conversion from the -bak files.&lt;br /&gt;
; -m, --missing:              Warn about tags without side= keys now applying to all sides.&lt;br /&gt;
; -s, --stripcr:              Convert DOS-style CR/LF to Unix-style LF.&lt;br /&gt;
; -v, --verbose:              Set verbosity; more details below.&lt;br /&gt;
; -K, --known:                Suppress check for unknown unit types, recruits, races, scenarios, etc.&lt;br /&gt;
; -S, --nospellcheck:         Suppress spellchecking&lt;br /&gt;
; --version:                  show program's version number and exit&lt;br /&gt;
&lt;br /&gt;
The verbosity option works like this:&lt;br /&gt;
&lt;br /&gt;
; -v:          lists changes.&lt;br /&gt;
; -v -v:       warns of maps already converted.&lt;br /&gt;
; -v -v -v:    names each file before it's processed.&lt;br /&gt;
; -v -v -v -v: shows verbose parse details (developers only).&lt;br /&gt;
&lt;br /&gt;
The recommended procedure is this:&lt;br /&gt;
&lt;br /&gt;
# Run it with --dryrun first to see what it will do.&lt;br /&gt;
# If the messages look good, run without --dryrun; the old content will be left in backup files with a -bak extension.&lt;br /&gt;
# Eyeball the changes with the --diff option.&lt;br /&gt;
# Use wmlscope, with a directory path including the Wesnoth mainline WML, to check that you have no unresolved references.&lt;br /&gt;
# Test the conversion.&lt;br /&gt;
# Use either --clean to remove the -bak files or --revert to undo the conversion.&lt;br /&gt;
&lt;br /&gt;
Additionally, wmllint tries to locate a spell checker on your system and spell-checks storyline and message strings.  It will work automatically with any of [https://github.com/AbiWord/enchant enchant]'s spellchecking backends (including aspell, myspell, ispell, applespell, hunspell, nuspell, and so on, depending on the version of enchant), provided you have the &amp;lt;tt&amp;gt;enchant.py&amp;lt;/tt&amp;gt; Python library installed. Note that the spellchecking results can vary depending on which backend enchant decides to use.&lt;br /&gt;
&lt;br /&gt;
wmllint supports a number of magic comments to customize its behaviour and avoid false positives. All magic wmllint comments begin with the string &amp;lt;tt&amp;gt;wmllint:&amp;lt;/tt&amp;gt;, followed by some additional keyword and potentially some arguments. In the below explanations, a string of the form &amp;lt;code&amp;gt;[a|b]&amp;lt;/code&amp;gt; means you may use either &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; at that location, while a string of the form &amp;lt;code&amp;gt;&amp;lt;arg&amp;gt;&amp;lt;/code&amp;gt; indicates free text substitution.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ignore&amp;lt;/code&amp;gt;: Disables checking of terrains and translation marks on the current line only.&lt;br /&gt;
* &amp;lt;code&amp;gt;noconvert&amp;lt;/code&amp;gt;: Disables conversion of terrains and image/sound filenames on the current line only.&lt;br /&gt;
* &amp;lt;code&amp;gt;markcheck [on|off]&amp;lt;/code&amp;gt;: Enables or disables translation mark checking from the current (next?) line onward.&lt;br /&gt;
* &amp;lt;code&amp;gt;no-icon&amp;lt;/code&amp;gt;: If an attack has no description, without this wmllint adds a dummy description to the attack which is just the name of the attack. With this, this description insertion is suppressed.&lt;br /&gt;
* &amp;lt;code&amp;gt;recognize &amp;lt;name&amp;gt;&amp;lt;/code&amp;gt;: Indicates that the character with the given name exists even though a declaration (ie a &amp;lt;code&amp;gt;[unit]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;[side]&amp;lt;/code&amp;gt; tag) is not visible.&lt;br /&gt;
* &amp;lt;code&amp;gt;whofield &amp;lt;macro&amp;gt; &amp;lt;number&amp;gt;&amp;lt;/code&amp;gt;: Indicates that the specified macro declares a character whose name is given by the specified argument to the macro.&lt;br /&gt;
* &amp;lt;code&amp;gt;whofield clear &amp;lt;macro&amp;gt;&amp;lt;/code&amp;gt;: Removes the &amp;lt;code&amp;gt;whofield&amp;lt;/code&amp;gt; definition for the specified macro.&lt;br /&gt;
* &amp;lt;code&amp;gt;who &amp;lt;macro&amp;gt; is &amp;lt;name&amp;gt; &amp;lt;name&amp;gt; ...&amp;lt;/code&amp;gt;: Indicates that the specified macro declares one or more characters whose names are given as a space-separated list. This can also be used for macros that auto-recall a list of characters, some of which join later or may die at some point. If a definition for the macro already exists, then the specified names are appended to it. If a name is preceded by a double minus (&amp;lt;code&amp;gt;-- &amp;lt;name&amp;gt;&amp;lt;/code&amp;gt;) then it is removed from the definition.&lt;br /&gt;
* &amp;lt;code&amp;gt;unwho all|&amp;lt;name&amp;gt;&amp;lt;/code&amp;gt;: Removes the &amp;lt;code&amp;gt;who&amp;lt;/code&amp;gt; definition for the specified macro, or all &amp;lt;code&amp;gt;who&amp;lt;/code&amp;gt; definitions.&lt;br /&gt;
* &amp;lt;code&amp;gt;usage of &amp;quot;&amp;lt;unit&amp;gt;&amp;quot; is &amp;lt;class&amp;gt;&amp;lt;/code&amp;gt;: Declares the usage of the specified unit (the &amp;lt;code&amp;gt;usage=&amp;lt;/code&amp;gt; key in the &amp;lt;code&amp;gt;[unit_type]&amp;lt;/code&amp;gt; tag). Useful if you are using macros to generate several similar unit types.&lt;br /&gt;
* &amp;lt;code&amp;gt;usagetype &amp;lt;class&amp;gt;&amp;lt;/code&amp;gt;: Declares a valid usage type for units. &amp;lt;code&amp;gt;usagetypes&amp;lt;/code&amp;gt; is also recognized, and a comma-separated list of usage types can be specified.&lt;br /&gt;
* &amp;lt;code&amp;gt;validate-[on|off]&amp;lt;/code&amp;gt;: Enables or disables stack-based validation checks. Use when you have unbalanced tags in macros.&lt;br /&gt;
* &amp;lt;code&amp;gt;unbalanced-[on|off]&amp;lt;/code&amp;gt;: Similar to above, the precise difference is unclear.&lt;br /&gt;
* &amp;lt;code&amp;gt;no translatables&amp;lt;/code&amp;gt;: Suppresses warnings about a missing textdomain declaration in the current file. Make sure the file really does have no translatable strings!&lt;br /&gt;
* &amp;lt;code&amp;gt;display [on|off]&amp;lt;/code&amp;gt;: Enable or disable warnings about newlines in messages.&lt;br /&gt;
* &amp;lt;code&amp;gt;notecheck [on|off]&amp;lt;/code&amp;gt;: Enable or disable note consistency checks for unit descriptions.&lt;br /&gt;
* &amp;lt;code&amp;gt;deathcheck [on|off]&amp;lt;/code&amp;gt;: Enable or disable the check for units speaking in their death events.&lt;br /&gt;
* &amp;lt;code&amp;gt;[general|directory|local] spellings &amp;lt;word&amp;gt; &amp;lt;word&amp;gt; ...&amp;lt;/code&amp;gt;: Declares the specified space-separated list of words to be valid spellings in the specified context. The context &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; indicates the current file only, while &amp;lt;code&amp;gt;directory&amp;lt;/code&amp;gt; means the current file and any siblings in the same directory or subdirectories. The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; context indicates the spellings are valid anywhere.&lt;br /&gt;
* &amp;lt;code&amp;gt;no spellcheck&amp;lt;/code&amp;gt;: Disables spell checking on the current line.&lt;br /&gt;
* &amp;lt;code&amp;gt;skip-side&amp;lt;/code&amp;gt;: Indicates that there is a missing side declaration at this location that will be provided by a macro expansion.&lt;br /&gt;
* &amp;lt;code&amp;gt;match &amp;lt;string&amp;gt; with &amp;lt;notes_macro&amp;gt;&amp;lt;/code&amp;gt;: Indicates that uses of the specified string in a unit definition (usually a macro, including the curly braces) should be matched up with the specified special notes macro (which is also specified as the full macro with curly braces).&lt;br /&gt;
* &amp;lt;code&amp;gt;no ellipsecheck&amp;lt;/code&amp;gt;: Disables checking of unit ellipses on the current line.&lt;br /&gt;
&lt;br /&gt;
=== Explanations of &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; diagnostics ===&lt;br /&gt;
Some &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; diagnostics may require further explanation for UMC authors to understand; this section will be for providing such explanations, and descriptions of how to solve and/or silence them.&lt;br /&gt;
&lt;br /&gt;
In these, &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; will be replaced by a string. When the recommended solution also includes a &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt;, it's a suggestion to copy the string from the error message into your code.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;nonstandard word-wrap style within message&amp;lt;/code&amp;gt;: This message meant there was an unexpected newline character within a &amp;lt;code&amp;gt;[message]&amp;lt;/code&amp;gt; tag. However, this check was removed in the 1.15.10 release. Pre-1.15.10, add-on developers could silence by putting a &amp;lt;code&amp;gt;# wmllint: display on&amp;lt;/code&amp;gt; comment before the string and a &amp;lt;code&amp;gt;# wmllint: display off&amp;lt;/code&amp;gt; comment after the string, however, post-1.15.10, this is no longer necessary.&lt;br /&gt;
* &amp;lt;code&amp;gt;%s is not a known unit type&amp;lt;/code&amp;gt; (in cases where you'd think the unit type ''would'' be known): This means the unit has a type that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can load the mainline unit types. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;unknown speaker '%s' of [message]&amp;lt;/code&amp;gt;: use a &amp;lt;code&amp;gt;# wmllint: recognize %s&amp;lt;/code&amp;gt; magic comment, or, alternatively, if the speaker is created by a macro, use a magic comment of the form of either &amp;lt;code&amp;gt;# wmllint: who MACRO is SPEAKER&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;# wmllint: whofield MACRO NUMBER&amp;lt;/code&amp;gt;, depending on whether the macro takes an argument for the unit's name or not.&lt;br /&gt;
* &amp;lt;code&amp;gt;unknown '%s' referred to by id&amp;lt;/code&amp;gt;: use a &amp;lt;code&amp;gt;# wmllint: recognize %s&amp;lt;/code&amp;gt; magic comment, or, alternatively, if the unit is created by a macro, use a magic comment of the form of either &amp;lt;code&amp;gt;# wmllint: who MACRO is UNIT&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;# wmllint: whofield MACRO NUMBER&amp;lt;/code&amp;gt;, depending on whether the macro takes an argument for the unit's name or not.&lt;br /&gt;
* &amp;lt;code&amp;gt;%s has unknown advancements&amp;lt;/code&amp;gt; (in cases where you'd think the advancement ''would'' be known): This means the unit has an advancement that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can load mainline units for checking advancements. Note that it's also possible that you just made typo, too, so be sure to check your spelling. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;.description may need hand fixup&amp;lt;/code&amp;gt;: This one comes from mucking around with the &amp;lt;code&amp;gt;.description&amp;lt;/code&amp;gt; field of unit data manually in a hackish fashion. There isn't really much of a way to work around it, besides just the &amp;quot;don't do that&amp;quot; solution.&lt;br /&gt;
* &amp;lt;code&amp;gt;tag stack nonempty (%s) at end of file.&amp;lt;/code&amp;gt;: This means that you have unbalanced tags somewhere in the file, e.g. an opener without a closer, or vice versa. This can often be seen when defining macros for unit abilities. A way to fix this warning is to wrap the section with unbalanced tags with a &amp;lt;code&amp;gt;# wmllint: unbalanced-on&amp;lt;/code&amp;gt; magic comment beforehand and a &amp;lt;code&amp;gt;# wmllint: unbalanced-off&amp;lt;/code&amp;gt; magic comment afterwards. As having unbalanced tags will also cause issues for other WML maintenance tools, such as &amp;lt;tt&amp;gt;wmlindent&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;wmlxgettext&amp;lt;/tt&amp;gt;, you may also want to add separate magic comments for each of them (see their documentation for the form they take).&lt;br /&gt;
* &amp;lt;code&amp;gt;unit declaration without side attribute&amp;lt;/code&amp;gt;: the default side for a unit declaration when left implicit is side 1. Specify your unit sides explicitly to solve this.&lt;br /&gt;
* &amp;lt;code&amp;gt;no %s units recruitable at difficulty %s&amp;lt;/code&amp;gt; (even when there are such units recruitable): This diagnostic has to do with matching the &amp;lt;code&amp;gt;usage&amp;lt;/code&amp;gt; key of units recruitable by an AI side with their &amp;lt;code&amp;gt;recruitment_pattern&amp;lt;/code&amp;gt;. It means the unit has a usage that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can know which mainline units are recruitable. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;%s has unknown movement type&amp;lt;/code&amp;gt; (even when you'd think that that movement type ''would'' actually be known): This means the unit has a movetype that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can load the mainline movement types. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;%s has unknown race&amp;lt;/code&amp;gt; (even when you'd think that that race ''would'' actually be known): This means the unit has a race that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can load the mainline races. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;derivation of %s from %s does not resolve&amp;lt;/code&amp;gt; (even when you'd think it would): This means that a unit using the [[UnitTypeWML#Other_tags|[base_unit]]] tag specifies a unit ID in that tag that was never defined in mainline or in the add-on. This is why you're supposed to always add Wesnoth's core directory as the first item to be checked when using &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; (which is something that the GUI version of it will do automatically for you), so that it can load the core units for its derivation checks. (You can also silence this warning by passing the &amp;lt;tt&amp;gt;-K&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt;.)&lt;br /&gt;
* &amp;lt;code&amp;gt;[advancefrom] needs to be manually updated to [modify_unit_type] and moved into the _main.cfg file&amp;lt;/code&amp;gt;: This one is pretty self-explanatory: [[UnitTypeWML#Unit_Type|[advancefrom]]] was deprecated in [https://github.com/wesnoth/wesnoth/commit/3950f40f3f0483032bc70b3e57166bd355acd9fc commit 3950f40] due to [https://github.com/wesnoth/wesnoth/issues/3955 issue #3955], and in fact doesn't even work anymore (in 1.16) as per [https://github.com/wesnoth/wesnoth/issues/6204 issue #6204]. The main reason &amp;lt;tt&amp;gt;wmllint&amp;lt;/tt&amp;gt; can't fix this automatically is because it could end up being too complicated for it to figure out which files to edit if there are multiple uses of &amp;lt;code&amp;gt;[advancefrom]&amp;lt;/code&amp;gt;, and it also doesn't want to assume where to put the [[ModificationWML|[modify_unit_type]]] tag in &amp;lt;tt&amp;gt;_main.cfg&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== wmlindent ==&lt;br /&gt;
&lt;br /&gt;
Call with no arguments to filter WML on standard input to reindented WML on&lt;br /&gt;
standard output.  If arguments are specified, they are taken to be files to be&lt;br /&gt;
re-indented in place; a directory name causes reindenting on all WML&lt;br /&gt;
beneath it.&lt;br /&gt;
&lt;br /&gt;
The indent unit is four spaces.  Absence of an option to change this is&lt;br /&gt;
deliberate; the purpose of this tool is to ''prevent'' style wars, not encourage&lt;br /&gt;
them.&lt;br /&gt;
&lt;br /&gt;
On non-empty lines, this code never modifies anything but leading and&lt;br /&gt;
trailing whitespace. Leading whitespace will be regularized to the&lt;br /&gt;
current indent; trailing whitespace will be stripped.  After processing&lt;br /&gt;
all lines will end with a Unix-style &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt; end-of-line marker.&lt;br /&gt;
&lt;br /&gt;
Runs of entirely blank lines will be reduced to one blank line, except&lt;br /&gt;
in two cases where they will be discarded: (a) before WML closing&lt;br /&gt;
tags, and (b) after WML opening tags.&lt;br /&gt;
&lt;br /&gt;
It is possible to wrap a section of lines in special comments so that&lt;br /&gt;
&amp;lt;tt&amp;gt;wmlindent&amp;lt;/tt&amp;gt; will ignore them.  You may need to do this for unbalanced&lt;br /&gt;
macros (it's better, though, to get rid of those where possible).&lt;br /&gt;
Use '&amp;lt;code&amp;gt;wmlindent: {start,stop} ignoring&amp;lt;/code&amp;gt;' anywhere in a comment.&lt;br /&gt;
&lt;br /&gt;
It is also possible to declare custom openers an closers, e.g for macros&lt;br /&gt;
that are actually control constructs.  To do this, use declarations&lt;br /&gt;
&lt;br /&gt;
    # wmlindent: opener &amp;quot;{EXCEPTIONAL_OPENER &amp;quot;&lt;br /&gt;
    # wmlindent: closer &amp;quot;{EXCEPTIONAL_CLOSER &amp;quot;&lt;br /&gt;
&lt;br /&gt;
The lines after an opener will be indented an extra level; a closer&lt;br /&gt;
and lines following will be indented one level less. Note that these&lt;br /&gt;
declare prefixes; any prefix match to the non-whitespace text of a line&lt;br /&gt;
will be recognized.&lt;br /&gt;
&lt;br /&gt;
The public utility macros &amp;quot;&amp;lt;code&amp;gt;{FOREACH&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;{NEXT&amp;lt;/code&amp;gt;&amp;quot; come as wired-in exceptions,&lt;br /&gt;
because it is not guaranteed that their indent declarations will be processed&lt;br /&gt;
before the macro library is reached.&lt;br /&gt;
&lt;br /&gt;
Interrupting &amp;lt;tt&amp;gt;wmlindent&amp;lt;/tt&amp;gt; ought to be safe, as each reindenting will be done to a copy&lt;br /&gt;
that is atomically renamed when it's done.  If the output file is identical&lt;br /&gt;
to the input, the output file will simply be deleted, so the timestamp&lt;br /&gt;
on the input file won't be touched.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--dryrun&amp;lt;/tt&amp;gt; option detects and reports files that would be changed&lt;br /&gt;
without changing them. The &amp;lt;tt&amp;gt;--verbose&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt; option enables reporting&lt;br /&gt;
of files that are (or would be, under &amp;lt;tt&amp;gt;--dryrun&amp;lt;/tt&amp;gt;) changed.  With &amp;lt;tt&amp;gt;-v -v&amp;lt;/tt&amp;gt;,&lt;br /&gt;
unchanged files are also reported.  The &amp;lt;tt&amp;gt;--exclude&amp;lt;/tt&amp;gt; option takes a regexp&lt;br /&gt;
and excludes files matching it.&lt;br /&gt;
&lt;br /&gt;
If you don't apply this tool to your own WML that you wish to submit, the&lt;br /&gt;
mainline-campaign maintainers will do it when and if your code is accepted into the tree.&lt;br /&gt;
&lt;br /&gt;
Note: This tool does not include a parser.  It will produce bad results on WML&lt;br /&gt;
that is syntactically unbalanced.  Unbalanced double quotes that aren't part&lt;br /&gt;
of a multiline literal will also confuse it.  You will receive warnings&lt;br /&gt;
if there's an indent open at end of file or if a closer occurs with&lt;br /&gt;
indent already zero; these two conditions strongly suggest unbalanced WML.&lt;br /&gt;
&lt;br /&gt;
== GUI.pyw ==&lt;br /&gt;
&lt;br /&gt;
Starting from version 1.11.15 and 1.13.0, a GUI (written in Tkinter, plus the themed widgets ttk) is available in the same directory as the other tools. To use it, you need to have a version of Python equal to or greater than 3.1.0 (the 3.0.x series doesn't include the ttk widgets, and as such is unsuitable for this script).&lt;br /&gt;
&lt;br /&gt;
If you're on Linux, be sure to have installed the ''python3-tk'' module, '''or the application won't run at all'''. To install it in a Debian-based distro (like Ubuntu), type this line in a Terminal:&lt;br /&gt;
 sudo apt install python3-tk&lt;br /&gt;
&lt;br /&gt;
To start it, just double click on the GUI.pyw file. The interface is pretty much self-explanatory, and allows you to run wmllint, wmlscope, wmlindent and wmlxgettext, modify their options, select an add-on and save the tools' output as a text file.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Translation Maintenance Commands]] (for &amp;lt;tt&amp;gt;wmlxgettext&amp;lt;/tt&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[Category:Create]]&lt;br /&gt;
[[Category:Tools]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74912</id>
		<title>PreprocessorRef</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=PreprocessorRef&amp;diff=74912"/>
		<updated>2026-03-20T15:50:21Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* #define */  Mention define/enddef non-nesting requirement (cf. GNA #21343)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth loads just one configuration file directly: '''data/_main.cfg'''. However, the '''WML preprocessor''' allows the inclusion of more files. Whenever a WML file is read by Wesnoth, it is passed through the preprocessor.&lt;br /&gt;
&lt;br /&gt;
The preprocessor can interpret a simple language of string expansions known as ''macros''. A macro should always be defined '''before''' the place where it needs to be used.&lt;br /&gt;
&lt;br /&gt;
The preprocessor is applied recursively, so included files will be parsed for macros, and after macro expansion will be parsed for macros again, and so on. As a result, you should not write a recursive macro that references itself, because it will cause errors (but, alas, not necessarily error messages).&lt;br /&gt;
&lt;br /&gt;
== Preprocessor directives ==&lt;br /&gt;
&lt;br /&gt;
The following directives are used to create and use ''macros'', i.e. shortcuts which reduce repetition of information. See [https://www.wesnoth.org/macro-reference.html the macro reference] for the list of predefined core macros.&lt;br /&gt;
&lt;br /&gt;
Macros have scoping rules such that addons have separate preprocessing contexts, meaning that they can be overridden however an author of UMC wishes to override them, without worrying about breaking other add-ons.&lt;br /&gt;
&lt;br /&gt;
The preprocessor has changed several times, so don't expect old Wesnoth versions to behave exactly the same as the current stable and development series.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In multiplayer scenarios, these directives will appear to work only for the host and not for other clients. This is because the preprocessor is run only on the host, and the clients receive the resultant WML from the server. It's particularly important to keep this in mind before using preprocessor conditionals.&lt;br /&gt;
&lt;br /&gt;
=== #define ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax: #define ''symbol'' [''parameters''] ''&amp;lt;newline&amp;gt;'' ''substitution'' #enddef'''&lt;br /&gt;
&lt;br /&gt;
All subsequent occurences of '''{''symbol'' [''arguments'']}''' (see below) will be replaced by the contents of the ''substitution'' block, with all occurrences of any parameter {''parameter''} within ''substitution'' replaced by the corresponding value in ''arguments''. &amp;lt;code&amp;gt;#define-#enddef&amp;lt;/code&amp;gt; blocks cannot be nested inside another &amp;lt;code&amp;gt;#define&amp;lt;/code&amp;gt;, as of Wesnoth 1.19.&lt;br /&gt;
&lt;br /&gt;
As an example, the ENEMY_UNIT macro for the [[#Macro inclusions|macro inclusion]] example below could be defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define ENEMY_UNIT TYPE X Y&lt;br /&gt;
## the ordering above is important, since the preprocessor does not distinguish&lt;br /&gt;
## data into different types; only the ordering is used to determine which&lt;br /&gt;
## arguments apply to which parameters.&lt;br /&gt;
[unit]&lt;br /&gt;
    type={TYPE} ## the unit will be of type TYPE, so different&lt;br /&gt;
                ## instantiations&lt;br /&gt;
                ## of this macro can create different units.&lt;br /&gt;
    x={X}&lt;br /&gt;
    y={Y}&lt;br /&gt;
    side=2 ## the unit will be an enemy, regardless of the parameter&lt;br /&gt;
           ## values. This reduces &amp;quot;repetition of information&amp;quot;,&lt;br /&gt;
           ## since it is no longer necessary to specify&lt;br /&gt;
           ## each created unit as an enemy.&lt;br /&gt;
[/unit]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(See [[SingleUnitWML]] for further information on creating units using WML.)&lt;br /&gt;
&lt;br /&gt;
'''Important note:''' Although macros may look like they're simplifying the code, they do not help with wml bloating. Macros are very good at ''disguising'' WML bloat, but they do nothing to ''alleviate'' it. So instead of using macros to generate redundant and repetitive instructions, you should be considering how to eliminate redundancy through programming techniques of abstraction. The most popular way to improve your code is using custom [[EventWML|events]] and [[InternalActionsWML#.5Bfire_event.5D|fire_event]] tags. See also: [[Wml_optimisation|WML Optimisation]].&lt;br /&gt;
&lt;br /&gt;
==== Whitespace in Macros ====&lt;br /&gt;
&lt;br /&gt;
When expanding a macro, '''''all''''' whitespace in the definition of the macro is preserved. The &amp;lt;tt&amp;gt;#arg&amp;lt;/tt&amp;gt; declarations for optional arguments are removed including the final newline. The body of the optional argument (the default value) is similarly processed just as if it were a macro, so all whitespace is preserved.&lt;br /&gt;
&lt;br /&gt;
There are two main practical implications of these rules:&lt;br /&gt;
&lt;br /&gt;
* When using a macro to define simple constants to be used inline in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#enddef&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_CONSTANT&lt;br /&gt;
42#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* If using a macro inside a quoted string, you should not indent the contents of the macro, as the indentation will be preserved upon macro substitution.&lt;br /&gt;
* Similarly if you use an optional argument in the middle of an attribute value, the entire content and the &amp;lt;tt&amp;gt;#endarg&amp;lt;/tt&amp;gt; must be on one line, like so:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg OPTIONAL_ARG&lt;br /&gt;
default#endarg&lt;br /&gt;
  key = &amp;quot;composite {OPTIONAL_ARG} value&amp;quot;&lt;br /&gt;
#enddef&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #arg ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|7}} &lt;br /&gt;
&lt;br /&gt;
'''Syntax: #arg ''symbol'' ''&amp;lt;newline&amp;gt;'' ''default value'' #endarg'''&lt;br /&gt;
&lt;br /&gt;
Defines an optional argument for a macro along with its default value. Optional arguments can be used to make a macro more flexible and to allow its user to specify certain parameters only when necessary.&lt;br /&gt;
&lt;br /&gt;
For example, one could define a shortcut macro for [message] with only one required argument (the text displayed), but several optional ones:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MESSAGE TEXT&lt;br /&gt;
&lt;br /&gt;
#arg SPEAKER_ID&lt;br /&gt;
narrator#endarg&lt;br /&gt;
&lt;br /&gt;
#arg CAPTION&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg SOUND&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
#arg IMG&lt;br /&gt;
#endarg&lt;br /&gt;
&lt;br /&gt;
[message]&lt;br /&gt;
    speaker={SPEAKER_ID}&lt;br /&gt;
    message={TEXT}&lt;br /&gt;
    caption={CAPTION}&lt;br /&gt;
    sound={SOUND}&lt;br /&gt;
    image={IMG}&lt;br /&gt;
[/message]&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The caller of the macro can then decide which, if any, of the default values to override:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;Halt!&amp;quot; SPEAKER_ID=&amp;quot;Guard Captain&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Two days pass...&amp;quot; IMG=wesnoth-icon.png SOUND=ambient/morning.ogg}&lt;br /&gt;
{MESSAGE _&amp;quot;...&amp;quot;}&lt;br /&gt;
{MESSAGE _&amp;quot;Welcome!&amp;quot; CAPTION=_&amp;quot;Elóndra's shop of wonders&amp;quot; IMG=portraits/elves/shyde.png}&lt;br /&gt;
{MESSAGE _&amp;quot;*smash*&amp;quot; SPEAKER_ID=&amp;quot;Bridge Troll&amp;quot; SOUND=mace.ogg}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multiline optional argument defined and called as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define MY_MACRO&lt;br /&gt;
#arg MULTILINE&lt;br /&gt;
[some_tag]&lt;br /&gt;
    some_attribute = &amp;quot;some value&amp;quot;&lt;br /&gt;
[/some_tag]&lt;br /&gt;
#endarg&lt;br /&gt;
...&lt;br /&gt;
#enddef&lt;br /&gt;
&lt;br /&gt;
{MY_MACRO (MULTILINE=[other_tag]&lt;br /&gt;
    other_attribute = &amp;quot;other value&amp;quot;&lt;br /&gt;
[/other_tag])}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' As with #enddef, the final line break before #endarg is included in the default value. This means that if the symbol is used in the middle of a line, you should place the #endarg immediately after the value has ended, without a line break in between.&lt;br /&gt;
&lt;br /&gt;
=== #undef ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#undef ''symbol'' '''&lt;br /&gt;
&lt;br /&gt;
Removes the previous definition of the macro named ''symbol''. Wesnoth expects this to be done when overriding an existing macro, and will warn you if you redefine an existing macro without an explicit #undef before it.&lt;br /&gt;
&lt;br /&gt;
=== Inclusion directive {} ===&lt;br /&gt;
&lt;br /&gt;
This directive can be used to include macros, single files or sets of files from a target directory.&lt;br /&gt;
&lt;br /&gt;
==== File/directory inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''path''}'''&lt;br /&gt;
&lt;br /&gt;
Includes the file with the specified ''path'', which will in turn run the preprocessor on it and perform any required substitutions or inclusions within it. The ''path'' may not contain ''..'' or the inclusion will be skipped.&lt;br /&gt;
&lt;br /&gt;
The exact location in which the ''path'' will be resolved will depend on its prefix:&lt;br /&gt;
&lt;br /&gt;
* '''{''path''}''': If ''path'' isn't a known macro (see below), the game will assume it's a relative path to a file in the main game '''data/''' directory and include it.&lt;br /&gt;
* '''{~''path''}''': As above, but instead of the game data directory, the path is resolved relative to the user '''data/''' directory, where user made add-ons can normally be found.&lt;br /&gt;
* '''{./''path''}''': The path is resolved relative to the location of the current file containing this inclusion.&lt;br /&gt;
&lt;br /&gt;
Information for locating the user data and game data directories can be found in [[EditingWesnoth]].&lt;br /&gt;
&lt;br /&gt;
Forward slashes ('''/''') should '''always''' be used as the path delimiter, even if your platform uses a different symbol such as colons (''':''') or backslashes ('''\''')! It is also very important to respect the '''actual letter case''' used to name files and directories for compatibility with case-sensitive filesystems on Unix-based operating systems.&lt;br /&gt;
&lt;br /&gt;
When ''path'' points to a directory instead of a file, the preprocessor will include all files found within with the '''.cfg''' extension, in alphabetical order; files without this extension (such as '''.map''' or '''.png''' files) are ignored.&lt;br /&gt;
&lt;br /&gt;
Some directories are handled in a special fashion according to their contents:&lt;br /&gt;
&lt;br /&gt;
* If there's a file named '''_main.cfg''' in the target directory, only that file will be included and preprocessed. It may include other files from its own directory or subdirectories within it, of course. This is used for managing WML directories as self-contained packages, like user made add-ons.&lt;br /&gt;
* If there are files named '''_main.cfg''' in subdirectories of the target and there isn't one in the target itself, they will be all preprocessed. Given the following layout:&lt;br /&gt;
 dir/&lt;br /&gt;
 dir/a/_main.cfg&lt;br /&gt;
 dir/a/other.cfg&lt;br /&gt;
 dir/b/_main.cfg&lt;br /&gt;
 dir/b/other.cfg&lt;br /&gt;
 dir/other.cfg&lt;br /&gt;
Using '''{dir}''' will cause dir/a/_main.cfg, dir/b/_main.cfg and dir/other.cfg to be included.&lt;br /&gt;
* If there's a file named '''_final.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''after'' all the other files in the directory.&lt;br /&gt;
* If there's a file named '''_initial.cfg''' but no '''_main.cfg''', the file is guaranteed to be included and processed ''before'' all the other files in the directory.&lt;br /&gt;
&lt;br /&gt;
==== Macro inclusions ====&lt;br /&gt;
&lt;br /&gt;
'''Syntax: {''symbol'' [''arguments''] [''optional arguments'']}'''&lt;br /&gt;
&lt;br /&gt;
If the macro named ''symbol'' is defined, the preprocessor will replace this instruction by the expression ''symbol'' was previously defined as, using ''arguments'' as parameters. The number of normal arguments must be exactly the same as in the original definition or an error will occur. Optional arguments can only be placed '''after''' all normal arguments, however they can be specified in any order desired.&lt;br /&gt;
&lt;br /&gt;
You can create multiple word arguments by using parentheses to delimit the contents. For example, in '''{ENEMY_UNIT Wolf Rider 18 24}''' the four words will be interpreted as separate arguments and cause the preprocessor to fail since the macro was defined above with only three; instead, you should use '''{ENEMY_UNIT (Wolf Rider) 18 24}'''.&lt;br /&gt;
&lt;br /&gt;
Optional arguments can also be delimited by placing parentheses, however they must be placed around both the argument name '''and''' content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; (SPEAKER_ID=Bridge Troll) } # Correct&lt;br /&gt;
{MESSAGE _&amp;quot;I'll smash you!&amp;quot; SPEAKER_ID=(Bridge Troll) } # Wrong&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way even complex arguments can be passed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
{MODIFY_UNIT (&lt;br /&gt;
    [filter_adjacent]&lt;br /&gt;
        canrecruit=yes&lt;br /&gt;
    [/filter_adjacent]&lt;br /&gt;
    ) side 2}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the name of an existing macro as the name of a macro argument is possible, but the argument will always take precedence over the original macro:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#define VARIABLE&lt;br /&gt;
#enddef&lt;br /&gt;
#define MACRO VARIABLE&lt;br /&gt;
    {VARIABLE} # is calling for the argument, not for the macro above&lt;br /&gt;
#enddef&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #ifdef and #ifndef ===&lt;br /&gt;
&lt;br /&gt;
Unlike the other preprocessor directives, '''#ifdef''' and '''#ifndef''' are not mere conveniences. They are often necessary to distinguish between different gameplay modes or difficulties (see [[#Built-in macros|Built-in macros]] below).&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifdef ''symbol'' ''substitution-if-defined'' [#else ''substitution-if-not-defined'' ] #endif'''&lt;br /&gt;
&lt;br /&gt;
If ''symbol'' has been defined with '''#define''' or as a built-in macro, the whole block will be replaced by ''substitution-if-defined''.  If not, it will be replaced by ''substitution-if-not-defined'' if it is available.&lt;br /&gt;
&lt;br /&gt;
'''#ifndef''' is the exact opposite of '''#ifdef''', reversing the logic:&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifndef ''symbol'' ''substitution-if-not-defined''  [#else ''substitution-if-defined''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifhave and #ifnhave ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifhave ''path'' ''substitution-if-path-exists'' [#else ''substitution-if-path-does-not-exist''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Checks for the existence of a file. Uses the same relative paths as [[#Inclusion_directive_.7B.7D|include directives]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifhave ~add-ons/My_Addon/_main.cfg&lt;br /&gt;
    {MY_ADDON_MACROS}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnhave'''  does the opposite of '''#ifhave''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnhave ''path'' ''substitution-if-path-does-not-exist'' [#else ''substitution-if-path-exists''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #ifver and #ifnver ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-met'' [#else ''substitution-if-condition-not-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
Compares a version number defined in a macro against an argument for conditional block inclusions, like ''#ifdef'' and ''#ifhave''. ''operator'' is one of ''=='' (equal), ''!='' (not equal), ''&amp;lt;'' (less), ''&amp;lt;='' (less or equal), ''&amp;gt;'' (greater), ''&amp;gt;='' (greater or equal). The specified ''symbol'' should have been previously defined as plain text without more macro inclusions within it, and it must not require any arguments.&lt;br /&gt;
&lt;br /&gt;
Versions with text suffixes are sorted in binary order and come after all versions with the same number. The most common suffixes begin with &amp;quot;+&amp;quot;, but as this represents multiple possible versions, comparing versions against it is not recommended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;gt;= 1.9.7+&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7+, 1.9.8 or later!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#else&lt;br /&gt;
#ifver WESNOTH_VERSION == 1.9.7&lt;br /&gt;
    [message]&lt;br /&gt;
        speaker=narrator&lt;br /&gt;
        message= _ &amp;quot;I’m on Wesnoth 1.9.7, and I’ll include some workaround code for bug #9001!&amp;quot;&lt;br /&gt;
    [/message]&lt;br /&gt;
#endif&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''#ifnver'''  does the opposite of '''#ifver''':&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#ifnver ''symbol'' ''operator'' ''version-number'' ''&amp;lt;newline&amp;gt;'' ''substitution-if-condition-not-met'' [#else ''substitution-if-condition-met''] #endif'''&lt;br /&gt;
&lt;br /&gt;
=== #error ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#error [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to fail unconditionally upon encountering the line. For add-ons, this will cause the game to display an error and return to the titlescreen if the add-on is required for the user's action (such as playing a campaign or loading a saved game). For core WML, this will cause the game to quit entirely.&lt;br /&gt;
&lt;br /&gt;
Please note that in spite of the example below, it is '''not''' advisable to use this mechanism in published add-ons for version or feature-checking, since the message is not displayed in a form that permits translation and the additional trace information may confuse players. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#error This add-on does not support Wesnoth 1.11.10!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #warning ===&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#warning [''message'']'''&lt;br /&gt;
&lt;br /&gt;
Causes the WML preprocessor to emit a warning upon encountering the line. The message will '''only''' be relayed to stderr, not to the player in the game UI. This directive is only intended as a debugging aid for content creators.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;wml&amp;quot;&amp;gt;&lt;br /&gt;
#ifver WESNOTH_VERSION &amp;lt; 1.11.10&lt;br /&gt;
#warning On Wesnoth 1.11.9 or earlier, bug workarounds enabled!&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== #deprecated ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.13|11}}&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 1 ''message'''''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 2 ''version'' ''message'''''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 3 ''version'' ''message'''''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:''' '''#deprecated 4 ''message'''''&lt;br /&gt;
&lt;br /&gt;
The effect of this directive depends on whether it appears within a macro definition.&lt;br /&gt;
&lt;br /&gt;
* If it appears at file level, outside any macro definition, then it immediately outputs a warning saying that the file is deprecated, with the provided message. Multiple '''#deprecated''' directives at toplevel in a single file will result in separate messages.&lt;br /&gt;
* If it appears inside a macro definition ('''#define ... #enddef'''), then it doesn't output anything. Instead, it marks the macro as deprecated. When that macro is later used, only then will the preprocessor output a warning saying that the macro is deprecated, with the provided message. Multiple '''#deprecated''' directives within a single macro will be merged into one message.&lt;br /&gt;
&lt;br /&gt;
Note that deprecation messages will only appear if they have been set to. {{DevFeature1.13|12}} This can be done by enabling debug mode, or by going to Advanced Preferences and setting the log-level for the deprecation logdomain. (This can also be done on the command-line.)&lt;br /&gt;
&lt;br /&gt;
If you provide a deprecation level of 2 or 3, it is required to indicate the earliest version in which the feature could be removed. However, if you provide a deprecation level of 1 or 4, any provided ''version'' will instead be parsed as part of the message, so you will probably not want to provide one at all. Other deprecation levels are not valid. See the documentation for [[InterfaceActionsWML#.5Bdeprecated_message.5D|[deprecated_message]]] for the meaning of the various ''level'' values.&lt;br /&gt;
&lt;br /&gt;
== Built-in macros ==&lt;br /&gt;
&lt;br /&gt;
The following macros are automatically defined with empty contents (unless specified otherwise) by the game engine depending on the configuration or gameplay mode.&lt;br /&gt;
&lt;br /&gt;
Note that except during an actual game, '''MULTIPLAYER''', '''EDITOR''' and previous campaign defines, are not guaranteed to be undefined, especially when coming back to the titlescreen. So it is not enough to hide contents inside of an #ifdef to prevent them from being seen by the campaign selection dialog, for example for multiplayer specific '''[campaign]'''s or '''[modification]'''s '''type=mp''' must be used. &lt;br /&gt;
&lt;br /&gt;
* A campaign define symbol (see ''define'' in [[CampaignWML]]): defined when playing a single-player campaign.&lt;br /&gt;
* A campaign difficulty level, usually '''EASY''', '''NORMAL''' or '''HARD''' (see ''difficulties'' in [[CampaignWML]]): defined according to the chosen difficulty when starting a single-player campaign, also stored in saved games.&lt;br /&gt;
* '''MULTIPLAYER''': defined when in multiplayer mode.&lt;br /&gt;
* '''EDITOR''': defined when running the built-in map editor.&lt;br /&gt;
* '''DEBUG_MODE''': defined when the game has been launched in debug mode (i.e. with '''-d''' or '''--debug''' in the command line). Can also be set by typing &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; to bring up [[CommandMode]], then typing &amp;lt;code&amp;gt;debug&amp;lt;/code&amp;gt;, and then restarting the scenario.&lt;br /&gt;
* '''APPLE''': defined while processing the main game data when running on Mac OS X. This primarily exists to switch Control for Command in hotkeys, which is why there are no defines for other platforms.&lt;br /&gt;
* '''WESNOTH_VERSION''': defined containing just the game version number when running the WML preprocessor.&lt;br /&gt;
* '''CURRENT_FILE''': Expands to the name of the current WML file.&lt;br /&gt;
* '''CURRENT_DIRECTORY''': Expands to the preprocessor path of the parent directory for the current WML file (e.g. for &amp;lt;code&amp;gt;&amp;amp;lt;user data dir&amp;amp;gt;/data/add-ons/My_Addon/_main.cfg&amp;lt;/code&amp;gt; this evaluates to &amp;lt;code&amp;gt;~add-ons/My_Addon&amp;lt;/code&amp;gt;). &lt;br /&gt;
* '''LEFT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;{&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''RIGHT_BRACE''': {{DevFeature1.15|2}} Expands to &amp;lt;code&amp;gt;}&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''SCHEMA_VALIDATION''': defined if the validator is being run.&lt;br /&gt;
* '''__WMLUNITS__''': defined when the tool to create [https://units.wesnoth.org units.wesnoth.org] is being run.&lt;br /&gt;
&lt;br /&gt;
A ''very large'' number of additional macros are provided as part of the default game core WML. For a full list of those, check the [https://www.wesnoth.org/macro-reference.html macro reference].&lt;br /&gt;
&lt;br /&gt;
== Command-line preprocessor ==&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
Or the short form:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: -p ''&amp;amp;lt;source file/directory&amp;gt;'' ''&amp;lt;target directory&amp;gt;'' '''&lt;br /&gt;
&lt;br /&gt;
You can specify a list of predefined defines with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-defines=DEFINE1,DEFINE2,etc'''&lt;br /&gt;
&lt;br /&gt;
comma separated list of defines to be used by '--preprocess' command. If 'SKIP_CORE' is in the define list the data/core won't be preprocessed.&lt;br /&gt;
&lt;br /&gt;
The command will first preprocess '''data/core/macros''' and '''data/core/terrain-graphics''', and afterwards the specified path. You can specify a single file to be preprocessed (if you want to preprocess multiple separate files, you'll need to run a different command line for each one), or an entire directory, which will be preprocessed according to the rules used by the inclusion directive above.&lt;br /&gt;
&lt;br /&gt;
The resulting preprocessed files will be written in the target directory. There will be two types of files: .cfg files --- the normal ones, and .plain files containing line markers and textdomain changes.&lt;br /&gt;
&lt;br /&gt;
If by chance, the simple macro define doesn't suffice, you can use:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-input-macros &amp;lt;file&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
To import an existing file that contains macros, and they will be available in the defines database before processing the specified files.&lt;br /&gt;
&lt;br /&gt;
There is also the possibility to export the preprocessed defines/macro list with:&lt;br /&gt;
&lt;br /&gt;
'''Syntax: --preprocess-output-macros [&amp;lt;target file&amp;gt;]'''&lt;br /&gt;
&lt;br /&gt;
This file could be fed to the 'input-macros' argument next time you run it. For example, a scenario would be: parsing just the core first time, and for the intended target files, you would add SKIP_CORE but import the generated macros file - that will be faster than preprocessing the core again. If the target file is not specified, the output file will be _MACROS_.cfg in the target directory of the preprocess's command.&lt;br /&gt;
&lt;br /&gt;
If ''file/directory'' and ''target directory'' are not absolute paths, they will be considered relative to the current directory.&lt;br /&gt;
&lt;br /&gt;
Some examples:&lt;br /&gt;
&lt;br /&gt;
* Preprocess the entire tutorial dir, and write the results in the ~/result folder:&lt;br /&gt;
 -p ~/wesnoth/data/campaigns/tutorial ~/result&lt;br /&gt;
* Add the MULTIPLAYER define to the list and preprocess a scenario's config file:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign/scenarios/01_First_Scenario.cfg ~/result --preprocess-defines=MULTIPLAYER&lt;br /&gt;
* Add the MY_CAMPAIGN and HARD defines before preprocessing a campaign's files:&lt;br /&gt;
 -p ~/.wesnoth/data/add-ons/My_Campaign ~/result --preprocess-defines=MY_CAMPAIGN,HARD&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
 -p data/gui/macros/_initial.cfg  /tmp --preprocess-output-macros=macros&lt;br /&gt;
 -p myfile.cfg ~/result --preprocess-input-macros=/tmp/macros&lt;br /&gt;
&lt;br /&gt;
When it starts getting complicated, such as a file that depends on multiple other files, it is probably easiest to simply &amp;quot;include&amp;quot; the dependencies:&lt;br /&gt;
&lt;br /&gt;
* File myfile.cfg depends on macros defined in data/gui/macros/_initial.cfg:&lt;br /&gt;
  Add {gui/macros/_initial.cfg} to the beginning of  myfile.cfg&lt;br /&gt;
  -p myfile.cfg ~/result&lt;br /&gt;
&lt;br /&gt;
If you want a more detailed (and potentially overwhelming) log, you can simply add the switches '''--log-debug=all''' or '''--log-info=all''' to the command line, so you can see how things are preprocessed in detail.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[SyntaxWML]] (explains relationship between comments and preprocessor directives)&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=GUIWidgetInstanceWML&amp;diff=74898</id>
		<title>GUIWidgetInstanceWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GUIWidgetInstanceWML&amp;diff=74898"/>
		<updated>2026-03-12T05:52:03Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Subtag [option] */  add value&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Widget instance ==&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;
== Widget ==&lt;br /&gt;
All widgets placed in the cell have some values in common:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| This value is used for the engine to identify 'special' items. This means that for example a text_box can get the proper initial value. This value should be unique or empty. Those special values are documented at the window definition that uses them. NOTE items starting with an underscore are used for composed widgets and these should be unique per composed widget.&lt;br /&gt;
|-&lt;br /&gt;
| definition&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;default&amp;quot;&lt;br /&gt;
| The id of the widget definition to use. This way it's possible to select a specific version of the widget e.g. a title label when the label is used as title.&lt;br /&gt;
|-&lt;br /&gt;
| linked_group&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The linked group the control belongs to.&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| Most widgets have some text associated with them, this field contain the value of that text. Some widgets use this value for other purposes, this is documented at the widget. E.g. an image uses the filename in this field.&lt;br /&gt;
|-&lt;br /&gt;
| use_markup&lt;br /&gt;
| | [[GUIVariable#bool|bool]]&lt;br /&gt;
| false&lt;br /&gt;
| Whether [https://docs.gtk.org/Pango/pango_markup.html Pango Markup] could be used to format the `label` of this widget (bold, italic, font color, alpha etc.)&lt;br /&gt;
|-&lt;br /&gt;
| tooltip&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If you hover over a widget a while (the time it takes can differ per widget) a short help can show up.This defines the text of that message. This field may not be empty when 'help' is set.&lt;br /&gt;
|-&lt;br /&gt;
| help&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If you hover over a widget and press F10 (or the key the user defined for the help tip) a help message can show up. This help message might be the same as the tooltip but in general (if used) this message should show more help. This defines the text of that message.&lt;br /&gt;
|-&lt;br /&gt;
| use_tooltip_on_label_overflow&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If the text on the label is truncated and the tooltip is empty the label can be used for the tooltip. If this variable is set to true this will happen.&lt;br /&gt;
|-&lt;br /&gt;
| debug_border_mode&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The mode for showing the debug border. This border shows the area reserved for a widget. This function is only meant for debugging and might not be available in all Wesnoth binaries. Available modes: &lt;br /&gt;
* '''0:''' no border. &lt;br /&gt;
* '''1:''' 1 pixel border. &lt;br /&gt;
* '''2:''' floodfill the widget area.&lt;br /&gt;
|-&lt;br /&gt;
| debug_border_color&lt;br /&gt;
| [[GUIVariable#color|color]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The color of the debug border.&lt;br /&gt;
|-&lt;br /&gt;
| size_text&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| Sets the minimum width of the widget depending on the text in it. (Note not implemented yet.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Button ==&lt;br /&gt;
A button is a control that can be pushed to start an action or close a dialog.&lt;br /&gt;
&lt;br /&gt;
Instance of a button. When a button has a return value it sets the&lt;br /&gt;
return value for the window. Normally this closes the window and returns&lt;br /&gt;
this value to the caller. The return value can either be defined by the&lt;br /&gt;
user or determined from the id of the button. The return value has a&lt;br /&gt;
higher precedence as the one defined by the id. (Of course it's weird to&lt;br /&gt;
give a button an id and then override its return value.)&lt;br /&gt;
&lt;br /&gt;
When the button doesn't have a standard id, but you still want to use the&lt;br /&gt;
return value of that id, use return_value_id instead. This has a higher&lt;br /&gt;
precedence as return_value.&lt;br /&gt;
&lt;br /&gt;
List with the button specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Supported values for return_value_id:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!string&lt;br /&gt;
!value&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ok&amp;quot;||-1||Equivalent to closing the dialog by pressing the Enter key&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cancel&amp;quot;||-2||Equivalent to closing the dialog by pressing the Esc key&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;quit&amp;quot;||-2||An alias for cancel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;&amp;quot;||N/A||Clears any previously set return_value_id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Combobox ==&lt;br /&gt;
{{DevFeature1.19|0}}&lt;br /&gt;
[[File:Combobox.png|frame|right|A Combobox with its list open]]&lt;br /&gt;
A widget with a text box and a dropdown list. Selecting an element from the list sets the value of the text box to that item of the list. The user can also manually enter a value in the text box.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! key !! type !! default !! description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The text of the combobox&lt;br /&gt;
|-&lt;br /&gt;
| max_input_length || [[GUIVariable#int|int]] || 0 || Maximum length of text in characters that can be entered into the combobox&lt;br /&gt;
|-&lt;br /&gt;
| hint_text || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Text that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| hint_image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image that is shown in the background when there is no input&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;combobox&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| value || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Value of the option. Defaults to &amp;lt;code&amp;gt;label&amp;lt;/code&amp;gt; if unspecified.&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || User visible translatable name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| icon || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || WML path to the icon to be shown alongside the text in this option, if any.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Drawing ==&lt;br /&gt;
A drawing is widget with a fixed size and gives access to the canvas of the widget in the window instance. This allows special display only widgets.&lt;br /&gt;
&lt;br /&gt;
If either the width or the height is not zero the drawing functions as a&lt;br /&gt;
fixed size drawing.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| width&lt;br /&gt;
| [[GUIVariable#f_unsigned|f_unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The width of the drawing.&lt;br /&gt;
|-&lt;br /&gt;
| height&lt;br /&gt;
| [[GUIVariable#f_unsigned|f_unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The height of the drawing.&lt;br /&gt;
|-&lt;br /&gt;
| draw&lt;br /&gt;
| [[GUIVariable#config|config]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The config containing the drawing.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The variable available are the same as for the window resolution see&lt;br /&gt;
http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of&lt;br /&gt;
items.&lt;br /&gt;
&lt;br /&gt;
== Grid Listbox ==&lt;br /&gt;
List with the listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!ID (return value)&lt;br /&gt;
!Type&lt;br /&gt;
!Mandatory&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Horizontal listbox ==&lt;br /&gt;
A horizontal listbox is a control that holds several items of the same type.  Normally the items in a listbox are ordered in rows, this version orders them in columns instead.&lt;br /&gt;
&lt;br /&gt;
List with the horizontal listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!ID (return value)&lt;br /&gt;
!Type&lt;br /&gt;
!Mandatory&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In order to force widgets to be the same size inside a horizontal listbox,&lt;br /&gt;
the widgets need to be inside a linked_group.&lt;br /&gt;
&lt;br /&gt;
Inside the list section there are only the following widgets allowed&lt;br /&gt;
* grid (to nest)&lt;br /&gt;
* selectable widgets which are&lt;br /&gt;
** toggle_button&lt;br /&gt;
** toggle_panel&lt;br /&gt;
&lt;br /&gt;
== Image ==&lt;br /&gt;
An image shows a static image whose path is specified by its '''[[GUIWidgetInstanceWML#Widget|label]]''' key. Unlike other widgets, the '''label''' key here is not translatable since it specifies a path. The path is a standard WML path, i.e., &amp;lt;code&amp;gt;label=&amp;quot;units/konrad.png&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;label=&amp;quot;~add-ons/MyAddon/image/test.png&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It has no other extra fields.&lt;br /&gt;
&lt;br /&gt;
== Label ==&lt;br /&gt;
A label displays text provided via the '''[[GUIWidgetInstanceWML#Widget|label]]''' key that can be wrapped but no scrollbars are provided. For a version with scrollbars, see the [[GUIWidgetInstanceWML#Scroll_Label|Scroll Label]] widget.&lt;br /&gt;
&lt;br /&gt;
[[File:Title Label.png|frame|right|A Label with definition &amp;quot;title&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
List with the label specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| wrap || [[GUIVariable#bool|bool]] || false || Is wrapping enabled for the label.&lt;br /&gt;
|-&lt;br /&gt;
| characters_per_line || [[GUIVariable#unsigned|unsigned]] || 0 || Sets the maximum number of characters per line. This is only an approximate means of limiting the line's length, since the width of a character differs. E.g. iii is smaller than MMM. When the value is non-zero it also implies '''wrap''' is true. &lt;br /&gt;
When having long strings, wrapping them can increase readability. A rule of thumb is 66 characters per line is considered the optimum for a one column text.&lt;br /&gt;
|-&lt;br /&gt;
| text_alignment || [[GUIVariable#h_align|h_align]] || left || The way the text is aligned inside the canvas.&lt;br /&gt;
|-&lt;br /&gt;
| can_shrink || [[GUIVariable#bool|bool]] || false || Whether the label can shrink past its optimal size.&lt;br /&gt;
|-&lt;br /&gt;
| link_aware || [[GUIVariable#bool|bool]] || false || 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;
&lt;br /&gt;
== Listbox ==&lt;br /&gt;
A listbox is a control that holds several items of the same type. Normally the items in a listbox are ordered in rows, this version might allow more options for ordering the items in the future.&lt;br /&gt;
&lt;br /&gt;
List with the listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In order to force widgets to be the same size inside a listbox, the widgets&lt;br /&gt;
need to be inside a linked_group.&lt;br /&gt;
&lt;br /&gt;
Inside the list section there are only the following widgets allowed&lt;br /&gt;
* grid (to nest)&lt;br /&gt;
* selectable widgets which are&lt;br /&gt;
** toggle_button&lt;br /&gt;
** toggle_panel&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
List with the matrix specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Menu Button ==&lt;br /&gt;
[[File:Menu Button.png|thumb|left|A Menu Button with it's list open.]]&lt;br /&gt;
A button that shows a dropdown list when clicked. The user can select any one of the predefined options.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;menu_button&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| icon || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || WML path to the icon to be shown alongside the text in this option, if any.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Minimap ==&lt;br /&gt;
A minimap to show the gamemap, this only shows the map and has no interaction options. This version is used for map previews, there will be a another version which allows interaction.&lt;br /&gt;
&lt;br /&gt;
A minimap has no extra fields.&lt;br /&gt;
&lt;br /&gt;
== Multiline Text ==&lt;br /&gt;
{{DevFeature1.17|26}}&lt;br /&gt;
&lt;br /&gt;
Base class for a multiline text area.  Not to be used directly in a GUI, use the [[GUIWidgetInstanceWML#Scroll_Text|scroll_text]] widget instead.&lt;br /&gt;
&lt;br /&gt;
The following variables exist:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The initial text of the text box.&lt;br /&gt;
|-&lt;br /&gt;
| history&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The name of the history for the text box. A history saves the data entered in a text box between the games. With the up and down arrow it can be accessed. To create a new history item just add a new unique name for this field and the engine will handle the rest.&lt;br /&gt;
|-&lt;br /&gt;
| editable&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| &amp;quot;true&amp;quot;&lt;br /&gt;
| If the contents of the text box can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multimenu Button ==&lt;br /&gt;
[[File:Multimenu Button.png|thumb|right|A Multimenu Button with its list open]]&lt;br /&gt;
A widget clicking on which shows a list from which one or more options can be selected.&lt;br /&gt;
&lt;br /&gt;
List with the multimenu_button specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value || [[GUIVariable#int|int]] || 0 || The return value.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_shown || [[GUIVariable#int|int]] || -1 || The maximum number of currently selected values to list on the button.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;multimenu_button&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| checkbox || [[GUIVariable#bool|bool]] || &amp;quot;&amp;quot; || Whether the checkbox alongside this option is selected or not.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi page ==&lt;br /&gt;
A multi page is a control that contains several 'pages' of which only one is visible. The pages can contain the same widgets containing the same 'kind' of data or look completely different.&lt;br /&gt;
&lt;br /&gt;
List with the multi page specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| page_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a multi page item looks. It must contain the grid definition for at least one page.&lt;br /&gt;
|-&lt;br /&gt;
| page_data&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the multi page. Every row must have the same number of columns as the 'page_definition'.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Panel ==&lt;br /&gt;
A panel is an item which can hold other items. The difference between a grid and a panel is that it's possible to define how a panel looks. A grid in an invisible container to just hold the items.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Password box ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The initial text of the password box.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Progress bar ==&lt;br /&gt;
A progress bar shows the progress of a certain object.&lt;br /&gt;
&lt;br /&gt;
A progress bar has no extra fields.&lt;br /&gt;
&lt;br /&gt;
== Repeating button ==&lt;br /&gt;
A repeating_button is a control that can be pushed down and repeat a certain action. Once the button is down every x milliseconds it is down a new down event is triggered.&lt;br /&gt;
&lt;br /&gt;
== Rich Label ==&lt;br /&gt;
{{DevFeature1.19|x}}&lt;br /&gt;
&lt;br /&gt;
A label that shows formatted text marked up with [[Help markup]]. It can show embedded images, links and tables inside text.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| text_alignment || [[GUIVariable#h_align|h_align]] || left || The way the text is aligned inside the canvas.&lt;br /&gt;
|-&lt;br /&gt;
| padding || [[GUIVariable#int|int]] || 5 || Internal padding, used in various spaces and between different types of elements (for example, between two float image, between a header and following text and so on).&lt;br /&gt;
|-&lt;br /&gt;
| link_aware || [[GUIVariable#bool|bool]] || true || 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;
&lt;br /&gt;
== Scroll Label ==&lt;br /&gt;
A scroll label is a label that wraps its text and also has a vertical scrollbar. This way a text can't be too long to be shown for this widget.&lt;br /&gt;
&lt;br /&gt;
List with the scroll label specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scroll Text ==&lt;br /&gt;
{{DevFeature1.19|x}}&lt;br /&gt;
&lt;br /&gt;
A multiline text area that shows a scrollbar if the text gets too long.&lt;br /&gt;
&lt;br /&gt;
List with the scrollbar container specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| editable&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| &amp;quot;true&amp;quot;&lt;br /&gt;
| If the contents of this scroll_text can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scrollbar panel ==&lt;br /&gt;
Instance of a scrollbar_panel.&lt;br /&gt;
&lt;br /&gt;
List with the scrollbar_panel specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a scrollbar_panel item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slider ==&lt;br /&gt;
&lt;br /&gt;
A slider is a control that can select a value by moving a grip on a groove.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| best_slider_length&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The best length for the sliding part.&lt;br /&gt;
|-&lt;br /&gt;
| minimum_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The minimum value the slider can have.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The maximum value the slider can have.&lt;br /&gt;
|-&lt;br /&gt;
| step_size&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The number of items the slider's value increases with one step.&lt;br /&gt;
|-&lt;br /&gt;
| value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The value of the slider.&lt;br /&gt;
|-&lt;br /&gt;
| minimum_value_label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If the minimum value is chosen there might be the need for a special value (eg off). When this key has a value that value will be shown if the minimum is selected.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_value_label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If the maximum value is chosen there might be the need for a special value (eg unlimited)). When this key has a value that value will be shown if the maximum is selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spinner ==&lt;br /&gt;
{{DevFeature1.17|26}}&lt;br /&gt;
&lt;br /&gt;
[[File:Spinner.png|thumb|right]]&lt;br /&gt;
&lt;br /&gt;
A textbox with two repeating buttons, which allow increasing/decreasing of the numerical value inside the textbox.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&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;
| 0&lt;br /&gt;
| Should the contents of the textbox wrap?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spacer ==&lt;br /&gt;
A spacer is a dummy item to either fill in a widget since no empty items are allowed or to reserve a fixed space.&lt;br /&gt;
&lt;br /&gt;
If either the width or the height is non-zero the spacer functions as a&lt;br /&gt;
fixed size spacer.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| width || [[GUIVariable#f_unsigned|f_unsigned]] || 0 || The width of the spacer.&lt;br /&gt;
|-&lt;br /&gt;
| height || [[GUIVariable#f_unsigned|f_unsigned]] || 0 || The height of the spacer.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The variable available are the same as for the window resolution see&lt;br /&gt;
http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of&lt;br /&gt;
items.&lt;br /&gt;
&lt;br /&gt;
== Tab Container ==&lt;br /&gt;
{{DevFeature1.19|0}}&lt;br /&gt;
&lt;br /&gt;
A container widget that can show its contents separated into various pages, each of which are accessible.&lt;br /&gt;
&lt;br /&gt;
It can contain one or more &amp;lt;code&amp;gt;[tab]&amp;lt;/code&amp;gt; tags inside it, each defining a tab's name, image (if any) and the contents of the tag, specified by the &amp;lt;code&amp;gt;[data]&amp;lt;/code&amp;gt; tag inside the &amp;lt;code&amp;gt;[tab]&amp;lt;/code&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
=== Subtag [tab] ===&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| name || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the tab&lt;br /&gt;
|-&lt;br /&gt;
| image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image for the tab to be shown alongside the name, if any&lt;br /&gt;
|-&lt;br /&gt;
| [data] || [[GUIVariable#grid|grid]] || empty grid || This subtag contains a grid that defines the contents for this tab.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Text box ==&lt;br /&gt;
A single line text entry widget.&lt;br /&gt;
&lt;br /&gt;
[[File:Text Box.png|frame|right|A Text Box]]&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || The initial text of the text box.&lt;br /&gt;
|-&lt;br /&gt;
| history || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The name of the history for the text box. A history saves the data entered in a text box between the games. With the up and down arrow it can be accessed. To create a new history item just add a new unique name for this field and the engine will handle the rest.&lt;br /&gt;
|-&lt;br /&gt;
| max_input_length || [[GUIVariable#int|int]] || 0 || Maximum length of text in characters that can be entered into the combobox&lt;br /&gt;
|-&lt;br /&gt;
| hint_text || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Text that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| hint_image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| editable || [[GUIVariable#bool|bool]] || &amp;quot;true&amp;quot; || If the contents of the text box can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Toggle button ==&lt;br /&gt;
Variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Toggle panel ==&lt;br /&gt;
A toggle panel is an item which can hold other items. The difference between&lt;br /&gt;
a grid and a panel is that it's possible to define how a panel looks. A grid&lt;br /&gt;
in an invisible container to just hold the items. The toggle panel is a&lt;br /&gt;
combination of the panel and a toggle button, it allows a toggle button with&lt;br /&gt;
its own grid.&lt;br /&gt;
&lt;br /&gt;
Variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id, see [[GUIToolkitWML#Button]] for more information.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value, see [[GUIToolkitWML#Button]] for more information.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tree view ==&lt;br /&gt;
A tree view is a control that holds several items of the same or different types. The items shown are called tree view nodes and when a node has children, these can be shown or hidden. Nodes that contain children need to provide a clickable button in order to fold or unfold the children.&lt;br /&gt;
&lt;br /&gt;
List with the tree view specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| indention_step_size&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The number of pixels every level of nodes is indented from the previous level.&lt;br /&gt;
|-&lt;br /&gt;
| node&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The tree view can contain multiple node sections. This part needs more documentation.&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| .&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| .&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If true, a tree with at least one item will always have something selected (except when items are being deleted). Although this is {{DevFeature1.19|21}}, the previous behavior is equivalent to setting this to true. The GUI doesn't provide a way to unselect items, the purpose of setting this to false is to add a landing page, as the campaign menu does.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTE more documentation and examples are needed.&lt;br /&gt;
&lt;br /&gt;
== Vertical scrollbar ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Viewport ==&lt;br /&gt;
A viewport is an special widget used to view only a part of the widget it `holds'.&lt;br /&gt;
&lt;br /&gt;
List with the viewport specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grow_direction&lt;br /&gt;
| [[GUIVariable#grow_direction|grow_direction]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The direction in which new items grow.&lt;br /&gt;
|-&lt;br /&gt;
| parallel_items&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The number of items that are growing in parallel.&lt;br /&gt;
|-&lt;br /&gt;
| item_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The definition of a new item.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;br /&gt;
[[Category: GUI WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=GUIWidgetInstanceWML&amp;diff=74891</id>
		<title>GUIWidgetInstanceWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=GUIWidgetInstanceWML&amp;diff=74891"/>
		<updated>2026-03-07T06:21:33Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Rich Label */ RL width is automatic as of 1.19.21&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Widget instance ==&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;
== Widget ==&lt;br /&gt;
All widgets placed in the cell have some values in common:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| This value is used for the engine to identify 'special' items. This means that for example a text_box can get the proper initial value. This value should be unique or empty. Those special values are documented at the window definition that uses them. NOTE items starting with an underscore are used for composed widgets and these should be unique per composed widget.&lt;br /&gt;
|-&lt;br /&gt;
| definition&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;default&amp;quot;&lt;br /&gt;
| The id of the widget definition to use. This way it's possible to select a specific version of the widget e.g. a title label when the label is used as title.&lt;br /&gt;
|-&lt;br /&gt;
| linked_group&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The linked group the control belongs to.&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| Most widgets have some text associated with them, this field contain the value of that text. Some widgets use this value for other purposes, this is documented at the widget. E.g. an image uses the filename in this field.&lt;br /&gt;
|-&lt;br /&gt;
| use_markup&lt;br /&gt;
| | [[GUIVariable#bool|bool]]&lt;br /&gt;
| false&lt;br /&gt;
| Whether [https://docs.gtk.org/Pango/pango_markup.html Pango Markup] could be used to format the `label` of this widget (bold, italic, font color, alpha etc.)&lt;br /&gt;
|-&lt;br /&gt;
| tooltip&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If you hover over a widget a while (the time it takes can differ per widget) a short help can show up.This defines the text of that message. This field may not be empty when 'help' is set.&lt;br /&gt;
|-&lt;br /&gt;
| help&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If you hover over a widget and press F10 (or the key the user defined for the help tip) a help message can show up. This help message might be the same as the tooltip but in general (if used) this message should show more help. This defines the text of that message.&lt;br /&gt;
|-&lt;br /&gt;
| use_tooltip_on_label_overflow&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If the text on the label is truncated and the tooltip is empty the label can be used for the tooltip. If this variable is set to true this will happen.&lt;br /&gt;
|-&lt;br /&gt;
| debug_border_mode&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The mode for showing the debug border. This border shows the area reserved for a widget. This function is only meant for debugging and might not be available in all Wesnoth binaries. Available modes: &lt;br /&gt;
* '''0:''' no border. &lt;br /&gt;
* '''1:''' 1 pixel border. &lt;br /&gt;
* '''2:''' floodfill the widget area.&lt;br /&gt;
|-&lt;br /&gt;
| debug_border_color&lt;br /&gt;
| [[GUIVariable#color|color]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The color of the debug border.&lt;br /&gt;
|-&lt;br /&gt;
| size_text&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| Sets the minimum width of the widget depending on the text in it. (Note not implemented yet.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Button ==&lt;br /&gt;
A button is a control that can be pushed to start an action or close a dialog.&lt;br /&gt;
&lt;br /&gt;
Instance of a button. When a button has a return value it sets the&lt;br /&gt;
return value for the window. Normally this closes the window and returns&lt;br /&gt;
this value to the caller. The return value can either be defined by the&lt;br /&gt;
user or determined from the id of the button. The return value has a&lt;br /&gt;
higher precedence as the one defined by the id. (Of course it's weird to&lt;br /&gt;
give a button an id and then override its return value.)&lt;br /&gt;
&lt;br /&gt;
When the button doesn't have a standard id, but you still want to use the&lt;br /&gt;
return value of that id, use return_value_id instead. This has a higher&lt;br /&gt;
precedence as return_value.&lt;br /&gt;
&lt;br /&gt;
List with the button specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Supported values for return_value_id:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!string&lt;br /&gt;
!value&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ok&amp;quot;||-1||Equivalent to closing the dialog by pressing the Enter key&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cancel&amp;quot;||-2||Equivalent to closing the dialog by pressing the Esc key&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;quit&amp;quot;||-2||An alias for cancel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;&amp;quot;||N/A||Clears any previously set return_value_id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Combobox ==&lt;br /&gt;
{{DevFeature1.19|0}}&lt;br /&gt;
[[File:Combobox.png|frame|right|A Combobox with its list open]]&lt;br /&gt;
A widget with a text box and a dropdown list. Selecting an element from the list sets the value of the text box to that item of the list. The user can also manually enter a value in the text box.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! key !! type !! default !! description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The text of the combobox&lt;br /&gt;
|-&lt;br /&gt;
| max_input_length || [[GUIVariable#int|int]] || 0 || Maximum length of text in characters that can be entered into the combobox&lt;br /&gt;
|-&lt;br /&gt;
| hint_text || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Text that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| hint_image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image that is shown in the background when there is no input&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;combobox&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| icon || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || WML path to the icon to be shown alongside the text in this option, if any.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Drawing ==&lt;br /&gt;
A drawing is widget with a fixed size and gives access to the canvas of the widget in the window instance. This allows special display only widgets.&lt;br /&gt;
&lt;br /&gt;
If either the width or the height is not zero the drawing functions as a&lt;br /&gt;
fixed size drawing.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| width&lt;br /&gt;
| [[GUIVariable#f_unsigned|f_unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The width of the drawing.&lt;br /&gt;
|-&lt;br /&gt;
| height&lt;br /&gt;
| [[GUIVariable#f_unsigned|f_unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The height of the drawing.&lt;br /&gt;
|-&lt;br /&gt;
| draw&lt;br /&gt;
| [[GUIVariable#config|config]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The config containing the drawing.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The variable available are the same as for the window resolution see&lt;br /&gt;
http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of&lt;br /&gt;
items.&lt;br /&gt;
&lt;br /&gt;
== Grid Listbox ==&lt;br /&gt;
List with the listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!ID (return value)&lt;br /&gt;
!Type&lt;br /&gt;
!Mandatory&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Horizontal listbox ==&lt;br /&gt;
A horizontal listbox is a control that holds several items of the same type.  Normally the items in a listbox are ordered in rows, this version orders them in columns instead.&lt;br /&gt;
&lt;br /&gt;
List with the horizontal listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!ID (return value)&lt;br /&gt;
!Type&lt;br /&gt;
!Mandatory&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIToolkitWML#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIToolkitWML#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIToolkitWML#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIToolkitWML#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In order to force widgets to be the same size inside a horizontal listbox,&lt;br /&gt;
the widgets need to be inside a linked_group.&lt;br /&gt;
&lt;br /&gt;
Inside the list section there are only the following widgets allowed&lt;br /&gt;
* grid (to nest)&lt;br /&gt;
* selectable widgets which are&lt;br /&gt;
** toggle_button&lt;br /&gt;
** toggle_panel&lt;br /&gt;
&lt;br /&gt;
== Image ==&lt;br /&gt;
An image shows a static image whose path is specified by its '''[[GUIWidgetInstanceWML#Widget|label]]''' key. Unlike other widgets, the '''label''' key here is not translatable since it specifies a path. The path is a standard WML path, i.e., &amp;lt;code&amp;gt;label=&amp;quot;units/konrad.png&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;label=&amp;quot;~add-ons/MyAddon/image/test.png&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It has no other extra fields.&lt;br /&gt;
&lt;br /&gt;
== Label ==&lt;br /&gt;
A label displays text provided via the '''[[GUIWidgetInstanceWML#Widget|label]]''' key that can be wrapped but no scrollbars are provided. For a version with scrollbars, see the [[GUIWidgetInstanceWML#Scroll_Label|Scroll Label]] widget.&lt;br /&gt;
&lt;br /&gt;
[[File:Title Label.png|frame|right|A Label with definition &amp;quot;title&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
List with the label specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| wrap || [[GUIVariable#bool|bool]] || false || Is wrapping enabled for the label.&lt;br /&gt;
|-&lt;br /&gt;
| characters_per_line || [[GUIVariable#unsigned|unsigned]] || 0 || Sets the maximum number of characters per line. This is only an approximate means of limiting the line's length, since the width of a character differs. E.g. iii is smaller than MMM. When the value is non-zero it also implies '''wrap''' is true. &lt;br /&gt;
When having long strings, wrapping them can increase readability. A rule of thumb is 66 characters per line is considered the optimum for a one column text.&lt;br /&gt;
|-&lt;br /&gt;
| text_alignment || [[GUIVariable#h_align|h_align]] || left || The way the text is aligned inside the canvas.&lt;br /&gt;
|-&lt;br /&gt;
| can_shrink || [[GUIVariable#bool|bool]] || false || Whether the label can shrink past its optimal size.&lt;br /&gt;
|-&lt;br /&gt;
| link_aware || [[GUIVariable#bool|bool]] || false || 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;
&lt;br /&gt;
== Listbox ==&lt;br /&gt;
A listbox is a control that holds several items of the same type. Normally the items in a listbox are ordered in rows, this version might allow more options for ordering the items in the future.&lt;br /&gt;
&lt;br /&gt;
List with the listbox specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| header&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional header. (This grid will automatically get the id _header_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| footer&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| []&lt;br /&gt;
| Defines the grid for the optional footer. (This grid will automatically get the id _footer_grid.)&lt;br /&gt;
|-&lt;br /&gt;
| list_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a listbox item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|-&lt;br /&gt;
| list_data&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the listbox. Every row must have the same number of columns as the 'list_definition'.&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, less than one row can be selected.&lt;br /&gt;
|-&lt;br /&gt;
| has_maximum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If false, more than one row can be selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In order to force widgets to be the same size inside a listbox, the widgets&lt;br /&gt;
need to be inside a linked_group.&lt;br /&gt;
&lt;br /&gt;
Inside the list section there are only the following widgets allowed&lt;br /&gt;
* grid (to nest)&lt;br /&gt;
* selectable widgets which are&lt;br /&gt;
** toggle_button&lt;br /&gt;
** toggle_panel&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
List with the matrix specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Menu Button ==&lt;br /&gt;
[[File:Menu Button.png|thumb|left|A Menu Button with it's list open.]]&lt;br /&gt;
A button that shows a dropdown list when clicked. The user can select any one of the predefined options.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;menu_button&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| icon || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || WML path to the icon to be shown alongside the text in this option, if any.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Minimap ==&lt;br /&gt;
A minimap to show the gamemap, this only shows the map and has no interaction options. This version is used for map previews, there will be a another version which allows interaction.&lt;br /&gt;
&lt;br /&gt;
A minimap has no extra fields.&lt;br /&gt;
&lt;br /&gt;
== Multiline Text ==&lt;br /&gt;
{{DevFeature1.17|26}}&lt;br /&gt;
&lt;br /&gt;
Base class for a multiline text area.  Not to be used directly in a GUI, use the [[GUIWidgetInstanceWML#Scroll_Text|scroll_text]] widget instead.&lt;br /&gt;
&lt;br /&gt;
The following variables exist:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The initial text of the text box.&lt;br /&gt;
|-&lt;br /&gt;
| history&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The name of the history for the text box. A history saves the data entered in a text box between the games. With the up and down arrow it can be accessed. To create a new history item just add a new unique name for this field and the engine will handle the rest.&lt;br /&gt;
|-&lt;br /&gt;
| editable&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| &amp;quot;true&amp;quot;&lt;br /&gt;
| If the contents of the text box can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multimenu Button ==&lt;br /&gt;
[[File:Multimenu Button.png|thumb|right|A Multimenu Button with its list open]]&lt;br /&gt;
A widget clicking on which shows a list from which one or more options can be selected.&lt;br /&gt;
&lt;br /&gt;
List with the multimenu_button specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value || [[GUIVariable#int|int]] || 0 || The return value.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_shown || [[GUIVariable#int|int]] || -1 || The maximum number of currently selected values to list on the button.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Subtag [option] ===&lt;br /&gt;
Specifies the initial list of options to be shown in the &amp;lt;code&amp;gt;multimenu_button&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the option.&lt;br /&gt;
|-&lt;br /&gt;
| tooltip || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Tooltip that is shown when the mouse hovers above this option.&lt;br /&gt;
|-&lt;br /&gt;
| checkbox || [[GUIVariable#bool|bool]] || &amp;quot;&amp;quot; || Whether the checkbox alongside this option is selected or not.&lt;br /&gt;
|-&lt;br /&gt;
| details || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Short description about this option.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi page ==&lt;br /&gt;
A multi page is a control that contains several 'pages' of which only one is visible. The pages can contain the same widgets containing the same 'kind' of data or look completely different.&lt;br /&gt;
&lt;br /&gt;
List with the multi page specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| page_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a multi page item looks. It must contain the grid definition for at least one page.&lt;br /&gt;
|-&lt;br /&gt;
| page_data&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| []&lt;br /&gt;
| A grid alike section which stores the initial data for the multi page. Every row must have the same number of columns as the 'page_definition'.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Panel ==&lt;br /&gt;
A panel is an item which can hold other items. The difference between a grid and a panel is that it's possible to define how a panel looks. A grid in an invisible container to just hold the items.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Password box ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The initial text of the password box.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Progress bar ==&lt;br /&gt;
A progress bar shows the progress of a certain object.&lt;br /&gt;
&lt;br /&gt;
A progress bar has no extra fields.&lt;br /&gt;
&lt;br /&gt;
== Repeating button ==&lt;br /&gt;
A repeating_button is a control that can be pushed down and repeat a certain action. Once the button is down every x milliseconds it is down a new down event is triggered.&lt;br /&gt;
&lt;br /&gt;
== Rich Label ==&lt;br /&gt;
{{DevFeature1.19|x}}&lt;br /&gt;
&lt;br /&gt;
A label that shows formatted text marked up with [[Help markup]]. It can show embedded images, links and tables inside text.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| text_alignment || [[GUIVariable#h_align|h_align]] || left || The way the text is aligned inside the canvas.&lt;br /&gt;
|-&lt;br /&gt;
| padding || [[GUIVariable#int|int]] || 5 || Internal padding, used in various spaces and between different types of elements (for example, between two float image, between a header and following text and so on).&lt;br /&gt;
|-&lt;br /&gt;
| link_aware || [[GUIVariable#bool|bool]] || true || 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;
&lt;br /&gt;
== Scroll Label ==&lt;br /&gt;
A scroll label is a label that wraps its text and also has a vertical scrollbar. This way a text can't be too long to be shown for this widget.&lt;br /&gt;
&lt;br /&gt;
List with the scroll label specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scroll Text ==&lt;br /&gt;
{{DevFeature1.19|x}}&lt;br /&gt;
&lt;br /&gt;
A multiline text area that shows a scrollbar if the text gets too long.&lt;br /&gt;
&lt;br /&gt;
List with the scrollbar container specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| editable&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| &amp;quot;true&amp;quot;&lt;br /&gt;
| If the contents of this scroll_text can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scrollbar panel ==&lt;br /&gt;
Instance of a scrollbar_panel.&lt;br /&gt;
&lt;br /&gt;
List with the scrollbar_panel specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| This defines how a scrollbar_panel item looks. It must contain the grid definition for 1 row of the list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Slider ==&lt;br /&gt;
&lt;br /&gt;
A slider is a control that can select a value by moving a grip on a groove.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| best_slider_length&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The best length for the sliding part.&lt;br /&gt;
|-&lt;br /&gt;
| minimum_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The minimum value the slider can have.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The maximum value the slider can have.&lt;br /&gt;
|-&lt;br /&gt;
| step_size&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The number of items the slider's value increases with one step.&lt;br /&gt;
|-&lt;br /&gt;
| value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The value of the slider.&lt;br /&gt;
|-&lt;br /&gt;
| minimum_value_label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If the minimum value is chosen there might be the need for a special value (eg off). When this key has a value that value will be shown if the minimum is selected.&lt;br /&gt;
|-&lt;br /&gt;
| maximum_value_label&lt;br /&gt;
| [[GUIVariable#t_string|t_string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| If the maximum value is chosen there might be the need for a special value (eg unlimited)). When this key has a value that value will be shown if the maximum is selected.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spinner ==&lt;br /&gt;
{{DevFeature1.17|26}}&lt;br /&gt;
&lt;br /&gt;
[[File:Spinner.png|thumb|right]]&lt;br /&gt;
&lt;br /&gt;
A textbox with two repeating buttons, which allow increasing/decreasing of the numerical value inside the textbox.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&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;
| 0&lt;br /&gt;
| Should the contents of the textbox wrap?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spacer ==&lt;br /&gt;
A spacer is a dummy item to either fill in a widget since no empty items are allowed or to reserve a fixed space.&lt;br /&gt;
&lt;br /&gt;
If either the width or the height is non-zero the spacer functions as a&lt;br /&gt;
fixed size spacer.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| width || [[GUIVariable#f_unsigned|f_unsigned]] || 0 || The width of the spacer.&lt;br /&gt;
|-&lt;br /&gt;
| height || [[GUIVariable#f_unsigned|f_unsigned]] || 0 || The height of the spacer.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The variable available are the same as for the window resolution see&lt;br /&gt;
http://www.wesnoth.org/wiki/GUIToolkitWML#Resolution_2 for the list of&lt;br /&gt;
items.&lt;br /&gt;
&lt;br /&gt;
== Tab Container ==&lt;br /&gt;
{{DevFeature1.19|0}}&lt;br /&gt;
&lt;br /&gt;
A container widget that can show its contents separated into various pages, each of which are accessible.&lt;br /&gt;
&lt;br /&gt;
It can contain one or more &amp;lt;code&amp;gt;[tab]&amp;lt;/code&amp;gt; tags inside it, each defining a tab's name, image (if any) and the contents of the tag, specified by the &amp;lt;code&amp;gt;[data]&amp;lt;/code&amp;gt; tag inside the &amp;lt;code&amp;gt;[tab]&amp;lt;/code&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
=== Subtag [tab] ===&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| name || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || Name of the tab&lt;br /&gt;
|-&lt;br /&gt;
| image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image for the tab to be shown alongside the name, if any&lt;br /&gt;
|-&lt;br /&gt;
| [data] || [[GUIVariable#grid|grid]] || empty grid || This subtag contains a grid that defines the contents for this tab.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Text box ==&lt;br /&gt;
A single line text entry widget.&lt;br /&gt;
&lt;br /&gt;
[[File:Text Box.png|frame|right|A Text Box]]&lt;br /&gt;
&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key !!type !!default !!description&lt;br /&gt;
|-&lt;br /&gt;
| label || [[GUIVariable#t_string|t_string]] || &amp;quot;&amp;quot; || The initial text of the text box.&lt;br /&gt;
|-&lt;br /&gt;
| history || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || The name of the history for the text box. A history saves the data entered in a text box between the games. With the up and down arrow it can be accessed. To create a new history item just add a new unique name for this field and the engine will handle the rest.&lt;br /&gt;
|-&lt;br /&gt;
| max_input_length || [[GUIVariable#int|int]] || 0 || Maximum length of text in characters that can be entered into the combobox&lt;br /&gt;
|-&lt;br /&gt;
| hint_text || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Text that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| hint_image || [[GUIVariable#string|string]] || &amp;quot;&amp;quot; || Image that is shown in the background when there is no input&lt;br /&gt;
|-&lt;br /&gt;
| editable || [[GUIVariable#bool|bool]] || &amp;quot;true&amp;quot; || If the contents of the text box can be edited.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Toggle button ==&lt;br /&gt;
Variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Toggle panel ==&lt;br /&gt;
A toggle panel is an item which can hold other items. The difference between&lt;br /&gt;
a grid and a panel is that it's possible to define how a panel looks. A grid&lt;br /&gt;
in an invisible container to just hold the items. The toggle panel is a&lt;br /&gt;
combination of the panel and a toggle button, it allows a toggle button with&lt;br /&gt;
its own grid.&lt;br /&gt;
&lt;br /&gt;
Variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grid&lt;br /&gt;
| [[GUIVariable#grid|grid]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| Defines the grid with the widgets to place on the panel.&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#string|string]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| The return value id, see [[GUIToolkitWML#Button]] for more information.&lt;br /&gt;
|-&lt;br /&gt;
| return_value&lt;br /&gt;
| [[GUIVariable#int|int]]&lt;br /&gt;
| 0&lt;br /&gt;
| The return value, see [[GUIToolkitWML#Button]] for more information.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tree view ==&lt;br /&gt;
A tree view is a control that holds several items of the same or different types. The items shown are called tree view nodes and when a node has children, these can be shown or hidden. Nodes that contain children need to provide a clickable button in order to fold or unfold the children.&lt;br /&gt;
&lt;br /&gt;
List with the tree view specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| vertical_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| horizontal_scrollbar_mode&lt;br /&gt;
| [[GUIVariable#scrollbar_mode|scrollbar_mode]]&lt;br /&gt;
| initial_auto&lt;br /&gt;
| Determines whether or not to show the scrollbar.&lt;br /&gt;
|-&lt;br /&gt;
| indention_step_size&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| 0&lt;br /&gt;
| The number of pixels every level of nodes is indented from the previous level.&lt;br /&gt;
|-&lt;br /&gt;
| node&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The tree view can contain multiple node sections. This part needs more documentation.&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| .&lt;br /&gt;
|-&lt;br /&gt;
| return_value_id&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
| .&lt;br /&gt;
|-&lt;br /&gt;
| has_minimum&lt;br /&gt;
| [[GUIVariable#bool|bool]]&lt;br /&gt;
| true&lt;br /&gt;
| If true, a tree with at least one item will always have something selected (except when items are being deleted). Although this is {{DevFeature1.19|21}}, the previous behavior is equivalent to setting this to true. The GUI doesn't provide a way to unselect items, the purpose of setting this to false is to add a landing page, as the campaign menu does.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
NOTE more documentation and examples are needed.&lt;br /&gt;
&lt;br /&gt;
== Vertical scrollbar ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Viewport ==&lt;br /&gt;
A viewport is an special widget used to view only a part of the widget it `holds'.&lt;br /&gt;
&lt;br /&gt;
List with the viewport specific variables:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!key&lt;br /&gt;
!type&lt;br /&gt;
!default&lt;br /&gt;
!description&lt;br /&gt;
|-&lt;br /&gt;
| grow_direction&lt;br /&gt;
| [[GUIVariable#grow_direction|grow_direction]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The direction in which new items grow.&lt;br /&gt;
|-&lt;br /&gt;
| parallel_items&lt;br /&gt;
| [[GUIVariable#unsigned|unsigned]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The number of items that are growing in parallel.&lt;br /&gt;
|-&lt;br /&gt;
| item_definition&lt;br /&gt;
| [[GUIVariable#section|section]]&lt;br /&gt;
| mandatory&lt;br /&gt;
| The definition of a new item.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;br /&gt;
[[Category: GUI WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74845</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74845"/>
		<updated>2026-02-16T15:19:47Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Widget Callbacks */ Sort subsections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
* ''widget''.'''best_slider_length''' &amp;amp;harr; ''length''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== editable ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
If this text box is editable, i.e., read-only. (Text can be selected/copied but not modified.)&lt;br /&gt;
&lt;br /&gt;
=== ellipsize_mode ===&lt;br /&gt;
* ''widget''.'''ellipsize_mode''' &amp;amp;harr; ''ellipsization mode string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.EllipsizeMode.html Pango ellipsization mode] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
|-&lt;br /&gt;
| start&lt;br /&gt;
|-&lt;br /&gt;
| end&lt;br /&gt;
|-&lt;br /&gt;
| middle&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== help ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Help text for this widget.&lt;br /&gt;
&lt;br /&gt;
=== hint_image ===&lt;br /&gt;
* ''widget''.'''hint_image''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
A image that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== hint_text ===&lt;br /&gt;
* ''widget''.'''hint_text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
A background text that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== history ===&lt;br /&gt;
* ''widget''.'''history''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
Input history of this text box.&lt;br /&gt;
&lt;br /&gt;
=== indentation_step_size ===&lt;br /&gt;
* ''widget''.'''indentation_step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
How much should child nodes be offset from their parent node.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== link_aware ===&lt;br /&gt;
* ''widget''.'''link_aware''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]''', '''[scroll_label]''', '''[scroll_text]'''&lt;br /&gt;
Whether this widget recognizes inline links and allows clicking on them.&lt;br /&gt;
&lt;br /&gt;
=== link_color ===&lt;br /&gt;
* ''widget''.'''link_color''' &amp;amp;rarr; ''color string''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]'''&lt;br /&gt;
Color of the inline link, as an hex string.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
* ''widget''.'''maximum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== max_input_length ===&lt;br /&gt;
* ''widget''.'''max_input_length''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
Maximum number of character than can be input into this widget.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
* ''widget''.'''minimum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== overflow_to_tooltip ===&lt;br /&gt;
* ''widget''.'''overflow_to_tooltip''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== step_size ===&lt;br /&gt;
* ''widget''.'''step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== text_alignment ===&lt;br /&gt;
* ''widget''.'''text_alignment''' &amp;amp;harr; ''text alignment string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.Alignment.html Pango text alignment] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value&lt;br /&gt;
|-&lt;br /&gt;
| left&lt;br /&gt;
|-&lt;br /&gt;
| right&lt;br /&gt;
|-&lt;br /&gt;
| center&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;harr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== wrap ===&lt;br /&gt;
* ''widget''.'''wrap''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
Whether the text content in this label can wrap.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74844</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74844"/>
		<updated>2026-02-16T15:16:18Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Widget Attributes */ Sort attributes alphabetically. (via some find&amp;amp;replace and Linux `sort` utility)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
* ''widget''.'''best_slider_length''' &amp;amp;harr; ''length''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== editable ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
If this text box is editable, i.e., read-only. (Text can be selected/copied but not modified.)&lt;br /&gt;
&lt;br /&gt;
=== ellipsize_mode ===&lt;br /&gt;
* ''widget''.'''ellipsize_mode''' &amp;amp;harr; ''ellipsization mode string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.EllipsizeMode.html Pango ellipsization mode] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
|-&lt;br /&gt;
| start&lt;br /&gt;
|-&lt;br /&gt;
| end&lt;br /&gt;
|-&lt;br /&gt;
| middle&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== help ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Help text for this widget.&lt;br /&gt;
&lt;br /&gt;
=== hint_image ===&lt;br /&gt;
* ''widget''.'''hint_image''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
A image that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== hint_text ===&lt;br /&gt;
* ''widget''.'''hint_text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
A background text that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== history ===&lt;br /&gt;
* ''widget''.'''history''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
Input history of this text box.&lt;br /&gt;
&lt;br /&gt;
=== indentation_step_size ===&lt;br /&gt;
* ''widget''.'''indentation_step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
How much should child nodes be offset from their parent node.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== link_aware ===&lt;br /&gt;
* ''widget''.'''link_aware''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]''', '''[scroll_label]''', '''[scroll_text]'''&lt;br /&gt;
Whether this widget recognizes inline links and allows clicking on them.&lt;br /&gt;
&lt;br /&gt;
=== link_color ===&lt;br /&gt;
* ''widget''.'''link_color''' &amp;amp;rarr; ''color string''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]'''&lt;br /&gt;
Color of the inline link, as an hex string.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
* ''widget''.'''maximum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== max_input_length ===&lt;br /&gt;
* ''widget''.'''max_input_length''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
Maximum number of character than can be input into this widget.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
* ''widget''.'''minimum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== overflow_to_tooltip ===&lt;br /&gt;
* ''widget''.'''overflow_to_tooltip''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== step_size ===&lt;br /&gt;
* ''widget''.'''step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== text_alignment ===&lt;br /&gt;
* ''widget''.'''text_alignment''' &amp;amp;harr; ''text alignment string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.Alignment.html Pango text alignment] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value&lt;br /&gt;
|-&lt;br /&gt;
| left&lt;br /&gt;
|-&lt;br /&gt;
| right&lt;br /&gt;
|-&lt;br /&gt;
| center&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;harr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== wrap ===&lt;br /&gt;
* ''widget''.'''wrap''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
Whether the text content in this label can wrap.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74843</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74843"/>
		<updated>2026-02-16T04:40:36Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Widget Attributes */  Docs for more attrs in c2b2664eb21585a67afbb7bff931fb7b169eea47&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== indentation_step_size ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''indentation_step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
How much should child nodes be offset from their parent node.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== hint_text ===&lt;br /&gt;
* ''widget''.'''hint_text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
&lt;br /&gt;
A background text that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== hint_image ===&lt;br /&gt;
* ''widget''.'''hint_image''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
&lt;br /&gt;
A image that is shown on the widget when it is not focused and has no other text.&lt;br /&gt;
&lt;br /&gt;
=== history ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''history''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Input history of this text box.&lt;br /&gt;
&lt;br /&gt;
=== max_input_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''max_input_length''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]''', '''[combobox]'''&lt;br /&gt;
&lt;br /&gt;
Maximum number of character than can be input into this widget.&lt;br /&gt;
&lt;br /&gt;
=== link_aware ===&lt;br /&gt;
* ''widget''.'''link_aware''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]''', '''[scroll_label]''', '''[scroll_text]'''&lt;br /&gt;
&lt;br /&gt;
Whether this widget recognizes inline links and allows clicking on them.&lt;br /&gt;
&lt;br /&gt;
=== link_color ===&lt;br /&gt;
* ''widget''.'''link_color''' &amp;amp;rarr; ''color string''&lt;br /&gt;
* Available on: '''[label]''', '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Color of the inline link, as an hex string.&lt;br /&gt;
&lt;br /&gt;
=== wrap ===&lt;br /&gt;
* ''widget''.'''wrap''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
&lt;br /&gt;
Whether the text content in this label can wrap.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''best_slider_length''' &amp;amp;harr; ''length''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''minimum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''maximum_value_label''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== step_size ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''step_size''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;harr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== editable ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
If this text box is editable, i.e., read-only. (Text can be selected/copied but not modified.)&lt;br /&gt;
&lt;br /&gt;
=== help ===&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Help text for this widget.&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== overflow_to_tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''overflow_to_tooltip''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;harr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== ellipsize_mode ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''ellipsize_mode''' &amp;amp;harr; ''ellipsization mode string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.EllipsizeMode.html Pango ellipsization mode] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value &lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
|-&lt;br /&gt;
| start&lt;br /&gt;
|-&lt;br /&gt;
| end&lt;br /&gt;
|-&lt;br /&gt;
| middle&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== text_alignment ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text_alignment''' &amp;amp;harr; ''text alignment string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Sets the [https://docs.gtk.org/Pango/enum.Alignment.html Pango text alignment] for the widget. Accepts only one of the special strings:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value &lt;br /&gt;
|-&lt;br /&gt;
| left&lt;br /&gt;
|-&lt;br /&gt;
| right&lt;br /&gt;
|-&lt;br /&gt;
| center&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74842</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74842"/>
		<updated>2026-02-16T03:58:56Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* maximum_value_label */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74841</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74841"/>
		<updated>2026-02-16T03:58:47Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* minimum_value_label */ label -&amp;gt; text&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''label''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74840</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74840"/>
		<updated>2026-02-16T03:58:23Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* label */ add characters_per_line (c2b2664eb21585a67afbb7bff931fb7b169eea47)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''label''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''label''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== characters_per_line ===&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''int''&lt;br /&gt;
* Available on: '''[label]'''&lt;br /&gt;
&lt;br /&gt;
Maximum characters this label should show per line.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74839</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74839"/>
		<updated>2026-02-16T03:54:00Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* value */ Info for more attributes as of c2b2664eb21585a67afbb7bff931fb7b169eea47&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== best_slider_length ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
Best length of the slider.&lt;br /&gt;
&lt;br /&gt;
=== minimum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''label''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at minimum value position.&lt;br /&gt;
&lt;br /&gt;
=== maximum_value_label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''label''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The text the slider's label shows when it is at maximum value position.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74838</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74838"/>
		<updated>2026-02-16T03:49:14Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* unfolded */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]''', '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74837</id>
		<title>LuaAPI/types/widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/types/widget&amp;diff=74837"/>
		<updated>2026-02-16T03:48:48Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* item_count */  Extra support as of c2b2664eb21585a67afbb7bff931fb7b169eea47&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''widget''' userdata offers access to a widget of a GUI2 dialog. While there is only one type of widget userdata that covers all widgets including the window itself, the properties of a widget userdata are different for each type of widget. Indexing a widget's userdata can either be used to access a child widget or to set or get a property of a widget. Some properties are read-only or write-only; the properties depend on the type of the widget.&lt;br /&gt;
&lt;br /&gt;
An example of accessing a child widget:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=lua&amp;gt;&lt;br /&gt;
function preshow(dialog)&lt;br /&gt;
  local okay_button = dialog.okay_button&lt;br /&gt;
  -- okay_button is now a handle to the the widget's child with the id 'okay_button' &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Widget Attributes ==&lt;br /&gt;
&lt;br /&gt;
=== selected ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected''' &amp;amp;harr; ''boolean''&lt;br /&gt;
* Available on: '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Whether the item is selected or not. Note that this should only be used for widgets that have only 2 states. In particular, there exist 3-State toggle_buttons (for example in listbox headers). For those, selected_index must be used instead.&lt;br /&gt;
&lt;br /&gt;
=== selected_index ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_index''' &amp;amp;harr; ''index''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[stacked_widget]''', '''[menu_button]''', '''[toggle_button]''', '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
The selected index of the item. For '''[toggle_button]''' and '''[toggle_panel]''', this is the same as '''selected''' only encoded as a number (1 for false or 2 for true) instead of a boolean.&lt;br /&gt;
&lt;br /&gt;
For a  '''[listbox]'''with '''has_maximum=false''' and more than one item selected, reading '''selected_index''' will return the first selected index.&lt;br /&gt;
&lt;br /&gt;
For a '''[stacked_widget]''', only the layer specified by '''selected_index''' will be displayed and receive events (callbacks will only be triggered on the selected layer).&lt;br /&gt;
A '''selected_index''' of 0 represents all layers being selected, with events only being received by the layer with the highest index.  Note that term ''selected'' for the ''layer'' of a stacked_widget is not the same as the '''selected''' ''widget'' attribute.&lt;br /&gt;
&lt;br /&gt;
=== text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''text''' &amp;amp;harr; ''text''&lt;br /&gt;
* Available on: '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
The text of the textbox.&lt;br /&gt;
&lt;br /&gt;
=== value ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''value''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[slider]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the slider.&lt;br /&gt;
&lt;br /&gt;
=== percentage ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''percentage''' &amp;amp;harr; ''position''&lt;br /&gt;
* Available on: '''[progress_bar]'''&lt;br /&gt;
&lt;br /&gt;
The current position of the progress bar, between 0 and 100.&lt;br /&gt;
&lt;br /&gt;
=== selected_item_path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''selected_item_path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view]'''&lt;br /&gt;
&lt;br /&gt;
A table describing the currently selected node. If for example, in the following treeview, Item 9 is selected, the result will be {2,1,3}.&lt;br /&gt;
&lt;br /&gt;
 +Section1&lt;br /&gt;
  +Subsection11&lt;br /&gt;
   *Item1&lt;br /&gt;
   *Item2&lt;br /&gt;
   *Item3&lt;br /&gt;
  +Subsection12&lt;br /&gt;
   *Item4&lt;br /&gt;
   *Item5&lt;br /&gt;
   *Item6&lt;br /&gt;
 +Section2&lt;br /&gt;
  +Subsection21&lt;br /&gt;
   *Item7&lt;br /&gt;
   *Item8&lt;br /&gt;
   *Item9&lt;br /&gt;
  +Subsection22&lt;br /&gt;
   *Item10&lt;br /&gt;
   *Item11&lt;br /&gt;
   *Item12&lt;br /&gt;
&lt;br /&gt;
=== path ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''path''' &amp;amp;rarr; ''array of indices''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
A table describing this node in the overall treeview. See [[#selected_item_path|selected_item_path]] for the meaning of the table..&lt;br /&gt;
&lt;br /&gt;
=== unfolded ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unfolded''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: '''[tree_view_node]'''&lt;br /&gt;
&lt;br /&gt;
Control whether a tree node is currently expanded or not.&lt;br /&gt;
&lt;br /&gt;
=== unit ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''unit''' &amp;amp;larr; ''unit or unit type''&lt;br /&gt;
* Available on: '''[unit_preview_pane]'''&lt;br /&gt;
&lt;br /&gt;
Change the displayed unit or unit type in the preview pane.&lt;br /&gt;
&lt;br /&gt;
=== item_count ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''item_count''' &amp;amp;rarr; ''number of items''&lt;br /&gt;
* Available on: '''[multi_page]''', '''[listbox]''',  '''[combobox]''',  '''[stacked_widget]''', '''[tree_view]''',  '''[tree_view_node]''', '''[styled_widget]'''&lt;br /&gt;
&lt;br /&gt;
The number of items in the container widget.&lt;br /&gt;
&lt;br /&gt;
=== use_markup ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''use_markup''' &amp;amp;rarr; ''boolean''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Sets whether the widget's label will parse [[Pango formatting]].&lt;br /&gt;
&lt;br /&gt;
=== label ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''label''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]''', '''[image]'''&lt;br /&gt;
&lt;br /&gt;
The widget's label. Technically this is a special string used in the widget's wml definition. It usually does what one would expect, but also sets the image for '''image''' widgets.  For '''[text_box]''', use '''text''' for initial values.&lt;br /&gt;
&lt;br /&gt;
=== marked_up_text ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''marked_up_text''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets, in particular '''[label]''', '''[button]'''&lt;br /&gt;
&lt;br /&gt;
Shortcut for setting label and use_markup=yes.&lt;br /&gt;
&lt;br /&gt;
=== enabled ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''enabled''' &amp;amp;larr; ''boolean''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== tooltip ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''tooltip''' &amp;amp;larr; ''text''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
=== visible ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''visible''' &amp;amp;larr; ''visibility string''&lt;br /&gt;
* Available on: Most widgets&lt;br /&gt;
&lt;br /&gt;
Determines whether the widget is visible onscreen. The following visibility statuses are recognized:&lt;br /&gt;
{| clasS=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! String value !! Boolean shorthand !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| visible || true || The widget is visible and handles events.&lt;br /&gt;
|-&lt;br /&gt;
| hidden || || The widget is not visible, doesn't handle events, but still takes up space on the dialog grid.&lt;br /&gt;
|-&lt;br /&gt;
| invisible || false || The widget is not visible, doesn't handle events, and does not take up space on the dialog grid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''type''' &amp;amp;rarr; ''string''&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Returns a string specifying the type of the widget.&lt;br /&gt;
&lt;br /&gt;
== Widget Callbacks ==&lt;br /&gt;
&lt;br /&gt;
=== on_modified ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_modified''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: Most widgets, in particular '''[slider]''', '''[toggle_button]''', '''[listbox]''', '''[menu_button]''', '''[text_box]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user changes the value of the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_left_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_left_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: All widgets&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the widget.&lt;br /&gt;
&lt;br /&gt;
=== on_double_click ===&lt;br /&gt;
{{DevFeature1.19|14}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_double_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[toggle_panel]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user double clicks on the widget. Non-toggle panel widgets can be wrapped in a toggle panel to make use of this event handler.&lt;br /&gt;
&lt;br /&gt;
=== on_button_click ===&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_button_click''' &amp;amp;larr; '''function'''()&lt;br /&gt;
* Available on: '''[button]''', '''[repeating_button]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on the button. This can differ from '''on_left_click''', depending on the type of widget. For example, on a '''[repeating_button]''' it will fire multiple times if the user holds the mouse button down.&lt;br /&gt;
&lt;br /&gt;
=== on_link_click ===&lt;br /&gt;
{{DevFeature1.19|9}}&lt;br /&gt;
&lt;br /&gt;
* ''widget''.'''on_link_click''' &amp;amp;larr; '''function'''(''dest'')&lt;br /&gt;
* Available on: '''[rich_label]'''&lt;br /&gt;
&lt;br /&gt;
Triggers when the user clicks on a '''&amp;lt;ref&amp;gt;''' link inside a '''[rich_label]'''. The first argument '''dest''' is the target of the link.&lt;br /&gt;
&lt;br /&gt;
== Widget Length ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}}&lt;br /&gt;
&lt;br /&gt;
* '''#'''''widget''&lt;br /&gt;
* Available on: '''[listbox]''', '''[multi_page]''', '''[tree_view]''', '''[tree_view_node]''', {{DevFeature1.19|6}} '''[stacked_widget]'''&lt;br /&gt;
&lt;br /&gt;
Returns the total number of children in the specified container widget – for example, the number of rows in a list box, or the number of pages in a multi-page.&lt;br /&gt;
&lt;br /&gt;
== Widget Methods ==&lt;br /&gt;
&lt;br /&gt;
Any function defined in the [[LuaAPI/gui/widget|gui.widget]] module and taking a widget as its first parameter can be called as a method of a widget. This includes any functions that are added to the module by user code. Note that these methods are available even if the widget itself doesn't support that function, so in some cases it may be necessary to check '''widget.type''' before calling the method.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74825</id>
		<title>Android</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74825"/>
		<updated>2026-02-13T09:11:17Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Dev Notes */  add info about manifest.txt and status.properties files. syntax info will be added later.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This pages contains some specific information about the Battle for Wesnoth new Android port (1.19+)&lt;br /&gt;
&lt;br /&gt;
== Playing controls ==&lt;br /&gt;
* Tap a unit to select/deselect it.&lt;br /&gt;
* Tap a unit, then tap the target hex to show defense stats of that unit and footsteps. (Similar to hover on PC)&lt;br /&gt;
* Tap a unit, then double tap on the target hex to move it. Alternative, you can drag along the path to choose the exact path which the unit is supposed to move by.&lt;br /&gt;
* Drag from attacker unit towards attacked unit to attack.&lt;br /&gt;
* Long press on any hex to show the Right-click context menu that has Recruit/Recall etc.&lt;br /&gt;
&lt;br /&gt;
== The Settings menu (Splash screen) ==&lt;br /&gt;
&lt;br /&gt;
== Logs and debugging steps ==&lt;br /&gt;
* Install adb (Android Debug Bridge) on your computer. Search internet for information about your OS. Install drivers for your phone/tablet if necessary.&lt;br /&gt;
* Enable Developer Mode on your Android device (phone/tablet). Again, the internet is your friend. On newer devices, you need tap Settings &amp;gt; About Phone &amp;gt; Build Number 7 times until it says &amp;quot;You are now a developer&amp;quot;, then go into the Setting &amp;gt; System &amp;gt; Developer Options (newly appeared), and find &amp;quot;USB Debugging&amp;quot; in the menu and turn that on.&lt;br /&gt;
* Connect phone to PC. Do &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; or similar from a terminal/command prompt to see if your device appears on the list and is authorized. Tap ok on your phone if any permission request appears.&lt;br /&gt;
* Run &amp;lt;code&amp;gt;adb logcat -c&amp;lt;/code&amp;gt; (clears existing logs), then &amp;lt;code&amp;gt;adb logcat &amp;gt; log.txt&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; and copy from terminal). Run Wesnoth on phone. Reproduce the crash.&lt;br /&gt;
* stop &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; on PC, and attach the &amp;lt;code&amp;gt;log.txt&amp;lt;/code&amp;gt; to your issue report on github along with detailed steps of the bug, and use the Android label.&lt;br /&gt;
&lt;br /&gt;
(Note: adb can be &amp;lt;code&amp;gt;./adb.exe&amp;lt;/code&amp;gt; on Windows. Use internet for help on any of the steps if needed, this is supposed to be a preliminary guideline. Steps might slightly differ based on manufacturer or Android version.)&lt;br /&gt;
&lt;br /&gt;
=== Enabling taps ===&lt;br /&gt;
It is useful for debugging purposes, especially if you're sharing a screen recording of your bug, to show where you're tapping on the screen in the screen recording. See [https://discussio.zendesk.com/hc/en-gb/articles/4625151970065-How-to-Show-Taps-for-Mobile-Screen-Sharing-on-Android here] for how to enable that.&lt;br /&gt;
&lt;br /&gt;
=== Turning off Developer Mode ===&lt;br /&gt;
Go to System &amp;gt; Developer Options and turn off  the '''Use developer options''' toggle.&lt;br /&gt;
&lt;br /&gt;
== Dev Notes ==&lt;br /&gt;
=== Package manifest (manifest.txt) and download status file (status.properties) ===&lt;br /&gt;
{{DevFeature1.19|19}}&lt;br /&gt;
&lt;br /&gt;
The package manifest file (&amp;lt;code&amp;gt;manifest.txt&amp;lt;/code&amp;gt;) is a file on the Wesnoth sourceforge site that the Android Wesnoth client reads to figure out available packages for download. For example, for Wesnoth 1.19.19 it is located here: [https://sourceforge.net/projects/wesnoth/files/wesnoth/wesnoth-1.19.19/android-data/manifest.txt/download manifest.txt]. This path is mostly hardcoded [https://github.com/wesnoth/wesnoth/blob/ff3ad482074d2698762cffcad08660c77ea1bb2c/packaging/android/app/src/main/java/org/wesnoth/Wesnoth/InitActivity.java#L66-L67 here] with only the version code part changing per release.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;status.properties&amp;lt;/code&amp;gt; file is generated by the Android client to track details of downloaded packages, and is created inside &amp;lt;code&amp;gt;/sdcard/Android/data/org.wesnoth.Wesnoth/files/gamedata&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Version Code scheme (1191601001 - post 1.19.16 fixup) ===&lt;br /&gt;
&amp;lt;code&amp;gt;MmmPPppVVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; - Major version code, so far at 1; since the max versionCode is 21000000 it can go up to 2&lt;br /&gt;
* &amp;lt;code&amp;gt;mm&amp;lt;/code&amp;gt; - Minor version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;PP&amp;lt;/code&amp;gt; - Patch version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;pp&amp;lt;/code&amp;gt; - Android patch version/any other use.&lt;br /&gt;
* &amp;lt;code&amp;gt;VVV&amp;lt;/code&amp;gt; - Reserved for ABI/Variants.&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Rest unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
=== New Version Code scheme draft ===&lt;br /&gt;
This is but one possible idea among many, and is not final.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;MSUUmmPPppVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* 1 - Major version code. Wesnoth's version's first digit is almost always 1, but the max versionCode is 21000000 so it can go upto 2 if needed.&lt;br /&gt;
* S - store identifier (must be greater than 2 to allow upgrade from previous scheme.) For example:&lt;br /&gt;
** &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; - F-Droid&lt;br /&gt;
** &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; - Google Play&lt;br /&gt;
** Others if needed.&lt;br /&gt;
* UU - unused/unspecified.&lt;br /&gt;
* mm - Minor version&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* pp - Android Patch version&lt;br /&gt;
* VV - ABI/Variants&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Last but one digit - Unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
E.g., 1.20.14 with hotfix 1, Fdroid, arm64 ABI would be: &amp;lt;code&amp;gt;120020140102&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Other version code scheme drafts ===&lt;br /&gt;
&lt;br /&gt;
Given that we only have 10 digits to work with (max being 2.1e9, which is signed INT_MAX with some margin), the above scheme is not possible. The PR to remove/disable the existing version codes on f-droid has been rejected, so we're probably stuck with version codes &amp;gt; 1.19e9. &lt;br /&gt;
The highest version code currently (2025-10-02) in use is 1191601002.&lt;br /&gt;
&lt;br /&gt;
Further constraints are:&lt;br /&gt;
* version codes should go up&lt;br /&gt;
* each ABI needs its own version code&lt;br /&gt;
* we may have multiple APK releases for one &amp;quot;regular wesnoth version&amp;quot; to fix android-only issues (android patch version)&lt;br /&gt;
* we may have builds that differ per store (F-droid creates the file /data/dist with contents &amp;quot;F-Droid&amp;quot; during the build process)&lt;br /&gt;
* we may want various variants of builds, that is, a &amp;quot;clean&amp;quot; build, a build with google play integrations, a build with a different integration, and so on. This may or may not be tied to the store the APK is distributed on&lt;br /&gt;
&lt;br /&gt;
Drafts of possible approaches:&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;MMMPPpxxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
* MMM - Combined Major/Minor: 1.19 = 119, but each subsequent minor *or* major bump increases this number by 1. This remains visually the same until 2.0 happens.&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* p - Android patch version&lt;br /&gt;
* V - Build variant (0 is clean, 1 might be google play integrations. Could be a bitfield or an enum)&lt;br /&gt;
* A - ABI (as above)&lt;br /&gt;
* x - Unspecified, available for expanding these fields or adding other flags&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1220320002&amp;lt;/code&amp;gt; would be version 1.22 (or 2.0 or 2.2, but 2 stables from 1.18), patch 3, android patch 2, default (clean) variant, arm64&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMMPPpVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Basically the same thing, just shifted to the right by eating up the unspecified digits, and with the first digits fixed to 12. Leaves 8 &amp;quot;additional epochs&amp;quot; available for future expansion.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1212203202&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMPPpxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Removes the major version digit, freeing up 1 digit. Not functionally different from the major-minor scheme, but reduces the number of available version bumps until epoch change.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1222032002&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74824</id>
		<title>Android</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Android&amp;diff=74824"/>
		<updated>2026-02-13T08:55:01Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Dev Notes */ Promote section header levels&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This pages contains some specific information about the Battle for Wesnoth new Android port (1.19+)&lt;br /&gt;
&lt;br /&gt;
== Playing controls ==&lt;br /&gt;
* Tap a unit to select/deselect it.&lt;br /&gt;
* Tap a unit, then tap the target hex to show defense stats of that unit and footsteps. (Similar to hover on PC)&lt;br /&gt;
* Tap a unit, then double tap on the target hex to move it. Alternative, you can drag along the path to choose the exact path which the unit is supposed to move by.&lt;br /&gt;
* Drag from attacker unit towards attacked unit to attack.&lt;br /&gt;
* Long press on any hex to show the Right-click context menu that has Recruit/Recall etc.&lt;br /&gt;
&lt;br /&gt;
== The Settings menu (Splash screen) ==&lt;br /&gt;
&lt;br /&gt;
== Logs and debugging steps ==&lt;br /&gt;
* Install adb (Android Debug Bridge) on your computer. Search internet for information about your OS. Install drivers for your phone/tablet if necessary.&lt;br /&gt;
* Enable Developer Mode on your Android device (phone/tablet). Again, the internet is your friend. On newer devices, you need tap Settings &amp;gt; About Phone &amp;gt; Build Number 7 times until it says &amp;quot;You are now a developer&amp;quot;, then go into the Setting &amp;gt; System &amp;gt; Developer Options (newly appeared), and find &amp;quot;USB Debugging&amp;quot; in the menu and turn that on.&lt;br /&gt;
* Connect phone to PC. Do &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; or similar from a terminal/command prompt to see if your device appears on the list and is authorized. Tap ok on your phone if any permission request appears.&lt;br /&gt;
* Run &amp;lt;code&amp;gt;adb logcat -c&amp;lt;/code&amp;gt; (clears existing logs), then &amp;lt;code&amp;gt;adb logcat &amp;gt; log.txt&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; and copy from terminal). Run Wesnoth on phone. Reproduce the crash.&lt;br /&gt;
* stop &amp;lt;code&amp;gt;adb logcat&amp;lt;/code&amp;gt; on PC, and attach the &amp;lt;code&amp;gt;log.txt&amp;lt;/code&amp;gt; to your issue report on github along with detailed steps of the bug, and use the Android label.&lt;br /&gt;
&lt;br /&gt;
(Note: adb can be &amp;lt;code&amp;gt;./adb.exe&amp;lt;/code&amp;gt; on Windows. Use internet for help on any of the steps if needed, this is supposed to be a preliminary guideline. Steps might slightly differ based on manufacturer or Android version.)&lt;br /&gt;
&lt;br /&gt;
=== Enabling taps ===&lt;br /&gt;
It is useful for debugging purposes, especially if you're sharing a screen recording of your bug, to show where you're tapping on the screen in the screen recording. See [https://discussio.zendesk.com/hc/en-gb/articles/4625151970065-How-to-Show-Taps-for-Mobile-Screen-Sharing-on-Android here] for how to enable that.&lt;br /&gt;
&lt;br /&gt;
=== Turning off Developer Mode ===&lt;br /&gt;
Go to System &amp;gt; Developer Options and turn off  the '''Use developer options''' toggle.&lt;br /&gt;
&lt;br /&gt;
== Dev Notes ==&lt;br /&gt;
=== Version Code scheme (1191601001 - post 1.19.16 fixup) ===&lt;br /&gt;
&amp;lt;code&amp;gt;MmmPPppVVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; - Major version code, so far at 1; since the max versionCode is 21000000 it can go up to 2&lt;br /&gt;
* &amp;lt;code&amp;gt;mm&amp;lt;/code&amp;gt; - Minor version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;PP&amp;lt;/code&amp;gt; - Patch version code.&lt;br /&gt;
* &amp;lt;code&amp;gt;pp&amp;lt;/code&amp;gt; - Android patch version/any other use.&lt;br /&gt;
* &amp;lt;code&amp;gt;VVV&amp;lt;/code&amp;gt; - Reserved for ABI/Variants.&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Rest unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
=== New Version Code scheme draft ===&lt;br /&gt;
This is but one possible idea among many, and is not final.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;MSUUmmPPppVV&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where,&lt;br /&gt;
* 1 - Major version code. Wesnoth's version's first digit is almost always 1, but the max versionCode is 21000000 so it can go upto 2 if needed.&lt;br /&gt;
* S - store identifier (must be greater than 2 to allow upgrade from previous scheme.) For example:&lt;br /&gt;
** &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; - F-Droid&lt;br /&gt;
** &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; - Google Play&lt;br /&gt;
** Others if needed.&lt;br /&gt;
* UU - unused/unspecified.&lt;br /&gt;
* mm - Minor version&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* pp - Android Patch version&lt;br /&gt;
* VV - ABI/Variants&lt;br /&gt;
** Last digit - ABI (&amp;lt;code&amp;gt;['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]&amp;lt;/code&amp;gt;)&lt;br /&gt;
** Last but one digit - Unused (variants if we need them)&lt;br /&gt;
&lt;br /&gt;
E.g., 1.20.14 with hotfix 1, Fdroid, arm64 ABI would be: &amp;lt;code&amp;gt;120020140102&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Other version code scheme drafts ===&lt;br /&gt;
&lt;br /&gt;
Given that we only have 10 digits to work with (max being 2.1e9, which is signed INT_MAX with some margin), the above scheme is not possible. The PR to remove/disable the existing version codes on f-droid has been rejected, so we're probably stuck with version codes &amp;gt; 1.19e9. &lt;br /&gt;
The highest version code currently (2025-10-02) in use is 1191601002.&lt;br /&gt;
&lt;br /&gt;
Further constraints are:&lt;br /&gt;
* version codes should go up&lt;br /&gt;
* each ABI needs its own version code&lt;br /&gt;
* we may have multiple APK releases for one &amp;quot;regular wesnoth version&amp;quot; to fix android-only issues (android patch version)&lt;br /&gt;
* we may have builds that differ per store (F-droid creates the file /data/dist with contents &amp;quot;F-Droid&amp;quot; during the build process)&lt;br /&gt;
* we may want various variants of builds, that is, a &amp;quot;clean&amp;quot; build, a build with google play integrations, a build with a different integration, and so on. This may or may not be tied to the store the APK is distributed on&lt;br /&gt;
&lt;br /&gt;
Drafts of possible approaches:&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;MMMPPpxxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
* MMM - Combined Major/Minor: 1.19 = 119, but each subsequent minor *or* major bump increases this number by 1. This remains visually the same until 2.0 happens.&lt;br /&gt;
* PP - Patch version&lt;br /&gt;
* p - Android patch version&lt;br /&gt;
* V - Build variant (0 is clean, 1 might be google play integrations. Could be a bitfield or an enum)&lt;br /&gt;
* A - ABI (as above)&lt;br /&gt;
* x - Unspecified, available for expanding these fields or adding other flags&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1220320002&amp;lt;/code&amp;gt; would be version 1.22 (or 2.0 or 2.2, but 2 stables from 1.18), patch 3, android patch 2, default (clean) variant, arm64&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMMPPpVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Basically the same thing, just shifted to the right by eating up the unspecified digits, and with the first digits fixed to 12. Leaves 8 &amp;quot;additional epochs&amp;quot; available for future expansion.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1212203202&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;br /&gt;
&lt;br /&gt;
==== &amp;lt;code&amp;gt;12MMPPpxVA&amp;lt;/code&amp;gt; ====&lt;br /&gt;
Removes the major version digit, freeing up 1 digit. Not functionally different from the major-minor scheme, but reduces the number of available version bumps until epoch change.&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;1222032002&amp;lt;/code&amp;gt; would be version 1.22.3.2 clean arm64, as above.&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74785</id>
		<title>UnitsWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitsWML&amp;diff=74785"/>
		<updated>2026-01-29T14:05:40Z</updated>

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

		<summary type="html">&lt;p&gt;Bssarkar: /* Wesnoth Map Tracker */  fixup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page collects information about tools in the Wesnoth source tree that are intended to help you write campaign WML. &lt;br /&gt;
&lt;br /&gt;
== tmx_trackplacer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} '''tmx_trackplacer''' is a tool for editing journey tracks - the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
You'll need Tiled, a GPLv2 map editor:&lt;br /&gt;
* Debian / Ubuntu: install the &amp;quot;tiled&amp;quot; package&lt;br /&gt;
* other platforms: https://www.mapeditor.org/&lt;br /&gt;
* these instructions were written with version 1.2.4&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&lt;br /&gt;
Assume the campaign that we want to make a map for is Story of Wose, which is set on the Green Isle. Start by putting a copy of the map in the campaign:&lt;br /&gt;
&lt;br /&gt;
    mkdir Story_of_Wose/images/maps&lt;br /&gt;
    cp WESNOTH_DIR/data/campaigns/The_Rise_Of_Wesnoth/images/maps/green_isle.png Story_of_Wose/images/maps/&lt;br /&gt;
&lt;br /&gt;
Create a template .tmx file with the tool:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer Story_of_Wose/images/maps/green_isle.png -o temp.tmx&lt;br /&gt;
&lt;br /&gt;
=== In Tiled ===&lt;br /&gt;
&lt;br /&gt;
Start Tiled with the temp.tmx file. Expect to see the Green Isle map. On the right hand side of the screen there should be two windows:&lt;br /&gt;
* in the top, tabs ''Minimap'', ''Objects'' and ''Layers''. The Layers tab will have only ''background''.&lt;br /&gt;
* in the bottom, tabs ''Terrains'' and ''Tilesets''. The Tilesets tab should have ''wesnoth journey icons'' with the red dot, battle and rest markers.&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930950-ac876c80-f035-11e9-9599-d5dc4301acf2.png&lt;br /&gt;
&lt;br /&gt;
In Layers, create a ''New Layer'' of type ''Object Layer''. A typical name for this layer is '''JOURNEY'''. Ensure that this layer is selected.&lt;br /&gt;
From the menu bar at the top, select ''Insert Tile''.&lt;br /&gt;
From the Tilesets tab, choose dots, battles or rests, and click on the map to add them. The first two items placed will define the start of the journey; every item placed after the first two will be inserted in to the sequence based on whether it appears to be at the end or in the middle.&lt;br /&gt;
&lt;br /&gt;
For Story of Wose, the journey doubles back on itself. For this we'll split the journey in to two parts - rename '''JOURNEY''' to '''JOURNEY_PART1''', and add a new layer '''JOURNEY_PART2'''. You can use the opacity control at the top of the layers window to see what's on each layer.&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART1''' starts with a battle, and ends with a battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930947-abeed600-f035-11e9-89e8-efde15f2a48d.png&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART2''' starts with dots, has a battle and then ends with another battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930949-abeed600-f035-11e9-86a0-18c90c151c76.png&lt;br /&gt;
&lt;br /&gt;
Save the .tmx file.&lt;br /&gt;
&lt;br /&gt;
=== Creating the .cfg ===&lt;br /&gt;
&lt;br /&gt;
Convert the .tmx file to a .cfg file:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer temp.tmx -o Story_of_Wose/utils/bigmap.cfg&lt;br /&gt;
&lt;br /&gt;
Expect to see:&lt;br /&gt;
&lt;br /&gt;
    Read data: &amp;lt;Journey based on map file 'Story_of_Wose/images/maps/green_isle.png', with tracks {JOURNEY_PART1,JOURNEY_PART2}&amp;gt;&lt;br /&gt;
    Exporting as cfg&lt;br /&gt;
&lt;br /&gt;
At the moment, tmx_trackplacer doesn't have a way to preview the animations, other than loading the .cfg with Wesnoth itself. For testing, let's put all of the journey in at the start of the first scenario, Story_of_Wose/scenarios/1_The_Oldwood.cfg&lt;br /&gt;
&lt;br /&gt;
    #define STORY_BACKGROUND&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/background.jpg&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/green_isle.png&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
            base_layer=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
    #enddef&lt;br /&gt;
&lt;br /&gt;
    [story]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            story= _ &amp;quot;Today I want to tell you another story, a mere footnote in the history books if it is even remembered at all.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This should now show at the start of the campaign. Remember to refresh Wesnoth's cache if it doesn't appear.&lt;br /&gt;
&lt;br /&gt;
=== Could this be integrated as a Tiled plugin? ===&lt;br /&gt;
&lt;br /&gt;
Yes it could. Implementing it as a file converter was the easier option for development, and the code is (hopefully) modular enough for reuse.&lt;br /&gt;
&lt;br /&gt;
== trackviewer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} Map journey track animation preview tool, shows the journey without needing to start Wesnoth and refresh the cache. It’s a support program which assumes you’re either editing the .cfg file with a text editor or using Tiled with [[Authoring_tools#tmx_trackplacer|tmx_trackplacer]]; in other words, it's the part of the [[Authoring_tools#trackplacer|old trackplacer]] that wasn't covered by tmx_trackplacer.&lt;br /&gt;
&lt;br /&gt;
At least on Linux you can have both Tiled and this open on the same file. Save the file in Tiled, alt+tab to this, and press enter to reload the file.&lt;br /&gt;
&lt;br /&gt;
Keys:&lt;br /&gt;
* Escape quits&lt;br /&gt;
* Return or Enter reloads the .cfg or .tmx file, and restarts the animation&lt;br /&gt;
* Space pauses/unpauses&lt;br /&gt;
&lt;br /&gt;
== trackplacer ==&lt;br /&gt;
&lt;br /&gt;
'''UPDATE: per Elvish_Hunter in [https://forums.wesnoth.org/viewtopic.php?f=21&amp;amp;t=48478&amp;amp;p=631121#p631121 this thread]: &lt;br /&gt;
'''&amp;lt;nowiki&amp;gt;&amp;quot;trackplacer is outdated (it requires the obsolete PyGTK toolkit, which doesn't run on Python 3) and terribly bugged (it doesn't run at all on Windows, for example).&amp;quot;&amp;lt;/nowiki&amp;gt; You should either use [[Authoring tools#tmx_trackplacer|tmx_trackplacer]], or use image editing software to find the X and Y coordinates to create each dot or cross manually.&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' is a tool for visually editing journey tracks.  Journey tracks are the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
A 'journey' is an object containing a map file name and a (possibly empty) list of tracks, each with a name and each consisting of a sequence of track markers. This program exists to visually edit journeys represented as specially delimited sections in in .cfg files.&lt;br /&gt;
&lt;br /&gt;
When you run '''trackplacer''', it will pop up a file selection dialog asking you to select either a map image or a .cfg file.  When you select a map image, you will be starting a new set of journey tracks on that map.  If you select a .cfg, the .cfg will be scanned for macros describing journey tracks.  All other content in the .cfg, except for some magic special comments interpreted by '''trackplacer''' (which will be described later on) is ignored.&lt;br /&gt;
&lt;br /&gt;
Once you have a map (and possibly also a set of track for it), there is always a currently selected track (shown in red) and possibly one or more unselected tracks (shown in white).  You can add journey markers to the select track by clicking the left mouse button; they will appear on the screen.  The rule for adding markers to the track is as follows: if the two markers closest to the mouse pointer are adjacent on the track, insert the new marker between them in the track order. Otherwise, append it to the end of the track.&lt;br /&gt;
&lt;br /&gt;
You can click on and drag a marker with the middle mouse button to move it. Moving a marker preserves its place in the track order.  The right mouse button pops up an information window describing all features overlapping the pointer; it will disappear when you release.&lt;br /&gt;
&lt;br /&gt;
Radiobuttons in the upper-left-hand corner of the '''trackplacer''' window let you select placing battle markers (crossed swords) and rest markers (a flag).  If you click the trashcan icon, clicking on track markers will remove them.  If you click the copy/convert button, clicking on unselected track markers will copy them. &lt;br /&gt;
&lt;br /&gt;
When copying, '''trackplacer''' looks under the mouse pointer for a marker from an unselected track.  If it finds one, it creates a matching new icon on the selected track, preserving its pixel coordinates exactly.  This can be useful when you want two named tracks to end at exactly the same spot.&lt;br /&gt;
&lt;br /&gt;
The '''Animate''' button erases all icons, then redisplays them in order with a delay between each redraw, so you can see the track order.&lt;br /&gt;
&lt;br /&gt;
The '''Save''' button saves your work.  Your track will be saved on .cfg format as a sequence of macro definitions that you can insert in the story parts of your campaign.  Conventionally, the place to put this .cfg is in a file named 'journey.cfg' in the 'utils/' directory of your campaign, near your private macro files (if you have any).  Then the definitions will automatically be available in your scenario files.&lt;br /&gt;
&lt;br /&gt;
The '''Properties''' button brings up a dialog that allows you to edit key/value pairs associated with the track that may affect the behavior of '''trackplacer'''. Currently only two such properties are defined: &amp;quot;map&amp;quot; has the name of the track's base file as its value, and &amp;quot;prefix&amp;quot; sets the prefix to be used when generating macro names (defaulting to '''JOURNEY''').&lt;br /&gt;
&lt;br /&gt;
The '''Tracks''' button pops up a list of controls, one for each track.  You can change the state of the checkboxes to control which tracks are visible. The radiobuttons can be used to select a track for editing.  You can also add and rename tracks here.  Hover over the controls for tooltips.&lt;br /&gt;
&lt;br /&gt;
The Help button displays documentation.&lt;br /&gt;
&lt;br /&gt;
The Quit button ends your session, asking for confirmation if you have unsaved changes.&lt;br /&gt;
&lt;br /&gt;
To understand what your 'journey.cfg' does, you need to know that journey-track markers can be put on your story screens by two different sets of macros.  One, used for 'new' marks, is displayed in color with quarter-second delays; the other, 'old' set displays marks in white with no delay.  Your journey track is divided into stages by battle and rest markers; conventionally, you want to display the latest (most recent) stage with the new macros and all previous stages with the old ones.  &lt;br /&gt;
&lt;br /&gt;
Your track will be saved in .cfg format as a sequence of macro definitions with names like '''JOURNEY_STAGE_1''', '''JOURNEY_STAGE_2''' and so on.  '''JOURNEY_STAGE_1''' will draw the first stage in the 'new' color parts.  '''JOURNEY_STAGE_2''' will draw the first stage in the 'old' color and the second stage in the 'new' one; '''JOURNEY_STAGE_3''' will draw the first and second stages in the 'old' color parts and the third stage in the 'new' one; and so on.&lt;br /&gt;
&lt;br /&gt;
There will be a final macro '''JOURNEY_COMPLETE''' that displays the entire track in the 'old' color. This will be useful when you are piecing together multiple tracks, say for a campaign with branches.&lt;br /&gt;
&lt;br /&gt;
The track information in your journey.cfg will be enclosed in special comments&lt;br /&gt;
that look like this:&lt;br /&gt;
&lt;br /&gt;
    # trackplacer: tracks begin&lt;br /&gt;
    # trackplacer: tracks end&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' will not alter anything it finds outside these comments, and will always enclose everything it writes in them.&lt;br /&gt;
&lt;br /&gt;
Special comments may appear in your ''journey.cfg'', looking like this:&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;tt&amp;gt;# trackplacer: &amp;amp;lt;property&amp;amp;gt;=&amp;amp;lt;value&amp;amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These set properties that '''trackplacer''' may use.  At present there is only one such property: &amp;lt;tt&amp;gt;map&amp;lt;/tt&amp;gt;, which records the name of the mapfile on which your track is laid.  Don't remove this comment, '''trackplacer''' needs it.&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' has one known bug: you can confuse it (or possibly the underlying toolkit, or X) by dragging markers rapidly across other markers. If this happens to you, click '''Animate''' to refresh and slow down.&lt;br /&gt;
&lt;br /&gt;
== CampSynt==&lt;br /&gt;
&lt;br /&gt;
'''CampSynt''' is a tool to create a not so skeletal campaign as you can view in the help:&lt;br /&gt;
&lt;br /&gt;
        camp-synt -c -n -s [-s] -h [-h] -u [-u] -f -w&lt;br /&gt;
&lt;br /&gt;
        Warning: put underscores instead of spaces or include in double quotes (eg: a_string or &amp;quot;a string&amp;quot;)&lt;br /&gt;
        Warning: you can use long or short notations for options:&lt;br /&gt;
        -c A_str  is the same of -c &amp;quot;A str&amp;quot; and of --campaign=A_str and --campaign=&amp;quot;A str&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        OPTIONS:&lt;br /&gt;
        -c Name_with_underscores or  &amp;quot;Name in quotes&amp;quot;. This option is mandatory.&lt;br /&gt;
        -n Number of scenarios if not provided scenario's names via -s option&lt;br /&gt;
        -s First_scenario [-s Second_scenario -s Third_scenario -s End]&lt;br /&gt;
           one or more scenario names provided in sequential order&lt;br /&gt;
        -h Hero_Name [-h Best_Friend -h My_Dog.Wolf]&lt;br /&gt;
           one or more hero names to create and use in the story.&lt;br /&gt;
           If the name contains a '.' (dot sign) everything following it is considerd as the type of that unit.&lt;br /&gt;
        -u new_Unit [-u Another_one -u Last]&lt;br /&gt;
           one or more new unit types to be included in the private units folder.&lt;br /&gt;
           If the name contains two dot signs it will be splitted this way: new_unit_name, race, copied_from&lt;br /&gt;
           like in: Farm_rebel.humans.Peasant&lt;br /&gt;
           This need -w option properly set.&lt;br /&gt;
        -f Force the rewrite of an existing file.&lt;br /&gt;
        -w Wesnoth path (in double quotes if containing spaces) to access original units.&lt;br /&gt;
           If this option is set and the path match 1.6 then the directory 'campaigns' is used instead of 'add-ons'.&lt;br /&gt;
&lt;br /&gt;
        EXAMPLES:&lt;br /&gt;
        -c Camp_Name  -n  3&lt;br /&gt;
        -c Camp_Name  -n  3 -f&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two -h Hero_Name -u New_unit&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero_Name -h His_Friend -u New_unit -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero -h Friend.New_Bowman -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero.New_Bowman -u New_Bowman.humans.Peasant&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
campsynth is a perl script (with core modules usage only, suitable for most Linux systems and packed as exe for the enjoy of some other OS users). It was written based on 1.8.5 version of the game but can be also used with 1.6.x versions and was successfully tested with 1.9.5 (12 apr 2011). campsynth is located at the forum http://forum.wesnoth.org/viewtopic.php?f=8&amp;amp;t=29010&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Map Tracker ==&lt;br /&gt;
A standalone free and open source GUI tool that is available from here: https://github.com/babaissarkar/WesnothMapTracker&lt;br /&gt;
&lt;br /&gt;
It allows you to open an image file (say the Wesnoth Map) and place markers upon it, and the corresponding macro code is generated like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
  {NEW_JOURNEY 455 300}&lt;br /&gt;
  {NEW_REST 500 300}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it cannot generate a full map.cfg yet, just the part mentioned. For detailed instructions please visit the link above.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tools]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Authoring_tools&amp;diff=74716</id>
		<title>Authoring tools</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Authoring_tools&amp;diff=74716"/>
		<updated>2026-01-09T01:46:22Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Wesnoth Map Tracker */  use syntaxhighlight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page collects information about tools in the Wesnoth source tree that are intended to help you write campaign WML. &lt;br /&gt;
&lt;br /&gt;
== tmx_trackplacer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} '''tmx_trackplacer''' is a tool for editing journey tracks - the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
You'll need Tiled, a GPLv2 map editor:&lt;br /&gt;
* Debian / Ubuntu: install the &amp;quot;tiled&amp;quot; package&lt;br /&gt;
* other platforms: https://www.mapeditor.org/&lt;br /&gt;
* these instructions were written with version 1.2.4&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&lt;br /&gt;
Assume the campaign that we want to make a map for is Story of Wose, which is set on the Green Isle. Start by putting a copy of the map in the campaign:&lt;br /&gt;
&lt;br /&gt;
    mkdir Story_of_Wose/images/maps&lt;br /&gt;
    cp WESNOTH_DIR/data/campaigns/The_Rise_Of_Wesnoth/images/maps/green_isle.png Story_of_Wose/images/maps/&lt;br /&gt;
&lt;br /&gt;
Create a template .tmx file with the tool:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer Story_of_Wose/images/maps/green_isle.png -o temp.tmx&lt;br /&gt;
&lt;br /&gt;
=== In Tiled ===&lt;br /&gt;
&lt;br /&gt;
Start Tiled with the temp.tmx file. Expect to see the Green Isle map. On the right hand side of the screen there should be two windows:&lt;br /&gt;
* in the top, tabs ''Minimap'', ''Objects'' and ''Layers''. The Layers tab will have only ''background''.&lt;br /&gt;
* in the bottom, tabs ''Terrains'' and ''Tilesets''. The Tilesets tab should have ''wesnoth journey icons'' with the red dot, battle and rest markers.&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930950-ac876c80-f035-11e9-9599-d5dc4301acf2.png&lt;br /&gt;
&lt;br /&gt;
In Layers, create a ''New Layer'' of type ''Object Layer''. A typical name for this layer is '''JOURNEY'''. Ensure that this layer is selected.&lt;br /&gt;
From the menu bar at the top, select ''Insert Tile''.&lt;br /&gt;
From the Tilesets tab, choose dots, battles or rests, and click on the map to add them. The first two items placed will define the start of the journey; every item placed after the first two will be inserted in to the sequence based on whether it appears to be at the end or in the middle.&lt;br /&gt;
&lt;br /&gt;
For Story of Wose, the journey doubles back on itself. For this we'll split the journey in to two parts - rename '''JOURNEY''' to '''JOURNEY_PART1''', and add a new layer '''JOURNEY_PART2'''. You can use the opacity control at the top of the layers window to see what's on each layer.&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART1''' starts with a battle, and ends with a battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930947-abeed600-f035-11e9-89e8-efde15f2a48d.png&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART2''' starts with dots, has a battle and then ends with another battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930949-abeed600-f035-11e9-86a0-18c90c151c76.png&lt;br /&gt;
&lt;br /&gt;
Save the .tmx file.&lt;br /&gt;
&lt;br /&gt;
=== Creating the .cfg ===&lt;br /&gt;
&lt;br /&gt;
Convert the .tmx file to a .cfg file:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer temp.tmx -o Story_of_Wose/utils/bigmap.cfg&lt;br /&gt;
&lt;br /&gt;
Expect to see:&lt;br /&gt;
&lt;br /&gt;
    Read data: &amp;lt;Journey based on map file 'Story_of_Wose/images/maps/green_isle.png', with tracks {JOURNEY_PART1,JOURNEY_PART2}&amp;gt;&lt;br /&gt;
    Exporting as cfg&lt;br /&gt;
&lt;br /&gt;
At the moment, tmx_trackplacer doesn't have a way to preview the animations, other than loading the .cfg with Wesnoth itself. For testing, let's put all of the journey in at the start of the first scenario, Story_of_Wose/scenarios/1_The_Oldwood.cfg&lt;br /&gt;
&lt;br /&gt;
    #define STORY_BACKGROUND&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/background.jpg&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/green_isle.png&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
            base_layer=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
    #enddef&lt;br /&gt;
&lt;br /&gt;
    [story]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            story= _ &amp;quot;Today I want to tell you another story, a mere footnote in the history books if it is even remembered at all.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This should now show at the start of the campaign. Remember to refresh Wesnoth's cache if it doesn't appear.&lt;br /&gt;
&lt;br /&gt;
=== Could this be integrated as a Tiled plugin? ===&lt;br /&gt;
&lt;br /&gt;
Yes it could. Implementing it as a file converter was the easier option for development, and the code is (hopefully) modular enough for reuse.&lt;br /&gt;
&lt;br /&gt;
== trackviewer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} Map journey track animation preview tool, shows the journey without needing to start Wesnoth and refresh the cache. It’s a support program which assumes you’re either editing the .cfg file with a text editor or using Tiled with [[Authoring_tools#tmx_trackplacer|tmx_trackplacer]]; in other words, it's the part of the [[Authoring_tools#trackplacer|old trackplacer]] that wasn't covered by tmx_trackplacer.&lt;br /&gt;
&lt;br /&gt;
At least on Linux you can have both Tiled and this open on the same file. Save the file in Tiled, alt+tab to this, and press enter to reload the file.&lt;br /&gt;
&lt;br /&gt;
Keys:&lt;br /&gt;
* Escape quits&lt;br /&gt;
* Return or Enter reloads the .cfg or .tmx file, and restarts the animation&lt;br /&gt;
* Space pauses/unpauses&lt;br /&gt;
&lt;br /&gt;
== trackplacer ==&lt;br /&gt;
&lt;br /&gt;
'''UPDATE: per Elvish_Hunter in [https://forums.wesnoth.org/viewtopic.php?f=21&amp;amp;t=48478&amp;amp;p=631121#p631121 this thread]: &lt;br /&gt;
'''&amp;lt;nowiki&amp;gt;&amp;quot;trackplacer is outdated (it requires the obsolete PyGTK toolkit, which doesn't run on Python 3) and terribly bugged (it doesn't run at all on Windows, for example).&amp;quot;&amp;lt;/nowiki&amp;gt; You should either use [[Authoring tools#tmx_trackplacer|tmx_trackplacer]], or use image editing software to find the X and Y coordinates to create each dot or cross manually.&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' is a tool for visually editing journey tracks.  Journey tracks are the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
A 'journey' is an object containing a map file name and a (possibly empty) list of tracks, each with a name and each consisting of a sequence of track markers. This program exists to visually edit journeys represented as specially delimited sections in in .cfg files.&lt;br /&gt;
&lt;br /&gt;
When you run '''trackplacer''', it will pop up a file selection dialog asking you to select either a map image or a .cfg file.  When you select a map image, you will be starting a new set of journey tracks on that map.  If you select a .cfg, the .cfg will be scanned for macros describing journey tracks.  All other content in the .cfg, except for some magic special comments interpreted by '''trackplacer''' (which will be described later on) is ignored.&lt;br /&gt;
&lt;br /&gt;
Once you have a map (and possibly also a set of track for it), there is always a currently selected track (shown in red) and possibly one or more unselected tracks (shown in white).  You can add journey markers to the select track by clicking the left mouse button; they will appear on the screen.  The rule for adding markers to the track is as follows: if the two markers closest to the mouse pointer are adjacent on the track, insert the new marker between them in the track order. Otherwise, append it to the end of the track.&lt;br /&gt;
&lt;br /&gt;
You can click on and drag a marker with the middle mouse button to move it. Moving a marker preserves its place in the track order.  The right mouse button pops up an information window describing all features overlapping the pointer; it will disappear when you release.&lt;br /&gt;
&lt;br /&gt;
Radiobuttons in the upper-left-hand corner of the '''trackplacer''' window let you select placing battle markers (crossed swords) and rest markers (a flag).  If you click the trashcan icon, clicking on track markers will remove them.  If you click the copy/convert button, clicking on unselected track markers will copy them. &lt;br /&gt;
&lt;br /&gt;
When copying, '''trackplacer''' looks under the mouse pointer for a marker from an unselected track.  If it finds one, it creates a matching new icon on the selected track, preserving its pixel coordinates exactly.  This can be useful when you want two named tracks to end at exactly the same spot.&lt;br /&gt;
&lt;br /&gt;
The '''Animate''' button erases all icons, then redisplays them in order with a delay between each redraw, so you can see the track order.&lt;br /&gt;
&lt;br /&gt;
The '''Save''' button saves your work.  Your track will be saved on .cfg format as a sequence of macro definitions that you can insert in the story parts of your campaign.  Conventionally, the place to put this .cfg is in a file named 'journey.cfg' in the 'utils/' directory of your campaign, near your private macro files (if you have any).  Then the definitions will automatically be available in your scenario files.&lt;br /&gt;
&lt;br /&gt;
The '''Properties''' button brings up a dialog that allows you to edit key/value pairs associated with the track that may affect the behavior of '''trackplacer'''. Currently only two such properties are defined: &amp;quot;map&amp;quot; has the name of the track's base file as its value, and &amp;quot;prefix&amp;quot; sets the prefix to be used when generating macro names (defaulting to '''JOURNEY''').&lt;br /&gt;
&lt;br /&gt;
The '''Tracks''' button pops up a list of controls, one for each track.  You can change the state of the checkboxes to control which tracks are visible. The radiobuttons can be used to select a track for editing.  You can also add and rename tracks here.  Hover over the controls for tooltips.&lt;br /&gt;
&lt;br /&gt;
The Help button displays documentation.&lt;br /&gt;
&lt;br /&gt;
The Quit button ends your session, asking for confirmation if you have unsaved changes.&lt;br /&gt;
&lt;br /&gt;
To understand what your 'journey.cfg' does, you need to know that journey-track markers can be put on your story screens by two different sets of macros.  One, used for 'new' marks, is displayed in color with quarter-second delays; the other, 'old' set displays marks in white with no delay.  Your journey track is divided into stages by battle and rest markers; conventionally, you want to display the latest (most recent) stage with the new macros and all previous stages with the old ones.  &lt;br /&gt;
&lt;br /&gt;
Your track will be saved in .cfg format as a sequence of macro definitions with names like '''JOURNEY_STAGE_1''', '''JOURNEY_STAGE_2''' and so on.  '''JOURNEY_STAGE_1''' will draw the first stage in the 'new' color parts.  '''JOURNEY_STAGE_2''' will draw the first stage in the 'old' color and the second stage in the 'new' one; '''JOURNEY_STAGE_3''' will draw the first and second stages in the 'old' color parts and the third stage in the 'new' one; and so on.&lt;br /&gt;
&lt;br /&gt;
There will be a final macro '''JOURNEY_COMPLETE''' that displays the entire track in the 'old' color. This will be useful when you are piecing together multiple tracks, say for a campaign with branches.&lt;br /&gt;
&lt;br /&gt;
The track information in your journey.cfg will be enclosed in special comments&lt;br /&gt;
that look like this:&lt;br /&gt;
&lt;br /&gt;
    # trackplacer: tracks begin&lt;br /&gt;
    # trackplacer: tracks end&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' will not alter anything it finds outside these comments, and will always enclose everything it writes in them.&lt;br /&gt;
&lt;br /&gt;
Special comments may appear in your ''journey.cfg'', looking like this:&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;tt&amp;gt;# trackplacer: &amp;amp;lt;property&amp;amp;gt;=&amp;amp;lt;value&amp;amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These set properties that '''trackplacer''' may use.  At present there is only one such property: &amp;lt;tt&amp;gt;map&amp;lt;/tt&amp;gt;, which records the name of the mapfile on which your track is laid.  Don't remove this comment, '''trackplacer''' needs it.&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' has one known bug: you can confuse it (or possibly the underlying toolkit, or X) by dragging markers rapidly across other markers. If this happens to you, click '''Animate''' to refresh and slow down.&lt;br /&gt;
&lt;br /&gt;
== CampSynt==&lt;br /&gt;
&lt;br /&gt;
'''CampSynt''' is a tool to create a not so skeletal campaign as you can view in the help:&lt;br /&gt;
&lt;br /&gt;
        camp-synt -c -n -s [-s] -h [-h] -u [-u] -f -w&lt;br /&gt;
&lt;br /&gt;
        Warning: put underscores instead of spaces or include in double quotes (eg: a_string or &amp;quot;a string&amp;quot;)&lt;br /&gt;
        Warning: you can use long or short notations for options:&lt;br /&gt;
        -c A_str  is the same of -c &amp;quot;A str&amp;quot; and of --campaign=A_str and --campaign=&amp;quot;A str&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        OPTIONS:&lt;br /&gt;
        -c Name_with_underscores or  &amp;quot;Name in quotes&amp;quot;. This option is mandatory.&lt;br /&gt;
        -n Number of scenarios if not provided scenario's names via -s option&lt;br /&gt;
        -s First_scenario [-s Second_scenario -s Third_scenario -s End]&lt;br /&gt;
           one or more scenario names provided in sequential order&lt;br /&gt;
        -h Hero_Name [-h Best_Friend -h My_Dog.Wolf]&lt;br /&gt;
           one or more hero names to create and use in the story.&lt;br /&gt;
           If the name contains a '.' (dot sign) everything following it is considerd as the type of that unit.&lt;br /&gt;
        -u new_Unit [-u Another_one -u Last]&lt;br /&gt;
           one or more new unit types to be included in the private units folder.&lt;br /&gt;
           If the name contains two dot signs it will be splitted this way: new_unit_name, race, copied_from&lt;br /&gt;
           like in: Farm_rebel.humans.Peasant&lt;br /&gt;
           This need -w option properly set.&lt;br /&gt;
        -f Force the rewrite of an existing file.&lt;br /&gt;
        -w Wesnoth path (in double quotes if containing spaces) to access original units.&lt;br /&gt;
           If this option is set and the path match 1.6 then the directory 'campaigns' is used instead of 'add-ons'.&lt;br /&gt;
&lt;br /&gt;
        EXAMPLES:&lt;br /&gt;
        -c Camp_Name  -n  3&lt;br /&gt;
        -c Camp_Name  -n  3 -f&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two -h Hero_Name -u New_unit&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero_Name -h His_Friend -u New_unit -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero -h Friend.New_Bowman -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero.New_Bowman -u New_Bowman.humans.Peasant&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
campsynth is a perl script (with core modules usage only, suitable for most Linux systems and packed as exe for the enjoy of some other OS users). It was written based on 1.8.5 version of the game but can be also used with 1.6.x versions and was successfully tested with 1.9.5 (12 apr 2011). campsynth is located at the forum http://forum.wesnoth.org/viewtopic.php?f=8&amp;amp;t=29010&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Map Tracker ==&lt;br /&gt;
A standalone free and open source GUI tool that is available from here: https://github.com/babaissarkar/WesnothMapTracker&lt;br /&gt;
&lt;br /&gt;
It allows you to open an image file (say the Wesnoth Map) and place markers upon it, and the corresponding macro code is generated like this:&lt;br /&gt;
of a user interface would be :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=wml&amp;gt;&lt;br /&gt;
  {NEW_JOURNEY 455 300}&lt;br /&gt;
  {NEW_REST 500 300}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it cannot generate a full map.cfg yet, just the part mentioned. For detailed instructions please visit the link above.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tools]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Authoring_tools&amp;diff=74715</id>
		<title>Authoring tools</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Authoring_tools&amp;diff=74715"/>
		<updated>2026-01-09T01:41:40Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: Add WesnothMapTracker tool&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page collects information about tools in the Wesnoth source tree that are intended to help you write campaign WML. &lt;br /&gt;
&lt;br /&gt;
== tmx_trackplacer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} '''tmx_trackplacer''' is a tool for editing journey tracks - the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
You'll need Tiled, a GPLv2 map editor:&lt;br /&gt;
* Debian / Ubuntu: install the &amp;quot;tiled&amp;quot; package&lt;br /&gt;
* other platforms: https://www.mapeditor.org/&lt;br /&gt;
* these instructions were written with version 1.2.4&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&lt;br /&gt;
Assume the campaign that we want to make a map for is Story of Wose, which is set on the Green Isle. Start by putting a copy of the map in the campaign:&lt;br /&gt;
&lt;br /&gt;
    mkdir Story_of_Wose/images/maps&lt;br /&gt;
    cp WESNOTH_DIR/data/campaigns/The_Rise_Of_Wesnoth/images/maps/green_isle.png Story_of_Wose/images/maps/&lt;br /&gt;
&lt;br /&gt;
Create a template .tmx file with the tool:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer Story_of_Wose/images/maps/green_isle.png -o temp.tmx&lt;br /&gt;
&lt;br /&gt;
=== In Tiled ===&lt;br /&gt;
&lt;br /&gt;
Start Tiled with the temp.tmx file. Expect to see the Green Isle map. On the right hand side of the screen there should be two windows:&lt;br /&gt;
* in the top, tabs ''Minimap'', ''Objects'' and ''Layers''. The Layers tab will have only ''background''.&lt;br /&gt;
* in the bottom, tabs ''Terrains'' and ''Tilesets''. The Tilesets tab should have ''wesnoth journey icons'' with the red dot, battle and rest markers.&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930950-ac876c80-f035-11e9-9599-d5dc4301acf2.png&lt;br /&gt;
&lt;br /&gt;
In Layers, create a ''New Layer'' of type ''Object Layer''. A typical name for this layer is '''JOURNEY'''. Ensure that this layer is selected.&lt;br /&gt;
From the menu bar at the top, select ''Insert Tile''.&lt;br /&gt;
From the Tilesets tab, choose dots, battles or rests, and click on the map to add them. The first two items placed will define the start of the journey; every item placed after the first two will be inserted in to the sequence based on whether it appears to be at the end or in the middle.&lt;br /&gt;
&lt;br /&gt;
For Story of Wose, the journey doubles back on itself. For this we'll split the journey in to two parts - rename '''JOURNEY''' to '''JOURNEY_PART1''', and add a new layer '''JOURNEY_PART2'''. You can use the opacity control at the top of the layers window to see what's on each layer.&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART1''' starts with a battle, and ends with a battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930947-abeed600-f035-11e9-89e8-efde15f2a48d.png&lt;br /&gt;
&lt;br /&gt;
'''JOURNEY_PART2''' starts with dots, has a battle and then ends with another battle:&lt;br /&gt;
https://user-images.githubusercontent.com/101462/66930949-abeed600-f035-11e9-86a0-18c90c151c76.png&lt;br /&gt;
&lt;br /&gt;
Save the .tmx file.&lt;br /&gt;
&lt;br /&gt;
=== Creating the .cfg ===&lt;br /&gt;
&lt;br /&gt;
Convert the .tmx file to a .cfg file:&lt;br /&gt;
&lt;br /&gt;
    WESNOTH_DIR/data/tools/tmx_trackplacer temp.tmx -o Story_of_Wose/utils/bigmap.cfg&lt;br /&gt;
&lt;br /&gt;
Expect to see:&lt;br /&gt;
&lt;br /&gt;
    Read data: &amp;lt;Journey based on map file 'Story_of_Wose/images/maps/green_isle.png', with tracks {JOURNEY_PART1,JOURNEY_PART2}&amp;gt;&lt;br /&gt;
    Exporting as cfg&lt;br /&gt;
&lt;br /&gt;
At the moment, tmx_trackplacer doesn't have a way to preview the animations, other than loading the .cfg with Wesnoth itself. For testing, let's put all of the journey in at the start of the first scenario, Story_of_Wose/scenarios/1_The_Oldwood.cfg&lt;br /&gt;
&lt;br /&gt;
    #define STORY_BACKGROUND&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/background.jpg&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
        [background_layer]&lt;br /&gt;
            image=maps/green_isle.png&lt;br /&gt;
            scale_vertically=yes&lt;br /&gt;
            scale_horizontally=no&lt;br /&gt;
            keep_aspect_ratio=yes&lt;br /&gt;
            base_layer=yes&lt;br /&gt;
        [/background_layer]&lt;br /&gt;
    #enddef&lt;br /&gt;
&lt;br /&gt;
    [story]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE1}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            {STORY_BACKGROUND}&lt;br /&gt;
            {JOURNEY_PART1_COMPLETE}&lt;br /&gt;
            {JOURNEY_PART2_STAGE2}&lt;br /&gt;
        [/part]&lt;br /&gt;
        [part]&lt;br /&gt;
            story= _ &amp;quot;Today I want to tell you another story, a mere footnote in the history books if it is even remembered at all.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This should now show at the start of the campaign. Remember to refresh Wesnoth's cache if it doesn't appear.&lt;br /&gt;
&lt;br /&gt;
=== Could this be integrated as a Tiled plugin? ===&lt;br /&gt;
&lt;br /&gt;
Yes it could. Implementing it as a file converter was the easier option for development, and the code is (hopefully) modular enough for reuse.&lt;br /&gt;
&lt;br /&gt;
== trackviewer ==&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.15|3}} Map journey track animation preview tool, shows the journey without needing to start Wesnoth and refresh the cache. It’s a support program which assumes you’re either editing the .cfg file with a text editor or using Tiled with [[Authoring_tools#tmx_trackplacer|tmx_trackplacer]]; in other words, it's the part of the [[Authoring_tools#trackplacer|old trackplacer]] that wasn't covered by tmx_trackplacer.&lt;br /&gt;
&lt;br /&gt;
At least on Linux you can have both Tiled and this open on the same file. Save the file in Tiled, alt+tab to this, and press enter to reload the file.&lt;br /&gt;
&lt;br /&gt;
Keys:&lt;br /&gt;
* Escape quits&lt;br /&gt;
* Return or Enter reloads the .cfg or .tmx file, and restarts the animation&lt;br /&gt;
* Space pauses/unpauses&lt;br /&gt;
&lt;br /&gt;
== trackplacer ==&lt;br /&gt;
&lt;br /&gt;
'''UPDATE: per Elvish_Hunter in [https://forums.wesnoth.org/viewtopic.php?f=21&amp;amp;t=48478&amp;amp;p=631121#p631121 this thread]: &lt;br /&gt;
'''&amp;lt;nowiki&amp;gt;&amp;quot;trackplacer is outdated (it requires the obsolete PyGTK toolkit, which doesn't run on Python 3) and terribly bugged (it doesn't run at all on Windows, for example).&amp;quot;&amp;lt;/nowiki&amp;gt; You should either use [[Authoring tools#tmx_trackplacer|tmx_trackplacer]], or use image editing software to find the X and Y coordinates to create each dot or cross manually.&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' is a tool for visually editing journey tracks.  Journey tracks are the sequences of dots, crossed-sword, and flag symbols (track markers) that march across the story screens at the beginning of many Wesnoth scenarios.&lt;br /&gt;
&lt;br /&gt;
A 'journey' is an object containing a map file name and a (possibly empty) list of tracks, each with a name and each consisting of a sequence of track markers. This program exists to visually edit journeys represented as specially delimited sections in in .cfg files.&lt;br /&gt;
&lt;br /&gt;
When you run '''trackplacer''', it will pop up a file selection dialog asking you to select either a map image or a .cfg file.  When you select a map image, you will be starting a new set of journey tracks on that map.  If you select a .cfg, the .cfg will be scanned for macros describing journey tracks.  All other content in the .cfg, except for some magic special comments interpreted by '''trackplacer''' (which will be described later on) is ignored.&lt;br /&gt;
&lt;br /&gt;
Once you have a map (and possibly also a set of track for it), there is always a currently selected track (shown in red) and possibly one or more unselected tracks (shown in white).  You can add journey markers to the select track by clicking the left mouse button; they will appear on the screen.  The rule for adding markers to the track is as follows: if the two markers closest to the mouse pointer are adjacent on the track, insert the new marker between them in the track order. Otherwise, append it to the end of the track.&lt;br /&gt;
&lt;br /&gt;
You can click on and drag a marker with the middle mouse button to move it. Moving a marker preserves its place in the track order.  The right mouse button pops up an information window describing all features overlapping the pointer; it will disappear when you release.&lt;br /&gt;
&lt;br /&gt;
Radiobuttons in the upper-left-hand corner of the '''trackplacer''' window let you select placing battle markers (crossed swords) and rest markers (a flag).  If you click the trashcan icon, clicking on track markers will remove them.  If you click the copy/convert button, clicking on unselected track markers will copy them. &lt;br /&gt;
&lt;br /&gt;
When copying, '''trackplacer''' looks under the mouse pointer for a marker from an unselected track.  If it finds one, it creates a matching new icon on the selected track, preserving its pixel coordinates exactly.  This can be useful when you want two named tracks to end at exactly the same spot.&lt;br /&gt;
&lt;br /&gt;
The '''Animate''' button erases all icons, then redisplays them in order with a delay between each redraw, so you can see the track order.&lt;br /&gt;
&lt;br /&gt;
The '''Save''' button saves your work.  Your track will be saved on .cfg format as a sequence of macro definitions that you can insert in the story parts of your campaign.  Conventionally, the place to put this .cfg is in a file named 'journey.cfg' in the 'utils/' directory of your campaign, near your private macro files (if you have any).  Then the definitions will automatically be available in your scenario files.&lt;br /&gt;
&lt;br /&gt;
The '''Properties''' button brings up a dialog that allows you to edit key/value pairs associated with the track that may affect the behavior of '''trackplacer'''. Currently only two such properties are defined: &amp;quot;map&amp;quot; has the name of the track's base file as its value, and &amp;quot;prefix&amp;quot; sets the prefix to be used when generating macro names (defaulting to '''JOURNEY''').&lt;br /&gt;
&lt;br /&gt;
The '''Tracks''' button pops up a list of controls, one for each track.  You can change the state of the checkboxes to control which tracks are visible. The radiobuttons can be used to select a track for editing.  You can also add and rename tracks here.  Hover over the controls for tooltips.&lt;br /&gt;
&lt;br /&gt;
The Help button displays documentation.&lt;br /&gt;
&lt;br /&gt;
The Quit button ends your session, asking for confirmation if you have unsaved changes.&lt;br /&gt;
&lt;br /&gt;
To understand what your 'journey.cfg' does, you need to know that journey-track markers can be put on your story screens by two different sets of macros.  One, used for 'new' marks, is displayed in color with quarter-second delays; the other, 'old' set displays marks in white with no delay.  Your journey track is divided into stages by battle and rest markers; conventionally, you want to display the latest (most recent) stage with the new macros and all previous stages with the old ones.  &lt;br /&gt;
&lt;br /&gt;
Your track will be saved in .cfg format as a sequence of macro definitions with names like '''JOURNEY_STAGE_1''', '''JOURNEY_STAGE_2''' and so on.  '''JOURNEY_STAGE_1''' will draw the first stage in the 'new' color parts.  '''JOURNEY_STAGE_2''' will draw the first stage in the 'old' color and the second stage in the 'new' one; '''JOURNEY_STAGE_3''' will draw the first and second stages in the 'old' color parts and the third stage in the 'new' one; and so on.&lt;br /&gt;
&lt;br /&gt;
There will be a final macro '''JOURNEY_COMPLETE''' that displays the entire track in the 'old' color. This will be useful when you are piecing together multiple tracks, say for a campaign with branches.&lt;br /&gt;
&lt;br /&gt;
The track information in your journey.cfg will be enclosed in special comments&lt;br /&gt;
that look like this:&lt;br /&gt;
&lt;br /&gt;
    # trackplacer: tracks begin&lt;br /&gt;
    # trackplacer: tracks end&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' will not alter anything it finds outside these comments, and will always enclose everything it writes in them.&lt;br /&gt;
&lt;br /&gt;
Special comments may appear in your ''journey.cfg'', looking like this:&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;tt&amp;gt;# trackplacer: &amp;amp;lt;property&amp;amp;gt;=&amp;amp;lt;value&amp;amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These set properties that '''trackplacer''' may use.  At present there is only one such property: &amp;lt;tt&amp;gt;map&amp;lt;/tt&amp;gt;, which records the name of the mapfile on which your track is laid.  Don't remove this comment, '''trackplacer''' needs it.&lt;br /&gt;
&lt;br /&gt;
'''trackplacer''' has one known bug: you can confuse it (or possibly the underlying toolkit, or X) by dragging markers rapidly across other markers. If this happens to you, click '''Animate''' to refresh and slow down.&lt;br /&gt;
&lt;br /&gt;
== CampSynt==&lt;br /&gt;
&lt;br /&gt;
'''CampSynt''' is a tool to create a not so skeletal campaign as you can view in the help:&lt;br /&gt;
&lt;br /&gt;
        camp-synt -c -n -s [-s] -h [-h] -u [-u] -f -w&lt;br /&gt;
&lt;br /&gt;
        Warning: put underscores instead of spaces or include in double quotes (eg: a_string or &amp;quot;a string&amp;quot;)&lt;br /&gt;
        Warning: you can use long or short notations for options:&lt;br /&gt;
        -c A_str  is the same of -c &amp;quot;A str&amp;quot; and of --campaign=A_str and --campaign=&amp;quot;A str&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        OPTIONS:&lt;br /&gt;
        -c Name_with_underscores or  &amp;quot;Name in quotes&amp;quot;. This option is mandatory.&lt;br /&gt;
        -n Number of scenarios if not provided scenario's names via -s option&lt;br /&gt;
        -s First_scenario [-s Second_scenario -s Third_scenario -s End]&lt;br /&gt;
           one or more scenario names provided in sequential order&lt;br /&gt;
        -h Hero_Name [-h Best_Friend -h My_Dog.Wolf]&lt;br /&gt;
           one or more hero names to create and use in the story.&lt;br /&gt;
           If the name contains a '.' (dot sign) everything following it is considerd as the type of that unit.&lt;br /&gt;
        -u new_Unit [-u Another_one -u Last]&lt;br /&gt;
           one or more new unit types to be included in the private units folder.&lt;br /&gt;
           If the name contains two dot signs it will be splitted this way: new_unit_name, race, copied_from&lt;br /&gt;
           like in: Farm_rebel.humans.Peasant&lt;br /&gt;
           This need -w option properly set.&lt;br /&gt;
        -f Force the rewrite of an existing file.&lt;br /&gt;
        -w Wesnoth path (in double quotes if containing spaces) to access original units.&lt;br /&gt;
           If this option is set and the path match 1.6 then the directory 'campaigns' is used instead of 'add-ons'.&lt;br /&gt;
&lt;br /&gt;
        EXAMPLES:&lt;br /&gt;
        -c Camp_Name  -n  3&lt;br /&gt;
        -c Camp_Name  -n  3 -f&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two&lt;br /&gt;
        -c Camp_Name  -s Scenario_One  -s Scenario_Two -h Hero_Name -u New_unit&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero_Name -h His_Friend -u New_unit -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero -h Friend.New_Bowman -u New_Bowman&lt;br /&gt;
        -c Camp_Name  -s One -s Two -h Hero.New_Bowman -u New_Bowman.humans.Peasant&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
campsynth is a perl script (with core modules usage only, suitable for most Linux systems and packed as exe for the enjoy of some other OS users). It was written based on 1.8.5 version of the game but can be also used with 1.6.x versions and was successfully tested with 1.9.5 (12 apr 2011). campsynth is located at the forum http://forum.wesnoth.org/viewtopic.php?f=8&amp;amp;t=29010&lt;br /&gt;
&lt;br /&gt;
== Wesnoth Map Tracker ==&lt;br /&gt;
A standalone free and open source GUI tool that is available from here: https://github.com/babaissarkar/WesnothMapTracker&lt;br /&gt;
&lt;br /&gt;
It allows you to open an image file (say the Wesnoth Map) and place markers upon it, and the corresponding macro code is generated like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  {NEW_JOURNEY 455 300}&lt;br /&gt;
  {NEW_REST 500 300}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For detailed instructions please visit the link above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tools]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74658</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74658"/>
		<updated>2025-12-03T03:58:08Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for specials with a value */ Add PO variables&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|17}} 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. 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 choosen.&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;
* 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|17}} 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 '''$value'''.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74657</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74657"/>
		<updated>2025-12-03T03:56:53Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for abilities with a value */  Show PO variables&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|17}} 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. 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 choosen.&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;
* 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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74653</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74653"/>
		<updated>2025-11-29T03:07:34Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Extra keys used by the [plague] special */ Mention $type variable&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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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. 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 choosen.&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;
* 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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74652</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74652"/>
		<updated>2025-11-29T03:05:00Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every weapon special */ Add unique_id details to weapon specials&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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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. 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 choosen.&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;
* 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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74651</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74651"/>
		<updated>2025-11-29T03:03:46Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ only keep ability specific registry info.&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|17}} 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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. 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 choosen.&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;
* 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;
* '''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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74650</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74650"/>
		<updated>2025-11-29T03:02:46Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ mention only ability registry&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|17}} 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'''. Similarly for weapon specials ('''[unit_type][attack]specials_list''', or via [[EffectWML]]).&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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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. 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 choosen.&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;
* 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;
* '''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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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.&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>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74631</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74631"/>
		<updated>2025-11-16T15:53:22Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ Update unique_id based on changed in PR 10691&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|17}} A unique identifier for this ability, used for the registry under [[UnitsWML#.5Babilities.5D|[units][abilities]]] or [[UnitsWML#.5Bweapon_specials.5D|[units][weapon_specials]]]. 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'''. Similarly for weapon specials ('''[unit_type][attack]specials_list''', or via [[EffectWML]]).&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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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 choosen.&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;
* 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;
* '''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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&lt;br /&gt;
* WEAPON_SPECIAL_BACKSTAB&lt;br /&gt;
* WEAPON_SPECIAL_BERSERK&lt;br /&gt;
* WEAPON_SPECIAL_CHARGE&lt;br /&gt;
* WEAPON_SPECIAL_DRAIN&lt;br /&gt;
* WEAPON_SPECIAL_FIRSTSTRIKE&lt;br /&gt;
* WEAPON_SPECIAL_MAGICAL&lt;br /&gt;
* WEAPON_SPECIAL_MARKSMAN&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE_TYPE TYPE&lt;br /&gt;
* WEAPON_SPECIAL_POISON&lt;br /&gt;
* WEAPON_SPECIAL_SLOW&lt;br /&gt;
* WEAPON_SPECIAL_STONE&lt;br /&gt;
* WEAPON_SPECIAL_SWARM&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[SingleUnitWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=74630</id>
		<title>UnitTypeWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=UnitTypeWML&amp;diff=74630"/>
		<updated>2025-11-16T15:49:20Z</updated>

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

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

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

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

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

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

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

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

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

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

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ mark supported version&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|17}} 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''' 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.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[filter_base_value]'''}}: filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', etc. If several keys are used all have to match.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this ability appears in. Note that such events get included when a unit with this ability first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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 choosen.&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;
* 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.&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].&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;
* '''active_on''': one of '''defense''' or '''offense'''; if left out, the special is active on both.&lt;br /&gt;
* '''apply_to''': one of '''self''','''opponent''','''attacker''','''defender''','''both''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability], {{DevFeature1.19|5}} [experimental_filter_specials] deprecated, use [filter_specials] instead.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this weapon special appears in. Note that such events get included when a unit with this weapon special first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&lt;br /&gt;
* WEAPON_SPECIAL_BACKSTAB&lt;br /&gt;
* WEAPON_SPECIAL_BERSERK&lt;br /&gt;
* WEAPON_SPECIAL_CHARGE&lt;br /&gt;
* WEAPON_SPECIAL_DRAIN&lt;br /&gt;
* WEAPON_SPECIAL_FIRSTSTRIKE&lt;br /&gt;
* WEAPON_SPECIAL_MAGICAL&lt;br /&gt;
* WEAPON_SPECIAL_MARKSMAN&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE_TYPE TYPE&lt;br /&gt;
* WEAPON_SPECIAL_POISON&lt;br /&gt;
* WEAPON_SPECIAL_SLOW&lt;br /&gt;
* WEAPON_SPECIAL_STONE&lt;br /&gt;
* WEAPON_SPECIAL_SWARM&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[SingleUnitWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74590</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74590"/>
		<updated>2025-11-03T03:38:34Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ Mention unique_id (PR #10644) fixup&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''': 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''' 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.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[filter_base_value]'''}}: filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', etc. If several keys are used all have to match.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this ability appears in. Note that such events get included when a unit with this ability first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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 choosen.&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;
* 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.&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].&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;
* '''active_on''': one of '''defense''' or '''offense'''; if left out, the special is active on both.&lt;br /&gt;
* '''apply_to''': one of '''self''','''opponent''','''attacker''','''defender''','''both''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability], {{DevFeature1.19|5}} [experimental_filter_specials] deprecated, use [filter_specials] instead.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this weapon special appears in. Note that such events get included when a unit with this weapon special first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&lt;br /&gt;
* WEAPON_SPECIAL_BACKSTAB&lt;br /&gt;
* WEAPON_SPECIAL_BERSERK&lt;br /&gt;
* WEAPON_SPECIAL_CHARGE&lt;br /&gt;
* WEAPON_SPECIAL_DRAIN&lt;br /&gt;
* WEAPON_SPECIAL_FIRSTSTRIKE&lt;br /&gt;
* WEAPON_SPECIAL_MAGICAL&lt;br /&gt;
* WEAPON_SPECIAL_MARKSMAN&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE_TYPE TYPE&lt;br /&gt;
* WEAPON_SPECIAL_POISON&lt;br /&gt;
* WEAPON_SPECIAL_SLOW&lt;br /&gt;
* WEAPON_SPECIAL_STONE&lt;br /&gt;
* WEAPON_SPECIAL_SWARM&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[SingleUnitWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74589</id>
		<title>AbilitiesWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AbilitiesWML&amp;diff=74589"/>
		<updated>2025-11-03T03:34:35Z</updated>

		<summary type="html">&lt;p&gt;Bssarkar: /* Common keys and tags for every ability */ Mention unique_id (PR #10644)&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''': A unique identifier for this ability. If not defined, falls back to '''id'''. Used to add this ability via '''abilities''' 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.&lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_base_value|'''[filter_base_value]'''}}: filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', etc. If several keys are used all have to match.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this ability appears in. Note that such events get included when a unit with this ability first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== 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. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&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 choosen.&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;
* 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.&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].&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;
* '''active_on''': one of '''defense''' or '''offense'''; if left out, the special is active on both.&lt;br /&gt;
* '''apply_to''': one of '''self''','''opponent''','''attacker''','''defender''','''both''' (default: ''self''). Determines who the effects of this special are applied to.&lt;br /&gt;
* '''[filter_adjacent]''': if an adjacent unit does not match this filter, the special will not be active and no-one will receive its effects. Takes extra keys ''adjacent'', ''count'', ''is_enemy'', just like in a [[StandardUnitFilter]]. In fact, it's really a shorthand for a [filter_adjacent] nested within [filter_self], with the one difference that, in the absence of a specified ''count'', all listed directions must match (so, with two directiones eg ''adjacent=n,s'', the default is ''count=2''). The variables $this_unit and {{DevFeature1.13|2}} $other_unit both work as you'd expect. Multiple [filter_adjacent] can be provided, all of which must pass for the ability to activate. &lt;br /&gt;
* '''[filter_adjacent_location]''': like [filter_adjacent], but filters on locations instead of units. This is a shorthand for [filter_self][filter_location][filter_adjacent_location].&lt;br /&gt;
* {{anchor|filter_self|'''[filter_self]'''}}: the special will only be active if the owner matches this [[StandardUnitFilter]] (SUF).&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the opponent.&lt;br /&gt;
* {{anchor|filter_opponent|'''[filter_opponent]'''}}: the special will only be active if the opponent matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the unit that owns the weapon.&lt;br /&gt;
* {{anchor|filter_attacker|'''[filter_attacker]'''}}: the special will only be active if the attacker matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the defender.&lt;br /&gt;
* {{anchor|filter_defender|'''[filter_defender]'''}} the special will only be active if the defender matches this SUF.&lt;br /&gt;
** '''[filter_weapon]''': a [[FilterWML#Filtering_Weapons|standard weapon filter]], including special=.&lt;br /&gt;
** '''$other_unit''': {{DevFeature1.13|2}} The special variable $other_unit refers to the attacker.&lt;br /&gt;
* '''overwrite_specials''': if equal to 'one_side', then only this unit's specials are evaluated. If equal to 'both_sides', then both this unit's specials and any of the opponent's weapon specials that affect this unit are evaluated. If a special with this attribute is active, it will take precedence over any other specials of the same type that do not have this attribute. Don't applied to boolean weapon special like [poison] ,[slow], [firststrike] or [petrifies].&lt;br /&gt;
* '''[overwrite]''': {{DevFeature1.17|22}} Allows more flexibility in determining which specials should take priority over other specials of the same type.&lt;br /&gt;
** '''priority''': A numeric value to use when determining which special should be used if multiple specials of the same type have the '''overwrite_specials''' attribute. Default is 0.&lt;br /&gt;
** '''[experimental_filter_specials]''': [[StandardAbilityFilter]] Further attributes to filter specials by to determine if it should take priority over other specials. Accepts the same attributes as [experimental_filter_ability], {{DevFeature1.19|5}} [experimental_filter_specials] deprecated, use [filter_specials] instead.&lt;br /&gt;
* '''[event]''': [[EventWML]]. {{DevFeature1.19|4}} An [event] to be included into any scenario where a unit with this weapon special appears in. Note that such events get included when a unit with this weapon special first appears in the scenario, not automatically when the scenario begins (meaning that ''name=prestart'' events, for example, would usually never trigger). See [[WML_Abilities|WML Abilities]]. Shortcut of [unit_type][event].&lt;br /&gt;
&lt;br /&gt;
=== Common keys and tags for specials with a value ===&lt;br /&gt;
&lt;br /&gt;
The '''[damage]''', '''[attacks]''', and '''[chance_to_hit]''' specials take values that specify how those specials modify their respective base values. The '''[drains]''' special takes a value specifying the percentage of damage drained (default 50) and '''[heal_on_hit]''' takes the amount to heal (default 0; negative values will harm the attacker, but not kill). &lt;br /&gt;
&lt;br /&gt;
* '''value''': the value to be used. &lt;br /&gt;
* '''add''': the number to add to the base value. Note the interaction with '''sub''' in [[#Common_calculations]].&lt;br /&gt;
* '''sub''': the number to subtract from the base value.&lt;br /&gt;
* '''multiply''': this multiplies the base value.&lt;br /&gt;
* '''divide''': this divides the base value.&lt;br /&gt;
* '''max_value''': {{DevFeature1.19|2}}  maximum special value. Default: no limit.&lt;br /&gt;
* '''min_value''': {{DevFeature1.19|2}}  minimum special value. Default: no limit.&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with the base value.&lt;br /&gt;
* '''backstab''': if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {{DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.&lt;br /&gt;
* '''[filter_base_value]''': filters on the value before any modifications; uses the keys '''equals''', '''not_equals''', '''less_than''', '''greater_than''', '''less_than_equal_to''', '''greater_than_equal_to'''.&lt;br /&gt;
&lt;br /&gt;
==== Common calculations ====&lt;br /&gt;
&lt;br /&gt;
Several abilities and weapon specials take the keys '''add''', '''sub''', '''multiply''' and '''divide'''.&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.19|4}} '''add''' and '''sub''' work independently.&lt;br /&gt;
&lt;br /&gt;
Prior to 1.19.4:&lt;br /&gt;
&lt;br /&gt;
* If '''add''' and '''sub''' are used in the same ability, the '''add''' is ignored&lt;br /&gt;
* If '''add''' and '''sub''' are used in separate abilities with the same id, or with the default id that's used when no id is specified, then the order in which the abilities are encountered controls the calculation, which may change depending on units' positions on the map.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[damage_type]'' special ===&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.17|23}}&lt;br /&gt;
&lt;br /&gt;
* '''replacement_type''': replaces the attack type with the specified type when [damage_type] is active.&lt;br /&gt;
* '''alternative_type''': add a second type of attack to the existing type, it is always the one of the two which will do the most damage to the opponent which will be used.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' In 1.18, alternative_type may be stronger than expected, as the damage calculations sometimes ignore [resistance] abilities. This is a known bug, which occurs deterministically and will be left unfixed in 1.18.x to prevent Out Of Sync errors.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If a [damage_type] special includes a [filter_weapon]type=, that filter is tested against the base type of the weapon, ignoring all [damage_type] specials.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[berserk]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''value''': the maximum number of combat rounds (default 1).&lt;br /&gt;
* '''cumulative''': if set to 'yes', this special will be cumulative with other active berserk specials (on the current combatant, not with an opponent's berserk).&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[plague]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''type''': the unit type to be spawned on kill. When not specified, the default is the unit type of the unit doing the plaguing.&lt;br /&gt;
&lt;br /&gt;
=== Extra keys used by the ''[swarm]'' special ===&lt;br /&gt;
&lt;br /&gt;
* '''swarm_attacks_max''': the maximum number of attacks for the swarm. Defaults to the base number of attacks modified by any applicable [attacks] specials. If this is specified, then the base number of attacks is ignored.&lt;br /&gt;
* '''swarm_attacks_min''': the minimum number of attacks for the swarm. Defaults to zero. This can be set higher than swarm_attacks_max to cause a unit to gain attacks as health decreases.&lt;br /&gt;
The ratio of the unit's current to maximum hit points will be used to scale the number of attacks between these two values.&lt;br /&gt;
&lt;br /&gt;
Prior to version 1.11, a [swarm] special will cause [attacks] specials to be ignored. In 1.11 and later, [attacks] specials are applied before [swarm].&lt;br /&gt;
&lt;br /&gt;
=== Macros for common weapon specials ===&lt;br /&gt;
&lt;br /&gt;
[https://www.wesnoth.org/macro-reference.html#file:weapon_specials.cfg macro reference]&lt;br /&gt;
* WEAPON_SPECIAL_BACKSTAB&lt;br /&gt;
* WEAPON_SPECIAL_BERSERK&lt;br /&gt;
* WEAPON_SPECIAL_CHARGE&lt;br /&gt;
* WEAPON_SPECIAL_DRAIN&lt;br /&gt;
* WEAPON_SPECIAL_FIRSTSTRIKE&lt;br /&gt;
* WEAPON_SPECIAL_MAGICAL&lt;br /&gt;
* WEAPON_SPECIAL_MARKSMAN&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE&lt;br /&gt;
* WEAPON_SPECIAL_PLAGUE_TYPE TYPE&lt;br /&gt;
* WEAPON_SPECIAL_POISON&lt;br /&gt;
* WEAPON_SPECIAL_SLOW&lt;br /&gt;
* WEAPON_SPECIAL_STONE&lt;br /&gt;
* WEAPON_SPECIAL_SWARM&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[SingleUnitWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML Reference]]&lt;/div&gt;</summary>
		<author><name>Bssarkar</name></author>
		
	</entry>
</feed>