CalcDir
Calculates the direction for a step from point (Xfrom, Yfrom) to point (Xto, Yto).
Returns a direction value (0–7):
| Value | Direction |
|---|---|
| 0 | North |
| 1 | NorthEast |
| 2 | East |
| 3 | SouthEast |
| 4 | South |
| 5 | SouthWest |
| 6 | West |
| 7 | NorthWest |
If both points are identical (Xfrom = Xto and Yfrom = Yto), returns 100.
Вычисляет направление для шага из точки (Xfrom, Yfrom) в точку (Xto, Yto).
Возвращает значение направления (0–7, см. таблицу выше).
Если обе точки совпадают (Xfrom = Xto и Yfrom = Yto), возвращает 100.
function CalcDir(Xfrom: Word; Yfrom: Word; Xto: Word; Yto: Word): Byte;
Parameters:
- Xfrom, Yfrom — source point coordinates.
- Xto, Yto — destination point coordinates.
def CalcDir(xfrom: int, yfrom: int, xto: int, yto: int) -> int: ...
begin
// Step towards the point one tile to the east
Step(CalcDir(GetX(Self), GetY(Self), GetX(Self) + 1, GetY(Self)), True);
end.
# Step towards a target object
direction = CalcDir(GetX(Self()), GetY(Self()), GetX(target), GetY(target))
if direction != 100:
Step(direction, True)