Resolves Bot Generation Error

- Resolves an issue in bot generation caused by a missing parameter when calling the `shouldModBeSpawned` method.
- Adds a optional chaining operator within a condition to safeguard against undefined errors.

Contributed by: barlog_m

Thank you! :D
This commit is contained in:
Refringe 2024-02-05 19:16:36 -05:00
parent cd6e40b66c
commit 807ba04967
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E

View File

@ -108,6 +108,7 @@ export class BotEquipmentModGenerator
itemSlotTemplate, itemSlotTemplate,
modSlotName.toLowerCase(), modSlotName.toLowerCase(),
settings.spawnChances.equipmentMods, settings.spawnChances.equipmentMods,
settings.botEquipmentConfig,
); );
if (modSpawnResult === ModSpawn.SKIP && !forceSpawn) if (modSpawnResult === ModSpawn.SKIP && !forceSpawn)
{ {
@ -725,7 +726,7 @@ export class BotEquipmentModGenerator
return ModSpawn.SPAWN; return ModSpawn.SPAWN;
} }
const spawnMod = this.probabilityHelper.rollChance(modSpawnChances[modSlot]); const spawnMod = this.probabilityHelper.rollChance(modSpawnChances[modSlot]);
if (!spawnMod && (slotRequired || botEquipConfig.weaponSlotIdsToMakeRequired.includes(modSlot))) if (!spawnMod && (slotRequired || botEquipConfig.weaponSlotIdsToMakeRequired?.includes(modSlot)))
{ {
// Mod is required but spawn chance roll failed, choose default mod spawn for slot // Mod is required but spawn chance roll failed, choose default mod spawn for slot
return ModSpawn.DEFAULT_MOD; return ModSpawn.DEFAULT_MOD;