When you use ComTurnXY the unit turns to the specified hex but is there a way to predict in what direction the unit will turn? Oh yes there is

and the algorithm isn't that hard at all.

This function returns the direction a unit on hex [x1,y1] wouldturn to if it was asked to turn to hex [x,y] with ComTurnXY.

**Code:**

Export Function GetTurnDirection(x1,y1,x,y);

var dist_1, dist_2, a, temp_dist, dir;

begin

dist_1 = GetDistXY(x1,y1,x,y);

dist_2 = 99999;

for a = 0 to 5 do

begin

temp_dist = GetDistXY(ShiftX(x1,a,dist_1),ShiftY(y1,a,dist_1),x,y);

if temp_dist < dist_2 then

begin

dist_2 = temp_dist;

dir = a;

end;

end;

result = dir;

end;