From 3bf00a6f2787c4cd9546e346fa5d899ca6fe9a3f Mon Sep 17 00:00:00 2001 From: DenisZhamkin Date: Sun, 15 Sep 2024 09:45:37 +0000 Subject: [PATCH] Added the ability to enable insurance behavior as in live eft (!408) Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/408 Co-authored-by: DenisZhamkin Co-committed-by: DenisZhamkin --- project/assets/configs/insurance.json | 3 ++- project/src/controllers/InsuranceController.ts | 13 ++++++++----- project/src/models/spt/config/IInsuranceConfig.ts | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/project/assets/configs/insurance.json b/project/assets/configs/insurance.json index 757668ac..6384e2ff 100644 --- a/project/assets/configs/insurance.json +++ b/project/assets/configs/insurance.json @@ -8,5 +8,6 @@ "returnTimeOverrideSeconds": 0, "runIntervalSeconds": 600, "minAttachmentRoublePriceToBeTaken": 2000, - "chanceNoAttachmentsTakenPercent": 10 + "chanceNoAttachmentsTakenPercent": 10, + "isPveInsurance": false } diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index af88dc49..e23799d7 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -128,12 +128,15 @@ export class InsuranceController { // Iterate over each of the insurance packages. for (const insured of insuranceDetails) { - // Find items that should be deleted from the insured items. - const itemsToDelete = this.findItemsToDelete(rootItemParentID, insured); - - // Actually remove them. - this.removeItemsFromInsurance(insured, itemsToDelete); + const isPveInsurance = this.insuranceConfig.isPveInsurance; + if (!isPveInsurance) { + // Find items that should be deleted from the insured items. + 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); diff --git a/project/src/models/spt/config/IInsuranceConfig.ts b/project/src/models/spt/config/IInsuranceConfig.ts index a5ed5768..246f511d 100644 --- a/project/src/models/spt/config/IInsuranceConfig.ts +++ b/project/src/models/spt/config/IInsuranceConfig.ts @@ -16,4 +16,5 @@ export interface IInsuranceConfig extends IBaseConfig { minAttachmentRoublePriceToBeTaken: number; // Chance out of 100% no attachments from a parent are taken chanceNoAttachmentsTakenPercent: number; + isPveInsurance: boolean; }