Dist
Returns the distance in tiles between two points (X1, Y1) and (X2, Y2).
The distance is calculated as Max(|X2-X1|, |Y2-Y1|) (Chebyshev distance), which corresponds to the actual tile distance in UO.
Возвращает расстояние в тайлах между двумя точками (X1, Y1) и (X2, Y2).
Расстояние вычисляется как Max(|X2-X1|, |Y2-Y1|) (расстояние Чебышёва), что соответствует реальному расстоянию в тайлах в UO.
function Dist(Xfrom: Word; Yfrom: Word; Xto: Word; Yto: Word): Word;
Parameters:
- Xfrom, Yfrom — first point coordinates.
- Xto, Yto — second point coordinates.
def Dist(x1: int, y1: int, x2: int, y2: int) -> int: ...
begin
if Dist(GetX(Self), GetY(Self), GetX(target), GetY(target)) > 3 then
AddToSystemJournal(GetName(target) + ' is too far');
end.
d = Dist(GetX(Self()), GetY(Self()), GetX(target), GetY(target))
if d > 3:
AddToSystemJournal(f'{GetName(target)} is too far ({d} tiles)')