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 @@ -1829,8 +1829,8 @@ "ATTACKING": { "enter": function() { - var target = this.order.data.target; - var cmpFormation = Engine.QueryInterface(target, IID_Formation); + let target = this.order.data.target; + let cmpFormation = Engine.QueryInterface(target, IID_Formation); // if the target is a formation, save the attacking formation, and pick a member if (cmpFormation) { @@ -1857,25 +1857,25 @@ } } - var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); + let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); this.attackTimers = cmpAttack.GetTimers(this.order.data.attackType); // If the repeat time since the last attack hasn't elapsed, // delay this attack to avoid attacking too fast. - var prepare = this.attackTimers.prepare; + let prepare = this.attackTimers.prepare; if (this.lastAttacked) { - var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); - var repeatLeft = this.lastAttacked + this.attackTimers.repeat - cmpTimer.GetTime(); + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + let repeatLeft = this.lastAttacked + this.attackTimers.repeat - cmpTimer.GetTime(); prepare = Math.max(prepare, repeatLeft); } this.oldAttackType = this.order.data.attackType; // add prefix + no capital first letter for attackType - var animationName = "attack_" + this.order.data.attackType.toLowerCase(); + let animationName = "attack_" + this.order.data.attackType.toLowerCase(); if (this.IsFormationMember()) { - var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); + let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); if (cmpFormation) animationName = cmpFormation.GetFormationAnimation(this.entity, animationName); } @@ -1890,13 +1890,13 @@ this.FaceTowardsTarget(this.order.data.target); - var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); - if (cmpBuildingAI) + let cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); + if (cmpAttack && cmpBuildingAI && (cmpAttack.GetAttackTypes().indexOf("Capture") == -1 || this.order.data.attackType == "Capture") ) cmpBuildingAI.SetUnitAITarget(this.order.data.target); }, "leave": function() { - var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); + let cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); if (cmpBuildingAI) cmpBuildingAI.SetUnitAITarget(0); this.StopTimer(); @@ -1904,13 +1904,13 @@ }, "Timer": function(msg) { - var target = this.order.data.target; - var cmpFormation = Engine.QueryInterface(target, IID_Formation); + let target = this.order.data.target; + let cmpFormation = Engine.QueryInterface(target, IID_Formation); // if the target is a formation, save the attacking formation, and pick a member if (cmpFormation) { - var thisObject = this; - var filter = function(t) { + let thisObject = this; + let filter = function(t) { return thisObject.CanAttack(t); }; this.order.data.formationTarget = target; @@ -1923,7 +1923,7 @@ // If we are hunting, first update the target position of the gather order so we know where will be the killed animal if (this.order.data.hunting && this.orderQueue[1] && this.orderQueue[1].data.lastPos) { - var cmpPosition = Engine.QueryInterface(this.order.data.target, IID_Position); + let cmpPosition = Engine.QueryInterface(this.order.data.target, IID_Position); if (cmpPosition && cmpPosition.IsInWorld()) { // Store the initial position, so that we can find the rest of the herd later @@ -1935,18 +1935,16 @@ } } - var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); this.lastAttacked = cmpTimer.GetTime() - msg.lateness; this.FaceTowardsTarget(target); // BuildingAI has it's own attack-routine - var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); - if (!cmpBuildingAI) - { - let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); + let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); + let cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); + if ( cmpAttack && (this.order.data.attackType == "Capture") ? (cmpAttack.GetAttackTypes().indexOf("Capture") != -1) : !cmpBuildingAI ) cmpAttack.PerformAttack(this.order.data.attackType, target); - } // Check we can still reach the target for the next attack if (this.CheckTargetAttackRange(target, this.order.data.attackType)) @@ -1976,7 +1974,7 @@ } // if we're targetting a formation, find a new member of that formation - var cmpTargetFormation = Engine.QueryInterface(this.order.data.formationTarget || INVALID_ENTITY, IID_Formation); + let cmpTargetFormation = Engine.QueryInterface(this.order.data.formationTarget || INVALID_ENTITY, IID_Formation); // if there is no target, it means previously searching for the target inside the target formation failed, so don't repeat the search if (target && cmpTargetFormation) { Index: binaries/data/mods/public/simulation/templates/template_unit_siege_tower.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_siege_tower.xml +++ binaries/data/mods/public/simulation/templates/template_unit_siege_tower.xml @@ -1,6 +1,11 @@ + + 10 + 8 + 1000 + 0.0 12.0