diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index 517785b42..b1677a9ac 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -229,7 +229,7 @@ DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial = int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2); void CheckSectorFloor(sectortype* pSector, double z, DVector2& xy); int GetAngleToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2); -int GetWallNormal(walltype* nWall); +DAngle GetWallNormal(walltype* nWall); void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& vel); Collision AngleChase(DExhumedActor* nSprite, DExhumedActor* nSprite2, int ebx, int ecx, DAngle push1); void SetQuake(DExhumedActor* nSprite, int nVal); diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index fa45aad65..ed556ab5c 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -37,12 +37,12 @@ void DestroyGrenade(DExhumedActor* pActor) DeleteActor(pActor); } -void BounceGrenade(DExhumedActor* pActor, int nAngle) +void BounceGrenade(DExhumedActor* pActor, DAngle nAngle) { pActor->nTurn >>= 1; - pActor->x = bcos(nAngle, -5) * pActor->nTurn; - pActor->y = bsin(nAngle, -5) * pActor->nTurn; + pActor->x = bcos(nAngle.Buildang(), -5) * pActor->nTurn; + pActor->y = bsin(nAngle.Buildang(), -5) * pActor->nTurn; D3PlayFX(StaticSound[kSound3], pActor); } @@ -55,27 +55,29 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1) DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade; auto pPlayerActor = PlayerList[nPlayer].pActor; - int nAngle = pPlayerActor->int_ang(); + DAngle nAngle = pPlayerActor->spr.angle; ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect); pActor->spr.pos = pPlayerActor->spr.pos; - if (nAngle < 0) { - nAngle = pPlayerActor->int_ang(); + if (nAngle < nullAngle) { + nAngle = pPlayerActor->spr.angle; } pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; - pActor->set_int_ang(nAngle); + pActor->spr.angle = nAngle; if (push1 >= -3000) { int nVel = PlayerList[nPlayer].totalvel << 5; pActor->nTurn = ((90 - pActor->nIndex2) * (90 - pActor->nIndex2)) + nVel; - pActor->set_int_zvel((-64 * push1) - 4352); + pActor->vel.Z = ((-0.25 * push1) - 17); - auto nMov = movesprite(pActor, bcos(nAngle) * (pPlayerActor->native_clipdist() << 3), bsin(nAngle) * (pPlayerActor->native_clipdist() << 3), ecx, 0, 0, CLIPMASK1); + + DVector2 vec = nAngle.ToVector() * pPlayerActor->fClipdist() *2; // == << 14 + 3 + 2 - 18 + auto nMov = movesprite(pActor, FloatToFixed<18>(vec.X), FloatToFixed<18>(vec.Y), ecx, 0, 0, CLIPMASK1); if (nMov.type == kHitWall) { nAngle = GetWallNormal(nMov.hitWall); @@ -88,8 +90,8 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1) pActor->vel.Z = pPlayerActor->vel.Z; } - pActor->x = bcos(nAngle, -4) * pActor->nTurn; - pActor->y = bsin(nAngle, -4) * pActor->nTurn; + pActor->x = bcos(nAngle.Buildang(), -4) * pActor->nTurn; + pActor->y = bsin(nAngle.Buildang(), -4) * pActor->nTurn; PlayerList[nPlayer].pPlayerGrenade = nullptr; @@ -323,7 +325,7 @@ void AIGrenade::Tick(RunListEvent* ev) } else if (nMov.type == kHitSprite) { - BounceGrenade(pActor, nMov.actor()->int_ang()); + BounceGrenade(pActor, nMov.actor()->spr.angle); } pActor->nHealth = 0; diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index 09dcc0283..20e09462f 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -421,7 +421,7 @@ void AILion::Tick(RunListEvent* ev) if (nMov.type == kHitWall) { pActor->nAction = 7; - pActor->set_int_ang((GetWallNormal(nMov.hitWall) + 1024) & kAngleMask); + pActor->spr.angle = (GetWallNormal(nMov.hitWall) + DAngle180).Normalized360(); pActor->nCount = RandomSize(4); return; } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index efdbea5a0..2e5295485 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -966,10 +966,9 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int threshol return movesprite(pActor, FloatToFixed<18>(vec.X), FloatToFixed<18>(vec.Y), zz * 4096 + BobVal(zbob) * 512, 0, 0, nClipType); } -int GetWallNormal(walltype* pWall) +DAngle GetWallNormal(walltype* pWall) { - int nAngle = getangle(pWall->delta()); - return (nAngle + 512) & kAngleMask; + return (VecToAngle(pWall->delta()) + DAngle90).Normalized360(); } DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum) @@ -1178,7 +1177,7 @@ void AICreatureChunk::Tick(RunListEvent* ev) } else if (nVal.type == kHitWall) { - nAngle = DAngle::fromBuild(GetWallNormal(nVal.hitWall)); + nAngle = GetWallNormal(nVal.hitWall); } else { diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 8b1a1f22f..c5d14a361 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -720,7 +720,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort if (nMove.type == kHitSector || nMove.type == kHitWall) { sectortype* sect; - int nNormal = 0; + DAngle nNormal = nullAngle; if (nMove.type == kHitSector) { @@ -738,7 +738,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort { if ((sect->hitag == 45) && bTouchFloor) { - int nDiff = AngleDiff(DAngle::fromBuild(nNormal), DAngle::fromBuild((pPlayerActor->int_ang() + 1024) & kAngleMask)); + int nDiff = AngleDiff(nNormal, pPlayerActor->spr.angle + DAngle180); if (nDiff < 0) { nDiff = -nDiff; diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 6e5ddf32f..4531517a3 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -537,7 +537,7 @@ void AIQueenEgg::Tick(RunListEvent* ev) } else { - int nAngle; + DAngle nAngle; switch (nMov.type) { @@ -547,11 +547,11 @@ void AIQueenEgg::Tick(RunListEvent* ev) nAngle = GetWallNormal(nMov.hitWall); break; case kHitSprite: - nAngle = nMov.actor()->int_ang(); + nAngle = nMov.actor()->spr.angle; break; } - pActor->set_int_ang(nAngle); + pActor->spr.angle = nAngle; pActor->vel.XY() = pActor->spr.angle.ToVector() * 512; } @@ -766,11 +766,11 @@ void AIQueenHead::Tick(RunListEvent* ev) auto nMov = MoveCreature(pActor); // original BUG - this line doesn't exist in original code? - int nNewAng = pActor->int_ang(); + DAngle nNewAng = pActor->spr.angle; if (nMov.exbits == 0) { - if (nMov.type == kHitSprite) nNewAng = nMov.actor()->int_ang(); + if (nMov.type == kHitSprite) nNewAng = nMov.actor()->spr.angle; else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.hitWall); } else if (nMov.exbits == kHitAux2) @@ -785,7 +785,7 @@ void AIQueenHead::Tick(RunListEvent* ev) } // original BUG - var_18 isn't being set if the check above == 0x20000 ? - pActor->set_int_ang(nNewAng); + pActor->spr.angle = nNewAng; nVelShift++; if (nVelShift < 5) diff --git a/source/games/exhumed/src/trigdat.cpp b/source/games/exhumed/src/trigdat.cpp index 896ba9098..5a718489a 100644 --- a/source/games/exhumed/src/trigdat.cpp +++ b/source/games/exhumed/src/trigdat.cpp @@ -29,7 +29,7 @@ BEGIN_PS_NS // 100% done int AngleDiff(DAngle a, DAngle b) { - int diff = (b - a).Buildang(); + int diff = (b - a).Normalized360().Buildang(); if (diff > 1024) { diff = 2048 - diff;