Superxpdude / tmtm_template

Templates for mission creation for TMTM
3 stars 8 forks source link

Inventory system: Injection of custom loadout resolution logic #57

Open erem2k opened 1 year ago

erem2k commented 1 year ago

Currently inventory system resolves final loadout from config name right in the XPT_fnc_loadInventory before applying it to the unit. This includes fetching inventory defines from XPTLoadouts, performing random selections, etc. before formatting an array for setUnitLoadout call which does the actual application.

It would be beneficial to have an opt-in API that will allow to override the default behavior for creating loadout array, while preserving the general function of XPT loadout system.

This can be achieved by abstracting out the section of logic that currently does loadout resolution into separate function and introducing define for description.ext which will allow scripter to declare override function to be used in XPT_loadInventory in place of default one.

Such API will allow to extend the behavior of loadInventory in consistent and easier to maintain fashion, while generic use case will remain unaffected.

erem2k commented 1 year ago

This is something I've hit trying to randomize weapons and appropriate uniform\vest\backpack cargos, but this can also be quite useful for handling fully or partially DLC-restricted loadouts.

PR to address this is being prepared, hopefully this issue will provide additional context.