Basically I used mobile grids to measure the distance between the unit and the edge of a given area. X and Y are done seperately. For X, have use a 3x3 devourer grid starting on the player, removing some devs then moving the location onto the next dev, then removing the rest of them. this allows the location to move one devourer width left or right each time. Have as many copies of the trigger as there are possible coordinates each time the trigger repeats , add or subtract one from a variable (in my demo map i used resources so you can see the coords, use death counters if you need more or need them hidden). Having the condition that the location hasnt reached the side allows this to only repeat as many times as is needed to reach the side, giving the distance. Do the same either upwards or downwards for the Y coordinate.
You can then use the X-Y coordinates as conditions for triggers.
As well as this, you can use these moving grids to move a location to a specific place. First have a fixed starting point at one of the corners. Then set variables (death counters are best) corresponding to the x-y coordinates you want to move it to, then have a repeating trigger, same idea as before. Each repeat subtracts one from the variable. Do the X first, the the Y starting from the endpoint of the X movement.
One important note is that these coordinates don't correspond to the gridsquares (devourers are about 1 1/3 squares in size), so you'll need a little trial and error to find the coordinates of any particular thing, such as a beacon.
Dear God. That was the worst explaining I've ever done in my life. If you don't get it, look at the attached map. If you still dont get it, ask.
I'm sure theres a few other things you could do, such as finding the position of one unit relative to another or doing it all with one location by having burrowed units or something instead of locations for the edges (1 location for the whole map would be kinda cool i guess), but I cbf doing that right now.
Oh and don't worry about the lines of vision coming out of him, thats just because i was careless and had the units in the grid owned by the player, just have them owned by a computer player and that wouldn't happen.
Attachments:
None.