diff --git a/project/assets/configs/insurance.json b/project/assets/configs/insurance.json index 145aaa34..863009c9 100644 --- a/project/assets/configs/insurance.json +++ b/project/assets/configs/insurance.json @@ -1,8 +1,4 @@ { - "insuranceMultiplier": { - "54cb50c76803fa8b248b4571": 0.16, - "54cb57776803fa99248b456e": 0.25 - }, "returnChancePercent": { "54cb50c76803fa8b248b4571": 75, "54cb57776803fa99248b456e": 85 diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index 5329e505..8b68dd54 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -681,7 +681,9 @@ export class InsuranceController { itemsToPay.push({ id: this.roubleTpl, // TODO: update to handle different currencies - count: Math.round(this.insuranceService.getPremium(pmcData, inventoryItemsHash[key], body.tid)), + count: this.insuranceService.getRoublePriceToInsureItemWithTrader( + pmcData, inventoryItemsHash[key], + body.tid), }); } @@ -745,9 +747,9 @@ export class InsuranceController this.logger.debug(`Item with id: ${itemId} missing from player inventory, skipping`); continue; } - items[inventoryItemsHash[itemId]._tpl] = Math.round( - this.insuranceService.getPremium(pmcData, inventoryItemsHash[itemId], trader), - ); + items[inventoryItemsHash[itemId]._tpl] = this.insuranceService.getRoublePriceToInsureItemWithTrader( + pmcData, inventoryItemsHash[itemId], + trader); } response[trader] = items; diff --git a/project/src/models/spt/config/IInsuranceConfig.ts b/project/src/models/spt/config/IInsuranceConfig.ts index 05370b7b..a6259ecf 100644 --- a/project/src/models/spt/config/IInsuranceConfig.ts +++ b/project/src/models/spt/config/IInsuranceConfig.ts @@ -3,8 +3,6 @@ import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig"; export interface IInsuranceConfig extends IBaseConfig { kind: "spt-insurance" - /** Insurance price multiplier */ - insuranceMultiplier: Record /** Chance item is returned as insurance, keyed by trader id */ returnChancePercent: Record /** Item slots that should never be returned as insurance */ diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index 764d44f4..76aa789a 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -517,33 +517,18 @@ export class InsuranceService * @param traderId Trader item is insured with * @returns price in roubles */ - public getPremium(pmcData: IPmcData, inventoryItem: Item, traderId: string): number + public getRoublePriceToInsureItemWithTrader(pmcData: IPmcData, inventoryItem: Item, traderId: string): number { - let insuranceMultiplier = this.insuranceConfig.insuranceMultiplier[traderId]; - if (!insuranceMultiplier) - { - insuranceMultiplier = 0.3; - this.logger.warning( - this.localisationService.getText("insurance-missing_insurance_price_multiplier", traderId), - ); - } + const price = this.itemHelper.getStaticItemPrice(inventoryItem._tpl) + * (this.traderHelper.getLoyaltyLevel(traderId, pmcData).insurance_price_coef / 100); - // Multiply item handbook price by multiplier in config to get the new insurance price - let pricePremium = this.itemHelper.getStaticItemPrice(inventoryItem._tpl) * insuranceMultiplier; - const coef = this.traderHelper.getLoyaltyLevel(traderId, pmcData).insurance_price_coef; - - if (coef > 0) - { - pricePremium *= 1 - this.traderHelper.getLoyaltyLevel(traderId, pmcData).insurance_price_coef / 100; - } - - return Math.round(pricePremium); + return Math.ceil(price); } /** * Returns the ID that should be used for a root-level Item's parentId property value within in the context of insurance. - * - * @returns The ID. + * @param sessionID Players id + * @returns The root item Id. */ public getRootItemParentID(sessionID: string): string {