Movement based on result of roll
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Movement based on result of roll
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.
Re: Movement based on result of roll
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.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Movement based on result of roll
Thanks for your reply! So I tested out this macro:
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?
Code: Select all
[h: CurrentX = getTokenX(0)]
[h: CurrentY = getTokenY(0)]
[h: NewX = CurrentX + 1d20+getProperty("Racing")]
[h: NewY = CurrentY]
[h: moveToken(NewX, NewY)]
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?
Re: Movement based on result of roll
You need to set the units to 0 for Wiki: moveToken() to use cells.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Movement based on result of roll
Doh! Can't believe I missed that! Thanks for the help AliasMask, it works perfectly now!