FoundryVTT-BetterRolls5e icon indicating copy to clipboard operation
FoundryVTT-BetterRolls5e copied to clipboard

FR: Roll metadata in chat hooks/for other modules

Open gludington opened this issue 5 years ago • 5 comments
trafficstars

A pending FR on the https://github.com/gludington/conditional-visibility/ automatically hides a token making a stealth check from players whose perception the roll beats. The feature works in vanilla FoundryVTT rolls, because the ***chat hooks contain information about the roll and the token speaker, but there is no analogue to this information passed from BetterRolls5e. Is there any hook, method, or registration possible to get at this information? Since I use BetterRolls5e in my own games, I would like to find some way to be compatible with the system.

gludington avatar Oct 15 '20 05:10 gludington

This definitely sounds like something worth implementing support for! Does your module simply use hooks revolving around chat messages, or are there other hooks/entities you'd rather refer to for BR integration?

RedReign avatar Oct 16 '20 06:10 RedReign

I would love to be able to listen to roll-specific hooks in stock Foundry, but as far as I can tell they do not yet exist. Currently, it uses chat hooks and inspects message metadata to see if it is a stealth roll, though if it is simpler/more robust to implement on your end, ConditionalVisibility might be able to listen for a BetterRolls5e event of your choosing, and ignore the subsequent BetterRolls5e-flavored chat message.

To apply the condition, the visibility module needs to know the token to apply it to as well as the value to use, in whatever form it can be communicated. In the 0.0.8 release, there is a relevant method intended for macro users (e.g. ConditionalVisibility.hide(tokens, rollResult)), but it probably would be healthier for BetterRolls5e not to be coupled so tightly.

gludington avatar Oct 16 '20 20:10 gludington

The visibility module only works right now with passive perception. I would like to have at some point it also work with active perception checks, so that might be another argument in favor of some sort of hook method instead of direct coupling.

gludington avatar Oct 16 '20 21:10 gludington

Throwing another use case into the hat here for consideration...

I have a module that forces certain skill checks to roll blindly. Currently I accomplish this by hooking into Foundry's preCreateChatMessage hook and looking at some of the data in there to determine if the roll should be hidden or not. When using BR, I'm taking the entirety of the message content that BR produces, stripping out all the whitespace, and seeing if it includes a header containing the name of any of the skills in question (eg <h3 class="item-name">Insight</h3>). This is kinda silly and rather limits my ability to support other modules like DSN.

Being able to hook into the end of fullRollSkill right before the return and having access to the actor and skill data would make this much easier and less hacky for me.

crash1115 avatar Oct 25 '20 21:10 crash1115

Curious, has the recent changes solved this issue, or are there more things needed to support all of this? I looked into the linked issue and it seems resolved already.

Wondering if I can close the issue.

CarlosFdez avatar Feb 12 '21 21:02 CarlosFdez