- use proper angle math to calculate a delta

This commit is contained in:
Christoph Oelckers 2022-09-09 17:58:11 +02:00
parent 8f94b337ac
commit d2795e2def

View file

@ -791,9 +791,9 @@ loc_flag:
DExhumedActor* t = sPlayerInput[nPlayer].pTarget;
// only autoaim if target is in front of the player.
assert(t->sector());
int angletotarget = VecToAngle(t->int_pos().X - pPlayerActor->int_pos().X, t->int_pos().Y - pPlayerActor->int_pos().Y).Buildang();
int anglediff = (pPlayerActor->int_ang() - angletotarget) & 2047;
if (anglediff < 512 || anglediff > 1536)
DAngle angletotarget = VecToAngle(t->spr.pos - pPlayerActor->spr.pos);
DAngle anglediff = absangle(pPlayerActor->spr.angle, angletotarget);
if (anglediff < DAngle90)
{
target = t;
h = 0;