diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index 876242184..2628e70d7 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -173,7 +173,7 @@ void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, dou drawElement(320, 237, 2358, 1, 1, 1, 1); } - int zn = ((pPlayer->zWeapon - pPlayer->zView - (12 << 8)) >> 7) + 220; + int zn = (int(pPlayer->zWeapon - pPlayer->zView * zworldtoint - (12 << 8)) >> 7) + 220; PLAYER* pPSprite = &gPlayer[pPlayer->actor->spr.type - kDudePlayer1]; if (pPlayer->actor->IsPlayerActor() && pPSprite->hand == 1) { diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index d2685c8b8..f3f292c3d 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -713,18 +713,18 @@ void playerSetGodMode(PLAYER* pPlayer, bool bGodMode) void playerResetInertia(PLAYER* pPlayer) { POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; - pPlayer->zView = pPlayer->actor->int_pos().Z - pPosture->eyeAboveZ; + pPlayer->zView = pPlayer->actor->spr.pos.Z - pPosture->eyeAboveZ * zinttoworld; pPlayer->zWeapon = pPlayer->actor->int_pos().Z - pPosture->weaponAboveZ; viewBackupView(pPlayer->nPlayer); } void playerCorrectInertia(PLAYER* pPlayer, const DVector3& oldpos) { - auto zAdj = (pPlayer->actor->spr.pos.Z - oldpos.Z) * zworldtoint; + auto zAdj = pPlayer->actor->spr.pos.Z - oldpos.Z; pPlayer->zView += zAdj; - pPlayer->zWeapon += zAdj; + pPlayer->zWeapon += zAdj * zworldtoint; pPlayer->actor->opos.XY() += pPlayer->actor->spr.pos.XY() - oldpos.XY(); - pPlayer->ozView += (pPlayer->actor->spr.pos.Z - oldpos.Z) * zworldtoint; + pPlayer->ozView += zAdj; } void playerResetPowerUps(PLAYER* pPlayer) @@ -1865,12 +1865,12 @@ void playerProcess(PLAYER* pPlayer) ProcessInput(pPlayer); int nSpeed = approxDist(actor->int_vel().X, actor->int_vel().Y); pPlayer->zViewVel = interpolatedvalue(pPlayer->zViewVel, actor->int_vel().Z, FixedToFloat(0x7000)); - int dz = pPlayer->actor->int_pos().Z - pPosture->eyeAboveZ - pPlayer->zView; + int dz = pPlayer->actor->int_pos().Z - pPosture->eyeAboveZ - pPlayer->zView * zworldtoint; if (dz > 0) pPlayer->zViewVel += MulScale(dz << 8, 0xa000, 16); else pPlayer->zViewVel += MulScale(dz << 8, 0x1800, 16); - pPlayer->zView += pPlayer->zViewVel >> 8; + pPlayer->zView += FixedToFloat(pPlayer->zViewVel); pPlayer->zWeaponVel = interpolatedvalue(pPlayer->zWeaponVel, actor->int_vel().Z, FixedToFloat(0x5000)); dz = pPlayer->actor->int_pos().Z - pPosture->weaponAboveZ - pPlayer->zWeapon; if (dz > 0) @@ -1930,7 +1930,7 @@ void playerProcess(PLAYER* pPlayer) auto link = actor->sector()->lowerLink; if (link && (link->spr.type == kMarkerLowGoo || link->spr.type == kMarkerLowWater)) { - if (getceilzofslopeptr(actor->sector(), actor->spr.pos) > pPlayer->zView) + if (getceilzofslopeptrf(actor->sector(), actor->spr.pos) > pPlayer->zView) pPlayer->isUnderwater = 0; } } diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 0c530e67d..ee907921f 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -107,8 +107,8 @@ struct PLAYER int nPlayer; // Connect id int lifeMode; int bloodlust; // ---> useless - int zView; - int ozView; + double zView; + double ozView; int zViewVel; int zWeapon; int ozWeapon; diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 62366dfa4..59ac230b8 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -60,7 +60,7 @@ void viewBackupView(int nPlayer) { PLAYER* pPlayer = &gPlayer[nPlayer]; pPlayer->ozView = pPlayer->zView; - pPlayer->ozWeapon = pPlayer->zWeapon - pPlayer->zView - 0xc00; + pPlayer->ozWeapon = pPlayer->zWeapon - pPlayer->zView * zworldtoint - 0xc00; pPlayer->obobHeight = pPlayer->bobHeight; pPlayer->obobWidth = pPlayer->bobWidth; pPlayer->oswayHeight = pPlayer->swayHeight; @@ -491,8 +491,8 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& c #endif { cPos.XY() = pPlayer->actor->interpolatedpos(interpfrac).XY(); - cPos.Z = interpolatedvalue(pPlayer->ozView, pPlayer->zView, interpfrac) * zinttoworld; - zDelta = interpolatedvalue(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView - (12 << 8), interpfrac); + cPos.Z = interpolatedvalue(pPlayer->ozView, pPlayer->zView, interpfrac); + zDelta = interpolatedvalue(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView * zworldtoint - (12 << 8), interpfrac); bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac); bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac); shakeX = interpolatedvalue(pPlayer->oswayWidth, pPlayer->swayWidth, interpfrac); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index ff3cf68fb..021abd794 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -247,16 +247,16 @@ static bool checkAmmo2(const PLAYER* pPlayer, int ammotype, int amount) void SpawnBulletEject(PLAYER* pPlayer, int a2, int a3) { POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; - pPlayer->zView = pPlayer->actor->int_pos().Z - pPosture->eyeAboveZ; - int dz = pPlayer->zWeapon - (pPlayer->zWeapon - pPlayer->zView) / 2; + pPlayer->zView = pPlayer->actor->spr.pos.Z - pPosture->eyeAboveZ * zinttoworld; + int dz = pPlayer->zWeapon - (pPlayer->zWeapon - pPlayer->zView * zworldtoint) / 2; fxSpawnEjectingBrass(pPlayer->actor, dz, a2, a3); } void SpawnShellEject(PLAYER* pPlayer, int a2, int a3) { POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; - pPlayer->zView = pPlayer->actor->int_pos().Z - pPosture->eyeAboveZ; - int t = pPlayer->zWeapon - pPlayer->zView; + pPlayer->zView = pPlayer->actor->spr.pos.Z - pPosture->eyeAboveZ * zinttoworld; + int t = pPlayer->zWeapon - pPlayer->zView * zworldtoint; int dz = pPlayer->zWeapon - t + (t >> 2); fxSpawnEjectingShell(pPlayer->actor, dz, a2, a3); } diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index c1de25186..d240587e8 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -73,7 +73,7 @@ struct BloodPlayer native native int nPlayer; // Connect id //native int nSprite; native int lifeMode; - native int zView; + native double zView; native int zViewVel; native int zWeapon; native int zWeaponVel;