Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mod friendly way to manipulate loot tables #275

Open
Musashi1584 opened this issue Aug 13, 2017 · 0 comments
Open

Create a mod friendly way to manipulate loot tables #275

Musashi1584 opened this issue Aug 13, 2017 · 0 comments

Comments

@Musashi1584
Copy link
Contributor

Musashi1584 commented Aug 13, 2017

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.

Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 13, 2017
Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 14, 2017
Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 17, 2017
Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 18, 2017
Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 19, 2017
Musashi1584 added a commit to Musashi1584/X2CommunityHighlander that referenced this issue Aug 21, 2017
MalucoMarinero pushed a commit that referenced this issue Aug 31, 2017
* Added generic helper for loot tables.

* Issue #275 Provide a loot helper class

* Only recalculate changes when chances exceed 100%

* #275 Moves loot helper methods to X2LootTable and adds remove helper methods

* #275 Use self for instance methods, CDO for static methods

* #275 Removes InitLootTable calls and fixes RemoveEntry

* #275 Refactored and fixes. Makes recalculating optional for bulk add and recalc at the end

* #275 even out round based differences using the largest remainder method

* Fixes typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant