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

Substractions in macros not working properly

April 26 (4 months ago)

Edited April 26 (4 months ago)

I am experimenting with macros for a custom game system and encountering a weird behaviour. The macro I am trying to make takes into account the number of attacks made and compares it to a specific target to return the number of hits.

The macro is as follow :
&{template:default}{{name=Shot}}{{Sucess= [[{?{# of shots ? }d100}<?{Aim}+?{Weapon bonus}+?{Range bonus}+?{Cover}+?{Maluses}]]}}

In most cases, it works just fine and returns the correct number of successes. However, I found that, since the cover attribute is always negative (so the number is inputed as -20 for example), it causes a bug when the attribute right before it is lower than the subtracted number.
So 4d100<50+0+0+-20+0 for example does not work but 4d100<50+0+20+-20+0 does work.

Example :

Does anyone know what can cause this behaviour and if there is a way to work around it ?

April 26 (4 months ago)

Edited April 26 (4 months ago)
Gauss
Forum Champion

Hi Tetsudo, 

I am not seeing a bug here. 

In your first example, you have 0 successes, then you add 20 and subtract 20. Thus it stays 0 successes. 
{51, 60, 92, 55}<50 is 0 successes then you add +0 +20 -20 +0 to get 0

In your second example you have 3 successes, then you subtract 20. Thus you have -17 successes. 
{76, 20, 16, 30}<50 is 3 successes, then you add +0 +0 -20 +0 to get -17

What should it state? 

April 26 (4 months ago)

Hi Gauss, I understand the logic as to why it says to me there are -17 successes but what I want is the number of d100 that are below the entire operation on the right.
So for the one where there is a problem, what I want is the number of d100 below (50+0+0-20+0) so below 30 so what I want is essentially 4d100 < 30 but without having to manually add and subtract the different factors.
I tried grouping the factors inside a parenthesis without success so I'm a bit lost.

April 26 (4 months ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Weap the entire calculation for the target number in inline roll brackets:

&{template:default}{{name=Shot}}{{Sucess= [[{?{# of shots ? }d100}<[[?{Aim}+?{Weapon bonus}+?{Range bonus}+?{Cover}+?{Maluses}]]]]}}
April 26 (4 months ago)
Gauss
Forum Champion


Tetsudo said:

Hi Gauss, I understand the logic as to why it says to me there are -17 successes but what I want is the number of d100 that are below the entire operation on the right.
So for the one where there is a problem, what I want is the number of d100 below (50+0+0-20+0) so below 30 so what I want is essentially 4d100 < 30 but without having to manually add and subtract the different factors.
I tried grouping the factors inside a parenthesis without success so I'm a bit lost.


Ahhh yeah, so you want to group all the modifiers to the right of the inequality. Scott's solution is the one you want. 

April 26 (3 months ago)

It works, thank you both.