1
0
forked from 0ad/0ad

Add check to prevent error when ranged attack target is destroyed

This was SVN commit r11428.
This commit is contained in:
Jonathan Waller 2012-04-04 20:03:04 +00:00
parent 6d57808b84
commit 21a39dedfb

View File

@ -225,6 +225,9 @@ Attack.prototype.PerformAttack = function(type, target)
// Find the distance to the target
var selfPosition = Engine.QueryInterface(this.entity, IID_Position).GetPosition();
var cmpTargetPosition = Engine.QueryInterface(target, IID_Position);
if (!cmpTargetPosition)
return;
var targetPosition = Engine.QueryInterface(target, IID_Position).GetPosition();
var horizDistance = Math.sqrt(Math.pow(targetPosition.x - selfPosition.x, 2) + Math.pow(targetPosition.z - selfPosition.z, 2));