- more vector stuff in Blood AI

all the same pattern
This commit is contained in:
Christoph Oelckers 2022-08-23 22:29:05 +02:00
parent 67d0e51919
commit ea04f5f800
19 changed files with 114 additions and 158 deletions

View file

@ -174,10 +174,9 @@ static void beastThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{
@ -325,10 +324,9 @@ static void beastThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &beastSwimSearch);
@ -398,9 +396,8 @@ static void beastMoveForward(DBloodActor* actor)
actor->set_int_ang((actor->int_ang() + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047);
if (abs(nAng) > 341)
return;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (nDist <= 0x400 && Random(64) < 32)
return;
actor->vel.X += MulScale(pDudeInfo->frontSpeed, Cos(actor->int_ang()), 30);
@ -419,9 +416,8 @@ static void sub_628A0(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -455,10 +451,9 @@ static void sub_62AE0(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -490,10 +485,9 @@ static void sub_62D7C(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -152,10 +152,9 @@ static void eelThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &eelSearch);
@ -330,9 +329,8 @@ static void eelMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (nDist <= 0x399)
return;
int nCos = Cos(actor->int_ang());
@ -359,9 +357,8 @@ static void eelMoveSwoop(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x8000) && nDist <= 0x399)
return;
int nCos = Cos(actor->int_ang());
@ -386,9 +383,8 @@ static void eelMoveAscend(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x4000) && nDist <= 0x399)
return;
int nCos = Cos(actor->int_ang());

View file

@ -84,10 +84,9 @@ static void burnThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{

View file

@ -94,10 +94,9 @@ static void calebThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{
@ -212,10 +211,9 @@ static void calebThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tinycalebSwimSearch);
@ -284,9 +282,8 @@ static void sub_65D04(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -321,10 +318,9 @@ static void sub_65F44(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -357,10 +353,9 @@ static void sub_661E0(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -298,10 +298,9 @@ static void cerberusThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{

View file

@ -194,10 +194,9 @@ static void cultThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 5120 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{

View file

@ -264,10 +264,9 @@ static void gargThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gargoyleFSearch);
@ -533,9 +532,8 @@ static void gargMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -568,9 +566,8 @@ static void gargMoveSlow(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -609,9 +606,8 @@ static void gargMoveSwoop(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -649,9 +645,8 @@ static void gargMoveFly(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x4000) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -243,10 +243,9 @@ static void ghostThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ghostSearch);
@ -429,9 +428,8 @@ static void ghostMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -464,9 +462,8 @@ static void ghostMoveSlow(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -502,9 +499,8 @@ static void ghostMoveSwoop(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -539,9 +535,8 @@ static void ghostMoveFly(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Chance(0x4000) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -85,10 +85,9 @@ static void gillThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
{
@ -199,10 +198,9 @@ static void gillThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gillBeastSwimSearch);
@ -274,9 +272,8 @@ static void sub_6CB00(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if (Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -310,10 +307,9 @@ static void sub_6CD74(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());
@ -345,10 +341,9 @@ static void sub_6D03C(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -66,10 +66,9 @@ static void handThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &handSearch);

View file

@ -81,10 +81,9 @@ static void houndThinkGoto(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &houndSearch);

View file

@ -50,10 +50,9 @@ static void innocThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &innocentSearch);

View file

@ -139,10 +139,9 @@ static void aiPodMove(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery) {
switch (actor->spr.type) {

View file

@ -62,10 +62,9 @@ static void ratThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ratSearch);

View file

@ -136,10 +136,9 @@ void SpidBirthSeqCallback(int, DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
DBloodActor* spawned = nullptr;
if (target->IsPlayerActor() && pDudeExtraE->birthCounter < 10)
@ -171,10 +170,9 @@ static void spidThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &spidSearch);

View file

@ -265,10 +265,9 @@ static void sub_72850(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tchernobogSearch);

View file

@ -419,14 +419,14 @@ static void unicultThinkGoto(DBloodActor* actor)
return;
}
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
// if reached target, change to search mode
if (approxDist(dx, dy) < 5120 && abs(actor->int_ang() - nAngle) < getDudeInfo(actor->spr.type)->periphery)
if (nDist < 5120 && abs(actor->int_ang() - nAngle) < getDudeInfo(actor->spr.type)->periphery)
{
if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
@ -1122,9 +1122,8 @@ void aiGenDudeMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nDist = approxDist(dvec);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
int nCos = Cos(actor->int_ang());

View file

@ -91,10 +91,9 @@ static void zombaThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 921 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieASearch);

View file

@ -90,10 +90,9 @@ static void zombfThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieFSearch);