/**
   * Manage actions when a player click on this L2PcInstance.<br>
   * <br>
   * <B><U> Actions on first click on the L2PcInstance (Select it)</U> :</B><br>
   * <br>
   * <li>Set the target of the player
   * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)<br>
   *     <br>
   *     <B><U> Actions on second click on the L2PcInstance (Follow it/Attack it/Intercat with
   *     it)</U> :</B><br>
   *     <br>
   * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)
   * <li>If target L2PcInstance has a Private Store, notify the player AI with AI_INTENTION_INTERACT
   * <li>If target L2PcInstance is autoAttackable, notify the player AI with AI_INTENTION_ATTACK<br>
   *     <br>
   * <li>If target L2PcInstance is NOT autoAttackable, notify the player AI with AI_INTENTION_FOLLOW
   *     <br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Client packet : Action, AttackRequest<br>
   *     <br>
   *
   * @param activeChar The player that start an action on target L2PcInstance
   */
  public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) {
    // See description in TvTEvent.java
    if (!TvTEvent.onAction(activeChar, target.getObjectId())) return false;

    // Check if the L2PcInstance is confused
    if (activeChar.isOutOfControl()) return false;

    // Aggression target lock effect
    if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
      return false;
    }

    // Check if the activeChar already target this L2PcInstance
    if (activeChar.getTarget() != target) {
      // Set the target of the activeChar
      activeChar.setTarget(target);

      // Send a Server->Client packet MyTargetSelected to the activeChar
      // The color to display in the select window is White
      activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
      if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character) target));
    } else if (interact) {
      if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character) target));
      // Check if this L2PcInstance has a Private Store
      if (((L2PcInstance) target).getPrivateStoreType() != 0) {
        activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
      } else {
        // Check if this L2PcInstance is autoAttackable
        if (target.isAutoAttackable(activeChar)) {
          // activeChar with lvl < 21 can't attack a cursed weapon holder
          // And a cursed weapon holder  can't attack activeChars with lvl < 21
          if ((((L2PcInstance) target).isCursedWeaponEquipped() && activeChar.getLevel() < 21)
              || (activeChar.isCursedWeaponEquipped() && ((L2Character) target).getLevel() < 21)) {
            activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          } else {
            if (Config.GEODATA > 0) {
              if (GeoData.getInstance().canSeeTarget(activeChar, target)) {
                activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
                activeChar.onActionRequest();
              }
            } else {
              activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
              activeChar.onActionRequest();
            }
          }
        } else {
          // This Action Failed packet avoids activeChar getting stuck when clicking three or more
          // times
          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          if (Config.GEODATA > 0) {
            if (GeoData.getInstance().canSeeTarget(activeChar, target))
              activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
          } else activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
        }
      }
    }
    return true;
  }
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!target.isNpc() || activeChar.isCursedWeaponEquipped()) {
      return false;
    }

    if (command.equalsIgnoreCase(COMMANDS[0])) {
      makeSupportMagic(activeChar, (L2Npc) target, true);
    } else if (command.equalsIgnoreCase(COMMANDS[1])) {
      makeSupportMagic(activeChar, (L2Npc) target, false);
    }
    return true;
  }
  @Override
  public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item) {
    if ((effector == null) || !effector.isPlayer()) {
      return !_val;
    }

    final L2PcInstance player = effector.getActingPlayer();
    boolean canSummonSiegeGolem = true;
    if (player.isAlikeDead() || player.isCursedWeaponEquipped() || (player.getClan() == null)) {
      canSummonSiegeGolem = false;
    }

    final Castle castle = CastleManager.getInstance().getCastle(player);
    final Fort fort = FortManager.getInstance().getFort(player);
    if ((castle == null) && (fort == null)) {
      canSummonSiegeGolem = false;
    }

    if (((fort != null) && (fort.getResidenceId() == 0))
        || ((castle != null) && (castle.getResidenceId() == 0))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if (((castle != null) && !castle.getSiege().isInProgress())
        || ((fort != null) && !fort.getSiege().isInProgress())) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((player.getClanId() != 0)
        && (((castle != null) && (castle.getSiege().getAttackerClan(player.getClanId()) == null))
            || ((fort != null) && (fort.getSiege().getAttackerClan(player.getClanId()) == null)))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((SevenSigns.getInstance().checkSummonConditions(player))) {
      canSummonSiegeGolem = false;
    }
    return (_val == canSummonSiegeGolem);
  }
Exemplo n.º 4
0
  @Override
  protected void runImpl() {
    if (Config.DEBUG) _log.info("Say2: Msg Type = '" + _type + "' Text = '" + _text + "'.");

    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_type < 0 || _type >= CHAT_NAMES.length) {
      _log.warning(
          "Say2: Invalid type: "
              + _type
              + " Player : "
              + activeChar.getName()
              + " text: "
              + String.valueOf(_text));
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      activeChar.logout();
      return;
    }

    if (_text.isEmpty()) {
      _log.warning(activeChar.getName() + ": sending empty text. Possible packet hack!");
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      activeChar.logout();
      return;
    }

    // Even though the client can handle more characters than it's current limit allows, an overflow
    // (critical error) happens if you pass a huge (1000+) message.
    // July 11, 2011 - Verified on High Five 4 official client as 105.
    // Allow higher limit if player shift some item (text is longer then).
    if (!activeChar.isGM()
        && ((_text.indexOf(8) >= 0 && _text.length() > 500)
            || (_text.indexOf(8) < 0 && _text.length() > 105))) {
      activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.DONT_SPAM));
      return;
    }

    if (Config.L2WALKER_PROTECTION && _type == TELL && checkBot(_text)) {
      Util.handleIllegalPlayerAction(
          activeChar,
          "Client Emulator Detect: Player " + activeChar.getName() + " using l2walker.",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (activeChar.isCursedWeaponEquipped() && (_type == TRADE || _type == SHOUT)) {
      activeChar.sendPacket(
          SystemMessage.getSystemMessage(
              SystemMessageId.SHOUT_AND_TRADE_CHAT_CANNOT_BE_USED_WHILE_POSSESSING_CURSED_WEAPON));
      return;
    }

    if (activeChar.isChatBanned() && !_text.startsWith(".")) {
      for (int chatId : Config.BAN_CHAT_CHANNELS) {
        if (_type == chatId) {
          activeChar.sendPacket(
              SystemMessage.getSystemMessage(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED));
          return;
        }
      }
    }

    if (activeChar.isInJail() && Config.JAIL_DISABLE_CHAT) {
      if (_type == TELL || _type == SHOUT || _type == TRADE || _type == HERO_VOICE) {
        activeChar.sendMessage("You can not chat with players outside of the jail.");
        return;
      }
    }

    if (_type == PETITION_PLAYER && activeChar.isGM()) _type = PETITION_GM;

    if (Config.LOG_CHAT) {
      LogRecord record = new LogRecord(Level.INFO, _text);
      record.setLoggerName("chat");

      if (_type == TELL)
        record.setParameters(
            new Object[] {CHAT_NAMES[_type], "[" + activeChar.getName() + " to " + _target + "]"});
      else record.setParameters(new Object[] {CHAT_NAMES[_type], "[" + activeChar.getName() + "]"});

      _logChat.log(record);
    }

    if (_text.indexOf(8) >= 0) if (!parseAndPublishItem(activeChar)) return;

    // Say Filter implementation
    if (Config.USE_SAY_FILTER) checkText();

    IChatHandler handler = ChatHandler.getInstance().getChatHandler(_type);
    if (handler != null) handler.handleChat(_type, activeChar, _target, _text);
    else _log.info("No handler registered for ChatType: " + _type + " Player: " + getClient());
  }