mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-25 20:09:55 +02:00
[Fix] Improve HP Damage Multiplier Active Effect (#2110)
This commit is contained in:
parent
7fd2a7f17e
commit
82ce2f3052
3 changed files with 49 additions and 3 deletions
|
|
@ -105,9 +105,8 @@ export default class DamageField extends fields.SchemaField {
|
||||||
const configDamage = config.damage.clone();
|
const configDamage = config.damage.clone();
|
||||||
configDamage.main &&= configDamage.main.toJSON();
|
configDamage.main &&= configDamage.main.toJSON();
|
||||||
if (configDamage.main) {
|
if (configDamage.main) {
|
||||||
const multiplier = config.actionActor?.system.rules?.attack?.damage?.hpDamageMultiplier ?? 1;
|
|
||||||
const takenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
|
const takenMultiplier = actor.system.rules?.attack?.damage?.hpDamageTakenMultiplier;
|
||||||
configDamage.main.total = Math.ceil(config.damage.main.total * multiplier * takenMultiplier);
|
configDamage.main.total = Math.ceil(configDamage.main.total * takenMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
damagePromises.push(
|
damagePromises.push(
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,9 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
getActionChangeKeys() {
|
getActionChangeKeys() {
|
||||||
const type = this.options.messageType ?? (this.options.hasHealing ? 'healing' : 'damage');
|
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?.() ?? []) {
|
for (const damageType of this.options.damageFormula?.damageTypes?.values?.() ?? []) {
|
||||||
changeKeys.push(`system.bonuses.${type}.${damageType}`);
|
changeKeys.push(`system.bonuses.${type}.${damageType}`);
|
||||||
|
|
@ -210,6 +212,22 @@ export default class DamageRoll extends DHRoll {
|
||||||
formulaData.roll.terms.push(...this.formatModifier(total));
|
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);
|
formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms);
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,35 @@ export default class DHRoll extends BaseRoll {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sums the values of all instances of ActiveEffect.change values from the toggleable bonusEffects of the roll
|
||||||
|
* that match a given change.key partial path. Only for use on ActiveEffects.change with strictly numerical values.
|
||||||
|
* @param {string} path The full or partial effect.change key
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
getTotalBonus(path) {
|
||||||
|
return Object.values(this.options.bonusEffects).reduce((acc, effect) => {
|
||||||
|
if (!effect.selected) return acc;
|
||||||
|
return acc + effect.changes.reduce((acc, change) => {
|
||||||
|
if (!change.key.includes(path)) return acc;
|
||||||
|
const changeValue = game.system.api.documents.DhActiveEffect.getChangeValue(
|
||||||
|
this.data,
|
||||||
|
change,
|
||||||
|
effect.origEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
return Number.isNumeric(changeValue) ? acc + changeValue : acc;
|
||||||
|
}, 0);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grabs all instances of ActiveEffect.change values from the toggleable bonusEffects of the roll
|
||||||
|
* that match a given change.key partial path.
|
||||||
|
* @param {string} path The full or partial effect.change key
|
||||||
|
* @param {string} label The label to give the modifiers
|
||||||
|
* @returns {[{ label: string, value: any} ]}
|
||||||
|
*/
|
||||||
getBonus(path, label) {
|
getBonus(path, label) {
|
||||||
const modifiers = [];
|
const modifiers = [];
|
||||||
for (const effect of Object.values(this.options.bonusEffects)) {
|
for (const effect of Object.values(this.options.bonusEffects)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue