Fix some issues with capturing and miraged entities

This was SVN commit r16564.
This commit is contained in:
sanderd17 2015-04-22 09:59:59 +00:00
parent 6c7eb93e1c
commit d08fdf43d7
3 changed files with 11 additions and 7 deletions

View File

@ -238,10 +238,6 @@ Attack.prototype.GetRestrictedClasses = function(type)
Attack.prototype.CanAttack = function(target)
{
var cmpArmour = Engine.QueryInterface(target, IID_DamageReceiver);
if (!cmpArmour)
return false;
var cmpFormation = Engine.QueryInterface(target, IID_Formation);
if (cmpFormation)
return true;

View File

@ -1714,9 +1714,15 @@ GuiInterface.prototype.CanCapture = function(player, data)
if (!cmpAttack)
return false;
var cmpPlayer = QueryOwnerInterface(data.entity);
var cmpCapturable = Engine.QueryInterface(data.target, IID_Capturable);
if (cmpCapturable && cmpCapturable.CanCapture(cmpPlayer.GetPlayerID()) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1)
var owner = QueryOwnerInterface(data.entity).GetPlayerID();
var cmp = Engine.QueryInterface(data.target, IID_Mirage);
if (cmp && !cmp.Capturable())
return false
else if (!cmp)
var cmp = Engine.QueryInterface(data.target, IID_Capturable);
if (cmp && cmp.CanCapture(owner) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1)
return cmpAttack.CanAttack(data.target);
return false;

View File

@ -122,6 +122,8 @@ Mirage.prototype.GetCapturePoints = function()
return this.capturePoints;
};
Mirage.prototype.CanCapture = Capturable.prototype.CanCapture;
// ResourceSupply data
Mirage.prototype.CopyResourceSupply = function(maxAmount, amount, type, isInfinite)