ModifyGeneratedUnitAppearance

Tracking Issue: #783

Tags: customization, compatibility

Usage

This DLC hook allows mods to make arbitrary changes to unit appearance after it has been generated by XGCharacterGenerator::CreateTSoldier(). The generated appearance is stored in CharGen.kSoldier.kAppearance, which you can modify directly.

Other arguments are provided to for reference, as they were given to the CreateTSoldier() function.

The UnitState and the GameState will be passed to this hook only if the CreateTSoldier() function was called from CreateTSoldierFromUnit(), which normally happens only in the Shell code (TQL / Challenge Mode / Character Pool), and will be none otherwise.

If you wish to "redo" some parts of the process of generating unit's appearance, you can call various methods in the Character Generator, but you must avoid calling the CreateTSoldier() and CreateTSoldierFromUnit() methods, as that will retrigger the hook, potentially causing an inception loop and crashing the game.

Issue #1140 Addendum

This hook is triggered twice for faction heroes. Reapers and Templars run this hook the first time after initial character generation, and the second time after their faction-specific country and class-specific nickname have been generated. Skirmishers additionally get their faction-specific name after the first time the hook is triggered.

Compatibility

Custom XGCharacterGenerator classes used by mods to generate appearance of custom units can potentially interfere with the normal operation of this hook for themselves.

If the Character Generator implements a custom CreateTSoldier() function that does not call super.CreateTSoldier(), then this DLC hook will not be called for that class.

If super.CreateTSoldier() is called, but the custom CreateTSoldier() function makes changes to the generated appearance afterwards, it can potentially override changes made by this hook.

For best compatibility with this hook, mod-added XGCharacterGenerator classes should avoid making any appearance changes after calling super.CreateTSoldier(). Ideally, that function should not be overridden at all, and the Character Generator should rely on overriding other methods called by CreateTSoldier() as much as possible.

Source code references