Potential fix for failed/repeatable quests keeping their subtask completed status
This commit is contained in:
parent
19f6bbaed4
commit
12cb176a42
@ -107,17 +107,17 @@ export class InraidController
|
|||||||
*/
|
*/
|
||||||
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void
|
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void
|
||||||
{
|
{
|
||||||
const serveProfile = this.saveServer.getProfile(sessionID);
|
const serverProfile = this.saveServer.getProfile(sessionID);
|
||||||
const locationName = serveProfile.inraid.location.toLowerCase();
|
const locationName = serverProfile.inraid.location.toLowerCase();
|
||||||
|
|
||||||
const map: ILocationBase = this.databaseServer.getTables().locations[locationName].base;
|
const map: ILocationBase = this.databaseServer.getTables().locations[locationName].base;
|
||||||
const mapHasInsuranceEnabled = map.Insurance;
|
const mapHasInsuranceEnabled = map.Insurance;
|
||||||
|
|
||||||
let serverPmcProfile = serveProfile.characters.pmc;
|
let serverPmcProfile = serverProfile.characters.pmc;
|
||||||
const isDead = this.isPlayerDead(postRaidRequest.exit);
|
const isDead = this.isPlayerDead(postRaidRequest.exit);
|
||||||
const preRaidGear = this.inRaidHelper.getPlayerGear(serverPmcProfile.Inventory.items);
|
const preRaidGear = this.inRaidHelper.getPlayerGear(serverPmcProfile.Inventory.items);
|
||||||
|
|
||||||
serveProfile.inraid.character = "pmc";
|
serverProfile.inraid.character = "pmc";
|
||||||
|
|
||||||
this.inRaidHelper.updateProfileBaseStats(serverPmcProfile, postRaidRequest, sessionID);
|
this.inRaidHelper.updateProfileBaseStats(serverPmcProfile, postRaidRequest, sessionID);
|
||||||
this.inRaidHelper.updatePmcProfileDataPostRaid(serverPmcProfile, postRaidRequest, sessionID);
|
this.inRaidHelper.updatePmcProfileDataPostRaid(serverPmcProfile, postRaidRequest, sessionID);
|
||||||
@ -219,7 +219,7 @@ export class InraidController
|
|||||||
activeQuestIdsInProfile,
|
activeQuestIdsInProfile,
|
||||||
allQuests,
|
allQuests,
|
||||||
);
|
);
|
||||||
if (questAndFindItemConditionId)
|
if (Object.keys(questAndFindItemConditionId)?.length > 0)
|
||||||
{
|
{
|
||||||
this.profileHelper.removeCompletedQuestConditionFromProfile(pmcData, questAndFindItemConditionId);
|
this.profileHelper.removeCompletedQuestConditionFromProfile(pmcData, questAndFindItemConditionId);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ export class InRaidHelper
|
|||||||
public updatePmcProfileDataPostRaid(pmcData: IPmcData, saveProgressRequest: ISaveProgressRequestData, sessionId: string): void
|
public updatePmcProfileDataPostRaid(pmcData: IPmcData, saveProgressRequest: ISaveProgressRequestData, sessionId: string): void
|
||||||
{
|
{
|
||||||
// Process failed quests then copy everything
|
// Process failed quests then copy everything
|
||||||
this.processFailedQuests(sessionId, pmcData, pmcData.Quests, saveProgressRequest.profile.Quests);
|
this.processFailedQuests(sessionId, pmcData, pmcData.Quests, saveProgressRequest.profile);
|
||||||
pmcData.Quests = saveProgressRequest.profile.Quests;
|
pmcData.Quests = saveProgressRequest.profile.Quests;
|
||||||
|
|
||||||
// No need to do this for scav, old scav is deleted and new one generated
|
// No need to do this for scav, old scav is deleted and new one generated
|
||||||
@ -254,13 +254,13 @@ export class InRaidHelper
|
|||||||
* @param sessionId Player id
|
* @param sessionId Player id
|
||||||
* @param pmcData Player profile
|
* @param pmcData Player profile
|
||||||
* @param preRaidQuests Quests prior to starting raid
|
* @param preRaidQuests Quests prior to starting raid
|
||||||
* @param postRaidQuests Quest after raid
|
* @param postRaidProfile Profile sent by client
|
||||||
*/
|
*/
|
||||||
protected processFailedQuests(
|
protected processFailedQuests(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
preRaidQuests: IQuestStatus[],
|
preRaidQuests: IQuestStatus[],
|
||||||
postRaidQuests: IQuestStatus[],
|
postRaidProfile: IPostRaidPmcData,
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
if (!preRaidQuests)
|
if (!preRaidQuests)
|
||||||
@ -270,15 +270,30 @@ export class InRaidHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all quests from post-raid profile
|
// Loop over all quests from post-raid profile
|
||||||
for (const postRaidQuest of postRaidQuests)
|
for (const postRaidQuest of postRaidProfile.Quests)
|
||||||
{
|
{
|
||||||
// Find matching pre-raid quest
|
// Find matching pre-raid quest + not already failed
|
||||||
const preRaidQuest = preRaidQuests?.find((x) => x.qid === postRaidQuest.qid);
|
const preRaidQuest = preRaidQuests?.find((x) => x.qid === postRaidQuest.qid);
|
||||||
if (preRaidQuest)
|
if (!preRaidQuest)
|
||||||
{
|
{
|
||||||
// Post-raid quest is failed but wasn't pre-raid
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Already failed before raid, skip
|
||||||
|
if (preRaidQuest.status === QuestStatus.Fail)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preRaidQuest.status === QuestStatus.Success)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quest failed inside raid, need to handle
|
||||||
// postRaidQuest.status has a weird value, need to do some nasty casting to compare it
|
// postRaidQuest.status has a weird value, need to do some nasty casting to compare it
|
||||||
if (<string><unknown>postRaidQuest.status === "Fail" && preRaidQuest.status !== QuestStatus.Fail)
|
const postRaidQuestStatus = <string><unknown>postRaidQuest.status;
|
||||||
|
if (postRaidQuestStatus === "Fail")
|
||||||
{
|
{
|
||||||
// Send failed message
|
// Send failed message
|
||||||
const failBody: IFailQuestRequestData = {
|
const failBody: IFailQuestRequestData = {
|
||||||
@ -288,6 +303,48 @@ export class InRaidHelper
|
|||||||
};
|
};
|
||||||
this.questHelper.failQuest(pmcData, failBody, sessionId);
|
this.questHelper.failQuest(pmcData, failBody, sessionId);
|
||||||
}
|
}
|
||||||
|
// Restartable quests need special actions
|
||||||
|
else if (postRaidQuestStatus === "FailRestartable")
|
||||||
|
{
|
||||||
|
// Does failed quest have requirement to collect items from raid
|
||||||
|
const questDbData = this.questHelper.getQuestFromDb(postRaidQuest.qid, pmcData);
|
||||||
|
// AvailableForFinish
|
||||||
|
const matchingAffFindConditions = questDbData.conditions.AvailableForFinish.filter(x => x._parent === "FindItem");
|
||||||
|
const itemsToCollect: string[] = [];
|
||||||
|
if (matchingAffFindConditions)
|
||||||
|
{
|
||||||
|
// Find all items the failed quest wanted
|
||||||
|
for (const condition of matchingAffFindConditions)
|
||||||
|
{
|
||||||
|
itemsToCollect.push(...condition._props.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
postRaidProfile.Stats.Eft.CarriedQuestItems = postRaidProfile.Stats.Eft.CarriedQuestItems.filter(x => !itemsToCollect.includes(x))
|
||||||
|
|
||||||
|
// 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
|
||||||
|
for (const itemTpl of itemsToCollect)
|
||||||
|
{
|
||||||
|
// Look for sessioncounter and remove it
|
||||||
|
const counterIndex = postRaidProfile.Stats.Eft.SessionCounters.Items.findIndex(x => x.Key.includes(itemTpl) && x.Key.includes("LootItem"));
|
||||||
|
if (counterIndex > -1)
|
||||||
|
{
|
||||||
|
postRaidProfile.Stats.Eft.SessionCounters.Items.splice(counterIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for quest item and remove it
|
||||||
|
const inventoryItemIndex = postRaidProfile.Inventory.items.findIndex(x => x._tpl === itemTpl);
|
||||||
|
if (inventoryItemIndex > -1)
|
||||||
|
{
|
||||||
|
postRaidProfile.Inventory.items.splice(inventoryItemIndex, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear out any completed conditions
|
||||||
|
postRaidQuest.completedConditions = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -951,7 +951,7 @@ export class QuestHelper
|
|||||||
const questInDb = allQuests.find((x) => x._id === questId);
|
const questInDb = allQuests.find((x) => x._id === questId);
|
||||||
if (!questInDb)
|
if (!questInDb)
|
||||||
{
|
{
|
||||||
this.logger.warning(
|
this.logger.debug(
|
||||||
`Unable to find quest: ${questId} in db, cannot get 'FindItem' condition, skipping`,
|
`Unable to find quest: ${questId} in db, cannot get 'FindItem' condition, skipping`,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user