Exemple #1
0
  /**
   * Method sendOrderToMinions.
   *
   * @param actor NpcInstance
   */
  private void sendOrderToMinions(NpcInstance actor) {
    if (!actor.isInCombat()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final MinionList ml = actor.getMinionList();

    if ((ml == null) || !ml.hasMinions()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final long now = System.currentTimeMillis();

    if ((_nextOrderTime > now) && (_lastMinionsTargetRef.get() != null)) {
      final Player old_target = _lastMinionsTargetRef.get();

      if ((old_target != null) && !old_target.isAlikeDead()) {
        for (MinionInstance m : ml.getAliveMinions()) {
          if (!m.getAI().getAttackTarget().equals(old_target)) {
            m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, old_target, 10000000);
          }
        }

        return;
      }
    }

    _nextOrderTime = now + 30000;
    final List<Player> pl = World.getAroundPlayers(actor);

    if (pl.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final List<Player> alive = new LazyArrayList<>();

    for (Player p : pl) {
      if (!p.isAlikeDead()) {
        alive.add(p);
      }
    }

    if (alive.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final Player target = alive.get(Rnd.get(alive.size()));
    _lastMinionsTargetRef = target.getRef();
    Functions.npcSay(actor, "You " + target.getName() + "! Attack them!");

    for (MinionInstance m : ml.getAliveMinions()) {
      m.getAggroList().clear();
      m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 10000000);
    }
  }
 /** Method broadcastStatusUpdate. */
 @Override
 public void broadcastStatusUpdate() {
   for (Player player : World.getAroundPlayers(this)) {
     if (player != null) {
       player.sendPacket(new StaticObject(this, player));
     }
   }
 }
 /** Method runImpl. */
 @Override
 public void runImpl() {
   Functions.npcShout(
       CastleMassTeleporterInstance.this,
       NpcString.THE_DEFENDERS_OF_S1_CASTLE_WILL_BE_TELEPORTED_TO_THE_INNER_CASTLE,
       "#" + getCastle().getNpcStringName().getId());
   for (Player p : World.getAroundPlayers(CastleMassTeleporterInstance.this, 200, 50)) {
     p.teleToLocation(Location.findPointToStay(_teleportLoc, 10, 100, p.getGeoIndex()));
   }
   _teleportTask = null;
 }
  /** Method runImpl. */
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();

    if (activeChar == null) {
      return;
    }

    if (activeChar.getNoChannel() != 0) {
      if ((activeChar.getNoChannelRemained() > 0) || (activeChar.getNoChannel() < 0)) {
        activeChar.sendPacket(
            new SystemMessage(
                SystemMessage
                    .CHATTING_IS_CURRENTLY_PROHIBITED_IF_YOU_TRY_TO_CHAT_BEFORE_THE_PROHIBITION_IS_REMOVED_THE_PROHIBITION_TIME_WILL_BECOME_EVEN_LONGER));
        return;
      }

      activeChar.updateNoChannel(0);
    }

    Player targetPlayer = World.getPlayer(_reciever);

    if (targetPlayer == null) {
      activeChar.sendPacket(new SystemMessage(SystemMessage.THAT_PLAYER_IS_NOT_ONLINE));
      return;
    }

    if (targetPlayer.isBlockAll()) {
      activeChar.sendPacket(
          new SystemMessage(SystemMessage.THE_PERSON_IS_IN_A_MESSAGE_REFUSAL_MODE));
      return;
    }

    if (!activeChar.getFriendList().getList().containsKey(targetPlayer.getObjectId())) {
      return;
    }

    Log.LogChat("FRIENDTELL", activeChar.getName(), _reciever, _message);
    L2FriendSay frm = new L2FriendSay(activeChar.getName(), _reciever, _message);
    targetPlayer.sendPacket(frm);
  }
  /**
   * Method useAdminCommand.
   *
   * @param command String
   * @param wordList String[]
   * @param fullString String
   * @param activeChar Player
   * @return boolean
   * @see lineage2.gameserver.handlers.IAdminCommandHandler#useAdminCommand(String, String[],
   *     String, Player)
   */
  @Override
  public boolean useAdminCommand(
      String command, String[] wordList, String fullString, Player activeChar) {
    if (!activeChar.getPlayerAccess().CanKick) {
      return false;
    }

    switch (command) {
      case "admin_disconnect":
      case "admin_kick":
        final Player player;

        if (wordList.length == 1) {
          GameObject target = activeChar.getTarget();

          if (target == null) {
            activeChar.sendMessage("Select character or specify player name.");
            break;
          }

          if (!target.isPlayer()) {
            activeChar.sendPacket(new SystemMessage(SystemMessage.INVALID_TARGET));
            break;
          }

          player = (Player) target;
        } else {
          player = World.getPlayer(wordList[1]);

          if (player == null) {
            activeChar.sendMessage("Character " + wordList[1] + " not found in game.");
            break;
          }
        }

        if (player.getObjectId() == activeChar.getObjectId()) {
          activeChar.sendMessage("You can't logout your character.");
          break;
        }

        activeChar.sendMessage("Character " + player.getName() + " disconnected from server.");

        if (player.isInOfflineMode()) {
          player.setOfflineMode(false);
          player.kick();
          return true;
        }

        player.sendMessage("You where kicked by a GM.");
        player.sendPacket(
            new SystemMessage(
                SystemMessage.YOU_HAVE_BEEN_DISCONNECTED_FROM_THE_SERVER_PLEASE_LOGIN_AGAIN));
        ThreadPoolManager.getInstance()
            .schedule(
                new RunnableImpl() {
                  @Override
                  public void runImpl() {
                    player.kick();
                  }
                },
                500);
        break;
    }

    return true;
  }
Exemple #6
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;
  }