private boolean startAttack() { NpcInstance actor = getActor(); if (target == null) { List<Creature> around = actor.getAroundCharacters(3000, 150); if (around != null && !around.isEmpty()) { for (Creature obj : around) { if (checkTarget(obj)) { if (target == null || actor.getDistance3D(obj) < actor.getDistance3D(target)) target = obj; } } } } 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))) { target = null; return false; } return false; }