From 0342a0c39c7aa9aef1f36409dcde0e80552452b8 Mon Sep 17 00:00:00 2001 From: crustyselenium Date: Tue, 27 Aug 2024 22:15:08 +0000 Subject: [PATCH] 3.10.0-DEV WIP: Fixes #771 - Quest items not appearing on the case of dying after collecting them. Fixes an issue with gulp v5 corrupting pngs. (!403) See #771 for discussion and bug report. Implementation deletes the specific task's completedCondition so as to allow the item to appear again. Gulp v5 has a known issue that corrupts pngs when copying or moving them, this turns off encoding for the copying assets part of the build task. Reference was [this stack post](https://stackoverflow.com/questions/78391263/copying-images-with-gulp-are-corrupted-damaged). Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/403 Co-authored-by: crustyselenium Co-committed-by: crustyselenium --- project/gulpfile.mjs | 4 +++- project/src/helpers/InRaidHelper.ts | 23 +++++++++++++++++++ .../src/services/LocationLifecycleService.ts | 6 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/project/gulpfile.mjs b/project/gulpfile.mjs index 845ca61b..3f024904 100644 --- a/project/gulpfile.mjs +++ b/project/gulpfile.mjs @@ -122,7 +122,9 @@ const updateBuildProperties = async () => { */ const copyAssets = () => gulp - .src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"]) + .src(["assets/**/*.json", "assets/**/*.json5", "assets/**/*.png", "assets/**/*.jpg", "assets/**/*.ico"], { + encoding: false, + }) .pipe(gulp.dest(dataDir)); /** diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index 4cf0d0d7..561d24c7 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -1,3 +1,4 @@ +import { QuestController } from "@spt/controllers/QuestController"; import { InventoryHelper } from "@spt/helpers/InventoryHelper"; import { ItemHelper } from "@spt/helpers/ItemHelper"; import { IPmcData } from "@spt/models/eft/common/IPmcData"; @@ -10,6 +11,8 @@ import { ConfigServer } from "@spt/servers/ConfigServer"; import { DatabaseService } from "@spt/services/DatabaseService"; import { ICloner } from "@spt/utils/cloners/ICloner"; import { inject, injectable } from "tsyringe"; +import { ProfileHelper } from "./ProfileHelper"; +import { QuestHelper } from "./QuestHelper"; @injectable() export class InRaidHelper { @@ -23,6 +26,9 @@ export class InRaidHelper { @inject("ConfigServer") protected configServer: ConfigServer, @inject("PrimaryCloner") protected cloner: ICloner, @inject("DatabaseService") protected databaseService: DatabaseService, + @inject("QuestController") protected questController: QuestController, + @inject("ProfileHelper") protected profileHelper: ProfileHelper, + @inject("QuestHelper") protected questHelper: QuestHelper, ) { this.lostOnDeathConfig = this.configServer.getConfig(ConfigTypes.LOST_ON_DEATH); this.inRaidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); @@ -149,6 +155,23 @@ export class InRaidHelper { } } + /** + * Deletes quest conditions from pickup tasks given a list of quest items being carried by a PMC. + * @param carriedQuestItems Items carried by PMC at death, usually gotten from "CarriedQuestItems" + * @param sessionId Current sessionId + * @param pmcProfile Pre-raid profile that is being handled with raid information + */ + public removePickupQuestConditions(carriedQuestItems: string[], sessionId: string, pmcProfile: IPmcData) { + if (carriedQuestItems && this.lostOnDeathConfig.questItems) { + const pmcQuests = this.questController.getClientQuests(sessionId); + const pmcQuestIds = pmcQuests.map((a) => a._id); + for (const item of carriedQuestItems) { + const failedQuestId = this.questHelper.getFindItemConditionByQuestItem(item, pmcQuestIds, pmcQuests); + this.profileHelper.removeQuestConditionFromProfile(pmcProfile, failedQuestId); + } + } + } + /** * Get an array of items from a profile that will be lost on death * @param pmcProfile Profile to get items from diff --git a/project/src/services/LocationLifecycleService.ts b/project/src/services/LocationLifecycleService.ts index aecb9bc3..bc82c1c6 100644 --- a/project/src/services/LocationLifecycleService.ts +++ b/project/src/services/LocationLifecycleService.ts @@ -472,6 +472,12 @@ export class LocationLifecycleService { this.healthHelper.updateProfileHealthPostRaid(pmcProfile, postRaidProfile.Health, sessionId, isDead); if (isDead) { + this.inRaidHelper.removePickupQuestConditions( + postRaidProfile.Stats.Eft.CarriedQuestItems, + sessionId, + pmcProfile, + ); + this.pmcChatResponseService.sendKillerResponse(sessionId, pmcProfile, postRaidProfile.Stats.Eft.Aggressor); this.inRaidHelper.deleteInventory(pmcProfile, sessionId);