Have flying actors account for terrain height

This commit is contained in:
abcdefg30
2015-08-04 15:48:03 +02:00
parent d0fb08a48c
commit a94e35163a
2 changed files with 8 additions and 2 deletions

View File

@@ -37,6 +37,8 @@ namespace OpenRA.Mods.Common.Activities
public static bool AdjustAltitude(Actor self, Helicopter helicopter, WDist targetAltitude)
{
targetAltitude = new WDist(helicopter.CenterPosition.Z) + targetAltitude - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition);
var altitude = helicopter.CenterPosition.Z;
if (altitude == targetAltitude.Length)
return false;
@@ -78,7 +80,8 @@ namespace OpenRA.Mods.Common.Activities
// The next move would overshoot, so just set the final position
if (dist.HorizontalLengthSquared < move.HorizontalLengthSquared)
{
helicopter.SetPosition(self, pos + new WVec(0, 0, helicopter.Info.CruiseAltitude.Length - pos.Z));
var targetAltitude = helicopter.CenterPosition.Z + helicopter.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition).Length;
helicopter.SetPosition(self, pos + new WVec(0, 0, targetAltitude - pos.Z));
return NextActivity;
}