Default Loot Table

How is the default loot table for Better Loot generated? It appears to differ from what's listed on rustlabs.

In the LoadAllContainers() function. You are right it is wrong, It sets both min/max to max, and it's even missing some items. I wish I knew enought about how the game does it to fix this. It's a bit of a mess, a lot of old code, many different people worked on it all these years.

                    int slots = 0;
                    if (loot.LootSpawnSlots.Length > 0)
                    {
                        LootContainer.LootSpawnSlot[] lootSpawnSlots = loot.LootSpawnSlots;
                        for (int i = 0; i < lootSpawnSlots.Length; i++)
                            slots += lootSpawnSlots[i].numberToSpawn;
                    }
                    else
                        slots = loot.maxDefinitionsToSpawn;
                    container.Add("ItemsMin", slots);
                    container.Add("ItemsMax", slots);
discordFan

In the LoadAllContainers() function. You are right it is wrong, It sets both min/max to max, and it's even missing some items. I wish I knew enought about how the game does it to fix this. It's a bit of a mess, a lot of old code, many different people worked on it all these years.

                    int slots = 0;
                    if (loot.LootSpawnSlots.Length > 0)
                    {
                        LootContainer.LootSpawnSlot[] lootSpawnSlots = loot.LootSpawnSlots;
                        for (int i = 0; i < lootSpawnSlots.Length; i++)
                            slots += lootSpawnSlots[i].numberToSpawn;
                    }
                    else
                        slots = loot.maxDefinitionsToSpawn;
                    container.Add("ItemsMin", slots);
                    container.Add("ItemsMax", slots);

^100%

Part of the problem of wrong or missing items in the crate: lines 157-166 and 236-246, the if statements need switched around, and you'll notice he even does the same thing two different ways, try this:

if (loot.LootSpawnSlots.Length != 0) {
	LootContainer.LootSpawnSlot[] lootSpawnSlots = loot.LootSpawnSlots;
	foreach (var lootSpawnSlot in lootSpawnSlots) {	GetLootSpawn(lootSpawnSlot.definition, ref itemList); }
}
else if (loot.lootDefinition != null) { GetLootSpawn(loot.lootDefinition, ref itemList); }
​

for the code posted before about slots; for the most part min is always max-1? It's true for most containers I think. Try this for that fix:

container.Add("ItemsMax", slots);
slots = (slots > 1) ? slots - 1 : slots;
container.Add("ItemsMin", slots);

I'm stuck on the individual items, min should be correct, it's max that's the problem. It's figured in the GetAmounts method. this is what it uses, and is wrong:

((ItemAmountRanged)amount).maxAmount​
discordFan

Part of the problem of wrong or missing items in the crate: lines 157-166 and 236-246, the if statements need switched around, and you'll notice he even does the same thing two different ways, try this:

if (loot.LootSpawnSlots.Length != 0) {
	LootContainer.LootSpawnSlot[] lootSpawnSlots = loot.LootSpawnSlots;
	foreach (var lootSpawnSlot in lootSpawnSlots) {	GetLootSpawn(lootSpawnSlot.definition, ref itemList); }
}
else if (loot.lootDefinition != null) { GetLootSpawn(loot.lootDefinition, ref itemList); }
​

for the code posted before about slots; for the most part min is always max-1? It's true for most containers I think. Try this for that fix:

container.Add("ItemsMax", slots);
slots = (slots > 1) ? slots - 1 : slots;
container.Add("ItemsMin", slots);

I'm stuck on the individual items, min should be correct, it's max that's the problem. It's figured in the GetAmounts method. this is what it uses, and is wrong:

((ItemAmountRanged)amount).maxAmount​

Is there a github for this plugin where these updates can be submitted for pull requests?

Hi, in large wooden crates (basic) I spawn instead (rifle body, smg body, etc.) mostly electrical components. How do I change it? Thank you