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