foundryvtt / pf2e

A community contributed game system for Pathfinder Second Edition.
https://foundryvtt.com/packages/pf2e
Apache License 2.0
402 stars 335 forks source link

Multiple ChoiceSet REs causes following non-IWR REs to not be ignored #6309

Closed xyzzy42 closed 1 year ago

xyzzy42 commented 1 year ago

If an effect has a ChoiceSet RE that is skipped, e.g. because it has a false predicate, it will cause any IWR REs that follow it to failed to be applied. Other REs such as GrantItem and FlatModifier still work as expected when the follow non-activated ChoiceSet REs. The IWR RE still works if it precedes the ChoiceSet. Example:

{"key":"ChoiceSet","choices":[{"label":"foo","value":"foo"},{"label":"bar","value":"bar"}],"predicate":["self:trait:nope"]}
{"key":"Weakness","type":"piercing","value":5}

Change the trait to one that does exist and the Weakness RE works again.

stwlam commented 1 year ago

If a choice set is skipped, all other rule elements on the item are set to be ignored. You can override this by adding "allowNoSelection": true to the choice set.

xyzzy42 commented 1 year ago

Ok, so then the bug is the opposite, but it's more complex. If there are multiple ChoiceSet REs and one of them is skipped, non-IWR REs are not ignored, but IWR are.

Example:

{"key":"ChoiceSet","choices":[{"label":"foo","value":"foo"},{"label":"bar","value":"bar"}],"flag":"test1"}
{"key":"ChoiceSet","choices":[{"label":"foo","value":"foo"},{"label":"bar","value":"bar"}],"predicate":["nope"],"flag":"test2"}
{"key": "GrantItem","uuid": "Compendium.pf2e.conditionitems.i3OJZU2nk64Df3xm"}
{"key":"Immunity","type":"bleed"}

This does grant Clumsy, but doesn't do the IWR RE.

stwlam commented 1 year ago

Anything that runs during data preparation is forced to be ignored.

xyzzy42 commented 1 year ago

So what's going on is is the constructor of a ChoiceSet will set all REs to ignored if no selection is made. But then in preCreate all ChoiceSets get processed again and it will set all REs to unignored if a selection is made. If there are multiple ChoiceSet REs, then all REs will go from ignored, to unignored, to ignored.