Don't add units to selection if the selected unit isn't owned by the player. Fixes #1256, based on patch by mk12.
Update AI API to Health changes. This was SVN commit r11608.
This commit is contained in:
parent
03f04e54fc
commit
b9695db52c
@ -258,17 +258,28 @@ EntitySelection.prototype.checkRenamedEntities = function()
|
||||
|
||||
EntitySelection.prototype.addList = function(ents)
|
||||
{
|
||||
var selectionSize = this.toList().length;
|
||||
var selection = this.toList();
|
||||
var playerID = Engine.GetPlayerID();
|
||||
|
||||
// If someone else's player is the sole selected unit, don't allow adding to the selection
|
||||
if (!g_DevSettings.controlAll && selection.length == 1)
|
||||
{
|
||||
var firstEntState = GetEntityState(selection[0]);
|
||||
if (firstEntState && firstEntState.player != playerID)
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow selecting things not belong to this player (enemy, ally, gaia)
|
||||
var allowUnownedSelect = g_DevSettings.controlAll || (ents.length == 1 && selection.length == 0);
|
||||
|
||||
var i = 1;
|
||||
var added = [];
|
||||
var playerID = Engine.GetPlayerID();
|
||||
var allowEnemySelections = g_DevSettings.controlAll || (ents.length == 1 && selectionSize == 0);
|
||||
|
||||
for each (var ent in ents)
|
||||
{
|
||||
// Only add entities we own to our selection
|
||||
var entState = GetEntityState(ent);
|
||||
if (!this.selected[ent] && (selectionSize + i) <= MAX_SELECTION_SIZE && (allowEnemySelections || (entState && entState.player == playerID)))
|
||||
if (!this.selected[ent] && (selection.length + i) <= MAX_SELECTION_SIZE && (allowUnownedSelect || (entState && entState.player == playerID)))
|
||||
{
|
||||
added.push(ent);
|
||||
this.selected[ent] = ent;
|
||||
|
@ -60,7 +60,7 @@ var EntityTemplate = Class({
|
||||
},
|
||||
|
||||
maxHitpoints: function() { return this._template.Health.Max; },
|
||||
isHealable: function() { return this._template.Health.Healable === "true"; },
|
||||
isHealable: function() { return this._template.Health.Unhealable !== "true"; },
|
||||
isRepairable: function() { return this._template.Health.Repairable === "true"; },
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ var EntityTemplate = Class({
|
||||
},
|
||||
|
||||
maxHitpoints: function() { return this._template.Health.Max; },
|
||||
isHealable: function() { return this._template.Health.Healable === "true"; },
|
||||
isHealable: function() { return this._template.Health.Unhealable !== "true"; },
|
||||
isRepairable: function() { return this._template.Health.Repairable === "true"; },
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user