diff --git a/source/games/exhumed/src/anubis.cpp b/source/games/exhumed/src/anubis.cpp index 5b9a9aab0..f60ae27ce 100644 --- a/source/games/exhumed/src/anubis.cpp +++ b/source/games/exhumed/src/anubis.cpp @@ -216,7 +216,7 @@ void AIAnubis::Tick(RunListEvent* ev) { ap->spr.xvel = 0; ap->spr.yvel = 0; - ap->set_int_ang(getangle(pTarget->int_pos().X - ap->int_pos().X, pTarget->int_pos().Y - ap->int_pos().Y)); + ap->spr.angle = VecToAngle(pTarget->spr.pos - ap->spr.pos); ap->nAction = 3; ap->nFrame = 0; diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index 50240798e..e40bd1f20 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -339,7 +339,7 @@ void AIFish::Tick(RunListEvent* ev) pActor->nAction = 2; pActor->nFrame = 0; - int nAngle = getangle(pTargetActor->int_pos().X - pActor->int_pos().X, pTargetActor->int_pos().Z - pActor->int_pos().Z); + int nAngle = getangle(pTargetActor->spr.pos - pActor->spr.pos); pActor->spr.zvel = bsin(nAngle, -5); pActor->nCount = RandomSize(6) + 90; @@ -454,7 +454,7 @@ void AIFish::Tick(RunListEvent* ev) if (pHitAct->spr.statnum == 100) { pActor->pTarget = coll.actor(); - pActor->set_int_ang(getangle(pHitAct->int_pos().X - pActor->int_pos().X, pHitAct->int_pos().Y - pActor->int_pos().Y)); + pActor->spr.angle = VecToAngle(pHitAct->spr.pos - pActor->spr.pos); if (nAction != 3) { diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index 207aa9733..bcada9a47 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -658,31 +658,18 @@ int GetAngleToSprite(DExhumedActor* a1, DExhumedActor* a2) if (!a1 || !a2) return -1; - return getangle(a2->int_pos().X - a1->int_pos().X, a2->int_pos().Y - a1->int_pos().Y); + return getangle(a2->spr.pos - a1->spr.pos); } int PlotCourseToSprite(DExhumedActor* pActor1, DExhumedActor* pActor2) { if (pActor1 == nullptr || pActor2 == nullptr) return -1; + + auto vect = pActor2->spr.pos.XY() - pActor1->spr.pos.XY(); + pActor1->spr.angle = VecToAngle(vect); + return int(vect.Length() * worldtoint); - int x = pActor2->int_pos().X - pActor1->int_pos().X; - int y = pActor2->int_pos().Y - pActor1->int_pos().Y; - - pActor1->set_int_ang(getangle(x, y)); - - uint32_t x2 = abs(x); - uint32_t y2 = abs(y); - - uint32_t diff = x2 * x2 + y2 * y2; - - if (diff > INT_MAX) - { - DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__); - diff = INT_MAX; - } - - return ksqrt(diff); } DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage) @@ -1152,20 +1139,10 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int ebx, int { int nHeight = tileHeight(pActor2->spr.picnum) * pActor2->spr.yrepeat * 2; - int nMyAngle = getangle(pActor2->int_pos().X - pActor->int_pos().X, pActor2->int_pos().Y - pActor->int_pos().Y); + auto vect = pActor2->spr.pos.XY() - pActor->spr.pos.XY(); + int nMyAngle = getangle(vect); - uint32_t xDiff = abs(pActor2->int_pos().X - pActor->int_pos().X); - uint32_t yDiff = abs(pActor2->int_pos().Y - pActor->int_pos().Y); - - uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; - - if (sqrtNum > INT_MAX) - { - DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__); - sqrtNum = INT_MAX; - } - - int nSqrt = ksqrt(sqrtNum); + int nSqrt = int(vect.Length() * worldtoint); int var_18 = getangle(nSqrt, ((pActor2->int_pos().Z - nHeight) - pActor->int_pos().Z) >> 8); diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 36798ca64..e3cf83ed0 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -297,22 +297,12 @@ Collision QueenAngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int val { int nTileY = (tileHeight(pActor2->spr.picnum) * pActor2->spr.yrepeat) * 2; - int nMyAngle = getangle(pActor2->int_pos().X - pActor->int_pos().X, pActor2->int_pos().Y - pActor->int_pos().Y); + auto vect = pActor2->spr.pos.XY() - pActor->spr.pos.XY(); + int nMyAngle = getangle(vect); int edx = ((pActor2->int_pos().Z - nTileY) - pActor->int_pos().Z) >> 8; - uint32_t xDiff = abs(pActor2->int_pos().X - pActor->int_pos().X); - uint32_t yDiff = abs(pActor2->int_pos().Y - pActor->int_pos().Y); - - uint32_t sqrtVal = xDiff * xDiff + yDiff * yDiff; - - if (sqrtVal > INT_MAX) - { - DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__); - sqrtVal = INT_MAX; - } - - int nSqrt = ksqrt(sqrtVal); + int nSqrt = int(vect.Length() * worldtoint); int var_14 = getangle(nSqrt, edx); diff --git a/source/games/exhumed/src/roach.cpp b/source/games/exhumed/src/roach.cpp index fd05acd2b..fdff70c0d 100644 --- a/source/games/exhumed/src/roach.cpp +++ b/source/games/exhumed/src/roach.cpp @@ -273,7 +273,7 @@ void AIRoach::Tick(RunListEvent* ev) pActor->spr.xvel = 0; pActor->spr.yvel = 0; - pActor->set_int_ang(getangle(pTarget->int_pos().X - pActor->int_pos().X, pTarget->int_pos().Y - pActor->int_pos().Y)); + pActor->spr.angle = VecToAngle(pTarget->spr.pos - pActor->spr.pos); pActor->nFrame = 0; } @@ -302,7 +302,7 @@ void AIRoach::Tick(RunListEvent* ev) pActor->spr.xvel = 0; pActor->spr.yvel = 0; - pActor->set_int_ang(getangle(pTarget->int_pos().X - pActor->int_pos().X, pTarget->int_pos().Y - pActor->int_pos().Y)); + pActor->spr.angle = VecToAngle(pTarget->spr.pos - pActor->spr.pos); pActor->nFrame = 0; } diff --git a/source/games/exhumed/src/scorp.cpp b/source/games/exhumed/src/scorp.cpp index 8f8edacda..c5c97721a 100644 --- a/source/games/exhumed/src/scorp.cpp +++ b/source/games/exhumed/src/scorp.cpp @@ -428,7 +428,7 @@ void AIScorp::Effect(RunListEvent* ev, DExhumedActor* pTarget, int mode) { pActor->spr.xvel = 0; pActor->spr.yvel = 0; - pActor->set_int_ang(getangle(pTarget->int_pos().X - pActor->int_pos().X, pTarget->int_pos().Y - pActor->int_pos().Y)); + pActor->spr.angle = VecToAngle(pTarget->spr.pos - pActor->spr.pos); pActor->nIndex = RandomSize(2) + RandomSize(3);