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

Need help adding advantage to convoluted macro

1724194686

Edited 1724194781
For my game I created a training system which allows players to gather points in order to eventually gain proficiency with certain weapons, tools, languages, etc. The macro I have so far has been working as intended, but there is still one element missing. When a player trains for 4 hours or more, the rolls in the macro are to be made at advantage. This is the macro so far: /em is training hard! /roll ?{How many hours did you train?|1}d20 + (?{How many hours did you train?} * (?{Did you have a trainer? 1 for Yes, 0 for No|1|0}d20 + (?{Did you have a trainer? 1 for Yes, 0 for No} * 20))) + (?{How many hours did you train?} * (?{Select which ability is used for training | Strength,@{target|strength}| Dexterity,@{target|dexterity}| Constitution,@{target|constitution}| Intelligence,@{target|intelligence}| Wisdom,@{target|wisdom}| Charisma,@{target|charisma}} + @{target|intelligence})) In case it is too hard to read, the macro so far does the following: Ask how many hours you train. That's how many d20 you roll. Ask if you had a trainer. If so, an extra d20+20 is added for every hour trained. Ask which Ability Score is used for that particular training session + Intelligence Score (not the modifiers on purpose). Multiply the sum total of these two by the amount of hours trained. My goal is to find out if it would be possible to include and advantage to all the d20 rolls. If it is not possible, so be it. The players can just roll twice and take the highest numbers.
1724196408

Edited 1724196478
GiGs
Pro
Sheet Author
API Scripter
It is likely possible, but you'll need to restructucture the macro. (It won't be pretty!) How do advantage and disadvantage work in your system? 3. Ask which Ability Score is used for that particular training session + Intelligence Score (not the modifiers on purpose). Multiply the sum total of these two by the amount of hours trained. What is this sum used for? is it a bonus added to the roll?
1724204194

