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

dynamic in-line Caster Level variable dice Rolls

1403921672

Edited 1403921703
I'm trying to simplify my spell macros to auto roll the appropriate number of dice based on caster level using only inline expressions. I've seen posts suggesting use of "/r [[{floor(@{casterlevel}/2),5}dh1]]d4" to roll caster level variable dice, however that solution is not what I need. I need something that is completely inline to replace my current [[?{Number of Dice (½Caster Level, Max:5)|5}d4]] expression to remove the need for user input when casting such spells. Formulas that I have tried: [[{{floor(@{casterlevel}/2),5}dh1}d4]] (returns Undefined) [[{{@{casterlevel}/2,5}dh1}d4]] (returns Undefined) [[({floor(@{casterlevel}/2),5}dh1)d4]] (returns #dice does not roll) ex: [[({floor(10/2),5}dh1)d4]] returns 5 [[({@{casterlevel}/2,5}dh1)d4]] (returns #dice does not roll) ex: [[({10/2,5}dh1)d4]] returns 5 [[((@{casterlevel}-1)/2)d4]] (rolls correctly but does not cap #dice) I have read the dice reference article on order of operations and have sense learned that the floor() function resolves at the end of the expression and as such cannot be used in this sort of formula I believe that the dh1 function likely also can't be used in this formula either since [[((@{casterlevel}-1)/2)d4]] works but lacks the caster level cap for the spell so is there any other way to accomplish this?
1403928526
Gauss
Forum Champion
Without the API (a mentor level feature) your best bet is to use the very last formula and then change formulas when you max out.
I was hoping for a more hands-off solution but I suppose if thats the only option it'll have to do. if anyone does figure out another option i'd love to hear it
1403934874

Edited 1403934971
Lithl
Pro
Sheet Author
API Scripter
Try this one: [[(-0.0242082 * @{casterlevel} * @{casterlevel} + 0.760253 * @{casterlevel} - 0.758772 + @{casterlevel} / 100)d4]] The first part is a quadratic best-fit curve up to caster level 20 (it actually works at 21, as well, but that's just fortune rather than design): -0.0242082 x^2+0.760253 x-0.758772 The last part adds just a little bit to the result, so that it rounds properly at both 10 (requires approximately +0.08) and at 5 (requires less than +0.07). This solution is not easily extensible, but should give correct results for level/2, max at 5.
1403978739

Edited 1403980224
Brian said: Try this one: [[(-0.0242082 * @{casterlevel} * @{casterlevel} + 0.760253 * @{casterlevel} - 0.758772 + @{casterlevel} / 100)d4]] The first part is a quadratic best-fit curve up to caster level 20 (it actually works at 21, as well, but that's just fortune rather than design): -0.0242082 x^2+0.760253 x-0.758772 The last part adds just a little bit to the result, so that it rounds properly at both 10 (requires approximately +0.08) and at 5 (requires less than +0.07). This solution is not easily extensible, but should give correct results for level/2, max at 5. if I were to use this formula then what would the values be for the following: Lv/2, Max: 10 (Fireball, Lightningbolt, etc) Currently: [[((@{casterlevel}-1)/2)d#]] 2*Lv/4, Max: 2*4 or Lv/2 Max: 8 (Force Missiles) Currently: [[(((@{casterlevel}-3)/4)*2)d#]] or [[((@{casterlevel}-3)/4)d#+((@{casterlevel}-3)/4)d#]] or [[((@{casterlevel}-1)/2)d#]] Lv/4, Max: 3 (Various Rays) Currently: [[((@{casterlevel}-3)/4)d#]] Lv/5, Max: 5 (A few utility spells) Currently: [[((@{casterlevel}-4)/5)d#]] The campaign i'm in goes well into epic levels also, so if the formula breaks after 21st then it's probably not worth using in this campaign... at least not with such complexity...
1403990356
Lithl
Pro
Sheet Author
API Scripter
I can get you an equation for those cases, but if you need it to work up to epic levels, that's quite tricky and will result in something more complicated, which isn't exactly what you're looking for. Hell, I could give you an equation that gives you exact results, but it would require @{casterlevel} being raised to higher and higher exponents (max level - 1 to be precise, using polynomial interpolation).
sounds like It'd be much less complicated to remember to switch the dice rolls over to static once they exceed their cap then.... it's a shame that the keep/drop functions don't work for variable dice rolls