Unless I'm missing something, you can actually create a variable which has an X co-ordinates and a Y co-ordinates.... it's a variable type called 'point'... you can use it like this;
............
I'm sorry, I didn't know there was any problem with the 'Move unit to centre of (Region)' command... I actually using it in several of the maps I'm working on... could you explain this 'leak'...? It seems as if I'll end up with game lag if you don't tell me...:\
yes, that
might work...but i don't think so...
at any rate, what COULD happen, is that if you have enough memory leaks in the map built up, the game will crash on you.
i guess i used to try doing what you suggested above...
but i think you still have to use the remove location function.
anyway, if you use real x and real y variables, you can use those freely without worrying about how to clean the leaks. otherwise, i just hope you know what you're doing to clean the leaks. since i'm not a leak cleaner guy, it's too much trouble to remember to clean them, you know? it's hard enough getting the if then loop stuff down right, heh heh......
here's an example of a function that leaves no room for leaking:
CreateUnit(Player(0), 'efdr', 4836.9, - 6058.9, 202.890)
the 4836.9 and -6058.9 are the x and y variables. but in this case, i did not even use variables, but i did input the numbers manually.
what i did, to make sure i had the EXACT numbers, was run code to display what the numbers were, in the game.
you could do something like BJDebugMsg(R2S(GetLocationX(center of region))+","+R2S(GetLocationY(center of region)))
the debug msg thing just shows a message for 60 seconds, r2s is the real to string function, and you can probably figure out the rest.
display messages in testing can be pretty useful. i'm not sure what the 'center of region' looks like in custom text, but to find out, you can copy the trigger and convert the copy to custom text to view that.
here's a function i used to move units:
call SetUnitPosition(GetEnumUnit(), (GetRandomReal(-480.00, 0.00)), (GetRandomReal(9191.00, 10101.00)))
but, i'm not sure if it's leakless or whatever, since i used it at the end of the game.
i could've also done this:
JASS:
call SetUnitX(GetEnumUnit(), GetRandomReal(-480.0, 0.0))
call SetUnitY(GetEnumUnit(), GetRandomReal(9191.0, 10101.0)
those two functions are all you need. of course, as you could see, my above functions were something like, random point in region, rather than center of region.
obviously, you don't need a random real if you're just wanting the center.
JASS:
call SetUnitX(GetEnumUnit(), -240.0)
call SetUnitY(GetEnumUnit(), 9646.0)
that would be making it the center of a region.
also, you can ignore using regions almost entirely if you manually set the 4 reals...the bottom left 2 reals, and the top right 2 reals are all you need.