Edited 1724206585
It looks like the number of hours trained multiplies by everything, so the formula can be simplified a bit:      Hours * (1d20 + ?{Trainer}(d20 + 20) + ?{Ability} + Intelligence) Adding in advantage you need to adjust each of the d20 rolls:      Hours * (2d20kh1 + ?{Trainer}( 2d20kh1    + 20) + ?{Ability} + Intelligence) That will look like this: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}|Dexterity,@{target|dexterity}|Constitution,@{target|constitution}|Intelligence,@{target|intelligence}|Wisdom,@{target|wisdom}|Charisma,@{target|charisma}} /roll ?{How many hours did you train?}[Hours] * ({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1[Roll] + ?{Did you have a trainer?}*({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1 + 20)[Trainer] + ?{Select which ability is used for training}[Ability] + @{target|intelligence}[Intelligence]) Or inline: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}|Dexterity,@{target|dexterity}|Constitution,@{target|constitution}|Intelligence,@{target|intelligence}|Wisdom,@{target|wisdom}|Charisma,@{target|charisma}} [[?{How many hours did you train?}[Hours] * ({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1[Roll] + ?{Did you have a trainer?}*({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1 + 20)[Trainer] + ?{Select which ability is used for training}[Ability] + @{target|intelligence}[Intelligence])]]
1724204537
GiGs
Pro
Sheet Author
API Scripter
Jarren, it looks like you've assumed that advantage means every d20 roll gets an extra d20 roll on advantage. I was thinking its probably one d20 to the total. So there's some ambiguity. Also, OP probably wnats advantage to be applied automatically on every roll of 4 or more hours.
1724206383

Edited 1724211343
GiGs said: Jarren, it looks like you've assumed that advantage means every d20 roll gets an extra d20 roll on advantage. I was thinking its probably one d20 to the total. So there's some ambiguity. Also, OP probably wnats advantage to be applied automatically on every roll of 4 or more hours. Whoops I missed the part about advantage being automatically applied if the Hours are 4 or greater. I've adjusted macro above with this for the advantage (instead of a query): [[{?{How many hours did you train?},0}>4]]d20}kh1 And good thought on the ambiguity of adding advantage to both rolls or not.  I've kept it on both for now as Lyriander said "When a player trains for 4 hours or more, the rolls in the macro are to be made at advantage."  and "My goal is to find out if it would be possible to include and advantage to all the d20 rolls ." Lyriander - if only one of the rolls should be made at advantage, then just remove that section from the other roll and replace it with 1d20 instead.
1724214418
GiGs
Pro
Sheet Author
API Scripter
Jarren said: And good thought on the ambiguity of adding advantage to both rolls or not.  I've kept it on both for now as Lyriander said "When a player trains for 4 hours or more, the rolls in the macro are to be made at advantage."  and "My goal is to find out if it would be possible to include and advantage to all the d20 rolls ." Well spotted, I missed those.
Thank you both for the answers. To answer your questions: I use the standard d20kh1 for advantage and d20kl1 for disadvantage. The results of step 1, 2, and 3 are all added together, and the result is the amount of Training Points accumulated for that training session. To further clarify, when 4 or more Hours are used, each of the d20 rolls is to be made at advantage, so at 4 hours it becomes 2d20kh1+2d20kh1+2d20kh1+2d20kh1 (for the initial roll anyway). Jarren said: It looks like the number of hours trained multiplies by everything, so the formula can be simplified a bit:      Hours * (1d20 + ?{Trainer}(d20 + 20) + ?{Ability} + Intelligence) Adding in advantage you need to adjust each of the d20 rolls:      Hours * (2d20kh1 + ?{Trainer}( 2d20kh1    + 20) + ?{Ability} + Intelligence) That will look like this: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}|Dexterity,@{target|dexterity}|Constitution,@{target|constitution}|Intelligence,@{target|intelligence}|Wisdom,@{target|wisdom}|Charisma,@{target|charisma}} /roll ?{How many hours did you train?}[Hours] * ({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1[Roll] + ?{Did you have a trainer?}*({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1 + 20)[Trainer] + ?{Select which ability is used for training}[Ability] + @{target|intelligence}[Intelligence]) Or inline: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}|Dexterity,@{target|dexterity}|Constitution,@{target|constitution}|Intelligence,@{target|intelligence}|Wisdom,@{target|wisdom}|Charisma,@{target|charisma}} [[?{How many hours did you train?}[Hours] * ({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1[Roll] + ?{Did you have a trainer?}*({1d20,[[{?{How many hours did you train?},0}>4]]d20}kh1 + 20)[Trainer] + ?{Select which ability is used for training}[Ability] + @{target|intelligence}[Intelligence])]] The macro you created works well, though it works a bit differently than I originally had in mind. Your macro rolls a die (or two if at advantage) for both the initial roll and the trainer roll each, and multiplies the total sum result with the amount of hours. My original macro rolls a number of dice equal to the amount of hours per instance (although I do realize this wasn't the case for the Trainer roll, which I should fix). So your macro gives me something this: 4*({(18)+( 13 )}+1*({(4)+( 1 )}+20)+12+19) = 292 Whereas I would be looking more for something like: (((11)+( 9 ))+((10)+( 9 ))+((18)+( 15 ))+((19)+( 14 ))) + ( ((7)+( 6 )+20)+((10)+( 8 )+20)+((15)+( 12 )+20)+((20)+( 11 )+20) ) + (4*(12+19)) = 314 Perhaps your version is more efficient and easier to incorporate, though the players will be left with a low result if they roll bad once, rather than on all the dice. I feel like it's similar to the old discussion "double the result of damage dice result vs roll twice the amount of dice" for critical hits. My apologies for the lack of clarity in my original post.
That style of advantage, with variable number of dice, isn't cleanly possible with the current dice roller. There is an open suggestion for custom dice syntax that could handle it nicely that you may want to vote for. However in the meantime I'd recommend creating a rollable table "d20adv" with values 1 to 20 and weightings of 1, 3, 5, etc. That table can mimic a d20 with advantage and can scale based on your training hours. The final roll (including the fix for trainer rolls) could then be [[?{How many hours did you train?|1} * (1+?{Did you have a trainer?|Yes,1|No,0}) * {?{How many hours did you train?},4}<3 ]]d20 + [[?{How many hours did you train?|1} * (1+?{Did you have a trainer?|Yes,1|No,0}) * {?{How many hours did you train?},3}>4 ]]t[d20adv] + ?{How many hours did you train?}*(?{Did you have a trainer?}*20 + ?{Select which ability is used for training | Strength,@{target|strength}| Dexterity,@{target|dexterity}| Constitution,@{target|constitution}| Intelligence,@{target|intelligence}| Wisdom,@{target|wisdom}| Charisma,@{target|charisma}} + @{target|intelligence}) It works by rolling d20's for 3 hours or less or rolling on the "d20adv" table for 4 hours or more. The fix for trainer hours just doubles the number of dice/table rolls giving it a roll per hour rather than a simple multiplier.
Wow RainbowEncoder, that certainly works! Thanks for the solution! Just to be sure, for the "d20adv" I wasn't entirely sure what you meant for the weightings. Did you mean the following pattern? 1 = 1 2 = 3 3 = 5 4 = 7 5 = 9 6 = 11 7 = 13 8 = 15 9 = 17 10 = 19 11 = 19 12 = 17 13 = 15 14 = 13 15 = 11 16 = 9 17 = 7 18 = 5 19 = 3 20 = 1
Ah wait, I found a neat explanation given by the mathematician Matt Parker . Apparently the weightiness just keeps going up by 2 all the way up to the 20. Thank you everyone for the contribution!
1724265142

Edited 1724265427
Lyriander D. said: The macro you created works well, though it works a bit differently than I originally had in mind. Your macro rolls a die (or two if at advantage) for both the initial roll and the trainer roll each, and multiplies the total sum result with the amount of hours. My original macro rolls a number of dice equal to the amount of hours per instance (although I do realize this wasn't the case for the Trainer roll, which I should fix). So your macro gives me something this: 4*({(18)+( 13 )}+1*({(4)+( 1 )}+20)+12+19) = 292 Whereas I would be looking more for something like: (((11)+( 9 ))+((10)+( 9 ))+((18)+( 15 ))+((19)+( 14 ))) + ( ((7)+( 6 )+20)+((10)+( 8 )+20)+((15)+( 12 )+20)+((20)+( 11 )+20) ) + (4*(12+19)) = 314 Perhaps your version is more efficient and easier to incorporate, though the players will be left with a low result if they roll bad once, rather than on all the dice. I feel like it's similar to the old discussion "double the result of damage dice result vs roll twice the amount of dice" for critical hits. Ah well this is a bit longer, but it should give you the Advantage roll that you're looking for (rolling the total number of dice twice and keeping the higher sum): Regular /roll: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}[Strength]|Dexterity,@{target|dexterity}[Dexterity]|Constitution,@{target|constitution}[Constitution]|Intelligence,@{target|intelligence}[Intelligence]|Wisdom,@{target|wisdom}[Wisdom]|Charisma,@{target|charisma}[Charisma]} /roll ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1)[Hours] + (?{Did you have a trainer?} * ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1 + ?{How many hours did you train?} * 20))[Trainer] + (?{How many hours did you train?} * (?{Select which ability is used for training}))[Ability] + (?{How many hours did you train?} * (@{target|intelligence}))[Intelligence]  Inline: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}[Strength]|Dexterity,@{target|dexterity}[Dexterity]|Constitution,@{target|constitution}[Constitution]|Intelligence,@{target|intelligence}[Intelligence]|Wisdom,@{target|wisdom}[Wisdom]|Charisma,@{target|charisma}[Charisma]} [[ ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1)[Hours] + (?{Did you have a trainer?} * ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1 + ?{How many hours did you train?} * 20))[Trainer] + (?{How many hours did you train?} * (?{Select which ability is used for training}))[Ability] + (?{How many hours did you train?} * (@{target|intelligence}))[Intelligence] ]] If you want a cleaner output and just want to see the results, you can add some additional inline roll calculations (using /roll still allows you to see the individual rolls when you hover over them and see the tooltip): ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}[Strength]|Dexterity,@{target|dexterity}[Dexterity]|Constitution,@{target|constitution}[Constitution]|Intelligence,@{target|intelligence}[Intelligence]|Wisdom,@{target|wisdom}[Wisdom]|Charisma,@{target|charisma}[Charisma]} /roll ([[{?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1]])[Hours] + ([[?{Did you have a trainer?} * ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1 + ?{How many hours did you train?} * 20)]])[Trainer] + ([[?{How many hours did you train?} * (?{Select which ability is used for training})]])[Ability] + ([[?{How many hours did you train?} * (@{target|intelligence})]])[Intelligence] Inline will hide the individual rolls completely: ! ?{How many hours did you train?} ?{Did you have a trainer?|Yes,1|No,0} ?{Select which ability is used for training|Strength,@{target|strength}[Strength]|Dexterity,@{target|dexterity}[Dexterity]|Constitution,@{target|constitution}[Constitution]|Intelligence,@{target|intelligence}[Intelligence]|Wisdom,@{target|wisdom}[Wisdom]|Charisma,@{target|charisma}[Charisma]} [[ ([[{?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1]])[Hours] + ([[?{Did you have a trainer?} * ({?{How many hours did you train?}d20,[[{?{How many hours did you train?},0}>4]] * ?{How many hours did you train?}d20}kh1 + ?{How many hours did you train?} * 20)]])[Trainer] + ([[?{How many hours did you train?} * (?{Select which ability is used for training})]])[Ability] + ([[?{How many hours did you train?} * (@{target|intelligence})]])[Intelligence] ]] (I also added an inline tooltip for the Ability modifier name to the 'Select which ability is used for training' query.)