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

Macro for keeping higher of 2 values

1427408809

Edited 1427409146
Hi I'm new to macros and was trying to create one that picked the higher of a rolled value and a max value /me ...[[(DIE ROLL CALCULATION, MAX)kh1]]... The calculation works fine, but does not output the max value when the calculation is above the max, it just keeps the calculated value. So, I'm guessing I haven't coded this correctly, but I can't find anything to help me out. All the examples use /roll. Can you not use [[...]] with the keep highest/lowest die function? the full code is: [[@{LEVEL} + (ceil((1d20+ @{CHA})/3) - 4), 4)kh1]] The entire sequence is: /me holds forth a glowing holy symbol and turns or rebukes a total of [[2d6 + @{LEVEL} + @{CHA}]] hit die of creatures up to [[@{LEVEL} + (ceil((1d20+ @{CHA})/3) - 4), 4)kh1]] hit die each. which simulates the d&d 3.5 cleric turn undead check and damage (yes, I know I can make a simpler die roll and check the table...but I enjoy complicating my life :) ) Thanks
1427416983

Edited 1427417546
Gauss
Forum Champion
Here you go: [[ @{LEVEL} + {(ceil((1d20 +@{CHA})/3) -4) , 0d0+4}kh1 ]] Also, all sections of keep/drop needs to be either dice rolls or non-dice rolls so I added 0d0. Note: I am not sure where you wanted @{LEVEL} so it may be in the incorrect place (outside of the {} instead of inside the {} ).
Thanks. I did try the 0d0 at one point. So, for example, if I use the formula you've provided with a CHA of 15 and LEVEL 2 and roll an 18 the value returned is 9, not the max of 6. I've also put the LEVEL into the brackets and then with the calculation of the max value and that doesn't seem to work either. Is kh1 part of the API or something? I'm not yet a contributing member.
1427426237

Edited 1427427002
Gauss
Forum Champion
Paul , you didnt have "{}" so it wasn't doing kh1. No, kh1 is not part of the API. What I gave you was what you posted but corrected. According to your formula you should have: Level + (the greater of (round up((1d20+charisma)/3 -4)) or 4). Putting in the numbers you just gave shows that the above formula is working correctly: 2 + (greater of ((18+15)/3 -4) or 4) = 2 + (greater of (33/3) -4) or 4) = 2 + (greater of (11) -4) or 4) = 2 + (greater of (7) or 4) = 2 + (7) = 9 If you give me the math formula without Roll20 commands I can see if there is a way to make it work for you. Edit: I think I see the problem (had to re-read 3.5 rules, it has been several years). You are using the Charisma score, not Charisma modifier. Replace @{CHA} with whatever is the Charisma Modifier Attribute.
1427427422
Diana P
Pro
Sheet Author
if you're using the 3.5 sheet, the charisma mod is @{cha-mod}
1427429072

Edited 1427429279
WOW! Yes, what a silly mistake. It happened when I was trying to do a Min/Max thing and couldn't get that to work properly and then tried to go back to my original and deleted the wrong part. (I made up my own attributes. CHA is the charisma modifier. But I guess I should change that, might want to do a charisma contest at some point :) ) Ok. So that works perfectly. Thanks. Looking at your syntax also helped me figure out the Min part too. So my final working macro for the cleric turn dead ability in D&D 3.5 is: /me holds forth a glowing holy symbol and turns or rebukes a total of [[2d6 + @{LEVEL} + @{CHA}]] hit die of creatures up to [[ @{LEVEL} + {{(ceil((1d20 +@{CHA})/3) -4) , 0d0+4}kl1,0d0-4}kh1 ]] hit die each. All affected creatures with [[floor(@{LEVEL}/2)]] hit die or less EXPLODE! where CHA is the charisma modifier, and LEVEL is the cleric level Thanks again.