0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Added code to add hideout customisation unlocks to profile when quest completion rewards an achievement

Fixed inaccurate `rewards` type for achievement object
This commit is contained in:
Chomp 2025-01-07 13:06:28 +00:00
parent b0d3d68d01
commit 3e760e88e4
4 changed files with 43 additions and 8 deletions

View File

@ -235,7 +235,7 @@ export class CustomizationController {
return customisationResultsClone;
}
// Append on customisations unlocked by player to results
// Append customisations unlocked by player to results
customisationResultsClone.push(...(profile.customisationUnlocks ?? []));
return customisationResultsClone;

View File

@ -544,12 +544,47 @@ export class ProfileHelper {
}
/**
* Add an achievement to player profile
* @param pmcProfile Profile to add achievement to
* Add an achievement to player profile + check for and add any hideout customisation unlocks to profile
* @param fullProfile Profile to add achievement to
* @param achievementId Id of achievement to add
*/
public addAchievementToProfile(pmcProfile: IPmcData, achievementId: string): void {
pmcProfile.Achievements[achievementId] = this.timeUtil.getTimestamp();
public addAchievementToProfile(fullProfile: ISptProfile, achievementId: string): void {
// Add achievement id to profile with timestamp it was unlocked
fullProfile.characters.pmc.Achievements[achievementId] = this.timeUtil.getTimestamp();
// Check for any customisation unlocks
const achievementDataDb = this.databaseService
.getTemplates()
.achievements.find((achievement) => achievement.id === achievementId);
if (!achievementDataDb) {
return;
}
// Get customisation reward object from achievement db
const customizationDirectReward = achievementDataDb.rewards.find(
(reward) => reward.type === "CustomizationDirect",
);
if (!customizationDirectReward) {
return;
}
const customisationDataDb = this.databaseService
.getHideout()
.customisation.globals.find((customisation) => customisation.itemId === customizationDirectReward.target);
if (!customisationDataDb) {
this.logger.error(
`Unable to find customisation data for ${customizationDirectReward.target} in profile ${fullProfile.info.id}`,
);
return;
}
// Reward found, add to profile
fullProfile.customisationUnlocks.push({
id: customizationDirectReward.target,
source: "achievement",
type: customisationDataDb.type,
});
}
public hasAccessToRepeatableFreeRefreshSystem(pmcProfile: IPmcData): boolean {

View File

@ -979,7 +979,7 @@ export class QuestHelper {
// Handled by getAssort(), locked assorts are stripped out by `assortHelper.stripLockedLoyaltyAssort()` before being sent to player
break;
case QuestRewardType.ACHIEVEMENT:
this.profileHelper.addAchievementToProfile(pmcProfile, reward.target);
this.profileHelper.addAchievementToProfile(fullProfile, reward.target);
break;
case QuestRewardType.STASH_ROWS:
this.profileHelper.addStashRowsBonusToProfile(sessionId, Number.parseInt(<string>reward.value)); // Add specified stash rows from quest reward - requires client restart

View File

@ -1,10 +1,10 @@
import { IQuestConditionTypes, IQuestRewards } from "@spt/models/eft/common/tables/IQuest";
import { IQuestConditionTypes, IQuestReward } from "@spt/models/eft/common/tables/IQuest";
export interface IAchievement {
id: string;
imageUrl: string;
assetPath: string;
rewards: IQuestRewards;
rewards: IQuestReward[];
conditions: IQuestConditionTypes;
instantComplete: boolean;
showNotificationsInGame: boolean;