From afd1eaee0dc8bee8ff608a29c0397639c5d5718d Mon Sep 17 00:00:00 2001 From: Freagarach Date: Sat, 6 Mar 2021 06:12:07 +0000 Subject: [PATCH] Allow players to push orders to the front of the queue. Differential revision: D3605 This was SVN commit r25020. --- binaries/data/config/default.cfg | 1 + .../data/mods/public/gui/session/input.js | 10 +- .../mods/public/gui/session/unit_actions.js | 43 +++++--- .../public/simulation/ai/common-api/entity.js | 41 +++---- .../public/simulation/components/UnitAI.js | 102 +++++++++--------- .../public/simulation/helpers/Commands.js | 34 +++--- 6 files changed, 126 insertions(+), 105 deletions(-) diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index cd4f81e051..2d36a1c25c 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -319,6 +319,7 @@ guard = "G" ; Modifier to escort/guard when clicking on unit/bu patrol = "P" ; Modifier to patrol a unit repair = "J" ; Modifier to repair when clicking on building/mechanical unit queue = Shift ; Modifier to queue unit orders instead of replacing +pushorderfront = "" ; Modifier to push unit orders to the front instead of replacing. orderone = Alt ; Modifier to order only one entity in selection. batchtrain = Shift ; Modifier to train units in batches massbarter = Shift ; Modifier to barter bunch of resources diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 556bc0399c..b11d765741 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -1232,8 +1232,14 @@ function handleUnitAction(target, action) let selection = Engine.HotkeyIsPressed("session.orderone") && popOneFromSelection(action) || g_Selection.toList(); // If the session.queue hotkey is down, add the order to the unit's order queue instead - // of running it immediately. - return g_UnitActions[action.type].execute(target, action, selection, Engine.HotkeyIsPressed("session.queue")); + // of running it immediately. If the pushorderfront hotkey is down, execute the order + // immidiately and continue the rest of the queue afterwards. + return g_UnitActions[action.type].execute( + target, + action, + selection, + Engine.HotkeyIsPressed("session.queue"), + Engine.HotkeyIsPressed("session.pushorderfront")); } function getEntityLimitAndCount(playerState, entType) diff --git a/binaries/data/mods/public/gui/session/unit_actions.js b/binaries/data/mods/public/gui/session/unit_actions.js index cb7850a38d..200862918d 100644 --- a/binaries/data/mods/public/gui/session/unit_actions.js +++ b/binaries/data/mods/public/gui/session/unit_actions.js @@ -45,7 +45,7 @@ var g_UnitActions = { "move": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "walk", @@ -53,6 +53,7 @@ var g_UnitActions = "x": target.x, "z": target.z, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getDefault() }); @@ -89,7 +90,7 @@ var g_UnitActions = "attack-move": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { let targetClasses; if (Engine.HotkeyIsPressed("session.attackmoveUnit")) @@ -104,6 +105,7 @@ var g_UnitActions = "z": target.z, "targetClasses": targetClasses, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -141,7 +143,7 @@ var g_UnitActions = "capture": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "attack", @@ -149,6 +151,7 @@ var g_UnitActions = "target": action.target, "allowCapture": true, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -187,13 +190,14 @@ var g_UnitActions = "attack": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "attack", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "allowCapture": false, "formation": g_AutoFormation.getNull() }); @@ -238,7 +242,7 @@ var g_UnitActions = "patrol": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "patrol", @@ -292,13 +296,14 @@ var g_UnitActions = "heal": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "heal", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -357,7 +362,7 @@ var g_UnitActions = "repair": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "repair", @@ -365,6 +370,7 @@ var g_UnitActions = "target": action.target, "autocontinue": true, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -416,13 +422,14 @@ var g_UnitActions = "gather": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "gather", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -467,13 +474,14 @@ var g_UnitActions = "returnresource": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "returnresource", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -525,7 +533,7 @@ var g_UnitActions = "cancel-setup-trade-route": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "cancel-setup-trade-route", @@ -678,13 +686,14 @@ var g_UnitActions = "garrison": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "garrison", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -751,13 +760,14 @@ var g_UnitActions = "guard": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "guard", "entities": selection, "target": action.target, "queued": queued, + "pushFront": pushFront, "formation": g_AutoFormation.getNull() }); @@ -849,13 +859,14 @@ var g_UnitActions = "remove-guard": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "remove-guard", "entities": selection, "target": action.target, - "queued": queued + "queued": queued, + "pushFront": pushFront }); Engine.GuiInterfaceCall("PlaySound", { @@ -890,7 +901,7 @@ var g_UnitActions = "set-rallypoint": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { // if there is a position set in the action then use this so that when setting a // rally point on an entity it is centered on that entity @@ -1098,7 +1109,7 @@ var g_UnitActions = "unset-rallypoint": { - "execute": function(target, action, selection, queued) + "execute": function(target, action, selection, queued, pushFront) { Engine.PostNetworkCommand({ "type": "unset-rallypoint", diff --git a/binaries/data/mods/public/simulation/ai/common-api/entity.js b/binaries/data/mods/public/simulation/ai/common-api/entity.js index 8a59596878..d6d5f6635a 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/entity.js +++ b/binaries/data/mods/public/simulation/ai/common-api/entity.js @@ -807,31 +807,31 @@ m.Entity = m.Class({ return false; }, - "move": function(x, z, queued = false) { - Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued }); + "move": function(x, z, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued, "pushFront": pushFront }); return this; }, - "moveToRange": function(x, z, min, max, queued = false) { - Engine.PostCommand(PlayerID, { "type": "walk-to-range", "entities": [this.id()], "x": x, "z": z, "min": min, "max": max, "queued": queued }); + "moveToRange": function(x, z, min, max, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "walk-to-range", "entities": [this.id()], "x": x, "z": z, "min": min, "max": max, "queued": queued, "pushFront": pushFront }); return this; }, - "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 }); + "attackMove": function(x, z, targetClasses, allowCapture = true, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "attack-walk", "entities": [this.id()], "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "queued": queued, "pushFront": pushFront }); return this; }, // violent, aggressive, defensive, passive, standground - "setStance": function(stance, queued = false) { + "setStance": function(stance, queued = false, pushFront = false) { if (this.getStance() === undefined) return undefined; - Engine.PostCommand(PlayerID, { "type": "stance", "entities": [this.id()], "name": stance, "queued": queued }); + Engine.PostCommand(PlayerID, { "type": "stance", "entities": [this.id()], "name": stance, "queued": queued, "pushFront": pushFront }); return this; }, "stopMoving": function() { - Engine.PostCommand(PlayerID, { "type": "stop", "entities": [this.id()], "queued": false }); + Engine.PostCommand(PlayerID, { "type": "stop", "entities": [this.id()], "queued": false, "pushFront": false }); }, "unload": function(id) { @@ -882,7 +882,7 @@ m.Entity = m.Class({ direction[0] /= norm; direction[1] /= norm; } - Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": this.position()[0] + direction[0]*dist, "z": this.position()[1] + direction[1]*dist, "queued": false }); + Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": this.position()[0] + direction[0]*dist, "z": this.position()[1] + direction[1]*dist, "queued": false, "pushFront": false }); } return this; }, @@ -896,23 +896,23 @@ m.Entity = m.Class({ FleeDirection[0] = 40 * FleeDirection[0]/dist; FleeDirection[1] = 40 * FleeDirection[1]/dist; - Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": this.position()[0] + FleeDirection[0], "z": this.position()[1] + FleeDirection[1], "queued": false }); + Engine.PostCommand(PlayerID, { "type": "walk", "entities": [this.id()], "x": this.position()[0] + FleeDirection[0], "z": this.position()[1] + FleeDirection[1], "queued": false, "pushFront": false }); } return this; }, - "gather": function(target, queued = false) { - Engine.PostCommand(PlayerID, { "type": "gather", "entities": [this.id()], "target": target.id(), "queued": queued }); + "gather": function(target, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "gather", "entities": [this.id()], "target": target.id(), "queued": queued, "pushFront": pushFront }); return this; }, - "repair": function(target, autocontinue = false, queued = false) { - Engine.PostCommand(PlayerID, { "type": "repair", "entities": [this.id()], "target": target.id(), "autocontinue": autocontinue, "queued": queued }); + "repair": function(target, autocontinue = false, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "repair", "entities": [this.id()], "target": target.id(), "autocontinue": autocontinue, "queued": queued, "pushFront": pushFront }); return this; }, - "returnResources": function(target, queued = false) { - Engine.PostCommand(PlayerID, { "type": "returnresource", "entities": [this.id()], "target": target.id(), "queued": queued }); + "returnResources": function(target, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "returnresource", "entities": [this.id()], "target": target.id(), "queued": queued, "pushFront": pushFront }); return this; }, @@ -927,7 +927,7 @@ m.Entity = m.Class({ }, "tradeRoute": function(target, source) { - Engine.PostCommand(PlayerID, { "type": "setup-trade-route", "entities": [this.id()], "target": target.id(), "source": source.id(), "route": undefined, "queued": false }); + Engine.PostCommand(PlayerID, { "type": "setup-trade-route", "entities": [this.id()], "target": target.id(), "source": source.id(), "route": undefined, "queued": false, "pushFront": false }); return this; }, @@ -981,6 +981,7 @@ m.Entity = m.Class({ "autorepair": false, "autocontinue": false, "queued": false, + "pushFront": false, "metadata": metadata // can be undefined }); return this; @@ -1006,8 +1007,8 @@ m.Entity = m.Class({ return this; }, - "guard": function(target, queued = false) { - Engine.PostCommand(PlayerID, { "type": "guard", "entities": [this.id()], "target": target.id(), "queued": queued }); + "guard": function(target, queued = false, pushFront = false) { + Engine.PostCommand(PlayerID, { "type": "guard", "entities": [this.id()], "target": target.id(), "queued": queued, "pushFront": pushFront }); return this; }, diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index f6263d33b3..5c66fcccee 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -5349,12 +5349,14 @@ UnitAI.prototype.ComputeWalkingDistance = function() return distance; }; -UnitAI.prototype.AddOrder = function(type, data, queued) +UnitAI.prototype.AddOrder = function(type, data, queued, pushFront) { if (this.expectedRoute) this.expectedRoute = undefined; - if (queued) + if (pushFront) + this.PushOrderFront(type, data); + else if (queued) this.PushOrder(type, data); else { @@ -5369,7 +5371,7 @@ UnitAI.prototype.AddOrder = function(type, data, queued) /** * Adds guard/escort order to the queue, forced by the player. */ -UnitAI.prototype.Guard = function(target, queued) +UnitAI.prototype.Guard = function(target, queued, pushFront) { if (!this.CanGuard()) { @@ -5388,7 +5390,7 @@ UnitAI.prototype.Guard = function(target, queued) this.RemoveGuard(); } - this.AddOrder("Guard", { "target": target, "force": false }, queued); + this.AddOrder("Guard", { "target": target, "force": false }, queued, pushFront); }; /** @@ -5470,37 +5472,37 @@ UnitAI.prototype.CanPatrol = function() /** * Adds walk order to queue, forced by the player. */ -UnitAI.prototype.Walk = function(x, z, queued) +UnitAI.prototype.Walk = function(x, z, queued, pushFront) { - if (this.expectedRoute && queued) + if (!pushFront && this.expectedRoute && queued) this.expectedRoute.push({ "x": x, "z": z }); else - this.AddOrder("Walk", { "x": x, "z": z, "force": true }, queued); + this.AddOrder("Walk", { "x": x, "z": z, "force": true }, queued, pushFront); }; /** * Adds walk to point range order to queue, forced by the player. */ -UnitAI.prototype.WalkToPointRange = function(x, z, min, max, queued) +UnitAI.prototype.WalkToPointRange = function(x, z, min, max, queued, pushFront) { - this.AddOrder("Walk", { "x": x, "z": z, "min": min, "max": max, "force": true }, queued); + this.AddOrder("Walk", { "x": x, "z": z, "min": min, "max": max, "force": true }, queued, pushFront); }; /** * Adds stop order to queue, forced by the player. */ -UnitAI.prototype.Stop = function(queued) +UnitAI.prototype.Stop = function(queued, pushFront) { - this.AddOrder("Stop", { "force": true }, queued); + this.AddOrder("Stop", { "force": true }, queued, pushFront); }; /** * Adds walk-to-target order to queue, this only occurs in response * to a player order, and so is forced. */ -UnitAI.prototype.WalkToTarget = function(target, queued) +UnitAI.prototype.WalkToTarget = function(target, queued, pushFront) { - this.AddOrder("WalkToTarget", { "target": target, "force": true }, queued); + this.AddOrder("WalkToTarget", { "target": target, "force": true }, queued, pushFront); }; /** @@ -5508,12 +5510,12 @@ UnitAI.prototype.WalkToTarget = function(target, queued) * 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, allowCapture = true, queued = false) +UnitAI.prototype.WalkAndFight = function(x, z, targetClasses, allowCapture = true, queued = false, pushFront = false) { - this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued); + this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued, pushFront); }; -UnitAI.prototype.Patrol = function(x, z, targetClasses, allowCapture = true, queued = false) +UnitAI.prototype.Patrol = function(x, z, targetClasses, allowCapture = true, queued = false, pushFront = false) { if (!this.CanPatrol()) { @@ -5521,7 +5523,7 @@ UnitAI.prototype.Patrol = function(x, z, targetClasses, allowCapture = true, que return; } - this.AddOrder("Patrol", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued); + this.AddOrder("Patrol", { "x": x, "z": z, "targetClasses": targetClasses, "allowCapture": allowCapture, "force": true }, queued, pushFront); }; /** @@ -5551,7 +5553,7 @@ UnitAI.prototype.LeaveFoundation = function(target) /** * Adds attack order to the queue, forced by the player. */ -UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false) +UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false, pushFront = false) { if (!this.CanAttack(target)) { @@ -5560,7 +5562,7 @@ UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false) if (this.IsHealer()) this.MoveToTargetRange(target, IID_Heal); else - this.WalkToTarget(target, queued); + this.WalkToTarget(target, queued, pushFront); return; } @@ -5582,13 +5584,13 @@ UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false) return; } - this.AddOrder("Attack", order, queued); + this.AddOrder("Attack", order, queued, pushFront); }; /** * Adds garrison order to the queue, forced by the player. */ -UnitAI.prototype.Garrison = function(target, queued) +UnitAI.prototype.Garrison = function(target, queued, pushFront) { if (target == this.entity) return; @@ -5597,7 +5599,7 @@ UnitAI.prototype.Garrison = function(target, queued) this.WalkToTarget(target, queued); return; } - this.AddOrder("Garrison", { "target": target, "force": true }, queued); + this.AddOrder("Garrison", { "target": target, "force": true }, queued, pushFront); }; /** @@ -5625,15 +5627,15 @@ UnitAI.prototype.Autogarrison = function(target) * Adds gather order to the queue, forced by the player * until the target is reached */ -UnitAI.prototype.Gather = function(target, queued) +UnitAI.prototype.Gather = function(target, queued, pushFront) { - this.PerformGather(target, queued, true); + this.PerformGather(target, queued, true, pushFront); }; /** * Internal function to abstract the force parameter. */ -UnitAI.prototype.PerformGather = function(target, queued, force) +UnitAI.prototype.PerformGather = function(target, queued, force, pushFront = false) { if (!this.CanGather(target)) { @@ -5678,28 +5680,28 @@ UnitAI.prototype.PerformGather = function(target, queued, force) return; } - this.AddOrder("Gather", order, queued); + this.AddOrder("Gather", order, queued, pushFront); }; /** * Adds gather-near-position order to the queue, not forced, so it can be * interrupted by attacks. */ -UnitAI.prototype.GatherNearPosition = function(x, z, type, template, queued) +UnitAI.prototype.GatherNearPosition = function(x, z, type, template, queued, pushFront) { if (template.indexOf("resource|") != -1) template = template.slice(9); if (this.IsFormationController() || Engine.QueryInterface(this.entity, IID_ResourceGatherer)) - this.AddOrder("GatherNearPosition", { "type": type, "template": template, "x": x, "z": z, "force": false }, queued); + this.AddOrder("GatherNearPosition", { "type": type, "template": template, "x": x, "z": z, "force": false }, queued, pushFront); else - this.AddOrder("Walk", { "x": x, "z": z, "force": false }, queued); + this.AddOrder("Walk", { "x": x, "z": z, "force": false }, queued, pushFront); }; /** * Adds heal order to the queue, forced by the player. */ -UnitAI.prototype.Heal = function(target, queued) +UnitAI.prototype.Heal = function(target, queued, pushFront) { if (!this.CanHeal(target)) { @@ -5715,13 +5717,13 @@ UnitAI.prototype.Heal = function(target, queued) return; } - this.AddOrder("Heal", { "target": target, "force": true }, queued); + this.AddOrder("Heal", { "target": target, "force": true }, queued, pushFront); }; /** * Adds return resource order to the queue, forced by the player. */ -UnitAI.prototype.ReturnResource = function(target, queued) +UnitAI.prototype.ReturnResource = function(target, queued, pushFront) { if (!this.CanReturnResource(target, true)) { @@ -5729,7 +5731,7 @@ UnitAI.prototype.ReturnResource = function(target, queued) return; } - this.AddOrder("ReturnResource", { "target": target, "force": true }, queued); + this.AddOrder("ReturnResource", { "target": target, "force": true }, queued, pushFront); }; /** @@ -5775,7 +5777,7 @@ UnitAI.prototype.CancelSetupTradeRoute = function(target) * The possible route may be given directly as a SetupTradeRoute argument * if coming from a RallyPoint, or through this.expectedRoute if a user command. */ -UnitAI.prototype.SetupTradeRoute = function(target, source, route, queued) +UnitAI.prototype.SetupTradeRoute = function(target, source, route, queued, pushFront) { if (!this.CanTrade(target)) { @@ -5826,14 +5828,14 @@ UnitAI.prototype.SetupTradeRoute = function(target, source, route, queued) cmpFormation.Disband(); } else - this.AddOrder("Trade", data, queued); + this.AddOrder("Trade", data, queued, pushFront); } else { if (this.IsFormationController()) - this.CallMemberFunction("WalkToTarget", [cmpTrader.GetFirstMarket(), queued]); + this.CallMemberFunction("WalkToTarget", [cmpTrader.GetFirstMarket(), queued, pushFront]); else - this.WalkToTarget(cmpTrader.GetFirstMarket(), queued); + this.WalkToTarget(cmpTrader.GetFirstMarket(), queued, pushFront); this.expectedRoute = []; } }; @@ -5921,7 +5923,7 @@ UnitAI.prototype.StopTrading = function() * Adds repair/build order to the queue, forced by the player * until the target is reached */ -UnitAI.prototype.Repair = function(target, autocontinue, queued) +UnitAI.prototype.Repair = function(target, autocontinue, queued, pushFront) { if (!this.CanRepair(target)) { @@ -5938,16 +5940,16 @@ UnitAI.prototype.Repair = function(target, autocontinue, queued) return; } - this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue, "force": true }, queued); + this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue, "force": true }, queued, pushFront); }; /** * Adds flee order to the queue, not forced, so it can be * interrupted by attacks. */ -UnitAI.prototype.Flee = function(target, queued) +UnitAI.prototype.Flee = function(target, queued, pushFront) { - this.AddOrder("Flee", { "target": target, "force": false }, queued); + this.AddOrder("Flee", { "target": target, "force": false }, queued, pushFront); }; UnitAI.prototype.Cheer = function() @@ -5955,30 +5957,30 @@ UnitAI.prototype.Cheer = function() this.PushOrderFront("Cheer", { "force": false }); }; -UnitAI.prototype.Pack = function(queued) +UnitAI.prototype.Pack = function(queued, pushFront) { if (this.CanPack()) - this.AddOrder("Pack", { "force": true }, queued); + this.AddOrder("Pack", { "force": true }, queued, pushFront); }; -UnitAI.prototype.Unpack = function(queued) +UnitAI.prototype.Unpack = function(queued, pushFront) { if (this.CanUnpack()) - this.AddOrder("Unpack", { "force": true }, queued); + this.AddOrder("Unpack", { "force": true }, queued, pushFront); }; -UnitAI.prototype.CancelPack = function(queued) +UnitAI.prototype.CancelPack = function(queued, pushFront) { var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); if (cmpPack && cmpPack.IsPacking() && !cmpPack.IsPacked()) - this.AddOrder("CancelPack", { "force": true }, queued); + this.AddOrder("CancelPack", { "force": true }, queued, pushFront); }; -UnitAI.prototype.CancelUnpack = function(queued) +UnitAI.prototype.CancelUnpack = function(queued, pushFront) { var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); if (cmpPack && cmpPack.IsPacking() && cmpPack.IsPacked()) - this.AddOrder("CancelUnpack", { "force": true }, queued); + this.AddOrder("CancelUnpack", { "force": true }, queued, pushFront); }; UnitAI.prototype.SetStance = function(stance) @@ -6298,7 +6300,7 @@ UnitAI.prototype.WalkToHeldPosition = function() { if (this.heldPosition) { - this.AddOrder("Walk", { "x": this.heldPosition.x, "z": this.heldPosition.z, "force": false }, false); + this.AddOrder("Walk", { "x": this.heldPosition.x, "z": this.heldPosition.z, "force": false }, false, false); return true; } return false; diff --git a/binaries/data/mods/public/simulation/helpers/Commands.js b/binaries/data/mods/public/simulation/helpers/Commands.js index ab42692bd8..e4ce126f54 100644 --- a/binaries/data/mods/public/simulation/helpers/Commands.js +++ b/binaries/data/mods/public/simulation/helpers/Commands.js @@ -158,7 +158,7 @@ var g_Commands = { "walk": function(player, cmd, data) { GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Walk(cmd.x, cmd.z, cmd.queued); + cmpUnitAI.Walk(cmd.x, cmd.z, cmd.queued, cmd.pushFront); }); }, @@ -166,7 +166,7 @@ var g_Commands = { { for (let ent in data.entities) GetFormationUnitAIs([data.entities[ent]], player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Walk(cmd.targetPositions[ent].x, cmd.targetPositions[ent].y, cmd.queued); + cmpUnitAI.Walk(cmd.targetPositions[ent].x, cmd.targetPositions[ent].y, cmd.queued, cmd.pushFront); }); }, @@ -177,7 +177,7 @@ var g_Commands = { { var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); if (cmpUnitAI) - cmpUnitAI.WalkToPointRange(cmd.x, cmd.z, cmd.min, cmd.max, cmd.queued); + cmpUnitAI.WalkToPointRange(cmd.x, cmd.z, cmd.min, cmd.max, cmd.queued, cmd.pushFront); } }, @@ -186,7 +186,7 @@ var g_Commands = { let allowCapture = cmd.allowCapture || cmd.allowCapture == null; GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.targetClasses, allowCapture, cmd.queued); + cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.targetClasses, allowCapture, cmd.queued, cmd.pushFront); }); }, @@ -195,7 +195,7 @@ var g_Commands = { let allowCapture = cmd.allowCapture || cmd.allowCapture == null; for (let ent in data.entities) GetFormationUnitAIs([data.entities[ent]], player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.WalkAndFight(cmd.targetPositions[ent].x, cmd.targetPositions[ent].y, cmd.targetClasses, allowCapture, cmd.queued); + cmpUnitAI.WalkAndFight(cmd.targetPositions[ent].x, cmd.targetPositions[ent].y, cmd.targetClasses, allowCapture, cmd.queued, cmd.pushFront); }); }, @@ -208,7 +208,7 @@ var g_Commands = { warn("Invalid command: attack target is not owned by enemy of player "+player+": "+uneval(cmd)); GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Attack(cmd.target, allowCapture, cmd.queued); + cmpUnitAI.Attack(cmd.target, allowCapture, cmd.queued, cmd.pushFront); }); }, @@ -227,7 +227,7 @@ var g_Commands = { warn("Invalid command: heal target is not owned by player "+player+" or their ally: "+uneval(cmd)); GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Heal(cmd.target, cmd.queued); + cmpUnitAI.Heal(cmd.target, cmd.queued, cmd.pushFront); }); }, @@ -238,7 +238,7 @@ var g_Commands = { warn("Invalid command: repair target is not owned by ally of player "+player+": "+uneval(cmd)); GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Repair(cmd.target, cmd.autocontinue, cmd.queued); + cmpUnitAI.Repair(cmd.target, cmd.autocontinue, cmd.queued, cmd.pushFront); }); }, @@ -248,14 +248,14 @@ var g_Commands = { warn("Invalid command: resource is not owned by gaia or player "+player+": "+uneval(cmd)); GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Gather(cmd.target, cmd.queued); + cmpUnitAI.Gather(cmd.target, cmd.queued, cmd.pushFront); }); }, "gather-near-position": function(player, cmd, data) { GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.GatherNearPosition(cmd.x, cmd.z, cmd.resourceType, cmd.resourceTemplate, cmd.queued); + cmpUnitAI.GatherNearPosition(cmd.x, cmd.z, cmd.resourceType, cmd.resourceTemplate, cmd.queued, cmd.pushFront); }); }, @@ -265,7 +265,7 @@ var g_Commands = { warn("Invalid command: dropsite is not owned by player "+player+": "+uneval(cmd)); GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.ReturnResource(cmd.target, cmd.queued); + cmpUnitAI.ReturnResource(cmd.target, cmd.queued, cmd.pushFront); }); }, @@ -472,7 +472,7 @@ var g_Commands = { } GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Garrison(cmd.target, cmd.queued); + cmpUnitAI.Garrison(cmd.target, cmd.queued, cmd.pushFront); }); }, @@ -486,7 +486,7 @@ var g_Commands = { } GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { - cmpUnitAI.Guard(cmd.target, cmd.queued); + cmpUnitAI.Guard(cmd.target, cmd.queued, cmd.pushFront); }); }, @@ -684,9 +684,9 @@ var g_Commands = { continue; if (cmd.pack) - cmpUnitAI.Pack(cmd.queued); + cmpUnitAI.Pack(cmd.queued, cmd.pushFront); else - cmpUnitAI.Unpack(cmd.queued); + cmpUnitAI.Unpack(cmd.queued, cmd.pushFront); } }, @@ -699,9 +699,9 @@ var g_Commands = { continue; if (cmd.pack) - cmpUnitAI.CancelPack(cmd.queued); + cmpUnitAI.CancelPack(cmd.queued, cmd.pushFront); else - cmpUnitAI.CancelUnpack(cmd.queued); + cmpUnitAI.CancelUnpack(cmd.queued, cmd.pushFront); } },