Skip to content

Create a mod friendly way to manipulate loot tables #275

@Musashi1584

Description

@Musashi1584

Although loot tables are already deprivatized there is no common way to add/remove loot.
There are some caveats involved,e.g. loot chances must be recalculated per rollgroup when a loot table is edited.
A simple helper class with static methods would go a long way in providing a unified interface for mods to interact with loot tables without the hassle of ini entry manipulating.

For pre start state manipulation of loot tables use the static methods in OnPostTemplatesCreated like this
class'X2LootTableManager'.static.AddEntryStatic(LootTableName, LootTableEntry);

At runtime you can use the singleton instance like

LootManager = class'X2LootTableManager'.static.GetLootTableManager();
LootManager.AddEntry(LootTableName, LootTableEntry);
LootManager.InitLootTables();

this will also reinitialise the loot tables.

For bulk add to loot tables you can move the chance recalculation to the end:

LootManager.AddEntry(TableName, EntryToAdd, false);
LootManager.AddEntry(TableName, EntryToAdd, false);
LootManager.AddEntry(TableName, EntryToAdd, false);
LootManager.RecalculateLootTableChance(TableName);

This way your chance ratio is preserved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions