Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.
Raymond Wu edited this page May 18, 2020 · 25 revisions

Welcome to the Custom Troop Upgrades wiki! This page will help you in how to use this mod.

Example here: https://github.com/Designer225/CustomTroopUpgrades/wiki/Example

Overview

On first glance, Custom Troop Upgrades allows you to specify troop upgrade paths to be added. And it does that. But it also allows you to delete the same specified troop paths! And all without having to touch troop XML files.

If you do create custom troops, you can use this mod to "patch" old units to use the new units' stats, upgrades included. You can even specify what parts of troop information to and not to overwrite. This bypasses an issue where overwriting existing troop configs causes vanilla information to mix in with modded ones.

And more importantly, the mod checks through all currently active modules (including itself) to make sure the changes do not get applied unless the modules that are required for the changes to take effect are loaded.

Setup

All XML config files used by this mod need to be in the CustomTroopUpgradesData directory of your module folder, as this mod only loads data from that folder. These files need to have a format similar to the example config. Do not specify these XML files in SubModule.xml as this mod automatically searches for all active mods for the CustomTroopUpgradesData folder and its contents.

The replacement troop definition files (e.g. spnpccharacters.xml) go where they usually go - i.e. the ModuleData folder. You use this mod's replace operations (see Overwriting Troops) to updates other troops to use their replacements' stats. Do not put troop definition files in CustomTroopUpgradesData - they will not be loaded. Put them in ModuleData folder as normal, and reference them in your mod's SubModule.xml file.

So this might be your module's local file system:

<YourModule>
|-SubModule.xml
|-<other folders, e.g. bin>
|-ModuleData
  |-<your troop definition files, all XMLs>
  |-<other stuff that makes your troops work>
|-CustomTroopUpgradesData
  |-<your troop upgrade/replace config files here, all XMLs>

Barring format-breaking changes, the XML configs should work every update. They will do nothing without this mod, but that is fine.

Format

CustomTroopUpgrades

The root node of the XML file must be a CustomTroopUpgrades node, which indicates the start of a Custom Troop Upgrade config:

<CustomTroopUpgrades Priority="1000">
</CustomTroopUpgrades>

Attributes:

  • Priority (optional): This dictates when the configs in the XML are loaded. A lower priority causes the config file to load earlier. Default is 1000. Specify a higher value for things such as compatibility patches.

Note: the mod loads configs first by Priority, then by the contents of DependentModules (see below). So if two configs have the same priority, the config with more dependent modules will load later than the other one. If both have the same number of modules, then the config whose DependentModule IDs are "ahead" of those of the other (see String.CompareTo function at MS Docs) will load earlier. This might cause issues with compatibility patches; for that reason, you should specify a Priority value for compatibility patches and related things.

Within a CustomTroopUpgrades node, there are three sub-nodes: DependentModules, covered below, and CustomTroopUpgradeOperations and CustomTroopReplaceOperations, which have their own pages.

DependentModules

DependentModules, as the name suggest, represent modules that need to be loaded before the config can take effect.

<DependentModules>
  <Module>SturgianArmyReDone</Module>
</DependentModules>

Within each Module node, specify the IDs of modules that need to be loaded before the config can be used.

The mod will always assign Native, SandBoxCore, Sandbox, StoryMode, and CustomBattle as dependent modules, even if they are not specified in the config. It is recommended that you specify other dependent modules unless you are only modifying vanilla troops.

Operation Apply Order

The mod applies all CustomTroopReplaceOperations first, then CustomTroopUpgradeOperations.

Limitations

  • Currently, Bannerlord is limited to only 2 upgrades per troop. Any more than that will crash the game when attempting to access the troop's upgrades from the Party menu. The encyclopedia entry for that troop will also be borked. A workaround is to delete an existing upgrade path for every upgrade path you add, before you add the upgrade.
  • Some may notice the "double entry in the encyclopedia" issue. Unfortunately, the way this mod bypasses the issue of the game attempting to mix vanilla and modded information involves having to use a modified copy of the original unit, then replacing the original's information with the modded one. The amount of effort required to fix this renders a fix unlikely.

Troubleshooting

This mod will (usually) not crash the game if it encounters a problem; it instead outputs the error information to rgl_log_x.txt in C:\ProgramData\Mount and Blade II Bannerlord\logs folder (usually). When you report an issue, make sure to include that file in your report; I cannot help you without it.