From 8dbd0f10d30aceb2ce2a6f4bdd1b9465509af8ce Mon Sep 17 00:00:00 2001 From: carnivoroussociety <38839485+carnivoroussociety@users.noreply.github.com> Date: Thu, 7 Oct 2021 06:20:57 +1000 Subject: [PATCH] Refactored DUDEEXTRA struct and correctly init state # Conflicts: # source/games/blood/src/aiboneel.cpp # source/games/blood/src/aicerber.cpp # source/games/blood/src/aigarg.cpp # source/games/blood/src/aighost.cpp # source/games/blood/src/aitchern.cpp --- source/games/blood/src/actor.cpp | 6 +- source/games/blood/src/ai.cpp | 222 ++++++++++++--------------- source/games/blood/src/ai.h | 26 +--- source/games/blood/src/aibat.cpp | 14 +- source/games/blood/src/aiboneel.cpp | 18 +-- source/games/blood/src/aicerber.cpp | 12 +- source/games/blood/src/aigarg.cpp | 12 +- source/games/blood/src/aighost.cpp | 12 +- source/games/blood/src/aispid.cpp | 6 +- source/games/blood/src/aitchern.cpp | 12 +- source/games/blood/src/aiunicult.cpp | 4 +- source/games/blood/src/loadsave.cpp | 7 +- source/games/blood/src/nnexts.cpp | 2 +- 13 files changed, 157 insertions(+), 196 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index afdcd1faa..862eb29a8 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3553,17 +3553,17 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag break; case kDudeSpiderBrown: - if (Owner) Owner->dudeExtra.at6.u1.xval2--; + if (Owner) Owner->dudeExtra.stats.birthCounter--; genericDeath(actor, nSeq, 1803, dudeInfo[nType].seqStartID + nSeq); break; case kDudeSpiderRed: - if (Owner) Owner->dudeExtra.at6.u1.xval2--; + if (Owner) Owner->dudeExtra.stats.birthCounter--; genericDeath(actor, nSeq, 1803, dudeInfo[nType].seqStartID + nSeq); break; case kDudeSpiderBlack: - if (Owner) Owner->dudeExtra.at6.u1.xval2--; + if (Owner) Owner->dudeExtra.stats.birthCounter--; genericDeath(actor, nSeq, 1803, dudeInfo[nType].seqStartID + nSeq); break; diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 99ce8a7a4..8ca8430c8 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -387,10 +387,9 @@ void aiActivateDude(DBloodActor* actor) { case kDudePhantasm: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &ghostSearch); else @@ -406,9 +405,8 @@ void aiActivateDude(DBloodActor* actor) case kDudeCultistTNT: case kDudeCultistBeast: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) { switch (pXSprite->medium) @@ -451,9 +449,8 @@ void aiActivateDude(DBloodActor* actor) #ifdef NOONE_EXTENSIONS case kDudeModernCustom: { - DUDEEXTRA_at6_u1* pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) { if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); @@ -474,8 +471,8 @@ void aiActivateDude(DBloodActor* actor) #endif case kDudeCultistTommyProne: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 1; pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 1; pSprite->type = kDudeCultistTommy; if (actor->GetTarget() == nullptr) { @@ -511,9 +508,8 @@ void aiActivateDude(DBloodActor* actor) } case kDudeCultistShotgunProne: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 1; pSprite->type = kDudeCultistShotgun; if (actor->GetTarget() == nullptr) { @@ -555,10 +551,9 @@ void aiActivateDude(DBloodActor* actor) break; case kDudeBat: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (!pSprite->flags) pSprite->flags = 9; if (actor->GetTarget() == nullptr) @@ -573,10 +568,9 @@ void aiActivateDude(DBloodActor* actor) } case kDudeBoneEel: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &eelSearch); else @@ -591,13 +585,12 @@ void aiActivateDude(DBloodActor* actor) } case kDudeGillBeast: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; XSECTOR *pXSector = NULL; if (sector[pSprite->sectnum].extra > 0) pXSector = &xsector[sector[pSprite->sectnum].extra]; - pDudeExtraE->xval1 = 0; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) { if (pXSector && pXSector->Underwater) @@ -620,9 +613,8 @@ void aiActivateDude(DBloodActor* actor) } case kDudeZombieAxeNormal: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &zombieASearch); else @@ -650,25 +642,22 @@ void aiActivateDude(DBloodActor* actor) } case kDudeZombieAxeBuried: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (pXSprite->aiState == &zombieEIdle) aiNewState(actor, &zombieEUp); break; } case kDudeZombieAxeLaying: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (pXSprite->aiState == &zombieSIdle) aiNewState(actor, &zombie13AC2C); break; } case kDudeZombieButcher: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &zombieFSearch); else @@ -694,10 +683,9 @@ void aiActivateDude(DBloodActor* actor) aiNewState(actor, &zombieFBurnChase); break; case kDudeGargoyleFlesh: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &gargoyleFSearch); else @@ -712,10 +700,9 @@ void aiActivateDude(DBloodActor* actor) } case kDudeGargoyleStone: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) aiNewState(actor, &gargoyleFSearch); else @@ -833,9 +820,8 @@ void aiActivateDude(DBloodActor* actor) break; case kDudeSpiderMother: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 1; pSprite->flags |= 2; pSprite->cstat &= ~8; if (actor->GetTarget() == nullptr) @@ -849,9 +835,8 @@ void aiActivateDude(DBloodActor* actor) } case kDudeTinyCaleb: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (actor->GetTarget() == nullptr) { switch (pXSprite->medium) @@ -882,9 +867,8 @@ void aiActivateDude(DBloodActor* actor) } case kDudeBeast: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 1; - pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 1; if (actor->GetTarget() == nullptr) { switch (pXSprite->medium) @@ -1128,7 +1112,12 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType if (nDmgType == kDamageTesla) { DUDEEXTRA *pDudeExtra = &actor->dudeExtra; - pDudeExtra->recoil = 1; + pDudeExtra->teslaHit = 1; + } + else if (!VanillaMode()) // reset tesla hit state if received different type of damage + { + DUDEEXTRA *pDudeExtra = &actor->dudeExtra; + pDudeExtra->teslaHit = 0; } const bool fixRandomCultist = !cl_bloodvanillaenemies && (pSprite->inittype >= kDudeBase) && (pSprite->inittype < kDudeMax) && !VanillaMode(); // fix burning cultists randomly switching types underwater switch (pSprite->type) @@ -1261,7 +1250,7 @@ void RecoilDude(DBloodActor* actor) #ifdef NOONE_EXTENSIONS case kDudeModernCustom: { GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); int rChance = getRecoilChance(pSprite); - if (pExtra->canElectrocute && pDudeExtra->recoil && !spriteIsUnderwater(pSprite, false)) { + if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(pSprite, false)) { if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(pSprite, &genDudeRecoilTesla); else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(pSprite, &genDudeRecoilL); @@ -1302,7 +1291,7 @@ void RecoilDude(DBloodActor* actor) } - pDudeExtra->recoil = 0; + pDudeExtra->teslaHit = 0; break; } #endif @@ -1315,11 +1304,11 @@ void RecoilDude(DBloodActor* actor) else aiPlay3DSound(pSprite, 1013+Random(2), AI_SFX_PRIORITY_2, -1); if (!v4 && pXSprite->medium == kMediumNormal) { - if (pDudeExtra->recoil) aiNewState(actor, &cultistTeslaRecoil); + if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil); else aiNewState(actor, &cultistRecoil); } else if (v4 && pXSprite->medium == kMediumNormal) { - if (pDudeExtra->recoil) aiNewState(actor, &cultistTeslaRecoil); + if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil); else if (gGameOptions.nDifficulty > 0) aiNewState(actor, &cultistProneRecoil); else aiNewState(actor, &cultistRecoil); } @@ -1327,7 +1316,7 @@ void RecoilDude(DBloodActor* actor) aiNewState(actor, &cultistSwimRecoil); else { - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil); else aiNewState(actor, &cultistRecoil); @@ -1343,7 +1332,7 @@ void RecoilDude(DBloodActor* actor) #endif case kDudeZombieButcher: aiPlay3DSound(pSprite, 1202, AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &zombieFTeslaRecoil); else aiNewState(actor, &zombieFRecoil); @@ -1351,7 +1340,7 @@ void RecoilDude(DBloodActor* actor) case kDudeZombieAxeNormal: case kDudeZombieAxeBuried: aiPlay3DSound(pSprite, 1106, AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil && pXSprite->data3 > pDudeInfo->startHealth/3) + if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3) aiNewState(actor, &zombieATeslaRecoil); else if (pXSprite->data3 > pDudeInfo->startHealth/3) aiNewState(actor, &zombieARecoil2); @@ -1373,7 +1362,7 @@ void RecoilDude(DBloodActor* actor) break; case kDudeCerberusTwoHead: aiPlay3DSound(pSprite, 2302+Random(2), AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil && pXSprite->data3 > pDudeInfo->startHealth/3) + if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3) aiNewState(actor, &cerberusTeslaRecoil); else aiNewState(actor, &cerberusRecoil); @@ -1384,7 +1373,7 @@ void RecoilDude(DBloodActor* actor) break; case kDudeHellHound: aiPlay3DSound(pSprite, 1302, AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &houndTeslaRecoil); else aiNewState(actor, &houndRecoil); @@ -1422,7 +1411,7 @@ void RecoilDude(DBloodActor* actor) } case kDudePhantasm: aiPlay3DSound(pSprite, 1602, AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &ghostTeslaRecoil); else aiNewState(actor, &ghostRecoil); @@ -1439,7 +1428,7 @@ void RecoilDude(DBloodActor* actor) break; case kDudeInnocent: aiPlay3DSound(pSprite, 7007+Random(2), AI_SFX_PRIORITY_2, -1); - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &innocentTeslaRecoil); else aiNewState(actor, &innocentRecoil); @@ -1447,7 +1436,7 @@ void RecoilDude(DBloodActor* actor) case kDudeTinyCaleb: if (pXSprite->medium == kMediumNormal) { - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &tinycalebTeslaRecoil); else aiNewState(actor, &tinycalebRecoil); @@ -1456,7 +1445,7 @@ void RecoilDude(DBloodActor* actor) aiNewState(actor, &tinycalebSwimRecoil); else { - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &tinycalebTeslaRecoil); else aiNewState(actor, &tinycalebRecoil); @@ -1466,7 +1455,7 @@ void RecoilDude(DBloodActor* actor) aiPlay3DSound(pSprite, 9004+Random(2), AI_SFX_PRIORITY_2, -1); if (pXSprite->medium == kMediumNormal) { - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &beastTeslaRecoil); else aiNewState(actor, &beastRecoil); @@ -1475,7 +1464,7 @@ void RecoilDude(DBloodActor* actor) aiNewState(actor, &beastSwimRecoil); else { - if (pDudeExtra->recoil) + if (pDudeExtra->teslaHit) aiNewState(actor, &beastTeslaRecoil); else aiNewState(actor, &beastRecoil); @@ -1493,7 +1482,7 @@ void RecoilDude(DBloodActor* actor) aiNewState(actor, &genRecoil); break; } - pDudeExtra->recoil = 0; + pDudeExtra->teslaHit = 0; } } @@ -1679,8 +1668,11 @@ void aiInitSprite(spritetype *pSprite) if (nXSector > 0) pXSector = &xsector[nXSector]; DUDEEXTRA *pDudeExtra = &actor->dudeExtra; - pDudeExtra->recoil = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtra->teslaHit = 0; pDudeExtra->time = 0; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 0; #ifdef NOONE_EXTENSIONS int stateTimer = -1, targetMarker = -1; @@ -1706,64 +1698,48 @@ void aiInitSprite(spritetype *pSprite) case kDudeCultistTNT: case kDudeCultistBeast: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; aiNewState(actor, &cultistIdle); break; } case kDudeCultistTommyProne: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; aiNewState(actor, &fanaticProneIdle); break; } case kDudeCultistShotgunProne: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; aiNewState(actor, &cultistProneIdle); break; } case kDudeZombieButcher: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &zombieFIdle); break; } case kDudeZombieAxeNormal: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &zombieAIdle); break; } case kDudeZombieAxeLaying: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &zombieSIdle); pSprite->flags &= ~1; break; } case kDudeZombieAxeBuried: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &zombieEIdle); break; } case kDudeGargoyleFlesh: case kDudeGargoyleStone: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 0; aiNewState(actor, &gargoyleFIdle); break; } @@ -1772,12 +1748,19 @@ void aiInitSprite(spritetype *pSprite) aiNewState(actor, &gargoyleStatueIdle); break; case kDudeCerberusTwoHead: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &cerberusIdle); break; } + case kDudeCerberusOneHead: { + if (!VanillaMode()) { + pDudeExtraE->thinkTime = 0; + aiNewState(actor, &cerberus2Idle); + break; + } + aiNewState(actor, &genIdle); + break; + } case kDudeHellHound: aiNewState(actor, &houndIdle); break; @@ -1786,10 +1769,8 @@ void aiInitSprite(spritetype *pSprite) break; case kDudePhantasm: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 0; aiNewState(actor, &ghostIdle); break; } @@ -1801,10 +1782,8 @@ void aiInitSprite(spritetype *pSprite) break; case kDudeBoneEel: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 0; aiNewState(actor, &eelIdle); break; } @@ -1813,10 +1792,8 @@ void aiInitSprite(spritetype *pSprite) break; case kDudeBat: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; + pDudeExtraE->active = 0; aiNewState(actor, &batIdle); break; } @@ -1824,27 +1801,22 @@ void aiInitSprite(spritetype *pSprite) case kDudeSpiderRed: case kDudeSpiderBlack: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &spidIdle); break; } case kDudeSpiderMother: { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; + pDudeExtraE->birthCounter = 0; aiNewState(actor, &spidIdle); break; } case kDudeTchernobog: { - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - pDudeExtraE->xval2 = 0; - pDudeExtraE->xval1 = 0; + pDudeExtraE->active = 0; + pDudeExtraE->thinkTime = 0; aiNewState(actor, &tchernobogIdle); break; } diff --git a/source/games/blood/src/ai.h b/source/games/blood/src/ai.h index 6c84bb094..9a6e1aa21 100644 --- a/source/games/blood/src/ai.h +++ b/source/games/blood/src/ai.h @@ -51,31 +51,21 @@ enum AI_SFX_PRIORITY { }; -struct DUDEEXTRA_at6_u1 +struct DUDEEXTRA_STATS { - int xval1; - int xval2; - char xval3; -}; - -struct DUDEEXTRA_at6_u2 -{ - int xval1; - char xval2; + union { + int thinkTime; + int birthCounter; + }; + char active; }; struct DUDEEXTRA { int time; - int recoil; + char teslaHit; int prio; - // Broken by design... :? - union - { - DUDEEXTRA_at6_u1 u1; - DUDEEXTRA_at6_u2 u2; - } at6; - //DUDEEXTRA_at6 at6; + DUDEEXTRA_STATS stats; }; struct TARGETTRACK { diff --git a/source/games/blood/src/aibat.cpp b/source/games/blood/src/aibat.cpp index 145239d7a..862a9799f 100644 --- a/source/games/blood/src/aibat.cpp +++ b/source/games/blood/src/aibat.cpp @@ -84,12 +84,12 @@ static void batThinkTarget(DBloodActor* actor) auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10) - pDudeExtraE->xval2++; - else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z); @@ -433,8 +433,8 @@ void batMoveToCeil(DBloodActor* actor) int nSector = pSprite->sectnum; if (z - pXSprite->targetZ < 0x1000) { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->thinkTime = 0; pSprite->flags = 0; aiNewState(actor, &batIdle); } diff --git a/source/games/blood/src/aiboneel.cpp b/source/games/blood/src/aiboneel.cpp index c59cdb045..1f6c92315 100644 --- a/source/games/blood/src/aiboneel.cpp +++ b/source/games/blood/src/aiboneel.cpp @@ -96,12 +96,12 @@ static void eelThinkTarget(DBloodActor* actor) auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10) - pDudeExtraE->xval2++; - else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z); @@ -129,13 +129,13 @@ static void eelThinkTarget(DBloodActor* actor) int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, pPlayer->nSprite); aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, x, y, z); aiActivateDude(&bloodActors[pXSprite->reference]); } @@ -435,8 +435,8 @@ void eelMoveToCeil(DBloodActor* actor) int nSector = pSprite->sectnum; if (z - pXSprite->targetZ < 0x1000) { - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = 0; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 0; pSprite->flags = 0; aiNewState(actor, &eelIdle); } diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index d6984dd04..efda00e60 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -255,10 +255,10 @@ static void cerberusThinkTarget(DBloodActor* actor) return; } DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10) - pDudeExtraE->xval2++; - else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; @@ -290,13 +290,13 @@ static void cerberusThinkTarget(DBloodActor* actor) int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, pPlayer->nSprite); aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, x, y, z); aiActivateDude(&bloodActors[pXSprite->reference]); } diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index 249e37023..2f0fdebd0 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -216,10 +216,10 @@ static void gargThinkTarget(DBloodActor* actor) return; } DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10) - pDudeExtraE->xval2++; - else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; @@ -248,13 +248,13 @@ static void gargThinkTarget(DBloodActor* actor) int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, pPlayer->nSprite); aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, x, y, z); aiActivateDude(&bloodActors[pXSprite->reference]); } diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index 836e90979..25ef17fa4 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -193,10 +193,10 @@ static void ghostThinkTarget(DBloodActor* actor) return; } DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; - if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10) - pDudeExtraE->xval2++; - else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; @@ -225,14 +225,14 @@ static void ghostThinkTarget(DBloodActor* actor) int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, pPlayer->nSprite); aiActivateDude(&bloodActors[pXSprite->reference]); return; } else if (nDist < pDudeInfo->hearDist) { - pDudeExtraE->xval2 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, x, y, z); aiActivateDude(&bloodActors[pXSprite->reference]); return; diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index 35c3d22c5..9ea9e4ff7 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -146,14 +146,14 @@ void SpidBirthSeqCallback(int, DBloodActor* actor) DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); if (!actor->ValidateTarget(__FUNCTION__)) return; spritetype *pTarget = &actor->GetTarget()->s(); - DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1; + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; int nAngle = getangle(dx, dy); int nDist = approxDist(dx, dy); DBloodActor* spawned = nullptr; - if (IsPlayerSprite(pTarget) && pDudeExtraE->xval2 < 10) + if (IsPlayerSprite(pTarget) && pDudeExtraE->birthCounter < 10) { if (nDist < 0x1a00 && nDist > 0x1400 && abs(pSprite->ang-nAngle) < pDudeInfo->periphery) spawned = actSpawnDude(actor, kDudeSpiderRed, pSprite->clipdist, 0); @@ -164,7 +164,7 @@ void SpidBirthSeqCallback(int, DBloodActor* actor) if (spawned) { - pDudeExtraE->xval2++; + pDudeExtraE->birthCounter++; spawned->SetOwner(spawned); gKillMgr.AddNewKill(1); } diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index 586185368..8f7f28c0c 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -227,10 +227,10 @@ static void sub_725A4(DBloodActor* actor) return; } DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); - DUDEEXTRA_at6_u2 *pDudeExtraE = &actor->dudeExtra.at6.u2; - if (pDudeExtraE->xval2 && pDudeExtraE->xval1 < 10) - pDudeExtraE->xval1++; - else if (pDudeExtraE->xval1 >= 10 && pDudeExtraE->xval2) + DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats; + if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10) + pDudeExtraE->thinkTime++; + else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active) { pXSprite->goalAng += 256; POINT3D *pTarget = &baseSprite[pSprite->index]; @@ -259,13 +259,13 @@ static void sub_725A4(DBloodActor* actor) int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, pPlayer->nSprite); aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { - pDudeExtraE->xval1 = 0; + pDudeExtraE->thinkTime = 0; aiSetTarget_(pXSprite, x, y, z); aiActivateDude(&bloodActors[pXSprite->reference]); } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index b5745799e..55812b488 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -2230,8 +2230,8 @@ void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite) auto actor = &bloodActors[pSprite->index]; switch (pSprite->type) { case kDudeModernCustom: { - DUDEEXTRA_at6_u1* pDudeExtraE = &actor->dudeExtra.at6.u1; - pDudeExtraE->xval3 = pDudeExtraE->xval1 = 0; + DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats; + pDudeExtraE->active = 0; aiGenDudeNewState(pSprite, &genDudeIdleL); break; } diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index 1763c8a49..560088ee2 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -438,11 +438,10 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DUDEEXTRA& w, DUDE if (arc.BeginObject(keyname)) { arc("time", w.time, &empty) - ("recoil", w.recoil, &empty) + ("teslaHit", w.teslaHit, &empty2) ("prio", w.prio, &empty) - ("x1", w.at6.u1.xval1, &empty) - ("x2", w.at6.u1.xval2, &empty) - ("x3", w.at6.u1.xval3, &empty2) + ("thinkTime", w.stats.thinkTime, &empty) + ("active", w.stats.active, &empty2) .EndObject(); } return arc; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 0add033df..d81eaaa24 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -3082,7 +3082,7 @@ void damageSprites(XSPRITE* pXSource, spritetype* pSprite) { if (forceRecoil && !pPlayer) { pXSprite->data3 = 32767; - actor->dudeExtra.recoil = (dmgType == kDmgElectric) ? 1 : 0; + actor->dudeExtra.teslaHit = (dmgType == kDmgElectric) ? 1 : 0; if (pXSprite->aiState->stateType != kAiStateRecoil) RecoilDude(&bloodActors[pXSprite->reference]); }