diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index 4f8679d9..e3d2c225 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -920,19 +920,7 @@ export class HideoutController { for (const tool of production.sptRequiredTools) { - const toolToAdd: Item = { - _id: this.hashUtil.generate(), - _tpl: tool, - }; - - if (this.itemHelper.isItemTplStackable(tool)) - { - toolToAdd.upd = { - StackObjectsCount: 1, - } - } - - toolsToSendToPlayer.push([toolToAdd]); + toolsToSendToPlayer.push([tool]); } } @@ -963,17 +951,22 @@ export class HideoutController return; } - // Add the used tools to the stash as non-FiR - const addToolsRequest: IAddItemsDirectRequest = { - itemsWithModsToAdd: toolsToSendToPlayer, - foundInRaid: false, - useSortingTable: false, - callback: null, - }; - this.inventoryHelper.addItemsToStash(sessionID, addToolsRequest, pmcData, output); - if (output.warnings.length > 0) + // Add the tools to the stash, we have to do this individually due to FiR state potentially being different + for (const toolItem of toolsToSendToPlayer) { - return; + // Note: FIR state will be based on the first item's SpawnedInSession property per item group + const addToolsRequest: IAddItemsDirectRequest = { + itemsWithModsToAdd: [toolItem], + foundInRaid: toolItem[0].upd?.SpawnedInSession ?? false, + useSortingTable: false, + callback: null, + }; + + this.inventoryHelper.addItemsToStash(sessionID, addToolsRequest, pmcData, output); + if (output.warnings.length > 0) + { + return; + } } // Add the crafting result to the stash, marked as FiR diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index a9da0695..559f873f 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -27,6 +27,7 @@ import { PlayerService } from "@spt-aki/services/PlayerService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; @injectable() export class HideoutHelper @@ -53,6 +54,7 @@ export class HideoutHelper @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ItemHelper") protected itemHelper: ItemHelper, @inject("ConfigServer") protected configServer: ConfigServer, + @inject("JsonUtil") protected jsonUtil: JsonUtil, ) { this.hideoutConfig = this.configServer.getConfig(ConfigTypes.HIDEOUT); @@ -102,10 +104,28 @@ export class HideoutHelper ); // Store the tools used for this production, so we can return them later - const productionTools = recipe.requirements.filter(req => req.type === "Tool").map(req => req.templateId); - if (productionTools.length > 0) + const bodyAsSingle = body as IHideoutSingleProductionStartRequestData; + if (bodyAsSingle && bodyAsSingle.tools.length > 0) { - production.sptRequiredTools = productionTools; + production.sptRequiredTools = []; + + for (const tool of bodyAsSingle.tools) + { + const toolItem = this.jsonUtil.clone(pmcData.Inventory.items.find(x => x._id === tool.id)); + + // Make sure we only return as many as we took + if (!toolItem.upd) + { + toolItem.upd = {}; + } + toolItem.upd.StackObjectsCount = tool.count; + + production.sptRequiredTools.push({ + _id: this.hashUtil.generate(), + _tpl: toolItem._tpl, + upd: toolItem.upd + }); + } } pmcData.Hideout.Production[body.recipeId] = production; diff --git a/project/src/models/eft/common/tables/IBotBase.ts b/project/src/models/eft/common/tables/IBotBase.ts index 16627b6a..f308346f 100644 --- a/project/src/models/eft/common/tables/IBotBase.ts +++ b/project/src/models/eft/common/tables/IBotBase.ts @@ -393,8 +393,8 @@ export interface Productive sptIsComplete?: boolean; /** Is the craft a Continuous, e.g bitcoins/water collector */ sptIsContinuous?: boolean; - /** Stores a list of tools used in this craft, to give back once the craft is done */ - sptRequiredTools?: string[]; + /** Stores a list of tools used in this craft and whether they're FiR, to give back once the craft is done */ + sptRequiredTools?: Item[]; } export interface Production extends Productive