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

Help reusing roll in a macro

Hi! We use a custom D100 system and i would like to find/write a macro roll for it: When a player roll a dice for attacking, the damages will depends on "how much" he success like: My player roll 1d100<70, 33, he success by 70-33 = 37. Now from this 37 we count how much "5" we can fit in it, the answer is 7 (7*5=35) so his success rate is 7 and it'll add 7 to his damages. So i'm searching for a macro to do this automatically, like my player roll "1d100<70" and if the result is 37 the script should output something like:"37, success rate=7" In simple maths, i would like to do something like: - My player use the macro lire "/rs {SkillLevel} (which is 70 in my previous instance) - My player roll, i store the variable {RollResult} - Maths: {SuccessRate}=ROUNDDOWN(({SkillLevel}-{RollResult})/5) - Output: "Result: {RollResult}, success/fail by {SuccessRate}" Do anybody know a macro that can do something similar or any tutorial that would help me to make this? I already read the "Reusing Rolls" wiki page but i'm not good enough with macro to make mine with this (i don't understand how to use & store variable in a macro). Thanks!
1600598557

Edited 1600599177
Oosh
Sheet Author
API Scripter
Something like this should do the job: &{template:default} {{name=Skill Roll}} [[ floor(abs({[[1d100]]-?{Skill Level|37},0}kl1/5)) ]] {{Roll Result=$[[0]] vs ?{Skill Level}}} {{Success Rate=$[[1]]}} You might want to change the default Skill Level, or change it to an @{Attribute} reference if it's recorded on a character sheet. You could also add some success/failure coloring if you'd like, change the roll to: [[ floor(abs({[[1d100cf>?{Skill Level|37}cs<?{Skill Level}]]-?{Skill Level},0}kl1/5)) ]] Green for rolling under, red for rolling over, and blue for exact. edit - corrected the math
1600603681
GiGs
Pro
Sheet Author
API Scripter
M.J  said: Now from this 37 we count how much "5" we can fit in it, the answer is 7 (7*5=35) so his success rate is 7 and it'll add 7 to his damages. Just to check if 0s are valid, if a character has a skill of 40, and rolled a 37, what is the success rate?
GiGs said: M.J  said: Now from this 37 we count how much "5" we can fit in it, the answer is 7 (7*5=35) so his success rate is 7 and it'll add 7 to his damages. Just to check if 0s are valid, if a character has a skill of 40, and rolled a 37, what is the success rate? It's 0, it's a success but without any bonus.
1600604140
GiGs
Pro
Sheet Author
API Scripter
Great - was just checking because if the minimum was 1 (I have seen some systems that work like this), Oosh's macro would need some tweaking.
Oosh said: Something like this should do the job: &{template:default} {{name=Skill Roll}} [[ floor(abs({[[1d100]]-?{Skill Level|37},0}kl1/5)) ]] {{Roll Result=$[[0]] vs ?{Skill Level}}} {{Success Rate=$[[1]]}} You might want to change the default Skill Level, or change it to an @{Attribute} reference if it's recorded on a character sheet. You could also add some success/failure coloring if you'd like, change the roll to: [[ floor(abs({[[1d100cf>?{Skill Level|37}cs<?{Skill Level}]]-?{Skill Level},0}kl1/5)) ]] Green for rolling under, red for rolling over, and blue for exact. edit - corrected the math Thanks! But with this i need to add all their skills with skill level on their character sheet & they have to roll using one different macro for each skill right? Is there a way to make this like a command with an arg? like "/rs {skilllevel} and they just enter their skill level?
1600605360
GiGs
Pro
Sheet Author
API Scripter
This part: ?{Skill Level|37} is a query. It is exactly what you want. It is a popup form that lets players enter a skill value (the |37 part says 37 will be inserted by default, you can change the number to something else).
1600609620

Edited 1600609992
Oh yes i just tried, it works like a charm! Many thanks for all! Is there a way to color the window & change the title depending on if it's a success or a fail?