예제 #1
0
  public void restore() {
    _contacts.clear();

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps = con.prepareStatement(QUERY_LOAD)) {
      ps.setInt(1, activeChar.getObjectId());
      try (ResultSet rs = ps.executeQuery()) {
        int contactId;
        String contactName;
        while (rs.next()) {
          contactId = rs.getInt(1);
          contactName = CharNameTable.getInstance().getNameById(contactId);
          if ((contactName == null)
              || contactName.equals(activeChar.getName())
              || (contactId == activeChar.getObjectId())) {
            continue;
          }

          _contacts.add(contactName);
        }
      }
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(),
          e);
    }
  }
예제 #2
0
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    final TradeList trade = player.getActiveTradeList();
    if (trade == null) {
      _log.warning(
          "Character: "
              + player.getName()
              + " requested item:"
              + _objectId
              + " add without active tradelist:"
              + _tradeId);
      return;
    }

    final L2PcInstance partner = trade.getPartner();
    if (partner == null
        || L2World.getInstance().getPlayer(partner.getObjectId()) == null
        || partner.getActiveTradeList() == null) {
      // Trade partner not found, cancel trade
      if (partner != null)
        _log.warning(
            "Character:" + player.getName() + " requested invalid trade object: " + _objectId);
      SystemMessage msg = new SystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
      player.sendPacket(msg);
      player.cancelActiveTrade();
      return;
    }

    if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed()) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CANNOT_ADJUST_ITEMS_AFTER_TRADE_CONFIRMED));
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disable for your Access Level");
      player.cancelActiveTrade();
      return;
    }

    if (!player.validateItemManipulation(_objectId, "trade")) {
      player.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
      return;
    }

    final TradeList.TradeItem item = trade.addItem(_objectId, _count);
    if (item != null) {
      player.sendPacket(new TradeOwnAdd(item));
      trade.getPartner().sendPacket(new TradeOtherAdd(item));
    }
  }
 public void handleCheat(L2PcInstance player, L2Npc npc) {
   showHtmlFile(player, "data/html/seven_signs/rift/Cheater.htm", npc);
   if (!player.isGM()) {
     _log.warning(
         "Player "
             + player.getName()
             + "("
             + player.getObjectId()
             + ") was cheating in dimension rift area!");
     Util.handleIllegalPlayerAction(
         player,
         "Warning!! Character " + player.getName() + " tried to cheat in dimensional rift.",
         Config.DEFAULT_PUNISH);
   }
 }
예제 #4
0
  public void remove(String name) {
    int contactId = CharNameTable.getInstance().getIdByName(name);

    if (!_contacts.contains(name)) {
      activeChar.sendPacket(SystemMessageId.NAME_NOT_REGISTERED_ON_CONTACT_LIST);
      return;
    } else if (contactId < 1) {
      // TODO: Message?
      return;
    }

    _contacts.remove(name);

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps = con.prepareStatement(QUERY_REMOVE)) {
      ps.setInt(1, activeChar.getObjectId());
      ps.setInt(2, contactId);
      ps.execute();

      SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESFULLY_DELETED_FROM_CONTACT_LIST);
      sm.addString(name);
      activeChar.sendPacket(sm);
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(),
          e);
    }
  }
예제 #5
0
  public boolean add(String name) {
    SystemMessage sm;

    int contactId = CharNameTable.getInstance().getIdByName(name);
    if (_contacts.contains(name)) {
      activeChar.sendPacket(SystemMessageId.NAME_ALREADY_EXIST_ON_CONTACT_LIST);
      return false;
    } else if (activeChar.getName().equals(name)) {
      activeChar.sendPacket(SystemMessageId.CANNOT_ADD_YOUR_NAME_ON_CONTACT_LIST);
      return false;
    } else if (_contacts.size() >= 100) {
      activeChar.sendPacket(SystemMessageId.CONTACT_LIST_LIMIT_REACHED);
      return false;
    } else if (contactId < 1) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.NAME_S1_NOT_EXIST_TRY_ANOTHER_NAME);
      sm.addString(name);
      activeChar.sendPacket(sm);
      return false;
    } else {
      for (String contactName : _contacts) {
        if (contactName.equalsIgnoreCase(name)) {
          activeChar.sendPacket(SystemMessageId.NAME_ALREADY_EXIST_ON_CONTACT_LIST);
          return false;
        }
      }
    }

    try (Connection con = ConnectionFactory.getInstance().getConnection();
        PreparedStatement ps = con.prepareStatement(QUERY_ADD)) {
      ps.setInt(1, activeChar.getObjectId());
      ps.setInt(2, contactId);
      ps.execute();

      _contacts.add(name);

      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ADDED_TO_CONTACT_LIST);
      sm.addString(name);
      activeChar.sendPacket(sm);
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(),
          e);
    }
    return true;
  }
예제 #6
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    String htmlPath = command.substring(4).trim();
    if (htmlPath.isEmpty()) {
      _log.warning("Player " + activeChar.getName() + " sent empty link html!");
      return false;
    }

    if (htmlPath.contains("..")) {
      _log.warning("Player " + activeChar.getName() + " sent invalid link html: " + htmlPath);
      return false;
    }

    String filename = "html/" + htmlPath;
    final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0);
    html.setFile(activeChar.getHtmlPrefix(), filename);
    html.replace("%objectId%", String.valueOf(target != null ? target.getObjectId() : 0));
    activeChar.sendPacket(html);
    return true;
  }
예제 #7
0
  // @formatter:off
  @RegisterEvent(EventType.ON_NPC_MANOR_BYPASS)
  @RegisterType(ListenerRegisterType.NPC)
  @Id({35100, 35142, 35184, 35226, 35274, 35316, 35363, 35509, 35555})
  // @formatter:on
  public final void onNpcManorBypass(OnNpcManorBypass evt) {
    final L2PcInstance player = evt.getActiveChar();
    final L2Npc npc = evt.getTarget();
    if (isOwner(player, npc)) {
      final CastleManorManager manor = CastleManorManager.getInstance();
      if (manor.isUnderMaintenance()) {
        player.sendPacket(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE);
        return;
      }

      final int castleId =
          (evt.getManorId() == -1) ? npc.getCastle().getResidenceId() : evt.getManorId();
      switch (evt.getRequest()) {
        case 3: // Seed info
          player.sendPacket(new ExShowSeedInfo(castleId, evt.isNextPeriod(), true));
          break;
        case 4: // Crop info
          player.sendPacket(new ExShowCropInfo(castleId, evt.isNextPeriod(), true));
          break;
        case 5: // Basic info
          player.sendPacket(new ExShowManorDefaultInfo(true));
          break;
        case 7: // Seed settings
          if (manor.isManorApproved()) {
            player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_4_30_AM_AND_8_PM);
            return;
          }
          player.sendPacket(new ExShowSeedSetting(castleId));
          break;
        case 8: // Crop settings
          if (manor.isManorApproved()) {
            player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_4_30_AM_AND_8_PM);
            return;
          }
          player.sendPacket(new ExShowCropSetting(castleId));
          break;
        default:
          _log.warning(
              getClass().getSimpleName()
                  + ": Player "
                  + player.getName()
                  + " ("
                  + player.getObjectId()
                  + ") send unknown request id "
                  + evt.getRequest()
                  + "!");
      }
    }
  }
