Index: binaries/data/mods/public/simulation/components/Formation.js =================================================================== --- binaries/data/mods/public/simulation/components/Formation.js +++ binaries/data/mods/public/simulation/components/Formation.js @@ -939,14 +939,24 @@ { this.members[this.members.indexOf(msg.entity)] = msg.newentity; this.memberPositions[msg.newentity] = this.memberPositions[msg.entity]; + + cmpNewUnitAI.SetLastFormationTemplate(Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetCurrentTemplateName(this.entity)); + cmpNewUnitAI.SetFormationController(this.entity); + + for (let ent of this.formationMembersWithAura) + { + let cmpAuras = Engine.QueryInterface(ent, IID_Auras); + if (cmpAuras && cmpAuras.HasFormationAura()) + cmpAuras.ApplyFormationBonus([msg.newentity]); + } } + // TODO: Should check if new/old units were in this.formationMembersWithAura + // (As of a22 the only formation aura is from a hero so this isn't an issue) + var cmpOldUnitAI = Engine.QueryInterface(msg.entity, IID_UnitAI); cmpOldUnitAI.SetFormationController(INVALID_ENTITY); - if (cmpNewUnitAI) - cmpNewUnitAI.SetFormationController(this.entity); - // Because the renamed entity might have different characteristics, // (e.g. packed vs. unpacked siege), we need to recompute motion parameters this.ComputeMotionParameters();