- handle all x() calls in AI code.

This commit is contained in:
Christoph Oelckers 2021-12-22 20:48:11 +01:00
parent 389933fe3a
commit 723e22743e
18 changed files with 44 additions and 43 deletions

View file

@ -214,7 +214,7 @@ static void beastThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
@ -222,7 +222,7 @@ static void beastThinkChase(DBloodActor* actor)
auto pSector = actor->spr.sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSearch);
@ -253,7 +253,7 @@ static void beastThinkChase(DBloodActor* actor)
&& target->IsPlayerActor() && Chance(0x8000))
{
int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth / 2)
if (target->xspr.health > (unsigned)gPlayerTemplate[0].startHealth / 2)
{
switch (hit)
{
@ -355,11 +355,11 @@ static void beastThinkSwimChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &beastSwimSearch);
return;

View file

@ -174,11 +174,11 @@ static void eelThinkPonder(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &eelSearch);
return;
@ -277,11 +277,11 @@ static void eelThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &eelSearch);
return;

View file

@ -158,11 +158,11 @@ static void burnThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
switch (actor->spr.type)
{

View file

@ -127,11 +127,11 @@ static void calebThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &tinycalebSwimSearch);
@ -235,11 +235,11 @@ static void calebThinkSwimChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &tinycalebSwimSearch);
return;

View file

@ -343,12 +343,12 @@ static void cerberusThinkChase(DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) {
if (target->xspr.health == 0) {
switch (actor->spr.type) {
case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusSearch);

View file

@ -236,11 +236,11 @@ static void cultThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
switch (pXSprite->medium)
{

View file

@ -347,11 +347,11 @@ static void gargThinkChase(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &gargoyleFSearch);
return;

View file

@ -327,11 +327,11 @@ static void ghostThinkChase(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &ghostSearch);
return;

View file

@ -89,11 +89,11 @@ static void handThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &handSearch);
return;

View file

@ -106,11 +106,11 @@ static void houndThinkChase(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &houndSearch);
return;

View file

@ -74,11 +74,11 @@ static void innocThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &innocentSearch);
return;

View file

@ -182,11 +182,11 @@ static void aiPodChase(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0) {
if (target->xspr.health == 0) {
switch (actor->spr.type) {
case kDudePodGreen:

View file

@ -84,11 +84,11 @@ static void ratThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &ratSearch);
return;

View file

@ -194,11 +194,11 @@ static void spidThinkChase(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &spidSearch);
return;

View file

@ -291,11 +291,11 @@ static void sub_72934(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &tchernobogSearch);
return;

View file

@ -478,6 +478,7 @@ static void unicultThinkChase(DBloodActor* actor)
genDudeUpdate(actor);
}
// we need to be very careful here not to screw up the condition for this check!
XSPRITE* pXTarget = !targetactor || !targetactor->IsDudeActor() || !targetactor->hasX() ? nullptr : &targetactor->x();
if (pXTarget == nullptr) // target lost

View file

@ -115,11 +115,11 @@ static void zombaThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &zombieASearch);
return;
@ -165,11 +165,11 @@ static void zombaThinkPonder(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &zombieASearch);
return;

View file

@ -114,11 +114,11 @@ static void zombfThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
XSPRITE* pXTarget = &actor->GetTarget()->x();
int dx = target->spr.pos.X - actor->spr.pos.X;
int dy = target->spr.pos.Y - actor->spr.pos.Y;
aiChooseDirection(actor, getangle(dx, dy));
if (pXTarget->health == 0)
if (target->xspr.health == 0)
{
aiNewState(actor, &zombieFSearch);
return;