/**
   * 道具执行
   *
   * @param data 参数
   * @param pc 对象
   * @param item 道具
   */
  @Override
  public void execute(final int[] data, final L1PcInstance pc, final L1ItemInstance item) {

    final int itemId = item.getItemId();
    final int itemobj = data[0];
    final L1ItemInstance l1iteminstance1 = pc.getInventory().getItem(itemobj);
    final int logbookId = l1iteminstance1.getItem().getItemId();

    if (logbookId == (itemId + 8034)) {
      pc.createNewItem(pc, 41058, 1);
      pc.getInventory().removeItem(l1iteminstance1, 1);
      pc.getInventory().removeItem(item, 1);
    } else {
      pc.sendPackets(new S_ServerMessage(79)); // \f1没有任何事情发生。
    }
  }
  /**
   * 道具执行
   *
   * @param data 参数
   * @param pc 对象
   * @param item 道具
   */
  @Override
  public void execute(final int[] data, final L1PcInstance pc, final L1ItemInstance item) {

    final int itemobj = data[0];
    final L1ItemInstance l1iteminstance1 = pc.getInventory().getItem(itemobj);
    final int historybookId = l1iteminstance1.getItem().getItemId();

    // 封印的历史书1~8页
    if ((historybookId >= 41011) && (41018 >= historybookId)) {
      if ((Random.nextInt(99) + 1) <= Config.CREATE_CHANCE_HISTORY_BOOK) {
        pc.createNewItem(pc, historybookId + 8, 1);
      } else {
        pc.sendPackets(new S_ServerMessage(158, l1iteminstance1.getName())); // \f1%0%s 消失。
      }
      pc.getInventory().removeItem(l1iteminstance1, 1);
      pc.getInventory().removeItem(item, 1);
    } else {
      pc.sendPackets(new S_ServerMessage(79)); // \f1没有任何事情发生。
    }
  }
  /**
   * 道具执行
   *
   * @param data 参数
   * @param pc 对象
   * @param item 道具
   */
  @Override
  public void execute(final int[] data, final L1PcInstance pc, final L1ItemInstance item) {

    // 伊娃圣水
    if (pc.hasSkillEffect(STATUS_HOLY_WATER_OF_EVA)) {
      pc.sendPackets(new S_ServerMessage(79)); // \f1没有任何事情发生。
      return;
    }

    // 删除圣水状态
    if (pc.hasSkillEffect(STATUS_HOLY_WATER)) {
      pc.removeSkillEffect(STATUS_HOLY_WATER);
    }

    pc.setSkillEffect(STATUS_HOLY_MITHRIL_POWDER, 900 * 1000);
    pc.sendPackets(new S_SkillSound(pc.getId(), 190));
    pc.broadcastPacket(new S_SkillSound(pc.getId(), 190));
    pc.sendPackets(new S_ServerMessage(1142)); // 你得到可以攻击哈蒙将军的力量。
    pc.getInventory().removeItem(item, 1);
  }
  /**
   * 道具物件执行
   *
   * @param data 参数
   * @param pc 执行者
   * @param item 物件
   */
  @Override
  public void execute(final int[] data, final L1PcInstance pc, final L1ItemInstance item) {

    // 不能变身的状态
    // 取回觉醒技能ID
    final int awakeSkillId = pc.getAwakeSkillId();
    if ((awakeSkillId == AWAKEN_ANTHARAS)
        || (awakeSkillId == AWAKEN_FAFURION)
        || (awakeSkillId == AWAKEN_VALAKAS)) {
      pc.sendPackets(new S_ServerMessage(1384)); // 目前状态中无法变身。
      return;
    }

    // 变身时间 (秒)与变身编号
    final short time = 900;
    final short polyId = 3888; // 小巴 (巴风特)

    L1PolyMorph.doPoly(pc, polyId, time, L1PolyMorph.MORPH_BY_ITEMMAGIC);

    // 删除道具
    pc.getInventory().removeItem(item, 1);
  }
Exemple #5
0
  public C_Shop(final byte abyte0[], final ClientThread clientthread) {
    super(abyte0);

    final L1PcInstance pc = clientthread.getActiveChar();
    if (pc.isGhost()) {
      return;
    }

    final int mapId = pc.getMapId();
    // 可以开设个人商店的地图
    if ((mapId != 340 // 古鲁丁商店村
        )
        && (mapId != 350 // 奇岩商店村
        )
        && (mapId != 360 // 欧瑞商店村
        )
        && (mapId != 370 // 银骑士商店村
        )) {
      pc.sendPackets(new S_ServerMessage(876)); // 无法在此开设个人商店。
      return;
    }

    final List<L1PrivateShopSellList> sellList = pc.getSellList();
    final List<L1PrivateShopBuyList> buyList = pc.getBuyList();
    L1ItemInstance checkItem;
    boolean tradable = true;

    final int type = this.readC();
    if (type == 0) { // 开始
      final int sellTotalCount = this.readH();
      int sellObjectId;
      int sellPrice;
      int sellCount;
      for (int i = 0; i < sellTotalCount; i++) {
        sellObjectId = this.readD();
        sellPrice = this.readD();
        sellCount = this.readD();
        // 检查交易项目
        checkItem = pc.getInventory().getItem(sellObjectId);
        if (!checkItem.getItem().isTradable()) {
          tradable = false;
          pc.sendPackets(
              new S_ServerMessage(
                  166, // \f1%0%s %4%1%3
                  // %2。
                  checkItem.getItem().getName(),
                  "这是不可能处理。"));
        }
        for (final L1NpcInstance petNpc : pc.getPetList().values()) {
          if (petNpc instanceof L1PetInstance) {
            final L1PetInstance pet = (L1PetInstance) petNpc;
            if (checkItem.getId() == pet.getItemObjId()) {
              tradable = false;
              pc.sendPackets(
                  new S_ServerMessage(
                      166, // \f1%0%s
                      // %4%1%3
                      // %2。
                      checkItem.getItem().getName(),
                      "这是不可能处理。"));
              break;
            }
          }
        }
        final L1PrivateShopSellList pssl = new L1PrivateShopSellList();
        pssl.setItemObjectId(sellObjectId);
        pssl.setSellPrice(sellPrice);
        pssl.setSellTotalCount(sellCount);
        sellList.add(pssl);
      }
      final int buyTotalCount = this.readH();
      int buyObjectId;
      int buyPrice;
      int buyCount;
      for (int i = 0; i < buyTotalCount; i++) {
        buyObjectId = this.readD();
        buyPrice = this.readD();
        buyCount = this.readD();
        // 检查交易项目
        checkItem = pc.getInventory().getItem(buyObjectId);
        if (!checkItem.getItem().isTradable()) {
          tradable = false;
          pc.sendPackets(
              new S_ServerMessage(
                  166, // \f1%0%s %4%1%3
                  // %2。
                  checkItem.getItem().getName(),
                  "这是不可能处理。"));
        }

        // 封印的装备
        if (checkItem.getBless() >= 128) { // 封印的装备
          // \f1%0%d是不可转移的…
          pc.sendPackets(new S_ServerMessage(210, checkItem.getItem().getName()));
          return;
        }

        // 防止异常堆叠交易
        if ((checkItem.getCount() > 1) && (!checkItem.getItem().isStackable())) {
          pc.sendPackets(new S_SystemMessage("此物品非堆叠,但异常堆叠无法交易。"));
          return;
        }

        // 使用中的宠物项链 - 无法贩卖
        for (final L1NpcInstance petNpc : pc.getPetList().values()) {
          if (petNpc instanceof L1PetInstance) {
            final L1PetInstance pet = (L1PetInstance) petNpc;
            if (checkItem.getId() == pet.getItemObjId()) {
              tradable = false;
              pc.sendPackets(new S_ServerMessage(1187)); // 宠物项链正在使用中。
              break;
            }
          }
        }

        // 使用中的魔法娃娃 - 无法贩卖
        for (final L1DollInstance doll : pc.getDollList().values()) {
          if (doll.getItemObjId() == checkItem.getId()) {
            tradable = false;
            pc.sendPackets(new S_ServerMessage(1181)); // 这个魔法娃娃目前正在使用中。
            break;
          }
        }
        final L1PrivateShopBuyList psbl = new L1PrivateShopBuyList();
        psbl.setItemObjectId(buyObjectId);
        psbl.setBuyPrice(buyPrice);
        psbl.setBuyTotalCount(buyCount);
        buyList.add(psbl);
      }
      if (!tradable) { // 如果项目不包括在交易结束零售商
        sellList.clear();
        buyList.clear();
        pc.setPrivateShop(false);
        pc.sendPackets(new S_DoActionGFX(pc.getId(), ActionCodes.ACTION_Idle));
        pc.broadcastPacket(new S_DoActionGFX(pc.getId(), ActionCodes.ACTION_Idle));
        return;
      }
      final byte[] chat = this.readByte();
      pc.setShopChat(chat);
      pc.setPrivateShop(true);
      pc.sendPackets(new S_DoActionShop(pc.getId(), ActionCodes.ACTION_Shop, chat));
      pc.broadcastPacket(new S_DoActionShop(pc.getId(), ActionCodes.ACTION_Shop, chat));
    } else if (type == 1) { // 终了
      sellList.clear();
      buyList.clear();
      pc.setPrivateShop(false);
      pc.sendPackets(new S_DoActionGFX(pc.getId(), ActionCodes.ACTION_Idle));
      pc.broadcastPacket(new S_DoActionGFX(pc.getId(), ActionCodes.ACTION_Idle));
    }
  }