Skip to content

[#6261] Add modifiers to DamageData#6834

Open
arbron wants to merge 3 commits into
6.0.xfrom
damage/modifiers
Open

[#6261] Add modifiers to DamageData#6834
arbron wants to merge 3 commits into
6.0.xfrom
damage/modifiers

Conversation

@arbron

@arbron arbron commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

Adds a new modifiers field for damage that is applied automatically to the formula. The DamageData model now automatically adds these modifiers to the formula, attaching to the first roll (if one can be found when using a custom formula).

The DamageData#scaledFormula supports passing in additional modifiers that are also appended. This is to support a future Rule active effect that adds modifiers to certain rolls at evaluation time (such as Elemental Adept, which would add min2 to all damage rolls from spells that deal a certain damage type).

Closes #6261

@arbron arbron added this to the D&D5E 6.0.0 milestone Mar 16, 2026
@arbron arbron self-assigned this Mar 16, 2026
@arbron arbron changed the base branch from 5.3.x to 6.0.x June 2, 2026 17:49
Adds a new modifiers field for damage that is applied automatically
to the formula. The `DamageData` model now automatically adds these
modifiers to the formula, attaching to the first roll (if one can
be found when using a custom formula).

The `DamageData#scaledFormula` supports passing in additional
modifiers that are also appended. This is to support a future Rule
active effect that adds modifiers to certain rolls at evaluation
time (such as Elemental Adept, which would add `min2` to all damage
rolls from spells that deal a certain damage type).

Closes #6261
@arbron arbron force-pushed the damage/modifiers branch from a4ec673 to 62e3180 Compare June 2, 2026 18:09
Comment thread module/data/shared/damage-field.mjs Outdated
Comment thread module/data/shared/damage-field.mjs Outdated
@arbron arbron requested a review from Fyorl June 5, 2026 20:58
get formula() {
if ( this.custom.enabled ) return this.custom.formula ?? "";
if ( this.custom.enabled ) return this._manualFormula();
return this._automaticFormula();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also something I missed from my original round of feedback, was that we use formula for display on sheets as well. This isn't a new problem because AEs will also cause this, but it would be nice if we just had the 'pristine' formula on display, and any modifiers omitted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the ability to pass modifiers: false into the formula methods and tied that into the label generation for the damage parts. It doesn't strip out existing modifiers from custom formulas, but it does avoid adding new modifiers.

Passing through DamageFormulaOptions is also going to be necessary in the future for rule AEs that add modifiers so it is good to get it piped in now.

@arbron arbron requested a review from Fyorl June 5, 2026 21:53
if ( number && this.denomination ) formula = `${number}d${this.denomination}`;
if ( number && this.denomination ) {
formula = `${number}d${this.denomination}${modifiers !== false
? Array.from(this.modifiers).concat(modifiers ?? []).join("") : ""}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DamageFormulaOptions has modifiers as a Set, so this will concat the whole set into the array I think.

Suggested change
? Array.from(this.modifiers).concat(modifiers ?? []).join("") : ""}`;
? Array.from(this.modifiers).concat(...(modifiers ?? [])).join("") : ""}`;

_manualFormula({ modifiers }={}) {
if ( !this.custom.formula ) return "";
if ( modifiers === false ) return this.custom.formula;
modifiers = Array.from(this.modifiers).concat(modifiers ?? []).join("");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifiers = Array.from(this.modifiers).concat(modifiers ?? []).join("");
modifiers = Array.from(this.modifiers).concat(...(modifiers ?? [])).join("");

@@ -1,8 +1,13 @@
import simplifyRollFormula from "../../dice/simplify-roll-formula.mjs";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add modifiers field to DamageData

2 participants