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 @@ -1984,17 +1984,16 @@ this.FaceTowardsTarget(target); - // BuildingAI has it's own attack-routine - let cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); - if (!cmpBuildingAI) - { - let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); - cmpAttack.PerformAttack(this.order.data.attackType, target); - } - - // Check we can still reach the target for the next attack + // Check we can still reach the target if (this.CheckTargetAttackRange(target, this.order.data.attackType)) { + // BuildingAI has it's own attack-routine + let cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); + if (!cmpBuildingAI) + { + let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); + cmpAttack.PerformAttack(this.order.data.attackType, target); + } if (this.resyncAnimation) { this.SetAnimationSync(this.attackTimers.repeat, this.attackTimers.repeat);