- replacing target_i, batch 1.

This was the simple stuff, mostly done by search&replacing common patterns.
This commit is contained in:
Christoph Oelckers 2021-05-05 09:47:08 +02:00
parent 90091965ba
commit 261301bdea
23 changed files with 106 additions and 104 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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;