public bool TryToAttackRanged()
{
CreatureObject killObject = null;
Vector3 myLoc = Script.GetPosition(this.ObjectId);
foreach (CreatureObject enemy in Party.EnemySoftTargets)
{
if (Script.LineOfSightObject(this.ObjectId, enemy.ObjectId) == CLRScriptBase.TRUE)
{
killObject = enemy;
Vector3 loc = Script.GetPosition(enemy.ObjectId);
float diff = ((loc.x - myLoc.x) * (loc.x - myLoc.x)) + ((loc.y - myLoc.y) * (loc.y - myLoc.y));
if (diff < 5.0f)
{
// We appear to be in melee range; probably unwise to shoot.
return false;
}
}
}
if (killObject == null)
{
foreach (CreatureObject enemy in Party.Enemies)
{
if (Script.LineOfSightObject(this.ObjectId, enemy.ObjectId) == CLRScriptBase.TRUE)
{
killObject = enemy;
Vector3 loc = Script.GetPosition(enemy.ObjectId);
float diff = ((loc.x - myLoc.x) * (loc.x - myLoc.x)) + ((loc.y - myLoc.y) * (loc.y - myLoc.y));
if (diff < 5.0f)
{
// We appear to be in melee range; probably unwise to shoot.
return false;
}
}
}
}
// We don't have any enemies who we can shoot without moving.
if (killObject == null)
return false;
else
{
_EquipWeapon(false);
// Looks like we found something to kill and something to kill it with.
_AttackWrapper(killObject);
return true;
}
}