diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 2e148edd..646159a2 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -344,7 +344,7 @@ export class BotLootGenerator this.randomiseAmmoStackSize(isPmc, itemToAddTemplate, itemsToAdd[0]); } // Must add soft inserts/plates - else if (this.itemHelper.isOfBaseclasses(itemToAddTemplate._id, [BaseClasses.ARMOR, BaseClasses.HEADWEAR, BaseClasses.VEST])) + else if (this.itemHelper.itemCanRequireArmorInserts(itemToAddTemplate._id)) { itemsToAdd = this.itemHelper.addChildSlotItems(itemsToAdd, itemToAddTemplate, null, true); } diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 1414cbc1..fd223ec6 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -861,7 +861,7 @@ export class LocationGenerator ); itemWithMods.push(...magazineItem); } - else if (this.itemHelper.isOfBaseclasses(chosenTpl, [BaseClasses.VEST, BaseClasses.ARMOR, BaseClasses.HEADWEAR])) + else if (this.itemHelper.itemCanRequireArmorInserts(chosenTpl)) { itemWithMods.push({ _id: this.objectId.generate(), @@ -1071,7 +1071,7 @@ export class LocationGenerator // Replace existing magazine with above array items.splice(items.indexOf(items[0]), 1, ...magazineWithCartridges); } - else if (this.itemHelper.isOfBaseclasses(chosenTpl, [BaseClasses.VEST, BaseClasses.ARMOR, BaseClasses.HEADWEAR])) + else if (this.itemHelper.itemCanRequireArmorInserts(chosenTpl)) { if (itemTemplate._props.Slots?.length > 0) { diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 6794fdf4..a78424cd 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -98,6 +98,18 @@ export class ItemHelper return this.itemBaseClassService.itemHasBaseClass(tpl, baseClassTpls); } + /** + * Does the provided item have the chance to require soft armor inserts + * Only applies to helmets/vest/armors. + * Not all head gear needs them + * @param itemTpl item to check + * @returns Does item have the possibility ot need soft inserts + */ + public itemCanRequireArmorInserts(itemTpl: string): boolean + { + return this.isOfBaseclasses(itemTpl, [BaseClasses.HEADWEAR, BaseClasses.VEST, BaseClasses.ARMOR]); + } + /** * Returns the item price based on the handbook or as a fallback from the prices.json if the item is not * found in the handbook. If the price can't be found at all return 0 diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 0939e2ec..64a059eb 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -14,6 +14,7 @@ import { IQuest, IQuestCondition, IQuestReward } from "@spt-aki/models/eft/commo import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; import { IAcceptQuestRequestData } from "@spt-aki/models/eft/quests/IAcceptQuestRequestData"; import { IFailQuestRequestData } from "@spt-aki/models/eft/quests/IFailQuestRequestData"; +import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { MessageType } from "@spt-aki/models/enums/MessageType"; import { QuestRewardType } from "@spt-aki/models/enums/QuestRewardType"; @@ -262,6 +263,15 @@ export class QuestHelper let rewardItems: Item[] = []; let targets: Item[] = []; const mods: Item[] = []; + const rootItem = questReward.items[0]; + + // Is armor item that needs inserts + if (questReward.items.length === 1 && this.itemHelper.itemCanRequireArmorInserts(rootItem._tpl)) + { + // Add required child mods only to the reward array before being processed below + const itemDbData = this.itemHelper.getItem(rootItem._tpl)[1]; + questReward.items = this.itemHelper.addChildSlotItems(questReward.items, itemDbData, null, true); + } for (const item of questReward.items) { @@ -273,7 +283,7 @@ export class QuestHelper item.upd.SpawnedInSession = true; - // separate base item and mods, fix stacks + // Separate base item and mods, fix stacks if (item._id === questReward.target) { if ( diff --git a/project/src/services/BotEquipmentModPoolService.ts b/project/src/services/BotEquipmentModPoolService.ts index c042c873..fa9dcfb0 100644 --- a/project/src/services/BotEquipmentModPoolService.ts +++ b/project/src/services/BotEquipmentModPoolService.ts @@ -201,7 +201,7 @@ export class BotEquipmentModPoolService protected generateGearPool(): void { const gear = Object.values(this.databaseServer.getTables().templates.items).filter((x) => - x._type === "Item" && this.itemHelper.isOfBaseclasses(x._id, [BaseClasses.ARMORED_EQUIPMENT, BaseClasses.VEST]) + x._type === "Item" && this.itemHelper.isOfBaseclasses(x._id, [BaseClasses.ARMORED_EQUIPMENT, BaseClasses.VEST, BaseClasses.ARMOR, BaseClasses.HEADWEAR]) ); this.generatePool(gear, "gear"); diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index 84a4cf5f..f39a63ac 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -481,7 +481,7 @@ export class FenceService rootItemToPush.upd.UnlimitedCount = false; // Need to add mods to armors so they dont show as red in the trade screen - if (this.itemHelper.isOfBaseclasses(rootItemToPush._tpl, [BaseClasses.HEADWEAR, BaseClasses.VEST, BaseClasses.ARMOR])) + if (this.itemHelper.itemCanRequireArmorInserts(rootItemToPush._tpl)) { this.addModsToArmorModSlots(itemsToPush, itemDbDetails); }