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

variable number of dice using 2 conditions?

1422281278
Ziechael
Forum Champion
Sheet Author
API Scripter
Hi, i'm looking to write a macro that tells the system to roll x or 4 and drop the highest (keep the lowest if you prefer) d4. I've tried a few variables but might mind has blanked after a week of flu so i'm going to ask for help instead of soldiering pointlessly on. I have the simple: (@{selected|casterlevel}/2)d4 which uses the round function to ensure i'm getting the number of d4 i want (an extra 1 for each odd level; 1 @ 1, 2 @ 3 etc up to a maximum of 4d4 at level 7). However i can't for the life of me figure out how to put a kl or dh into the equation to cap it at 4d4? The full thing looks like this as there is a bonus of the caster level to add on too: [[(@{selected|casterlevel}/2)d4 + @{selected|casterlevel}]] Any help would be greatly appreciated! Z
1422285564
Diana P
Pro
Sheet Author
The dl or kl goes right after the d4: [[(@{selected|casterlevel}/2)d4kl4 + @{selected|casterlevel}]] If you need to also limit the bonus, it could be done with a comparision: [[(@{selected|casterlevel}/2)d4kl4 + {@{selected|casterlevel},7}dh1]] (limits the caster level to 7)
1422286913
Ziechael
Forum Champion
Sheet Author
API Scripter
GAH so simple and yet so beyond my tiny brain! Thanks so much, yet again, Diana :)
1422291115
Lithl
Pro
Sheet Author
API Scripter
Dropping or keeping some number of the d4s seems like a bad idea, as you then skew the probabilities for the roll. (if you keep the lowest 4, you get an average below the expected value, with the inverse for keeping the highest 4). The simplest solution which doesn't skew the results is to combine /roll and inline rolls: /roll [[{round(@{selected|casterlevel} / 2), 4}kl1]]d4 + @{selected|casterlevel} This solution doesn't permit you to do the whole thing inline, however.
1422291976

Edited 1422292091
Roger A.
Sheet Author
hmm, you could do it the way Diana suggested, but that can actually roll a lot more d4s than just 4, and it will only use the lowest 4 of the results so it should give you lower average results than if you did it with only rolling 4 dice. you could switch out the kl4 for kh4 but that gives you a slightly higher average result than only rolling 4 dice once you get into more than 4 dice being rolled. /r [[ { ceil(@{selected|casterlevel}/2), 4}kl1 ]]d4 + @{selected|casterlevel} will give you only 4 dice being rolled, so it gets around the slightly wrong probability distribution of the other methods, but since we can't nest inline rolls, and we need to put the kl1 inside an inline roll to get it to work as a dice number, you loose the ability to have the whole thing show up as an inline roll. If you can put up with the results being skewed slightly after caster level 8, then you just need to decide which direction you want to skew them, and you can use the inlines for the overall result. The other option is to leave the formula as (@{selected|casterlevel}/2) until they hit caster level 9, and just change it to 4d4 at that point... ninjad by brian....shouldnt have taken the time to put the pizza in the oven....
1422298661
Lithl
Pro
Sheet Author
API Scripter
Roger A. said: ninjad by brian....shouldnt have taken the time to put the pizza in the oven.... While you may have been beaten in making the post, it is always worth taking the time to make pizza.
1422303270
Ziechael
Forum Champion
Sheet Author
API Scripter
Thanks all, the varied opinions are always welcome and help expand my paltry knowledge lol.
1422452718
Ziechael
Forum Champion
Sheet Author
API Scripter
And now... how to apply this same logic to a power card ;) I want a damage output of xd8 (capped at 5) with x being determined by @{selected|casterlevel}/2. While /r [[ { ceil(@{selected|casterlevel}/2), 5}kl1 ]]d8 works beautifully normally it fails when used in a powercard :( Please note, when i post things like this i make sure to check all options first and refer to the dice reference extensively before asking for help! Cheers
The problem is that for Powercards you must use an inline roll. The problem with inline rolls that attempt to calculate the number of dice fail if you include "ceil", "floor" or "round" in the actual dice calculation. However, with that said it is important to note that even if you do not use the "round" explicitly in the calculation, it automatically does this. So in your case you need to make sure that the calculation is correct up to @{casterlevel} 10 because realistically above 10 it will always use 5, correct?
1422458159

Edited 1422458263
Also, based on your macro that works, it seems that the minimum caster level is 2 for this spell, correct? If yes, then you could use this to provide the correct results... but the tooltip is kind of ugly. !power --name|Damage Ability --Result|[[ {floor((@{casterlevel})/2),1}kl1*[NH]1d8+{floor((@{casterlevel})/4),1}kl1*[NH]1d8+{floor((@{casterlevel})/6),1}kl1*[NH]1d8+{floor((@{casterlevel})/8),1}kl1*[NH]1d8+{floor((@{casterlevel})/10),1}kl1*[NH]1d8]] Note, I included the [NH] option for the dice roll so it doesn't highlight strangely at levels lower than max (because in this macro all dice are rolled, but they are zeroed out if you don't meet the level requirements). Also you can add the "@{selected|" syntax, I just tested off of the sheet so I didn't need to setup a token.
1422459498
Ziechael
Forum Champion
Sheet Author
API Scripter
I did wonder if it was to do with the inline thing, the minimum level is actually 1 for this spell however with the auto round up factor 1 would still return a 1 when halved therefore giving the 1d8 i so crave...? Your second option seems to have some legs to it, very ugly legs but may well get me around the inline issue... thanks Kevin, i'll take a look using that.
So if the minimum level is actually 1, you can do the following instead (since there will always be a 1d8): !power --name|Damage Ability --Result|[[ [NH]1d8+{floor((@{casterlevel})/4),1}kl1*[NH]1d8+{floor((@{casterlevel})/6),1}kl1*[NH]1d8+{floor((@{casterlevel})/8),1}kl1*[NH]1d8+{floor((@{casterlevel})/10),1}kl1*[NH]1d8]] This would always give you 1d8 plus additional 1d8 at casterlevel 4, 6, 8, and 10.
1422469291

Edited 1422469692
The Aaron
Pro
API Scripter
Another option would be to write an API script that would maintain an attribute with the appropriate number for each character... !power --name|Damage Ability --Result|[[ @{wizard_cantripDice}d8 ]] This script looks for the caster level attributes (bard_level, cleric_level, etc) and calculates the number of dice a cantrip should do for the level in question, and update or create an attribute named 'bard_cantripDice' or the like. It will verify all instances of that attribute on startup, and update the attribute whenever the parent attribute is either created or updated. (I'm transitioning to GIT for my scripts in preparation for putting them in the Roll20 API repo... bear with me!) GIT: <a href="https://github.com/shdwjk/Roll20API/blob/prod/Spel" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/prod/Spel</a>...
@The Aaron - that is an interesting take, I was using a catrip_die field as an attribute until I could figure out a formula. One thing to note though is that cantrips are unique and work based off of total level rather than individual level. Your scriptomancy is much higher than my ability to comprehend (maybe someday, working up towards "Javascript: The Good Parts", but need to understand the basic parts better first), so I have a question, does your script factor in total level or just individual class levels?
1422477183
The Aaron
Pro
API Scripter
Ah, interesting. I haven't multi-classed in 5e yet, so that distinction escaped me. Mine is calculating based on the individual class levels. I'll adjust it to calculate based on a total level. I've been thinking that this script could really be generalized to managed derived attributes for a whole host of purposes... time to generalize!