Merge pull request #8938 from abcdefg30/heliheigth

Have flying actors account for terrain height
This commit is contained in:
Pavel Penev
2015-08-17 13:53:39 +03:00
2 changed files with 8 additions and 2 deletions

View File

@@ -37,6 +37,8 @@ namespace OpenRA.Mods.Common.Activities
public static void FlyToward(Actor self, Plane plane, int desiredFacing, WDist desiredAltitude)
{
desiredAltitude = new WDist(plane.CenterPosition.Z) + desiredAltitude - self.World.Map.DistanceAboveTerrain(plane.CenterPosition);
var move = plane.FlyStep(plane.Facing);
var altitude = plane.CenterPosition.Z;
@@ -71,7 +73,8 @@ namespace OpenRA.Mods.Common.Activities
var desiredFacing = Util.GetFacing(d, plane.Facing);
// Don't turn until we've reached the cruise altitude
if (plane.CenterPosition.Z < plane.Info.CruiseAltitude.Length)
var targetAltitude = plane.CenterPosition.Z + plane.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(plane.CenterPosition).Length;
if (plane.CenterPosition.Z < targetAltitude)
desiredFacing = plane.Facing;
FlyToward(self, plane, desiredFacing, plane.Info.CruiseAltitude);

View File

@@ -38,6 +38,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;
@@ -85,7 +87,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;
}