From df93245e9d8d81b9d1ae34acc2e60002c0fda4d9 Mon Sep 17 00:00:00 2001 From: Brent Date: Thu, 18 Apr 2024 14:29:16 +0000 Subject: [PATCH] Fix incompatible default mods being used in required slots (!299) This prevents weapons from getting the default mods for their base preset when they won't fit other required mods. This was observed on the AK-74M, where the weapon generator would choose the VDM CS gas tube, which is incompatible with the default AK-74 polymer handguard (6P20 Sb.9). When this occurs, the generator will bypass the default mod selection and instead choose from the loot pool assigned to the handguard in the bot configs. https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/596 Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/299 Co-authored-by: Brent Co-committed-by: Brent --- .../src/generators/BotEquipmentModGenerator.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index b439054f..56bbcd2f 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -957,17 +957,25 @@ export class BotEquipmentModGenerator // You'd have a mod being picked without any sub-mods in its chain, possibly resulting in missing required mods not being added if (matchingMod) { - // Mod isnt in existing mod pool + // Mod is in existing mod pool if (itemModPool[modSlot].includes(matchingMod._tpl)) { // Found mod on preset + it already exists in mod pool return [matchingMod._tpl]; } - // Mod isnt in existing pool, only add if its got no children - if (this.itemHelper.getItem(matchingMod._tpl)[1]._props.Slots.length === 0) + // Check the filter of the slot to ensure a chosen mod fits + const parentSlotCompatibleItems = parentTemplate._props.Slots?.find((slot) => + slot._name.toLowerCase() === modSlot.toLowerCase() + )._props.filters[0].Filter; + + // Mod isnt in existing pool, only add if it has no children and matches parent filter + if ( + this.itemHelper.getItem(matchingMod._tpl)[1]._props.Slots.length === 0 + && parentSlotCompatibleItems.includes(matchingMod._tpl) + ) { - // Mod has no children + // Mod has no children and matches parent filters, can be used return [matchingMod._tpl]; } }