Beispiel #1
0
 /**
  * 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);
     }
   }
 }
Beispiel #2
0
  /**
   * Method thinkActive.
   *
   * @return boolean
   */
  @Override
  protected boolean thinkActive() {
    final NpcInstance actor = getActor();

    if ((actor == null) || actor.isDead()) {
      return true;
    }

    if (_def_think) {
      doTask();
      return true;
    }

    if ((diedTentacle < 3) || (currentPoint > (MOVE_LOC.length - 1))) {
      final List<Creature> list =
          World.getAroundCharacters(
              getActor(), getActor().getAggroRange(), getActor().getAggroRange());

      for (Creature target : list) {
        if ((target != null) && !target.isDead() && Util.contains(ATTACK_IDS, target.getId())) {
          clearTasks();
          actor.setRunning();
          addTaskAttack(target);
          return true;
        }
      }

      if ((currentPoint > (MOVE_LOC.length - 1)) && (currentPoint2 <= (way.length - 1))) {
        if (loc == null) {
          loc =
              new Location(
                  (way[currentPoint2].getX() + Rnd.get(50)) - Rnd.get(50),
                  (way[currentPoint2].getY() + Rnd.get(50)) - Rnd.get(50),
                  (way[currentPoint2].getZ() + Rnd.get(50)) - Rnd.get(50));
        }

        actor.setRunning();
        clearTasks();
        addTaskMove(loc, true);
        doTask();
        return true;
      }

      return false;
    } else if ((diedTentacle >= 3) && (currentPoint <= (MOVE_LOC.length - 1))) {
      if (loc == null) {
        loc =
            new Location(
                (MOVE_LOC[currentPoint].getX() + Rnd.get(50)) - Rnd.get(50),
                (MOVE_LOC[currentPoint].getY() + Rnd.get(50)) - Rnd.get(50),
                (MOVE_LOC[currentPoint].getZ() + Rnd.get(50)) - Rnd.get(50));
      }

      actor.setRunning();
      clearTasks();
      addTaskMove(loc, true);
      doTask();
      return true;
    }

    return false;
  }