Files
CHOMPStation2/code/_helpers/distance_ch.dm
Cadyn ecd8125771 Ai update (#8023)
Co-authored-by: silicons <2003111+silicons@users.noreply.github.com>
Co-authored-by: silicons <no@you.cat>
2024-03-31 13:38:23 +02:00

38 lines
859 B
Plaintext

/**
* checks distance from one thing to another but automatically resolving for turf / nesting
*/
/proc/in_range_of(atom/A, atom/B, dist = 1)
return game_range_to(A, B) <= dist
/**
* gets real dist from A to B, including resolving for turf. if not the same Z, returns infinity.
*/
/proc/game_range_to(atom/A, atom/B)
A = get_turf(A)
B = get_turf(B)
return A.z == B.z? get_dist(A, B) : INFINITY
/**
* real dist because byond dist doesn't go above 127 :/
*
* accepts **TURFS**
*/
/proc/get_chebyshev_dist(turf/A, turf/B)
return max(abs(A.x - B.x), abs(A.y - B.y))
/**
* real euclidean dist
*
* accepts **TURFS**
*/
/proc/get_euclidean_dist(turf/A, turf/B)
return sqrt((A.x - B.x) ** 2 + (A.y - B.y) ** 2)
/**
* real taxicab dist
*
* accepts **TURFS**
*/
/proc/get_manhattan_dist(turf/A, turf/B)
return abs(A.x - B.x) + abs(A.y - B.y)