예제 #8
0
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    String command = "admin_" + _command.split(" ")[0];

    IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);

    if (ach == null) {
      if (activeChar.isGM()) {
        activeChar.sendMessage("指令「" + command.substring(6) + "」不存在!");
      }

      _log.warning("No handler registered for admin command '" + command + "'");
      return;
    }

    if (!AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel())) {
      activeChar.sendMessage("没有相关权限");
      _log.warning(
          "Character "
              + activeChar.getName()
              + " tryed to use admin command "
              + command
              + ", but have no access to it!");
      return;
    }

    if (Config.GMAUDIT) {
      GMAudit.auditGMAction(
          activeChar.getName() + " [" + activeChar.getObjectId() + "]",
          _command,
          (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
    }

    ach.useAdminCommand("admin_" + _command, activeChar);
  }
예제 #9
0
 @Override
 public boolean useAdminCommand(String command, L2PcInstance activeChar) {
   if (command.equals("admin_gm") && activeChar.isGM()) {
     AdminData.getInstance().deleteGm(activeChar);
     activeChar.setAccessLevel(0, true);
     activeChar.sendMessage("You no longer have GM status.");
     _log.info(
         "GM: "
             + activeChar.getName()
             + "("
             + activeChar.getObjectId()
             + ") turned his GM status off");
   }
   return true;
 }
예제 #10
0
  final void onAuctionFinished(final ItemAuction auction) {
    auction.broadcastToAllBiddersInternal(
        new SystemMessage(SystemMessageId.S1_AUCTION_ENDED).addNumber(auction.getAuctionId()));

    final ItemAuctionBid bid = auction.getHighestBid();
    if (bid != null) {
      final L2ItemInstance item = auction.createNewItemInstance();
      final L2PcInstance player = bid.getPlayer();
      if (player != null) {
        player.getWarehouse().addItem("ItemAuction", item, null, null);
        player.sendPacket(
            new SystemMessage(SystemMessageId.WON_BID_ITEM_CAN_BE_FOUND_IN_WAREHOUSE));

        _log.log(
            Level.INFO,
            "L2ItemAuctionInstance: Auction "
                + auction.getAuctionId()
                + " has finished. Highest bid by "
                + player.getName()
                + " for instance "
                + _instanceId);
      } else {
        item.setOwnerId(bid.getPlayerObjId());
        item.setLocation(ItemLocation.WAREHOUSE);
        item.updateDatabase();
        L2World.getInstance().removeObject(item);

        _log.log(
            Level.INFO,
            "L2ItemAuctionInstance: Auction "
                + auction.getAuctionId()
                + " has finished. Highest bid by "
                + CharNameTable.getInstance().getNameById(bid.getPlayerObjId())
                + " for instance "
                + _instanceId);
      }

      // Clean all canceled bids
      auction.clearCanceledBids();
    } else {
      _log.log(
          Level.INFO,
          "L2ItemAuctionInstance: Auction "
              + auction.getAuctionId()
              + " has finished. There have not been any bid for instance "
              + _instanceId);
    }
  }
예제 #11
0
  /**
   * Adds item to inventory
   *
   * @param process : String Identifier of process triggering this action
   * @param itemId : int Item Identifier of the item to be added
   * @param count : int Quantity of items to be added
   * @param actor : L2PcInstance Player requesting the item add
   * @param reference : Object Object referencing current action like NPC selling item or previous
   *     item in transformation
   * @return L2ItemInstance corresponding to the new item or the updated item in inventory
   */
  public L2ItemInstance addItem(
      String process, int itemId, long count, L2PcInstance actor, Object reference) {
    L2ItemInstance item = getItemByItemId(itemId);

    // If stackable item is found in inventory just add to current quantity
    if (item != null && item.isStackable()) {
      item.changeCount(process, count, actor, reference);
      item.setLastChange(L2ItemInstance.MODIFIED);
      // Updates database
      if (itemId == 57 && count < 10000 * Config.RATE_DROP_ITEMS_ID.get(57)) {
        // Small adena changes won't be saved to database all the time
        if (GameTimeController.getGameTicks() % 5 == 0) item.updateDatabase();
      } else item.updateDatabase();
    }
    // If item hasn't be found in inventory, create new one
    else {
      for (int i = 0; i < count; i++) {
        L2Item template = ItemTable.getInstance().getTemplate(itemId);
        if (template == null) {
          _log.log(
              Level.WARNING,
              (actor != null ? "[" + actor.getName() + "] " : "") + "Invalid ItemId requested: ",
              itemId);
          return null;
        }

        item =
            ItemTable.getInstance()
                .createItem(process, itemId, template.isStackable() ? count : 1, actor, reference);
        item.setOwnerId(getOwnerId());
        item.setLocation(getBaseLocation());
        item.setLastChange(L2ItemInstance.ADDED);

        // Add item in inventory
        addItem(item);
        // Updates database
        item.updateDatabase();

        // If stackable, end loop as entire count is included in 1 instance of item
        if (template.isStackable() || !Config.MULTIPLE_ITEM_DROP) break;
      }
    }

    refreshWeight();
    return item;
  }
예제 #12
0
  protected void enterInstance(
      L2PcInstance player, InstanceWorld instance, String template, int templateId) {
    final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
    if (world != null) {
      if (world.getTemplateId() == templateId) {
        onEnterInstance(player, world, false);

        final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
        if (inst.isRemoveBuffEnabled()) {
          handleRemoveBuffs(player, world);
        }
        return;
      }
      player.sendPacket(
          SystemMessageId
              .YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
      return;
    }

    if (checkConditions(player, templateId)) {
      instance.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
      instance.setTemplateId(templateId);
      instance.setStatus(0);
      InstanceManager.getInstance().addWorld(instance);
      onEnterInstance(player, instance, true);

      final Instance inst = InstanceManager.getInstance().getInstance(instance.getInstanceId());
      if (inst.getReenterType() == InstanceReenterType.ON_INSTANCE_ENTER) {
        handleReenterTime(instance);
      }

      if (inst.isRemoveBuffEnabled()) {
        handleRemoveBuffs(instance);
      }

      if (Config.DEBUG_INSTANCES) {
        _log.info(
            "Instance "
                + inst.getName()
                + " ("
                + instance.getTemplateId()
                + ") has been created by player "
                + player.getName());
      }
    }
  }
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if ((player == null) || (player.getBuyList() == null)) {
      return;
    }

    if ((_storeMsg != null) && (_storeMsg.length() > MAX_MSG_LENGTH)) {
      Util.handleIllegalPlayerAction(
          player,
          "Player " + player.getName() + " tried to overflow private store buy message",
          Config.DEFAULT_PUNISH);
      return;
    }

    player.getBuyList().setTitle(_storeMsg);
    player.sendPacket(new PrivateStoreMsgBuy(player));
  }
  /**
   * Handle chat type 'partymatchroom'
   *
   * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int,
   *     net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
   */
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (activeChar.isInPartyMatchRoom()) {
      PartyMatchRoom _room = PartyMatchRoomList.getInstance().getPlayerRoom(activeChar);
      if (_room != null) {
        if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
          activeChar.sendPacket(
              SystemMessage.getSystemMessage(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED));
          return;
        }

        CreatureSay cs =
            new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
        for (L2PcInstance _member : _room.getPartyMembers()) {
          _member.sendPacket(cs);
        }
      }
    }
  }
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if ((_name != null) && (_name.length() > MAX_MSG_LENGTH)) {
      Util.handleIllegalPlayerAction(
          player,
          "Player " + player.getName() + " tried to overflow recipe shop message",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (player.hasManufactureShop()) {
      player.setStoreName(_name);
    }
  }
예제 #16
0
  /**
   * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String,
   *     com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
   */
  public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
    String screenMsgNoble = "Congratulations On Becoming A Noblesse!";

    try {
      if (validateNobleCommand(activeChar)
          && activeChar.destroyItemByItemId(
              "Noble", 3470, Config.L2JMOD_SYSTEM_NOBLE_AMOUNT_ITEM, activeChar, true)) {
        activeChar.startParalyze();
        activeChar.setNoble(true);
        activeChar.sendPacket(new UserInfo(activeChar));
        activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));
        ExShowScreenMessage showMessage =
            new ExShowScreenMessage(screenMsgNoble, Config.L2JMOD_CUSTOM_WHITE_SCREEN_MESSAGE_TIME);
        activeChar.sendPacket(showMessage);
        activeChar.startAbnormalEffect(AbnormalEffect.REAL_TARGET);
        activeChar.startAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
        activeChar.broadcastPacket(new PlaySound("Itemsound.quest_finish"));
        activeChar.setIsTeleporting(true); // block movements
        ThreadPoolManager.getInstance()
            .scheduleGeneral(
                new Runnable() {

                  @Override
                  public void run() {
                    activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
                    activeChar.stopAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
                    activeChar.setIsTeleporting(false); // restore movements
                  }
                },
                Config.L2JMOD_CUSTOM_WHITE_SCREEN_MESSAGE_TIME / 3);
      }
    } catch (Exception e) {
      _log.log(
          Level.SEVERE,
          "Error when trying to become the player:"
              + activeChar.getName()
              + " in noble: "
              + e.getMessage(),
          e);
    }

    return true;
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();

    if ((activeChar == null) || (activeChar.getClan() != null)) {
      return;
    }

    final L2Clan clan = ClanTable.getInstance().getClan(_clanId);

    if (clan == null) {
      return;
    }

    final PledgeApplicantInfo info =
        new PledgeApplicantInfo(
            activeChar.getObjectId(),
            activeChar.getName(),
            activeChar.getLevel(),
            _karma,
            _clanId,
            _message);

    if (ClanEntryManager.getInstance().addPlayerApplicationToClan(_clanId, info)) {
      activeChar.sendPacket(new ExPledgeRecruitApplyInfo(ClanEntryStatus.WAITING));

      final L2PcInstance clanLeader = L2World.getInstance().getPlayer(clan.getLeaderId());

      if (clanLeader != null) {
        clanLeader.sendPacket(ExPledgeWaitingListAlarm.STATIC_PACKET);
      }
    } else {
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId
                  .YOU_MAY_APPLY_FOR_ENTRY_AFTER_S1_MINUTE_S_DUE_TO_CANCELLING_YOUR_APPLICATION);
      sm.addLong(ClanEntryManager.getInstance().getPlayerLockTime(activeChar.getObjectId()));
      activeChar.sendPacket(sm);
    }
  }
예제 #18
0
파일: Util.java 프로젝트: 54k/L2J_Server
 /**
  * Fills the community board's multiedit window with text. Must send after sendCBHtml
  *
  * @param activeChar
  * @param text
  */
 public static void fillMultiEditContent(L2PcInstance activeChar, String text) {
   text = text.replaceAll("<br>", Config.EOL);
   List<String> arg = new FastList<>();
   arg.add("0");
   arg.add("0");
   arg.add("0");
   arg.add("0");
   arg.add("0");
   arg.add("0");
   arg.add(activeChar.getName());
   arg.add(Integer.toString(activeChar.getObjectId()));
   arg.add(activeChar.getAccountName());
   arg.add("9");
   arg.add(" ");
   arg.add(" ");
   arg.add(text);
   arg.add("0");
   arg.add("0");
   arg.add("0");
   arg.add("0");
   activeChar.sendPacket(new ShowBoard(arg));
 }
예제 #19
0
  private void enterInstance(L2PcInstance player, String template) {
    InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);

    if (world != null) {
      if (world instanceof DPFWorld) {
        teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
        return;
      }
      player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
      return;
    }

    if (!checkTeleport(player)) {
      return;
    }

    world = new DPFWorld();
    world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
    world.setTemplateId(TEMPLATE_ID);
    world.addAllowed(player.getObjectId());
    world.setStatus(0);
    InstanceManager.getInstance().addWorld(world);
    teleportPlayer(player, ENTRY_POINT, world.getInstanceId());

    _log.info(
        "Tower of Infinitum - Demon Prince floor started "
            + template
            + " Instance: "
            + world.getInstanceId()
            + " created by player: "
            + player.getName());

    for (L2PcInstance partyMember : player.getParty().getMembers()) {
      teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
      partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true);
      world.addAllowed(partyMember.getObjectId());
    }
  }
