Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -266,7 +266,6 @@ }, "Order.Stop": function(msg) { - this.StopMoving(); this.FinishOrder(); if (this.IsAnimal()) @@ -736,7 +735,6 @@ cmpFormation.ResetOrderVariant(); if (!this.IsAttackingAsFormation()) this.CallMemberFunction("Stop", [false]); - this.StopMoving(); this.FinishOrder(); // Don't move the members back into formation, // as the formation then resets and it looks odd when walk-stopping. @@ -1421,10 +1419,13 @@ return false; }, + "leave": function() { + this.StopMoving(); + }, + "MovementUpdate": function() { if (!this.CheckRange(this.order.data)) return; - this.StopMoving(); this.FinishOrder(); }, }, @@ -1744,7 +1745,6 @@ "GUARD": { "RemoveGuard": function() { - this.StopMoving(); this.FinishOrder(); }, @@ -1793,7 +1793,6 @@ "GUARDING": { "enter": function() { - this.StopMoving(); this.StartTimer(1000, 1000); this.SetHeldPositionOnEntity(this.entity); this.SetAnimationVariant("combat"); @@ -1928,7 +1927,6 @@ "Timer": function(msg) { if (this.ShouldAbandonChase(this.order.data.target, this.order.data.force, IID_Attack, this.order.data.attackType)) { - this.StopMoving(); this.FinishOrder(); if (this.GetStance().respondHoldGround) @@ -2009,8 +2007,6 @@ return true; } - this.StopMoving(); - let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); this.attackTimers = cmpAttack.GetTimers(this.order.data.attackType); @@ -2184,7 +2180,6 @@ "Order.MoveToChasingPoint": function(msg) { if (this.CheckPointRangeExplicit(msg.data.x, msg.data.z, 0, msg.data.max)) { - this.StopMoving(); this.FinishOrder(); return; } @@ -2220,7 +2215,6 @@ "Timer": function(msg) { if (this.ShouldAbandonChase(this.order.data.target, this.order.data.force, IID_Attack, this.order.data.attackType)) { - this.StopMoving(); this.FinishOrder(); if (this.GetStance().respondHoldGround) @@ -2439,7 +2433,6 @@ // off to a different target.) if (this.CheckTargetRange(this.gatheringTarget, IID_ResourceGatherer)) { - this.StopMoving(); this.SetDefaultAnimationVariant(); this.FaceTowardsTarget(this.order.data.target); this.SelectAnimation("gather_" + this.order.data.type.specific); @@ -2924,8 +2917,6 @@ return true; } - this.StopMoving(); - let cmpBuilderList = QueryBuilderListInterface(this.repairTarget); if (cmpBuilderList) cmpBuilderList.AddBuilder(this.entity); @@ -3210,9 +3201,7 @@ "PACKING": { "enter": function() { - this.StopMoving(); - - var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); + let cmpPack = Engine.QueryInterface(this.entity, IID_Pack); cmpPack.Pack(); return false; }, @@ -3233,9 +3222,7 @@ "UNPACKING": { "enter": function() { - this.StopMoving(); - - var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); + let cmpPack = Engine.QueryInterface(this.entity, IID_Pack); cmpPack.Unpack(); return false; }, @@ -3275,15 +3262,13 @@ }, "PickupCanceled": function() { - this.StopMoving(); this.FinishOrder(); }, }, "LOADING": { "enter": function() { - this.StopMoving(); - var cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); + let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); if (!cmpGarrisonHolder || cmpGarrisonHolder.IsFull()) { this.FinishOrder(); @@ -3380,7 +3365,6 @@ "FEEDING": { "enter": function() { this.SelectAnimation("feeding"); - this.StopMoving(); this.StartTimer(randIntInclusive(+this.template.FeedTimeMin, +this.template.FeedTimeMax)); return false; }, @@ -5789,7 +5773,6 @@ UnitAI.prototype.StopTrading = function() { - this.StopMoving(); this.FinishOrder(); var cmpTrader = Engine.QueryInterface(this.entity, IID_Trader); cmpTrader.StopTrading(); @@ -5873,7 +5856,7 @@ // Stop moving if switching to stand ground // TODO: Also stop existing orders in a sensible way if (stance == "standground") - this.StopMoving(); + this.Stop(); // Reset the range queries, since the range depends on stance. this.SetupRangeQueries();