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

Conditional Macros

Is there any way to make a macro reads my ability and gives me a result based on that ability on other rolls non-associated with that ability?
Exg: A macro reads my hp and gives me temporary hit points if I'm under half my max hp when I use a power?

January 21 (10 years ago)
Unfortunately conditional logic is not available as part of macros. What you are looking to do could be scripted via the API. The API is a mentor only feature.

It is important to understand that only the GM needs to be a mentor in order for all players to benefit from the use of APIs. Also while the API is really a great feature of the subscription, there are several other great features that are included as well.

https://app.roll20.net/account/supporter/?topbarma...

January 22 (10 years ago)

Edited January 22 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

If you can reduce your condition to 0 or 1, and the result you want is numeric, you can multiply the condition (or 1 - condition, depending on needs) by the result to give you either 0 or the appropriate result. Scratching something out quickly for your described problem:

/me gains [[{abs(floor(@{hp|max} / @{hp} / 2)), 1}kl1 * 3d8]] temporary hit points

(Assuming the number of temporary hit points gained is 3d8)

Testing:

/roll {abs(floor(50 / 100 / 2)), 1}kl1 * 3d8
= 0

/roll {abs(floor(50 / 50 / 2)), 1}kl1 * 3d8 = 0 /roll {abs(floor(50 / 26 / 2)), 1}kl1 * 3d8
= 0

/roll {abs(floor(50 / 25 / 2)), 1}kl1 * 3d8
= 8+7+5 = 20

/roll {abs(floor(50 / 24 / 2)), 1}kl1 * 3d8
= 1+7+2 = 10

/roll {abs(floor(50 / 1 / 2)), 1}kl1 * 3d8
= 6+6+8 = 20

/roll {abs(floor(50 / -10 / 2)), 1}kl1 * 3d8
= 4+7+2 = 13

/roll {abs(floor(50 / -25 / 2)), 1}kl1 * 3d8
= 4+2+5 = 11

/roll {abs(floor(50 / -50 / 2)), 1}kl1 * 3d8
= 2+1+5 = 8
January 22 (10 years ago)
That is a pretty interesting way to handle that!
Thanks a lot Brian. That kind of thing is what I was looking for. I tested the macro and it worked just fine with the power.

The power in use is Warforged's Resolve:
Effect: You gain a number of temporary hit points equal to 3 + one-half your level. You can make an immediate saving throw against one effect that deals ongoing damage and can be ended with a save. In addition, if you are bloodied you regain hit points equal to 3 + one-half your level.

/em uses Warforged's Resolve.
/em gains [[floor(@{Warforged|level}/2)+3]] temporary hp and can make a saving throw [[1d20]].
/em gains [[{abs(floor(@{hp|max} / @{hp} / 2)), 1}kl1 * (floor(@{Warforged|level}/2)+3)]] hit points.

Is there anyway to not show the last line if the value is zero because not being bloodied? I don't think so but, you know...
January 22 (10 years ago)
No, not currently.
January 22 (10 years ago)
Gen Kitty
Forum Champion
Actually, there's a way to do it! This is taking advantage of the system-parser interpreting any line starting with ! as a call to API scripts.

Do this for your macro:
/em uses Warforged's Resolve.
/em gains [[floor(@{Warforged|level}/2)+3]] temporary hp and can make a saving throw [[1d20]].
?{Bloodied Check|!}/em gains [[{abs(floor(@{hp|max} / @{hp} / 2)), 1}kl1 * (floor(@{Warforged|level}/2)+3)]] hit points.

When you run this macro, you'll get a prompt stating 'Bloodied check' with a ! in the box. If you're bloodied, remove the ! and accept the value. If you're not, leave in the !. Leaving in the ! will effectively comment out that line of the macro (because it is trying to call an API which doesn't exist) and it will not be processed further and the line will not appear.
January 22 (10 years ago)
Wow...learning all kinds of interesting things today, that's a neat one!
January 22 (10 years ago)
Gen Kitty
Forum Champion
I can't take credit for this one, I think it was Gold that taught me this one. 99% sure :>