From bd28cbca5776a3a033bfc9da4b6401f74e1a7879 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 30 Jun 2024 23:20:49 +0100 Subject: [PATCH] Feature, plates in armors listed by fence now have individual chances to be removed before listing based on plate protection level --- project/assets/configs/trader.json | 7 +++++- .../src/models/spt/config/ITraderConfig.ts | 3 ++- project/src/services/FenceService.ts | 25 +++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/project/assets/configs/trader.json b/project/assets/configs/trader.json index b57b94b6..24905f12 100644 --- a/project/assets/configs/trader.json +++ b/project/assets/configs/trader.json @@ -201,7 +201,12 @@ "max": 100 } }, - "chancePlateExistsInArmorPercent": 50, + "chancePlateExistsInArmorPercent": { + "3": 95, + "4": 75, + "5": 25, + "6": 10 + }, "armorMaxDurabilityPercentMinMax": { "current": { "min": 50, diff --git a/project/src/models/spt/config/ITraderConfig.ts b/project/src/models/spt/config/ITraderConfig.ts index de2e8756..8409ac58 100644 --- a/project/src/models/spt/config/ITraderConfig.ts +++ b/project/src/models/spt/config/ITraderConfig.ts @@ -33,7 +33,8 @@ export interface FenceConfig presetPriceMult: number armorMaxDurabilityPercentMinMax: IItemDurabilityCurrentMax weaponDurabilityPercentMinMax: IItemDurabilityCurrentMax - chancePlateExistsInArmorPercent: number + /** Keyed to plate protection level */ + chancePlateExistsInArmorPercent: Record /** Key: item tpl */ itemStackSizeOverrideMinMax: Record itemTypeLimits: Record diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index ad97df23..00be79c0 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -1220,6 +1220,7 @@ export class FenceService /** * Randomise the durability values of plate items in armor + * Has chance to remove plate * @param plateSlots Slots of items to randomise * @param armorItemAndMods Array of armor + inserts to get items from */ @@ -1227,23 +1228,27 @@ export class FenceService { for (const plateSlot of plateSlots!) { - // Chance to not add plate - if (!this.randomUtil.getChance100(this.traderConfig.fence.chancePlateExistsInArmorPercent)) - { - // Remove plate from armor - armorItemAndMods = armorItemAndMods - .filter((item) => item.slotId!.toLowerCase() !== plateSlot._name.toLowerCase()); - continue; - } - const plateTpl = plateSlot._props.filters[0].Plate; if (!plateTpl) { - // Bsg data lacks a default plate, skip adding mod + // Bsg data lacks a default plate, skip randomisng for this mod continue; } const modItemDbDetails = this.itemHelper.getItem(plateTpl)[1]; + + // Chance to remove plate + const plateExistsChance = this.traderConfig + .fence.chancePlateExistsInArmorPercent[modItemDbDetails._props?.armorClass ?? "3"]; + if (!this.randomUtil.getChance100(plateExistsChance)) + { + // Remove plate from armor + armorItemAndMods = armorItemAndMods + .filter((item) => item.slotId!.toLowerCase() !== plateSlot._name.toLowerCase()); + + continue; + } + const durabilityValues = this.getRandomisedArmorDurabilityValues( modItemDbDetails, this.traderConfig.fence.armorMaxDurabilityPercentMinMax,