TOTAL WAR WIKI

Total War: ATTILA KIT - Battle Definition XML

Battle Definition XML Documentation

08 April 2015

15:01

 

About Battle Definitions

 

A battle definition determines for the game all the vital properties of a battle, prior to loading. Such properties include what battlefield to use, where the armies should deploy, the factions, armies and units, the weather and more. For battles loaded from the campaign, the campaign itself creates the battle definition. For custom battles, the custom battle screen creates the definition from the inputs the user has given. For scripted content, the battle definition is created via an XML file.

 

Creating a Battle Definition XML

 

TEd does not automatically write a battle definition XML, you have to create one yourself. A sample XML can be found elsewhere in this documentation.

 

Copy the example (or any other working xml) into a file called battle.xml in the folder pertaining to your battle in:

 

%AppData%\The Creative Assembly\Attila\Maps

 

Elements of the Battle XML

A valid battle xml contains a heirarchy of objects defined within the xml itself. From a conceptual point of view, the main objects and how they are nested are described in the heirarchy structure below:

 

<battle>

<alliance>

<army>

<unit>

</unit>

<!-- additional units -->

</army>

<!-- additional armies -->

</alliance>

 

<alliance>

<army>

<unit>

</unit>

<!-- additional units -->

</army>

<!-- additional armies -->

</alliance>

 

<battle_description>

</battle_description>

 

<weather>

</weather>

 

</battle>

 

 

 

 

 

Workflow Tips

Creating an XML by copying

 

When creating a new scripted battle it's usually best to duplicate a working XML from an existing battle and edit it, rather than trying to write one from scratch.

 

Use XML comment syntax

 

Sections of XML can be commented out and prevented from working using the following syntax:-

<!--

        <tag>not being read</tag>

-->

 

Create units by hand

 

When laying out armies for the first time, the best initial approach is to do it roughly by hand. Copy and paste the individual units within the XML until the required number of units is reached, then edit the unit keys and number of men. This will set out an army with multiple units in the exact same position. The next step will be to arrange those units in more desirable locations.

 

Allowing free deployment on the battlefield

 

By removing or commenting-out the <battle_script> tag (within the <battle_description> tag) any battle script will be prevented from executing and the battle will enter deployment phase when run (assuming deployment is not skipped with the <skip_deployment> tag). This allows deployment of units around the battlefield during the deployment phase, which is useful because units in the controlled army can then be deployed to their desired start positions.

 

When the Start Battle button is clicked the game will write a version of the XML to the following file:

 

%appdata%\The Creative Assembly\Attila\logs\battle.xml

 

If the player's units are deployed in their desired start position and then the Start Battle button clicked, the XML that gets written will contain the units in those positions. The positions, orientations and widths can then be copied from this output XML into the original source XML in the map folder. It's inadvisable to copy the entire XML in one go, however, as the output process tends to juggle the order of tags around and rewrites some unit special abilities. Instead, copy and paste each individual block of <position>, <orientation> and <width> tags, one at a time, from each outputted unit to the same unit in the source file.

 

Switching Sides

 

The player always controls the first army of the alliance defined in the battle XML. By re-arranging the order in which the alliances are declared and repeating the above steps, the layout for any allied armies and the enemy alliance may be defined.