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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Average

Hello, i want to do a macro like this : Roll D20 =or< Average (AgilityStat/StrenghStat) Is that possible ? Thanks a lot
1520255950
Ziechael
Forum Champion
Sheet Author
API Scripter
On my phone but: 1d20<[[ (@{agilitystat}+@{strengthstat})/2 ]] That would give you the a success count against the number?
1520261212

Edited 1520261293
It doesn't work : 1d20<[[ (@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2 ]] Result : 1d20<13.5
1520261596
The Aaron
Pro
API Scripter
Use: /r 1d20<[[ (@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2 ]] or [[1d20<[[ (@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2 ]]]]
It always show "1" for the result :S
1520263994
The Aaron
Pro
API Scripter
Hmm.  It seems like putting a formula in the inline roll causes it to always be a 1.  That's bizarre.  If you put the number, it would work.  Even putting the number inside an inline roll works.  The introduction of a formula breaks it. Unrelated, with 4 items summed up, you'd want to divide by 4 to get the average, not 2. This is probably a bug that should be posted in the bugs forum.
I have seen this happen before for attributes. If you put a 0 at the front of the inline roll for the comparison, it should work. [[1d20<[[ 0+ (@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2 ]]]]
1520264591
Ziechael
Forum Champion
Sheet Author
API Scripter
Hmm, in my testing I was able to get some 0 results... I guess it was likely breaking due to the fact that the average wasn't being calculated correctly (dividing by 2 instead of 4) which was likely always higher than 20? I hardcoded values of 18 and 12 (average 15) named as in the OP and the formulas didn't break the roll results:
1520264854
The Aaron
Pro
API Scripter
Actually, it looks like this will work: [[1d20<[[ floor((@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/4) ]]]] or /r 1d20<[[ floor((@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/4) ]]
1520264890
The Aaron
Pro
API Scripter
Seems like the remainder breaks things.  Could also use round(), which might be better.
1520265486
Ziechael
Forum Champion
Sheet Author
API Scripter
Good call, serves me right for only testing whole numbers!
the result must be under the average of strengh(Force) and agility(Adresse). I tried your macro Aaron. It show 1 or 0 sometimes but the resultat is incorrect
It say Rolling 1d20<6 but the Strengh(Force)+Mod for the character Darkam is 14+3 and the agility(Adresse)+Mod is 12-2. (17+10)/2=13.5 not 6 :s
it's ok you've put divide by 4 instead of 2 ! thx !
Just a little thing to add please ^^ If it's a success I want to throw a dice... Can I add something to this macro ?
1520271225
The Aaron
Pro
API Scripter
What do you mean "throw a die" ? You could take the above and use it as the number of dice in an expression: /r [[1d20<[[ floor((@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2) ]] ]]d8
Sorry for my english ;) Your macro : [[1d20<[[ floor((@{Darkam|Adresse}+@{Darkam|AdresseMod}+@{Darkam|Force}+@{Darkam|ForceMod})/2) ]]]] Is Ok for me thanks a lot ! It will be quickly now ;) Now to finalise it I want to add : If the result is ok (<Agility+Strengh/2...) And If the result of the 1d20 is 1 then it launch another macro (The attack of the character sheet+A Critical bonus) If the result of the 1d20 is more than 1 then it launch another macro (The attack of the character sheet) Do you understand ? ^^
1520273059
The Aaron
Pro
API Scripter
The best you could hope for without either the API or a custom roll template is to always roll the critical damage and multiply it by the result of this formula, thus making it 0 if there is no critical.
Ok thanks a lot !!!!