Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to grab the advantage/disadvantage calculation output from Midi? #16

Closed
emirkmo opened this issue Jan 27, 2022 · 10 comments · Fixed by #33
Closed

Is it possible to grab the advantage/disadvantage calculation output from Midi? #16

emirkmo opened this issue Jan 27, 2022 · 10 comments · Fixed by #33

Comments

@emirkmo
Copy link

emirkmo commented Jan 27, 2022

Is it possible to grab the advantage/disadvantage calculation output from MidiQOL, and only use this mod as basically a CSS enhancer for the advantage/disadvantage auto selection?

@kaelad02
Copy link
Owner

You're thinking of using this with Midi? I'm guessing then you have Midi configured to still prompt for rolls then, it's not auto-rolling attacks or saving throws. If that's the case, I suppose I could look into some sort of compatibility with it. Like you said, maybe it does nothing related to advantage/disadvantage but could still do CSS (maybe even the new messages feature).

@emirkmo
Copy link
Author

emirkmo commented Jan 28, 2022

Yes, basically Midi allows you to automate only the parts you want. Players like to select advantage/disadvantage (they can fast forward with a keybind but some of my players aren't too comfortable with that). GM rolls auto fastforward.

Anyway, irregardless of that, the CSS you have for showing the favored roll outcomes (which midi also calculates and sets as the default selection) and the accompanying message is super clear and nice. So this would allow my players to see the calculated roll clearly, then choose to use something different if they want to. But if it's too much for you to dig through, maybe I could ask Midi dev to add in something like this.

@mech-tools
Copy link
Contributor

mech-tools commented Jan 28, 2022

@emirkmo Hey, I know it's not a perfect solution but you could install this package: https://github.com/cswendrowski/FoundryVTT-Custom-CSS

And add your own CSS rule for the default button:

.dialog .dialog-buttons button.default.advantage {
  font-weight: bold;
}

.dialog .dialog-buttons button.default.disadvantage {
  font-weight: bold;
}

.dialog .dialog-buttons button.default.critical {
  font-weight: bold;
}

Or any custom rule.

@kaelad02
Copy link
Owner

kaelad02 commented Jan 29, 2022

Yeah, could add the CSS in other ways. Did confirm that it does work though. I can see the buttons with bold text.

I tested it out and this does work with Midi QOL. From what I can tell, Midi will ignore this module's advantage flags anyways. Sure, that does mean this module wastes time doing the calculations but it's not a noticeable performance hit.

The unfortunate part is the new messages feature doesn't work either. This module adds something to the roll options that Midi doesn't pass along to the system's roll method for some like attack and damage rolls. Nothing I can do except file a bug report there. From what I can tell it should work with saves and ability checks but I can't get Midi to show the dialogs no matter what settings I change.

Edit: It does show messages for saves and ability checks. I also had MRE loaded (was testing w/ it earlier) and it was interfering.

@emirkmo
Copy link
Author

emirkmo commented Feb 1, 2022

A simple CSS hack is easier, but a maintained module is of course much more stable in the long run. Great to hear it's working. I will verify this weekend and report back. Seems like there are some compatibility issues with other modules and that might be the issue I had. Probably better to track that in another issue though.

kaelad02 added a commit that referenced this issue Feb 3, 2022
Did another round of testing with Better Rolls and noted that messages do not work at all. When it queries for advantage it does not use the default template and doesn't pass along any options anyways.
Added more information about Midi as well. Note to self on messages for attack and damage rolls: it doesn't work because Midi doesn't pass along the dialog options
@tposney
Copy link

tposney commented Apr 26, 2022

I think the messages part is working for attack rolls.
I wondering if there is a way for midi to insert advantage helper text (i.e. disadvantage: nearby foes) without creating an active effect with the data (since that involves a db transaction to and and another to remove).

@kaelad02
Copy link
Owner

Looking for a little integration @tposney? I turned on Midi's debugging b/c it's been a while and I couldn't remember the order some of this stuff is called but looks like there's a few Midi workflow phases that are run before Advantage Reminder does it's work in the wrapped rollAttack function (up to WAITFORATTACKROLL from what I can tell).

Two ways I can think of:

  1. We could come up with something in the options argument Midi could add that Advantage Reminder could pickup. Options are in all of the rolls I wrap, so would even work for saving throws, etc.
  2. You could add it as one of Midi's workflow variables and Advantage Reminder could grab it that way. It doesn't seem hard to get the workflow object, MidiQOL.Workflow.getWorkflow using the item's UUID should do. This would work for attacks but maybe not for saving throws since in my wrapper I only have the actor, not the item, so I'm not sure how I'd get the workflow ID that way.

@kaelad02
Copy link
Owner

fwiw, I'd lean towards that first option... seems more straight forward

@tposney
Copy link

tposney commented Apr 26, 2022

I like option 1 as well.

I've hacked together something that inserts the midi advantage info dialogOptions.adv-reminder.message, but a structured solution might be better - although it's pretty okay at the moment. I currently have an object (or array) of strings which are advantage attribution information.
Screenshot from 2022-04-26 21-29-16

@kaelad02
Copy link
Owner

@tposney Sorry for letting this fall by the wayside.

We could just use dialogOptions.adv-reminder.messages, the plural of what I'm already using. I like namespacing it with the module name to avoid conflicts. I thought of extraMessages but it just seemed like extra was unnecessary. Sound good to you?

Then this module will just look for a string or array of strings in that option and add it to any messages it finds in the active effects. The one function to look out for is Item5e#rollDamage with its inner options object. In that case, we'd need to pass it on that inner options objects:

const messages = [ ... ];
item.rollDamage({ options: {"dialogOptions.adv-reminder.messages": messages }});

kaelad02 added a commit that referenced this issue Sep 19, 2022
@kaelad02 kaelad02 mentioned this issue Sep 19, 2022
kaelad02 added a commit that referenced this issue Sep 19, 2022
* update readme with new modules and remove old ones

BR and MRE are no longer supported in v10 so remove them. Include notes about their replacements

* close #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants