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

Random token movement on Hex Grid

I'm designing a Mortal Engines board game for Roll20. The players control roving cities that aim to 'eat' other cities and grow in size. The problem is that there needs to be 'NPC' cities too, and they need to move. Is it possible to have a macro that would cause a token to move from one hex grid space into one of the 6 surrounding ones, at random?
1660514972
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Alastair! There are Mod scripts (ex. Token Mod) that can do this, if you are in a game created by a Pro user. But macros by themselves cannot change any game elements.
Thanks for the reply! So is it possible to push a button and have an NPC token move let's say 10 feet in one of 6 directions (determined by rolling a dice)?
1660607508
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It should. I have a token-mod macro that does something like this, moving a selected token 1-2 spaces in a random direction. I have not tested anything specifically on a hex map, though. Let me see if I can find the Aaron (author of token mod), he'll have a better idea of how it handles hex maps.
1660615360
The Aaron
Roll20 Production Team
API Scripter
TokenMod doesn't have any special handling built in for hex grids.  You'd just need to use the --move with an appropriate angle and distance.  I could probably build something for that, it just hasn't come up. In a true hex grid, it would be 1u between a hex and any of its 6 neighbors.  However, You can't represent a perfect hex grid on a pixel based screen, so the distance is not precise.  For a horizontal hex grid on Roll20, the distance to the hex above or below is  79.6887899835 pixels.  This would move a token "up" 3 hexes. (note the = on the front which causes it to ignore rotation of the graphic): !token-mod --move =[[ 79.6887899835*3]] For one of the 4 diagonal hexes, the distance is  80.1851967642 pixels.  This will move down and to the right 2 hexes: !token-mod --move 120|=[[80.1851967642*2]] Basically, you can use that combination to set up macros that move in the right direction.  Even so, once you've moved a bit like this, you can end up with error introduced by round off.  Also, be careful not to move off the edge of the map. Hope that helps!
That's awesome, thankyou as always. I will try and get it working for me
1660763109
The Aaron
Roll20 Production Team
API Scripter
No problem.  Let me know if you need something more custom.  I can probably build something that is a bit easier to use, possibly add better hex support in TokenMod.