- aiChooseDirection and its subfunctions.

This commit is contained in:
Christoph Oelckers 2021-09-16 00:17:37 +02:00
parent a79d362b40
commit 774a015e6b
23 changed files with 109 additions and 102 deletions

View file

@ -96,11 +96,11 @@ void aiNewState(DBloodActor* actor, AISTATE *pAIState)
{ {
seqStartId += pAIState->seqId; seqStartId += pAIState->seqId;
if (getSequence(seqStartId)) if (getSequence(seqStartId))
seqSpawn(seqStartId, 3, pSprite->extra, pAIState->funcId); seqSpawn(seqStartId, actor, pAIState->funcId);
} }
if (pAIState->enterFunc) if (pAIState->enterFunc)
pAIState->enterFunc(&bloodActors[pXSprite->reference]); pAIState->enterFunc(actor);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -109,17 +109,18 @@ void aiNewState(DBloodActor* actor, AISTATE *pAIState)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool isImmune(spritetype* pSprite, int dmgType, int minScale) static bool isImmune(DBloodActor* actor, int dmgType, int minScale)
{ {
if (dmgType >= kDmgFall && dmgType < kDmgMax && pSprite->extra >= 0 && xsprite[pSprite->extra].locked != 1) if (dmgType >= kDmgFall && dmgType < kDmgMax && actor->hasX() && actor->x().locked != 1)
{ {
if (pSprite->type >= kThingBase && pSprite->type < kThingMax) int type = actor->s().type;
return (thingInfo[pSprite->type - kThingBase].dmgControl[dmgType] <= minScale); if (type >= kThingBase && type < kThingMax)
else if (IsDudeSprite(pSprite)) return (thingInfo[type - kThingBase].dmgControl[dmgType] <= minScale);
else if (actor->IsDudeActor())
{ {
if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].godMode || gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType] <= minScale); if (actor->IsPlayerActor()) return (gPlayer[type - kDudePlayer1].godMode || gPlayer[type - kDudePlayer1].damageControl[dmgType] <= minScale);
else return (dudeInfo[pSprite->type - kDudeBase].damageVal[dmgType] <= minScale); else return (dudeInfo[type - kDudeBase].damageVal[dmgType] <= minScale);
} }
} }
return true; return true;
@ -131,8 +132,9 @@ bool isImmune(spritetype* pSprite, int dmgType, int minScale)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool CanMove(spritetype *pSprite, int a2, int nAngle, int nRange) bool CanMove(DBloodActor *actor, int a2, int nAngle, int nRange)
{ {
auto pSprite = &actor->s();
int top, bottom; int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
int x = pSprite->x; int x = pSprite->x;
@ -207,7 +209,7 @@ bool CanMove(spritetype *pSprite, int a2, int nAngle, int nRange)
// It makes ignore danger if enemy immune to N damageType. As result Cerberus start acting like // It makes ignore danger if enemy immune to N damageType. As result Cerberus start acting like
// in Blood 1.0 so it can move normally to player. It's up to you for adding rest of enemies here as // in Blood 1.0 so it can move normally to player. It's up to you for adding rest of enemies here as
// i don't think it will broke something in game. // i don't think it will broke something in game.
if (!cl_bloodvanillaenemies && !VanillaMode() && Crusher && isImmune(pSprite, pXSector->damageType, 16)) return true; if (!cl_bloodvanillaenemies && !VanillaMode() && Crusher && isImmune(actor, pXSector->damageType, 16)) return true;
[[fallthrough]]; [[fallthrough]];
case kDudeZombieButcher: case kDudeZombieButcher:
case kDudeSpiderBrown: case kDudeSpiderBrown:
@ -250,8 +252,11 @@ bool CanMove(spritetype *pSprite, int a2, int nAngle, int nRange)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3) void aiChooseDirection(DBloodActor* actor, int a3)
{ {
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
int nSprite = pSprite->index; int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
int vc = ((a3+1024-pSprite->ang)&2047)-1024; int vc = ((a3+1024-pSprite->ang)&2047)-1024;
@ -264,17 +269,17 @@ void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3)
int v8 = 341; int v8 = 341;
if (vc < 0) if (vc < 0)
v8 = -341; v8 = -341;
if (CanMove(pSprite, pXSprite->target, pSprite->ang+vc, vsi)) if (CanMove(actor, pXSprite->target, pSprite->ang+vc, vsi))
pXSprite->goalAng = pSprite->ang+vc; pXSprite->goalAng = pSprite->ang+vc;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang+vc/2, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang+vc/2, vsi))
pXSprite->goalAng = pSprite->ang+vc/2; pXSprite->goalAng = pSprite->ang+vc/2;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang-vc/2, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang-vc/2, vsi))
pXSprite->goalAng = pSprite->ang-vc/2; pXSprite->goalAng = pSprite->ang-vc/2;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang+v8, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang+v8, vsi))
pXSprite->goalAng = pSprite->ang+v8; pXSprite->goalAng = pSprite->ang+v8;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang-v8, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang-v8, vsi))
pXSprite->goalAng = pSprite->ang-v8; pXSprite->goalAng = pSprite->ang-v8;
//else if (pSprite->flags&2) //else if (pSprite->flags&2)
//pXSprite->goalAng = pSprite->ang+341; //pXSprite->goalAng = pSprite->ang+341;
@ -284,10 +289,10 @@ void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3)
pXSprite->dodgeDir = 1; pXSprite->dodgeDir = 1;
else else
pXSprite->dodgeDir = -1; pXSprite->dodgeDir = -1;
if (!CanMove(pSprite, pXSprite->target, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, pXSprite->target, pSprite->ang+pXSprite->dodgeDir*512, 512))
{ {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(pSprite, pXSprite->target, pSprite->ang+pXSprite->dodgeDir*512, 512)) if (!CanMove(actor, pXSprite->target, pSprite->ang+pXSprite->dodgeDir*512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
} }
@ -376,7 +381,7 @@ void aiActivateDude(DBloodActor* actor)
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!pXSprite->state) if (!pXSprite->state)
{ {
aiChooseDirection(pSprite, pXSprite, getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y)); aiChooseDirection(actor, getangle(pXSprite->targetX-pSprite->x, pXSprite->targetY-pSprite->y));
pXSprite->state = 1; pXSprite->state = 1;
} }
switch (pSprite->type) switch (pSprite->type)

View file

@ -91,7 +91,7 @@ extern const int dword_138BB0[5];
bool dudeIsPlayingSeq(DBloodActor* pSprite, int nSeq); bool dudeIsPlayingSeq(DBloodActor* pSprite, int nSeq);
void aiPlay3DSound(DBloodActor* pSprite, int a2, AI_SFX_PRIORITY a3, int a4); void aiPlay3DSound(DBloodActor* pSprite, int a2, AI_SFX_PRIORITY a3, int a4);
void aiNewState(DBloodActor* actor, AISTATE *pAIState); void aiNewState(DBloodActor* actor, AISTATE *pAIState);
void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3); void aiChooseDirection(DBloodActor* actor, int a3);
void aiMoveForward(DBloodActor*pXSprite); void aiMoveForward(DBloodActor*pXSprite);
void aiMoveTurn(DBloodActor*pXSprite); void aiMoveTurn(DBloodActor*pXSprite);
void aiMoveDodge(DBloodActor *actor); void aiMoveDodge(DBloodActor *actor);
@ -104,7 +104,7 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite);
void aiProcessDudes(void); void aiProcessDudes(void);
void aiInit(void); void aiInit(void);
void aiInitSprite(spritetype *pSprite); void aiInitSprite(spritetype *pSprite);
bool CanMove(spritetype* pSprite, int a2, int nAngle, int nRange); bool CanMove(DBloodActor* pSprite, int a2, int nAngle, int nRange);
bool dudeIsPlayingSeq(spritetype* pSprite, int nSeq); // deprecated bool dudeIsPlayingSeq(spritetype* pSprite, int nSeq); // deprecated
void aiPlay3DSound(spritetype* pSprite, int a2, AI_SFX_PRIORITY a3, int a4); void aiPlay3DSound(spritetype* pSprite, int a2, AI_SFX_PRIORITY a3, int a4);

View file

@ -136,7 +136,7 @@ static void batThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor, pXSprite->goalAng);
batThinkTarget(actor); batThinkTarget(actor);
} }
@ -150,7 +150,7 @@ static void batThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
batThinkTarget(actor); batThinkTarget(actor);
@ -172,7 +172,7 @@ static void batThinkPonder(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
@ -280,7 +280,7 @@ static void batThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);

View file

@ -187,7 +187,7 @@ static void beastThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -207,7 +207,7 @@ static void beastThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
@ -243,7 +243,7 @@ static void beastThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
@ -391,7 +391,7 @@ static void beastThinkSwimGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -413,7 +413,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);

View file

