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))) { target = null; return false; } return false; }
/** * Method setGeoOpen. * * @param open boolean * @return boolean */ protected boolean setGeoOpen(boolean open) { if (_geoOpen == open) { return false; } _geoOpen = open; if (Config.ALLOW_GEODATA) { if (open) { GeoEngine.removeGeoCollision(this, getGeoIndex()); } else { GeoEngine.applyGeoCollision(this, getGeoIndex()); } } return true; }
/** * Method onEvtAttacked. * * @param attacker Creature * @param damage int */ @Override protected void onEvtAttacked(Creature attacker, int damage) { final NpcInstance actor = getActor(); if (attacker != null) { final Location pos = Location.findPointToStay(actor, 150, 250); if (GeoEngine.canMoveToCoord( attacker.getX(), attacker.getY(), attacker.getZ(), pos.x, pos.y, pos.z, actor.getGeoIndex())) { actor.setRunning(); addTaskMove(pos, false); } } }