From 72fdada5d7691d87e38be1a7226595d6f18381ce Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 13 Jan 2024 20:47:59 +0000 Subject: [PATCH] Add vistor shot damage to those listed on flea/fence - 25% chance a damaged helmet can have a visor with bullet hits Improved `FenceService.addModsToArmorModSlots()` to not break when it cant find a default plate tpl --- .../src/generators/RagfairOfferGenerator.ts | 17 ++++++++++++- project/src/services/FenceService.ts | 25 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index 5442b790..b0932eea 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -589,13 +589,28 @@ export class RagfairOfferGenerator if (this.itemHelper.armorItemCanHoldMods(rootItem._tpl)) { // Chance to not adjust armor - if (!this.randomUtil.getChance100(this.ragfairConfig.dynamic.condition[BaseClasses.ARMORED_EQUIPMENT])) + if (!this.randomUtil.getChance100(this.ragfairConfig.dynamic.condition[BaseClasses.ARMORED_EQUIPMENT].conditionChance * 100)) { return; } this.randomiseArmorDurabilityValues(itemWithMods); + // Add hits to visor + const visorMod = itemWithMods.find(item => item.parentId === BaseClasses.ARMORED_EQUIPMENT && item.slotId === "mod_equipment_000"); + if (this.randomUtil.getChance100(25) + && visorMod) + { + if (!visorMod.upd) + { + visorMod.upd = {}; + } + + visorMod.upd.FaceShield = { + Hits: this.randomUtil.getInt(1,3) + } + } + return; } diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index cfc5b74b..b96e0932 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -516,9 +516,16 @@ export class FenceService { const modItemDbDetails = this.itemHelper.getItem(requiredSlot._props.filters[0].Plate)[1]; const durabilityValues = this.getRandomisedArmorDurabilityValues(modItemDbDetails, this.traderConfig.fence.armorMaxDurabilityPercentMinMax); - armor.push({ + const plateTpl = requiredSlot._props.filters[0].Plate; // `Plate` property appears to be the 'default' item for slot + if (plateTpl === "") + { + // Some bsg plate properties are empty, skip mod + continue; + } + + const mod: Item = { _id: this.hashUtil.generate(), - _tpl: requiredSlot._props.filters[0].Plate, // `Plate` property appears to be the 'default' item for slot + _tpl: plateTpl, parentId: armor[0]._id, slotId: requiredSlot._name, upd: { @@ -527,7 +534,19 @@ export class FenceService MaxDurability: durabilityValues.MaxDurability } } - }); + }; + + // 25% chance to add shots to visor when its below max durability + if (this.randomUtil.getChance100(25) + && mod.parentId === BaseClasses.ARMORED_EQUIPMENT && mod.slotId === "mod_equipment_000" + && mod.upd.Repairable.Durability < modItemDbDetails._props.MaxDurability) + { + mod.upd.FaceShield = { + Hits: this.randomUtil.getInt(1,3) + } + } + + armor.push(mod); } }