<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=TestWML</id>
	<title>TestWML - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=TestWML"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=TestWML&amp;action=history"/>
	<updated>2026-05-18T14:04:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=TestWML&amp;diff=71489&amp;oldid=prev</id>
		<title>Octalot: Document [test_do_attack_by_id]</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=TestWML&amp;diff=71489&amp;oldid=prev"/>
		<updated>2023-07-02T17:35:10Z</updated>

		<summary type="html">&lt;p&gt;Document [test_do_attack_by_id]&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
The tags and macros on this page are for use in unit tests, they're defined in data/test and enabled when '''#ifdef TEST''' is true.&lt;br /&gt;
&lt;br /&gt;
The main '''[test]''' tag is documented on the [[ScenarioWML#The_.5Btest.5D_tag|ScenarioWML]] page.&lt;br /&gt;
&lt;br /&gt;
== The [test_do_attack_by_id] tag ==&lt;br /&gt;
&lt;br /&gt;
The '''[test_do_attack_by_id]''' tag is a wrapper for [[ReplayWML|[do_command][attack]]], taking unit ids instead of map coordinates. It has the following attributes:&lt;br /&gt;
&lt;br /&gt;
* '''attacker''' the unit that initiates the attack&lt;br /&gt;
* '''defender''' the unit being attacked&lt;br /&gt;
* '''weapon''' (unset by default) if set, is used as the value for [do_command][attack]weapon=&lt;br /&gt;
* '''defender_weapon''' (unset by default) if set, is used as the value for [do_command][attack]defender_weapon=&lt;br /&gt;
* '''resupply_attacks_left''' (unset by default) if set to an integer higher than attacker.attacks_left, then attacker.attacks_left will be set to this value before calling [do_command][attack]&lt;br /&gt;
&lt;br /&gt;
The reason for making this a test-only tag is that it can handle errors by failing the test, or by doing nothing and having the test fail later. Using unit IDs helps avoid hardcoding map coordinates in tests, and in tests the author is expected to know exactly which units should be involved. Even if this was a generic tag, it's likely that its only use outside tests would only be in events that already auto-store '''$unit''', and either auto-store '''$second_unit''' or already include a hardcoded '''x,y=''' filter.&lt;br /&gt;
&lt;br /&gt;
An alternative would be a generic tag taking SUFs for attacker and defender, but outside unit tests, there's a possibility of there being no unit matching the SUF, many units matching the SUF, or that the two units aren't adjacent to each other.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[LuaAPI/unit_test|LuaAPI for unit tests]]&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Octalot</name></author>
		
	</entry>
</feed>