michael-buschbeck / mychs-macro-magic

A simple, sane, and friendly little scripting language for your Roll20 macros.
MIT License
1 stars 1 forks source link

Force min/max rolls #207

Open phylll opened 2 years ago

phylll commented 2 years ago

I need to get the maximum result for a given roll expr, e.g. 8 for 1d6+2. By extension, I can imagine similar use cases where I'd need the minimum result.

Presumably, roll() already knows how to interpret roll expressions, so this might be a quick tweak for another version of calling the roll() function?

michael-buschbeck commented 2 years ago

roll() sends a /roll chat command to Roll20 and waits for the result. :)

Strictly speaking, with how open-ended roll expressions could theoretically be, I'm not even sure if calculating the maximum potential roll can be done without either brute-forcing all potential rolls or doing some fancy computer algebra.

Consider:

That said… if we change the problem description to "roll result if all dice roll critical success" (or failure), it becomes a bit easier – maybe I can make MMM sufficiently aware of Roll20's zoo of roll suffixes to substitute each NdX expression with its respective "critical success" roll result and have Roll20 re-evaluate the expression with that.

phylll commented 2 years ago

Um, ok. I need this for pretty simple roll expressions limited to NdX+/-Y. And since the X is always the maximum roll for that type of die, my immediate use case would be served already by transforming the expression into N * X +/- Y and calculating that.