Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate or replace formula data when applying effects or enchantments #4907

Open
wants to merge 1 commit into
base: 4.2.x
Choose a base branch
from

Conversation

krbz999
Copy link
Contributor

@krbz999 krbz999 commented Dec 19, 2024

Proof-of-concept PR on how the system might use roll data from a caster on a target or other evaluated values.

Related issues: #3809, #4437, #4464, #4465

When granting an effect or enchantment via the effect trays,

  • if ActiveEffect#flags.dnd5e.application.mode is "evaluate", then the effect will attempt to retrieve roll data from the origin and use a copy of the changes array where the values are fully evaluated (dice rolls performed if needed);
  • if it's "replace", then roll data in the values are simply replaced with the caster's, allowing the target to make use of it.
  • The "evaluateSelf" mode is identical to "evaluate" but uses the target's own roll data (more niche but still useful for stuff like an enchantment that uses roll data targeting a NumberField).

TODO:

  • Add these options in the effect config.
  • Consider whether the option should be in the data model instead; perhaps a data model for the base type, which the enchantment type could then extend.

Some notes:

While I did consider placing this in _preCreate, it isn't possible to determine if the creation of the effect was due to just wanting to copy from one item/actor to another during data entry or to grant the item/actor the effect.

@krbz999 krbz999 force-pushed the effect-change-evaluation branch from 49ddd0c to 60022c6 Compare December 19, 2024 15:52
@krbz999 krbz999 force-pushed the effect-change-evaluation branch from 60022c6 to ab1eb24 Compare December 19, 2024 16:59
@tposney
Copy link

tposney commented Dec 20, 2024

Very nice - I can rip out most of the guts of dae if this goes in.

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.

4 participants