mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Changed P_SeekerMissile() to compute a proper 3D trajectory.
SVN r2276 (trunk)
This commit is contained in:
parent
d6d2ce6b24
commit
f101b45d9a
1 changed files with 16 additions and 16 deletions
|
@ -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)))
|
||||||
{
|
{ // Need to seek vertically
|
||||||
if (actor->z + actor->height < target->z ||
|
double dist = MAX(1.0, FVector2(target->x - actor->x, target->y - actor->y).Length());
|
||||||
target->z + target->height < actor->z)
|
// Aim at a player's eyes and at the middle of the actor for everything else.
|
||||||
{ // Need to seek vertically
|
fixed_t aimheight = target->height/2;
|
||||||
dist = P_AproxDistance (target->x - actor->x, target->y - actor->y);
|
if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
|
||||||
dist = dist / actor->Speed;
|
{
|
||||||
if (dist < 1)
|
aimheight = static_cast<APlayerPawn *>(target)->ViewHeight;
|
||||||
{
|
|
||||||
dist = 1;
|
|
||||||
}
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue