- floatified gillThinkChase

This commit is contained in:
Christoph Oelckers 2022-09-27 22:38:24 +02:00
parent 523400772e
commit edf6c69159

View file

@ -116,9 +116,9 @@ static void gillThinkChase(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type); DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int dx = target->int_pos().X - actor->int_pos().X; auto dv = target->spr.pos.XY() - actor->spr.pos.XY();
int dy = target->int_pos().Y - actor->int_pos().Y; DAngle nAngle = VecToAngle(dv);
aiChooseDirection(actor, VecToAngle(dx, dy)); aiChooseDirection(actor, nAngle);
if (actor->xspr.health == 0) if (actor->xspr.health == 0)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
@ -135,20 +135,20 @@ static void gillThinkChase(DBloodActor* actor)
aiNewState(actor, &gillBeastSearch); aiNewState(actor, &gillBeastSearch);
return; return;
} }
int nDist = approxDist(dx, dy); double nDist = dv.Length();
if (nDist <= pDudeInfo->seeDist) if (nDist <= pDudeInfo->SeeDist())
{ {
int nDeltaAngle = getincangle(actor->int_ang(), getangle(dx, dy)); 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() && nDeltaAngle <= pDudeInfo->Periphery())
{ {
aiSetTarget(actor, actor->GetTarget()); aiSetTarget(actor, actor->GetTarget());
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->int_pos().Z - actor->int_pos().Z, nDist, 10); actor->dudeSlope = nDist == 0 ? 0 : (target->spr.pos.Z - actor->spr.pos.Z) / nDist * 16384;
if (nDist < 921 && abs(nDeltaAngle) < 28) if (nDist < 57.5625 && abs(nDeltaAngle) < DAngle1 * 5)
{ {
int hit = HitScan_(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(actor, actor->spr.pos.Z, DVector3(dv, 0), CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
case -1: case -1: