Modding

From Warhammer 40,000: Gladius - Relics of War Wiki
Jump to: navigation, search

Practically every aspect of Gladius - Relics of War is moddable; only modifying the game logic remains inaccessible.


You can create new or modify existing:


General Notes:

- References to game directories like \Data, \Resources, etc. are shorthand for


  • \Warhammer 40000 Gladius - Relics of War\Data;
  • \Warhammer 40000 Gladius - Relics of War\Resources;
  • etc.


where \Warhammer 40000 Gladius - Relics of War is the top-level game installation directory.

- For brevity, the wiki uses the Windows backslash \ notation with regards to directory identification. Linux users should readily replace the backslash with a forward slash /.


Mod Location[edit | edit source]

As of patch 1.08, the game uses non-destructive modding (i.e., core files are not modified). In order for the game to load mods, they must be placed in:


  • (Windows) \My Documents\Proxy Studios\Gladius\Mods\<mod name>\Data\
  • (Linux) ~/.config/Proxy Studios/Gladius/Mods/<mod name>/Data/


replacing <mod name> with the name of the actual mod. Any mod files meant to replace their original counterparts must be named and placed in the correct directory hierarchy (detailed below) in order to be flagged as such by the engine.


The \Data Structure[edit | edit source]

All of the game's assets are located under \Warhammer 40000 Gladius - Relics of War\Data:

Rather than further enumerate individually all of the numerous sub-directories, the location of specific remaining content is best absorbed through particular modding ventures. For example, when creating a new "unit", that respective section of the modding guide will elaborate all the necessary files required under \Audio, \Video, \World, etc.


Log Files & Crashes[edit | edit source]

As with any general modding venture, there will often be times where changes will lead to a game crash. To help diagnose the source of the error, in addition to an on-screen error prompt, the game writes an error log to:


  • (Windows) \My Documents\Proxy Studios\Gladius\Logs\Gladius.error.log
  • (Linux) ~/.config/Proxy Studios/Gladius/Logs/Gladius.error.log


Consulting this log file is an excellent place to help narrow down the source of the error.


Some general crash issues:

  • Missing elements in \Data\Core and \Data\World usually cause a crash on game startup.
  • Missing elements in \Data\Video usually cause a crash with "Visual C++ runtime error".
  • Click on "New Game". Crashes here are mostly due if you missed adding faction base images to new factions, or changed WorldParameters.xml
  • Launch this new game. Crashes here occur for missing cutscenes in Data\Video, missing starting city or units, but also other reasons.
  • Settle a new city.' Crashes here occur of you forgot to add a base city for your faction.
  • Once you test a game where you can settle a city, also remember to check the Compendium and Research features and see if they do not crash.
  • Crashes when clicking on Research mean you have bad references in Data\World\Upgrades and Data\Core files, or just missing icons in Data\Video, or that you added a research that does not have enough researches leading to that tier.
  • Crashes when clicking on Compendium mean you forgot to add flavor or description to some elements in Data\Core.


XML Programming[edit | edit source]

Every aspect of the game outside of the engine is defined using XML. The difficulty posed to the modder is not XML per se, but rather the general game framework built using XML. In other words, Gladius XML. The engine recognizes certain predefined XML code structure that modders need to adhere to. Opening up an .xml file and changing a value or following a pattern to add to the existing code is trivial. Going through such an example is illustrated at the end of this page. Getting the engine to work with custom XML tags is the tricky part. In this section we give an example of a more intricate nature showcasing how the general Gladius XML framework is structured.


For this example we will consider a simple modification to the colour of the Menu button in the top-right corner of the world GUI. This button is defined using the following code:


\Data\GUI\Blueprints\World\TopBar.xml

