Skip to content

Commit

Permalink
Fixed scav repeatable quest progress not persisting after raid
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomp committed Jan 7, 2025
1 parent 2e1e13e commit 145551c
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions project/src/services/LocationLifecycleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ export class LocationLifecycleService {
// Copy scav fence values to PMC profile
pmcProfile.TradersInfo[Traders.FENCE] = scavProfile.TradersInfo[Traders.FENCE];

if (this.profileHasConditionCounters(scavProfile)) {
// Scav quest progress needs to be moved to pmc so player can see it in menu / hand them in
this.migrateScavQuestProgressToPmcProfile(scavProfile, pmcProfile);
}

// Must occur after encyclopedia updated
this.mergePmcAndScavEncyclopedias(scavProfile, pmcProfile);

Expand Down Expand Up @@ -1122,4 +1127,56 @@ export class LocationLifecycleService {
primary.Encyclopedia = merged;
secondary.Encyclopedia = merged;
}

/**
* Does provided profile contain any condition counters
* @param profile Profile to check for condition counters
* @returns Profile has condition counters
*/
protected profileHasConditionCounters(profile: IPmcData): boolean {
if (!profile.TaskConditionCounters) {
return false;
}

return Object.keys(profile.TaskConditionCounters).length > 0;
}

/**
* Scav quest progress isnt transferred automatically from scav to pmc, we do this manually
* @param scavProfile Scav profile with quest progress post-raid
* @param pmcProfile Server pmc profile to copy scav quest progress into
*/
protected migrateScavQuestProgressToPmcProfile(scavProfile: IPmcData, pmcProfile: IPmcData): void {
for (const scavQuest of scavProfile.Quests) {
const pmcQuest = pmcProfile.Quests.find((quest) => quest.qid === scavQuest.qid);
if (!pmcQuest) {
this.logger.warning(
this.localisationService.getText(
"inraid-unable_to_migrate_pmc_quest_not_found_in_profile",
scavQuest.qid,
),
);
continue;
}

// Get counters related to scav quest
const matchingCounters = Object.values(scavProfile.TaskConditionCounters).filter(
(counter) => counter.sourceId === scavQuest.qid,
);

if (!matchingCounters) {
continue;
}

// insert scav quest counters into pmc profile
for (const counter of matchingCounters) {
pmcProfile.TaskConditionCounters[counter.id] = counter;
}

// Find Matching PMC Quest
// Update Status and StatusTimer properties
pmcQuest.status = scavQuest.status;
pmcQuest.statusTimers = scavQuest.statusTimers;
}
}
}

0 comments on commit 145551c

Please sign in to comment.