Figuring Out z-order on a grid

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
User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Figuring Out z-order on a grid

Post by aliasmask »

I'm finally redoing my z-order formula (which I totally got backward) where larger creatures have a smaller z-order and elevated tokens have a larger z-order. I'm wondering if any of you have thoughts on how I should do this. Since a formula is determining the z-order based on the x,y,z and size I need the values to be unique (with in a certain range).

I was thinking of something like this for the base:

Code: Select all

[H: zOrder = mod(getTokenX(0),100) + mod(getTokenY(0),100) * 100]
zOrder is the position on the grid in a 100 cell block. So, if you're at (0,0) then your zOrder is 0; at (1,0) z is 1; (0,1) z is 100. For MT, zOrder has to be unique, if not it just makes it the highest zOrder value +1.

So, to expand the available values to account for size I'll have to make the base number bigger. Since I want tiny in front, it'll have to have the biggest number. So, a colossal creature at (0,0) will be behind a tiny creature at (0,0). So, I'm thinking of multiplying the base by 100, then use a size mod 10 to 70 (colossal = 10, tiny = 70) and use 0-9 for actual stacking of same size tokens. I could check that by when setting the zOrder it get back a different number which tells me that zOrder already exists. 71 to 99 can be used for elevation in 5ft increments, so 70 + max(0,min(29,floor(elevation/5)+sizeMod)) where sizeMod is 0 for medium, 1 for large, etc...

What do you think? Any other ideas?

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: Figuring Out z-order on a grid

Post by Jagged »

Ooh. I've been playing a lot with Z-Ordering while working on my Isometric Grid. Do you have any pictures of what you are trying to achieve?

It might be that if you use 1.4 with the Isometric code, you could achieve what you want by using the new Figure Token. You don't have to use the Isometric Grid, and the Figure Tokens can be normal size, but the new Z-Ordering code would kick in anyway.

Post Reply

Return to “Macros”