<?xml version="1.0" encoding="utf-8"?>
<world:topBar type="topBar">
	<container layoutAlignment="MiddleLeft" preferredSize="FillParent FillParent" weights="2 FillAll">
		<label name="resourcesLabel" alignment="MiddleRight" preferredSize="WrapContent FillParent" stringStyle="<style name='Heading'/>"/>
	</container>
	<container layoutAlignment="MiddleCenter" preferredSize="FillParent FillParent" weights="1 FillAll">
		<label name="turnLabel" alignment="MiddleCenter" preferredSize="FillParent FillParent" stringStyle="<style name='Heading'/>" wordCut="1"/>
	</container>
	<container layoutAlignment="MiddleRight" layoutGap="8 8" preferredSize="FillParent FillParent" weights="2 FillAll">
		<label name="playerLabel" alignment="MiddleRight" preferredSize="FillParent FillParent" weights="1 FillAll" stringStyle="<style name='Heading'/>" wordCut="1"/>
		<!-- <button name="restartButton" preferredSize="148 FillParent" caption="<string name='GUI/RestartScenario'/>" type="emphasizedButton"/> -->
		<button name="menuButton" preferredSize="148 FillParent" caption="<string name='GUI/Menu'/>" keys="Escape"/>
	</container>
</world:topBar>


Specifically, we are interested in the third-last line <button name="menuButton" ... />. This tells us that the Menu button style is defined as <button>. Now, the definition for <button> is:


\Data\GUI\Skins\Default.xml

<skin>
	...
	<button preferredSize="200 28"
			pressedSound="Interface/Press">
		<background texture="GUI/Button" color="1 1 1 1"
				pressedTexture="GUI/Button" pressedColor="1 1 1 1"
				padding="7 7" delta="2 2"/>
		<content margin="4 2"/>
	</button>
	...
</skin>


From this we see that the original texture used for a <button> is \Data\Video\Textures\GUI\Button.dds. We can proceed by either 1) changing what Button.dds looks like, 2) create a new image, for example, NewButton.dds, and set pressedTexture="GUI/NewButton", or 3) modify TopBar.xml. The modder is encouraged to try the first two approaches and see that they are inadequate solutions. The underlying image used by <button> is system-wide, so aspects of the UI that the modder never intended to change will, in fact, change. Therefore, we are left with implementing a Gladius XML solution.


The engine expects TopBar.xml to pass to it <button>. If the modder attempts to create a new custom XML tag, for example, <menuButton>, then the game will crash. However, the problem is not where to define it, but rather how to define it. There is no getting around the fact that <button> is a construct defined directly in the engine. Therefore, the modder is not going to be successful in trying to create a new construct that the engine does not inherently understand. What the modder can do is modify which <button> will be loaded:


\Data\GUI\Skins\Default.xml

<skin>
	...
	<button preferredSize="200 28"
			pressedSound="Interface/Press">
		<background texture="GUI/Button" color="1 1 1 1"
				pressedTexture="GUI/Button" pressedColor="1 1 1 1"
				padding="7 7" delta="2 2"/>
		<content margin="4 2"/>
	</button>
	...
	<menuButton preferredSize="200 28"
			pressedSound="Interface/Press">
		<background texture="GUI/ButtonMenu" color="1 1 1 1"
				pressedTexture="GUI/ButtonMenu" pressedColor="1 1 1 1"
				padding="7 7" delta="2 2"/>
		<content margin="4 2"/>
	</menuButtonbutton>
	...
</skin>


So what we did was define a new XML tag <menuButton> that has the exactly same structure as <button>. Now, in TopBar.xml, we can reference this new button by the type attribute:


<button type="menuButton" name="menuButton" ... />


The above example demonstrates that XML in-and-of-itself is insufficient beyond superficial manipulation of existing values. Advanced modding relies on understanding the underlying Gladius XML framework.

Modifiers[edit | edit source]

When creating or modifying units, buildings, traits, weapons, etc, modifiers are very important to know about. More information about their structure, lists of their components and explanations of their effects can be found in the modifiers page.

General Notes about Image Editing[edit | edit source]

