Additional changes to randomiseWeaponDurabilityValues()
Move chance to make changes check outside of function Aliased ragfair config property Aliased chosen child multipler value Added comment to function
This commit is contained in:
parent
a87129c541
commit
48f99ecfa6
@ -130,7 +130,7 @@
|
|||||||
},
|
},
|
||||||
"57bef4c42459772e8d35a53b": {
|
"57bef4c42459772e8d35a53b": {
|
||||||
"_name": "ARMORED_EQUIPMENT",
|
"_name": "ARMORED_EQUIPMENT",
|
||||||
"conditionChance": 0.6,
|
"conditionChance": 0.25,
|
||||||
"min": 0.05,
|
"min": 0.05,
|
||||||
"max": 1
|
"max": 1
|
||||||
},
|
},
|
||||||
|
@ -588,6 +588,12 @@ export class RagfairOfferGenerator
|
|||||||
// Randomise armor
|
// Randomise armor
|
||||||
if (this.itemHelper.armorItemCanHoldMods(rootItem._tpl))
|
if (this.itemHelper.armorItemCanHoldMods(rootItem._tpl))
|
||||||
{
|
{
|
||||||
|
// Chance to not adjust armor
|
||||||
|
if (!this.randomUtil.getChance100(this.ragfairConfig.dynamic.condition[BaseClasses.ARMORED_EQUIPMENT]))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.randomiseArmorDurabilityValues(itemWithMods);
|
this.randomiseArmorDurabilityValues(itemWithMods);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -670,40 +676,44 @@ export class RagfairOfferGenerator
|
|||||||
item.upd.Repairable.MaxDurability = tempMaxDurability;
|
item.upd.Repairable.MaxDurability = tempMaxDurability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Randomise the durabiltiy values for an armors plates and soft inserts
|
||||||
|
* @param armorWithMods Armor item with its child mods
|
||||||
|
*/
|
||||||
protected randomiseArmorDurabilityValues(armorWithMods: Item[]): void
|
protected randomiseArmorDurabilityValues(armorWithMods: Item[]): void
|
||||||
{
|
{
|
||||||
let childMultiplerValues = {};
|
const itemDurabilityConfigDict = this.ragfairConfig.dynamic.condition;
|
||||||
if (this.randomUtil.getChance100(25)) { // chance the armor is damaged
|
const childMultiplerValues = {};
|
||||||
for (const item of armorWithMods)
|
for (const item of armorWithMods)
|
||||||
|
{
|
||||||
|
const itemDbDetails = this.itemHelper.getItem(item._tpl)[1];
|
||||||
|
if ((parseInt(<string>itemDbDetails._props.armorClass)) > 0)
|
||||||
{
|
{
|
||||||
const itemDbDetails = this.itemHelper.getItem(item._tpl)[1];
|
if (!item.upd)
|
||||||
if ((parseInt(<string>itemDbDetails._props.armorClass)) > 0)
|
|
||||||
{
|
{
|
||||||
if (!item.upd)
|
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] = this.randomUtil.getFloat(
|
||||||
|
itemDurabilityConfigDict[itemDbDetails._parent].min,
|
||||||
|
itemDurabilityConfigDict[itemDbDetails._parent].max,
|
||||||
|
) / itemDurabilityConfigDict[itemDbDetails._parent].max;
|
||||||
|
}
|
||||||
|
|
||||||
|
const modMultipler = childMultiplerValues[itemDbDetails._parent];
|
||||||
|
const maxDurability = Math.round(
|
||||||
|
this.randomUtil.getFloat(itemDbDetails._props.MaxDurability * this.randomUtil.getFloat(modMultipler, 1), itemDbDetails._props.MaxDurability),
|
||||||
|
);
|
||||||
|
const durability = Math.round(
|
||||||
|
this.randomUtil.getFloat(maxDurability * this.randomUtil.getFloat(modMultipler, 1), maxDurability),
|
||||||
|
);
|
||||||
|
item.upd.Repairable = {
|
||||||
|
Durability: durability || 1, // Never let value become 0
|
||||||
|
MaxDurability: maxDurability
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user