cs96and / FoundryVTT-CGMP

FoundryVTT module that adds a few handy options for the GM.
MIT License
5 stars 5 forks source link

[Bug] "Blind rolls made by hidden tokens" incompatible with some game systems? #4

Closed patrickburk1988 closed 3 years ago

patrickburk1988 commented 3 years ago

This might be something that has to be addressed by the developer of the system itself, but I discovered that "Blind rolls made by hidden tokens" doesn't necessarily function in all game systems.

A specific example would be crnormand's GURPS system. Inline chat rolls made by hidden tokens are hidden as one would expect, but rolls made from a hidden actor's character sheet (e.g. clicking on a skill to roll it) are displayed normally to players.

I can reproduce this bug in a new world with all other modules disabled.

cs96and commented 3 years ago

I think this is an issue with the GURPS system. The ChatMessage.data.speaker.token variable is null, so I cannot tell if the roll was made by a hidden token or not. The GURPS system needs to set the token variable to correspond to the token that made the roll.

image

patrickburk1988 commented 3 years ago

Thanks. I'll forward this their way and see if it's something they can take a look at.

crnormand commented 3 years ago

@cs96and, thank you for looking into this. I want to make the GURPS system as compatible as possible (especially for such cool modules!), but I must admit, I am not a Foundry expert... we have gotten as far as we have by sheer force of will and a ton of hacks. ;-)

When creating the roll chat, I am setting up the chat message data as follows:

  const speaker = { alias: actor.name, _id: actor.id, id: actor.id, actor: actor }
  let messageData = {
    user: game.user.id,
    speaker: speaker,
    type: CONST.CHAT_MESSAGE_TYPES.ROLL,
  };

Is the fix as simple as:

  const speaker = { alias: actor.name, _id: actor.id, id: actor.id, actor: actor, token: actor.token }
  let messageData = {
    user: game.user.id,
    speaker: speaker,
    type: CONST.CHAT_MESSAGE_TYPES.ROLL,
  };
cs96and commented 3 years ago

@crnormand I'm not much of a Foundry expert either! However, there is a ChatMessage.getSpeaker() function which helps to construct the speaker parameter of the message. If you give it no parameters, it returns the speaker data for the currently selected token (or the user's default character if no token is selected).

You can provide overrides for the scene, actor, token and alias. You probably want to override the actor to the one for the sheet that is being rolled from. I think it automatically finds a token for that actor on the scene, and defaults to null if one is not found.

crnormand commented 3 years ago

Fantastic, thanks! That seems to set the token attribute correctly (it was the token.id). Unfortunately, I cannot seem to test... how do I make a token "hidden"?

cs96and commented 3 years ago

Right click on the token and select the top right icon (hooded face).

crnormand commented 3 years ago

LOL... I've said many times that, even though I have been working on the GURPS Game Aid (Steve Jackson Games doesn't like it if we call it a "system") for over 6 months... I have yet to actually play a game in Foundry. So there are a lot of things I don't know about using it. Sad, I know ;-)

Thank you for the explanations... I have fixed our code, and it now correctly works with the Cautious Gamemaster's Pack module.