X2CommunityCore / X2CommunityHighlander

MIT License
7 stars 3 forks source link

Add generic interface for loot table manipulation. #274

Closed Musashi1584 closed 7 years ago

Musashi1584 commented 7 years ago

Provides a mod friendly way to manipulate loot tables. A interface in X2LootTable allows mods to add/remove whole tables or items to loot tables without ini juggling. Drop chances are recalculated accordingly. 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.