@ -149,7 +149,7 @@ static void eelThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
eelThinkTarget(actor); eelThinkTarget(actor);
} }
@ -163,7 +163,7 @@ static void eelThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
eelThinkTarget(actor); eelThinkTarget(actor);
@ -185,7 +185,7 @@ static void eelThinkPonder(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
@ -293,7 +293,7 @@ static void eelThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);

View file

@ -79,7 +79,7 @@ static void burnThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -93,7 +93,7 @@ static void burnThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) switch (pSprite->type)
@ -167,7 +167,7 @@ static void burnThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
switch (pSprite->type) switch (pSprite->type)

View file

@ -86,7 +86,7 @@ static void calebThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -106,7 +106,7 @@ static void calebThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
@ -142,7 +142,7 @@ static void calebThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
@ -256,7 +256,7 @@ static void calebThinkSwimGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -278,7 +278,7 @@ static void calebThinkSwimChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);

View file

@ -252,7 +252,7 @@ static void cerberusThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -332,7 +332,7 @@ static void cerberusThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) { switch (pSprite->type) {
@ -380,7 +380,7 @@ static void cerberusThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) { if (pXTarget->health == 0) {
switch (pSprite->type) { switch (pSprite->type) {

View file

@ -201,7 +201,7 @@ static void cultThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiLookForTarget(pSprite, pXSprite); aiLookForTarget(pSprite, pXSprite);
} }
@ -215,7 +215,7 @@ static void cultThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
@ -257,7 +257,7 @@ static void cultThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)

View file

@ -267,7 +267,7 @@ static void gargThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiLookForTarget(pSprite, pXSprite); aiLookForTarget(pSprite, pXSprite);
} }
@ -285,7 +285,7 @@ static void gargThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -375,7 +375,7 @@ static void gargThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);

View file

@ -243,7 +243,7 @@ static void ghostThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -261,7 +261,7 @@ static void ghostThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ghostSearch); aiNewState(actor, &ghostSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -353,7 +353,7 @@ static void ghostThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &ghostSearch); aiNewState(actor, &ghostSearch);

View file

@ -77,7 +77,7 @@ static void gillThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -97,7 +97,7 @@ static void gillThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
@ -133,7 +133,7 @@ static void gillThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
@ -243,7 +243,7 @@ static void gillThinkSwimGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -265,7 +265,7 @@ static void gillThinkSwimChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);

View file

@ -62,7 +62,7 @@ static void handThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -76,7 +76,7 @@ static void handThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -98,7 +98,7 @@ static void handThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);

View file

@ -80,7 +80,7 @@ static void houndThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -99,7 +99,7 @@ static void houndThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -129,7 +129,7 @@ static void houndThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);

View file

@ -45,7 +45,7 @@ static void innocThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -59,7 +59,7 @@ static void innocThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -81,7 +81,7 @@ static void innocThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);

View file

