Skip to content

Commit

Permalink
Add new achievement rewards to 3.10 profile (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchangelWTF authored Feb 15, 2025
1 parent c832784 commit f997688
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions project/src/controllers/GameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HideoutHelper } from "@spt/helpers/HideoutHelper";
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RewardHelper } from "@spt/helpers/RewardHelper";
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
import { IPmcData } from "@spt/models/eft/common/IPmcData";
Expand All @@ -14,6 +15,7 @@ import {
CustomisationType,
ICustomisationStorage,
} from "@spt/models/eft/common/tables/ICustomisationStorage";
import { IItem } from "@spt/models/eft/common/tables/IItem";
import { ICheckVersionResponse } from "@spt/models/eft/game/ICheckVersionResponse";
import { ICurrentGroupResponse } from "@spt/models/eft/game/ICurrentGroupResponse";
import { IGameConfigResponse } from "@spt/models/eft/game/IGameConfigResponse";
Expand All @@ -28,6 +30,7 @@ import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
import { BonusType } from "@spt/models/enums/BonusType";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { HideoutAreas } from "@spt/models/enums/HideoutAreas";
import { RewardType } from "@spt/models/enums/RewardType";
import { SkillTypes } from "@spt/models/enums/SkillTypes";
import { IBotConfig } from "@spt/models/spt/config/IBotConfig";
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
Expand Down Expand Up @@ -70,6 +73,7 @@ export class GameController {
@inject("PreSptModLoader") protected preSptModLoader: PreSptModLoader,
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
@inject("InventoryHelper") protected inventoryHelper: InventoryHelper,
@inject("RewardHelper") protected rewardHelper: RewardHelper,
@inject("RandomUtil") protected randomUtil: RandomUtil,
@inject("HideoutHelper") protected hideoutHelper: HideoutHelper,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
Expand Down Expand Up @@ -292,6 +296,33 @@ export class GameController {
clothingToRemove.push(clothing);
}
}

if (Object.keys(fullProfile.characters.pmc.Achievements).length > 0) {
const achievementsDb = this.databaseService.getTemplates().achievements;

for (const achievementId in fullProfile.characters.pmc.Achievements) {
let rewards = achievementsDb.find((achievementDb) => achievementDb.id === achievementId)?.rewards;

if (!rewards) {
continue;
}

// Only hand out the new hideout customization rewards.
rewards = rewards.filter(
(achievementReward) => achievementReward.type === RewardType.CUSTOMIZATION_DIRECT,
);

this.rewardHelper.applyRewards(
rewards,
CustomisationSource.ACHIEVEMENT,
fullProfile,
fullProfile.characters.pmc,
achievementId,
);
}
}

fullProfile.spt.version = `${this.profileHelper.getDefaultSptDataObject().version} (Migrated from 3.10)`;
}

if (fullProfile.characters.pmc.Info.Side === "Usec") {
Expand Down

0 comments on commit f997688

Please sign in to comment.