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,10 +676,14 @@ 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];
|
const itemDbDetails = this.itemHelper.getItem(item._tpl)[1];
|
||||||
@ -688,25 +698,25 @@ export class RagfairOfferGenerator
|
|||||||
if (!childMultiplerValues[itemDbDetails._parent])
|
if (!childMultiplerValues[itemDbDetails._parent])
|
||||||
{
|
{
|
||||||
childMultiplerValues[itemDbDetails._parent] = this.randomUtil.getFloat(
|
childMultiplerValues[itemDbDetails._parent] = this.randomUtil.getFloat(
|
||||||
this.ragfairConfig.dynamic.condition[itemDbDetails._parent].min,
|
itemDurabilityConfigDict[itemDbDetails._parent].min,
|
||||||
this.ragfairConfig.dynamic.condition[itemDbDetails._parent].max,
|
itemDurabilityConfigDict[itemDbDetails._parent].max,
|
||||||
)/this.ragfairConfig.dynamic.condition[itemDbDetails._parent].max;
|
) / itemDurabilityConfigDict[itemDbDetails._parent].max;
|
||||||
}
|
}
|
||||||
|
|
||||||
let maxDurability = Math.round(
|
const modMultipler = childMultiplerValues[itemDbDetails._parent];
|
||||||
this.randomUtil.getFloat(itemDbDetails._props.MaxDurability * this.randomUtil.getFloat(childMultiplerValues[itemDbDetails._parent], 1), itemDbDetails._props.MaxDurability),
|
const maxDurability = Math.round(
|
||||||
|
this.randomUtil.getFloat(itemDbDetails._props.MaxDurability * this.randomUtil.getFloat(modMultipler, 1), itemDbDetails._props.MaxDurability),
|
||||||
);
|
);
|
||||||
let durability = Math.round(
|
const durability = Math.round(
|
||||||
this.randomUtil.getFloat(maxDurability * this.randomUtil.getFloat(childMultiplerValues[itemDbDetails._parent], 1), maxDurability),
|
this.randomUtil.getFloat(maxDurability * this.randomUtil.getFloat(modMultipler, 1), maxDurability),
|
||||||
);
|
);
|
||||||
item.upd.Repairable = {
|
item.upd.Repairable = {
|
||||||
Durability: durability || 1,
|
Durability: durability || 1, // Never let value become 0
|
||||||
MaxDurability: maxDurability
|
MaxDurability: maxDurability
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add missing conditions to an item if needed
|
* Add missing conditions to an item if needed
|
||||||
|
Loading…
Reference in New Issue
Block a user