Skip to content

Commit

Permalink
Added function addMissingInternalContainersToProfile that runs on p…
Browse files Browse the repository at this point in the history
…rofile creation
  • Loading branch information
Chomp committed Dec 30, 2024
1 parent 43a0950 commit d1d2adc
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions project/src/controllers/ProfileController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ISearchFriendRequestData } from "@spt/models/eft/profile/ISearchFriendR
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
import { IInraid, ISptProfile, IVitality } from "@spt/models/eft/profile/ISptProfile";
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
import { ItemTpl } from "@spt/models/enums/ItemTpl";
import { MessageType } from "@spt/models/enums/MessageType";
import { QuestStatus } from "@spt/models/enums/QuestStatus";
import { ILogger } from "@spt/models/spt/utils/ILogger";
Expand Down Expand Up @@ -160,6 +161,9 @@ export class ProfileController {
pmcData.UnlockedInfo = { unlockedProductionRecipe: [] };
}

// Add required items to pmc stash
this.addMissingInternalContainersToProfile(pmcData);

// Change item IDs to be unique
pmcData.Inventory.items = this.itemHelper.replaceIDs(
pmcData.Inventory.items,
Expand Down Expand Up @@ -243,6 +247,41 @@ export class ProfileController {
}
}

/**
* Ensure a profile has the necessary internal containers e.g. questRaidItems / sortingTable
* DOES NOT check that stash exists
* @param pmcData Profile to check
*/
protected addMissingInternalContainersToProfile(pmcData: IPmcData): void {
if (!pmcData.Inventory.items.find((item) => item._id === pmcData.Inventory.hideoutCustomizationStashId)) {
pmcData.Inventory.items.push({
_id: pmcData.Inventory.hideoutCustomizationStashId,
_tpl: ItemTpl.HIDEOUTAREACONTAINER_CUSTOMIZATION,
});
}

if (!pmcData.Inventory.items.find((item) => item._id === pmcData.Inventory.sortingTable)) {
pmcData.Inventory.items.push({
_id: pmcData.Inventory.sortingTable,
_tpl: ItemTpl.SORTINGTABLE_SORTING_TABLE,
});
}

if (!pmcData.Inventory.items.find((item) => item._id === pmcData.Inventory.questStashItems)) {
pmcData.Inventory.items.push({
_id: pmcData.Inventory.questStashItems,
_tpl: ItemTpl.STASH_QUESTOFFLINE,
});
}

if (!pmcData.Inventory.items.find((item) => item._id === pmcData.Inventory.questRaidItems)) {
pmcData.Inventory.items.push({
_id: pmcData.Inventory.questRaidItems,
_tpl: ItemTpl.STASH_QUESTRAID,
});
}
}

/**
* Delete a profile
* @param sessionID Id of profile to delete
Expand Down

0 comments on commit d1d2adc

Please sign in to comment.