X4: Foundations

X4: Foundations

More Default Paint
SkeletalFish  [developer] 31 Oct, 2021 @ 8:58am
How This Mod Works
I have had a request for a guide on how this mod works. It is pretty straight forward, it involves two files, a script and an xml file (along with the content.xml file and preview image necessary for uploading the mod to the workshop). The next two posts will describe these files, and what you would need to do to make your own mod with this functionality.

I would recommend extracting one of my mods using the X Catalogue Tool here[www.egosoft.com] so that you have some files to look at while reading this discussion.
Last edited by SkeletalFish; 31 Oct, 2021 @ 9:19am
< >
Showing 1-5 of 5 comments
SkeletalFish  [developer] 31 Oct, 2021 @ 9:14am 
The first file is the themes.xml file. This is in the libraries folder and essentially tells the game what wares are usable as ship skins by the AI, and in special cases what skins can be used by the player as default skins. This file is a patch file, so if you don't already know what that is look up how to make xml patch files for X4, there are plenty of tutorials here[forum.egosoft.com]. This file has a load of add patch sections that look like this:

<add sel="/themes">
<theme id="painttheme_player_custom_9" default="error_theme" name="{20114,10011}">
<group faction="player" paintmod="paintmod_0001" />
</theme>
</add>

To add a new paint, make a similar block in your own themes.xml file, and change the various parameters. I don't think these need to be individual add blocks, you can merge them into a single one, the multiple blocks is a left over bug fixing attempt as in previous X games errors could occur if there was more than one inner block (ie the theme block) per operation block.
  • The id parameter is up to you, it does not need to match anything in your mod, but it must be unique.
  • The default parameter does not need changing, this is what the game defaults to if the paint mod specified cannot be loaded.
  • The name parameter needs changing to the display name of your paint job. This can either be a link to a translation string, as in the example above, or can be a text string.
  • The faction parameter does not need changing, "player" tells the game that this is for a default player skin, not for an AI faction.
  • The paintmod parameter must match the id of your paint mod as it is in your wares.xml file
Add a theme block for each paint mod you want to have available in the default skin list, making sure to change the parameters accordingly.
SkeletalFish  [developer] 31 Oct, 2021 @ 9:31am 
The other file is the xml file in the md folder. Without this file the themes.xml file will do nothing. This is a script, provided by $300, that adds the paint jobs in the wares.xml file of your mod (or the base game) to the player as blueprints. This script replaces the need to edit the game starts so provides compatibility with any game start, custom or vanilla, and allows the mod to work on existing saves.

There are a few lines in this file that also need changing.

At the start of the file are the lines:

<mdscript name="Addthemestoplayer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<cues>
<cue name="Addthemesonload">

Change the name parameters to something unique in the mdscript block and the cue block to something unique

Further down the file is a block like:

<set_value name="$paintmods" exact="[
ware.paintmod_0001,
ware.paintmod_0002,
ware.paintmod_0003,
...
]"/>

This is a list of all the paint mod wares that you have created in wares.xml (that you have also included in the themes.xml group blocks). Between the [ and ] place a comma separated list of all your paint mod ware ids, prefixed with "ware." without the quotes.
SkeletalFish  [developer] 31 Oct, 2021 @ 9:43am 
And that is it. As long as you have added these two files, with the mentioned changes, to your existing paint job mod, they should show up in the default skin list. As mentioned by Hijack Hornet in the main comment thread, there are some additional changes you can make to the script to allow easier updating in the future, but I have not yet got around to adding that to my own mod yet.

I have created a python script that automates this process, but it's pretty rough. I basically just point it at the extracted mod files, it then loops over the paintmods.xml file to get a list of paint mods added by the mod, links them to names from the wares.xml, then uses a loop of string operations to build up the xml files needed for these default paint mods.

If you have any questions about making these mods feel free to ask them in this discussion thread. This isn't the most beginner friendly tutorial, the best place for tutorials on X4 mod making in general is the Egosoft forums.
Last edited by SkeletalFish; 31 Oct, 2021 @ 9:47am
Grandsome 20 Dec, 2021 @ 10:24pm 
thanks for making this guide, I'll try my hand at making patches
Hobo 1 Apr, 2022 @ 1:50pm 
Any chance you upload this to nexus for us gog users?
(sorry for asking hear, steam won't let you post in the comment section unless you buy the steam version)
< >
Showing 1-5 of 5 comments
Per page: 1530 50