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

Help making a more efficient macro

December 03 (8 months ago)

Hey there!  I'm not the best at macroing things in R20 and I'm trying to find a way to setup some stuff for skill use.

What I'm hoping is that the following would be true:

AttributeResult
00
12
24
37
410
514

It doesn't need to be a formula that works for any other attributes, but I'm hoping to find something that if the attribute is on the left, that the macro spits out the right.  I don't know how to do this efficiently.  Any help appreciated.

December 03 (8 months ago)

Edited December 03 (8 months ago)
Gauss
Forum Champion

Hi Gary M,

This should work for you:

[[{@{charactername|attributename},@{charactername|attributename}-1}>1*2 + {@{charactername|attributename},@{charactername|attributename}-1}>3*3 + {@{charactername|attributename},0}>5*4]]


Please replace @{charactername|attributename} with the charactername and attribute name. 

How it works: 

{@{charactername|attributename},@{charactername|attributename}-1}>1*2
This part checks for a "1" and a "2" (2-1) and compares that to a target number of 1. Each success is multiplied by 2.
So if the attribute is a 1 = 1*2 = 2 and if the attribute is a 2 = 2*2 = 4

{@{charactername|attributename},@{charactername|attributename}-1}>3*3
This part checks for a "3" and a "4" (4-1) and compares that to the target number of 3. Each success is multiplied by 3. 
So if the attribute is a 3 = 1*3 = 3 and if the attribute is a 4 = 2*3 = 6

{@{
charactername|attributename},0}>5*4
This part checks for a "5" and compares that to the target number of 5. Each success is multiplied by 4. 
So if the attribute is a 5 = 1*5 = 5

Then all the results are summed. 


December 03 (8 months ago)
The Aaron
Roll20 Production Team
API Scripter

Mathematically, a formula that generates that is:

N*2 + Max(N-2,0) + Max(N-4,0)
Translating that to a macro is harder.   Can you just use a Rollable table with the values 0,2,4,7,10,14 ?

December 03 (8 months ago)

Similar to Gauss':

[[{[[0@{selected|attribute}]],0}>1*(2) + {[[0@{selected|attribute}]],0}>2*(2) + {[[0@{selected|attribute}]],0}>3*(3) + {[[0@{selected|attribute}]],0}>4*(3) + {[[0@{selected|attribute}]],0}>5*(4)}]]
December 04 (8 months ago)

Edited December 04 (8 months ago)
GiGs
Pro
Sheet Author
API Scripter

As you can see, there a lot of ways of doing this but none of them are straightfotrward.

This is the one I'd use

/r {1,1,2,2,3,3,3,4,4,4,5,5,5,5}<@{attribute}

or for inline roll syntax

[[{1,1,2,2,3,3,3,4,4,4,5,5,5,5}<@{attribute}]]

which you could use in a roll template.


This compares @{attribute} against the numbers shown, and counts how many are equal to or under that total. If you repeat any numbers, it is counted again for each repeat.

You might need to use @{charactername|attribute} or @{selected|attribute} if using it in a macro (as opposed to a character ability).


December 04 (8 months ago)

Edited December 04 (8 months ago)
GiGs
Pro
Sheet Author
API Scripter


The Aaron said:

Mathematically, a formula that generates that is:

N*2 + Max(N-2,0) + Max(N-4,0)
Translating that to a macro is harder.

This is the Keep High method, which would be

/r @{ability} *2 + { @{ability}-2, 0 }kh1 + { @{ability}-4, 0 }kh1