Index: binaries/data/mods/public/simulation/components/GarrisonHolder.js =================================================================== --- binaries/data/mods/public/simulation/components/GarrisonHolder.js +++ binaries/data/mods/public/simulation/components/GarrisonHolder.js @@ -264,6 +264,10 @@ if (cmpProductionQueue) cmpProductionQueue.PauseProduction(); + let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); + if (cmpUnitAI) + cmpUnitAI.SetGarrisoned(true); + let cmpAura = Engine.QueryInterface(entity, IID_Auras); if (cmpAura && cmpAura.HasGarrisonAura()) cmpAura.ApplyGarrisonAura(this.entity); @@ -328,7 +332,10 @@ } if (cmpEntUnitAI) + { cmpEntUnitAI.Ungarrison(); + cmpEntUnitAI.SetGarrisoned(false); + } let cmpEntProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); if (cmpEntProductionQueue) 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 @@ -633,7 +633,6 @@ "Order.Ungarrison": function() { this.FinishOrder(); - this.isGarrisoned = false; }, "Order.Cheering": function(msg) { @@ -2910,8 +2909,6 @@ // Check that garrisoning succeeds if (cmpGarrisonHolder.Garrison(this.entity)) { - this.isGarrisoned = true; - if (this.formationController) { var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); @@ -3307,9 +3304,9 @@ return this.isGarrisoned; }; -UnitAI.prototype.SetGarrisoned = function() +UnitAI.prototype.SetGarrisoned = function(garrisoned) { - this.isGarrisoned = true; + this.isGarrisoned = garrisoned; }; UnitAI.prototype.GetGarrisonHolder = function() @@ -3384,7 +3381,7 @@ { // Switch to a virgin state to let states execute their leave handlers. // except if garrisoned or cheering or (un)packing, in which case we only clear the order queue - if (this.isGarrisoned || this.IsPacking() || this.orderQueue[0] && this.orderQueue[0].type == "Cheering") + if (this.IsGarrisoned() || this.IsPacking() || this.orderQueue[0] && this.orderQueue[0].type == "Cheering") { this.orderQueue.length = Math.min(this.orderQueue.length, 1); Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); @@ -5127,7 +5124,6 @@ */ UnitAI.prototype.Autogarrison = function(target) { - this.isGarrisoned = true; this.PushOrderFront("Garrison", { "target": target }); };