
RollMaster d100 Roll Generator
FILE LOCATION: My Personal Repo (one-click submission pending as of 17 June 2022)
PLUGGER PLUGIN: In addition to being a stand-alone script, this script will work with Plugger as a meta-script to modify other scripts' API commands and return the resulting roll to the command line interpreted by other scripts. See Using With Plugger, below.
ABSTRACT: Generates and returns an inline roll structure following RoleMaster explosion guidelines (otherwise unavailable within Roll20 roll syntax). Allows for the inclusion of any number of modifiers to the roll. You can also set the base die type, and/or the upper and lower explosion thresholds. Finally, it also works with Plugger to allow you to return the resulting roll to the command line of other scripts (or, with ZeroFrame installed as well, to a roll template output).
Updated Instructions (BELOW)
With the Production Release of this script, certain script behaviors have changed -- mostly around roll mechanics and storing script options in the state. After reading this post, please review the Production Release post for these changes.
Introduction
RoleMaster is a d100 system with an explosion mechanic not otherwise buildable using standard Roll20 syntax (though I am open to seeing how it can be done, if anyone -- say, RainbowEncoder -- can come up with a way to do it). =D
The mechanic is:
You roll 1d100, and explode on a 96 or above. However, you can also explode negatively on a 5 or less. On subsequent rolls, the same mechanic applies, so that on a 5 or less you flip again so that you are now positively exploding. As an example, rolling 96 results in rolling again and adding the result. That roll results in 4, so you roll again and subtract. You roll a 97, which explodes, and you roll again. The next roll results in 64, which does not explode. Your final roll output is:
96 + 5 - 97 - 64 = -60
As a part of the final value of the roll (representing a skill attempt, for example), you can add other modifiers (i.e., skill attributes, bonuses, etc.). The script accommodates those modifiers.
Command Line
Use !rmd100 to trigger the script. This will produce a simple roll depicting the various explosions that happened along the way.
Modifiers as Command Line Arguments
Add any modifiers to the roll as arguments to the line prefaced by a double hyphen. Any number of such modifiers can be used.
!rmd100 --20
!rmd100 --@{selected|Blacksmith} --@{selected|CraftingSkillGroup}
!rmd100 --@{selected|Blacksmith} --@{selected|CraftingSkillGroup} --?{Bonus|0}
If the argument represents a number, it will be included in the roll.
Include Labels for Modifiers
If you want to include a label for the value in the roll, include that label immediately after the double-hyphen, and separate it from the value by a hash (#) or a pipe (|) character.
!rmd100 --Blacksmith|@{selected|Blacksmith}
Labels will appear in the resulting roll:
Script Output (Whisper, Value Only)
Whispering
Include a --whisper argument to limit who can see the output of the roll. To whisper to yourself, leave the argument without a value:
!rmd100 --whisper
If you wish to whisper the result to someone else (for example, the GM), include the target after a delimiter:
!rmd100 --whisper|ActualCannibal
!rmd100 --whisper|gm
Outputting the Roll Value, Only
The typical output of the script is an inline roll equation (i.e. '[[90 + 20[Blacksmith] + 10]]'). If you wish, instead, to output the value of the roll only (which can be important when you use the script in combination with Plugger -- see below), you can use the special argument --value:
!rmd100 --Blacksmith|@{selected|Blacksmith} --value
The resulting output to chat will not have roll-tip available on-hover, but it will display the correct value.
Script Behavior (Base Dice, Explosion Thresholds, Reset, Report)
Base Dice & Explosion Thresholds
You can control the base die type of the roll, as well as the upper/lower explosion thresholds, using special arguments to the command line. These changes will persist for game sessions (or API sandbox reboots). These are not currently saved to the state (to persist between sandbox restarts), however if that feature is desired, it can be added.
While there is no reason that I'm aware of in the RoleMaster system to change these values, the ability to change the script's behavior allows it to potentially adapt to house rules or even to a system with a similar explosion mechanice but different starting values (i.e., d20, lower explosion of 2, upper explosion of 19).
These special arguments are as follows:
--die
--lowx
--highx
Follow these with an argument delimiter (hash or pipe), followed by a number. For instance, to set the d20/2/19 rule mentioned just above, the command line would be:
!rmd100 --die|20 --lowx|2 --highx|19
Report
If you want to see what values the script is currently using, you can use a --report argument:
!rmd100 --report
This can be paired with the --whisper argument.
Reset
If you wish to reset the die, lowx, and highx settings to their original values, you can use the --reset argument:
!rmd100 --reset
This can be paired with a --whisper argument.
Using With Plugger (Return a Value to the Command Line)
Plugger is a metascript that dispatches calls to secondary scripts when the Plugger syntax is included in a primary script's command line. If that secondary script registers itself to Plugger to be a 'plug-in', Plugger will actually return a value to the command line before the primary script ever receives the command.
In other words: to use the roll produced by RoleMasterD100 in another script, use the Plugger syntax to embed it in the command line.
The appropriate syntax for use as a plug-in is to take the original rmd100 command line but leave off the exclamation mark, and enclose the arguments in parentheses. Then, enclose the whole thing in the {&eval} tags from Plugger.
!somescript --Skill|Blacksmith --Result|{&eval}rmd100(--Blacksmith|@{selected|Blacksmith}){&/eval}
Remember that what is typically returned from RoleMasterD100 is the equation of an inline roll, (i.e. [[90 + 20[Blacksmith] + 10]]). This might not work for you as a Plugger plug-in, since inline rolls are processed by Roll20 before the message is given to the set of API scripts. There is no opportunity for Roll20 to process the new inline roll returned by RoleMasterD100 before it is handed off to the primary script where the Plugger syntax is embedded.
In such a case, you should include the --value argument to have RoleMasterD100 instead return the result of the roll to the command line.
!somescript --Skill|Blacksmith --Result|{&eval}rmd100(--Blacksmith|@{selected|Blacksmith} --value){&/eval}
Another way to solve this is to have ZeroFrame (another metascript) installed, as well. ZeroFrame will detect the inline roll equation (the default return from RoleMasterD100), and add it to the message that the secondary script receives. Using ZeroFrame in this way will preserve the roll as an inline roll, so you will be able to see the on-hover roll-tip.