Fix tools not coming back with the right properties after crafting (!238)
This resolves an issue where FiR tools were coming back as non-FiR. We now just store the whole .upd property, so any stats on the tool should carry over to after the craft is finished Note: Will break any in-progress crafts that use tools Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/238 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
42782589e0
commit
0433308fa8
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user