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
This post has been closed. You can still view previous posts, but you can't post any new replies.

In line rolls using floor() and ceiling()

This isn't a question, but just something that I have discovered. It may be known by others, and it may not, I just wanted to share it. In these two discussions (<a href="https://app.roll20.net/forum/post/364316/macro-to-restrict-the-maximum-modifier-per-level#post-366058" rel="nofollow">https://app.roll20.net/forum/post/364316/macro-to-restrict-the-maximum-modifier-per-level#post-366058</a>, <a href="https://app.roll20.net/forum/post/328661/shocking" rel="nofollow">https://app.roll20.net/forum/post/328661/shocking</a>... it was asked how to put level limits into spell macros. For instance, the shocking grasp spell causes 1d6 damage per level, but to a maximum 5d6 at level 5. In these discussions the following formula was given as the solution- /r 1d8+ Level-(Level-Maxlevel)*[[(floor(1/(floor(Level/Maxlevel)+1))-1)*(floor(1/(floor(Level/Maxlevel)+1))-1)]] (see the discussions for full details). However, it was also pointed out that this would only work as given, but when I tried to enter it in line (as /em [[1d8+ Level-(Level-Maxlevel)*[[(floor(1/(floor(Level/Maxlevel)+1))-1)*(floor(1/(floor(Level/Maxlevel)+1))-1)]]]]) it didn't work. After some fiddling with it I found a way to make it work in line. Enter it in as /em [[1d8]] + [[Level-(Level-Maxlevel)*[[(floor(1/(floor(Level/Maxlevel)+1))-1)*(floor(1/(floor(Level/Maxlevel)+1))-1)]]]]. The result will show in the chat log as two numbers added together (#+#). For example, a cleric in our game casts cure light wounds. In the chat long it reads "Alatien touches Avril restoring 7+5 hit points." Just thought others might be interested. If this is the wrong use of the forum I apologyze.
Interesting! FYI, the Keep / Drop function now provides a friendlier way to bound functions. e.g. Damage: [[ [[ {@{level}, 5}kl1 ]]d6 ]]
It works beautifully. You can even use it to add the level to a roll, with limits, such as cure spells. While [[ [[ {@{level}, 5}kl1 ]]d6 ]] will roll dice equal to the level limit, [[1d8+ [[ {@{level}, 5}kl1 ]] ]] will roll 1d8 and add the level limit as a modifier.