Evaluate or replace formula data when applying effects or enchantments #4907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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,
ActiveEffect#flags.dnd5e.application.mode
is"evaluate"
, then the effect will attempt to retrieve roll data from the origin and use a copy of thechanges
array where the values are fully evaluated (dice rolls performed if needed);"replace"
, then roll data in the values are simply replaced with the caster's, allowing the target to make use of it."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:
base
type, which theenchantment
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.