improve accuracy of daily quest system

Keep completed dailies inside "activeQuests" array until dailies are refreshed
Adjust post-raid quest handling to ensure previously completed/failed quests keep their original status
This commit is contained in:
Dev 2024-01-31 14:38:18 +00:00
parent a45cc3052e
commit 95dd27038d
3 changed files with 20 additions and 13 deletions

View File

@ -507,17 +507,12 @@ export class QuestController
// Inform client of quest changes // Inform client of quest changes
completeQuestResponse.profileChanges[sessionID].quests.push(...questDelta); completeQuestResponse.profileChanges[sessionID].quests.push(...questDelta);
// Check if it's a repeatable quest. If so, remove from Quests and repeatable.activeQuests list + move to repeatable.inactiveQuests // Check if it's a repeatable quest. If so, remove from Quests
for (const currentRepeatable of pmcData.RepeatableQuests) for (const currentRepeatable of pmcData.RepeatableQuests)
{ {
const repeatableQuest = currentRepeatable.activeQuests.find((x) => x._id === completedQuestId); const repeatableQuest = currentRepeatable.activeQuests.find((activeRepeatable) => activeRepeatable._id === completedQuestId);
if (repeatableQuest) if (repeatableQuest)
{ {
currentRepeatable.activeQuests = currentRepeatable.activeQuests.filter((x) =>
x._id !== completedQuestId
);
currentRepeatable.inactiveQuests.push(repeatableQuest);
// Need to remove redundant scav quest object as its no longer necessary, is tracked in pmc profile // Need to remove redundant scav quest object as its no longer necessary, is tracked in pmc profile
if (repeatableQuest.side === "Scav") if (repeatableQuest.side === "Scav")
{ {

View File

@ -84,7 +84,7 @@ export class RepeatableQuestController
* @param {string} _info Request from client * @param {string} _info Request from client
* @param {string} sessionID Player's session id * @param {string} sessionID Player's session id
* *
* @returns {array} array of "repeatableQuestObjects" as descibed above * @returns {array} Array of "repeatableQuestObjects" as descibed above
*/ */
public getClientRepeatableQuests(_info: IEmptyRequestData, sessionID: string): IPmcDataRepeatableQuest[] public getClientRepeatableQuests(_info: IEmptyRequestData, sessionID: string): IPmcDataRepeatableQuest[]
{ {

View File

@ -21,8 +21,8 @@ import { SaveServer } from "@spt-aki/servers/SaveServer";
import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { LocalisationService } from "@spt-aki/services/LocalisationService";
import { ProfileFixerService } from "@spt-aki/services/ProfileFixerService"; import { ProfileFixerService } from "@spt-aki/services/ProfileFixerService";
import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { JsonUtil } from "@spt-aki/utils/JsonUtil";
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil";
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
import { ProfileHelper } from "./ProfileHelper"; import { ProfileHelper } from "./ProfileHelper";
@injectable() @injectable()
@ -291,7 +291,7 @@ export class InRaidHelper
const postRaidQuestStatus = <string><unknown>postRaidQuest.status; const postRaidQuestStatus = <string><unknown>postRaidQuest.status;
// Find matching pre-raid quest // Find matching pre-raid quest
const preRaidQuest = preRaidQuests?.find((x) => x.qid === postRaidQuest.qid); const preRaidQuest = preRaidQuests?.find((preRaidQuest) => preRaidQuest.qid === postRaidQuest.qid);
if (!preRaidQuest) if (!preRaidQuest)
{ {
// Some traders gives locked quests (LightKeeper) due to time-gating // Some traders gives locked quests (LightKeeper) due to time-gating
@ -307,6 +307,18 @@ export class InRaidHelper
// Already completed/failed before raid, skip // Already completed/failed before raid, skip
if ([QuestStatus.Fail, QuestStatus.Success].includes(preRaidQuest.status) ) if ([QuestStatus.Fail, QuestStatus.Success].includes(preRaidQuest.status) )
{ {
// Daily quests get their status altered in-raid to "AvailableForStart",
// Copy pre-raid status to post raid data
if (preRaidQuest.status === QuestStatus.Success)
{
postRaidQuest.status = QuestStatus.Success;
}
if (preRaidQuest.status === QuestStatus.Fail)
{
postRaidQuest.status = QuestStatus.Fail;
}
continue; continue;
} }
@ -339,7 +351,7 @@ export class InRaidHelper
// Does failed quest have requirement to collect items from raid // Does failed quest have requirement to collect items from raid
const questDbData = this.questHelper.getQuestFromDb(postRaidQuest.qid, pmcData); const questDbData = this.questHelper.getQuestFromDb(postRaidQuest.qid, pmcData);
// AvailableForFinish // AvailableForFinish
const matchingAffFindConditions = questDbData.conditions.AvailableForFinish.filter(x => x.conditionType === "FindItem"); const matchingAffFindConditions = questDbData.conditions.AvailableForFinish.filter(condition => condition.conditionType === "FindItem");
const itemsToCollect: string[] = []; const itemsToCollect: string[] = [];
if (matchingAffFindConditions) if (matchingAffFindConditions)
{ {
@ -352,7 +364,7 @@ export class InRaidHelper
// Remove quest items from profile as quest has failed and may still be alive // Remove quest items from profile as quest has failed and may still be alive
// Required as restarting the quest from main menu does not remove value from CarriedQuestItems array // Required as restarting the quest from main menu does not remove value from CarriedQuestItems array
postRaidProfile.Stats.Eft.CarriedQuestItems = postRaidProfile.Stats.Eft.CarriedQuestItems.filter(x => !itemsToCollect.includes(x)) postRaidProfile.Stats.Eft.CarriedQuestItems = postRaidProfile.Stats.Eft.CarriedQuestItems.filter(carriedQuestItem => !itemsToCollect.includes(carriedQuestItem))
// Remove quest item from profile now quest is failed // Remove quest item from profile now quest is failed
// updateProfileBaseStats() has already passed by ref EFT.Stats, all changes applied to postRaid profile also apply to server profile // updateProfileBaseStats() has already passed by ref EFT.Stats, all changes applied to postRaid profile also apply to server profile