Index: ps/trunk/binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js +++ ps/trunk/binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js @@ -306,8 +306,9 @@ "entities": entities, "x": targetPos.x, "z": targetPos.y, - "queued": true, - "targetClasses": undefined + "targetClasses": undefined, + "allowCapture": false, + "queued": true }); if (attackerTemplate.hero) Index: ps/trunk/binaries/data/mods/public/maps/skirmishes/Gallic Fields (3).js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/skirmishes/Gallic Fields (3).js +++ ps/trunk/binaries/data/mods/public/maps/skirmishes/Gallic Fields (3).js @@ -22,8 +22,9 @@ continue; cmd.type = "attack-walk"; cmd.entities = intruders[origin]; - cmd.queued = true; cmd.targetClasses = { "attack": ["Unit", "Structure"] }; + cmd.allowCapture = false; + cmd.queued = true; ProcessCommand(0, cmd); } Index: ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js @@ -748,8 +748,8 @@ return this; }, - "attackMove": function(x, z, targetClasses, queued = false) { - Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": [this.id()], "x": x, "z": z, "targetClasses": targetClasses, "queued": queued }); + "attackMove": function(x, z, targetClasses, allowCapture = true, queued = false) { + Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": [this.id()], "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "queued": queued }); return this; }, Index: ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entitycollection.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entitycollection.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entitycollection.js @@ -146,30 +146,28 @@ return this._entities.size !== 0; }; -m.EntityCollection.prototype.move = function(x, z, queued) +m.EntityCollection.prototype.move = function(x, z, queued = false) { - queued = queued || false; Engine.PostCommand(PlayerID,{"type": "walk", "entities": this.toIdArray(), "x": x, "z": z, "queued": queued}); return this; }; -m.EntityCollection.prototype.moveToRange = function(x, z, min, max, queued) +m.EntityCollection.prototype.moveToRange = function(x, z, min, max, queued = false) { - queued = queued || false; - Engine.PostCommand(PlayerID,{"type": "walk-to-range", "entities": this.toIdArray(), "x": x, "z": z, "min": min, "max": max, "queued": queued }); + Engine.PostCommand(PlayerID,{"type": "walk-to-range", "entities": this.toIdArray(), "x": x, "z": z, + "min": min, "max": max, "queued": queued }); return this; }; -m.EntityCollection.prototype.attackMove = function(x, z, targetClasses, queued) +m.EntityCollection.prototype.attackMove = function(x, z, targetClasses, allowCapture = true, queued = false) { - queued = queued || false; - Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": this.toIdArray(), "x": x, "z": z, "targetClasses": targetClasses, "queued": queued}); + Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": this.toIdArray(), "x": x, "z": z, + "targetClasses": targetClasses, "allowCapture": allowCapture, "queued": queued}); return this; }; -m.EntityCollection.prototype.moveIndiv = function(x, z, queued) +m.EntityCollection.prototype.moveIndiv = function(x, z, queued = false) { - queued = queued || false; for (let id of this._entities.keys()) Engine.PostCommand(PlayerID,{"type": "walk", "entities": [id], "x": x, "z": z, "queued": queued}); return this; Index: ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js +++ ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js @@ -1111,6 +1111,7 @@ { this.patrolStartPosOrder = cmpPosition.GetPosition(); this.patrolStartPosOrder.targetClasses = this.order.data.targetClasses; + this.patrolStartPosOrder.allowCapture = this.order.data.allowCapture; } this.StartTimer(0, 1000); @@ -1638,6 +1639,7 @@ { this.patrolStartPosOrder = cmpPosition.GetPosition(); this.patrolStartPosOrder.targetClasses = this.order.data.targetClasses; + this.patrolStartPosOrder.allowCapture = this.order.data.allowCapture; } this.StartTimer(0, 1000); @@ -1655,7 +1657,7 @@ "MoveCompleted": function() { if (this.orderQueue.length == 1) - this.PushOrder("Patrol",this.patrolStartPosOrder); + this.PushOrder("Patrol", this.patrolStartPosOrder); this.PushOrder(this.order.type, this.order.data); this.FinishOrder(); @@ -5070,12 +5072,12 @@ * to a player order, and so is forced. * If targetClasses is given, only entities matching the targetClasses can be attacked. */ -UnitAI.prototype.WalkAndFight = function(x, z, targetClasses, queued) +UnitAI.prototype.WalkAndFight = function(x, z, targetClasses, allowCapture = true, queued = false) { - this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "force": true }, queued); + this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued); }; -UnitAI.prototype.Patrol = function(x, z, targetClasses, queued) +UnitAI.prototype.Patrol = function(x, z, targetClasses, allowCapture = true, queued = false) { if (!this.CanPatrol()) { @@ -5083,7 +5085,7 @@ return; } - this.AddOrder("Patrol", { "x": x, "z": z, "targetClasses": targetClasses, "force": true }, queued); + this.AddOrder("Patrol", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued); }; /** @@ -5104,7 +5106,7 @@ /** * Adds attack order to the queue, forced by the player. */ -UnitAI.prototype.Attack = function(target, queued, allowCapture) +UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false) { if (!this.CanAttack(target)) { @@ -5541,7 +5543,7 @@ if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ]) continue; } - this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": true }); + this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": this.order.data.allowCapture }); return true; } } @@ -5567,7 +5569,7 @@ if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ]) continue; } - this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": true }); + this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": this.order.data.allowCapture }); return true; } Index: ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js +++ ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js @@ -165,8 +165,10 @@ "attack-walk": function(player, cmd, data) { + let allowCapture = cmd.allowCapture || cmd.allowCapture == null; + GetFormationUnitAIs(data.entities, player).forEach(cmpUnitAI => { - cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.targetClasses, cmd.queued); + cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.targetClasses, allowCapture, cmd.queued); }); }, @@ -179,14 +181,16 @@ warn("Invalid command: attack target is not owned by enemy of player "+player+": "+uneval(cmd)); GetFormationUnitAIs(data.entities, player).forEach(cmpUnitAI => { - cmpUnitAI.Attack(cmd.target, cmd.queued, allowCapture); + cmpUnitAI.Attack(cmd.target, allowCapture, cmd.queued); }); }, "patrol": function(player, cmd, data) { + let allowCapture = cmd.allowCapture || cmd.allowCapture == null; + GetFormationUnitAIs(data.entities, player).forEach(cmpUnitAI => - cmpUnitAI.Patrol(cmd.x, cmd.z, cmd.targetClasses, cmd.queued) + cmpUnitAI.Patrol(cmd.x, cmd.z, cmd.targetClasses, allowCapture, cmd.queued) ); },