예제 #20
0
 /**
  * @param activeChar the active GM
  * @param player the online target
  * @param lvl the access level
  */
 private static void onlineChange(L2PcInstance activeChar, L2PcInstance player, int lvl) {
   if (lvl >= 0) {
     if (AdminData.getInstance().hasAccessLevel(lvl)) {
       final L2AccessLevel acccessLevel = AdminData.getInstance().getAccessLevel(lvl);
       player.setAccessLevel(lvl);
       player.sendMessage(
           "你的权限等级变更到 " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
       activeChar.sendMessage(
           player.getName()
               + "的权限等级变更到 "
               + acccessLevel.getName()
               + " ("
               + acccessLevel.getLevel()
               + ").");
     } else {
       activeChar.sendMessage("你在试图设定一个无效的权限等级: " + lvl + " 请使用一个有效的等级重试一次!");
     }
   } else {
     player.setAccessLevel(lvl);
     player.sendMessage("你的角色已被查封,再见.");
     player.logout();
   }
 }
예제 #21
0
  @Override
  protected final void writeImpl() {
    writeC(0x96);
    writeS(_activeChar.getName());
    writeD(_clan.getClanId());
    writeD(0x00);
    writeS(_clan.getName());
    writeS(_clan.getLeaderName());
    writeD(_clan.getCrestId()); // -> no, it's no longer used (nuocnam) fix by game
    writeD(_clan.getLevel());
    writeD(_clan.getCastleId());
    writeD(_clan.getHideoutId());
    writeD(_clan.getFortId());
    writeD(_clan.getRank());
    writeD(_clan.getReputationScore());
    writeD(0x00);
    writeD(0x00);

    writeD(_clan.getAllyId()); // c2
    writeS(_clan.getAllyName()); // c2
    writeD(_clan.getAllyCrestId()); // c2
    writeD(_clan.isAtWar() ? 1 : 0); // c3
    writeD(0x00); // T3 Unknown
    writeD(_clan.getMembers().length);

    for (L2ClanMember member : _clan.getMembers()) {
      if (member != null) {
        writeS(member.getName());
        writeD(member.getLevel());
        writeD(member.getClassId());
        writeD(member.getSex() ? 1 : 0);
        writeD(member.getRaceOrdinal());
        writeD(member.isOnline() ? member.getObjectId() : 0);
        writeD(member.getSponsor() != 0 ? 1 : 0);
      }
    }
  }
예제 #22
0
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    L2PcInstance ob = L2World.getInstance().getPlayer(_id);

    if (ob == null) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
      return;
    }

    if (activeChar.getClan() == null) {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
      return;
    }

    L2PcInstance target = ob;
    L2Clan clan = activeChar.getClan();
    if (!clan.checkAllyJoinCondition(activeChar, target)) {
      return;
    }
    if (!activeChar.getRequest().setRequest(target, this)) {
      return;
    }

    SystemMessage sm =
        new SystemMessage(SystemMessageId.S2_ALLIANCE_LEADER_OF_S1_REQUESTED_ALLIANCE);
    sm.addString(activeChar.getClan().getAllyName());
    sm.addString(activeChar.getName());
    target.sendPacket(sm);
    sm = null;
    AskJoinAlly aja = new AskJoinAlly(activeChar.getObjectId(), activeChar.getClan().getAllyName());
    target.sendPacket(aja);
  }
예제 #23
0
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if (_items == null) {
      player.setPrivateStoreType(PrivateStoreType.NONE);
      player.broadcastUserInfo();
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }

    if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessageId
              .WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(ZoneId.NO_STORE)) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!player.canOpenPrivateStore()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();

    // Check maximum number of allowed slots for pvt shops
    if (_items.length > player.getPrivateBuyStoreLimit()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }

    long totalCost = 0;
    for (Item i : _items) {
      if (!i.addToTradeList(tradeList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }

      totalCost += i.getCost();
      if (totalCost > MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set total price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Check for available funds
    if (totalCost > player.getAdena()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(
          SystemMessageId
              .THE_PURCHASE_PRICE_IS_HIGHER_THAN_THE_AMOUNT_OF_MONEY_THAT_YOU_HAVE_AND_SO_YOU_CANNOT_OPEN_A_PERSONAL_STORE);
      return;
    }

    player.sitDown();
    player.setPrivateStoreType(PrivateStoreType.BUY);
    player.broadcastUserInfo();
    player.broadcastPacket(new PrivateStoreMsgBuy(player));
  }
예제 #24
0
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    L2PcInstance targetChar = L2World.getInstance().getPlayer(_player);
    if (activeChar == null) {
      return;
    }
    if (targetChar == null) {
      activeChar.sendPacket(
          SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
      return;
    }
    if (activeChar == targetChar) {
      activeChar.sendPacket(
          SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
      return;
    }

    // Check if duel is possible
    if (!activeChar.canDuel()) {
      activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
      return;
    } else if (!targetChar.canDuel()) {
      activeChar.sendPacket(targetChar.getNoDuelReason());
      return;
    }
    // Players may not be too far apart
    else if (!activeChar.isInsideRadius(targetChar, 250, false, false)) {
      SystemMessage msg =
          SystemMessage.getSystemMessage(
              SystemMessageId.C1_IS_TOO_FAR_AWAY_TO_RECEIVE_A_DUEL_CHALLENGE);
      msg.addString(targetChar.getName());
      activeChar.sendPacket(msg);
      return;
    } else if (Config.FACTION_SYSTEM_ENABLED
        && ((activeChar.isEvil() && targetChar.isGood())
            || (activeChar.isGood() && targetChar.isEvil()))) {
      activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
      return;
    }

    // Duel is a party duel
    if (_partyDuel == 1) {
      // Player must be in a party & the party leader
      if (!activeChar.isInParty() || !activeChar.getParty().isLeader(activeChar)) {
        activeChar.sendMessage(
            "You have to be the leader of a party in order to request a party duel.");
        return;
      }
      // Target must be in a party
      else if (!targetChar.isInParty()) {
        activeChar.sendPacket(
            SystemMessageId
                .SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY);
        return;
      }
      // Target may not be of the same party
      else if (activeChar.getParty().containsPlayer(targetChar)) {
        activeChar.sendMessage("This player is a member of your own party.");
        return;
      }

      // Check if every player is ready for a duel
      for (L2PcInstance temp : activeChar.getParty().getMembers()) {
        if (!temp.canDuel()) {
          activeChar.sendMessage("Not all the members of your party are ready for a duel.");
          return;
        }
      }
      L2PcInstance partyLeader = null; // snatch party leader of targetChar's party
      for (L2PcInstance temp : targetChar.getParty().getMembers()) {
        if (partyLeader == null) {
          partyLeader = temp;
        }
        if (!temp.canDuel()) {
          activeChar.sendPacket(
              SystemMessageId
                  .THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL);
          return;
        }
      }

      // Send request to targetChar's party leader
      if (partyLeader != null) {
        if (!partyLeader.isProcessingRequest()) {
          activeChar.onTransactionRequest(partyLeader);
          partyLeader.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));

          if (Config.DEBUG) {
            _log.fine(activeChar.getName() + " requested a duel with " + partyLeader.getName());
          }

          SystemMessage msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_S_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL);
          msg.addString(partyLeader.getName());
          activeChar.sendPacket(msg);

          msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_S_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL);
          msg.addString(activeChar.getName());
          targetChar.sendPacket(msg);
        } else {
          SystemMessage msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
          msg.addString(partyLeader.getName());
          activeChar.sendPacket(msg);
        }
      }
    } else
    // 1vs1 duel
    {
      if (!targetChar.isProcessingRequest()) {
        activeChar.onTransactionRequest(targetChar);
        targetChar.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));

        if (Config.DEBUG) {
          _log.fine(activeChar.getName() + " requested a duel with " + targetChar.getName());
        }

        SystemMessage msg =
            SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_BEEN_CHALLENGED_TO_A_DUEL);
        msg.addString(targetChar.getName());
        activeChar.sendPacket(msg);

        msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_CHALLENGED_YOU_TO_A_DUEL);
        msg.addString(activeChar.getName());
        targetChar.sendPacket(msg);
      } else {
        SystemMessage msg =
            SystemMessage.getSystemMessage(
                SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
        msg.addString(targetChar.getName());
        activeChar.sendPacket(msg);
      }
    }
  }
예제 #25
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }

    if (Config.DEBUG) {
      _log.info(
          getType()
              + ": "
              + activeChar
              + " requested action use ID: "
              + _actionId
              + " Ctrl pressed:"
              + _ctrlPressed
              + " Shift pressed:"
              + _shiftPressed);
    }

    // Don't do anything if player is dead or confused
    if ((activeChar.isFakeDeath() && (_actionId != 0))
        || activeChar.isDead()
        || activeChar.isOutOfControl()) {
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    final BuffInfo info =
        activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(_actionId)) {
          activeChar.sendPacket(
              SystemMessageId
                  .YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    // Don't allow to do some action if player is transformed
    if (activeChar.isTransformed()) {
      int[] allowedActions =
          activeChar.isTransformed()
              ? ExBasicActionList.ACTIONS_ON_TRANSFORM
              : ExBasicActionList.DEFAULT_ACTION_LIST;
      if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0)) {
        sendPacket(ActionFailed.STATIC_PACKET);
        _log.warning(
            "Player "
                + activeChar
                + " used action which he does not have! Id = "
                + _actionId
                + " transform: "
                + activeChar.getTransformation());
        return;
      }
    }

    final L2Summon pet = activeChar.getPet();
    final L2Summon servitor = activeChar.getAnyServitor();
    final L2Object target = activeChar.getTarget();
    switch (_actionId) {
      case 0: // Sit/Stand
        if (activeChar.isSitting() || !activeChar.isMoving() || activeChar.isFakeDeath()) {
          useSit(activeChar, target);
        } else {
          // Sit when arrive using next action.
          // Creating next action class.
          final NextAction nextAction =
              new NextAction(
                  CtrlEvent.EVT_ARRIVED,
                  CtrlIntention.AI_INTENTION_MOVE_TO,
                  () -> useSit(activeChar, target));

          // Binding next action to AI.
          activeChar.getAI().setNextAction(nextAction);
        }
        break;
      case 1: // Walk/Run
        if (activeChar.isRunning()) {
          activeChar.setWalking();
        } else {
          activeChar.setRunning();
        }
        break;
      case 10: // Private Store - Sell
        activeChar.tryOpenPrivateSellStore(false);
        break;
      case 15: // Change Movement Mode (Pets)
        if (validateSummon(pet, true)) {
          ((L2SummonAI) pet.getAI()).notifyFollowStatusChange();
        }
        break;
      case 16: // Attack (Pets)
        if (validateSummon(pet, true)) {
          if (pet.canAttack(_ctrlPressed)) {
            pet.doAttack();
          }
        }
        break;
      case 17: // Stop (Pets)
        if (validateSummon(pet, true)) {
          pet.cancelAction();
        }
        break;
      case 19: // Unsummon Pet
        if (!validateSummon(pet, true)) {
          break;
        }

        if (pet.isDead()) {
          sendPacket(SystemMessageId.DEAD_PETS_CANNOT_BE_RETURNED_TO_THEIR_SUMMONING_ITEM);
          break;
        }

        if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled()) {
          sendPacket(SystemMessageId.A_PET_CANNOT_BE_UNSUMMONED_DURING_BATTLE);
          break;
        }

        if (pet.isHungry()) {
          if (!((L2PetInstance) pet).getPetData().getFood().isEmpty()) {
            sendPacket(SystemMessageId.YOU_MAY_NOT_RESTORE_A_HUNGRY_PET);
          } else {
            sendPacket(
                SystemMessageId
                    .THE_MINION_PET_CANNOT_BE_RETURNED_BECAUSE_THERE_IS_NOT_MUCH_TIME_REMAINING_UNTIL_IT_LEAVES);
          }
          break;
        }

        pet.unSummon(activeChar);
        break;
      case 21: // Change Movement Mode (Servitors)
        if (validateSummon(servitor, false)) {
          ((L2SummonAI) servitor.getAI()).notifyFollowStatusChange();
        }
        break;
      case 22: // Attack (Servitors)
        if (validateSummon(servitor, false)) {
          if (servitor.canAttack(_ctrlPressed)) {
            servitor.doAttack();
          }
        }
        break;
      case 23: // Stop (Servitors)
        if (validateSummon(servitor, false)) {
          servitor.cancelAction();
        }
        break;
      case 28: // Private Store - Buy
        activeChar.tryOpenPrivateBuyStore();
        break;
      case 32: // Wild Hog Cannon - Wild Cannon
        useSkill("DDMagic", false);
        break;
      case 36: // Soulless - Toxic Smoke
        useSkill("RangeDebuff", false);
        break;
      case 37: // Dwarven Manufacture
        if (activeChar.isAlikeDead()) {
          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
        if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
          activeChar.setPrivateStoreType(PrivateStoreType.NONE);
          activeChar.broadcastUserInfo();
        }
        if (activeChar.isSitting()) {
          activeChar.standUp();
        }

        sendPacket(new RecipeShopManageList(activeChar, true));
        break;
      case 38: // Mount/Dismount
        activeChar.mountPlayer(pet);
        break;
      case 39: // Soulless - Parasite Burst
        useSkill("RangeDD", false);
        break;
      case 41: // Wild Hog Cannon - Attack
        if (validateSummon(servitor, false)) {
          if ((target != null) && (target.isDoor() || (target instanceof L2SiegeFlagInstance))) {
            useSkill(4230, false);
          } else {
            sendPacket(SystemMessageId.INVALID_TARGET);
          }
        }
        break;
      case 42: // Kai the Cat - Self Damage Shield
        useSkill("HealMagic", false);
        break;
      case 43: // Merrow the Unicorn - Hydro Screw
        useSkill("DDMagic", false);
        break;
      case 44: // Big Boom - Boom Attack
        useSkill("DDMagic", false);
        break;
      case 45: // Boxer the Unicorn - Master Recharge
        useSkill("HealMagic", activeChar, false);
        break;
      case 46: // Mew the Cat - Mega Storm Strike
        useSkill("DDMagic", false);
        break;
      case 47: // Silhouette - Steal Blood
        useSkill("DDMagic", false);
        break;
      case 48: // Mechanic Golem - Mech. Cannon
        useSkill("DDMagic", false);
        break;
      case 51: // General Manufacture
        // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
        if (activeChar.isAlikeDead()) {
          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
        if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
          activeChar.setPrivateStoreType(PrivateStoreType.NONE);
          activeChar.broadcastUserInfo();
        }
        if (activeChar.isSitting()) {
          activeChar.standUp();
        }

        sendPacket(new RecipeShopManageList(activeChar, false));
        break;
      case 52: // Unsummon Servitor
        if (validateSummon(servitor, false)) {
          if (servitor.isAttackingNow() || servitor.isInCombat()) {
            sendPacket(SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED);
            break;
          }
          servitor.unSummon(activeChar);
        }
        break;
      case 53: // Move to target (Servitors)
        if (validateSummon(servitor, false)) {
          if ((target != null) && (servitor != target) && !servitor.isMovementDisabled()) {
            servitor.setFollowStatus(false);
            servitor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
          }
        }
        break;
      case 54: // Move to target (Pets)
        if (validateSummon(pet, true)) {
          if ((target != null) && (pet != target) && !pet.isMovementDisabled()) {
            pet.setFollowStatus(false);
            pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
          }
        }
        break;
      case 61: // Private Store Package Sell
        activeChar.tryOpenPrivateSellStore(true);
        break;
      case 65: // Bot Report Button
        if (Config.BOTREPORT_ENABLE) {
          BotReportTable.getInstance().reportBot(activeChar);
        } else {
          activeChar.sendMessage("This feature is disabled.");
        }
        break;
      case 67: // Steer
        if (activeChar.isInAirShip()) {
          if (activeChar.getAirShip().setCaptain(activeChar)) {
            activeChar.broadcastUserInfo();
          }
        }
        break;
      case 68: // Cancel Control
        if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar)) {
          if (activeChar.getAirShip().setCaptain(null)) {
            activeChar.broadcastUserInfo();
          }
        }
        break;
      case 69: // Destination Map
        AirShipManager.getInstance().sendAirShipTeleportList(activeChar);
        break;
      case 70: // Exit Airship
        if (activeChar.isInAirShip()) {
          if (activeChar.getAirShip().isCaptain(activeChar)) {
            if (activeChar.getAirShip().setCaptain(null)) {
              activeChar.broadcastUserInfo();
            }
          } else if (activeChar.getAirShip().isInDock()) {
            activeChar.getAirShip().oustPlayer(activeChar);
          }
        }
        break;
      case 71:
      case 72:
      case 73:
        useCoupleSocial(_actionId - 55);
        break;
      case 78:
      case 79:
      case 80:
      case 81:
        if ((activeChar.getParty() != null)
            && (activeChar.getTarget() != null)
            && (activeChar.getTarget().isCharacter())) {
          activeChar
              .getParty()
              .addTacticalSign(_actionId - 77, (L2Character) activeChar.getTarget());
        } else {
          sendPacket(ActionFailed.STATIC_PACKET);
        }
        break;
      case 82:
      case 83:
      case 84:
      case 85:
        if (activeChar.getParty() != null) {
          activeChar.getParty().setTargetBasedOnTacticalSignId(activeChar, _actionId - 81);
        } else {
          sendPacket(ActionFailed.STATIC_PACKET);
        }
        break;
      case 90: // /instancedzone action since Lindvior
        activeChar.sendPacket(new ExInzoneWaiting(activeChar));
        break;
      case 1000: // Siege Golem - Siege Hammer
        if ((target != null) && target.isDoor()) {
          useSkill(4079, false);
        }
        break;
      case 1001: // Sin Eater - Ultimate Bombastic Buster
        if (validateSummon(pet, true) && (pet.getId() == SIN_EATER_ID)) {
          pet.broadcastPacket(
              new NpcSay(
                  pet.getObjectId(),
                  ChatType.NPC_GENERAL,
                  pet.getId(),
                  NPC_STRINGS[Rnd.get(NPC_STRINGS.length)]));
        }
        break;
      case 1003: // Wind Hatchling/Strider - Wild Stun
        useSkill("PhysicalSpecial", true);
        break;
      case 1004: // Wind Hatchling/Strider - Wild Defense
        useSkill("Buff", activeChar, true);
        break;
      case 1005: // Star Hatchling/Strider - Bright Burst
        useSkill("DDMagic", true);
        break;
      case 1006: // Star Hatchling/Strider - Bright Heal
        useSkill("Heal", activeChar, true);
        break;
      case 1007: // Feline Queen - Blessing of Queen
        useSkill("Buff1", activeChar, false);
        break;
      case 1008: // Feline Queen - Gift of Queen
        useSkill("Buff2", activeChar, false);
        break;
      case 1009: // Feline Queen - Cure of Queen
        useSkill("DDMagic", false);
        break;
      case 1010: // Unicorn Seraphim - Blessing of Seraphim
        useSkill("Buff1", activeChar, false);
        break;
      case 1011: // Unicorn Seraphim - Gift of Seraphim
        useSkill("Buff2", activeChar, false);
        break;
      case 1012: // Unicorn Seraphim - Cure of Seraphim
        useSkill("DDMagic", false);
        break;
      case 1013: // Nightshade - Curse of Shade
        useSkill("DeBuff1", false);
        break;
      case 1014: // Nightshade - Mass Curse of Shade
        useSkill("DeBuff2", false);
        break;
      case 1015: // Nightshade - Shade Sacrifice
        useSkill("Heal", false);
        break;
      case 1016: // Cursed Man - Cursed Blow
        useSkill("PhysicalSpecial1", false);
        break;
      case 1017: // Cursed Man - Cursed Strike
        useSkill("PhysicalSpecial2", false);
        break;
      case 1031: // Feline King - Slash
        useSkill("PhysicalSpecial1", false);
        break;
      case 1032: // Feline King - Spinning Slash
        useSkill("PhysicalSpecial2", false);
        break;
      case 1033: // Feline King - Hold of King
        useSkill("PhysicalSpecial3", false);
        break;
      case 1034: // Magnus the Unicorn - Whiplash
        useSkill("PhysicalSpecial1", false);
        break;
      case 1035: // Magnus the Unicorn - Tridal Wave
        useSkill("PhysicalSpecial2", false);
        break;
      case 1036: // Spectral Lord - Corpse Kaboom
        useSkill("PhysicalSpecial1", false);
        break;
      case 1037: // Spectral Lord - Dicing Death
        useSkill("PhysicalSpecial2", false);
        break;
      case 1038: // Spectral Lord - Dark Curse
        useSkill("PhysicalSpecial3", false);
        break;
      case 1039: // Swoop Cannon - Cannon Fodder
        useSkill(5110, false);
        break;
      case 1040: // Swoop Cannon - Big Bang
        useSkill(5111, false);
        break;
      case 1041: // Great Wolf - Bite Attack
        useSkill("Skill01", true);
        break;
      case 1042: // Great Wolf - Maul
        useSkill("Skill03", true);
        break;
      case 1043: // Great Wolf - Cry of the Wolf
        useSkill("Skill02", true);
        break;
      case 1044: // Great Wolf - Awakening
        useSkill("Skill04", true);
        break;
      case 1045: // Great Wolf - Howl
        useSkill(5584, true);
        break;
      case 1046: // Strider - Roar
        useSkill(5585, true);
        break;
      case 1047: // Divine Beast - Bite
        useSkill(5580, false);
        break;
      case 1048: // Divine Beast - Stun Attack
        useSkill(5581, false);
        break;
      case 1049: // Divine Beast - Fire Breath
        useSkill(5582, false);
        break;
      case 1050: // Divine Beast - Roar
        useSkill(5583, false);
        break;
      case 1051: // Feline Queen - Bless The Body
        useSkill("buff3", false);
        break;
      case 1052: // Feline Queen - Bless The Soul
        useSkill("buff4", false);
        break;
      case 1053: // Feline Queen - Haste
        useSkill("buff5", false);
        break;
      case 1054: // Unicorn Seraphim - Acumen
        useSkill("buff3", false);
        break;
      case 1055: // Unicorn Seraphim - Clarity
        useSkill("buff4", false);
        break;
      case 1056: // Unicorn Seraphim - Empower
        useSkill("buff5", false);
        break;
      case 1057: // Unicorn Seraphim - Wild Magic
        useSkill("buff6", false);
        break;
      case 1058: // Nightshade - Death Whisper
        useSkill("buff3", false);
        break;
      case 1059: // Nightshade - Focus
        useSkill("buff4", false);
        break;
      case 1060: // Nightshade - Guidance
        useSkill("buff5", false);
        break;
      case 1061: // Wild Beast Fighter, White Weasel - Death blow
        useSkill(5745, true);
        break;
      case 1062: // Wild Beast Fighter - Double attack
        useSkill(5746, true);
        break;
      case 1063: // Wild Beast Fighter - Spin attack
        useSkill(5747, true);
        break;
      case 1064: // Wild Beast Fighter - Meteor Shower
        useSkill(5748, true);
        break;
      case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening
        useSkill(5753, true);
        break;
      case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt
        useSkill(5749, true);
        break;
      case 1067: // Fox Shaman, Spirit Shaman - Flash
        useSkill(5750, true);
        break;
      case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave
        useSkill(5751, true);
        break;
      case 1069: // Fox Shaman, Fairy Princess - Flare
        useSkill(5752, true);
        break;
      case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra,
        // Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control
        useSkill(5771, true);
        break;
      case 1071: // Tigress - Power Strike
        useSkill("DDMagic", true);
        break;
      case 1072: // Toy Knight - Piercing attack
        useSkill(6046, true);
        break;
      case 1073: // Toy Knight - Whirlwind
        useSkill(6047, true);
        break;
      case 1074: // Toy Knight - Lance Smash
        useSkill(6048, true);
        break;
      case 1075: // Toy Knight - Battle Cry
        useSkill(6049, true);
        break;
      case 1076: // Turtle Ascetic - Power Smash
        useSkill(6050, true);
        break;
      case 1077: // Turtle Ascetic - Energy Burst
        useSkill(6051, true);
        break;
      case 1078: // Turtle Ascetic - Shockwave
        useSkill(6052, true);
        break;
      case 1079: // Turtle Ascetic - Howl
        useSkill(6053, true);
        break;
      case 1080: // Phoenix Rush
        useSkill(6041, false);
        break;
      case 1081: // Phoenix Cleanse
        useSkill(6042, false);
        break;
      case 1082: // Phoenix Flame Feather
        useSkill(6043, false);
        break;
      case 1083: // Phoenix Flame Beak
        useSkill(6044, false);
        break;
      case 1084: // Switch State
        if (pet instanceof L2BabyPetInstance) {
          useSkill(SWITCH_STANCE_ID, true);
        }
        break;
      case 1086: // Panther Cancel
        useSkill(6094, false);
        break;
      case 1087: // Panther Dark Claw
        useSkill(6095, false);
        break;
      case 1088: // Panther Fatal Claw
        useSkill(6096, false);
        break;
      case 1089: // Deinonychus - Tail Strike
        useSkill(6199, true);
        break;
      case 1090: // Guardian's Strider - Strider Bite
        useSkill(6205, true);
        break;
      case 1091: // Guardian's Strider - Strider Fear
        useSkill(6206, true);
        break;
      case 1092: // Guardian's Strider - Strider Dash
        useSkill(6207, true);
        break;
      case 1093: // Maguen - Maguen Strike
        useSkill(6618, true);
        break;
      case 1094: // Maguen - Maguen Wind Walk
        useSkill(6681, true);
        break;
      case 1095: // Elite Maguen - Maguen Power Strike
        useSkill(6619, true);
        break;
      case 1096: // Elite Maguen - Elite Maguen Wind Walk
        useSkill(6682, true);
        break;
      case 1097: // Maguen - Maguen Return
        useSkill(6683, true);
        break;
      case 1098: // Elite Maguen - Maguen Party Return
        useSkill(6684, true);
        break;
      case 1099: // All servitor attack
        activeChar
            .getServitors()
            .values()
            .forEach(
                s -> {
                  if (validateSummon(s, false)) {
                    if (s.canAttack(_ctrlPressed)) {
                      s.doAttack();
                    }
                  }
                });
        break;
      case 1100: // All servitor move to
        activeChar
            .getServitors()
            .values()
            .forEach(
                s -> {
                  if (validateSummon(s, false)) {
                    if ((target != null) && (s != target) && !s.isMovementDisabled()) {
                      s.setFollowStatus(false);
                      s.getAI()
                          .setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
                    }
                  }
                });
        break;
      case 1101: // All servitor stop
        activeChar
            .getServitors()
            .values()
            .forEach(
                summon -> {
                  if (validateSummon(summon, false)) {
                    summon.cancelAction();
                  }
                });
        break;
      case 1102: // Unsummon all servitors
        boolean canUnsummon = true;
        OUT:
        for (L2Summon s : activeChar.getServitors().values()) {
          if (validateSummon(s, false)) {
            if (s.isAttackingNow() || s.isInCombat()) {
              sendPacket(
                  SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED);
              canUnsummon = false;
              break OUT;
            }
            s.unSummon(activeChar);
          }
        }
        if (canUnsummon) {
          activeChar
              .getServitors()
              .values()
              .stream()
              .forEach(
                  s -> {
                    s.unSummon(activeChar);
                  });
        }
        break;
      case 1103: // seems to be passive mode
        break;
      case 1104: // seems to be defend mode
        break;
      case 1106: // Cute Bear - Bear Claw
        useServitorsSkill(11278);
        break;
      case 1107: // Cute Bear - Bear Tumbling
        useServitorsSkill(11279);
        break;
      case 1108: // Saber Tooth Cougar- Cougar Bite
        useServitorsSkill(11280);
        break;
      case 1109: // Saber Tooth Cougar - Cougar Pounce
        useServitorsSkill(11281);
        break;
      case 1110: // Grim Reaper - Reaper Touch
        useServitorsSkill(11282);
        break;
      case 1111: // Grim Reaper - Reaper Power
        useServitorsSkill(11283);
        break;
      case 1113: // Golden Lion - Lion Roar
        useSkill(10051, false);
        break;
      case 1114: // Golden Lion - Lion Claw
        useSkill(10052, false);
        break;
      case 1115: // Golden Lion - Lion Dash
        useSkill(10053, false);
        break;
      case 1116: // Golden Lion - Lion Flame
        useSkill(10054, false);
        break;
      case 1117: // Thunder Hawk - Thunder Flight
        useSkill(10794, false);
        break;
      case 1118: // Thunder Hawk - Thunder Purity
        useSkill(10795, false);
        break;
      case 1120: // Thunder Hawk - Thunder Feather Blast
        useSkill(10797, false);
        break;
      case 1121: // Thunder Hawk - Thunder Sharp Claw
        useSkill(10798, false);
        break;
      case 1122: // Tree of Life - Blessing of Tree
        useServitorsSkill(11806);
        break;
      case 1124: // Wynn Kai the Cat - Feline Aggression
        useServitorsSkill(11323);
        break;
      case 1125: // Wynn Kai the Cat - Feline Stun
        useServitorsSkill(11324);
        break;
      case 1126: // Wynn Feline King - Feline Bite
        useServitorsSkill(11325);
        break;
      case 1127: // Wynn Feline King - Feline Pounce
        useServitorsSkill(11326);
        break;
      case 1128: // Wynn Feline Queen - Feline Touch
        useServitorsSkill(11327);
        break;
      case 1129: // Wynn Feline Queen - Feline Power
        useServitorsSkill(11328);
        break;
      case 1130: // Wynn Merrow - Unicorn's Aggression
        useServitorsSkill(11332);
        break;
      case 1131: // Wynn Merrow - Unicorn's Stun
        useServitorsSkill(11333);
        break;
      case 1132: // Wynn Magnus - Unicorn's Bite
        useServitorsSkill(11334);
        break;
      case 1133: // Wynn Magnus - Unicorn's Pounce
        useServitorsSkill(11335);
        break;
      case 1134: // Wynn Seraphim - Unicorn's Touch
        useServitorsSkill(11336);
        break;
      case 1135: // Wynn Seraphim - Unicorn's Power
        useServitorsSkill(11337);
        break;
      case 1136: // Wynn Nightshade - Phantom Aggression
        useServitorsSkill(11341);
        break;
      case 1137: // Wynn Nightshade - Phantom Stun
        useServitorsSkill(11342);
        break;
      case 1138: // Wynn Spectral Lord - Phantom Bite
        useServitorsSkill(11343);
        break;
      case 1139: // Wynn Spectral Lord - Phantom Pounce
        useServitorsSkill(11344);
        break;
      case 1140: // Wynn Soulless - Phantom Touch
        useServitorsSkill(11345);
        break;
      case 1141: // Wynn Soulless - Phantom Power
        useServitorsSkill(11346);
        break;
      case 1142: // Blood Panther - Panther Roar
        useServitorsSkill(10087);
        break;
      case 1143: // Blood Panther - Panther Rush
        useServitorsSkill(10088);
        break;
      case 5000: // Baby Rudolph - Reindeer Scratch
        useSkill(23155, true);
        break;
      case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction
        useSkill(23167, true);
        break;
      case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction
        useSkill(23168, true);
        break;
      case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt
        useSkill(5749, true);
        break;
      case 5004: // Hyum, Lapham, Hyum, Lapham - Flash
        useSkill(5750, true);
        break;
      case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave
        useSkill(5751, true);
        break;
      case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias,
        // Lapham, Mafum - Buff Control
        useSkill(5771, true);
        break;
      case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack
        useSkill(6046, true);
        break;
      case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack
        useSkill(6047, true);
        break;
      case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash
        useSkill(6048, true);
        break;
      case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite
        useSkill(6049, true);
        break;
      case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash
        useSkill(6050, true);
        break;
      case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst
        useSkill(6051, true);
        break;
      case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave
        useSkill(6052, true);
        break;
      case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite
        useSkill(6053, true);
        break;
      case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias,
        // Lapham, Mafum - Switch Stance
        useSkill(6054, true);
        break;
        // Social Packets
      case 12: // Greeting
        tryBroadcastSocial(2);
        break;
      case 13: // Victory
        tryBroadcastSocial(3);
        break;
      case 14: // Advance
        tryBroadcastSocial(4);
        break;
      case 24: // Yes
        tryBroadcastSocial(6);
        break;
      case 25: // No
        tryBroadcastSocial(5);
        break;
      case 26: // Bow
        tryBroadcastSocial(7);
        break;
      case 29: // Unaware
        tryBroadcastSocial(8);
        break;
      case 30: // Social Waiting
        tryBroadcastSocial(9);
        break;
      case 31: // Laugh
        tryBroadcastSocial(10);
        break;
      case 33: // Applaud
        tryBroadcastSocial(11);
        break;
      case 34: // Dance
        tryBroadcastSocial(12);
        break;
      case 35: // Sorrow
        tryBroadcastSocial(13);
        break;
      case 62: // Charm
        tryBroadcastSocial(14);
        break;
      case 66: // Shyness
        tryBroadcastSocial(15);
        break;
      case 87: // Propose
        tryBroadcastSocial(28);
        break;
      case 88: // Provoke
        tryBroadcastSocial(29);
        break;
      case 89: // Beauty Shop
        tryBroadcastSocial(30);
        activeChar.broadcastInfo();
        break;
      default:
        _log.warning(activeChar.getName() + ": unhandled action type " + _actionId);
        break;
    }
  }
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
   if (tmpworld instanceof DNPWorld) {
     final DNPWorld world = (DNPWorld) tmpworld;
     switch (event) {
       case "FINISH":
         {
           if (getQuestItemsCount(player, SEAL_OF_BINDING) >= 4) {
             player.showQuestMovie(13);
             startQuestTimer("TELEPORT", 27000, null, player);
           }
           break;
         }
       case "TELEPORT":
         {
           player.teleToLocation(ENTER, 0);
           break;
         }
       case "FIGHT":
         {
           for (L2Npc caster : world.anakimGroup) {
             if ((caster != null) && !caster.isCastingNow()) {
               makeCast(caster, world.lilithGroup);
             }
             if ((caster != null) && (caster.getId() == ANAKIM)) {
               if (caster.isScriptValue(0)) {
                 caster.broadcastPacket(
                     new NpcSay(
                         caster.getObjectId(),
                         Say2.NPC_SHOUT,
                         caster.getId(),
                         NpcStringId
                             .YOU_SUCH_A_FOOL_THE_VICTORY_OVER_THIS_WAR_BELONGS_TO_SHILIEN));
                 caster.setScriptValue(1);
               } else if (getRandom(100) < 10) {
                 caster.broadcastPacket(
                     new NpcSay(
                         caster.getObjectId(),
                         Say2.NPC_SHOUT,
                         caster.getId(),
                         LILITH_SHOUT[getRandom(3)]));
               }
             }
           }
           for (L2Npc caster : world.lilithGroup) {
             if ((caster != null) && !caster.isCastingNow()) {
               makeCast(caster, world.anakimGroup);
             }
             if ((caster != null) && (caster.getId() == 32715)) {
               if (caster.isScriptValue(0)) {
                 caster.broadcastPacket(
                     new NpcSay(
                         caster.getObjectId(),
                         Say2.NPC_SHOUT,
                         caster.getId(),
                         NpcStringId.FOR_THE_ETERNITY_OF_EINHASAD));
                 if (Util.checkIfInRange(2000, caster, player, true)) {
                   player.sendPacket(
                       new NpcSay(
                           caster.getObjectId(),
                           Say2.TELL,
                           caster.getId(),
                           NpcStringId.MY_POWERS_WEAKENING_HURRY_AND_TURN_ON_THE_SEALING_DEVICE));
                 }
                 caster.setScriptValue(1);
               } else if (getRandom(100) < 10) {
                 switch (getRandom(3)) {
                   case 0:
                     {
                       caster.broadcastPacket(
                           new NpcSay(
                               caster.getObjectId(),
                               Say2.NPC_SHOUT,
                               caster.getId(),
                               NpcStringId
                                   .DEAR_SHILLIENS_OFFSPRINGS_YOU_ARE_NOT_CAPABLE_OF_CONFRONTING_US));
                       if (Util.checkIfInRange(2000, caster, player, true)) {
                         player.sendPacket(
                             new NpcSay(
                                 caster.getObjectId(),
                                 Say2.TELL,
                                 caster.getId(),
                                 NpcStringId.ALL_4_SEALING_DEVICES_MUST_BE_TURNED_ON));
                       }
                       break;
                     }
                   case 1:
                     {
                       caster.broadcastPacket(
                           new NpcSay(
                               caster.getObjectId(),
                               Say2.NPC_SHOUT,
                               caster.getId(),
                               NpcStringId.ILL_SHOW_YOU_THE_REAL_POWER_OF_EINHASAD));
                       if (Util.checkIfInRange(2000, caster, player, true)) {
                         player.sendPacket(
                             new NpcSay(
                                 caster.getObjectId(),
                                 Say2.TELL,
                                 caster.getId(),
                                 NpcStringId
                                     .LILITHS_ATTACK_IS_GETTING_STRONGER_GO_AHEAD_AND_TURN_IT_ON));
                       }
                       break;
                     }
                   case 2:
                     {
                       caster.broadcastPacket(
                           new NpcSay(
                               caster.getObjectId(),
                               Say2.NPC_SHOUT,
                               caster.getId(),
                               NpcStringId
                                   .DEAR_MILITARY_FORCE_OF_LIGHT_GO_DESTROY_THE_OFFSPRINGS_OF_SHILLIEN));
                       if (Util.checkIfInRange(2000, caster, player, true)) {
                         player.sendPacket(
                             new NpcSay(
                                     caster.getObjectId(),
                                     Say2.TELL,
                                     caster.getId(),
                                     NpcStringId.DEAR_S1_GIVE_ME_MORE_STRENGTH)
                                 .addStringParameter(player.getName()));
                       }
                       break;
                     }
                 }
               }
             }
             startQuestTimer("FIGHT", 1000, null, player);
           }
           break;
         }
     }
   }
   return super.onAdvEvent(event, npc, player);
 }
  @Override
  protected void runImpl() {
    L2PcInstance player = getActiveChar();
    if (player == null) {
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Transactions are disabled for your current Access Level.");
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    BuffInfo info = player.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(BotReportTable.TRADE_ACTION_BLOCK_ID)) {
          player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_SO_ACTIONS_NOT_ALLOWED);
          player.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    final L2Object target = L2World.getInstance().findObject(_objectId);
    // If there is no target, target is far away or
    // they are in different instances (except multiverse)
    // trade request is ignored and there is no system message.
    if ((target == null)
        || !player.getKnownList().knowsObject(target)
        || ((target.getInstanceId() != player.getInstanceId()) && (player.getInstanceId() != -1))) {
      return;
    }

    // If target and acting player are the same, trade request is ignored
    // and the following system message is sent to acting player.
    if (target.getObjectId() == player.getObjectId()) {
      player.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
      return;
    }

    if (!target.isPlayer()) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      return;
    }

    final L2PcInstance partner = target.getActingPlayer();
    if (partner.isInOlympiadMode() || player.isInOlympiadMode()) {
      player.sendMessage(
          "A user currently participating in the Olympiad cannot accept or request a trade.");
      return;
    }

    info = partner.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(BotReportTable.TRADE_ACTION_BLOCK_ID)) {
          final SystemMessage sm =
              SystemMessage.getSystemMessage(SystemMessageId.C1_REPORTED_AND_IS_BEING_INVESTIGATED);
          sm.addCharName(partner);
          player.sendPacket(sm);
          player.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    // L2J Customs: Karma punishment
    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0)) {
      player.sendMessage("You cannot trade while you are in a chaotic state.");
      return;
    }

    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (partner.getKarma() > 0)) {
      player.sendMessage("You cannot request a trade while your target is in a chaotic state.");
      return;
    }

    if (Config.JAIL_DISABLE_TRANSACTION && (player.isJailed() || partner.isJailed())) {
      player.sendMessage("You cannot trade while you are in in Jail.");
      return;
    }

    if ((player.getPrivateStoreType() != PrivateStoreType.NONE)
        || (partner.getPrivateStoreType() != PrivateStoreType.NONE)) {
      player.sendPacket(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE);
      return;
    }

    if (player.isProcessingTransaction()) {
      if (Config.DEBUG) {
        _log.fine("Already trading with someone else.");
      }
      player.sendPacket(SystemMessageId.ALREADY_TRADING);
      return;
    }

    SystemMessage sm;
    if (partner.isProcessingRequest() || partner.isProcessingTransaction()) {
      if (Config.DEBUG) {
        _log.info("Transaction already in progress.");
      }
      sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_BUSY_TRY_LATER);
      sm.addString(partner.getName());
      player.sendPacket(sm);
      return;
    }

    if (partner.getTradeRefusal()) {
      player.sendMessage("That person is in trade refusal mode.");
      return;
    }

    if (BlockList.isBlocked(partner, player)) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST);
      sm.addCharName(partner);
      player.sendPacket(sm);
      return;
    }

    if (player.calculateDistance(partner, true, false) > 150) {
      player.sendPacket(SystemMessageId.TARGET_TOO_FAR);
      return;
    }

    player.onTransactionRequest(partner);
    partner.sendPacket(new SendTradeRequest(player.getObjectId()));
    sm = SystemMessage.getSystemMessage(SystemMessageId.REQUEST_C1_FOR_TRADE);
    sm.addString(partner.getName());
    player.sendPacket(sm);
  }
