From 43b8f92f919cd8762535ae4c4756bf3ece20fb66 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 7 Oct 2022 19:35:43 +0200 Subject: [PATCH] - all of Exhumed except BuildAnim --- source/games/exhumed/src/anims.cpp | 8 ++++---- source/games/exhumed/src/bullet.cpp | 7 +++---- source/games/exhumed/src/items.cpp | 14 +++++++------- source/games/exhumed/src/queen.cpp | 4 ++-- source/games/exhumed/src/ramses.cpp | 26 ++++++++++++-------------- source/games/exhumed/src/snake.cpp | 4 ++-- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index ba569b117..7ac3c2304 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -92,8 +92,7 @@ DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, const DVector } pActor->clipdist = 2.5; - pActor->spr.xrepeat = nRepeat; - pActor->spr.yrepeat = nRepeat; + pActor->spr.SetScale(nRepeat * REPEAT_SCALE, nRepeat * REPEAT_SCALE); pActor->spr.picnum = 1; pActor->spr.angle = nullAngle; pActor->spr.xoffset = 0; @@ -269,7 +268,7 @@ void BuildExplosion(DExhumedActor* pActor) edx = 34; } - BuildAnim(nullptr, edx, 0, pActor->spr.pos, pActor->sector(), pActor->spr.xrepeat, 4); + BuildAnim(nullptr, edx, 0, pActor->spr.pos, pActor->sector(), pActor->spr.ScaleX() * INV_REPEAT_SCALE, 4); } //--------------------------------------------------------------------------- @@ -284,7 +283,8 @@ void BuildSplash(DExhumedActor* pActor, sectortype* pSector) if (pActor->spr.statnum != 200) { - nRepeat = pActor->spr.xrepeat + (RandomWord() % pActor->spr.xrepeat); + int rep = int(pActor->spr.ScaleX() * INV_REPEAT_SCALE); + nRepeat = rep + (RandomWord() % rep); nSound = kSound0; } else diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index b7f44ef23..c75467944 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -183,7 +183,7 @@ void IgniteSprite(DExhumedActor* pActor) { pAnimActor->pTarget = pActor; ChangeActorStat(pAnimActor, kStatIgnited); - pAnimActor->spr.yrepeat = (uint8_t)max(1, (tileHeight(pAnimActor->spr.picnum) * 32) / nFlameHeight); + pAnimActor->spr.SetScaleY(max(1, (tileHeight(pAnimActor->spr.picnum) * 32) / nFlameHeight) * REPEAT_SCALE); } } @@ -636,8 +636,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, double fZOffset, DA nRepeat = 30; } - pBulletActor->spr.xrepeat = (uint8_t)nRepeat; - pBulletActor->spr.yrepeat = (uint8_t)nRepeat; + pBulletActor->spr.SetScale(nRepeat * REPEAT_SCALE, nRepeat * REPEAT_SCALE); pBulletActor->spr.xoffset = 0; pBulletActor->spr.yoffset = 0; pBulletActor->spr.angle = nAngle; @@ -808,7 +807,7 @@ void AIBullet::Tick(RunListEvent* ev) if (nFlag & 0x80) { - BuildAnim(nullptr, 45, 0, pActor->spr.pos, pActor->sector(), pActor->spr.xrepeat, 0); + BuildAnim(nullptr, 45, 0, pActor->spr.pos, pActor->sector(), pActor->spr.ScaleX() * REPEAT_SCALE, 0); } BulletList[nBullet].nFrame++; diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index 6913c5e23..318398d16 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -148,9 +148,9 @@ void BuildItemAnim(DExhumedActor* pActor) else { pActor->spr.intowner = -1; - pActor->spr.yrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; - pActor->spr.xrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; - } + double s = nItemAnimInfo[nItem].repeat * REPEAT_SCALE; + pActor->spr.SetScale(s, s); + } } //--------------------------------------------------------------------------- @@ -440,7 +440,7 @@ void StartRegenerate(DExhumedActor* pActor) if (pos >= Regenerates.Size()) { // ?? CHECKME - pActor->spr.xint = pActor->spr.xrepeat; + pActor->spr.xint = pActor->spr.ScaleX() * INV_REPEAT_SCALE; pActor->spr.inittype = pActor->spr.shade; pActor->spr.yint = pActor->spr.pal; } @@ -474,6 +474,7 @@ void DoRegenerates() for(unsigned i = 0; i < Regenerates.Size(); i++) { DExhumedActor* pActor = GC::ReadBarrier(Regenerates[i]); + double s = pActor->spr.xint * REPEAT_SCALE; if (pActor->spr.extra > 0) { pActor->spr.extra--; @@ -489,7 +490,7 @@ void DoRegenerates() } else { - if (pActor->spr.xrepeat < pActor->spr.xint) + if (pActor->spr.ScaleX() < s) { pActor->spr.AddScaleX(0.03125); pActor->spr.AddScaleY(0.03125); @@ -497,8 +498,7 @@ void DoRegenerates() } } - pActor->spr.yrepeat = (uint8_t)pActor->spr.xint; - pActor->spr.xrepeat = (uint8_t)pActor->spr.xint; + pActor->spr.SetScale(s, s); pActor->spr.pal = (uint8_t)pActor->spr.yint; pActor->spr.yint = 0; pActor->spr.xint = 0; diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 7e07cf407..bd3fe7042 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -1009,8 +1009,8 @@ void AIQueenHead::Tick(RunListEvent* ev) auto pSector =pActor->sector(); auto nAngle = RandomAngle(); - pActor->spr.xrepeat = 127 - QueenHead.nIndex2; - pActor->spr.yrepeat = 127 - QueenHead.nIndex2; + double s = (127 - QueenHead.nIndex2) * REPEAT_SCALE; + pActor->spr.SetScale(s, s); pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE; diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index 15c0590e6..2659ba884 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -55,8 +55,7 @@ int word_964E8 = 0; int word_964EA = 0; int word_964EC = 10; -int nSpiritRepeatX; -int nSpiritRepeatY; +DVector2 nSpiritScale; TObjPtr pSpiritSprite; int nPixelsToShow; int nTalkTime = 0; @@ -67,8 +66,7 @@ void InitSpiritHead() nPixels = 0; auto pSpiritSpr = pSpiritSprite; - nSpiritRepeatX = pSpiritSpr->spr.xrepeat; - nSpiritRepeatY = pSpiritSpr->spr.yrepeat; + nSpiritScale = pSpiritSpr->spr.Scale(); tileLoad(kTileRamsesNormal); // Ramses Normal Head @@ -383,18 +381,18 @@ void DoSpiritHead() if (nHeadStage == 1) { - if (pSpiritSpr->spr.xrepeat > nSpiritRepeatX) + if (pSpiritSpr->spr.ScaleX() > nSpiritScale.X) { - pSpiritSpr->spr.xrepeat -= 2; - if (pSpiritSpr->spr.xrepeat < nSpiritRepeatX) - pSpiritSpr->spr.xrepeat = (uint8_t)nSpiritRepeatX; - } - if (pSpiritSpr->spr.yrepeat > nSpiritRepeatY) - { - pSpiritSpr->spr.yrepeat -= 2; - if (pSpiritSpr->spr.yrepeat < nSpiritRepeatY) - pSpiritSpr->spr.yrepeat = (uint8_t)nSpiritRepeatY; + pSpiritSpr->spr.AddScaleX(-0.03125); + if (pSpiritSpr->spr.ScaleX() < nSpiritScale.X) + pSpiritSpr->spr.SetScaleX(nSpiritScale.X); } + if (pSpiritSpr->spr.ScaleY() > nSpiritScale.Y) + { + pSpiritSpr->spr.AddScaleY(-0.03125); + if (pSpiritSpr->spr.ScaleY() < nSpiritScale.Y) + pSpiritSpr->spr.SetScaleY(nSpiritScale.Y); + } int nCount = 0; for (int i = 0; i < nPixels; i++) diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index e7e2902e6..d97421096 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -221,8 +221,8 @@ void BuildSnake(int nPlayer, double zVal) else { pActor->spr.pos = sprt->spr.pos; - pActor->spr.xrepeat = 40 - 3 * i; - pActor->spr.yrepeat = 40 - 3 * i; + double s = 0.625 + 0.046875 * i; + pActor->spr.SetScale(s, s); } pActor->clipdist = 2.5;