mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 07:31:03 +00:00
- Blood: cleaned up various angle and distance checks in AI code
This commit is contained in:
parent
e6cfb165f8
commit
8d1938b363
5 changed files with 25 additions and 25 deletions
|
@ -137,9 +137,9 @@ static void batThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.X;
|
||||
auto nAngle = VecToAngle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, nAngle);
|
||||
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
if (nDist < 32 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
aiNewState(actor, &batSearch);
|
||||
batThinkTarget(actor);
|
||||
}
|
||||
|
@ -257,9 +257,9 @@ static void batThinkChase(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
double nDist = dvec.Length();
|
||||
if (nDist <= (pDudeInfo->seeDist * inttoworld))
|
||||
if (nDist <= pDudeInfo->SeeDist())
|
||||
{
|
||||
DAngle nDeltaAngle = deltaangle(actor->spr.angle, dvec.Angle());
|
||||
DAngle nDeltaAngle = absangle(actor->spr.angle, dvec.Angle());
|
||||
double height = pDudeInfo->eyeHeight * actor->spr.yrepeat * REPEAT_SCALE;
|
||||
// Should be dudeInfo[pTarget->spr.type-kDudeBase]
|
||||
double height2 = pDudeInfo->eyeHeight * pTarget->spr.yrepeat * REPEAT_SCALE;
|
||||
|
@ -267,13 +267,13 @@ static void batThinkChase(DBloodActor* actor)
|
|||
GetActorExtents(actor, &top, &bottom);
|
||||
if (cansee(pTarget->spr.pos, pTarget->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
||||
{
|
||||
if (nDist < (pDudeInfo->seeDist * inttoworld) && abs(nDeltaAngle).Buildang() <= pDudeInfo->periphery)
|
||||
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
|
||||
{
|
||||
aiSetTarget(actor, actor->GetTarget());
|
||||
double floorZ = getflorzofslopeptr(actor->sector(), actor->spr.pos);
|
||||
double floorDelta = floorZ - bottom;
|
||||
double heightDelta = height2 - height;
|
||||
bool angWithinRange = abs(nDeltaAngle) < mapangle(85);
|
||||
bool angWithinRange = nDeltaAngle < mapangle(85);
|
||||
if (heightDelta < 32 && nDist < 0x20 && angWithinRange)
|
||||
aiNewState(actor, &batBite);
|
||||
else if ((heightDelta > 80 || floorDelta > 80) && nDist < 0x140 && nDist > 0x80 && angWithinRange)
|
||||
|
|
|
@ -176,9 +176,9 @@ static void beastThinkGoto(DBloodActor* actor)
|
|||
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
auto nAngle = VecToAngle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, nAngle);
|
||||
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
if (nDist < 32 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
{
|
||||
if (pXSector && pXSector->Underwater)
|
||||
aiNewState(actor, &beastSwimSearch);
|
||||
|
@ -326,9 +326,9 @@ static void beastThinkSwimGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
auto nAngle = VecToAngle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, nAngle);
|
||||
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
if (nDist < 32 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
aiNewState(actor, &beastSwimSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
|
|||
|
||||
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
|
||||
DAngle nAngle = VecToAngle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
|
||||
aiChooseDirection(actor, nAngle);
|
||||
if (target->xspr.health == 0)
|
||||
|
@ -361,18 +361,18 @@ static void beastThinkSwimChase(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
|
||||
if (nDist <= pDudeInfo->seeDist)
|
||||
if (nDist <= pDudeInfo->SeeDist())
|
||||
{
|
||||
int nDeltaAngle = getincangle(actor->int_ang(), nAngle.Buildang());
|
||||
DAngle nDeltaAngle = absangle(actor->spr.angle, nAngle);
|
||||
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
|
||||
int top, bottom;
|
||||
GetActorExtents(actor, &top, &bottom);
|
||||
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
||||
{
|
||||
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
|
||||
{
|
||||
aiSetTarget(actor, actor->GetTarget());
|
||||
if (nDist < 0x400 && abs(nDeltaAngle) < 85)
|
||||
if (nDist < 64 && nDeltaAngle < mapangle(85))
|
||||
aiNewState(actor, &beastSwimSlash);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -150,9 +150,9 @@ static void eelThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
auto nAngle = VecToAngle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, nAngle);
|
||||
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
if (nDist < 32 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
||||
aiNewState(actor, &eelSearch);
|
||||
eelThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -340,9 +340,9 @@ static void gargThinkChase(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
double nDist = dxy.Length();
|
||||
if (nDist <= (pDudeInfo->seeDist * inttoworld))
|
||||
if (nDist <= pDudeInfo->SeeDist())
|
||||
{
|
||||
DAngle nDeltaAngle = deltaangle(actor->spr.angle, dxyAngle);
|
||||
DAngle nDeltaAngle = absangle(actor->spr.angle, dxyAngle);
|
||||
double height = pDudeInfo->eyeHeight * actor->spr.yrepeat * REPEAT_SCALE;
|
||||
// Should be dudeInfo[target->spr.type-kDudeBase]
|
||||
double height2 = pDudeInfo->eyeHeight * target->spr.yrepeat * REPEAT_SCALE;
|
||||
|
@ -350,13 +350,13 @@ static void gargThinkChase(DBloodActor* actor)
|
|||
GetActorExtents(actor, &top, &bottom);
|
||||
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
||||
{
|
||||
if (nDist < (pDudeInfo->seeDist * inttoworld) && abs(nDeltaAngle).Buildang() <= pDudeInfo->periphery)
|
||||
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
|
||||
{
|
||||
aiSetTarget(actor, actor->GetTarget());
|
||||
double floorZ = getflorzofslopeptr(actor->sector(), actor->spr.pos);
|
||||
double floorDelta = floorZ - bottom;
|
||||
double heightDelta = height2 - height;
|
||||
bool angWithinRange = abs(nDeltaAngle) < mapangle(85);
|
||||
bool angWithinRange = nDeltaAngle < mapangle(85);
|
||||
switch (actor->spr.type)
|
||||
{
|
||||
case kDudeGargoyleFlesh:
|
||||
|
|
|
@ -318,9 +318,9 @@ static void ghostThinkChase(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
double nDist = dxy.Length();
|
||||
if (nDist <= (pDudeInfo->seeDist * inttoworld))
|
||||
if (nDist <= pDudeInfo->SeeDist())
|
||||
{
|
||||
DAngle nDeltaAngle = deltaangle(actor->spr.angle, dxyAngle);
|
||||
DAngle nDeltaAngle = absangle(actor->spr.angle, dxyAngle);
|
||||
double height = pDudeInfo->eyeHeight * actor->spr.yrepeat * REPEAT_SCALE;
|
||||
// Should be dudeInfo[target->spr.type-kDudeBase]
|
||||
double height2 = pDudeInfo->eyeHeight * target->spr.yrepeat * REPEAT_SCALE;
|
||||
|
@ -328,13 +328,13 @@ static void ghostThinkChase(DBloodActor* actor)
|
|||
GetActorExtents(actor, &top, &bottom);
|
||||
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
||||
{
|
||||
if (nDist < (pDudeInfo->seeDist * inttoworld) && abs(nDeltaAngle).Buildang() <= pDudeInfo->periphery)
|
||||
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
|
||||
{
|
||||
aiSetTarget(actor, actor->GetTarget());
|
||||
double floorZ = getflorzofslopeptr(actor->sector(), actor->spr.pos);
|
||||
double floorDelta = floorZ - bottom;
|
||||
double heightDelta = height2 - height;
|
||||
bool angWithinRange = abs(nDeltaAngle) < mapangle(85);
|
||||
bool angWithinRange = nDeltaAngle < mapangle(85);
|
||||
switch (actor->spr.type) {
|
||||
case kDudePhantasm:
|
||||
if (nDist < 0x200 && nDist > 0x100 && angWithinRange) {
|
||||
|
|
Loading…
Reference in a new issue