[Fix] Improve HP Damage Multiplier Active Effect (#2110)

This commit is contained in:
WBHarry 2026-07-25 03:58:51 +02:00 committed by GitHub
parent 7fd2a7f17e
commit 82ce2f3052
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 3 deletions

View file

@ -131,7 +131,9 @@ export default class DamageRoll extends DHRoll {
getActionChangeKeys() {
const type = this.options.messageType ?? (this.options.hasHealing ? 'healing' : 'damage');
const changeKeys = [];
const changeKeys = [
'system.rules.attack.damage.hpDamageMultiplier'
];
for (const damageType of this.options.damageFormula?.damageTypes?.values?.() ?? []) {
changeKeys.push(`system.bonuses.${type}.${damageType}`);
@ -210,6 +212,22 @@ export default class DamageRoll extends DHRoll {
formulaData.roll.terms.push(...this.formatModifier(total));
}
}
const damageTakenMultiplier = this.getTotalBonus('system.rules.attack.damage.hpDamageMultiplier');
if (damageTakenMultiplier && damageTakenMultiplier !== 1) {
// The fully built up roll needs to be set inside of a paranthetical term, so we build the dice anew with all the pushed in terms.
// We clone it to avoid infinite recursion.
formulaData.roll = Roll.fromTerms(formulaData.roll.terms);
formulaData.roll.terms = [
new foundry.dice.terms.ParentheticalTerm({
roll: formulaData.roll.clone(),
term: formulaData.formula
}),
new foundry.dice.terms.OperatorTerm({ operator: '*' }),
new foundry.dice.terms.NumericTerm({ number: damageTakenMultiplier })
];
}
}
formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms);