From ea0c37b179e1e7894ef5831dcdc87a3e139e09f7 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 15 Sep 2024 10:50:57 +0100 Subject: [PATCH] Renamed hideout config property `isPveInsurance` to `simulateItemsBeingTaken` and updated code accordingly --- project/assets/configs/insurance.json | 2 +- project/src/controllers/InsuranceController.ts | 15 +++++++++------ project/src/models/spt/config/IInsuranceConfig.ts | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/project/assets/configs/insurance.json b/project/assets/configs/insurance.json index 6384e2ff..f29ffd28 100644 --- a/project/assets/configs/insurance.json +++ b/project/assets/configs/insurance.json @@ -9,5 +9,5 @@ "runIntervalSeconds": 600, "minAttachmentRoublePriceToBeTaken": 2000, "chanceNoAttachmentsTakenPercent": 10, - "isPveInsurance": false + "simulateItemsBeingTaken": true } diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index e23799d7..c56fe214 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -128,15 +128,15 @@ export class InsuranceController { // Iterate over each of the insurance packages. for (const insured of insuranceDetails) { - const isPveInsurance = this.insuranceConfig.isPveInsurance; - if (!isPveInsurance) { - // Find items that should be deleted from the insured items. + const simulateItemsBeingTaken = this.insuranceConfig.simulateItemsBeingTaken; + if (simulateItemsBeingTaken) { + // Find items that could be taken by another player off the players body const itemsToDelete = this.findItemsToDelete(rootItemParentID, insured); // Actually remove them. this.removeItemsFromInsurance(insured, itemsToDelete); } - + // Ensure that all items have a valid parent. insured.items = this.itemHelper.adoptOrphanedItems(rootItemParentID, insured.items); @@ -659,14 +659,17 @@ export class InsuranceController { /** * Insure softinserts of Armor that has softinsert slots + * Allows armors to come back after being lost correctly * @param item Armor item to be insured * @param pmcData Player profile * @param body Insurance request data */ public insureSoftInserts(item: Item, pmcData: IPmcData, body: IInsureRequestData): void { const softInsertIds = this.itemHelper.getSoftInsertSlotIds(); - const softInsertSlots = pmcData.Inventory.items.filter((x) => x.parentId === item._id && softInsertIds.includes(x.slotId.toLowerCase())); - + const softInsertSlots = pmcData.Inventory.items.filter( + (item) => item.parentId === item._id && softInsertIds.includes(item.slotId.toLowerCase()), + ); + for (const softInsertSlot of softInsertSlots) { this.logger.debug(`SoftInsertSlots: ${softInsertSlot.slotId}`); pmcData.InsuredItems.push({ tid: body.tid, itemId: softInsertSlot._id }); diff --git a/project/src/models/spt/config/IInsuranceConfig.ts b/project/src/models/spt/config/IInsuranceConfig.ts index 246f511d..704207b2 100644 --- a/project/src/models/spt/config/IInsuranceConfig.ts +++ b/project/src/models/spt/config/IInsuranceConfig.ts @@ -16,5 +16,5 @@ export interface IInsuranceConfig extends IBaseConfig { minAttachmentRoublePriceToBeTaken: number; // Chance out of 100% no attachments from a parent are taken chanceNoAttachmentsTakenPercent: number; - isPveInsurance: boolean; + simulateItemsBeingTaken: boolean; }