- two more functions in aibeast.cpp.

Note that the eyeHeight adjustment was removed because it was applied incorrectly and essentially non-functional.
eyeHeight is in world coordinates but was used as if it was Q24.8, resulting in a value too small to be significant.
This commit is contained in:
Christoph Oelckers 2022-09-27 10:02:00 +02:00
parent e9fc0d09a9
commit 1255fda4c1

View file

@ -435,12 +435,12 @@ static void sub_62AE0(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
int z = actor->int_pos().Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->int_pos().Z + getDudeInfo(target->spr.type)->eyeHeight;
auto nAng = deltaangle(actor->spr.angle, actor->xspr.goalAng);
auto nTurnRange = pDudeInfo->TurnRange();
actor->spr.angle += clamp(nAng, -nTurnRange, nTurnRange);
double nAccel = pDudeInfo->FrontSpeed() * 4;
if (abs(nAng) > DAngle60)
{
actor->xspr.goalAng += DAngle90;
@ -448,14 +448,15 @@ static void sub_62AE0(DBloodActor* actor)
}
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
double nDist = dvec.Length();
int dz = z2 - z;
if (Chance(0x600) && nDist <= 0x40)
return;
AdjustVelocity(actor, ADJUSTER{
t1 += nAccel;
});
actor->set_int_bvel_z(-dz);
double dz = target->spr.pos.Z - actor->spr.pos.Z;
actor->vel.Z -= dz / 256;
}
static void sub_62D7C(DBloodActor* actor)
@ -464,12 +465,12 @@ static void sub_62D7C(DBloodActor* actor)
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
int z = actor->int_pos().Z + getDudeInfo(actor->spr.type)->eyeHeight;
int z2 = target->int_pos().Z + getDudeInfo(target->spr.type)->eyeHeight;
auto nAng = deltaangle(actor->spr.angle, actor->xspr.goalAng);
auto nTurnRange = pDudeInfo->TurnRange();
actor->spr.angle += clamp(nAng, -nTurnRange, nTurnRange);
double nAccel = pDudeInfo->FrontSpeed() * 4;
if (abs(nAng) > DAngle60)
{
actor->spr.angle += DAngle90;
@ -477,14 +478,15 @@ static void sub_62D7C(DBloodActor* actor)
}
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
double nDist = dvec.Length();
int dz = (z2 - z) << 3;
if (Chance(0x4000) && nDist <= 0x40)
return;
AdjustVelocity(actor, ADJUSTER{
t1 += nAccel * 0.5;
});
actor->set_int_bvel_z(dz);
double dz = target->spr.pos.Z - actor->spr.pos.Z;
actor->vel.Z += dz / 32;
}
END_BLD_NS