Warhammer 40,000: Rogue Trader

Warhammer 40,000: Rogue Trader

Warhammer 40,000: Rogue Trader Worskhop
Explore other users' modes. Subscribe so you don't miss new content!
Learn More
 This topic has been pinned, so it's probably important
Starrok  [developer] 9 Dec, 2023 @ 1:25pm
Rogue Trader Modding Guide
Rogue Trader provides support for users who want to create additional content. The game supports 2 main ways of creating user content: our own OwlcatModificationManager and deep UnityModManager integration. Moreover, Rogue Trader supports Steam Workshop, feel free to visit the workshop to upload your own content or look at other users’ mods. Let’s take a brief overview of both modding ways.

OwlcatModificationManager.

This is Owlcat’s toolset which allows you to create and use mods in Rogue Trader. Everything you need to start using it is already shipped with the game. Toolset is located among game files at:

<game_installation_folder>\Warhammer 40,000 Rogue Trader\Modding

There is a folder and archive:

- “Steam Workshop tool” folder contains a compiled version of our Steam Workshop software, you can use it to publish and install content from Steam Workshop. Just run “Warhammer 40,000 Rogue Trader\Modding\Steam Workshop tool\owlcat-modifications-manager-win32-x64\owlcat-modifications-manager.exe” to start using the tool.

- WhRtModificationTemplate-release.rar contains a Unity3D project, which we call Modification Template. To use it, you’ll need to have Unity3D 2022.3.7f1 version installed on your computer. It’s recommended to unarchive the contents of the archive somewhere else from the Rogue Trader install directory. In other cases there is a chance that Steam will accidentally erase all the changes you’ve made to the Rogue Trader installation folder.

If you have experience with creating mods for Pathfinder: Wrath of the Righteous, you can notice that OwlcatModificationTemplate in Rogue Trader and OwlcatModificationTemplate in WotR have much in common. Rogue Trader’s modification support develops the ideas implemented in WotR modding support and brings them to a new level. The main advantage of Rogue Trader modding support is that now you can create mods without writing a single line of code.

Getting started with OwlcatModificationManager.

1. Unarchive the contents of WhRtModificationTemplate-release.rar somewhere outside the game folder.
2. Make sure you have Unity3D 2022.3.7f1 version installed on your computer. If you haven’t, please visit Unity3D download page (https://unity.com/releases/editor/archive) and install the correct version of the game engine. Please note: the installed Unity3D version should be 2022.3.7f1, we give absolutely no guarantee that ModificationTemplate would work using any other version of Unity3D. You don’t need to install any additional modules of Unity3D.
3. You can create mods for Rogue Trader without writing any code. But to use a full advantage of modding features you need to have some c# code editor or text editor installed on your computer, any of your choice should work.
4. Start Unity and open your WhRtModificationTemplate folder as a project.
5. Now you are ready to create mods.

The ModificationTemplate project contains some small and simple sample modifications. They can be found at “WhRtModificationTemplate-release\Assets\Modifications\” folder.

Setup your modification.

1. Create a folder for your modification in Assets/Modifications
2. Navigate to the folder you created and do the following: right click -> Modification Tools -> Create Mod Directory
3. This will create 4 folders (Blueprints, Scripts, Content, Localization) and a scriptable object file called NewModification.
4. Select NewModification and specify Unique Name, Version, and Display Name. Other fields are optional.
5. It’s a good practice to rename “NewModification” asset. You may call it as the Unique Name you specified.
6. Navigate to the “Scripts” folder and create the Assembly Definition file (right click -> Create -> Assembly Definition).
7. Create your mod.
8. To build your mod for in-game use select your modification asset (called “NewModification” by default) and click the “Build” button. This will compile scripts, create mod automatically and open the result folder.

Test your modification.

1. Copy Build/your-modification-name folder to “<user-folder>/AppData/LocalLow/Owlcat Games/Warhammer 40000 Rogue Trader/Modifications”
2. Add your modification to “<user-folder>/AppData/LocalLow/Owlcat Games/Warhammer 40000 Rogue Trader/OwlcatModificationManagerSettings.json”
3. Run Warhammer 40,000 Rogue Trader game.

ModifyOwlcatModificationManagerSettings.json file like this to enable your modification:
{ "EnabledModifications": ["your-modification-name"] // use name from the manifest(!), not folder name }

To check that your mod was detected by the game, run Rogue Trader, wait till the main menu loads. Hit Shift + F10 to open the OwlcatModificationManager window. Your mod name should appear in the window.

Features

Scripts
All of your scripts must be placed in assemblies (in folder with *.asmdef files or it's subfolders). Never put your scripts (except Editor scripts) in other places.

Content
All of your content (assets, prefabs, scenes, sprites, etc) must be placed in your-modification-name/Content folder.

Localization
You can add localized strings to the game or replace existing strings.

Create enGB|ruRU|deDE|frFR|zhCN|esES.json file(s) in your-modification-name/Localization folder.
You shouldn't copy enGB locale with different names if creating only enGB strings: enGB locale will be used if modification doesn't contain required locale.
The files should be in UTF-8 format (no fancy regional encodings, please!)

// localization file format
{
"strings": [
{
"Key": "guid", // "15edb451-dc5b-4def-807c-a451743eb3a6" for example
"Value": "whatever-you-want"
}
]
}

Assembly entry point

You can mark static method with OwlcatModificationEnterPoint attribute and the game will invoke this method with corresponding OwlcatModification parameter once on game start. Only one entry point per assembly is allowed.

[OwlcatModificationEnterPoint]
public static void EnterPoint(OwlcatModification modification)
{
...
}

GUI
Use OwlcatModification.OnGUI for inserting GUI to the game. It will be accessible from modifications' window (ctrl+M to open). GUI should be implemented with IMGUI (root layout is vertical).
example: Examples/Basics/Scripts/ModificationRoot.cs (ModificationRoot.Initialize method)

Harmony Patching

Harmony lib is included in the game and you can use it for patching code at runtime.
Harmony Documentation: https://harmony.pardeike.net/articles/intro.html
OwlcatModification modification = ...;
modification.OnGUI = () => GUILayout.Label("Hello world!");

Blueprints

Blueprints are JSON files which represent serialized version of static game data (classes inherited from SimpleBlueprint). You can consider blueprints as configuration files for the game. Blueprints must have file extension *.jbp and must be stored inside your-modification-name/Blueprints folder.

// *.jbp file format
{
"AssetId": "unity-file-guid-from-meta", // "42ea8fe3618449a5b09561d8207c50ab" for example
"Data": {
"$type": "type-id, type-name", // "618a7e0d54149064ab3ffa5d9057362c, BlueprintBuff" for example

// type-specific data
}
}

if you specify AssetId of an existing blueprint (built-in or from another modification) then the existing blueprint will be replaced

For access to metadata of all built-in blueprints use this method
// read data from <WotR-installation-path>/Bundles/cheatdata.json
// returns object {Entries: [{Name, Guid, TypeFullName}]}
BlueprintList Kingmaker.Cheats.Utilities.GetAllBlueprints();

If you add a brand-new blueprint (which doesn’t present in game) to your mod and reference it from the replaced\patched blueprint - this blueprint will be loaded from your mod automatically. Just don’t forget to add that brand-new blueprint file to the “Blueprints” folder of your mod.

Rogue Trader has a new feature called Blueprint patching. Blueprint patheris designed to modify the existing blueprint during runtime without changing or replacing source .jbp files. Blueprint patches have a special file format “.jbp_patch”. Patches can be created using Blueprints Editor, which is built in ModificationTemplate. Patching approach makes blueprint modding more flexible:

- You can still replace the blueprint if you wish. In that case, the replaced blueprint would be patched.
- You can patch a single blueprint file as many times as you want (in terms of single mod).
- Multiple mods can patch one blueprint at the same time. The only possible issue could happen - race of mods (in case of patching conflict, the order in which mods are applied affects the result).

If you want to patch or replace blueprint in your mod you should create a special scriptable object config in your mod. Right-click-inside-Blueprints-folder-of-your-mod -> Modification Tools -> Create Blueprint’s Patches Config. For each replaced or patched blueprint file in your folder add an Entry to created config:

1. Guid - guid of blueprint. You can get it selecting blueprint (.jbp or .jbp_patch) file -> right click -> Modification Tools -> Copy blueprint’s guid
2. Filename - file name of a blueprint (or patch) file. Right-click-on-file ->Modification Tools -> Copy file name
3. Patch type - Replace (for .jbp files) or Patch (for .jbp_patch files).

Blueprints Editor
To open the Blueprints Editor in ModificationTemplate click Window -> General -> Blueprints. This will open a window with blueprints files hierarchy. All the blueprints sources used in Rogue Trader are located inside the ModTemplate folder: In the “Blueprints” folder (near to Assets folder). This folder is ignored in Unity, but its content is shown in Blueprints Editor. Selecting Blueprint will show the Editor for Blueprints file in the “Inspector” window. To patch a blueprint file do:

1. Select a blueprint you want to patch
2. Hit the “Create Inherited” button at the top. This will create a new blueprint which has a target blueprint in the “Prototype” field. This means that the newly created blueprint inherits all the fields from the target one. Select the new blueprint file and double check “Prototype” field value/
3. Use can leave fields’ values or override them.
4. To override a value right-click on the little orange arrow at the right near corresponding value.
5. Now change the field value as you wish.
6. You can override nearly each field.
7. You can override multiple fields in one blueprint.
8. When you’re done editing values, hit the “Save” button at the bottom of the Inspector window.
9. Next hit the “Save as Patch” button.
10. Select a directory where you want to save a .jbp_patch file.
11. After the patch will be saved, a folder with a .jbp_patch file will be opened.
12. You should copy this file to the “Blueprints” folder of your mod.

Nearly everything in the game is configured with blueprints. Take a look at the folders, you may find a lot of interesting mod ideas. To make you blueprint search process easier, let us give you some pointers:

- Each of the party members has at least a couple of blueprints. Let’s look at Abelard, for example. His main blueprint file is Blueprints\Units\Companions\AbelardCompanion\AbelardCompanion.jbp. And fix features are inside Blueprints\Units\Pregens\PartyPregenTests\Abelard\FeatureLists\AbelardFeatureList_1lvl.jbp (or AbelardFeatureList_2lvl.jbp, AbelardFeatureList_3lvl.jbp)
- When creating your character at the game start, you are given several presets to choose (Fighter, Adept, etc.).Each preset has its own blueprint too Example 2: Soldier preset blueprints is located at Blueprints\Backgrounds\CharacterGeneration\StartGame_Pregens\StartGame_Pregen_Soldier.jbp

UnityModManager

UnityModManager (UMM) is a general tool which helps to create mods for Unity3D games. You can get information about it on Nexusmods. Tutorials and examples can be found there too. Rogue Trager has deep integration with UMM. This means that UnityModManager dll and its dependencies (including Harmony) are built inside the game code. This means that if you want to use UMM mod in Rogue Trader all you need to do is to copy the folder containing UMM-built mod inside

“<user-folder>/AppData/LocalLow/Owlcat Games/Rogue Trader/UnityModManager/” folder and start the game.

Brief overview

- You don’t need to patch the game to use UMM mods in it.
- You don’t need to configure UMM to use UMM mods in Rogue Trader.
- You can use OwlcatModificationManager mods and UMM mods together during the game.
- UMM code starts automatically at the most possible early moment during game start.
To see the UMM window inside Rogue Trader, run the game, wait till the main menu loads and hit Ctrl + F10.
- Notice that Rogue Trader uses a bit cut version of UMM (it lacks some functionality, like Updates).
- Rogue Trader uses Harmony v. 2.2.2.0
- For your convenience, you can use ADDB’s NuGet Templates to make the process of UMM mod project setup very simple.
- You can use Owlcat Steam Workshop tool to publish UMM-created mods to Steam Workshop.
- If you want a full UMM integration, you can follow the UMM guide and do it. This won’t break the game anyhow. In case of full UMM integration, the built-in cut UMM version will automatically detect Doorstop injection and will be disabled. In other words, full UMM integration disables built-in cut UMM.
- Don't change "Version", "ManagerVersion" and "GameVersion" fields values in the mod’s manifest.


Important Notes

- It may be useful to see some errors which may happen during Blueprints Editor usage. To see them use UberConsole (Window -> Show Uber Console).
- Some of the blueprint patches won’t make effect if you try to use mod with a save game made without the mod. There’s absolutely no guarantee that mods will work on saves, made without mods. Use them at your own risk.
- It’s better to use mods with New Game.
- There is a great mod which makes the process of Debugging the game state and your own mod much easier. We recommend you to use toyBox when testing your own mod or exploring how game state works. It’s very intuitive, useful and powerful.

Need help with the mod you’re working on? Want to contact other mod-creators? Feel free to join Owlcat Community Discord Server (https://discord.com/invite/owlcat)
Last edited by Starrok; 9 Dec, 2023 @ 1:25pm