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

Using the success macro function as a variable?

1525635225

Edited 1525635838
Okay, first off.  I have literally no idea how to use or even access the API for a campaign.  This will be the first time I've ever attempted to do so. As the title states, I'm hoping to use the success roll function as a variable to either hide or show information within a roll template. Since the Success function (when set correctly) can return either a 1 or a 0, I'd like to use this as a binary gate to display the next set of information and/or make rolls based off it. For example: 1d100>45, Result = 46 the game should then check for crit 1d100>77, Result = 89 With these two success variables equaling 1 the template should both roll damage, and add the variable to the critical multiplication: I.e.: [[@{Attack}*((2+@{critbonus})*crit.var)-@{target|Defense}]] This should show up as either regular damage, minus the target's defense if it isn't a crit, or multiply the total critical value by 0 or 1 if the Critical check was a success or not. All of this removes a lot of clutter from the screen if information is hidden if an attack misses, or an attack doesn't crit.
1525642960

Edited 1525643060
Ziechael
Forum Champion
Sheet Author
API Scripter
You'll either end up with 0 damage or some damage but something like the following would work (i'm not sure how your system works so I've had to summarise some things): Ziechael deals [[ [[ (1d20-2)*[[1d100>22]] ]] * [[ {1d20*[[1d100>30]],1d1}kh1 ]] ]] damage! To explain the above I'll replace the hard coded values below: Ziechael deals [[ [[ ([damage]-[target defence])*[[1d100>[attack target] ]] ]] * [[ {[crit multiplier]*[[1d100>[crit target] ]],1d1}kh1 ]] ]] damage! You may have to rearrange to suit your system but the general idea is that you multiply your damage by 0 or 1 depending on whether or not you hit, you then multiply that by your crit multiplier (which I assume would be higher than a 1?) if a crit success is rolled or it is multiplied by a 1 if the crit fails which gives you your basic damage. Sadly there would be no way to alter the padding so you'd have something like: With the only way of knowing a crit was applied by hovering over the result: In this case a crit wasn't applied since the damage was only multiplied by 1 :( And when you don't even hit you get the following (no hit and no crit... a bad day at the office): Hopefully that sets you on the road to an answer?
Ziechael said: You'll either end up with 0 damage or some damage but something like the following would work (i'm not sure how your system works so I've had to summarise some things): Ziechael deals [[ [[ (1d20-2)*[[1d100>22]] ]] * [[ {1d20*[[1d100>30]],1d1}kh1 ]] ]] damage! To explain the above I'll replace the hard coded values below: Ziechael deals [[ [[ ([damage]-[target defence])*[[1d100>[attack target] ]] ]] * [[ {[crit multiplier]*[[1d100>[crit target] ]],1d1}kh1 ]] ]] damage! You may have to rearrange to suit your system but the general idea is that you multiply your damage by 0 or 1 depending on whether or not you hit, you then multiply that by your crit multiplier (which I assume would be higher than a 1?) if a crit success is rolled or it is multiplied by a 1 if the crit fails which gives you your basic damage. Sadly there would be no way to alter the padding so you'd have something like: With the only way of knowing a crit was applied by hovering over the result: In this case a crit wasn't applied since the damage was only multiplied by 1 :( And when you don't even hit you get the following (no hit and no crit... a bad day at the office): Hopefully that sets you on the road to an answer? It's more like... I need a way to make a template show results based off of the success Function.  As it can return a 0 or 1 value.  By using this, I should be able to tell the game through the API whether or not to show information.  I'm not 100% sure how to explain it but basically if the check results in a 0 for the to-hit roll, the game shouldn't roll for damage and instead show: "Bandit attacks with Iron Axe, but misses <target>!" Where if it hits: "Bandit attacks with Iron Axe and deals 9 damage to <target>!" And if it crits: "Bandit attacks with Iron Axe and crits for 18 damage to <target>!"
1525644463

Edited 1525644530
Ziechael
Forum Champion
Sheet Author
API Scripter
Ahh I see, well then I would suggest  Powercards , conditional logic abound :) The script is well documented and here is the wiki entry for using the  API generally, you won't need much beyond where to go and how to add a script. Powercards is a powerful and daunting script... don't be afraid to post your needs in the linked thread, the community will give you a great head start to learning the options you'll have at your disposal.