From a87129c54101dd9b1eed0296a452db9083bf4778 Mon Sep 17 00:00:00 2001 From: r2go Date: Sat, 13 Jan 2024 09:03:51 +0000 Subject: [PATCH] #284 fixed flea armors not having random values (!193) https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/284 Probably needs some balancing since some armors are very random, some are not at all. It feels pretty realistic I think. Any feedback is appriciated. Co-authored-by: r2go-beep Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/193 Co-authored-by: r2go Co-committed-by: r2go --- .../src/generators/RagfairOfferGenerator.ts | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index d09ea9a8..87d72da8 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -672,36 +672,38 @@ export class RagfairOfferGenerator protected randomiseArmorDurabilityValues(armorWithMods: Item[]): void { - const childMultiplerValues = {}; - - for (const item of armorWithMods) - { - const itemDbDetails = this.itemHelper.getItem(item._tpl)[1]; - if ((parseInt(itemDbDetails._props.armorClass)) > 0) + let childMultiplerValues = {}; + if (this.randomUtil.getChance100(25)) { // chance the armor is damaged + for (const item of armorWithMods) { - if (!item.upd) + const itemDbDetails = this.itemHelper.getItem(item._tpl)[1]; + if ((parseInt(itemDbDetails._props.armorClass)) > 0) { - item.upd = {}; + if (!item.upd) + { + item.upd = {}; + } + + // Store mod types durabiltiy multiplier for later use in current/max durability value calculation + if (!childMultiplerValues[itemDbDetails._parent]) + { + childMultiplerValues[itemDbDetails._parent] = this.randomUtil.getFloat( + this.ragfairConfig.dynamic.condition[itemDbDetails._parent].min, + this.ragfairConfig.dynamic.condition[itemDbDetails._parent].max, + )/this.ragfairConfig.dynamic.condition[itemDbDetails._parent].max; + } + + let maxDurability = Math.round( + this.randomUtil.getFloat(itemDbDetails._props.MaxDurability * this.randomUtil.getFloat(childMultiplerValues[itemDbDetails._parent], 1), itemDbDetails._props.MaxDurability), + ); + let durability = Math.round( + this.randomUtil.getFloat(maxDurability * this.randomUtil.getFloat(childMultiplerValues[itemDbDetails._parent], 1), maxDurability), + ); + item.upd.Repairable = { + Durability: durability || 1, + MaxDurability: maxDurability + }; } - - // Store mod types durabiltiy multiplier for later use in current/max durability value calculation - if (!childMultiplerValues[itemDbDetails._parent]) - { - childMultiplerValues[itemDbDetails._parent] = Math.round(this.randomUtil.getFloat( - this.ragfairConfig.dynamic.condition[itemDbDetails._parent].min, - this.ragfairConfig.dynamic.condition[itemDbDetails._parent].max, - )); - } - - const maxDurability = Math.round( - this.randomUtil.getFloat(itemDbDetails._props.MaxDurability * this.randomUtil.getFloat(childMultiplerValues[itemDbDetails._parent], 1), itemDbDetails._props.MaxDurability), - ); - item.upd.Repairable = { - Durability: Math.round(itemDbDetails._props.MaxDurability * childMultiplerValues[itemDbDetails._parent]) || 1, - MaxDurability: maxDurability - }; - - const x = 2; } } }