From 484d01617202983a891b5bbb40c5bf1b8ece008f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Aug 2021 19:22:51 +0200 Subject: [PATCH] - cleaned up burn code. --- source/games/blood/src/actor.cpp | 9 ++++++++- source/games/blood/src/actor.h | 7 ++----- source/games/blood/src/aitchern.cpp | 11 ++++------- source/games/blood/src/aiunicult.cpp | 2 +- source/games/blood/src/bloodactor.h | 7 ------- source/games/blood/src/messages.cpp | 4 ++-- source/games/blood/src/nnexts.cpp | 8 ++++---- source/games/blood/src/player.cpp | 2 +- source/games/blood/src/weapon.cpp | 2 +- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index fa3302c97..705593214 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2976,7 +2976,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType) else { pXSprite->burnTime = 0; - pXSprite->burnSource = -1; + actor->SetBurnSource(nullptr); damageType = kDamageFall; } } @@ -7369,6 +7369,13 @@ void MakeSplash(DBloodActor* actor) } } +void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime) +{ + auto pXSprite = &pTarget->x(); + pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); + pTarget->SetBurnSource(pSource); +} + //--------------------------------------------------------------------------- // // diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index 20f52078b..7296e9a8f 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -198,11 +198,6 @@ template bool IsAmmoSprite(T const * const pSprite) return pSprite->type >= kItemAmmoBase && pSprite->type < kItemAmmoMax; } -inline void actBurnSprite(int nSource, XSPRITE *pXSprite, int nTime) -{ - pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); - pXSprite->burnSource = nSource; -} #ifdef POLYMER void actAddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio); @@ -236,6 +231,8 @@ DBloodActor * actSpawnThing(int nSector, int x, int y, int z, int nThingType); DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6); DBloodActor* actFireMissile(DBloodActor *pSprite, int a2, int a3, int a4, int a5, int a6, int nType); +void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime); + int actGetRespawnTime(DBloodActor *pSprite); bool actCheckRespawn(DBloodActor *pSprite); bool actCanSplatWall(int nWall); diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index aaa2b40a2..23d46565a 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -51,13 +51,10 @@ void sub_71A90(int, DBloodActor* actor) XSPRITE* pXSprite = &actor->x(); spritetype* pSprite = &actor->s(); if (!actor->ValidateTarget(__FUNCTION__)) return; - spritetype* pTarget = &actor->GetTarget()->s(); - XSPRITE* pXTarget = &actor->GetTarget()->x(); - int nTarget = pTarget->index; - int nOwner = pSprite->owner; - if (pXTarget->burnTime == 0) - evPostActor(actor->GetTarget(), 0, kCallbackFXFlameLick); - actBurnSprite(nOwner, pXTarget, 40); + auto target = actor->GetTarget(); + if (target->x().burnTime == 0) + evPostActor(target, 0, kCallbackFXFlameLick); + actBurnSprite(actor->GetOwner(), target, 40); if (Chance(0x6000)) aiNewState(actor, &tcherno13A9D4); } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 3a9a371bf..8e54d037d 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -745,7 +745,7 @@ static void unicultThinkChase(DBloodActor* actor) else aiGenDudeNewState(actor, &genDudeDodgeShortW); return; } - else if (dist <= 4000 && pXTarget->burnTime >= 2000 && pXTarget->burnSource == pSprite->index) + else if (dist <= 4000 && pXTarget->burnTime >= 2000 && targetactor->GetBurnSource() == actor) { if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudePunch); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index eea098660..6278b9f46 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -275,13 +275,6 @@ inline int DeleteSprite(DBloodActor* nSprite) return 0; } -inline void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime) -{ - auto pXSprite = &pTarget->x(); - pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); - pXSprite->burnSource = pSource? pSource->s().index : -1; -} - inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom) { GetSpriteExtents(&actor->s(), top, bottom); diff --git a/source/games/blood/src/messages.cpp b/source/games/blood/src/messages.cpp index 56e9c4e51..a5a7f4215 100644 --- a/source/games/blood/src/messages.cpp +++ b/source/games/blood/src/messages.cpp @@ -311,7 +311,7 @@ const char* GameInterface::GenericCheat(int player, int cheat) { if (!gMe->pXSprite->burnTime) evPostActor(gMe->actor(), 0, kCallbackFXFlameLick); - actBurnSprite(gMe->pSprite->index, gMe->pXSprite, 2400); + actBurnSprite(gMe->actor(), gMe->actor(), 2400); return GStrings("TXTB_FIRED"); } case kCheatEdmark: @@ -324,7 +324,7 @@ const char* GameInterface::GenericCheat(int player, int cheat) gMe->armor[1] = VanillaMode() ? 200 : 3200; if (!gMe->pXSprite->burnTime) evPostActor(gMe->actor(), 0, kCallbackFXFlameLick); - actBurnSprite(gMe->pSprite->index, gMe->pXSprite, 2400); + actBurnSprite(gMe->actor(), gMe->actor(), 2400); return GStrings("TXTB_RETARD"); } case kCheatSterno: diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index aa68f40c9..a1128ff9e 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4710,7 +4710,7 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH) case 65: // compare burn time (in %) var = (objActor->IsDudeActor()) ? 2400 : 1200; if (!condCmp((kPercFull * pXSpr->burnTime) / var, arg1, arg2, cmpOp)) return false; - else if (PUSH && spriRangeIsFine(pXSpr->burnSource)) condPush(aCond, OBJ_SPRITE, 0, objActor->GetBurnSource()); + else if (PUSH && objActor->GetBurnSource()) condPush(aCond, OBJ_SPRITE, 0, objActor->GetBurnSource()); return true; case 66: // any flares stuck in this sprite? @@ -6913,7 +6913,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor) int matesPerEnemy = 1; // dude is burning? - if (pXSprite->burnTime > 0 && spriRangeIsFine(pXSprite->burnSource)) + if (pXSprite->burnTime > 0 && actor->GetBurnSource()) { if (IsBurningDude(actor)) return; else @@ -6985,7 +6985,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor) if (actor->GetBurnSource() == targetactor) { pXSprite->burnTime = 0; - pXSprite->burnSource = -1; + actor->SetBurnSource(nullptr); } // force stop attack dude @@ -6993,7 +6993,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor) if (targetactor->GetBurnSource() == actor) { pXTarget->burnTime = 0; - pXTarget->burnSource = -1; + targetactor->SetBurnSource(nullptr); } } } diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index c0847e3c2..996b1cc66 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -684,7 +684,7 @@ void playerStart(int nPlayer, int bNewLevel) pSprite->clipdist = pDudeInfo->clipdist; pSprite->flags = 15; pXSprite->burnTime = 0; - pXSprite->burnSource = -1; + actor->SetBurnSource(nullptr); pPlayer->pXSprite->health = pDudeInfo->startHealth<<4; pPlayer->pSprite->cstat &= (unsigned short)~32768; pPlayer->bloodlust = 0; diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 85b1cd8e7..7c3af12b2 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -1684,7 +1684,7 @@ void AltFireNapalm(int , PLAYER *pPlayer) pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12); UseAmmo(pPlayer, 4, pXSprite->data4); seqSpawn(22, 3, pMissile->extra, -1); - actBurnSprite(pPlayer->pSprite->index, pXSprite, 600); + actBurnSprite(pPlayer->actor(), &bloodActors[pMissile->index], 600); evPostActor(&bloodActors[pMissile->index], 0, kCallbackFXFlameLick); sfxPlay3DSound(pMissile, 480, 2, 0); pPlayer->visibility = 30;