return startAttack();
}
private boolean startAttack()
{
NpcInstance actor = getActor();
if(target == null)
{
List<NpcInstance> around = actor.getAroundNpc(3000, 150);
if(around != null && !around.isEmpty())
{
for(NpcInstance npc : around)
{
if(checkTarget(npc))
{
if(target == null || actor.getDistance3D(npc) < actor.getDistance3D(target))
target = npc;
}
}
}
}
if(target != null && !actor.isAttackingNow() && !actor.isCastingNow() && !target.isDead() && GeoEngine.canSeeTarget(actor, target, false) && target.isVisible())
{
actor.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
return true;
}
if(target != null && (!target.isVisible() || target.isDead() || !GeoEngine.canSeeTarget(actor, target, false)))
{