// Handles Monster AI in terms influence maps.
// Worthless Bums 2012.


// Returns true iff the source and destination objects are within range of each other.
function objectWithinRange (%srcObjectPosition, %dstObjectPosition, %range)
{//echo("monsterIsInRangeOf()");
	// Calculate distance between the two objects.
	%distance = VectorDist(%srcObjectPosition, %dstObjectPosition);
	
	if (%distance <= %range)
	{
		// Return success;
		return true;
	}
	
	
	return false;
}
// Returns true iff the monster is in range of a squad member.
function isNearSquad (%monster, %range)
{//echo("isNearSquad()");
	if ($leaderPersist)
	{
		%distance = VectorDist(%monster.getPosition(), $playerSquad[0].getPosition());
		if (%distance <= %range)
		{
			 return true;
		}
	}
	if ($scoutPersist)
	{
		%distance = VectorDist(%monster.getPosition(), $playerSquad[1].getPosition());
		if (%distance <= %range)
		{
			 return true;
		}
	}
	if ($grenadierPersist)
	{
		%distance = VectorDist(%monster.getPosition(), $playerSquad[2].getPosition());
		if (%distance <= %range)
		{
			 return true;
		}
	}
	if ($supportPersist)
	{
		%distance = VectorDist(%monster.getPosition(), $playerSquad[3].getPosition());
		if (%distance <= %range)
		{
			 return true;
		}
	}
	
	return false;
}