@ -143,7 +143,7 @@ static void aiPodSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -162,7 +162,7 @@ static void aiPodMove(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) { if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudePodGreen: case kDudePodGreen:
@ -210,7 +210,7 @@ static void aiPodChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) { if (pXTarget->health == 0) {
switch (pSprite->type) { switch (pSprite->type) {

View file

@ -59,7 +59,7 @@ static void ratThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -73,7 +73,7 @@ static void ratThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -95,7 +95,7 @@ static void ratThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);

View file

@ -176,7 +176,7 @@ static void spidThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -190,7 +190,7 @@ static void spidThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -212,7 +212,7 @@ static void spidThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);

View file

@ -219,7 +219,7 @@ static void sub_72580(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -296,7 +296,7 @@ static void sub_72850(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -326,7 +326,7 @@ static void sub_72934(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);

View file

@ -386,7 +386,7 @@ static void unicultThinkSearch(DBloodActor* actor)
// TO DO: if can't see the target, but in fireDist range - stop moving and look around // TO DO: if can't see the target, but in fireDist range - stop moving and look around
//viewSetSystemMessage("IN SEARCH"); //viewSetSystemMessage("IN SEARCH");
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiLookForTarget(pSprite, pXSprite); aiLookForTarget(pSprite, pXSprite);
} }
@ -403,7 +403,7 @@ static void unicultThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY - pSprite->y; int dy = pXSprite->targetY - pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
// if reached target, change to search mode // if reached target, change to search mode
if (approxDist(dx, dy) < 5120 && abs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) { if (approxDist(dx, dy) < 5120 && abs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) {
@ -461,7 +461,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (inAttack(pXSprite->aiState)) if (inAttack(pXSprite->aiState))
xvelocity = yvelocity = ClipLow(pSprite->clipdist >> 1, 1); xvelocity = yvelocity = ClipLow(pSprite->clipdist >> 1, 1);
//aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); //aiChooseDirection(actor,getangle(dx, dy));
aiGenDudeChooseDirection(pSprite, pXSprite, getangle(dx, dy), xvelocity, yvelocity); aiGenDudeChooseDirection(pSprite, pXSprite, getangle(dx, dy), xvelocity, yvelocity);
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index]; GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
@ -1040,6 +1040,7 @@ void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, in
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax"); Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
return; return;
} }
auto actor = &bloodActors[pSprite->index];
// TO-DO: Take in account if sprite is flip-x, so enemy select correct angle // TO-DO: Take in account if sprite is flip-x, so enemy select correct angle
@ -1047,26 +1048,26 @@ void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, in
int t1 = DMulScale(xvel, Cos(pSprite->ang), yvel, Sin(pSprite->ang), 30); int t1 = DMulScale(xvel, Cos(pSprite->ang), yvel, Sin(pSprite->ang), 30);
int vsi = ((t1 * 15) >> 12) / 2; int v8 = (vc >= 0) ? 341 : -341; int vsi = ((t1 * 15) >> 12) / 2; int v8 = (vc >= 0) ? 341 : -341;
if (CanMove(pSprite, pXSprite->target, pSprite->ang + vc, vsi)) if (CanMove(actor, pXSprite->target, pSprite->ang + vc, vsi))
pXSprite->goalAng = pSprite->ang + vc; pXSprite->goalAng = pSprite->ang + vc;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang + vc / 2, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang + vc / 2, vsi))
pXSprite->goalAng = pSprite->ang + vc / 2; pXSprite->goalAng = pSprite->ang + vc / 2;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang - vc / 2, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang - vc / 2, vsi))
pXSprite->goalAng = pSprite->ang - vc / 2; pXSprite->goalAng = pSprite->ang - vc / 2;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang + v8, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang + v8, vsi))
pXSprite->goalAng = pSprite->ang + v8; pXSprite->goalAng = pSprite->ang + v8;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang, vsi))
pXSprite->goalAng = pSprite->ang; pXSprite->goalAng = pSprite->ang;
else if (CanMove(pSprite, pXSprite->target, pSprite->ang - v8, vsi)) else if (CanMove(actor, pXSprite->target, pSprite->ang - v8, vsi))
pXSprite->goalAng = pSprite->ang - v8; pXSprite->goalAng = pSprite->ang - v8;
else else
pXSprite->goalAng = pSprite->ang + 341; pXSprite->goalAng = pSprite->ang + 341;
pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1; pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1;
if (!CanMove(pSprite, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) { if (!CanMove(actor, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) {
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(pSprite, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!CanMove(actor, pXSprite->target, pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
} }
} }

View file

@ -87,7 +87,7 @@ static void zombaThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiLookForTarget(pSprite, pXSprite); aiLookForTarget(pSprite, pXSprite);
} }
@ -101,7 +101,7 @@ static void zombaThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 921 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 921 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -123,7 +123,7 @@ static void zombaThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
@ -175,7 +175,7 @@ static void zombaThinkPonder(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
@ -256,7 +256,7 @@ static void myThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
myThinkTarget(actor); myThinkTarget(actor);
} }

View file

@ -88,7 +88,7 @@ static void zombfThinkSearch(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng); aiChooseDirection(actor,pXSprite->goalAng);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -102,7 +102,7 @@ static void zombfThinkGoto(DBloodActor* actor)
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(actor,nAngle);
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
@ -124,7 +124,7 @@ static void zombfThinkChase(DBloodActor* actor)
XSPRITE *pXTarget = &xsprite[pTarget->extra]; XSPRITE *pXTarget = &xsprite[pTarget->extra];
int dx = pTarget->x-pSprite->x; int dx = pTarget->x-pSprite->x;
int dy = pTarget->y-pSprite->y; int dy = pTarget->y-pSprite->y;
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy)); aiChooseDirection(actor,getangle(dx, dy));
if (pXTarget->health == 0) if (pXTarget->health == 0)
{ {
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);

View file

@ -6514,6 +6514,7 @@ void nnExtAiSetDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3) {
/// patrol functions /// patrol functions
// ------------------------------------------------ // ------------------------------------------------
void aiPatrolState(spritetype* pSprite, int state) { void aiPatrolState(spritetype* pSprite, int state) {
auto actor = &bloodActors[pSprite->index];
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);