예제 #28
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final Castle castle = npc.getCastle();
    final StringTokenizer st = new StringTokenizer(event, " ");
    String htmltext = null;
    switch (st.nextToken()) {
      case "chamberlain-01.html":
      case "manor-help-01.html":
      case "manor-help-02.html":
      case "manor-help-03.html":
      case "manor-help-04.html":
        {
          htmltext = event;
          break;
        }
      case "fort_status":
        {
          if (npc.isMyLord(player)) {
            final StringBuilder sb = new StringBuilder();
            final List<Integer> fort = FORTRESS.get(castle.getResidenceId());
            for (int id : fort) {
              final Fort fortress = FortManager.getInstance().getFortById(id);
              final int fortId = fortress.getResidenceId();
              final String fortType = (fortId < 112) ? "1300133" : "1300134";
              final String fortStatus;
              switch (fortress.getFortState()) {
                case 1:
                  fortStatus = "1300122";
                  break;
                case 2:
                  fortStatus = "1300124";
                  break;
                default:
                  fortStatus = "1300123";
                  break;
              }
              sb.append("<fstring>1300" + fortId + "</fstring>");
              sb.append(" (<fstring>" + fortType + "</fstring>)");
              sb.append(
                  " : <font color=\"00FFFF\"><fstring>" + fortStatus + "</fstring></font><br>");
            }
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-28.html");
            html.replace("%list%", sb.toString());
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "siege_functions":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else if (!isDomainFortressInContractStatus(castle.getResidenceId())) {
              htmltext = "chamberlain-27.html";
            } else if (!SevenSigns.getInstance().isCompResultsPeriod()) {
              htmltext = "chamberlain-26.html";
            } else {
              htmltext = "chamberlain-12.html";
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manage_doors":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            if (st.hasMoreTokens()) {
              final StringBuilder sb = new StringBuilder();
              final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-13.html");
              html.replace("%type%", st.nextToken());
              while (st.hasMoreTokens()) {
                sb.append(" " + st.nextToken());
              }
              html.replace("%doors%", sb.toString());
              player.sendPacket(html);
            } else {
              htmltext = npc.getId() + "-du.html";
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "upgrade_doors":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            final int type = Integer.parseInt(st.nextToken());
            final int level = Integer.parseInt(st.nextToken());
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-14.html");
            html.replace("%gate_price%", Integer.toString(getDoorUpgradePrice(type, level)));
            html.replace("%event%", event.substring("upgrade_doors".length() + 1));
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "upgrade_doors_confirm":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              final int type = Integer.parseInt(st.nextToken());
              final int level = Integer.parseInt(st.nextToken());
              final int price = getDoorUpgradePrice(type, level);
              final int[] doors = new int[2];
              for (int i = 0; i <= st.countTokens(); i++) {
                doors[i] = Integer.parseInt(st.nextToken());
              }

              final L2DoorInstance door = castle.getDoor(doors[0]);
              if (door != null) {
                final int currentLevel = door.getStat().getUpgradeHpRatio();
                if (currentLevel >= level) {
                  final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-15.html");
                  html.replace("%doorlevel%", Integer.toString(currentLevel));
                  player.sendPacket(html);
                } else if (player.getAdena() >= price) {
                  takeItems(player, Inventory.ADENA_ID, price);
                  for (int doorId : doors) {
                    castle.setDoorUpgrade(doorId, level, true);
                  }
                  htmltext = "chamberlain-16.html";
                } else {
                  htmltext = "chamberlain-09.html";
                }
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manage_trap":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            if (st.hasMoreTokens()) {
              final NpcHtmlMessage html;
              if (castle.getName().equalsIgnoreCase("aden")) {
                html = getHtmlPacket(player, npc, "chamberlain-17a.html");
              } else {
                html = getHtmlPacket(player, npc, "chamberlain-17.html");
              }
              html.replace("%trapIndex%", st.nextToken());
              player.sendPacket(html);
            } else {
              htmltext = npc.getId() + "-tu.html";
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "upgrade_trap":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            final String trapIndex = st.nextToken();
            final int level = Integer.parseInt(st.nextToken());
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-18.html");
            html.replace("%trapIndex%", trapIndex);
            html.replace("%level%", Integer.toString(level));
            html.replace("%dmgzone_price%", Integer.toString(getTrapUpgradePrice(level)));
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "upgrade_trap_confirm":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              final int trapIndex = Integer.parseInt(st.nextToken());
              final int level = Integer.parseInt(st.nextToken());
              final int price = getTrapUpgradePrice(level);
              final int currentLevel = castle.getTrapUpgradeLevel(trapIndex);

              if (currentLevel >= level) {
                final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-19.html");
                html.replace("%dmglevel%", Integer.toString(currentLevel));
                player.sendPacket(html);
              } else if (player.getAdena() >= price) {
                takeItems(player, Inventory.ADENA_ID, price);
                castle.setTrapUpgrade(trapIndex, level, true);
                htmltext = "chamberlain-20.html";
              } else {
                htmltext = "chamberlain-09.html";
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "receive_report":
        {
          if (npc.isMyLord(player)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-07.html";
            } else {
              final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
              final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-02.html");
              html.replace("%clanleadername%", clan.getLeaderName());
              html.replace("%clanname%", clan.getName());
              html.replace("%castlename%", String.valueOf(1001000 + castle.getResidenceId()));

              switch (SevenSigns.getInstance().getCurrentPeriod()) {
                case SevenSigns.PERIOD_COMP_RECRUITING:
                  html.replace("%ss_event%", "1000509");
                  break;
                case SevenSigns.PERIOD_COMPETITION:
                  html.replace("%ss_event%", "1000507");
                  break;
                case SevenSigns.PERIOD_SEAL_VALIDATION:
                case SevenSigns.PERIOD_COMP_RESULTS:
                  html.replace("%ss_event%", "1000508");
                  break;
              }
              html.replace("%ss_avarice%", getSealOwner(1));
              html.replace("%ss_gnosis%", getSealOwner(2));
              html.replace("%ss_strife%", getSealOwner(3));
              player.sendPacket(html);
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manage_tax":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlesettaxrate.html");
              html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent()));
              html.replace("%next_tax_rate%", "0"); // TODO: Implement me!
              html.replace("%tax_limit%", Integer.toString(getTaxLimit()));
              player.sendPacket(html);
            }
          } else if (isOwner(player, npc)) {
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-03.html");
            html.replace("%tax_rate%", Integer.toString(castle.getTaxPercent()));
            html.replace("%next_tax_rate%", "0"); // TODO: Implement me!
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "set_tax":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              final NpcHtmlMessage html;
              final int tax = (st.hasMoreTokens()) ? Integer.parseInt(st.nextToken()) : 0;
              final int taxLimit = getTaxLimit();
              if (tax > taxLimit) {
                html = getHtmlPacket(player, npc, "castletoohightaxrate.html");
                html.replace("%tax_limit%", Integer.toString(taxLimit));
              } else {
                castle.setTaxPercent(tax);
                html = getHtmlPacket(player, npc, "castleaftersettaxrate.html");
                html.replace("%next_tax_rate%", Integer.toString(tax));
              }
              player.sendPacket(html);
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manage_vault":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) {
            long seedIncome = 0;
            if (Config.ALLOW_MANOR) {
              for (SeedProduction sp :
                  CastleManorManager.getInstance()
                      .getSeedProduction(castle.getResidenceId(), false)) {
                final long diff = sp.getStartAmount() - sp.getAmount();
                if (diff != 0) {
                  seedIncome += diff * sp.getPrice();
                }
              }
            }

            final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlemanagevault.html");
            html.replace("%tax_income%", Util.formatAdena(castle.getTreasury()));
            html.replace("%tax_income_reserved%", "0"); // TODO: Implement me!
            html.replace("%seed_income%", Util.formatAdena(seedIncome));
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "deposit":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) {
            final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0;
            if ((amount > 0) && (amount < Inventory.MAX_ADENA)) {
              if (player.getAdena() >= amount) {
                takeItems(player, Inventory.ADENA_ID, amount);
                castle.addToTreasuryNoTax(amount);
              } else {
                player.sendPacket(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
              }
            }
            htmltext = "chamberlain-01.html";
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "withdraw":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES)) {
            final long amount = (st.hasMoreTokens()) ? Long.parseLong(st.nextToken()) : 0;
            if (amount <= castle.getTreasury()) {
              castle.addToTreasuryNoTax((-1) * amount);
              giveAdena(player, amount, false);
              htmltext = "chamberlain-01.html";
            } else {
              final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlenotenoughbalance.html");
              html.replace("%tax_income%", Util.formatAdena(castle.getTreasury()));
              html.replace("%withdraw_amount%", Util.formatAdena(amount));
              player.sendPacket(html);
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manage_functions":
        {
          if (!isOwner(player, npc)) {
            htmltext = "chamberlain-21.html";
          } else if (castle.getSiege().isInProgress()) {
            htmltext = "chamberlain-08.html";
          } else {
            htmltext = "chamberlain-23.html";
          }
          break;
        }
      case "banish_foreigner_show":
        {
          if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) {
            htmltext = "chamberlain-21.html";
          } else if (castle.getSiege().isInProgress()) {
            htmltext = "chamberlain-08.html";
          } else {
            htmltext = "chamberlain-10.html";
          }
          break;
        }
      case "banish_foreigner":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_DISMISS)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              castle.banishForeigners();
              htmltext = "chamberlain-11.html";
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "doors":
        {
          if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) {
            htmltext = "chamberlain-21.html";
          } else if (castle.getSiege().isInProgress()) {
            htmltext = "chamberlain-08.html";
          } else {
            htmltext = npc.getId() + "-d.html";
          }
          break;
        }
      case "operate_door":
        {
          if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_OPEN_DOOR)) {
            htmltext = "chamberlain-21.html";
          } else if (castle.getSiege().isInProgress()) {
            htmltext = "chamberlain-08.html";
          } else {
            final boolean open = (Integer.parseInt(st.nextToken()) == 1);
            while (st.hasMoreTokens()) {
              castle.openCloseDoor(player, Integer.parseInt(st.nextToken()), open);
            }
            htmltext = (open ? "chamberlain-05.html" : "chamberlain-06.html");
          }
          break;
        }
      case "additional_functions":
        {
          htmltext =
              (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS))
                  ? "castletdecomanage.html"
                  : "chamberlain-21.html";
          break;
        }
      case "recovery":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AR01.html");
            funcReplace(castle, html, Castle.FUNC_RESTORE_HP, "HP");
            funcReplace(castle, html, Castle.FUNC_RESTORE_MP, "MP");
            funcReplace(castle, html, Castle.FUNC_RESTORE_EXP, "XP");
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "other":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledeco-AE01.html");
            funcReplace(castle, html, Castle.FUNC_TELEPORT, "TP");
            funcReplace(castle, html, Castle.FUNC_SUPPORT, "BF");
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "HP":
        {
          final int level = Integer.parseInt(st.nextToken());
          htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_HP, level);
          break;
        }
      case "MP":
        {
          final int level = Integer.parseInt(st.nextToken());
          htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_MP, level);
          break;
        }
      case "XP":
        {
          final int level = Integer.parseInt(st.nextToken());
          htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_RESTORE_EXP, level);
          break;
        }
      case "TP":
        {
          final int level = Integer.parseInt(st.nextToken());
          htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_TELEPORT, level);
          break;
        }
      case "BF":
        {
          final int level = Integer.parseInt(st.nextToken());
          htmltext = funcConfirmHtml(player, npc, castle, Castle.FUNC_SUPPORT, level);
          break;
        }
      case "set_func":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
            final int func = Integer.parseInt(st.nextToken());
            final int level = Integer.parseInt(st.nextToken());
            if (level == 0) {
              castle.updateFunctions(player, func, level, 0, 0, false);
            } else if (!castle.updateFunctions(
                player,
                func,
                level,
                getFunctionFee(func, level),
                getFunctionRatio(func),
                castle.getFunction(func) == null)) {
              htmltext = "chamberlain-09.html";
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "functions":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            final CastleFunction HP = castle.getFunction(Castle.FUNC_RESTORE_HP);
            final CastleFunction MP = castle.getFunction(Castle.FUNC_RESTORE_MP);
            final CastleFunction XP = castle.getFunction(Castle.FUNC_RESTORE_EXP);
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "castledecofunction.html");
            html.replace("%HPDepth%", (HP == null) ? "0" : Integer.toString(HP.getLvl()));
            html.replace("%MPDepth%", (MP == null) ? "0" : Integer.toString(MP.getLvl()));
            html.replace("%XPDepth%", (XP == null) ? "0" : Integer.toString(XP.getLvl()));
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "teleport":
        {
          if (!isOwner(player, npc) || !player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            htmltext = "chamberlain-21.html";
          } else if (castle.getFunction(Castle.FUNC_TELEPORT) == null) {
            htmltext = "castlefuncdisabled.html";
          } else {
            htmltext =
                npc.getId() + "-t" + castle.getFunction(Castle.FUNC_TELEPORT).getLvl() + ".html";
          }
          break;
        }
      case "goto":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            final int locId = Integer.parseInt(st.nextToken());
            final L2TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(locId);
            if (list != null) {
              if (takeItems(player, list.getItemId(), list.getPrice())) {
                player.teleToLocation(list.getLocX(), list.getLocY(), list.getLocZ());
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "buffer":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            if (castle.getFunction(Castle.FUNC_SUPPORT) == null) {
              htmltext = "castlefuncdisabled.html";
            } else {
              final NpcHtmlMessage html =
                  getHtmlPacket(
                      player,
                      npc,
                      "castlebuff-0" + castle.getFunction(Castle.FUNC_SUPPORT).getLvl() + ".html");
              html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp()));
              player.sendPacket(html);
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "cast_buff":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            if (castle.getFunction(Castle.FUNC_SUPPORT) == null) {
              htmltext = "castlefuncdisabled.html";
            } else {
              final int index = Integer.parseInt(st.nextToken());
              if (BUFFS.length > index) {
                final NpcHtmlMessage html;
                final SkillHolder holder = BUFFS[index];
                if (holder.getSkill().getMpConsume() < npc.getCurrentMp()) {
                  npc.setTarget(player);
                  npc.doCast(holder.getSkill());
                  html = getHtmlPacket(player, npc, "castleafterbuff.html");
                } else {
                  html = getHtmlPacket(player, npc, "castlenotenoughmp.html");
                }

                html.replace("%MPLeft%", Integer.toString((int) npc.getCurrentMp()));
                player.sendPacket(html);
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "list_siege_clans":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) {
            castle.getSiege().listRegisterClan(player);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "list_territory_clans":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANAGE_SIEGE)) {
            player.sendPacket(new ExShowDominionRegistry(castle.getResidenceId(), player));
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manor":
        {
          if (Config.ALLOW_MANOR) {
            htmltext =
                (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN))
                    ? "manor.html"
                    : "chamberlain-21.html";
          } else {
            player.sendMessage("Manor system is deactivated.");
          }
          break;
        }
      case "products":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-22.html");
            html.replace("%npcId%", Integer.toString(npc.getId()));
            player.sendPacket(html);
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "buy":
        {
          if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_USE_FUNCTIONS)) {
            ((L2MerchantInstance) npc).showBuyWindow(player, Integer.parseInt(st.nextToken()));
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "give_crown":
        {
          if (castle.getSiege().isInProgress()) {
            htmltext = "chamberlain-08.html";
          } else if (npc.isMyLord(player)) {
            if (hasQuestItems(player, CROWN)) {
              htmltext = "chamberlain-24.html";
            } else {
              final NpcHtmlMessage html = getHtmlPacket(player, npc, "chamberlain-25.html");
              html.replace("%owner_name%", String.valueOf(player.getName()));
              html.replace(
                  "%feud_name%", String.valueOf(String.valueOf(1001000 + castle.getResidenceId())));
              player.sendPacket(html);
              giveItems(player, CROWN, 1);
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manors_cert":
        {
          if (npc.isMyLord(player)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId())
                      == SevenSigns.CABAL_DAWN)
                  && SevenSigns.getInstance().isCompetitionPeriod()) {
                final int ticketCount = castle.getTicketBuyCount();
                if (ticketCount
                    < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) {
                  final NpcHtmlMessage html = getHtmlPacket(player, npc, "ssq_selldawnticket.html");
                  html.replace(
                      "%DawnTicketLeft%",
                      String.valueOf(
                          Config.SSQ_DAWN_TICKET_QUANTITY
                              - (ticketCount * Config.SSQ_DAWN_TICKET_BUNDLE)));
                  html.replace("%DawnTicketBundle%", String.valueOf(Config.SSQ_DAWN_TICKET_BUNDLE));
                  html.replace(
                      "%DawnTicketPrice%",
                      String.valueOf(Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE));
                  player.sendPacket(html);
                } else {
                  htmltext = "ssq_notenoughticket.html";
                }
              } else {
                htmltext = "ssq_notdawnorevent.html";
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
      case "manors_cert_confirm":
        {
          if (npc.isMyLord(player)) {
            if (castle.getSiege().isInProgress()) {
              htmltext = "chamberlain-08.html";
            } else {
              if ((SevenSigns.getInstance().getPlayerCabal(player.getObjectId())
                      == SevenSigns.CABAL_DAWN)
                  && SevenSigns.getInstance().isCompetitionPeriod()) {
                final int ticketCount = castle.getTicketBuyCount();
                if (ticketCount
                    < (Config.SSQ_DAWN_TICKET_QUANTITY / Config.SSQ_DAWN_TICKET_BUNDLE)) {
                  final long totalCost =
                      Config.SSQ_DAWN_TICKET_PRICE * Config.SSQ_DAWN_TICKET_BUNDLE;
                  if (player.getAdena() >= totalCost) {
                    takeItems(player, Inventory.ADENA_ID, totalCost);
                    giveItems(
                        player, Config.SSQ_MANORS_AGREEMENT_ID, Config.SSQ_DAWN_TICKET_BUNDLE);
                    castle.setTicketBuyCount(ticketCount + 1);
                  } else {
                    htmltext = "chamberlain-09.html";
                  }
                } else {
                  htmltext = "ssq_notenoughticket.html";
                }
              } else {
                htmltext = "ssq_notdawnorevent.html";
              }
            }
          } else {
            htmltext = "chamberlain-21.html";
          }
          break;
        }
    }
    return htmltext;
  }
예제 #29
0
 public final void addName(L2PcInstance player) {
   if (player != null) {
     addName(player.getObjectId(), player.getName());
     _accessLevels.put(player.getObjectId(), player.getAccessLevel().getLevel());
   }
 }
예제 #30
0
파일: Duel.java 프로젝트: 3mRe/L2Java
  /**
   * The duel has reached a state in which it can no longer continue
   *
   * @param result the duel result.
   */
  public void endDuel(DuelResult result) {
    if ((_playerA == null) || (_playerB == null)) {
      // clean up
      _playerConditions.clear();
      DuelManager.getInstance().removeDuel(this);
      return;
    }

    // inform players of the result
    SystemMessage sm = null;
    switch (result) {
      case Team1Win:
      case Team2Surrender:
        restorePlayerConditions(false);
        // send SystemMessage
        if (_partyDuel) {
          sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL);
        } else {
          sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
        }
        sm.addString(_playerA.getName());

        broadcastToTeam1(sm);
        broadcastToTeam2(sm);
        break;
      case Team1Surrender:
      case Team2Win:
        restorePlayerConditions(false);
        // send SystemMessage
        if (_partyDuel) {
          sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL);
        } else {
          sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
        }
        sm.addString(_playerB.getName());

        broadcastToTeam1(sm);
        broadcastToTeam2(sm);
        break;
      case Canceled:
        stopFighting();
        // Don't restore hp, mp, cp
        restorePlayerConditions(true);
        // TODO: is there no other message for a canceled duel?
        // send SystemMessage
        sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_HAS_ENDED_IN_A_TIE);

        broadcastToTeam1(sm);
        broadcastToTeam2(sm);
        break;
      case Timeout:
        stopFighting();
        // hp,mp,cp seem to be restored in a timeout too...
        restorePlayerConditions(false);
        // send SystemMessage
        sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_HAS_ENDED_IN_A_TIE);

        broadcastToTeam1(sm);
        broadcastToTeam2(sm);
        break;
    }

    final ExDuelEnd duelEnd = _partyDuel ? ExDuelEnd.PARTY_DUEL : ExDuelEnd.PLAYER_DUEL;
    broadcastToTeam1(duelEnd);
    broadcastToTeam2(duelEnd);

    // clean up
    _playerConditions.clear();
    DuelManager.getInstance().removeDuel(this);
  }