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?

As the title states, I'm wondering if you can use the Success Macro function to store and use as a variable in a single macro roll. For example: [[1d100>[[100-((@{acc}+(10*?{wadv?|0}))-@{target|avoid})]]]] This function above checks to see if your attack hit, with other variables to determine it.  I'm wondering if you can use this success binary value 0 or 1 to track and compare against other functions.  Specifically for rolling for damage if the function above results in a 1, and skipping the damage roll if it's a 0. 1d100>[[100-(@{critc}-@{target|cavoid})]] This function checks for a critical strike, I'm not 100% sure how to use the "ifwascrit" function in part of the Template, or even if it's a default function.  Either way, this check will use a binary value to add your critical strike multiplier to damage if it were a critical.
1525568755
GiGs
Pro
Sheet Author
API Scripter
Are you asking about editing a character sheet, or standard roll macros? A standard macro cant use the result of a roll as a variable. It has no flow control, or conditional logic support. You can  evaluate your hit roll as 0 or 1 (critical), and thus show critical damage, but this would replace the normal roll, so you wouldnt also be able to see if you got an ordinary success or fail. A character sheet rolltemplate can be written to show different additional effects on a critical (when you'd use ifWasCrit), but it still has limitations. It wouldnt eb able to add the two damage results for instance (you can't perform arithmetic inside a rolltemplate). Since you're a pro user, the PowerCards script might be able to do what you need, or an API script could be written to do it.
G G said: Are you asking about editing a character sheet, or standard roll macros? A standard macro cant use the result of a roll as a variable. It has no flow control, or conditional logic support. You can  evaluate your hit roll as 0 or 1 (critical), and thus show critical damage, but this would replace the normal roll, so you wouldnt also be able to see if you got an ordinary success or fail. A character sheet rolltemplate can be written to show different additional effects on a critical (when you'd use ifWasCrit), but it still has limitations. It wouldnt eb able to add the two damage results for instance (you can't perform arithmetic inside a rolltemplate). Since you're a pro user, the PowerCards script might be able to do what you need, or an API script could be written to do it. Yeah, I was hoping to avoid using the API, but I guess it's unavoidable.  I hope implementing Binary Variable checks based off of the Success function won't be too difficult.  But it's programming.  Nothing's simple in programming.
Oh and yes, I will be using a sheet.  So that might make things easier for using the API.
1525643678
Ziechael
Forum Champion
Sheet Author
API Scripter
Cross post from  here : 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?