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)
|
for (const tool of production.sptRequiredTools)
|
||||||
{
|
{
|
||||||
const toolToAdd: Item = {
|
toolsToSendToPlayer.push([tool]);
|
||||||
_id: this.hashUtil.generate(),
|
|
||||||
_tpl: tool,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.itemHelper.isItemTplStackable(tool))
|
|
||||||
{
|
|
||||||
toolToAdd.upd = {
|
|
||||||
StackObjectsCount: 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toolsToSendToPlayer.push([toolToAdd]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,17 +951,22 @@ export class HideoutController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the used tools to the stash as non-FiR
|
// Add the tools to the stash, we have to do this individually due to FiR state potentially being different
|
||||||
const addToolsRequest: IAddItemsDirectRequest = {
|
for (const toolItem of toolsToSendToPlayer)
|
||||||
itemsWithModsToAdd: toolsToSendToPlayer,
|
|
||||||
foundInRaid: false,
|
|
||||||
useSortingTable: false,
|
|
||||||
callback: null,
|
|
||||||
};
|
|
||||||
this.inventoryHelper.addItemsToStash(sessionID, addToolsRequest, pmcData, output);
|
|
||||||
if (output.warnings.length > 0)
|
|
||||||
{
|
{
|
||||||
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
|
// 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 { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||||
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
||||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||||
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class HideoutHelper
|
export class HideoutHelper
|
||||||
@ -53,6 +54,7 @@ export class HideoutHelper
|
|||||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||||
|
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.hideoutConfig = this.configServer.getConfig(ConfigTypes.HIDEOUT);
|
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
|
// 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);
|
const bodyAsSingle = body as IHideoutSingleProductionStartRequestData;
|
||||||
if (productionTools.length > 0)
|
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;
|
pmcData.Hideout.Production[body.recipeId] = production;
|
||||||
|
@ -393,8 +393,8 @@ export interface Productive
|
|||||||
sptIsComplete?: boolean;
|
sptIsComplete?: boolean;
|
||||||
/** Is the craft a Continuous, e.g bitcoins/water collector */
|
/** Is the craft a Continuous, e.g bitcoins/water collector */
|
||||||
sptIsContinuous?: boolean;
|
sptIsContinuous?: boolean;
|
||||||
/** Stores a list of tools used in this craft, to give back once the craft is done */
|
/** Stores a list of tools used in this craft and whether they're FiR, to give back once the craft is done */
|
||||||
sptRequiredTools?: string[];
|
sptRequiredTools?: Item[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Production extends Productive
|
export interface Production extends Productive
|
||||||
|
Loading…
Reference in New Issue
Block a user