Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Custom Dice for Homebrew

Hi guys.  I'm new to Roll20 API and I'm trying to get everything set up so I can playtest a homebrew with some non-local friends. I'd like to make some custom dice. I have some programming experience, but I could at least use some direction. From what I've read in other threads, the best thing I can do is explain in detail how my dice system works.  I'm going to annotate my die as "dS" My system is success based. Players roll a number of 10-sided dice based on their stats and add up successes. A success is any die that results in a value of 6 or greater. If they roll a 1, it is a fumble and counts as -1 success. If they roll a 10, it is a critical and counts as 2 successes. There is an attribute called "favor", which is a quantity value applied to certain rolls, often tied to specific skills. for each favor a player has, they roll one less die and add 1 success to the total (So if they're rolling 3dS, they'd instead roll 2dS+1. If they have 4 favor to this roll, it would just be 3 successes and no die roll).  If they have "disfavor", they just drop one die. For the sake of simplicity, favor and disfavor do not cancel out. If you have +1 favor and -1 favor and are rolling 3dS, you'd roll 1dS+1 There is another attribute called emphasis. emphasis applies only to specific types of rolls tied to roleplaying aspects, like when discussing politics or handling gnomish-made mechanics. It is applied to every die in the roll and with emphasis, the player rerolls any die that results in a fumble (result of 1) There are two attributes: one that increase a fumble to -2 outcome, and one that increases a critical to +3 outcome.  So my normal dice roll would be something like /roll 5d10>5cs10cf1. A bit complicated to have my players type. How can I make this easier on myself and my players? Ideally, I'd love to be able to do /roll {number of dice}dS, or /roll {number of dice}dSf{amount of favor}, or /roll {number of dice}dSf{amount of favor}e (for emphasis) Thank you for your assistance!
1489158956
The Aaron
Pro
API Scripter
Wow. &nbsp;That's a lot to process. &nbsp;I think you're firmly in the land of API scripts with that. I've written some dice mechanics scripts that are in the repo which you might take a look at as a jumping off point: CthuluTechDice -&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Ct" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Ct</a>... ZombieDice -&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Zo" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Zo</a>... MutantYearZero -&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Mu" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Mu</a>... WildDice -&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Wi" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Wi</a>... BashDice -&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/BashDice/BashDice.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/BashDice/BashDice.js</a>
1489170878
Lithl
Pro
Sheet Author
API Scripter
Note: d10&gt;5 will give you a success on 5 or greater, not 6+. While it's wrong for math, it's legacy syntax from another die rolling system. I think you can achieve everything you need with rollable tables. For example, the basic table ("dS") would be: Name Weight -1 1 0 4 1 4 2 1 Your macro would then be something like: [[[[@{stats} - (?{Favor|0} + ?{Disfavor|0})]]t[dS] + ?{Favor}]] With this method, you would need separate tables for emphasis, worse fumbles, and better crits (and combinations of those three features). For example, the emphasis table ("dSe") would be the same as the dS table, but without the -1 table item. Worse fumbles would change the -1 to a -2. Better crits would change the 2 to a 3. Better crits and &nbsp;worse fumbles would change both the -1 and the 2 to a -2 and 3, respectively. Emphasis completely negates fumbles, so no need for a worse-fumbles-plus-emphasis table (just use emphasis), but an emphasis-plus-better-crits table would be the better-crits table without the -1 item.
I think that'll work pretty well, especially if I can make macros for it.&nbsp; Is there a way to check if my variable (favor) is greater than zero?
1489176272

Edited 1489176325
Silvyre
Forum Champion
Michael said: Is there a way to check if my variable (favor) is greater than zero? A classic way is dividing by a large enough number and rounding up: [[ ceil(?{Favor} / 1e3) ]] returns 1 if greater than 0, else 0.
Almost have things exactly how I want. Looks pretty good. Any way to have the two calculated values not show up as a dice roll result? Also, is there a reason 1s are red like fumbles? I'd love for -1s to be red and 2s to be green. or actually, just positive values green and negative values red.
1489184062
Lithl
Pro
Sheet Author
API Scripter
Michael said: Any way to have the two calculated values not show up as a dice roll result? Remove the [[inline brackets]]. For the first number (the N in Nt[dS]), you'll need to wrap it in parentheses instead. So something like (@{stats} - (?{Favor|0} + ?{Disfavor|0}))t[dS] + ?{Favor} . Michael said: Also, is there a reason 1s are red like fumbles? I'd love for -1s to be red and 2s to be green. or actually, just positive values green and negative values red. No, as far as I'm aware.
I changed the expression from asking for favor/disfavor to getting it from the sheet's variable. I'll just combine favor/disfavor for ease (still haven't decided what to do anyway!). My current expression is /roll (@{skillrank} - abs(@{skillfavor}))t[dS]+({{@{skillfavor},-1}&gt;0}*(@{skillfavor})).&nbsp; This is the output of that (skill 5, 2 favor):
1489247235
Lithl
Pro
Sheet Author
API Scripter
You can't have any functions in the number-of-dice calculation unless you wrap it in an inline roll. /r [[3 - abs(0)]]t[dS] is okay and (3 - 0)t[dS] is okay, but (3 - abs(0))t[dS] is not okay.
1489262983
Silvyre
Forum Champion
Michael said: Any way to have the two calculated values not show up as a dice roll result? Adding unmatched opening inline roll bracket [[ to your /roll will remove the inline roll styling from any inline rolls following that. However, that unmatched inline roll bracket will need to occur within a inline label . [[] functions as both an inline label and an unmatched inline roll bracket for this purpose: /r [[] [[ @{skillrank} - abs(@{skillfavor}) ]]t[dS] + [[ {@{skillfavor}, 0}kh1 ]]