- floatified tchernobogThinkChase

This commit is contained in:
Christoph Oelckers 2022-09-27 22:23:09 +02:00
parent 0385897be4
commit 6b72414038
2 changed files with 17 additions and 17 deletions

View file

@ -83,9 +83,9 @@ static void ratThinkChase(DBloodActor* actor)
auto target = actor->GetTarget(); auto target = actor->GetTarget();
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY(); auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec); DAngle nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec); double nDist = dvec.Length();
aiChooseDirection(actor, DAngle::fromBuild(nAngle)); aiChooseDirection(actor, nAngle);
if (target->xspr.health == 0) if (target->xspr.health == 0)
{ {
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
@ -97,9 +97,9 @@ static void ratThinkChase(DBloodActor* actor)
return; return;
} }
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->SeeDist())
{ {
int nDeltaAngle = getincangle(actor->int_ang(), nAngle); int nDeltaAngle = getincangle(actor->int_ang(), nAngle.Buildang());
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE; double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector())) if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
{ {

View file

@ -32,12 +32,12 @@ BEGIN_BLD_NS
static void sub_72580(DBloodActor*); static void sub_72580(DBloodActor*);
static void sub_725A4(DBloodActor*); static void sub_725A4(DBloodActor*);
static void sub_72850(DBloodActor*); static void sub_72850(DBloodActor*);
static void sub_72934(DBloodActor*); static void tchernobogThinkChase(DBloodActor*);
AISTATE tchernobogIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, sub_725A4, NULL }; AISTATE tchernobogIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, sub_725A4, NULL };
AISTATE tchernobogSearch = { kAiStateSearch, 8, -1, 1800, NULL, aiMoveForward, sub_72580, &tchernobogIdle }; AISTATE tchernobogSearch = { kAiStateSearch, 8, -1, 1800, NULL, aiMoveForward, sub_72580, &tchernobogIdle };
AISTATE tchernobogChase = { kAiStateChase, 8, -1, 0, NULL, aiMoveForward, sub_72934, NULL }; AISTATE tchernobogChase = { kAiStateChase, 8, -1, 0, NULL, aiMoveForward, tchernobogThinkChase, NULL };
AISTATE tchernobogRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tchernobogSearch }; AISTATE tchernobogRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tchernobogSearch };
AISTATE tcherno13A9B8 = { kAiStateMove, 8, -1, 600, NULL, aiMoveForward, sub_72850, &tchernobogIdle }; AISTATE tcherno13A9B8 = { kAiStateMove, 8, -1, 600, NULL, aiMoveForward, sub_72850, &tchernobogIdle };
AISTATE tcherno13A9D4 = { kAiStateMove, 6, dword_279B54, 60, NULL, NULL, NULL, &tchernobogChase }; AISTATE tcherno13A9D4 = { kAiStateMove, 6, dword_279B54, 60, NULL, NULL, NULL, &tchernobogChase };
@ -270,7 +270,7 @@ static void sub_72850(DBloodActor* actor)
aiThinkTarget(actor); aiThinkTarget(actor);
} }
static void sub_72934(DBloodActor* actor) static void tchernobogThinkChase(DBloodActor* actor)
{ {
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
{ {
@ -286,9 +286,9 @@ static void sub_72934(DBloodActor* actor)
auto target = actor->GetTarget(); auto target = actor->GetTarget();
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY(); auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
int nAngle = getangle(dvec); DAngle nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec); double nDist = dvec.Length();
aiChooseDirection(actor, DAngle::fromBuild(nAngle)); aiChooseDirection(actor, nAngle);
if (target->xspr.health == 0) if (target->xspr.health == 0)
{ {
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
@ -300,20 +300,20 @@ static void sub_72934(DBloodActor* actor)
return; return;
} }
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->SeeDist())
{ {
int nDeltaAngle = getincangle(actor->int_ang(), nAngle); DAngle nDeltaAngle = absangle(actor->spr.angle, nAngle);
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE; double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector())) 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() && abs(nDeltaAngle) <= pDudeInfo->Periphery())
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
if (nDist < 0x1f00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) if (nDist < 0x1f0 && nDist > 0xd0 && nDeltaAngle < DAngle15)
aiNewState(actor, &tcherno13AA0C); aiNewState(actor, &tcherno13AA0C);
else if (nDist < 0xd00 && nDist > 0xb00 && abs(nDeltaAngle) < 85) else if (nDist < 0xd0 && nDist > 0xb0 && nDeltaAngle < DAngle15)
aiNewState(actor, &tcherno13A9D4); aiNewState(actor, &tcherno13A9D4);
else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) else if (nDist < 0xb0 && nDist > 0x50 && nDeltaAngle < DAngle15)
aiNewState(actor, &tcherno13A9F0); aiNewState(actor, &tcherno13A9F0);
return; return;
} }