Added nullguard check inside generateLoot()
to prevent 380 mods killing bot generation
This commit is contained in:
parent
2e824b129c
commit
ac5103390c
@ -85,6 +85,24 @@ export class BotLootGenerator
|
|||||||
// Limits on item types to be added as loot
|
// Limits on item types to be added as loot
|
||||||
const itemCounts = botJsonTemplate.generation.items;
|
const itemCounts = botJsonTemplate.generation.items;
|
||||||
|
|
||||||
|
if(!itemCounts.backpackLoot.weights
|
||||||
|
|| !itemCounts.pocketLoot.weights
|
||||||
|
|| !itemCounts.vestLoot.weights
|
||||||
|
|| !itemCounts.specialItems.weights
|
||||||
|
|| !itemCounts.healing.weights
|
||||||
|
|| !itemCounts.drugs.weights
|
||||||
|
|| !itemCounts.food.weights
|
||||||
|
|| !itemCounts.drink.weights
|
||||||
|
|| !itemCounts.currency.weights
|
||||||
|
|| !itemCounts.stims.weights
|
||||||
|
|| !itemCounts.grenades.weights
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.logger.warning(`Unable to generate bot loot for ${botRole} as bot.generation.items lacks data, skipping`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const backpackLootCount = Number(
|
const backpackLootCount = Number(
|
||||||
this.weightedRandomHelper.getWeightedValue<number>(itemCounts.backpackLoot.weights),
|
this.weightedRandomHelper.getWeightedValue<number>(itemCounts.backpackLoot.weights),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user