From c2d3f0cfdafc8aaf46033459ac8b1333b8c97ff7 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:03:32 +0800 Subject: [PATCH] [saco] Implement/match `CEntity::GetDistanceFromPoint(...)` --- saco/game/entity.cpp | 16 ++++++++++++++++ saco/game/entity.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/saco/game/entity.cpp b/saco/game/entity.cpp index 2e67935..ac3ba33 100644 --- a/saco/game/entity.cpp +++ b/saco/game/entity.cpp @@ -232,3 +232,19 @@ void CEntity::TeleportTo(float x, float y, float z) } //----------------------------------------------------------- + +float CEntity::GetDistanceFromPoint(float X, float Y, float Z) +{ + MATRIX4X4 matThis; + float fSX,fSY,fSZ; + + GetMatrix(&matThis); + fSX = (matThis.pos.X - X) * (matThis.pos.X - X); + fSY = (matThis.pos.Y - Y) * (matThis.pos.Y - Y); + fSZ = (matThis.pos.Z - Z) * (matThis.pos.Z - Z); + + return (float)sqrt(fSX + fSY + fSZ); +} + +//----------------------------------------------------------- + diff --git a/saco/game/entity.h b/saco/game/entity.h index 8332660..bb1af6a 100644 --- a/saco/game/entity.h +++ b/saco/game/entity.h @@ -26,6 +26,9 @@ public: UINT GetModelIndex(); void TeleportTo(float x, float y, float z); + float GetDistanceFromPoint(float X, float Y, float Z); + + BOOL FUNC_1009FDE0(); VECTOR field_4[5];