X2CommunityCore / X2CommunityHighlander

MIT License
7 stars 3 forks source link

Create a mod friendly way to manipulate loot tables #275

Open Musashi1584 opened 7 years ago

Musashi1584 commented 7 years ago

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.