mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 06:10:44 -05:00
Fixed prestiges not being persisted to profile
This commit is contained in:
parent
6ae0517ca3
commit
f4180993cb
@ -3,8 +3,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_standard",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -2701,8 +2701,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -5595,8 +5595,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_leftbehind",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -8852,8 +8852,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -12213,8 +12213,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_preparetoescape",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -15928,8 +15928,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -19846,8 +19846,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile-edgeofdarkness",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -23612,8 +23612,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -27509,8 +27509,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile-unheard",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -32014,8 +32014,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -36740,8 +36740,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile-tournament",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -37729,8 +37729,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -38719,8 +38719,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_sptdeveloper",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -41870,8 +41870,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -45008,8 +45008,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_spteasystart",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -48427,8 +48427,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -51849,8 +51849,8 @@
|
||||
"descriptionLocaleKey": "launcher-profile_sptzerotohero",
|
||||
"bear": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
@ -52828,8 +52828,8 @@
|
||||
},
|
||||
"usec": {
|
||||
"character": {
|
||||
"Achievements": [],
|
||||
"Prestige": [],
|
||||
"Achievements": {},
|
||||
"Prestige": {},
|
||||
"TaskConditionCounters": {},
|
||||
"Bonuses": [{
|
||||
"id": "64f5b9e5fa34f11b380756c0",
|
||||
|
@ -22,8 +22,12 @@ export class PrestigeCallbacks {
|
||||
}
|
||||
|
||||
/** Handle client/prestige/obtain */
|
||||
public obtainPrestige(url: string, info: IObtainPrestigeRequest[], sessionID: string): INullResponseData {
|
||||
this.prestigeController.obtainPrestige(sessionID, info);
|
||||
public async obtainPrestige(
|
||||
url: string,
|
||||
info: IObtainPrestigeRequest[],
|
||||
sessionID: string,
|
||||
): Promise<INullResponseData> {
|
||||
await this.prestigeController.obtainPrestige(sessionID, info);
|
||||
|
||||
return this.httpResponse.nullResponse();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ export class PrestigeController {
|
||||
/**
|
||||
* Handle /client/prestige/obtain
|
||||
*/
|
||||
public obtainPrestige(sessionId: string, request: IObtainPrestigeRequest[]): void {
|
||||
public async obtainPrestige(sessionId: string, request: IObtainPrestigeRequest[]): Promise<void> {
|
||||
const prePrestigeProfileClone = this.cloner.clone(this.profileHelper.getFullProfile(sessionId));
|
||||
const prePrestigePmc = prePrestigeProfileClone.characters.pmc;
|
||||
const createRequest: IProfileCreateRequestData = {
|
||||
@ -73,14 +73,19 @@ export class PrestigeController {
|
||||
voiceId: Object.values(this.databaseService.getTemplates().customization).find(
|
||||
(customisation) => customisation._name === prePrestigePmc.Info.Voice,
|
||||
)._id,
|
||||
sptForcePrestigeLevel: prePrestigeProfileClone.characters.pmc.Info.PrestigeLevel + 1, // Current + 1
|
||||
sptForcePrestigeLevel: prePrestigeProfileClone.characters.pmc.Info.PrestigeLevel + 1, // Current + 1,
|
||||
};
|
||||
|
||||
// Reset profile
|
||||
this.createProfileService.createProfile(sessionId, createRequest);
|
||||
await this.createProfileService.createProfile(sessionId, createRequest);
|
||||
|
||||
// Get freshly reset profile ready for editing
|
||||
const newProfile = this.profileHelper.getFullProfile(sessionId);
|
||||
if (!newProfile) {
|
||||
this.logger.error(`Unable to create get new profile for: ${sessionId}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Skill copy
|
||||
const commonSKillsToCopy = prePrestigePmc.Skills.Common;
|
||||
@ -109,18 +114,29 @@ export class PrestigeController {
|
||||
}
|
||||
}
|
||||
|
||||
const indexToGet = Math.min(createRequest.sptForcePrestigeLevel - 1, 1); // Index starts at 0
|
||||
const rewards = this.databaseService.getTemplates().prestige.elements[indexToGet].rewards;
|
||||
this.addPrestigeRewardsToProfile(sessionId, newProfile, rewards);
|
||||
const indexOfPrestigeObtained = Math.min(createRequest.sptForcePrestigeLevel - 1, 1); // Index starts at 0
|
||||
// Assumes Prestige data is in descending order
|
||||
const matchingPrestigeData = this.databaseService.getTemplates().prestige.elements[indexOfPrestigeObtained];
|
||||
|
||||
this.addPrestigeRewardsToProfile(sessionId, newProfile, matchingPrestigeData.rewards);
|
||||
|
||||
// Flag profile as having achieved this prestige level
|
||||
newProfile.characters.pmc.Prestige[matchingPrestigeData.id] = this.timeUtil.getTimestamp();
|
||||
|
||||
// Copy transferred items
|
||||
for (const transferRequest of request) {
|
||||
const item = prePrestigePmc.Inventory.items.find((item) => item._id === transferRequest.id);
|
||||
if (!item) {
|
||||
this.logger.error(
|
||||
`Unable to find item with id: ${transferRequest.id} in profile: ${sessionId}, skipping`,
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
const addItemRequest: IAddItemDirectRequest = {
|
||||
itemWithModsToAdd: [item],
|
||||
foundInRaid: item.upd?.SpawnedInSession,
|
||||
foundInRaid: item.upd?.SpawnedInSession ?? false,
|
||||
useSortingTable: false,
|
||||
callback: null,
|
||||
};
|
||||
this.inventoryHelper.addItemToStash(
|
||||
sessionId,
|
||||
@ -134,6 +150,9 @@ export class PrestigeController {
|
||||
if (!newProfile.achievements["676091c0f457869a94017a23"]) {
|
||||
newProfile.achievements["676091c0f457869a94017a23"] = this.timeUtil.getTimestamp();
|
||||
}
|
||||
|
||||
// Force save of above changes to disk
|
||||
await this.saveServer.saveProfile(sessionId);
|
||||
}
|
||||
|
||||
protected addPrestigeRewardsToProfile(sessionId: string, newProfile: ISptProfile, rewards: IReward[]) {
|
||||
|
@ -161,7 +161,8 @@ export class InventoryHelper {
|
||||
pmcData.Inventory.items.push(...itemWithModsToAddClone);
|
||||
|
||||
this.logger.debug(
|
||||
`Added ${itemWithModsToAddClone[0].upd?.StackObjectsCount ?? 1} item: ${itemWithModsToAddClone[0]._tpl
|
||||
`Added ${itemWithModsToAddClone[0].upd?.StackObjectsCount ?? 1} item: ${
|
||||
itemWithModsToAddClone[0]._tpl
|
||||
} with: ${itemWithModsToAddClone.length - 1} mods to inventory`,
|
||||
);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ export interface IBotBase {
|
||||
RagfairInfo: IRagfairInfo;
|
||||
/** Achievement id and timestamp */
|
||||
Achievements: Record<string, number>;
|
||||
Prestige: Record<string, number>;
|
||||
RepeatableQuests: IPmcDataRepeatableQuest[];
|
||||
Bonuses: IBonus[];
|
||||
Notes: INotes;
|
||||
|
@ -4,6 +4,6 @@ export interface IAddItemDirectRequest {
|
||||
/** Item and child mods to add to player inventory */
|
||||
itemWithModsToAdd: IItem[];
|
||||
foundInRaid: boolean;
|
||||
callback: (buyCount: number) => void;
|
||||
callback?: (buyCount: number) => void;
|
||||
useSortingTable: boolean;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export class PrestigeStaticRouter extends StaticRouter {
|
||||
new RouteAction(
|
||||
"/client/prestige/obtain",
|
||||
async (url: string, info: any, sessionID: string, _output: string): Promise<INullResponseData> => {
|
||||
return this.prestigeCallbacks.obtainPrestige(url, info, sessionID);
|
||||
return await this.prestigeCallbacks.obtainPrestige(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user