mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- eliminated lots of approxDist calls.
Only the really simple ones.
This commit is contained in:
parent
dcfac1c930
commit
105e20a32d
22 changed files with 111 additions and 105 deletions
|
@ -307,8 +307,8 @@ static void batMoveForward(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.X;
|
||||
int nDist = approxDist(dvec);
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x200)
|
||||
double nDist = dvec.Length();
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x20)
|
||||
return;
|
||||
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
|
@ -333,8 +333,8 @@ static void batMoveSwoop(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.X;
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x600) && nDist <= 0x200)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x600) && nDist <= 0x20)
|
||||
return;
|
||||
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
|
@ -357,8 +357,8 @@ static void batMoveFly(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.X;
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x4000) && nDist <= 0x200)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x4000) && nDist <= 0x20)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -399,8 +399,8 @@ static void beastMoveForward(DBloodActor* actor)
|
|||
if (abs(nAng) > DAngle60)
|
||||
return;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (nDist <= 0x400 && Random(64) < 32)
|
||||
double nDist = dvec.Length();
|
||||
if (nDist <= 0x40 && Random(64) < 32)
|
||||
return;
|
||||
actor->vel.XY() += actor->spr.angle.ToVector() * pDudeInfo->FrontSpeed();
|
||||
}
|
||||
|
@ -418,8 +418,8 @@ static void sub_628A0(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -447,9 +447,9 @@ static void sub_62AE0(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = z2 - z;
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel;
|
||||
|
@ -476,9 +476,9 @@ static void sub_62D7C(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = (z2 - z) << 3;
|
||||
if (Chance(0x4000) && nDist <= 0x400)
|
||||
if (Chance(0x4000) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -112,20 +112,20 @@ static void eelThinkTarget(DBloodActor* actor)
|
|||
auto ppos = pPlayer->actor->spr.pos;
|
||||
auto dvect = ppos.XY() - actor->spr.pos;
|
||||
auto pSector = pPlayer->actor->sector();
|
||||
int nDist = approxDist(dvect);
|
||||
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
|
||||
double nDist = dvect.Length();
|
||||
if (nDist > pDudeInfo->SeeDist() && nDist > pDudeInfo->Heardist())
|
||||
continue;
|
||||
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
|
||||
if (!cansee(ppos, pSector, actor->spr.pos.plusZ(-height), actor->sector()))
|
||||
continue;
|
||||
int nDeltaAngle = getincangle(actor->int_ang(), getangle(dvect));
|
||||
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
DAngle nDeltaAngle = absangle(actor->spr.angle, VecToAngle(dvect));
|
||||
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
|
||||
{
|
||||
pDudeExtraE->thinkTime = 0;
|
||||
aiSetTarget(actor, pPlayer->actor);
|
||||
aiActivateDude(actor);
|
||||
}
|
||||
else if (nDist < pDudeInfo->hearDist)
|
||||
else if (nDist < pDudeInfo->Heardist())
|
||||
{
|
||||
pDudeExtraE->thinkTime = 0;
|
||||
aiSetTarget(actor, ppos);
|
||||
|
@ -316,8 +316,8 @@ static void eelMoveForward(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (nDist <= 0x399)
|
||||
double nDist = dvec.Length();
|
||||
if (nDist <= 57.5625)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -339,8 +339,8 @@ static void eelMoveSwoop(DBloodActor* actor)
|
|||
if (abs(nAng) > DAngle60)
|
||||
return;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x8000) && nDist <= 0x399)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x8000) && nDist <= 57.5625)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
@ -360,8 +360,8 @@ static void eelMoveAscend(DBloodActor* actor)
|
|||
if (abs(nAng) > DAngle60)
|
||||
return;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x4000) && nDist <= 0x399)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x4000) && nDist <= 57.5625)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -86,9 +86,9 @@ static void burnThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
{
|
||||
switch (actor->spr.type)
|
||||
{
|
||||
|
|
|
@ -96,9 +96,9 @@ static void calebThinkGoto(DBloodActor* actor)
|
|||
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
{
|
||||
if (pXSector && pXSector->Underwater)
|
||||
aiNewState(actor, &tinycalebSwimSearch);
|
||||
|
@ -216,9 +216,9 @@ static void calebThinkSwimGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &tinycalebSwimSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
@ -287,8 +287,8 @@ static void sub_65D04(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -318,9 +318,9 @@ static void sub_65F44(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = z2 - z;
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel;
|
||||
|
@ -348,9 +348,9 @@ static void sub_661E0(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = (z2 - z) << 3;
|
||||
if (Chance(0x4000) && nDist <= 0x400)
|
||||
if (Chance(0x4000) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -296,9 +296,9 @@ static void cerberusThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
{
|
||||
switch (actor->spr.type) {
|
||||
case kDudeCerberusTwoHead:
|
||||
|
|
|
@ -196,9 +196,9 @@ static void cultThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 5120 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 320 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
{
|
||||
switch (actor->xspr.medium)
|
||||
{
|
||||
|
|
|
@ -262,9 +262,9 @@ static void gargThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &gargoyleFSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
@ -520,8 +520,8 @@ static void gargMoveForward(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -549,8 +549,8 @@ static void gargMoveSlow(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
@ -584,8 +584,8 @@ static void gargMoveSwoop(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
|
@ -619,8 +619,8 @@ static void gargMoveFly(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x4000) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x4000) && nDist <= 0x40)
|
||||
return;
|
||||
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
|
|
|
@ -241,9 +241,9 @@ static void ghostThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &ghostSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
@ -415,8 +415,8 @@ static void ghostMoveForward(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -443,8 +443,8 @@ static void ghostMoveSlow(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
@ -474,8 +474,8 @@ static void ghostMoveSwoop(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
@ -504,8 +504,8 @@ static void ghostMoveFly(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Chance(0x4000) && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Chance(0x4000) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -87,9 +87,9 @@ static void gillThinkGoto(DBloodActor* actor)
|
|||
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
{
|
||||
if (pXSector && pXSector->Underwater)
|
||||
aiNewState(actor, &gillBeastSwimSearch);
|
||||
|
@ -200,9 +200,9 @@ static void gillThinkSwimGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &gillBeastSwimSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
@ -274,8 +274,8 @@ static void sub_6CB00(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if (Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if (Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
@ -304,9 +304,9 @@ static void sub_6CD74(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = z2 - z;
|
||||
if (Chance(0x600) && nDist <= 0x400)
|
||||
if (Chance(0x600) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel;
|
||||
|
@ -333,9 +333,9 @@ static void sub_6D03C(DBloodActor* actor)
|
|||
return;
|
||||
}
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
int dz = (z2 - z) << 3;
|
||||
if (Chance(0x4000) && nDist <= 0x400)
|
||||
if (Chance(0x4000) && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
t1 += nAccel * 0.5;
|
||||
|
|
|
@ -68,9 +68,9 @@ static void handThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &handSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -83,9 +83,9 @@ static void houndThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &houndSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -52,9 +52,9 @@ static void innocThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &innocentSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -141,9 +141,9 @@ static void aiPodMove(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery) {
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery) {
|
||||
switch (actor->spr.type) {
|
||||
case kDudePodGreen:
|
||||
case kDudePodFire:
|
||||
|
|
|
@ -64,9 +64,9 @@ static void ratThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &ratSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -172,9 +172,9 @@ static void spidThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &spidSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -263,9 +263,9 @@ static void sub_72850(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &tchernobogSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -1122,8 +1122,8 @@ void aiGenDudeMoveForward(DBloodActor* actor)
|
|||
if (actor->GetTarget() == nullptr)
|
||||
actor->spr.angle += DAngle45;
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nDist = approxDist(dvec);
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
|
||||
double nDist = dvec.Length();
|
||||
if ((unsigned int)Random(64) < 32 && nDist <= 0x40)
|
||||
return;
|
||||
AdjustVelocity(actor, ADJUSTER{
|
||||
if (actor->GetTarget() == nullptr)
|
||||
|
|
|
@ -93,9 +93,9 @@ static void zombaThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 921 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 51.3125 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &zombieASearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -92,9 +92,9 @@ static void zombfThinkGoto(DBloodActor* actor)
|
|||
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
||||
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
||||
int nAngle = getangle(dvec);
|
||||
int nDist = approxDist(dvec);
|
||||
double nDist = dvec.Length();
|
||||
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
||||
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
||||
aiNewState(actor, &zombieFSearch);
|
||||
aiThinkTarget(actor);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ struct DUDEINFO {
|
|||
return seeDist * maptoworld;
|
||||
}
|
||||
|
||||
inline double MeleeDist() const
|
||||
{
|
||||
return meleeDist * maptoworld;
|
||||
}
|
||||
|
||||
inline DAngle Periphery() const
|
||||
{
|
||||
return mapangle(periphery);
|
||||
|
|
|
@ -5353,21 +5353,22 @@ bool aiFightIsMeleeUnit(DBloodActor* dude)
|
|||
int aiFightGetTargetDist(DBloodActor* actor, DUDEINFO* pDudeInfo, DBloodActor* target)
|
||||
{
|
||||
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
|
||||
int dist = approxDist(dvec);
|
||||
double dist = dvec.Length();
|
||||
|
||||
if (dist <= pDudeInfo->meleeDist) return 0;
|
||||
if (dist >= pDudeInfo->seeDist) return 13;
|
||||
if (dist <= pDudeInfo->seeDist / 12) return 1;
|
||||
if (dist <= pDudeInfo->seeDist / 11) return 2;
|
||||
if (dist <= pDudeInfo->seeDist / 10) return 3;
|
||||
if (dist <= pDudeInfo->seeDist / 9) return 4;
|
||||
if (dist <= pDudeInfo->seeDist / 8) return 5;
|
||||
if (dist <= pDudeInfo->seeDist / 7) return 6;
|
||||
if (dist <= pDudeInfo->seeDist / 6) return 7;
|
||||
if (dist <= pDudeInfo->seeDist / 5) return 8;
|
||||
if (dist <= pDudeInfo->seeDist / 4) return 9;
|
||||
if (dist <= pDudeInfo->seeDist / 3) return 10;
|
||||
if (dist <= pDudeInfo->seeDist / 2) return 11;
|
||||
if (dist <= pDudeInfo->MeleeDist()) return 0;
|
||||
double seeDist = pDudeInfo->SeeDist();
|
||||
if (dist >= seeDist) return 13;
|
||||
if (dist <= seeDist / 12) return 1;
|
||||
if (dist <= seeDist / 11) return 2;
|
||||
if (dist <= seeDist / 10) return 3;
|
||||
if (dist <= seeDist / 9) return 4;
|
||||
if (dist <= seeDist / 8) return 5;
|
||||
if (dist <= seeDist / 7) return 6;
|
||||
if (dist <= seeDist / 6) return 7;
|
||||
if (dist <= seeDist / 5) return 8;
|
||||
if (dist <= seeDist / 4) return 9;
|
||||
if (dist <= seeDist / 3) return 10;
|
||||
if (dist <= seeDist / 2) return 11;
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue