Movement based on result of roll

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
SzassT
Cave Troll
Posts: 30
Joined: Sun Apr 30, 2017 4:32 pm
Location: Fort Smith, AR

Movement based on result of roll

Post by SzassT »

I'm trying to make a macro for racing. My intention is that a character moves (Race Check*10)ft each round for a race. I was wondering if it is possible to have a macro that rolls 1d20+Racing and moves the token the appropriate distance in a straight line based on the result. Overall, my goal is to make a macro for horse races where I can simply select a group of horses and press one button per check so players can see the race in action. Assuming the horses (or whatever token) has a property on their stat sheet called "Racing" (without the quotes), does anyone know how to make a macro for this? I'm assuming it is either very simple and I'm missing something, or very complex. Any help is appreciated.

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Movement based on result of roll

Post by aliasmask »

You want to use Wiki: getTokenX() and Wiki: getTokenY() and depending on direction of the race add your random value to the coordinate. Then use Wiki: moveToken() to put in new value.

SzassT
Cave Troll
Posts: 30
Joined: Sun Apr 30, 2017 4:32 pm
Location: Fort Smith, AR

Re: Movement based on result of roll

Post by SzassT »

Thanks for your reply! So I tested out this macro:

Code: Select all

[h: CurrentX = getTokenX(0)]
[h: CurrentY = getTokenY(0)]
[h: NewX = CurrentX + 1d20+getProperty("Racing")]
[h: NewY = CurrentY]
[h: moveToken(NewX, NewY)]
with Auto Execute and Apply to Selected Tokens checked. The result moves the token a static distance diagonally (mostly up, a little to the right). Any idea what I'm doing wrong?

EDIT: So I believe the issue is that I'm not understanding the xy coordinate system. I switched it to display the results, and it showed -97 207 for Current and -75 207 for New. How far is a a single coordinate cell? I was assuming it would use the Grid, but that appears very incorrect. How would I make this apply to grid movement?

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Movement based on result of roll

Post by aliasmask »

You need to set the units to 0 for Wiki: moveToken() to use cells.

SzassT
Cave Troll
Posts: 30
Joined: Sun Apr 30, 2017 4:32 pm
Location: Fort Smith, AR

Re: Movement based on result of roll

Post by SzassT »

Doh! Can't believe I missed that! Thanks for the help AliasMask, it works perfectly now!

Post Reply

Return to “Macros”