Check that leader is not null in mothership attack checks

This commit is contained in:
cim 2014-02-28 20:59:41 +00:00
parent 4b59d85e94
commit 632bec9918

View File

@ -1603,7 +1603,7 @@ PriorityAIController.prototype.conditionMothershipIsAttacking = function()
if (this.ship.group && this.ship.group.leader != this.ship)
{
var leader = this.ship.group.leader;
if (leader.target && this.isFighting(leader) && this.distance(leader.target) < this.scannerRange)
if (leader && leader.target && this.isFighting(leader) && this.distance(leader.target) < this.scannerRange)
{
return true;
}
@ -1617,7 +1617,7 @@ PriorityAIController.prototype.conditionMothershipIsAttackingHostileTarget = fun
if (this.ship.group && this.ship.group.leader != this.ship)
{
var leader = this.ship.group.leader;
if (leader.target && this.isFighting(leader) && this.isAggressive(leader.target) && this.distance(leader.target) < this.scannerRange)
if (leader && leader.target && this.isFighting(leader) && this.isAggressive(leader.target) && this.distance(leader.target) < this.scannerRange)
{
return true;
}
@ -1630,7 +1630,7 @@ PriorityAIController.prototype.conditionMothershipUnderAttack = function()
if (this.ship.group && this.ship.group.leader != this.ship)
{
var leader = this.ship.group.leader;
if (leader.target && leader.target.target == leader && leader.target.hasHostileTarget && this.distance(leader.target) < this.scannerRange)
if (leader && leader.target && leader.target.target == leader && leader.target.hasHostileTarget && this.distance(leader.target) < this.scannerRange)
{
return true;
}