Index: binaries/data/mods/public/simulation/components/UnitMotionFlying.js
===================================================================
--- binaries/data/mods/public/simulation/components/UnitMotionFlying.js
+++ binaries/data/mods/public/simulation/components/UnitMotionFlying.js
@@ -10,6 +10,11 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
"" +
"" +
"" +
@@ -73,6 +78,7 @@
var ground = Math.max(cmpTerrain.GetGroundLevel(pos.x, pos.z), cmpWaterManager.GetWaterLevel(pos.x, pos.z));
var newangle = angle;
var canTurn = true;
+ var distanceToTargetSquared = Math.euclidDistance2DSquared(pos.x, pos.z, this.targetX, this.targetZ);
if (this.landing)
{
if (this.speed > 0 && this.onGround)
@@ -156,6 +162,13 @@
}
else
{
+ if (this.template.StationaryDistance && distanceToTargetSquared <= +this.template.StationaryDistance * +this.template.StationaryDistance)
+ {
+ cmpPosition.SetXZRotation(0, 0);
+ cmpPosition.TurnTo(Math.atan2(this.targetX - pos.x, this.targetZ - pos.z));
+ return;
+ }
+
// If we haven't reached max speed yet then we're still on the ground;
// otherwise we're taking off or flying
// this.onGround in case of a go-around after landing (but not fully stopped)
@@ -199,8 +212,7 @@
// If we're in range of the target then tell people that we've reached it
// (TODO: quantisation breaks this)
- var distFromTarget = Math.euclidDistance2D(pos.x, pos.z, this.targetX, this.targetZ);
- if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
+ if (!this.reachedTarget && this.targetMinRange * this.targetMinRange <= distanceToTargetSquared && distanceToTargetSquared <= this.targetMaxRange * this.targetMaxRange)
{
this.reachedTarget = true;
Engine.PostMessage(this.entity, MT_MotionUpdate, { "updateString": "likelySuccess" });
@@ -210,7 +222,7 @@
// then carry on going straight so we overshoot in a straight line
var isBehindTarget = ((this.targetX - pos.x) * Math.sin(angle) + (this.targetZ - pos.z) * Math.cos(angle) < 0);
// Overshoot the target: carry on straight
- if (isBehindTarget && distFromTarget < this.template.MaxSpeed * this.template.OvershootTime)
+ if (isBehindTarget && distanceToTargetSquared < this.template.MaxSpeed * this.template.MaxSpeed * this.template.OvershootTime * this.template.OvershootTime)
canTurn = false;
if (canTurn)
Index: binaries/data/mods/public/simulation/templates/units/plane.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/units/plane.xml
+++ binaries/data/mods/public/simulation/templates/units/plane.xml
@@ -67,6 +67,7 @@
5.0
10.0
2.0
+ 10.0
2.0
50.0
15.0