- use actor parameters for aiSetTarget and aiActivateDude in several places.

This commit is contained in:
Christoph Oelckers 2021-09-16 20:38:46 +02:00
parent 61d9cd1b17
commit 890cc4947b
9 changed files with 58 additions and 56 deletions

View file

@ -986,7 +986,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
else if (actor->GetTarget() == nullptr) // if no target, give the dude a target
{
aiSetTarget(actor, source);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiActivateDude(actor);
}
else if (source != actor->GetTarget()) // if found a new target, retarget
{
@ -1530,14 +1530,14 @@ void aiThinkTarget(DBloodActor* actor)
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
return;
}
else if (nDist < pDudeInfo->hearDist)
{
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
return;
}
}
@ -1546,6 +1546,7 @@ void aiThinkTarget(DBloodActor* actor)
void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
{
auto actor = &bloodActors[pSprite->index];
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
if (Chance(pDudeInfo->alertChance))
@ -1569,14 +1570,14 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
return;
}
else if (nDist < pDudeInfo->hearDist)
{
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
return;
}
}
@ -1586,11 +1587,10 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, sectmap, nullptr, newSectCheckMethod);
int nSprite2;
StatIterator it(kStatDude);
while ((nSprite2 = it.NextIndex()) >= 0)
BloodStatIterator it(kStatDude);
while (DBloodActor* actor2 = it.Next())
{
spritetype *pSprite2 = &sprite[nSprite2];
spritetype* pSprite2 = &actor2->s();
int dx = pSprite2->x-pSprite->x;
int dy = pSprite2->y-pSprite->y;
int nDist = approxDist(dx, dy);
@ -1599,8 +1599,8 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
DUDEINFO *pDudeInfo = getDudeInfo(pSprite2->type);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
aiSetTarget_(pXSprite, pSprite2->index);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, actor2);
aiActivateDude(actor);
return;
}
}

View file

@ -92,7 +92,7 @@ static void batThinkTarget(DBloodActor* actor)
pDudeExtraE->thinkTime = 0;
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &batTurn);
return;
}
@ -117,13 +117,13 @@ static void batThinkTarget(DBloodActor* actor)
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;
@ -439,7 +439,7 @@ void batMoveToCeil(DBloodActor* actor)
aiNewState(actor, &batIdle);
}
else
aiSetTarget_(pXSprite, x, y, sector[nSector].ceilingz);
aiSetTarget(actor, x, y, sector[nSector].ceilingz);
}
END_BLD_NS

View file

@ -104,7 +104,7 @@ static void eelThinkTarget(DBloodActor* actor)
pDudeExtraE->thinkTime = 0;
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &eelTurn);
return;
}
@ -130,14 +130,14 @@ static void eelThinkTarget(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;
@ -441,7 +441,7 @@ void eelMoveToCeil(DBloodActor* actor)
aiNewState(actor, &eelIdle);
}
else
aiSetTarget_(pXSprite, x, y, sector[nSector].ceilingz);
aiSetTarget(actor, x, y, sector[nSector].ceilingz);
}
END_BLD_NS

View file

@ -262,7 +262,7 @@ static void cerberusThinkTarget(DBloodActor* actor)
{
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
if (pSprite->type == kDudeCerberusTwoHead)
aiNewState(actor, &cerberus139890);
else
@ -291,14 +291,14 @@ static void cerberusThinkTarget(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;

View file

@ -223,7 +223,7 @@ static void gargThinkTarget(DBloodActor* actor)
{
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &gargoyleTurn);
return;
}
@ -249,14 +249,14 @@ static void gargThinkTarget(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;

View file

@ -200,7 +200,7 @@ static void ghostThinkTarget(DBloodActor* actor)
{
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &ghostTurn);
return;
}
@ -226,15 +226,15 @@ static void ghostThinkTarget(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
return;
}
else if (nDist < pDudeInfo->hearDist)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
return;
}
}

View file

@ -234,7 +234,7 @@ static void sub_725A4(DBloodActor* actor)
{
pXSprite->goalAng += 256;
POINT3D *pTarget = &baseSprite[pSprite->index];
aiSetTarget_(pXSprite, pTarget->x, pTarget->y, pTarget->z);
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
aiNewState(actor, &tcherno13AA28);
return;
}
@ -260,14 +260,14 @@ static void sub_725A4(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
pDudeExtraE->thinkTime = 0;
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;

View file

@ -466,7 +466,7 @@ static void unicultThinkChase(DBloodActor* actor)
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
if (!pExtra->canAttack) {
if (pExtra->canWalk) aiSetTarget_(pXSprite, pSprite->index);
if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self???
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL);
return;
@ -595,8 +595,9 @@ static void unicultThinkChase(DBloodActor* actor)
} else if (weaponType == kGenDudeWeaponSummon) {
// don't attack slaves
if (pXSprite->target_i >= 0 && sprite[pXSprite->target_i].owner == pSprite->index) {
aiSetTarget_(pXSprite, pSprite->x, pSprite->y, pSprite->z);
if (actor->GetTarget() != nullptr && actor->GetTarget()->GetOwner() == actor)
{
aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
return;
} else if (gGenDudeExtra[pSprite->index].slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist) {
if (dist <= meleeVector->maxDist) {
@ -1728,6 +1729,7 @@ void genDudeTransform(spritetype* pSprite) {
}
XSPRITE* pXSprite = &xsprite[pSprite->extra];
auto actor = &bloodActors[pXSprite->reference];
XSPRITE* pXIncarnation = getNextIncarnation(pXSprite);
if (pXIncarnation == NULL) {
if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0;
@ -1816,11 +1818,11 @@ void genDudeTransform(spritetype* pSprite) {
aiInitSprite(pSprite);
// try to restore target
if (target == -1) aiSetTarget_(pXSprite, pSprite->x, pSprite->y, pSprite->z);
if (target == -1) aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
else aiSetTarget_(pXSprite, target);
// finally activate it
aiActivateDude(&bloodActors[pXSprite->reference]);
aiActivateDude(actor);
break;
}

View file

@ -239,13 +239,13 @@ static void myThinkTarget(DBloodActor* actor)
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
aiSetTarget_(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, pPlayer->actor());
aiActivateDude(actor);
}
else if (nDist < pDudeInfo->hearDist)
{
aiSetTarget_(pXSprite, x, y, z);
aiActivateDude(&bloodActors[pXSprite->reference]);
aiSetTarget(actor, x, y, z);
aiActivateDude(actor);
}
else
continue;