foundryvtt / pf2e

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

Request: Rolls from @Check buttons should include chatMessage flag information about the DC statistic (missing for class DC) #16537

Open shemetz opened 1 month ago

shemetz commented 1 month ago

My previous feature request that tried to solve this problem didn't really end up doing so (https://github.com/foundryvtt/pf2e/issues/9824).

My new request: I want the chatMessageData object that I receive from the preCreateChatMessage hook to have information about the DC source statistic even in situations where it normally doesn't exist. This is for the Modifiers Matter module to work in more situations.

Right now, I try to get originUuid and dc.slug from the context flags (code) and then I use the origin item type and dc slug to figure out which statistic the DC came from (code). This code is working for most types of checks, but not for @Check buttons that require rolling against a class DC, such as the Monk's Stunning Fist.

What I'd like is for the chatMessage.flags.pf2e.context object, which is already full of useful information, to have a bit of extra information that allows me to determine exactly which origin statistic was responsible for creating the DC the roll was using (if it's not a fixed DC).

Right now, when rolling against the monk class DC in the normal way, I only get to have the following context data:

image

This doesn't include anything stable that I can rely on to know that the correct statistic is the actor.classDCs.monk statistic. The closest thing is the dc.label field, but that one's subject to changes by translations, as it's a user-facing string.

xyzzy42 commented 1 month ago

It seems like this information would not be hard to add. It's there when the dc flag is generated, but omitted.

            dc: context.dc ? R.omit(context.dc, ["statistic"]) : null,

This just needs to add context.dc.statistic.parent.slug to the flags.