From b127c379392e31a9df467f291e9877d23cc28170 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 12 Sep 2022 21:16:31 +1000 Subject: [PATCH] - Blood: Floatify all the bobbing/swaying code. --- source/games/blood/src/hudsprites.cpp | 8 ++-- source/games/blood/src/player.cpp | 40 +++++++++---------- source/games/blood/src/player.h | 24 +++++------ source/games/blood/src/view.cpp | 22 +++++----- .../static/zscript/games/blood/bloodgame.zs | 8 ++-- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index abefeeb71..c9d63c3c3 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -118,13 +118,13 @@ void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, dou { if (cl_hudinterpolation) { - cX += (bobx / 256.); - cY += (boby / 256.) + (zDelta * 2.); + cX += bobx; + cY += boby + (zDelta * 2.); } else { - cX += (int(bobx) >> 8); - cY += (int(boby) >> 8) + int(zDelta * 2); + cX += int(bobx); + cY += int(boby) + int(zDelta * 2); } } else diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 9a1506c1e..43b0b10a3 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -102,30 +102,30 @@ POSTURE gPostureDefaults[kModeMax][kPostureMax] = { // normal human { - { 0x4000, 0x4000, 0x4000, 14, 17, 24, 16, 32, 80, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 }, - { 0x1200, 0x1200, 0x1200, 14, 17, 24, 16, 32, 80, 20, 16, -0x600, 0xb0, 0x5b05, 0 }, - { 0x2000, 0x2000, 0x2000, 22, 28, 24, 16, 16, 40, 8, 6, -0x600, 0xb0, 0, 0 }, + { 0x4000, 0x4000, 0x4000, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 }, + { 0x1200, 0x1200, 0x1200, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -0x600, 0xb0, 0x5b05, 0 }, + { 0x2000, 0x2000, 0x2000, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -0x600, 0xb0, 0, 0 }, }, // normal beast { - { 0x4000, 0x4000, 0x4000, 14, 17, 24, 16, 32, 80, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 }, - { 0x1200, 0x1200, 0x1200, 14, 17, 24, 16, 32, 80, 20, 16, -0x600, 0xb0, 0x5b05, 0 }, - { 0x2000, 0x2000, 0x2000, 22, 28, 24, 16, 16, 40, 8, 6, -0x600, 0xb0, 0, 0 }, + { 0x4000, 0x4000, 0x4000, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 }, + { 0x1200, 0x1200, 0x1200, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -0x600, 0xb0, 0x5b05, 0 }, + { 0x2000, 0x2000, 0x2000, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -0x600, 0xb0, 0, 0 }, }, // shrink human { - { 10384, 10384, 10384, 14, 17, 24, 16, 32, 80, 22, 18, 3072, 144, -564586, -1329173 }, - { 2108, 2108, 2108, 14, 17, 24, 16, 32, 80, 20, 16, -1536, 176, 0x5b05, 0 }, - { 2192, 2192, 2192, 22, 28, 24, 16, 16, 40, 8, 6, -1536, 176, 0, 0 }, + { 10384, 10384, 10384, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 3072, 144, -564586, -1329173 }, + { 2108, 2108, 2108, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -1536, 176, 0x5b05, 0 }, + { 2192, 2192, 2192, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -1536, 176, 0, 0 }, }, // grown human { - { 19384, 19384, 19384, 14, 17, 24, 16, 32, 80, 22, 18, 3072, 144, -1014586, -1779173 }, - { 5608, 5608, 5608, 14, 17, 24, 16, 32, 80, 20, 16, -1536, 176, 0x5b05, 0 }, - { 11192, 11192, 11192, 22, 28, 24, 16, 16, 40, 8, 6, -1536, 176, 0, 0 }, + { 19384, 19384, 19384, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 3072, 144, -1014586, -1779173 }, + { 5608, 5608, 5608, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -1536, 176, 0x5b05, 0 }, + { 11192, 11192, 11192, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -1536, 176, 0, 0 }, }, }; @@ -1884,10 +1884,10 @@ void playerProcess(PLAYER* pPlayer) { pPlayer->bobAmp = (pPlayer->bobAmp + 17) & 2047; pPlayer->swayAmp = (pPlayer->swayAmp + 17) & 2047; - pPlayer->bobHeight = MulScale(pPosture->bobV * 10, Sin(pPlayer->bobAmp * 2), 30); - pPlayer->bobWidth = MulScale(pPosture->bobH * pPlayer->bobPhase, Sin(pPlayer->bobAmp - 256), 30); - pPlayer->swayHeight = MulScale(pPosture->swayV * pPlayer->bobPhase, Sin(pPlayer->swayAmp * 2), 30); - pPlayer->swayWidth = MulScale(pPosture->swayH * pPlayer->bobPhase, Sin(pPlayer->swayAmp - 0x155), 30); + pPlayer->bobHeight = pPosture->bobV * 10 * BobVal(pPlayer->bobAmp * 2); + pPlayer->bobWidth = pPosture->bobH * pPlayer->bobPhase * BobVal(pPlayer->bobAmp - 256); + pPlayer->swayHeight = pPosture->swayV * pPlayer->bobPhase * BobVal(pPlayer->swayAmp * 2); + pPlayer->swayWidth = pPosture->swayH * pPlayer->bobPhase * BobVal(pPlayer->swayAmp - 0x155); } else { @@ -1907,10 +1907,10 @@ void playerProcess(PLAYER* pPlayer) pPlayer->bobPhase = ClipHigh(pPlayer->bobPhase + nSpeed, 30); } } - pPlayer->bobHeight = MulScale(pPosture->bobV * pPlayer->bobPhase, Sin(pPlayer->bobAmp * 2), 30); - pPlayer->bobWidth = MulScale(pPosture->bobH * pPlayer->bobPhase, Sin(pPlayer->bobAmp - 256), 30); - pPlayer->swayHeight = MulScale(pPosture->swayV * pPlayer->bobPhase, Sin(pPlayer->swayAmp * 2), 30); - pPlayer->swayWidth = MulScale(pPosture->swayH * pPlayer->bobPhase, Sin(pPlayer->swayAmp - 0x155), 30); + pPlayer->bobHeight = pPosture->bobV * pPlayer->bobPhase * BobVal(pPlayer->bobAmp * 2); + pPlayer->bobWidth = pPosture->bobH * pPlayer->bobPhase * BobVal(pPlayer->bobAmp - 256); + pPlayer->swayHeight = pPosture->swayV * pPlayer->bobPhase * BobVal(pPlayer->swayAmp * 2); + pPlayer->swayWidth = pPosture->swayH * pPlayer->bobPhase * BobVal(pPlayer->swayAmp - 0x155); } pPlayer->flickerEffect = 0; pPlayer->quakeEffect = ClipLow(pPlayer->quakeEffect - 4, 0); diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 683283cd5..6c381bd97 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -64,10 +64,10 @@ struct POSTURE int sideAccel; int backAccel; int pace[2]; - int bobV; - int bobH; - int swayV; - int swayH; + double bobV; + double bobH; + double swayV; + double swayH; double eyeAboveZ; double weaponAboveZ; int xOffset; @@ -94,16 +94,16 @@ struct PLAYER int sceneQav; // by NoOne: used to keep qav id int bobPhase; int bobAmp; - int bobHeight; - int bobWidth; - int obobHeight; - int obobWidth; + double bobHeight; + double bobWidth; + double obobHeight; + double obobWidth; int swayPhase; int swayAmp; - int swayHeight; - int swayWidth; - int oswayHeight; - int oswayWidth; + double swayHeight; + double swayWidth; + double oswayHeight; + double oswayWidth; int nPlayer; // Connect id int lifeMode; int bloodlust; // ---> useless diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index bb79ad361..54b3ed46d 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -412,13 +412,13 @@ void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH if (effectType) { int nValue = ClipHigh(effectType * 8, 2000); - cH += buildhoriz(QRandom2(nValue >> 8)); - cA += mapangle(QRandom2(nValue >> 8)); + cH += buildfhoriz(QRandom2F(nValue * (1. / 256.))); + cA += DAngle::fromBuildf(QRandom2F(nValue * (1. / 256.))); cPos.X += QRandom2F(nValue * inttoworld) * inttoworld; cPos.Y += QRandom2F(nValue * inttoworld) * inttoworld; cPos.Z += QRandom2F(nValue) * zinttoworld; - pshakeX += QRandom2(nValue); - pshakeY += QRandom2(nValue); + pshakeX += QRandom2F(nValue) * (1. / 256.); + pshakeY += QRandom2F(nValue) * (1. / 256.); } }; doEffect(pPlayer->flickerEffect); @@ -493,10 +493,10 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& c cPos.XY() = pPlayer->actor->interpolatedpos(interpfrac).XY(); cPos.Z = interpolatedvalue(pPlayer->ozView, pPlayer->zView, interpfrac); zDelta = interpolatedvalue(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView - 12, interpfrac); - bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac); - bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac); - shakeX = interpolatedvalue(pPlayer->oswayWidth, pPlayer->swayWidth, interpfrac); - shakeY = interpolatedvalue(pPlayer->oswayHeight, pPlayer->swayHeight, interpfrac); + bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, interpfrac); + bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, interpfrac); + shakeX = interpolatedvalue(pPlayer->oswayWidth, pPlayer->swayWidth, interpfrac); + shakeY = interpolatedvalue(pPlayer->oswayHeight, pPlayer->swayHeight, interpfrac); if (!SyncInput()) { @@ -518,12 +518,12 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& c { if (cl_viewhbob) { - cPos.X -= bobWidth * cA.Sin() * (1. / 256.); - cPos.Y += bobWidth * cA.Cos() * (1. / 256.); + cPos.X -= bobWidth * cA.Sin(); + cPos.Y += bobWidth * cA.Cos(); } if (cl_viewvbob) { - cPos.Z += bobHeight * zinttoworld; + cPos.Z += bobHeight; } cPos.Z += FixedToFloat<24>(cH.asq16() * 10); } diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index 200db5fa3..f2a5f675f 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -64,12 +64,12 @@ struct BloodPlayer native native int sceneQav; // by NoOne: used to keep qav id native int bobPhase; native int bobAmp; - native int bobHeight; - native int bobWidth; + native double bobHeight; + native double bobWidth; native int swayPhase; native int swayAmp; - native int swayHeight; - native int swayWidth; + native double swayHeight; + native double swayWidth; native int nPlayer; // Connect id //native int nSprite; native int lifeMode;