diff --git a/source/games/exhumed/src/engine.h b/source/games/exhumed/src/engine.h index d46f6354c..333e35ece 100644 --- a/source/games/exhumed/src/engine.h +++ b/source/games/exhumed/src/engine.h @@ -122,6 +122,7 @@ uint16_t RandomWord(); int RandomLong(); int RandomSize(int nSize); DAngle RandomAngle9(); +DAngle RandomAngle(); // record diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index b1d69cf88..ba31f1044 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -337,8 +337,9 @@ void GameInterface::Ticker() for (int i = 0; i < 4; i++) { - lPlayerXVel += localInput.fvel * bcos(inita.Buildang()) + localInput.svel * bsin(inita.Buildang()); - lPlayerYVel += localInput.fvel * bsin(inita.Buildang()) - localInput.svel * bcos(inita.Buildang()); + // Velocities are stored as Q14.18 + lPlayerXVel += int((localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) * 16384); + lPlayerYVel += int((localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) * 16384); lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6); lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6); } diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index 79612193f..09dcc0283 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -375,14 +375,14 @@ void AILion::Tick(RunListEvent* ev) double nCheckDist = 0x7FFFFFFF; - int nAngle = pActor->int_ang(); - int nScanAngle = (nAngle - 512) & kAngleMask; + DAngle nAngle = pActor->spr.angle; + DAngle nScanAngle = (nAngle - DAngle90).Normalized360(); for (int i = 0; i < 5; i++) { HitInfo hit{}; - hitscan(pActor->spr.pos.plusZ(-GetActorHeightF(pActor) * 0.5), pActor->sector(), DVector3(bcos(nScanAngle), bsin(nScanAngle), 0), hit, CLIPMASK1); + hitscan(pActor->spr.pos.plusZ(-GetActorHeightF(pActor) * 0.5), pActor->sector(), DVector3(nScanAngle.ToVector() * 1024, 0), hit, CLIPMASK1); if (hit.hitWall) { @@ -396,11 +396,10 @@ void AILion::Tick(RunListEvent* ev) } } - nScanAngle += 256; - nScanAngle &= kAngleMask; + nScanAngle += DAngle45; } - pActor->set_int_ang(nAngle); + pActor->spr.angle = nAngle; pActor->nAction = 6; pActor->vel.XY() = pActor->spr.angle.ToVector() * (1024 - 128); diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index e643e4bb8..4f531c446 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1647,7 +1647,7 @@ void ExplodeEnergyBlock(DExhumedActor* pActor) pSector->floorshade = 50; pSector->extra = -1; - pSector->set_int_floorz(pActor->int_pos().Z); + pSector->floorz = pActor->spr.pos.Z; pActor->spr.pos.Z = (pActor->spr.pos.Z + pSector->floorz) * 0.5; diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index c14895195..48ae60f2d 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -936,7 +936,7 @@ void AIQueenHead::Tick(RunListEvent* ev) { auto pos = pActor->spr.pos; auto pSector =pActor->sector(); - int nAngle = RandomSize(11) & kAngleMask; + auto nAngle = RandomAngle(); pActor->spr.xrepeat = 127 - QueenHead.nIndex2; pActor->spr.yrepeat = 127 - QueenHead.nIndex2; @@ -945,11 +945,10 @@ void AIQueenHead::Tick(RunListEvent* ev) // DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue. // This behavior probably would be needed emulated for demo compatibility - int dx = bcos(nAngle, 10); - int dy = bsin(nAngle, 10); + auto dv = nAngle.ToVector() * 64; int dz = (RandomSize(5) - RandomSize(5)) << 7; - movesprite(pActor, dx, dy, dz, 0, 0, CLIPMASK1); + movesprite(pActor, FloatToFixed<18>(dv.X), FloatToFixed<18>(dv.Y), dz, 0, 0, CLIPMASK1); BlowChunks(pActor); BuildExplosion(pActor); diff --git a/source/games/exhumed/src/random.cpp b/source/games/exhumed/src/random.cpp index ad5262bf4..4b6aea96d 100644 --- a/source/games/exhumed/src/random.cpp +++ b/source/games/exhumed/src/random.cpp @@ -96,4 +96,9 @@ DAngle RandomAngle9() { return DAngle::fromBuild(RandomSize(9)); } + +DAngle RandomAngle() +{ + return DAngle::fromBuild(RandomSize(11)); +} END_PS_NS