- Changed P_SeekerMissile() to compute a proper 3D trajectory.

SVN r2276 (trunk)
This commit is contained in:
Randy Heit 2010-04-07 03:37:07 +00:00
parent d6d2ce6b24
commit f101b45d9a

View file

@ -1546,9 +1546,8 @@ bool AActor::CanSeek(AActor *target) const
bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax)
{ {
int dir; int dir;
int dist;
angle_t delta; angle_t delta;
angle_t angle; angle_t angle, pitch;
AActor *target; AActor *target;
target = actor->tracer; target = actor->tracer;
@ -1578,25 +1577,26 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax)
{ // Turn counter clockwise { // Turn counter clockwise
actor->angle -= delta; actor->angle -= delta;
} }
angle = actor->angle>>ANGLETOFINESHIFT; angle = actor->angle >> ANGLETOFINESHIFT;
actor->velx = FixedMul (actor->Speed, finecosine[angle]); pitch = 0;
actor->vely = FixedMul (actor->Speed, finesine[angle]);
if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{
if (actor->z + actor->height < target->z ||
target->z + target->height < actor->z)
{ // Need to seek vertically { // Need to seek vertically
dist = P_AproxDistance (target->x - actor->x, target->y - actor->y); double dist = MAX(1.0, FVector2(target->x - actor->x, target->y - actor->y).Length());
dist = dist / actor->Speed; // Aim at a player's eyes and at the middle of the actor for everything else.
if (dist < 1) fixed_t aimheight = target->height/2;
if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{ {
dist = 1; aimheight = static_cast<APlayerPawn *>(target)->ViewHeight;
}
actor->velz = ((target->z+target->height/2) - (actor->z+actor->height/2)) / dist;
} }
pitch = R_PointToAngle2(0, actor->z + actor->height/2, xs_CRoundToInt(dist), target->z + aimheight);
pitch >>= ANGLETOFINESHIFT;
} }
fixed_t xyscale = FixedMul(actor->Speed, finecosine[pitch]);
actor->velz = FixedMul(actor->Speed, finesine[pitch]);
actor->velx = FixedMul(xyscale, finecosine[angle]);
actor->vely = FixedMul(xyscale, finesine[angle]);
return true; return true;
} }