From 47fcff1338b25a8d4ffde3eb56238c23bcf7f700 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 22 Aug 2024 10:32:35 +0100 Subject: [PATCH] Added further work to circle of sacrifice area --- project/src/controllers/HideoutController.ts | 43 ++++++++++++++++--- project/src/helpers/HideoutHelper.ts | 14 ++++++ .../src/models/eft/common/tables/IBotBase.ts | 2 +- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index b5256bd2..b43557b3 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -32,6 +32,7 @@ import { BackendErrorCodes } from "@spt/models/enums/BackendErrorCodes"; import { BonusType } from "@spt/models/enums/BonusType"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; import { HideoutAreas } from "@spt/models/enums/HideoutAreas"; +import { ItemTpl } from "@spt/models/enums/ItemTpl"; import { SkillTypes } from "@spt/models/enums/SkillTypes"; import { IHideoutConfig } from "@spt/models/spt/config/IHideoutConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; @@ -1256,20 +1257,48 @@ export class HideoutController { pmcData: IPmcData, request: IHideoutCircleOfCultistProductionStartRequestData, ): IItemEventRouterResponse | PromiseLike { - // TODO - // Do we start a craft? + // Sparse, just has id, can get it via ItemTpl enum too + const cultistCraftData = this.databaseService.getHideout().production.scavRecipes[0]; + + const sacrificedItems: Item[] = this.getSacrificedItems(pmcData); + + const circleCraftId = ItemTpl.HIDEOUTAREACONTAINER_CIRCLEOFCULTISTS_STASH_1; + + this.hideoutHelper.registerCircleOfCultistProduction(sessionId, pmcData, circleCraftId, sacrificedItems); + + // What items can be rewarded by completion of craft + // TODO - how do we use this? maybe this is done in a later event? + const cultistStashDbItem = this.itemHelper.getItem(circleCraftId); + const rewardItemPool = cultistStashDbItem[1]._props.Grids[0]._props.filters[0].Filter; const output = this.eventOutputHolder.getOutput(sessionId); - // Get root items inside cultist grid and remove them from inventory + // TODO - is this necessary? + // Do the items remain in the sacrifice window for duration of craft? + // Remove sacrified items + // for (const rootItem of inventoryRootItemsInCultistGrid) { + // this.inventoryHelper.removeItem(pmcData, rootItem._id, sessionId, output); + // } + + return output; + } + + protected getSacrificedItems(pmcData: IPmcData): Item[] { + // Get root items that are in the cultist sacrifice window const inventoryRootItemsInCultistGrid = pmcData.Inventory.items.filter( (item) => item.slotId === "CircleOfCultistsGrid1", ); - for (const rootItem of inventoryRootItemsInCultistGrid) { - this.inventoryHelper.removeItem(pmcData, rootItem._id, sessionId, output); - } - return output; + // Get rootitem + its children + const sacrificedItems: Item[] = []; + for (const rootItem of inventoryRootItemsInCultistGrid) { + const rootItemWithChildren = this.itemHelper.findAndReturnChildrenAsItems( + pmcData.Inventory.items, + rootItem._id, + ); + sacrificedItems.push(...rootItemWithChildren); + } + return sacrificedItems; } /** diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index 3f11e40c..f98257e3 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -116,6 +116,20 @@ export class HideoutHelper { pmcData.Hideout.Production[body.recipeId] = production; } + public registerCircleOfCultistProduction( + sessionId: string, + pmcData: IPmcData, + recipeId: string, + sacrificedItems: Item[], + ): void { + // TODO: hard coded 12 hour craft + no fuel use, where can we get this data + const cultistProduction = this.initProduction(recipeId, 43200, false); + cultistProduction.GivenItemsInStart = sacrificedItems; + + // Add circle production to profile + pmcData.Hideout.Production[recipeId] = cultistProduction; + } + /** * This convenience function initializes new Production Object * with all the constants. diff --git a/project/src/models/eft/common/tables/IBotBase.ts b/project/src/models/eft/common/tables/IBotBase.ts index ab04b8ae..5ee18fe7 100644 --- a/project/src/models/eft/common/tables/IBotBase.ts +++ b/project/src/models/eft/common/tables/IBotBase.ts @@ -368,7 +368,7 @@ export interface Productive { SkipTime?: number; /** Seconds needed to fully craft */ ProductionTime?: number; - GivenItemsInStart?: string[]; + GivenItemsInStart?: Item[]; Interrupted?: boolean; Code?: string; Decoded?: boolean;