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 .
×
Why do rogues wear leather armor? Because it’s made of hide. 🥷

Macro: Keep High or Low Based on Input

Hi folks, Hoping you can help me out. Rules: Base 2d6 How many additional dice are being rolled?     If positive, add additional dice and keep the 2 highest results.     If negative, add additional dice and keep the 2 lowest results. Then add a +/- modifier. Example 1 (Keep High): 2d6 plus +4 dice plus -3 modifier Rolls 6d6k2-3 Example 2 (Keep Low): 2d6 plus -2 dice plus -1 modifier Rolls 4d6kh2-1 This is a working* keep high prompt *(have to manually add the base 2d6 to the query.) : &{template:default} {{name= Combat Roll}} {{Result= [[?{Number of Dice}d6k2+?{Armour}]]}} Thanks!
1776707673
Gauss
Forum Champion
You will not be able to use the same query to apply both a number of dice and a different kh/kl scheme as you have written above.  Instead, I suggest pulling the d6kh/kl logic into the query.  How many dice is the maximum number of dice rolled (positive or negative?)
Thanks, Gauss. I'm not sure if there is a limit... the highest I've seen in game has been 8 total but we're low level so I suspect the additional dice may increase at higher levels.
1776709526
Gauss
Forum Champion
So what I'd do then is use an attribute that you can adjust and then put that into the macro.  Example:  &{template:default} {{name= Combat Roll}} {{Result= [[@{dice}+?{Armour}]]}} Next, the dice attribute:  ?{Number of Extra Dice?|0,2d6|+1,3d6kh2|+2,4d6kh2|-1,3d6kl2|-2,4d6kl2} You can flesh that out to as high (and low) as you'd like. 
Whilst you cannot change between kh and kl with a simple number query; you can use the fact that dh can be used instead of kl and that both kh and dh can appear together to achieve what you want &{template:default} {{name=Combat Roll}} {{Result=[[ (2+[[0+abs(?{Additional Dice|0})]])d6kh[[2-{0,?{Additional Dice} }kl1 ]]dh[[0-{0,?{Additional Dice} }kl1]] + (?{Armour})]] }} With positive additional dice it keeps the highest 2 but drops none With negative additional dice it keeps all then drops the highest all but 2 (effectively keep lowest 2)
Amazing! Works like a charm. Thanks you two :D
1776712132
Gauss
Forum Champion
RainbowEncoder uses arcane magics that few understand.  Thanks RainbowEncoder :)