give possibility to choose type of targets in moveAttack, fixes #2740
This was SVN commit r15671.
This commit is contained in:
parent
ac9d4f1036
commit
2f1d143dc2
@ -278,6 +278,7 @@ hotkey.session.kill = Delete ; Destroy selected units
|
|||||||
hotkey.session.stop = "H" ; Stop the current action
|
hotkey.session.stop = "H" ; Stop the current action
|
||||||
hotkey.session.attack = "Ctrl+Alt" ; Modifier to force attack instead of another action
|
hotkey.session.attack = "Ctrl+Alt" ; Modifier to force attack instead of another action
|
||||||
hotkey.session.attackmove = Ctrl ; Modifier to attackmove when clicking on a point
|
hotkey.session.attackmove = Ctrl ; Modifier to attackmove when clicking on a point
|
||||||
|
hotkey.session.attackmoveUnit = "Ctrl+Q" ; Modifier to attackmove targeting only units when clicking on a point
|
||||||
hotkey.session.garrison = Ctrl ; Modifier to garrison when clicking on building
|
hotkey.session.garrison = Ctrl ; Modifier to garrison when clicking on building
|
||||||
hotkey.session.autorallypoint = Ctrl ; Modifier to set the rally point on the building itself
|
hotkey.session.autorallypoint = Ctrl ; Modifier to set the rally point on the building itself
|
||||||
hotkey.session.guard = "G" ; Modifier to escort/guard when clicking on unit/building
|
hotkey.session.guard = "G" ; Modifier to escort/guard when clicking on unit/building
|
||||||
|
@ -60,7 +60,12 @@ var unitActions =
|
|||||||
{
|
{
|
||||||
"execute": function(target, action, selection, queued)
|
"execute": function(target, action, selection, queued)
|
||||||
{
|
{
|
||||||
Engine.PostNetworkCommand({"type": "attack-walk", "entities": selection, "x": target.x, "z": target.z, "queued": queued});
|
if (Engine.HotkeyIsPressed("session.attackmoveUnit"))
|
||||||
|
var targetClasses = { "attack": ["Unit"] };
|
||||||
|
else
|
||||||
|
var targetClasses = { "attack": ["Unit", "Structure"] };
|
||||||
|
|
||||||
|
Engine.PostNetworkCommand({"type": "attack-walk", "entities": selection, "x": target.x, "z": target.z, "targetClasses": targetClasses, "queued": queued});
|
||||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_walk", "entity": selection[0] });
|
Engine.GuiInterfaceCall("PlaySound", { "name": "order_walk", "entity": selection[0] });
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -720,9 +720,9 @@ m.Entity = m.Class({
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
attackMove: function(x, z, queued) {
|
attackMove: function(x, z, targetClasses, queued) {
|
||||||
queued = queued || false;
|
queued = queued || false;
|
||||||
Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": [this.id()], "x": x, "z": z, "queued": queued });
|
Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": [this.id()], "x": x, "z": z, "targetClasses": targetClasses, "queued": queued });
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -228,10 +228,10 @@ m.EntityCollection.prototype.move = function(x, z, queued)
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
m.EntityCollection.prototype.attackMove = function(x, z, queued)
|
m.EntityCollection.prototype.attackMove = function(x, z, targetClasses, queued)
|
||||||
{
|
{
|
||||||
queued = queued || false;
|
queued = queued || false;
|
||||||
Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": this.toIdArray(), "x": x, "z": z, "queued": queued});
|
Engine.PostCommand(PlayerID,{"type": "attack-walk", "entities": this.toIdArray(), "x": x, "z": z, "targetClasses": targetClasses, "queued": queued});
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4920,10 +4920,11 @@ UnitAI.prototype.WalkToTarget = function(target, queued)
|
|||||||
/**
|
/**
|
||||||
* Adds walk-and-fight order to queue, this only occurs in response
|
* Adds walk-and-fight order to queue, this only occurs in response
|
||||||
* to a player order, and so is forced.
|
* 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, queued)
|
UnitAI.prototype.WalkAndFight = function(x, z, targetClasses, queued)
|
||||||
{
|
{
|
||||||
this.AddOrder("WalkAndFight", { "x": x, "z": z, "force": true }, queued);
|
this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "force": true }, queued);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5328,29 +5329,41 @@ UnitAI.prototype.FindWalkAndFightTargets = function()
|
|||||||
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
||||||
for each (var ent in cmpFormation.members)
|
for each (var ent in cmpFormation.members)
|
||||||
{
|
{
|
||||||
if (!(cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI)))
|
if (!(cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI)))
|
||||||
continue;
|
continue;
|
||||||
var targets = cmpUnitAI.GetTargetsFromUnit();
|
var targets = cmpUnitAI.GetTargetsFromUnit();
|
||||||
for each (var targ in targets)
|
for (var targ of targets)
|
||||||
{
|
{
|
||||||
if (cmpUnitAI.CanAttack(targ))
|
if (!cmpUnitAI.CanAttack(targ))
|
||||||
{
|
continue;
|
||||||
this.PushOrderFront("Attack", { "target": targ, "force": true });
|
var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|
||||||
return true;
|
if (cmpIdentity && this.order.data.targetClasses.attack
|
||||||
}
|
&& !MatchesClassList(cmpIdentity.GetClassesList(), this.order.data.targetClasses.attack))
|
||||||
|
continue;
|
||||||
|
if (cmpIdentity && this.order.data.targetClasses.avoid
|
||||||
|
&& MatchesClassList(cmpIdentity.GetClassesList(), this.order.data.targetClasses.avoid))
|
||||||
|
continue;
|
||||||
|
this.PushOrderFront("Attack", { "target": targ, "force": true });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var targets = this.GetTargetsFromUnit();
|
var targets = this.GetTargetsFromUnit();
|
||||||
for each (var targ in targets)
|
for (var targ of targets)
|
||||||
{
|
{
|
||||||
if (this.CanAttack(targ))
|
if (!this.CanAttack(targ))
|
||||||
{
|
continue;
|
||||||
this.PushOrderFront("Attack", { "target": targ, "force": true });
|
var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|
||||||
return true;
|
if (cmpIdentity && this.order.data.targetClasses.attack
|
||||||
}
|
&& !MatchesClassList(cmpIdentity.GetClassesList(), this.order.data.targetClasses.attack))
|
||||||
|
continue;
|
||||||
|
if (cmpIdentity && this.order.data.targetClasses.avoid
|
||||||
|
&& MatchesClassList(cmpIdentity.GetClassesList(), this.order.data.targetClasses.avoid))
|
||||||
|
continue;
|
||||||
|
this.PushOrderFront("Attack", { "target": targ, "force": true });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -130,7 +130,7 @@ var commands = {
|
|||||||
"attack-walk": function(player, cmd, data)
|
"attack-walk": function(player, cmd, data)
|
||||||
{
|
{
|
||||||
GetFormationUnitAIs(data.entities, player).forEach(function(cmpUnitAI) {
|
GetFormationUnitAIs(data.entities, player).forEach(function(cmpUnitAI) {
|
||||||
cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.queued);
|
cmpUnitAI.WalkAndFight(cmd.x, cmd.z, cmd.targetClasses, cmd.queued);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user