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 .
×

Conditions in macro

Hi everbody In a game on roll20, our characters have an "Atk" attribute (for example 70). I wanted to create a macro to: 1) Try to attack (1d100 < atk) 2) If it is a sucess, then throw damage dice (1d10 for example) 3) Decrease a "mana" attribute (by 2 for example) even if it is a fail Is it possible to do everything in only one macro ?  
1561824316

Edited 1561824342
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Unfortunately, your macro attempts a couple of things macros can't do: 1. Macros do not have conditional logic. There is no "if-then" construction within a macro. 2. Macros cannot write values to anywhere but chat. They cannot change an attribute. Macros are essentially printouts to chat that can do dice rolls or give random results from tables (even this is not a true table lookup, just random, weighted returns). It is possible to do all of these things with the API and knowledge of JavaScript, but that requires a Pro subscription.
You can do some limited conditional logic using arithmetic. A sample Ability on a Character that reports a damage score on a hit an a 0 on a miss: /roll [[ 1d100<@{Atk} ]] * 1d10 If the d100 roll equals Atk or less, the number in the square brackets is 1, otherwise it's 0. Thus, the 1d10 roll is multiplied by 1 on a hit (equaling 1d10) or multiplied by 0 on a miss (equaling 0).
1562020536
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Good solution for the first problem, so long as the attack roll is not required to display.
Ok, Thank you for your answer