diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 707399022..93ef7cfab 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -54,6 +54,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "nnexts.h" #include "player.h" #include "misc.h" +#include "bloodactor.h" BEGIN_BLD_NS @@ -2743,8 +2744,10 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, } } -void sub_2AA94(spritetype *pSprite, XSPRITE *pXSprite) +void sub_2AA94(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = actOwnerIdToSpriteId(pSprite->owner); actPostSprite(pSprite->index, kStatDecoration); seqSpawn(9, 3, pSprite->extra); @@ -4093,7 +4096,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) if (!IsPlayerSprite(pSprite)) { actDamageSprite(pSprite2->index, pSprite, DAMAGE_TYPE_0, dmg); if (xspriRangeIsFine(pSprite->extra) && !isActive(pSprite->index)) - aiActivateDude(pSprite, &xsprite[pSprite->extra]); + aiActivateDude(&bloodActors[pSprite->index]); } else if (powerupCheck(&gPlayer[pSprite->type - kDudePlayer1], kPwUpJumpBoots) > 0) actDamageSprite(pSprite2->index, pSprite, DAMAGE_TYPE_3, dmg); else actDamageSprite(pSprite2->index, pSprite, DAMAGE_TYPE_0, dmg); @@ -4444,7 +4447,7 @@ int MoveThing(spritetype *pSprite) switch (pSprite->type) { case kThingNapalmBall: - if (zvel[nSprite] == 0 || Chance(0xA000)) sub_2AA94(pSprite, pXSprite); + if (zvel[nSprite] == 0 || Chance(0xA000)) sub_2AA94(&bloodActors[pXSprite->reference]); break; case kThingZombieHead: if (klabs(zvel[nSprite]) > 0x80000) { @@ -5373,8 +5376,10 @@ void actExplodeSprite(spritetype *pSprite) xsprite[nXSprite].data3 = pExplodeInfo->flashEffect; } -void actActivateGibObject(spritetype *pSprite, XSPRITE *pXSprite) +void actActivateGibObject(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int vdx = ClipRange(pXSprite->data1, 0, 31); int vc = ClipRange(pXSprite->data2, 0, 31); int v4 = ClipRange(pXSprite->data3, 0, 31); @@ -5405,7 +5410,7 @@ bool IsUnderWater(spritetype *pSprite) return 0; } -void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite); +void MakeSplash(DBloodActor *actor); void actProcessSprites(void) { @@ -5588,7 +5593,7 @@ void actProcessSprites(void) switch (pSprite->type) { case kThingDripWater: case kThingDripBlood: - MakeSplash(pSprite, pXSprite); + MakeSplash(&bloodActors[pXSprite->reference]); break; #ifdef NOONE_EXTENSIONS case kModernThingThrowableRock: @@ -5907,7 +5912,7 @@ void actProcessSprites(void) pSprite->type = kDudeCerberusOneHead; if (pXSprite->target != -1) aiSetTarget(pXSprite, pXSprite->target); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } } if (pXSprite->Proximity && !pXSprite->isTriggered) @@ -6909,9 +6914,10 @@ void actPostProcess(void) gPostCount = 0; } -void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite) +void MakeSplash(DBloodActor* actor) { - UNREFERENCED_PARAMETER(pXSprite); + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); pSprite->flags &= ~2; int nXSprite = pSprite->extra; pSprite->z -= 4 << 8; diff --git a/source/blood/src/actor.h b/source/blood/src/actor.h index 2968cee84..7333f96b0 100644 --- a/source/blood/src/actor.h +++ b/source/blood/src/actor.h @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +class DBloodActor; + enum DAMAGE_TYPE { DAMAGE_TYPE_0 = 0, DAMAGE_TYPE_1, // Flame @@ -225,7 +227,7 @@ void ConcussSprite(int a1, spritetype *pSprite, int x, int y, int z, int a6); int actWallBounceVector(int *x, int *y, int nWall, int a4); int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5); void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11, int a12, int a13); -void sub_2AA94(spritetype *pSprite, XSPRITE *pXSprite); +void sub_2AA94(DBloodActor *actor); spritetype *actSpawnFloor(spritetype *pSprite); spritetype *actDropAmmo(spritetype *pSprite, int nType); spritetype *actDropWeapon(spritetype *pSprite, int nType); @@ -246,7 +248,7 @@ int MoveThing(spritetype *pSprite); void MoveDude(spritetype *pSprite); int MoveMissile(spritetype *pSprite); void actExplodeSprite(spritetype *pSprite); -void actActivateGibObject(spritetype *pSprite, XSPRITE *pXSprite); +void actActivateGibObject(DBloodActor *actor); bool IsUnderWater(spritetype *pSprite); void actProcessSprites(void); spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6); @@ -261,7 +263,7 @@ bool actCanSplatWall(int nWall); void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, VECTOR_TYPE vectorType); void actPostSprite(int nSprite, int nStatus); void actPostProcess(void); -void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite); +void MakeSplash(DBloodActor *actor); void actBuildMissile(spritetype* pMissile, int nXSprite, int nSprite); extern const int DudeDifficulty[]; diff --git a/source/blood/src/ai.cpp b/source/blood/src/ai.cpp index 56cab3cef..ec572f6f8 100644 --- a/source/blood/src/ai.cpp +++ b/source/blood/src/ai.cpp @@ -47,6 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "triggers.h" #include "view.h" #include "nnexts.h" +#include "bloodactor.h" BEGIN_BLD_NS @@ -98,7 +99,7 @@ void aiNewState(spritetype *pSprite, XSPRITE *pXSprite, AISTATE *pAIState) } if (pAIState->enterFunc) - pAIState->enterFunc(pSprite, pXSprite); + pAIState->enterFunc(&bloodActors[pXSprite->reference]); } bool isImmune(spritetype* pSprite, int dmgType, int minScale) { @@ -270,9 +271,10 @@ void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3) } } -void aiMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +void aiMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -280,12 +282,14 @@ void aiMoveForward(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; if (klabs(nAng) > 341) return; - xvel[nSprite] += mulscale30(pDudeInfo->frontSpeed, Cos(pSprite->ang)); - yvel[nSprite] += mulscale30(pDudeInfo->frontSpeed, Sin(pSprite->ang)); + actor->xvel() += mulscale30(pDudeInfo->frontSpeed, Cos(pSprite->ang)); + actor->yvel() += mulscale30(pDudeInfo->frontSpeed, Sin(pSprite->ang)); } -void aiMoveTurn(spritetype *pSprite, XSPRITE *pXSprite) +void aiMoveTurn(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -293,9 +297,10 @@ void aiMoveTurn(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; } -void aiMoveDodge(spritetype *pSprite, XSPRITE *pXSprite) +void aiMoveDodge(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -305,8 +310,8 @@ void aiMoveDodge(spritetype *pSprite, XSPRITE *pXSprite) { int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -314,13 +319,15 @@ void aiMoveDodge(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } } -void aiActivateDude(spritetype *pSprite, XSPRITE *pXSprite) +void aiActivateDude(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!pXSprite->state) { aiChooseDirection(pSprite, pXSprite, getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y)); @@ -905,7 +912,7 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T if (pXSprite->target == -1 || (nSource != pXSprite->target && Chance(pSprite->type == pSource->type ? nDamage*pDudeInfo->changeTargetKin : nDamage*pDudeInfo->changeTarget))) { aiSetTarget(pXSprite, nSource); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } if (nDmgType == DAMAGE_TYPE_6) { @@ -1091,8 +1098,10 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T return nDamage; } -void RecoilDude(spritetype *pSprite, XSPRITE *pXSprite) +void RecoilDude(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); char v4 = Chance(0x8000); DUDEEXTRA *pDudeExtra = &gDudeExtra[pSprite->extra]; if (pSprite->statnum == kStatDude && (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { @@ -1337,8 +1346,10 @@ void RecoilDude(spritetype *pSprite, XSPRITE *pXSprite) } } -void aiThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +void aiThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); if (Chance(pDudeInfo->alertChance)) @@ -1363,13 +1374,13 @@ void aiThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } else if (nDist < pDudeInfo->hearDist) { aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } } @@ -1402,13 +1413,13 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } else if (nDist < pDudeInfo->hearDist) { aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } } @@ -1431,7 +1442,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) continue; aiSetTarget(pXSprite, pSprite2->index); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } } @@ -1452,10 +1463,10 @@ void aiProcessDudes(void) { pXSprite->stateTimer = ClipLow(pXSprite->stateTimer-4, 0); if (pXSprite->aiState->moveFunc) - pXSprite->aiState->moveFunc(pSprite, pXSprite); + pXSprite->aiState->moveFunc(&bloodActors[pXSprite->reference]); if (pXSprite->aiState->thinkFunc && (gFrameCount & 3) == (nSprite & 3)) - pXSprite->aiState->thinkFunc(pSprite, pXSprite); + pXSprite->aiState->thinkFunc(&bloodActors[pXSprite->reference]); switch (pSprite->type) { #ifdef NOONE_EXTENSIONS @@ -1471,7 +1482,7 @@ void aiProcessDudes(void) { int hinder = ((pExtra->isMelee) ? 25 : 5) << 4; if (pXSprite->health <= 0 || hinder > cumulDamage[pSprite->extra]) break; pXSprite->data3 = cumulDamage[pSprite->extra]; - RecoilDude(pSprite, pXSprite); + RecoilDude(&bloodActors[pXSprite->reference]); break; } #endif @@ -1485,7 +1496,7 @@ void aiProcessDudes(void) { if (pXSprite->health > 0 && ((pDudeInfo->hinderDamage << 4) <= cumulDamage[nXSprite])) { pXSprite->data3 = cumulDamage[nXSprite]; - RecoilDude(pSprite, pXSprite); + RecoilDude(&bloodActors[pXSprite->reference]); } break; } diff --git a/source/blood/src/ai.h b/source/blood/src/ai.h index cedff36c9..1706ad19e 100644 --- a/source/blood/src/ai.h +++ b/source/blood/src/ai.h @@ -35,9 +35,9 @@ struct AISTATE { int seqId; int funcId; // seq callback int stateTicks; - void(*enterFunc)(spritetype *, XSPRITE *); - void(*moveFunc)(spritetype *, XSPRITE *); - void(*thinkFunc)(spritetype *, XSPRITE *); + void(*enterFunc)(DBloodActor *); + void(*moveFunc)(DBloodActor *); + void(*thinkFunc)(DBloodActor *); AISTATE *nextState; }; extern AISTATE aiState[]; @@ -95,18 +95,17 @@ bool dudeIsPlayingSeq(spritetype *pSprite, int nSeq); void aiPlay3DSound(spritetype *pSprite, int a2, AI_SFX_PRIORITY a3, int a4); void aiNewState(spritetype *pSprite, XSPRITE *pXSprite, AISTATE *pAIState); void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3); -void aiMoveForward(spritetype *pSprite, XSPRITE *pXSprite); -void aiMoveTurn(spritetype *pSprite, XSPRITE *pXSprite); -void aiMoveDodge(spritetype *pSprite, XSPRITE *pXSprite); -void aiActivateDude(spritetype *pSprite, XSPRITE *pXSprite); +void aiMoveForward(DBloodActor*pXSprite); +void aiMoveTurn(DBloodActor*pXSprite); +void aiMoveDodge(DBloodActor *actor); +void aiActivateDude(DBloodActor *actor); void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z); void aiSetTarget(XSPRITE *pXSprite, int nTarget); int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_TYPE nDmgType, int nDamage); -void aiThinkTarget(spritetype *pSprite, XSPRITE *pXSprite); +void aiThinkTarget(DBloodActor* actor); void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite); void aiProcessDudes(void); void aiInit(void); void aiInitSprite(spritetype *pSprite); bool CanMove(spritetype* pSprite, int a2, int nAngle, int nRange); -void RecoilDude(spritetype* pSprite, XSPRITE* pXSprite); END_BLD_NS diff --git a/source/blood/src/aibat.cpp b/source/blood/src/aibat.cpp index 2fd1ee275..dd79012b1 100644 --- a/source/blood/src/aibat.cpp +++ b/source/blood/src/aibat.cpp @@ -36,20 +36,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "dude.h" #include "player.h" #include "seq.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void batThinkTarget(spritetype *, XSPRITE *); -static void batThinkSearch(spritetype *, XSPRITE *); -static void batThinkGoto(spritetype *, XSPRITE *); -static void batThinkPonder(spritetype *, XSPRITE *); -static void batMoveDodgeUp(spritetype *, XSPRITE *); -static void batMoveDodgeDown(spritetype *, XSPRITE *); -static void batThinkChase(spritetype *, XSPRITE *); -static void batMoveForward(spritetype *, XSPRITE *); -static void batMoveSwoop(spritetype *, XSPRITE *); -static void batMoveFly(spritetype *, XSPRITE *); -static void batMoveToCeil(spritetype *, XSPRITE *); +static void batThinkTarget(DBloodActor*); +static void batThinkSearch(DBloodActor*); +static void batThinkGoto(DBloodActor*); +static void batThinkPonder(DBloodActor*); +static void batMoveDodgeUp(DBloodActor*); +static void batMoveDodgeDown(DBloodActor*); +static void batThinkChase(DBloodActor*); +static void batMoveForward(DBloodActor*); +static void batMoveSwoop(DBloodActor*); +static void batMoveFly(DBloodActor*); +static void batMoveToCeil(DBloodActor*); AISTATE batIdle = {kAiStateIdle, 0, -1, 0, NULL, NULL, batThinkTarget, NULL }; @@ -87,8 +88,10 @@ void batBiteSeqCallback(int, int nXSprite) actFireVector(pSprite, 0, 0, dx, dy, height2-height, VECTOR_TYPE_6); } -static void batThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void batThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEEXTRA_at6_u1 *pDudeExtraE = &gDudeExtra[pSprite->extra].at6.u1; @@ -125,12 +128,12 @@ static void batThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -139,14 +142,18 @@ static void batThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) } } -static void batThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void batThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - batThinkTarget(pSprite, pXSprite); + batThinkTarget(actor); } -static void batThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void batThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -156,11 +163,13 @@ static void batThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &batSearch); - batThinkTarget(pSprite, pXSprite); + batThinkTarget(actor); } -static void batThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) +static void batThinkPonder(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &batSearch); @@ -213,9 +222,10 @@ static void batThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void batMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) +static void batMoveDodgeUp(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -223,8 +233,8 @@ static void batMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -232,14 +242,15 @@ static void batMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x52aaa; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x52aaa; } -static void batMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) +static void batMoveDodgeDown(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -249,8 +260,8 @@ static void batMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -258,13 +269,15 @@ static void batMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x44444; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x44444; } -static void batThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void batThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &batGoto); @@ -323,9 +336,10 @@ static void batThinkChase(spritetype *pSprite, XSPRITE *pXSprite) aiNewState(pSprite, pXSprite, &batHide); } -static void batMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +static void batMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -343,21 +357,22 @@ static void batMoveForward(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void batMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) +static void batMoveSwoop(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -376,19 +391,20 @@ static void batMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x44444; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x44444; } -static void batMoveFly(spritetype *pSprite, XSPRITE *pXSprite) +static void batMoveFly(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -407,18 +423,20 @@ static void batMoveFly(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x2d555; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x2d555; } -void batMoveToCeil(spritetype *pSprite, XSPRITE *pXSprite) +void batMoveToCeil(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int x = pSprite->x; int y = pSprite->y; int z = pSprite->z; diff --git a/source/blood/src/aibeast.cpp b/source/blood/src/aibeast.cpp index a14c205d4..07db943ee 100644 --- a/source/blood/src/aibeast.cpp +++ b/source/blood/src/aibeast.cpp @@ -38,19 +38,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void MorphToBeast(spritetype *, XSPRITE *); -static void beastThinkSearch(spritetype *, XSPRITE *); -static void beastThinkGoto(spritetype *, XSPRITE *); -static void beastThinkChase(spritetype *, XSPRITE *); -static void beastThinkSwimGoto(spritetype *, XSPRITE *); -static void beastThinkSwimChase(spritetype *, XSPRITE *); -static void beastMoveForward(spritetype *, XSPRITE *); -static void sub_628A0(spritetype *, XSPRITE *); -static void sub_62AE0(spritetype *, XSPRITE *); -static void sub_62D7C(spritetype *, XSPRITE *); +static void MorphToBeast(DBloodActor *); +static void beastThinkSearch(DBloodActor *); +static void beastThinkGoto(DBloodActor *); +static void beastThinkChase(DBloodActor *); +static void beastThinkSwimGoto(DBloodActor *); +static void beastThinkSwimChase(DBloodActor *); +static void beastMoveForward(DBloodActor *); +static void sub_628A0(DBloodActor *); +static void sub_62AE0(DBloodActor *); +static void sub_62D7C(DBloodActor *); AISTATE beastIdle = {kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE beastChase = {kAiStateChase, 8, -1, 0, NULL, beastMoveForward, beastThinkChase, NULL }; @@ -186,20 +187,26 @@ void StompSeqCallback(int, int nXSprite) sfxPlay3DSound(pSprite, 9015+Random(2), -1, 0); } -static void MorphToBeast(spritetype *pSprite, XSPRITE *pXSprite) +static void MorphToBeast(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); actHealDude(pXSprite, dudeInfo[51].startHealth, dudeInfo[51].startHealth); pSprite->type = kDudeBeast; } -static void beastThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void beastThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void beastThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void beastThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); XSECTOR *pXSector; @@ -220,11 +227,13 @@ static void beastThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) else aiNewState(pSprite, pXSprite, &beastSearch); } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void beastThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void beastThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { XSECTOR *pXSector; @@ -385,8 +394,10 @@ static void beastThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void beastThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void beastThinkSwimGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -396,11 +407,13 @@ static void beastThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &beastSwimSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void beastThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) +static void beastThinkSwimChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &beastSwimGoto); @@ -453,9 +466,10 @@ static void beastThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void beastMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +static void beastMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -468,13 +482,14 @@ static void beastMoveForward(spritetype *pSprite, XSPRITE *pXSprite) int nDist = approxDist(dx, dy); if (nDist <= 0x400 && Random(64) < 32) return; - xvel[nSprite] += mulscale30(pDudeInfo->frontSpeed, Cos(pSprite->ang)); - yvel[nSprite] += mulscale30(pDudeInfo->frontSpeed, Sin(pSprite->ang)); + actor->xvel() += mulscale30(pDudeInfo->frontSpeed, Cos(pSprite->ang)); + actor->yvel() += mulscale30(pDudeInfo->frontSpeed, Sin(pSprite->ang)); } -static void sub_628A0(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_628A0(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -492,21 +507,22 @@ static void sub_628A0(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>2; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void sub_62AE0(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_62AE0(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); spritetype *pTarget = &sprite[pXSprite->target]; @@ -529,18 +545,20 @@ static void sub_62AE0(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -dz; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -dz; } -static void sub_62D7C(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_62D7C(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); @@ -564,14 +582,14 @@ static void sub_62D7C(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = dz; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = dz; } END_BLD_NS diff --git a/source/blood/src/aiboneel.cpp b/source/blood/src/aiboneel.cpp index 54b6c193c..508366a00 100644 --- a/source/blood/src/aiboneel.cpp +++ b/source/blood/src/aiboneel.cpp @@ -37,20 +37,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void eelThinkTarget(spritetype *, XSPRITE *); -static void eelThinkSearch(spritetype *, XSPRITE *); -static void eelThinkGoto(spritetype *, XSPRITE *); -static void eelThinkPonder(spritetype *, XSPRITE *); -static void eelMoveDodgeUp(spritetype *, XSPRITE *); -static void eelMoveDodgeDown(spritetype *, XSPRITE *); -static void eelThinkChase(spritetype *, XSPRITE *); -static void eelMoveForward(spritetype *, XSPRITE *); -static void eelMoveSwoop(spritetype *, XSPRITE *); -static void eelMoveAscend(spritetype *pSprite, XSPRITE *pXSprite); -static void eelMoveToCeil(spritetype *, XSPRITE *); +static void eelThinkTarget(DBloodActor *); +static void eelThinkSearch(DBloodActor *); +static void eelThinkGoto(DBloodActor *); +static void eelThinkPonder(DBloodActor *); +static void eelMoveDodgeUp(DBloodActor *); +static void eelMoveDodgeDown(DBloodActor *); +static void eelThinkChase(DBloodActor *); +static void eelMoveForward(DBloodActor *); +static void eelMoveSwoop(DBloodActor *); +static void eelMoveAscend(DBloodActor *actor); +static void eelMoveToCeil(DBloodActor *); AISTATE eelIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, eelThinkTarget, NULL }; @@ -100,8 +101,10 @@ void eelBiteSeqCallback(int, int nXSprite) actFireVector(pSprite, 0, 0, dx, dy, height2-height, VECTOR_TYPE_7); } -static void eelThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void eelThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEEXTRA_at6_u1 *pDudeExtraE = &gDudeExtra[pSprite->extra].at6.u1; @@ -139,13 +142,13 @@ static void eelThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -154,14 +157,18 @@ static void eelThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) } } -static void eelThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void eelThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - eelThinkTarget(pSprite, pXSprite); + eelThinkTarget(actor); } -static void eelThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void eelThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -171,11 +178,13 @@ static void eelThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &eelSearch); - eelThinkTarget(pSprite, pXSprite); + eelThinkTarget(actor); } -static void eelThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) +static void eelThinkPonder(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &eelSearch); @@ -228,9 +237,10 @@ static void eelThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void eelMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) +static void eelMoveDodgeUp(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -238,8 +248,8 @@ static void eelMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -247,14 +257,15 @@ static void eelMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x8000; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x8000; } -static void eelMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) +static void eelMoveDodgeDown(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -264,8 +275,8 @@ static void eelMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -273,13 +284,15 @@ static void eelMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x44444; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x44444; } -static void eelThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void eelThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &eelGoto); @@ -334,9 +347,10 @@ static void eelThinkChase(spritetype *pSprite, XSPRITE *pXSprite) aiNewState(pSprite, pXSprite, &eelSearch); } -static void eelMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +static void eelMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -354,21 +368,22 @@ static void eelMoveForward(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void eelMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) +static void eelMoveSwoop(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -384,19 +399,20 @@ static void eelMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x22222; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x22222; } -static void eelMoveAscend(spritetype *pSprite, XSPRITE *pXSprite) +static void eelMoveAscend(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; @@ -412,18 +428,20 @@ static void eelMoveAscend(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x8000; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x8000; } -void eelMoveToCeil(spritetype *pSprite, XSPRITE *pXSprite) +void eelMoveToCeil(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int x = pSprite->x; int y = pSprite->y; int z = pSprite->z; diff --git a/source/blood/src/aiburn.cpp b/source/blood/src/aiburn.cpp index d1269dc3d..5f45c9ca4 100644 --- a/source/blood/src/aiburn.cpp +++ b/source/blood/src/aiburn.cpp @@ -40,12 +40,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "sound.h" #include "nnexts.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void burnThinkSearch(spritetype*, XSPRITE*); -static void burnThinkGoto(spritetype*, XSPRITE*); -static void burnThinkChase(spritetype*, XSPRITE*); +static void burnThinkSearch(DBloodActor*); +static void burnThinkGoto(DBloodActor*); +static void burnThinkChase(DBloodActor*); AISTATE cultistBurnIdle = { kAiStateIdle, 3, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE cultistBurnChase = { kAiStateChase, 3, -1, 0, NULL, aiMoveForward, burnThinkChase, NULL }; @@ -88,14 +89,18 @@ void BurnSeqCallback(int, int) { } -static void burnThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void burnThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void burnThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void burnThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -132,11 +137,13 @@ static void burnThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) #endif } } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void burnThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void burnThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { switch (pSprite->type) diff --git a/source/blood/src/aicaleb.cpp b/source/blood/src/aicaleb.cpp index 33b2d98b6..619e2a2a8 100644 --- a/source/blood/src/aicaleb.cpp +++ b/source/blood/src/aicaleb.cpp @@ -38,17 +38,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void calebThinkSearch(spritetype *, XSPRITE *); -static void calebThinkGoto(spritetype *, XSPRITE *); -static void calebThinkChase(spritetype *, XSPRITE *); -static void calebThinkSwimGoto(spritetype *, XSPRITE *); -static void calebThinkSwimChase(spritetype *, XSPRITE *); -static void sub_65D04(spritetype *, XSPRITE *); -static void sub_65F44(spritetype *, XSPRITE *); -static void sub_661E0(spritetype *, XSPRITE *); +static void calebThinkSearch(DBloodActor *); +static void calebThinkGoto(DBloodActor *); +static void calebThinkChase(DBloodActor *); +static void calebThinkSwimGoto(DBloodActor *); +static void calebThinkSwimChase(DBloodActor *); +static void sub_65D04(DBloodActor *); +static void sub_65F44(DBloodActor *); +static void sub_661E0(DBloodActor *); AISTATE tinycalebIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE tinycalebChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveForward, calebThinkChase, NULL }; @@ -94,14 +95,18 @@ void SeqAttackCallback(int, int nXSprite) sfxPlay3DSound(pSprite, 1002, -1, 0); } -static void calebThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void calebThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void calebThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void calebThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); XSECTOR *pXSector; @@ -122,11 +127,13 @@ static void calebThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) else aiNewState(pSprite, pXSprite, &tinycalebSearch); } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void calebThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void calebThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { XSECTOR *pXSector; @@ -253,8 +260,10 @@ static void calebThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void calebThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void calebThinkSwimGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -264,11 +273,13 @@ static void calebThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &tinycalebSwimSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void calebThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) +static void calebThinkSwimChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &tinycalebSwimGoto); @@ -316,8 +327,10 @@ static void calebThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void sub_65D04(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_65D04(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); @@ -348,8 +361,10 @@ static void sub_65D04(spritetype *pSprite, XSPRITE *pXSprite) yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); } -static void sub_65F44(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_65F44(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); @@ -383,8 +398,10 @@ static void sub_65F44(spritetype *pSprite, XSPRITE *pXSprite) zvel[nSprite] = -dz; } -static void sub_661E0(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_661E0(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); diff --git a/source/blood/src/aicerber.cpp b/source/blood/src/aicerber.cpp index e6a01314e..7d91beb73 100644 --- a/source/blood/src/aicerber.cpp +++ b/source/blood/src/aicerber.cpp @@ -38,13 +38,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void cerberusThinkSearch(spritetype *pSprite, XSPRITE *pXSprite); -static void cerberusThinkTarget(spritetype *pSprite, XSPRITE *pXSprite); -static void cerberusThinkGoto(spritetype *pSprite, XSPRITE *pXSprite); -static void cerberusThinkChase(spritetype *pSprite, XSPRITE *pXSprite); +static void cerberusThinkSearch(DBloodActor *actor); +static void cerberusThinkTarget(DBloodActor *actor); +static void cerberusThinkGoto(DBloodActor *actor); +static void cerberusThinkChase(DBloodActor *actor); AISTATE cerberusIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, cerberusThinkTarget, NULL }; @@ -262,14 +263,18 @@ void cerberusBurnSeqCallback2(int, int nXSprite) } } -static void cerberusThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void cerberusThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void cerberusThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void cerberusThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -313,13 +318,13 @@ static void cerberusThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) { pDudeExtraE->xval1 = 0; aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { pDudeExtraE->xval1 = 0; aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -328,8 +333,10 @@ static void cerberusThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) } } -static void cerberusThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void cerberusThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -352,11 +359,13 @@ static void cerberusThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) break; } } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void cerberusThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void cerberusThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { switch (pSprite->type) { case kDudeCerberusTwoHead: diff --git a/source/blood/src/aicult.cpp b/source/blood/src/aicult.cpp index e93fdce90..169e1612a 100644 --- a/source/blood/src/aicult.cpp +++ b/source/blood/src/aicult.cpp @@ -40,12 +40,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void cultThinkSearch(spritetype *, XSPRITE *); -static void cultThinkGoto(spritetype *, XSPRITE *); -static void cultThinkChase(spritetype *, XSPRITE *); +static void cultThinkSearch(DBloodActor *); +static void cultThinkGoto(DBloodActor *); +static void cultThinkChase(DBloodActor *); AISTATE cultistIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE cultistProneIdle = { kAiStateIdle, 17, -1, 0, NULL, NULL, aiThinkTarget, NULL }; @@ -216,14 +217,18 @@ static char TargetNearExplosion(spritetype *pSprite) return 0; } -static void cultThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void cultThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); sub_5F15C(pSprite, pXSprite); } -static void cultThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void cultThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -244,11 +249,13 @@ static void cultThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) break; } } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void cultThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void cultThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { switch (pXSprite->medium) diff --git a/source/blood/src/aigarg.cpp b/source/blood/src/aigarg.cpp index aa63b596e..6ab717a1d 100644 --- a/source/blood/src/aigarg.cpp +++ b/source/blood/src/aigarg.cpp @@ -41,22 +41,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "sound.h" #include "nnexts.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void gargThinkTarget(spritetype *, XSPRITE *); -static void gargThinkSearch(spritetype *, XSPRITE *); -static void gargThinkGoto(spritetype *, XSPRITE *); -static void gargMoveDodgeUp(spritetype *, XSPRITE *); -static void gargMoveDodgeDown(spritetype *, XSPRITE *); -static void gargThinkChase(spritetype *, XSPRITE *); -static void entryFStatue(spritetype *, XSPRITE *); -static void entrySStatue(spritetype *, XSPRITE *); -static void gargMoveForward(spritetype *, XSPRITE *); -static void gargMoveSlow(spritetype *, XSPRITE *); -static void gargMoveSwoop(spritetype *, XSPRITE *); -static void gargMoveFly(spritetype *, XSPRITE *); -static void playStatueBreakSnd(spritetype*,XSPRITE*); +static void gargThinkTarget(DBloodActor *); +static void gargThinkSearch(DBloodActor *); +static void gargThinkGoto(DBloodActor *); +static void gargMoveDodgeUp(DBloodActor *); +static void gargMoveDodgeDown(DBloodActor *); +static void gargThinkChase(DBloodActor *); +static void entryFStatue(DBloodActor *); +static void entrySStatue(DBloodActor *); +static void gargMoveForward(DBloodActor *); +static void gargMoveSlow(DBloodActor *); +static void gargMoveSwoop(DBloodActor *); +static void gargMoveFly(DBloodActor *); +static void playStatueBreakSnd(DBloodActor*); AISTATE gargoyleFIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, gargThinkTarget, NULL }; AISTATE gargoyleStatueIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, NULL, NULL }; @@ -85,8 +86,9 @@ AISTATE gargoyleFDodgeDownLeft = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeD AISTATE statueFBreakSEQ = { kAiStateOther, 5, -1, 0, entryFStatue, NULL, playStatueBreakSnd, &gargoyleFMorph2}; AISTATE statueSBreakSEQ = { kAiStateOther, 5, -1, 0, entrySStatue, NULL, playStatueBreakSnd, &gargoyleSMorph2}; -static void playStatueBreakSnd(spritetype* pSprite, XSPRITE* pXSprite) { - UNREFERENCED_PARAMETER(pXSprite); +static void playStatueBreakSnd(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiPlay3DSound(pSprite, 313, AI_SFX_PRIORITY_1, -1); } @@ -222,8 +224,10 @@ void ThrowSSeqCallback(int, int nXSprite) actFireThing(pSprite, 0, 0, gDudeSlope[nXSprite]-7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111); } -static void gargThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void gargThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -264,13 +268,13 @@ static void gargThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -279,14 +283,18 @@ static void gargThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) } } -static void gargThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void gargThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); sub_5F15C(pSprite, pXSprite); } -static void gargThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void gargThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -300,12 +308,13 @@ static void gargThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &gargoyleFSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void gargMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveDodgeUp(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -317,8 +326,8 @@ static void gargMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -326,14 +335,15 @@ static void gargMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x1d555; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x1d555; } -static void gargMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveDodgeDown(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -347,8 +357,8 @@ static void gargMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -356,13 +366,15 @@ static void gargMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x44444; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x44444; } -static void gargThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void gargThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &gargoyleFGoto); @@ -541,23 +553,28 @@ static void gargThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void entryFStatue(spritetype *pSprite, XSPRITE *pXSprite) +static void entryFStatue(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); DUDEINFO *pDudeInfo = &dudeInfo[6]; actHealDude(pXSprite, pDudeInfo->startHealth, pDudeInfo->startHealth); pSprite->type = kDudeGargoyleFlesh; } -static void entrySStatue(spritetype *pSprite, XSPRITE *pXSprite) +static void entrySStatue(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); DUDEINFO *pDudeInfo = &dudeInfo[7]; actHealDude(pXSprite, pDudeInfo->startHealth, pDudeInfo->startHealth); pSprite->type = kDudeGargoyleStone; } -static void gargMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -579,21 +596,22 @@ static void gargMoveForward(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void gargMoveSlow(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveSlow(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -616,27 +634,28 @@ static void gargMoveSlow(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 = nAccel>>1; t2 >>= 1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudeGargoyleFlesh: - zvel[nSprite] = 0x44444; + actor->zvel() = 0x44444; break; case kDudeGargoyleStone: - zvel[nSprite] = 0x35555; + actor->zvel() = 0x35555; break; } } -static void gargMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveSwoop(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -659,26 +678,27 @@ static void gargMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudeGargoyleFlesh: - zvel[nSprite] = t1; + actor->zvel() = t1; break; case kDudeGargoyleStone: - zvel[nSprite] = t1; + actor->zvel() = t1; break; } } -static void gargMoveFly(spritetype *pSprite, XSPRITE *pXSprite) +static void gargMoveFly(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -701,22 +721,22 @@ static void gargMoveFly(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudeGargoyleFlesh: - zvel[nSprite] = -t1; + actor->zvel() = -t1; break; case kDudeGargoyleStone: - zvel[nSprite] = -t1; + actor->zvel() = -t1; break; } - klabs(zvel[nSprite]); + klabs(actor->zvel()); } END_BLD_NS diff --git a/source/blood/src/aighost.cpp b/source/blood/src/aighost.cpp index 2d29345f5..a7f07e2e8 100644 --- a/source/blood/src/aighost.cpp +++ b/source/blood/src/aighost.cpp @@ -41,19 +41,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "sound.h" #include "nnexts.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void ghostThinkTarget(spritetype *, XSPRITE *); -static void ghostThinkSearch(spritetype *, XSPRITE *); -static void ghostThinkGoto(spritetype *, XSPRITE *); -static void ghostMoveDodgeUp(spritetype *, XSPRITE *); -static void ghostMoveDodgeDown(spritetype *, XSPRITE *); -static void ghostThinkChase(spritetype *, XSPRITE *); -static void ghostMoveForward(spritetype *, XSPRITE *); -static void ghostMoveSlow(spritetype *, XSPRITE *); -static void ghostMoveSwoop(spritetype *, XSPRITE *); -static void ghostMoveFly(spritetype *, XSPRITE *); +static void ghostThinkTarget(DBloodActor *); +static void ghostThinkSearch(DBloodActor *); +static void ghostThinkGoto(DBloodActor *); +static void ghostMoveDodgeUp(DBloodActor *); +static void ghostMoveDodgeDown(DBloodActor *); +static void ghostThinkChase(DBloodActor *); +static void ghostMoveForward(DBloodActor *); +static void ghostMoveSlow(DBloodActor *); +static void ghostMoveSwoop(DBloodActor *); +static void ghostMoveFly(DBloodActor *); AISTATE ghostIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, ghostThinkTarget, NULL }; @@ -199,8 +200,10 @@ void ghostBlastSeqCallback(int, int nXSprite) #endif } -static void ghostThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -241,28 +244,32 @@ static void ghostThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } else if (nDist < pDudeInfo->hearDist) { pDudeExtraE->xval2 = 0; aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } } } } -static void ghostThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void ghostThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -276,11 +283,13 @@ static void ghostThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &ghostSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void ghostMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveDodgeUp(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { @@ -293,8 +302,8 @@ static void ghostMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -302,13 +311,15 @@ static void ghostMoveDodgeUp(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -0x1d555; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -0x1d555; } -static void ghostMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveDodgeDown(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { @@ -323,8 +334,8 @@ static void ghostMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int dx = xvel[nSprite]; - int dy = yvel[nSprite]; + int dx = actor->xvel(); + int dy = actor->yvel(); int t1 = dmulscale30(dx, nCos, dy, nSin); int t2 = dmulscale30(dx, nSin, -dy, nCos); if (pXSprite->dodgeDir > 0) @@ -332,13 +343,15 @@ static void ghostMoveDodgeDown(spritetype *pSprite, XSPRITE *pXSprite) else t2 -= pDudeInfo->sideSpeed; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = 0x44444; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = 0x44444; } -static void ghostThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &ghostGoto); @@ -449,9 +462,10 @@ static void ghostThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void ghostMoveForward(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveForward(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -473,21 +487,22 @@ static void ghostMoveForward(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void ghostMoveSlow(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveSlow(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -510,24 +525,25 @@ static void ghostMoveSlow(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 = nAccel>>1; t2 >>= 1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudePhantasm: - zvel[nSprite] = 0x44444; + actor->zvel() = 0x44444; break; } } -static void ghostMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveSwoop(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -550,23 +566,24 @@ static void ghostMoveSwoop(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudePhantasm: - zvel[nSprite] = t1; + actor->zvel() = t1; break; } } -static void ghostMoveFly(spritetype *pSprite, XSPRITE *pXSprite) +static void ghostMoveFly(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -589,16 +606,16 @@ static void ghostMoveFly(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); switch (pSprite->type) { case kDudePhantasm: - zvel[nSprite] = -t1; + actor->zvel() = -t1; break; } } diff --git a/source/blood/src/aigilbst.cpp b/source/blood/src/aigilbst.cpp index 2f8ac6d7d..81c1f8a7b 100644 --- a/source/blood/src/aigilbst.cpp +++ b/source/blood/src/aigilbst.cpp @@ -39,17 +39,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void gillThinkSearch(spritetype *, XSPRITE *); -static void gillThinkGoto(spritetype *, XSPRITE *); -static void gillThinkChase(spritetype *, XSPRITE *); -static void gillThinkSwimGoto(spritetype *, XSPRITE *); -static void gillThinkSwimChase(spritetype *, XSPRITE *); -static void sub_6CB00(spritetype *, XSPRITE *); -static void sub_6CD74(spritetype *, XSPRITE *); -static void sub_6D03C(spritetype *, XSPRITE *); +static void gillThinkSearch(DBloodActor *); +static void gillThinkGoto(DBloodActor *); +static void gillThinkChase(DBloodActor *); +static void gillThinkSwimGoto(DBloodActor *); +static void gillThinkSwimChase(DBloodActor *); +static void sub_6CB00(DBloodActor *); +static void sub_6CD74(DBloodActor *); +static void sub_6D03C(DBloodActor *); AISTATE gillBeastIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; @@ -86,14 +87,18 @@ void GillBiteSeqCallback(int, int nXSprite) actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_8); } -static void gillThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void gillThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void gillThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void gillThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); XSECTOR *pXSector; @@ -114,11 +119,13 @@ static void gillThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) else aiNewState(pSprite, pXSprite, &gillBeastSearch); } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void gillThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void gillThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { XSECTOR *pXSector; @@ -241,8 +248,10 @@ static void gillThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void gillThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void gillThinkSwimGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -252,11 +261,13 @@ static void gillThinkSwimGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &gillBeastSwimSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void gillThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) +static void gillThinkSwimChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &gillBeastSwimSearch); @@ -309,8 +320,10 @@ static void gillThinkSwimChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void sub_6CB00(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_6CB00(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); int nSprite = pSprite->index; assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); @@ -329,21 +342,22 @@ static void sub_6CB00(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); if (pXSprite->target == -1) t1 += nAccel; else t1 += nAccel>>2; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); } -static void sub_6CD74(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_6CD74(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); spritetype *pTarget = &sprite[pXSprite->target]; @@ -366,19 +380,20 @@ static void sub_6CD74(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = -dz; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = -dz; } -static void sub_6D03C(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_6D03C(DBloodActor* actor) { - int nSprite = pSprite->index; + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); spritetype *pTarget = &sprite[pXSprite->target]; @@ -401,14 +416,14 @@ static void sub_6D03C(spritetype *pSprite, XSPRITE *pXSprite) return; int nCos = Cos(pSprite->ang); int nSin = Sin(pSprite->ang); - int vx = xvel[nSprite]; - int vy = yvel[nSprite]; + int vx = actor->xvel(); + int vy = actor->yvel(); int t1 = dmulscale30(vx, nCos, vy, nSin); int t2 = dmulscale30(vx, nSin, -vy, nCos); t1 += nAccel>>1; - xvel[nSprite] = dmulscale30(t1, nCos, t2, nSin); - yvel[nSprite] = dmulscale30(t1, nSin, -t2, nCos); - zvel[nSprite] = dz; + actor->xvel() = dmulscale30(t1, nCos, t2, nSin); + actor->yvel() = dmulscale30(t1, nSin, -t2, nCos); + actor->zvel() = dz; } END_BLD_NS diff --git a/source/blood/src/aihand.cpp b/source/blood/src/aihand.cpp index 8729b848e..78674a85d 100644 --- a/source/blood/src/aihand.cpp +++ b/source/blood/src/aihand.cpp @@ -39,12 +39,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void handThinkSearch(spritetype *, XSPRITE *); -static void handThinkGoto(spritetype *, XSPRITE *); -static void handThinkChase(spritetype *, XSPRITE *); +static void handThinkSearch(DBloodActor *); +static void handThinkGoto(DBloodActor *); +static void handThinkChase(DBloodActor *); AISTATE handIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE hand13A3B4 = { kAiStateOther, 0, -1, 0, NULL, NULL, NULL, NULL }; @@ -71,14 +72,18 @@ void HandJumpSeqCallback(int, int nXSprite) } } -static void handThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void handThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void handThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void handThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -88,11 +93,13 @@ static void handThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &handSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void handThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void handThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &handGoto); diff --git a/source/blood/src/aihound.cpp b/source/blood/src/aihound.cpp index 46848ee50..7df0740a3 100644 --- a/source/blood/src/aihound.cpp +++ b/source/blood/src/aihound.cpp @@ -41,12 +41,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "sound.h" #include "nnexts.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void houndThinkSearch(spritetype *, XSPRITE *); -static void houndThinkGoto(spritetype *, XSPRITE *); -static void houndThinkChase(spritetype *, XSPRITE *); +static void houndThinkSearch(DBloodActor *); +static void houndThinkGoto(DBloodActor *); +static void houndThinkChase(DBloodActor *); AISTATE houndIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE houndSearch = { kAiStateMove, 8, -1, 1800, NULL, aiMoveForward, houndThinkSearch, &houndIdle }; @@ -93,14 +94,18 @@ void houndBurnSeqCallback(int, int nXSprite) actFireMissile(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileFlameHound); } -static void houndThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void houndThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void houndThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void houndThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -115,11 +120,13 @@ static void houndThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &houndSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void houndThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void houndThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &houndGoto); diff --git a/source/blood/src/aiinnoc.cpp b/source/blood/src/aiinnoc.cpp index c1f308041..d2238c026 100644 --- a/source/blood/src/aiinnoc.cpp +++ b/source/blood/src/aiinnoc.cpp @@ -39,12 +39,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void innocThinkSearch(spritetype *, XSPRITE *); -static void innocThinkGoto(spritetype *, XSPRITE *); -static void innocThinkChase(spritetype *, XSPRITE *); +static void innocThinkSearch(DBloodActor *); +static void innocThinkGoto(DBloodActor *); +static void innocThinkChase(DBloodActor *); AISTATE innocentIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE innocentSearch = { kAiStateSearch, 6, -1, 1800, NULL, aiMoveForward, innocThinkSearch, &innocentIdle }; @@ -53,14 +54,18 @@ AISTATE innocentRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &innocent AISTATE innocentTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &innocentChase }; AISTATE innocentGoto = { kAiStateMove, 6, -1, 600, NULL, aiMoveForward, innocThinkGoto, &innocentIdle }; -static void innocThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void innocThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void innocThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void innocThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -70,11 +75,13 @@ static void innocThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &innocentSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void innocThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void innocThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &innocentGoto); diff --git a/source/blood/src/aipod.cpp b/source/blood/src/aipod.cpp index b2ee2be26..d8dbbb544 100644 --- a/source/blood/src/aipod.cpp +++ b/source/blood/src/aipod.cpp @@ -41,12 +41,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void aiPodSearch(spritetype *, XSPRITE *); -static void aiPodMove(spritetype *, XSPRITE *); -static void aiPodChase(spritetype *, XSPRITE *); +static void aiPodSearch(DBloodActor* actor); +static void aiPodMove(DBloodActor* actor); +static void aiPodChase(DBloodActor* actor); AISTATE podIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE podMove = { kAiStateMove, 7, -1, 3600, NULL, aiMoveTurn, aiPodMove, &podSearch }; @@ -160,14 +161,18 @@ void sub_70284(int, int nXSprite) sub_2A620(nSprite, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nDist, 1, 5*(1+gGameOptions.nDifficulty), dmgType, 2, nBurn, 0, 0); } -static void aiPodSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void aiPodSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void aiPodMove(spritetype *pSprite, XSPRITE *pXSprite) +static void aiPodMove(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -192,11 +197,13 @@ static void aiPodMove(spritetype *pSprite, XSPRITE *pXSprite) break; } } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void aiPodChase(spritetype *pSprite, XSPRITE *pXSprite) +static void aiPodChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { switch (pSprite->type) { case kDudePodGreen: diff --git a/source/blood/src/airat.cpp b/source/blood/src/airat.cpp index 4c232b053..ef3d12b78 100644 --- a/source/blood/src/airat.cpp +++ b/source/blood/src/airat.cpp @@ -39,12 +39,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void ratThinkSearch(spritetype *, XSPRITE *); -static void ratThinkGoto(spritetype *, XSPRITE *); -static void ratThinkChase(spritetype *, XSPRITE *); +static void ratThinkSearch(DBloodActor *); +static void ratThinkGoto(DBloodActor *); +static void ratThinkChase(DBloodActor *); AISTATE ratIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE ratSearch = { kAiStateSearch, 7, -1, 1800, NULL, aiMoveForward, ratThinkSearch, &ratIdle }; @@ -68,14 +69,18 @@ void ratBiteSeqCallback(int, int nXSprite) actFireVector(pSprite, 0, 0, dx, dy, pTarget->z-pSprite->z, VECTOR_TYPE_16); } -static void ratThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void ratThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void ratThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void ratThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -85,11 +90,13 @@ static void ratThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &ratSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void ratThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void ratThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &ratGoto); diff --git a/source/blood/src/aispid.cpp b/source/blood/src/aispid.cpp index ec29df2c8..d0e2c5124 100644 --- a/source/blood/src/aispid.cpp +++ b/source/blood/src/aispid.cpp @@ -40,12 +40,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void spidThinkSearch(spritetype *, XSPRITE *); -static void spidThinkGoto(spritetype *, XSPRITE *); -static void spidThinkChase(spritetype *, XSPRITE *); +static void spidThinkSearch(DBloodActor *); +static void spidThinkGoto(DBloodActor *); +static void spidThinkChase(DBloodActor *); AISTATE spidIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; @@ -190,14 +191,18 @@ void sub_71370(int, int nXSprite) } -static void spidThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void spidThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void spidThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void spidThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -207,11 +212,13 @@ static void spidThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &spidSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void spidThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void spidThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &spidGoto); diff --git a/source/blood/src/aitchern.cpp b/source/blood/src/aitchern.cpp index bb3a5db2d..6e941c762 100644 --- a/source/blood/src/aitchern.cpp +++ b/source/blood/src/aitchern.cpp @@ -40,13 +40,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void sub_72580(spritetype *, XSPRITE *); -static void sub_725A4(spritetype *, XSPRITE *); -static void sub_72850(spritetype *, XSPRITE *); -static void sub_72934(spritetype *, XSPRITE *); +static void sub_72580(DBloodActor *); +static void sub_725A4(DBloodActor *); +static void sub_72850(DBloodActor *); +static void sub_72934(DBloodActor *); AISTATE tchernobogIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, sub_725A4, NULL }; @@ -231,14 +232,18 @@ void sub_720AC(int, int nXSprite) actFireMissile(pSprite, -350, 0, ax, ay, az, kMissileFireballTchernobog); } -static void sub_72580(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_72580(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void sub_725A4(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_725A4(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -279,13 +284,13 @@ static void sub_725A4(spritetype *pSprite, XSPRITE *pXSprite) { pDudeExtraE->xval1 = 0; aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { pDudeExtraE->xval1 = 0; aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -294,8 +299,10 @@ static void sub_725A4(spritetype *pSprite, XSPRITE *pXSprite) } } -static void sub_72850(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_72850(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); ///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); @@ -309,11 +316,13 @@ static void sub_72850(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &tchernobogSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void sub_72934(spritetype *pSprite, XSPRITE *pXSprite) +static void sub_72934(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &tcherno13A9B8); diff --git a/source/blood/src/aiunicult.cpp b/source/blood/src/aiunicult.cpp index f981940b3..b9f83842b 100644 --- a/source/blood/src/aiunicult.cpp +++ b/source/blood/src/aiunicult.cpp @@ -50,15 +50,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "view.h" #include "raze_sound.h" +#include "bloodactor.h" #include "gib.h" BEGIN_BLD_NS static void ThrowThing(int, bool); -static void unicultThinkSearch(spritetype*, XSPRITE*); -static void unicultThinkGoto(spritetype*, XSPRITE*); -static void unicultThinkChase(spritetype*, XSPRITE*); -static void forcePunch(spritetype*, XSPRITE*); +static void unicultThinkSearch(DBloodActor*); +static void unicultThinkGoto(DBloodActor*); +static void unicultThinkChase(DBloodActor*); +static void forcePunch(DBloodActor*); AISTATE genDudeIdleL = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; AISTATE genDudeIdleW = { kAiStateIdle, 13, -1, 0, NULL, NULL, aiThinkTarget, NULL }; @@ -126,7 +127,10 @@ const GENDUDESND gCustomDudeSnd[] = { GENDUDEEXTRA gGenDudeExtra[kMaxSprites]; // savegame handling in ai.cpp -void forcePunch(spritetype* pSprite, XSPRITE*) { +static void forcePunch(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (gGenDudeExtra[pSprite->index].forcePunch && seqGetStatus(3, pSprite->extra) == -1) punchCallback(0,pSprite->extra); } @@ -242,7 +246,7 @@ void genDudeAttack1(int, int nXIndex) { if (xspriRangeIsFine(pSpawned->extra)) { xsprite[pSpawned->extra].target = pXSprite->target; if (pXSprite->target > -1) - aiActivateDude(pSpawned, &xsprite[pSpawned->extra]); + aiActivateDude(&bloodActors[pSpawned->index]); } gKillMgr.AddNewKill(1); @@ -377,8 +381,10 @@ static void ThrowThing(int nXIndex, bool impact) { } } -static void unicultThinkSearch( spritetype* pSprite, XSPRITE* pXSprite ) { - +static void unicultThinkSearch(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); // TO DO: if can't see the target, but in fireDist range - stop moving and look around //viewSetSystemMessage("IN SEARCH"); @@ -386,8 +392,10 @@ static void unicultThinkSearch( spritetype* pSprite, XSPRITE* pXSprite ) { sub_5F15C(pSprite, pXSprite); } -static void unicultThinkGoto(spritetype* pSprite, XSPRITE* pXSprite) { - +static void unicultThinkGoto(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); return; @@ -404,11 +412,13 @@ static void unicultThinkGoto(spritetype* pSprite, XSPRITE* pXSprite) { if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); else aiGenDudeNewState(pSprite, &genDudeSearchL); } - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { - +static void unicultThinkChase(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return; else if (pXSprite->target < 0 || pXSprite->target >= kMaxSprites) { if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW); @@ -564,7 +574,7 @@ static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { return; } else { - int state = checkAttackState(pSprite, pXSprite); + int state = checkAttackState(&bloodActors[pXSprite->reference]); if (state == 1) aiGenDudeNewState(pSprite, &genDudeChaseW); else if (state == 2) { if (Chance(0x5000)) aiGenDudeNewState(pSprite, &genDudeChaseD); @@ -595,7 +605,7 @@ static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { aiGenDudeNewState(pSprite, &genDudePunch); return; } else { - int state = checkAttackState(pSprite, pXSprite); + int state = checkAttackState(&bloodActors[pXSprite->reference]); if (state == 1) aiGenDudeNewState(pSprite, &genDudeChaseW); else if (state == 2) aiGenDudeNewState(pSprite, &genDudeChaseD); else aiGenDudeNewState(pSprite, &genDudeChaseL); @@ -605,7 +615,7 @@ static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { } else if (weaponType == kGenDudeWeaponMissile) { // special handling for flame, explosive and life leech missiles - int state = checkAttackState(pSprite, pXSprite); + int state = checkAttackState(&bloodActors[pXSprite->reference]); switch (curWeapon) { case kMissileLifeLeechRegular: // pickup life leech if it was thrown previously @@ -653,7 +663,7 @@ static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { return; } - int state = checkAttackState(pSprite, pXSprite); + int state = checkAttackState(&bloodActors[pXSprite->reference]); int kAngle = (dudeIsMelee(pXSprite) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng; if (dist < vdist && klabs(losAngle) < kAngle) { @@ -907,8 +917,10 @@ static void unicultThinkChase( spritetype* pSprite, XSPRITE* pXSprite ) { } -int checkAttackState(spritetype* pSprite, XSPRITE* pXSprite) { - UNREFERENCED_PARAMETER(pXSprite); +int checkAttackState(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (dudeIsPlayingSeq(pSprite, 14) || spriteIsUnderwater(pSprite,false)) { if ( !dudeIsPlayingSeq(pSprite, 14) || spriteIsUnderwater(pSprite,false)) @@ -965,7 +977,10 @@ int getGenDudeMoveSpeed(spritetype* pSprite,int which, bool mul, bool shift) { return speed; } -void aiGenDudeMoveForward(spritetype* pSprite, XSPRITE* pXSprite ) { +void aiGenDudeMoveForward(DBloodActor* actor) +{ + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index]; int maxTurn = pDudeInfo->angSpeed * 4 >> 4; @@ -1103,7 +1118,7 @@ void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState) { } if (pAIState->enterFunc) - pAIState->enterFunc(pSprite, pXSprite); + pAIState->enterFunc(&bloodActors[pXSprite->reference]); } @@ -1785,7 +1800,7 @@ void genDudeTransform(spritetype* pSprite) { else aiSetTarget(pXSprite, target); // finally activate it - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); break; } @@ -1818,7 +1833,7 @@ void updateTargetOfLeech(spritetype* pSprite) { if (pXDude->target < 0 && spriRangeIsFine(pXLeech->target)) { aiSetTarget(pXDude, pXLeech->target); if (inIdle(pXDude->aiState)) - aiActivateDude(pSprite, pXDude); + aiActivateDude(&bloodActors[pXDude->reference]); } else { pXLeech->target = pXDude->target; } diff --git a/source/blood/src/aiunicult.h b/source/blood/src/aiunicult.h index 7994a3b48..78bcaa2dc 100644 --- a/source/blood/src/aiunicult.h +++ b/source/blood/src/aiunicult.h @@ -203,11 +203,11 @@ void removeDudeStuff(spritetype* pSprite); spritetype* leechIsDropped(spritetype* pSprite); bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false); bool playGenDudeSound(spritetype* pSprite, int mode); -void aiGenDudeMoveForward(spritetype* pSprite, XSPRITE* pXSprite); +void aiGenDudeMoveForward(DBloodActor* actor); void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int aXvel = -1, int aYvel = -1); void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState); int getGenDudeMoveSpeed(spritetype* pSprite, int which, bool mul, bool shift); -int checkAttackState(spritetype* pSprite, XSPRITE* pXSprite); +int checkAttackState(DBloodActor* actor); bool doExplosion(spritetype* pSprite, int nType); spritetype* genDudeSpawn(spritetype* pSprite, int nDist); void genDudeTransform(spritetype* pSprite); diff --git a/source/blood/src/aizomba.cpp b/source/blood/src/aizomba.cpp index 3c6fb52a0..f50fc443a 100644 --- a/source/blood/src/aizomba.cpp +++ b/source/blood/src/aizomba.cpp @@ -40,18 +40,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void zombaThinkSearch(spritetype *, XSPRITE *); -static void zombaThinkGoto(spritetype *, XSPRITE *); -static void zombaThinkChase(spritetype *, XSPRITE *); -static void zombaThinkPonder(spritetype *, XSPRITE *); -static void myThinkTarget(spritetype *, XSPRITE *); -static void myThinkSearch(spritetype *, XSPRITE *); -static void entryEZombie(spritetype *, XSPRITE *); -static void entryAIdle(spritetype *, XSPRITE *); -static void entryEStand(spritetype *, XSPRITE *); +static void zombaThinkSearch(DBloodActor *); +static void zombaThinkGoto(DBloodActor *); +static void zombaThinkChase(DBloodActor *); +static void zombaThinkPonder(DBloodActor *); +static void myThinkTarget(DBloodActor *); +static void myThinkSearch(DBloodActor *); +static void entryEZombie(DBloodActor *); +static void entryAIdle(DBloodActor *); +static void entryEStand(DBloodActor *); AISTATE zombieAIdle = { kAiStateIdle, 0, -1, 0, entryAIdle, NULL, aiThinkTarget, NULL }; @@ -99,14 +100,18 @@ void StandSeqCallback(int, int nXSprite) sfxPlay3DSound(&sprite[nSprite], 1102, -1, 0); } -static void zombaThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void zombaThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); sub_5F15C(pSprite, pXSprite); } -static void zombaThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void zombaThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -116,11 +121,13 @@ static void zombaThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 921 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &zombieASearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void zombaThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void zombaThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &zombieASearch); @@ -169,8 +176,10 @@ static void zombaThinkChase(spritetype *pSprite, XSPRITE *pXSprite) pXSprite->target = -1; } -static void zombaThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) +static void zombaThinkPonder(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &zombieASearch); @@ -220,8 +229,10 @@ static void zombaThinkPonder(spritetype *pSprite, XSPRITE *pXSprite) aiNewState(pSprite, pXSprite, &zombieAChase); } -static void myThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) +static void myThinkTarget(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); for (int p = connecthead; p >= 0; p = connectpoint2[p]) @@ -245,12 +256,12 @@ static void myThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { aiSetTarget(pXSprite, pPlayer->nSprite); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nDist < pDudeInfo->hearDist) { aiSetTarget(pXSprite, x, y, z); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); } else continue; @@ -258,27 +269,32 @@ static void myThinkTarget(spritetype *pSprite, XSPRITE *pXSprite) } } -static void myThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void myThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - myThinkTarget(pSprite, pXSprite); + myThinkTarget(actor); } -static void entryEZombie(spritetype *pSprite, XSPRITE *pXSprite) +static void entryEZombie(DBloodActor* actor) { - UNREFERENCED_PARAMETER(pXSprite); + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); pSprite->type = kDudeZombieAxeNormal; pSprite->flags |= 1; } -static void entryAIdle(spritetype *pSprite, XSPRITE *pXSprite) +static void entryAIdle(DBloodActor* actor) { - UNREFERENCED_PARAMETER(pSprite); + auto pXSprite = &actor->x(); pXSprite->target = -1; } -static void entryEStand(spritetype *pSprite, XSPRITE *pXSprite) +static void entryEStand(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); sfxPlay3DSound(pSprite, 1100, -1, 0); pSprite->ang = getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y); } diff --git a/source/blood/src/aizombf.cpp b/source/blood/src/aizombf.cpp index b84b66452..3b91b91f3 100644 --- a/source/blood/src/aizombf.cpp +++ b/source/blood/src/aizombf.cpp @@ -39,12 +39,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "seq.h" #include "sound.h" +#include "bloodactor.h" BEGIN_BLD_NS -static void zombfThinkSearch(spritetype *pSprite, XSPRITE *pXSprite); -static void zombfThinkGoto(spritetype *pSprite, XSPRITE *pXSprite); -static void zombfThinkChase(spritetype *pSprite, XSPRITE *pXSprite); +static void zombfThinkSearch(DBloodActor *actor); +static void zombfThinkGoto(DBloodActor *actor); +static void zombfThinkChase(DBloodActor *actor); AISTATE zombieFIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL }; @@ -104,14 +105,18 @@ void ThrowSeqCallback(int, int nXSprite) actFireMissile(pSprite, 0, -getDudeInfo(pSprite->type)->eyeHeight, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileButcherKnife); } -static void zombfThinkSearch(spritetype *pSprite, XSPRITE *pXSprite) +static void zombfThinkSearch(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void zombfThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) +static void zombfThinkGoto(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int dx = pXSprite->targetX-pSprite->x; @@ -121,11 +126,13 @@ static void zombfThinkGoto(spritetype *pSprite, XSPRITE *pXSprite) aiChooseDirection(pSprite, pXSprite, nAngle); if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) aiNewState(pSprite, pXSprite, &zombieFSearch); - aiThinkTarget(pSprite, pXSprite); + aiThinkTarget(actor); } -static void zombfThinkChase(spritetype *pSprite, XSPRITE *pXSprite) +static void zombfThinkChase(DBloodActor* actor) { + auto pXSprite = &actor->x(); + auto pSprite = &actor->s(); if (pXSprite->target == -1) { aiNewState(pSprite, pXSprite, &zombieFGoto); diff --git a/source/blood/src/bloodactor.h b/source/blood/src/bloodactor.h index 3934a0db4..ae79494be 100644 --- a/source/blood/src/bloodactor.h +++ b/source/blood/src/bloodactor.h @@ -10,7 +10,7 @@ BEGIN_BLD_NS -// Due to the messed up array storage of all the game data we cannot do any direct referenced here yet. We have to access everything via wrapper functions for now. +// Due to the messed up array storage of all the game data we cannot do any direct references here yet. We have to access everything via wrapper functions for now. // Note that the indexing is very inconsistent - partially by sprite index, partially by xsprite index. class DBloodActor { diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index 484ac2320..c25c254a3 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "ai.h" #include "savegamehelp.h" +#include "bloodactor.h" BEGIN_BLD_NS @@ -2123,7 +2124,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) { if (target >= 0) { pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z; - pXDude->target = target; aiActivateDude(pSprite, pXDude); + pXDude->target = target; aiActivateDude(&bloodActors[pXDude->reference]); } } @@ -3612,7 +3613,7 @@ void aiFightAlarmDudesInSight(spritetype* pSprite, int max) { continue; aiSetTarget(pXDude, pDude->x, pDude->y, pDude->z); - aiActivateDude(pDude, pXDude); + aiActivateDude(&bloodActors[pXDude->reference]); if (max-- < 1) break; } @@ -3696,7 +3697,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite switch (pXSprite->aiState->stateType) { case kAiStateIdle: case kAiStateGenIdle: - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); break; } break; @@ -3735,10 +3736,10 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4; pXSpawn->burnTime = 10; pXSpawn->target = -1; - aiActivateDude(pSpawn, pXSpawn); + aiActivateDude(&bloodActors[pXSpawn->reference]); break; default: - if (pSprite->flags & kModernTypeFlag3) aiActivateDude(pSpawn, pXSpawn); + if (pSprite->flags & kModernTypeFlag3) aiActivateDude(&bloodActors[pXSpawn->reference]); break; } } @@ -4635,7 +4636,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { int mDist = 3; if (aiFightIsMeleeUnit(pSprite)) mDist = 2; if (pXSprite->target >= 0 && aiFightGetTargetDist(pSprite, pDudeInfo, &sprite[pXSprite->target]) < mDist) { - if (!isActive(pSprite->index)) aiActivateDude(pSprite, pXSprite); + if (!isActive(pSprite->index)) aiActivateDude(&bloodActors[pXSprite->reference]); return; } // lets try to look for target that fits better by distance @@ -4649,19 +4650,19 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { spritetype* prvTarget = &sprite[pXSprite->target]; aiSetTarget(&xsprite[prvTarget->extra], prvTarget->x, prvTarget->y, prvTarget->z); if (!isActive(pTarget->index)) - aiActivateDude(pTarget, pXTarget); + aiActivateDude(&bloodActors[pXTarget->reference]); } // Change target for dude aiSetTarget(pXSprite, pTarget->index); if (!isActive(pSprite->index)) - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); // ...and change target of target to dude to force it fight if (pXSource->data3 > 0 && pXTarget->target != pSprite->index) { aiSetTarget(pXTarget, pSprite->index); if (!isActive(pTarget->index)) - aiActivateDude(pTarget, pXTarget); + aiActivateDude(&bloodActors[pXTarget->reference]); } return; @@ -4697,13 +4698,13 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { // Change target for dude aiSetTarget(pXSprite, pTarget->index); if (!isActive(pSprite->index)) - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); // ...and change target of target to dude to force it fight if (pXSource->data3 > 0 && pXTarget->target != pSprite->index) { aiSetTarget(pXTarget, pSprite->index); if (pPlayer == NULL && !isActive(pTarget->index)) - aiActivateDude(pTarget, pXTarget); + aiActivateDude(&bloodActors[pXTarget->reference]); if (pXSource->data3 == 2) aiFightAlarmDudesInSight(pTarget, maxAlarmDudes); @@ -4725,12 +4726,12 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { if (pXMateTarget->target < 0) { aiSetTarget(pXMateTarget, pSprite->index); if (IsDudeSprite(pMateTarget) && !isActive(pMateTarget->index)) - aiActivateDude(pMateTarget, pXMateTarget); + aiActivateDude(&bloodActors[pXMateTarget->reference]); } aiSetTarget(pXSprite, pMateTarget->index); if (!isActive(pSprite->index)) - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; // try walk in mate direction in case if not see the target @@ -4741,7 +4742,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { pXSprite->targetY = pMate->y; pXSprite->targetZ = pMate->z; if (!isActive(pSprite->index)) - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); return; } } diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index b6df130d1..b5d41792b 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -50,6 +50,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "messages.h" #include "nnexts.h" #include "d_net.h" +#include "bloodactor.h" BEGIN_BLD_NS @@ -349,7 +350,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdSpritePush: case kCmdSpriteTouch: if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1); - aiActivateDude(pSprite, pXSprite); + aiActivateDude(&bloodActors[pXSprite->reference]); break; } @@ -507,7 +508,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4; pXSpawn->burnTime = 10; pXSpawn->target = -1; - aiActivateDude(pSpawn, pXSpawn); + aiActivateDude(&bloodActors[pXSpawn->reference]); break; default: break; @@ -625,15 +626,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: if (!SetSpriteState(nSprite, pXSprite, 0)) break; - actActivateGibObject(pSprite, pXSprite); + actActivateGibObject(&bloodActors[pXSprite->reference]); break; case kCmdOn: if (!SetSpriteState(nSprite, pXSprite, 1)) break; - actActivateGibObject(pSprite, pXSprite); + actActivateGibObject(&bloodActors[pXSprite->reference]); break; default: if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break; - actActivateGibObject(pSprite, pXSprite); + actActivateGibObject(&bloodActors[pXSprite->reference]); break; } break;