All images (apart from fonts) use the DDS file format. The freely-available Paint.NET program (https://www.getpaint.net/download.html) is an easy and convenient way to work with DDS images.

The trickiest part in getting images to work in Gladius - Relics of War is to make sure to have the correct export settings for the DDS format. The export settings will appear only after first saving the file in Paint.NET. Use the following export settings:

- DXT3 (Explicit Alpha)
- Cluster fit (Slow/HQ)
- Perceptual
- Generate Mip Maps
- Fant

The only other thing to keep in mind while working with images in Paint.NET is to set an appropriate Opacity-Alpha value (which is accessible from the Colors palette -> More). Setting this value correctly might require some trial and error, especially if it's an image to which the game applies it's own additional filters.


Dev-Provided Modding Resources[edit | edit source]

The development team at Proxy Studios has provided the community with official tools that can be used for modding. These are the same tools used in-house by the studio when creating game assets. Anyone who bought the game, automatically gets access to the tools:



A Simple Example Mod[edit | edit source]

By editing \Data\World\Blueprints\WorldParameters.xml you can add an option for larger maps. The original file contains the following code:

<sizes>
	<size dimension="27 27" recommendedPlayers="2"/>
	<size dimension="33 33" recommendedPlayers="3"/>
	<size dimension="38 38" recommendedPlayers="4"/>
	<size dimension="46 46" recommendedPlayers="6"/>
	<size dimension="53 53" recommendedPlayers="8"/>
</sizes>


We can add a new line at the end to make a new map size, 80x80 with recommended player count of 16:

<sizes>
	<size dimension="27 27" recommendedPlayers="2"/>
	<size dimension="33 33" recommendedPlayers="3"/>
	<size dimension="38 38" recommendedPlayers="4"/>
	<size dimension="46 46" recommendedPlayers="6"/>
	<size dimension="53 53" recommendedPlayers="8"/>
	<size dimension="80 80" recommendedPlayers="16"/>
</sizes>


Now we must also locate the string reference, otherwise the game will crash. We do this by modifying \Data\Core\Languages\<...your language...>\WorldParameters.xml. The original file contains the following code:

<language>
	...
	<entry name="Size" value="World Size"/>
	<entry name="Size0" value="Tiny"/>
	<entry name="Size0Hint" value="%1%: Recommended for 2 players."/>
	<entry name="Size1" value="Small"/>
	<entry name="Size1Hint" value="%1%: Recommended for 3 players."/>
	<entry name="Size2" value="Medium"/>
	<entry name="Size2Hint" value="%1%: Recommended for 4 players."/>
	<entry name="Size3" value="Large"/>
	<entry name="Size3Hint" value="%1%: Recommended for 6 players."/>
	<entry name="Size4" value="Huge"/>
	<entry name="Size4Hint" value="%1%: Recommended for 8 players."/>
	...
</language>

where the ... represent other code in the file but not directly pertinent for our mod. We want two follow the same structure as the above code and add two new lines at the end:

<language>
	...
	<entry name="Size" value="World Size"/>
	<entry name="Size0" value="Tiny"/>
	<entry name="Size0Hint" value="%1%: Recommended for 2 players."/>
	<entry name="Size1" value="Small"/>
	<entry name="Size1Hint" value="%1%: Recommended for 3 players."/>
	<entry name="Size2" value="Medium"/>
	<entry name="Size2Hint" value="%1%: Recommended for 4 players."/>
	<entry name="Size3" value="Large"/>
	<entry name="Size3Hint" value="%1%: Recommended for 6 players."/>
	<entry name="Size4" value="Huge"/>
	<entry name="Size4Hint" value="%1%: Recommended for 8 players."/>
	<entry name="Size5" value="Gigantic"/>
	<entry name="Size5Hint" value="%1%: Recommended for 16 players or more."/>
</language>


We now make sure that the above files are placed in the correct mod location under a suitable mod name and... tada! We just allowed for an epic map size!