Permalink
Browse files

Fix 99.9% broken target prediction for direct fire.

Projectile flight time was calculated in seconds, instead of milliseconds.

Also, assume ground unit altitudes will follow the terrain.

Lancers can now hit moving targets, again.
  • Loading branch information...
1 parent 32a687f commit acd0587f829bfdde0dc7aa30dcab5fafe8875d9b @Cyp Cyp committed Dec 17, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/combat.cpp
View
@@ -277,7 +277,7 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
int32_t flightTime;
if (proj_Direct(psStats) || dist <= psStats->minRange)
{
- flightTime = dist / psStats->flightSpeed;
+ flightTime = dist * GAME_TICKS_PER_SEC / psStats->flightSpeed;
}
else
{
@@ -300,6 +300,10 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
}
predict += Vector3i(iSinCosR(psDroid->sMove.moveDir, psDroid->sMove.speed*flightTime / GAME_TICKS_PER_SEC), 0);
+ if (!isFlying(psDroid))
+ {
+ predict.z = map_Height(removeZ(predict)); // Predict that the object will be on the ground.
+ }
}
/* Fire off the bullet to the miss location. The miss is only visible if the player owns the target. (Why? - Per) */

0 comments on commit acd0587

Please sign in to comment.