mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- handle all x() calls in AI code.
This commit is contained in:
parent
389933fe3a
commit
723e22743e
18 changed files with 44 additions and 43 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue