From 261301bdeafeb0f7756fa4f6115d6e03acdcba28 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 5 May 2021 09:47:08 +0200 Subject: [PATCH] - replacing target_i, batch 1. This was the simple stuff, mostly done by search&replacing common patterns. --- source/games/blood/src/ai.cpp | 4 ++-- source/games/blood/src/aibat.cpp | 16 ++++++++-------- source/games/blood/src/aibeast.cpp | 16 ++++++++-------- source/games/blood/src/aiboneel.cpp | 18 +++++++++--------- source/games/blood/src/aiburn.cpp | 6 +++--- source/games/blood/src/aicaleb.cpp | 16 ++++++++-------- source/games/blood/src/aicerber.cpp | 6 +++--- source/games/blood/src/aicult.cpp | 6 +++--- source/games/blood/src/aigarg.cpp | 10 +++++----- source/games/blood/src/aighost.cpp | 10 +++++----- source/games/blood/src/aigilbst.cpp | 16 ++++++++-------- source/games/blood/src/aihand.cpp | 6 +++--- source/games/blood/src/aihound.cpp | 6 +++--- source/games/blood/src/aiinnoc.cpp | 6 +++--- source/games/blood/src/aipod.cpp | 6 +++--- source/games/blood/src/airat.cpp | 6 +++--- source/games/blood/src/aispid.cpp | 6 +++--- source/games/blood/src/aitchern.cpp | 6 +++--- source/games/blood/src/aiunicult.cpp | 14 +++++++------- source/games/blood/src/aizomba.cpp | 13 ++++++------- source/games/blood/src/aizombf.cpp | 6 +++--- source/games/blood/src/callback.cpp | 2 +- source/games/blood/src/nnexts.cpp | 9 ++++++--- 23 files changed, 106 insertions(+), 104 deletions(-) diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 66d0eb811..74f26a645 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -994,9 +994,9 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType spritetype *pSource = &source->s(); int nSource = pSource->index; if (pSprite == pSource) return 0; - else if (pXSprite->target_i == -1) // if no target, give the dude a target + else if (actor->GetTarget() == nullptr) // if no target, give the dude a target { - aiSetTarget(pXSprite, nSource); + aiSetTarget(actor, source); aiActivateDude(&bloodActors[pXSprite->reference]); } else if (nSource != pXSprite->target_i) // if found a new target, retarget diff --git a/source/games/blood/src/aibat.cpp b/source/games/blood/src/aibat.cpp index b62a6ed28..2a4223cb7 100644 --- a/source/games/blood/src/aibat.cpp +++ b/source/games/blood/src/aibat.cpp @@ -160,7 +160,7 @@ static void batThinkPonder(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &batSearch); return; @@ -188,7 +188,7 @@ static void batThinkPonder(DBloodActor* actor) GetSpriteExtents(pSprite, &top, &bottom); if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (height2-height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) aiNewState(actor, &batDodgeUp); else if (height2-height > 0x5000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) @@ -209,7 +209,7 @@ static void batThinkPonder(DBloodActor* actor) } } aiNewState(actor, &batGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void batMoveDodgeUp(DBloodActor* actor) @@ -268,7 +268,7 @@ static void batThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &batGoto); return; @@ -304,7 +304,7 @@ static void batThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); if (height2-height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85) aiNewState(actor, &batBite); @@ -322,7 +322,7 @@ static void batThinkChase(DBloodActor* actor) } } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); aiNewState(actor, &batHide); } @@ -338,7 +338,7 @@ static void batMoveForward(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -351,7 +351,7 @@ static void batMoveForward(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>1; diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index a5199dc95..401a23fe9 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -222,7 +222,7 @@ static void beastThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { XSECTOR *pXSector; int nXSector = sector[pSprite->sectnum].extra; @@ -281,7 +281,7 @@ static void beastThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags&2) && IsPlayerSprite(pTarget) && Chance(0x8000)) @@ -378,7 +378,7 @@ static void beastThinkChase(DBloodActor* actor) aiNewState(actor, &beastSwimGoto); else aiNewState(actor, &beastGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void beastThinkSwimGoto(DBloodActor* actor) @@ -401,7 +401,7 @@ static void beastThinkSwimChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &beastSwimGoto); return; @@ -435,7 +435,7 @@ static void beastThinkSwimChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x400 && abs(nDeltaAngle) < 85) aiNewState(actor, &beastSwimSlash); else @@ -450,7 +450,7 @@ static void beastThinkSwimChase(DBloodActor* actor) return; } aiNewState(actor, &beastSwimGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void beastMoveForward(DBloodActor* actor) @@ -485,7 +485,7 @@ static void sub_628A0(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -498,7 +498,7 @@ static void sub_628A0(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>2; diff --git a/source/games/blood/src/aiboneel.cpp b/source/games/blood/src/aiboneel.cpp index 7b4cf12f2..8a1443e54 100644 --- a/source/games/blood/src/aiboneel.cpp +++ b/source/games/blood/src/aiboneel.cpp @@ -80,7 +80,7 @@ void eelBiteSeqCallback(int, DBloodActor* actor) * copied from lines 177:181 * resolves this case, but may cause other issues? */ - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &eelSearch); return; @@ -173,7 +173,7 @@ static void eelThinkPonder(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &eelSearch); return; @@ -201,7 +201,7 @@ static void eelThinkPonder(DBloodActor* actor) GetSpriteExtents(pSprite, &top, &bottom); if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (height2-height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) aiNewState(actor, &eelDodgeUp); else if (height2-height > 0xccc && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) @@ -222,7 +222,7 @@ static void eelThinkPonder(DBloodActor* actor) } } aiNewState(actor, &eelGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void eelMoveDodgeUp(DBloodActor* actor) @@ -281,7 +281,7 @@ static void eelThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &eelGoto); return; @@ -317,7 +317,7 @@ static void eelThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x399 && top2 > top && abs(nDeltaAngle) < 85) aiNewState(actor, &eelSwoop); else if (nDist <= 0x399 && abs(nDeltaAngle) < 85) @@ -331,7 +331,7 @@ static void eelThinkChase(DBloodActor* actor) return; } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); aiNewState(actor, &eelSearch); } @@ -347,7 +347,7 @@ static void eelMoveForward(DBloodActor* actor) int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -360,7 +360,7 @@ static void eelMoveForward(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>1; diff --git a/source/games/blood/src/aiburn.cpp b/source/games/blood/src/aiburn.cpp index 43cc7d289..529ed5e54 100644 --- a/source/games/blood/src/aiburn.cpp +++ b/source/games/blood/src/aiburn.cpp @@ -130,7 +130,7 @@ static void burnThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { switch (pSprite->type) { @@ -207,7 +207,7 @@ static void burnThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x333 && abs(nDeltaAngle) < 85) { switch (pSprite->type) @@ -268,7 +268,7 @@ static void burnThinkChase(DBloodActor* actor) break; #endif } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aicaleb.cpp b/source/games/blood/src/aicaleb.cpp index 57b0b9848..a160781a5 100644 --- a/source/games/blood/src/aicaleb.cpp +++ b/source/games/blood/src/aicaleb.cpp @@ -121,7 +121,7 @@ static void calebThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { XSECTOR *pXSector; int nXSector = sector[pSprite->sectnum].extra; @@ -183,7 +183,7 @@ static void calebThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); if (nDist < 0x599 && abs(nDeltaAngle) < 28) { @@ -243,7 +243,7 @@ static void calebThinkChase(DBloodActor* actor) aiNewState(actor, &tinycalebGoto); if (Chance(0x2000)) sfxPlay3DSound(pSprite, 10000 + Random(5), -1, 0); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void calebThinkSwimGoto(DBloodActor* actor) @@ -266,7 +266,7 @@ static void calebThinkSwimChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &tinycalebSwimGoto); return; @@ -300,7 +300,7 @@ static void calebThinkSwimChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x400 && abs(nDeltaAngle) < 85) aiNewState(actor, &tinycalebSwimAttack); else @@ -310,7 +310,7 @@ static void calebThinkSwimChase(DBloodActor* actor) return; } aiNewState(actor, &tinycalebSwimGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void sub_65D04(DBloodActor* actor) @@ -326,7 +326,7 @@ static void sub_65D04(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -339,7 +339,7 @@ static void sub_65D04(DBloodActor* actor) int vy = yvel[nSprite]; int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>2; diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index 358bb02e3..5c5c4b643 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -351,7 +351,7 @@ static void cerberusThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) { + if (actor->GetTarget() == nullptr) { switch (pSprite->type) { case kDudeCerberusTwoHead: aiNewState(actor, &cerberusGoto); @@ -414,7 +414,7 @@ static void cerberusThinkChase(DBloodActor* actor) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) { switch (pSprite->type) { @@ -490,7 +490,7 @@ static void cerberusThinkChase(DBloodActor* actor) aiNewState(actor, &cerberus2Goto); break; } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aicult.cpp b/source/games/blood/src/aicult.cpp index b6a383c88..c41f0c6d8 100644 --- a/source/games/blood/src/aicult.cpp +++ b/source/games/blood/src/aicult.cpp @@ -236,7 +236,7 @@ static void cultThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { switch (pXSprite->medium) { @@ -299,7 +299,7 @@ static void cultThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); switch (pSprite->type) { case kDudeCultistTommy: @@ -633,7 +633,7 @@ static void cultThinkChase(DBloodActor* actor) aiNewState(actor, &cultistSwimGoto); break; } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index 6f53bce47..ab6e8d322 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -355,7 +355,7 @@ static void gargThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &gargoyleFGoto); return; @@ -399,7 +399,7 @@ static void gargThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); switch (pSprite->type) { case kDudeGargoyleFlesh: @@ -530,7 +530,7 @@ static void gargThinkChase(DBloodActor* actor) } aiNewState(actor, &gargoyleFGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void entryFStatue(DBloodActor* actor) @@ -565,7 +565,7 @@ static void gargMoveForward(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -578,7 +578,7 @@ static void gargMoveForward(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>1; diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index 8d246717b..d0fa239a1 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -333,7 +333,7 @@ static void ghostThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &ghostGoto); return; @@ -377,7 +377,7 @@ static void ghostThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); switch (pSprite->type) { case kDudePhantasm: @@ -440,7 +440,7 @@ static void ghostThinkChase(DBloodActor* actor) } aiNewState(actor, &ghostGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void ghostMoveForward(DBloodActor* actor) @@ -459,7 +459,7 @@ static void ghostMoveForward(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -472,7 +472,7 @@ static void ghostMoveForward(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>1; diff --git a/source/games/blood/src/aigilbst.cpp b/source/games/blood/src/aigilbst.cpp index d89b08423..24c9bc1d8 100644 --- a/source/games/blood/src/aigilbst.cpp +++ b/source/games/blood/src/aigilbst.cpp @@ -112,7 +112,7 @@ static void gillThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { XSECTOR *pXSector; int nXSector = sector[pSprite->sectnum].extra; @@ -171,7 +171,7 @@ static void gillThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); if (nDist < 921 && abs(nDeltaAngle) < 28) { @@ -230,7 +230,7 @@ static void gillThinkChase(DBloodActor* actor) else aiNewState(actor, &gillBeastGoto); sfxPlay3DSound(pSprite, 1701, -1, 0); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void gillThinkSwimGoto(DBloodActor* actor) @@ -253,7 +253,7 @@ static void gillThinkSwimChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &gillBeastSwimSearch); return; @@ -287,7 +287,7 @@ static void gillThinkSwimChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x400 && abs(nDeltaAngle) < 85) aiNewState(actor, &gillBeastSwimBite); else @@ -302,7 +302,7 @@ static void gillThinkSwimChase(DBloodActor* actor) return; } aiNewState(actor, &gillBeastSwimGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void sub_6CB00(DBloodActor* actor) @@ -318,7 +318,7 @@ static void sub_6CB00(DBloodActor* actor) int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang+256)&2047; int dx = pXSprite->targetX-pSprite->x; int dy = pXSprite->targetY-pSprite->y; @@ -331,7 +331,7 @@ static void sub_6CB00(DBloodActor* actor) int vy = actor->yvel(); int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel>>2; diff --git a/source/games/blood/src/aihand.cpp b/source/games/blood/src/aihand.cpp index eb6f16b9a..42e0eae14 100644 --- a/source/games/blood/src/aihand.cpp +++ b/source/games/blood/src/aihand.cpp @@ -86,7 +86,7 @@ static void handThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &handGoto); return; @@ -118,7 +118,7 @@ static void handThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x233 && abs(nDeltaAngle) < 85 && gGameOptions.nGameType == 0) aiNewState(actor, &handJump); return; @@ -127,7 +127,7 @@ static void handThinkChase(DBloodActor* actor) } aiNewState(actor, &handGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aihound.cpp b/source/games/blood/src/aihound.cpp index 0fd061cf2..4ec349ec4 100644 --- a/source/games/blood/src/aihound.cpp +++ b/source/games/blood/src/aihound.cpp @@ -109,7 +109,7 @@ static void houndThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &houndGoto); return; @@ -149,7 +149,7 @@ static void houndThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) aiNewState(actor, &houndBurn); else if(nDist < 0x266 && abs(nDeltaAngle) < 85) @@ -160,7 +160,7 @@ static void houndThinkChase(DBloodActor* actor) } aiNewState(actor, &houndGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aiinnoc.cpp b/source/games/blood/src/aiinnoc.cpp index 4c38aaac2..34c978f38 100644 --- a/source/games/blood/src/aiinnoc.cpp +++ b/source/games/blood/src/aiinnoc.cpp @@ -69,7 +69,7 @@ static void innocThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &innocentGoto); return; @@ -101,7 +101,7 @@ static void innocThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x666 && abs(nDeltaAngle) < 85) aiNewState(actor, &innocentIdle); return; @@ -111,7 +111,7 @@ static void innocThinkChase(DBloodActor* actor) aiPlay3DSound(pSprite, 7000+Random(6), AI_SFX_PRIORITY_1, -1); aiNewState(actor, &innocentGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } diff --git a/source/games/blood/src/aipod.cpp b/source/games/blood/src/aipod.cpp index b91d74c32..5a6f5329e 100644 --- a/source/games/blood/src/aipod.cpp +++ b/source/games/blood/src/aipod.cpp @@ -182,7 +182,7 @@ static void aiPodChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) { + if (actor->GetTarget() == nullptr) { switch (pSprite->type) { case kDudePodGreen: case kDudePodFire: @@ -234,7 +234,7 @@ static void aiPodChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (abs(nDeltaAngle) < 85 && pTarget->type != kDudePodGreen && pTarget->type != kDudePodFire) { switch (pSprite->type) { case kDudePodGreen: @@ -262,7 +262,7 @@ static void aiPodChase(DBloodActor* actor) aiNewState(actor, &tentacleMove); break; } - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/airat.cpp b/source/games/blood/src/airat.cpp index b033578ce..9c5f4dddd 100644 --- a/source/games/blood/src/airat.cpp +++ b/source/games/blood/src/airat.cpp @@ -83,7 +83,7 @@ static void ratThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &ratGoto); return; @@ -115,7 +115,7 @@ static void ratThinkChase(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x399 && abs(nDeltaAngle) < 85) aiNewState(actor, &ratBite); return; @@ -124,7 +124,7 @@ static void ratThinkChase(DBloodActor* actor) } aiNewState(actor, &ratGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index 1f4ae9e3b..9ce72a8bf 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -200,7 +200,7 @@ static void spidThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &spidGoto); return; @@ -229,7 +229,7 @@ static void spidThinkChase(DBloodActor* actor) int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); switch (pSprite->type) { case kDudeSpiderRed: @@ -257,7 +257,7 @@ static void spidThinkChase(DBloodActor* actor) } aiNewState(actor, &spidGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index 95e9ec6dc..b9b87d3d7 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -306,7 +306,7 @@ static void sub_72934(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &tcherno13A9B8); return; @@ -346,7 +346,7 @@ static void sub_72934(DBloodActor* actor) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x1f00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) aiNewState(actor, &tcherno13AA0C); else if (nDist < 0xd00 && nDist > 0xb00 && abs(nDeltaAngle) < 85) @@ -359,7 +359,7 @@ static void sub_72934(DBloodActor* actor) } aiNewState(actor, &tcherno13A9B8); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index ad50ba44a..d45617c01 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -434,7 +434,7 @@ static void unicultThinkChase(DBloodActor* actor) if (pXTarget == NULL) { // target lost if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW); else aiGenDudeNewState(pSprite, &genDudeSearchShortL); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); return; } else if (pXTarget->health <= 0) { // target is dead @@ -446,7 +446,7 @@ static void unicultThinkChase(DBloodActor* actor) } else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW); else aiGenDudeNewState(pSprite, &genDudeGotoL); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); return; } @@ -475,7 +475,7 @@ static void unicultThinkChase(DBloodActor* actor) if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0) { if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW); else aiGenDudeNewState(pSprite, &genDudeSearchShortL); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); return; } } @@ -489,7 +489,7 @@ static void unicultThinkChase(DBloodActor* actor) if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); else aiGenDudeNewState(pSprite, &genDudeSearchL); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); return; } @@ -880,7 +880,7 @@ static void unicultThinkChase(DBloodActor* actor) } } - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); switch (state) { case 1: aiGenDudeNewState(pSprite, &genDudeFireW); @@ -999,7 +999,7 @@ void aiGenDudeMoveForward(DBloodActor* actor) int nAccel = pDudeInfo->frontSpeed << 2; if (abs(nAng) > 341) return; - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) pSprite->ang = (pSprite->ang + 256) & 2047; int dx = pXSprite->targetX - pSprite->x; int dy = pXSprite->targetY - pSprite->y; @@ -1012,7 +1012,7 @@ void aiGenDudeMoveForward(DBloodActor* actor) int vy = yvel[pSprite->index]; int t1 = DMulScale(vx, nCos, vy, nSin, 30); int t2 = DMulScale(vx, nSin, -vy, nCos, 30); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) t1 += nAccel; else t1 += nAccel >> 1; diff --git a/source/games/blood/src/aizomba.cpp b/source/games/blood/src/aizomba.cpp index 8064c0d39..b06bcd7d1 100644 --- a/source/games/blood/src/aizomba.cpp +++ b/source/games/blood/src/aizomba.cpp @@ -111,7 +111,7 @@ static void zombaThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &zombieASearch); return; @@ -147,7 +147,7 @@ static void zombaThinkChase(DBloodActor* actor) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x400 && abs(nDeltaAngle) < 85) aiNewState(actor, &zombieAHack); return; @@ -156,14 +156,14 @@ static void zombaThinkChase(DBloodActor* actor) } aiNewState(actor, &zombieAGoto); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void zombaThinkPonder(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &zombieASearch); return; @@ -195,7 +195,7 @@ static void zombaThinkPonder(DBloodActor* actor) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x400) { if (abs(nDeltaAngle) < 85) @@ -270,8 +270,7 @@ static void entryEZombie(DBloodActor* actor) static void entryAIdle(DBloodActor* actor) { - auto pXSprite = &actor->x(); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } static void entryEStand(DBloodActor* actor) diff --git a/source/games/blood/src/aizombf.cpp b/source/games/blood/src/aizombf.cpp index 6c07d51ec..1e5997e8f 100644 --- a/source/games/blood/src/aizombf.cpp +++ b/source/games/blood/src/aizombf.cpp @@ -112,7 +112,7 @@ static void zombfThinkChase(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (pXSprite->target_i == -1) + if (actor->GetTarget() == nullptr) { aiNewState(actor, &zombieFGoto); return; @@ -144,7 +144,7 @@ static void zombfThinkChase(DBloodActor* actor) { if (abs(nDeltaAngle) <= pDudeInfo->periphery) { - aiSetTarget(pXSprite, pXSprite->target_i); + aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85) { int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); @@ -208,7 +208,7 @@ static void zombfThinkChase(DBloodActor* actor) } aiNewState(actor, &zombieFSearch); - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } END_BLD_NS diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 79e60f7a7..8efa861e4 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -269,7 +269,7 @@ void Respawn(int nSprite) // 9 // return dude to the patrol state if (gModernMap && pXSprite->dudeFlag4) { pXSprite->data3 = 0; - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } #else pSprite->clipdist = getDudeInfo(nType + kDudeBase)->clipdist; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 8a872d92a..ac25c5e04 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -6792,8 +6792,11 @@ void aiPatrolSetMarker(spritetype* pSprite, XSPRITE* pXSprite) { } -void aiPatrolStop(spritetype* pSprite, int target, bool alarm) { - if (xspriRangeIsFine(pSprite->extra)) { +void aiPatrolStop(spritetype* pSprite, int target, bool alarm) +{ + auto actor = &bloodActors[pSprite->index]; + if (xspriRangeIsFine(pSprite->extra)) + { XSPRITE* pXSprite = &xsprite[pSprite->extra]; pXSprite->data3 = 0; // reset spot progress @@ -6805,7 +6808,7 @@ void aiPatrolStop(spritetype* pSprite, int target, bool alarm) { if (pXSprite->target_i >= 0 && sprite[pXSprite->target_i].type == kMarkerPath) { if (target < 0) pSprite->ang = sprite[pXSprite->target_i].ang & 2047; - pXSprite->target_i = -1; + actor->SetTarget(nullptr); } bool patrol = pXSprite->dudeFlag4; pXSprite->dudeFlag4 = 0;