From b466b5d660d42071467bf20da4624884056947e4 Mon Sep 17 00:00:00 2001 From: matjaeck <37185497+matjaeck@users.noreply.github.com> Date: Sat, 2 Feb 2019 19:53:48 +0100 Subject: [PATCH] Reset unit stance on owner change. --- OpenRA.Mods.Common/Traits/AutoTarget.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index 01321ed228..59ea75b303 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class AutoTarget : ConditionalTrait, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyCreated + public class AutoTarget : ConditionalTrait, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyCreated, INotifyOwnerChanged { readonly IEnumerable activeAttackBases; readonly AttackFollow[] attackFollows; @@ -177,6 +177,12 @@ namespace OpenRA.Mods.Common.Traits ApplyStanceCondition(self); } + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + { + PredictedStance = self.Owner.IsBot || !self.Owner.Playable ? Info.InitialStanceAI : Info.InitialStance; + SetStance(self, PredictedStance); + } + void IResolveOrder.ResolveOrder(Actor self, Order order) { if (order.OrderString == "SetUnitStance" && Info.EnableStances)