From afec39aded0c9763060c941306ec35265090d35b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Nov 2021 01:13:54 +0100 Subject: [PATCH] - reworked non-functional anim detection when picking up an item. This would not unregister the item's run list entries because the logic was insufficient. --- source/games/exhumed/src/anims.cpp | 2 ++ source/games/exhumed/src/exhumed.h | 2 ++ source/games/exhumed/src/items.cpp | 2 +- source/games/exhumed/src/player.cpp | 7 +++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index dc39bbdeb..79fa3fafe 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -111,6 +111,8 @@ DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, int x, int y, pActor->nIndex = 0; pActor->nIndex2 = SeqOffsets[val] + val2; pActor->pTarget = nullptr; + pActor->nDamage = pActor->nRun; + pActor->nPhase = ITEM_MAGIC; if (nFlag & 0x80) { pSprite->cstat |= 0x2; // set transluscence diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 34045cb5e..d8b36a3dd 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -39,6 +39,8 @@ BEGIN_PS_NS enum { kTimerTicks = 120 }; +const int ITEM_MAGIC = 0x4711; + enum basepal_t { BASEPAL = 0, ANIMPAL, diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index fc915ab49..6ad3da237 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -146,7 +146,7 @@ void BuildItemAnim(DExhumedActor* pActor) void DestroyItemAnim(DExhumedActor* actor) { - if (actor && actor->s().owner == 0) + if (actor && actor->s().owner >= 0) DestroyAnim(actor); } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 3a17964f0..218dadbec 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1349,8 +1349,11 @@ sectdone: // CHECKME - is order of evaluation correct? if (!mplevel || (var_70 >= 25 && (var_70 <= 25 || var_70 == 50))) { - DestroyItemAnim(pActorB); - DeleteActor(pActorB); + // If this is an anim we need to properly destroy it so we need to do some proper detection and not wild guesses. + if (pActorB->nRun == pActorB->nDamage && pActorB->nRun != 0 && pActorB->nPhase == ITEM_MAGIC) + DestroyAnim(pActorB); + else + DeleteActor(pActorB); } else {