Exemplo n.º 1
0
  /**
   * This method displays EnchantSkillList to the player.
   *
   * @param player The player who requested the method.
   * @param npc The L2Npc linked to the request.
   * @param classId The classId asked. Used to sort available enchant skill list.
   */
  public static void showEnchantSkillList(L2PcInstance player, L2Npc npc, ClassId classId) {
    if (((L2NpcInstance) npc).getClassesToTeach() == null) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      final String sb =
          StringUtil.concat(
              "<html><body>I cannot teach you. My class list is empty.<br>Your admin needs to add me teachTo informations.<br>NpcId:",
              String.valueOf(npc.getTemplate().getNpcId()),
              ", your classId:",
              String.valueOf(player.getClassId().getId()),
              "</body></html>");
      html.setHtml(sb);
      player.sendPacket(html);
      return;
    }

    if (!npc.getTemplate().canTeach(classId)) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile("data/html/trainer/" + npc.getTemplate().getNpcId() + "-noskills.htm");
      player.sendPacket(html);
      return;
    }

    if (player.getClassId().level() < 3) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setHtml("<html><body> You must have 3rd class change quest completed.</body></html>");
      player.sendPacket(html);
      return;
    }

    ExEnchantSkillList esl = new ExEnchantSkillList();
    boolean empty = true;

    List<L2EnchantSkillLearn> esll = SkillTreeTable.getInstance().getAvailableEnchantSkills(player);
    for (L2EnchantSkillLearn skill : esll) {
      L2Skill sk = SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel());
      if (sk == null) continue;

      L2EnchantSkillData data =
          SkillTreeTable.getInstance().getEnchantSkillData(skill.getEnchant());
      if (data == null) continue;

      esl.addSkill(skill.getId(), skill.getLevel(), data.getCostSp(), data.getCostExp());
      empty = false;
    }

    if (empty) {
      player.sendPacket(SystemMessageId.THERE_IS_NO_SKILL_THAT_ENABLES_ENCHANT);

      if (player.getLevel() < 74)
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1)
                .addNumber(74));
      else player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
    } else player.sendPacket(esl);

    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
Exemplo n.º 2
0
  /**
   * This method displays SkillList to the player.
   *
   * @param player The player who requested the method.
   * @param npc The L2Npc linked to the request.
   * @param classId The classId asked. Used to sort available skill list.
   */
  public static void showSkillList(L2PcInstance player, L2Npc npc, ClassId classId) {
    if (((L2NpcInstance) npc).getClassesToTeach() == null) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      final String sb =
          StringUtil.concat(
              "<html><body>I cannot teach you. My class list is empty.<br>Your admin needs to add me teachTo informations.<br>NpcId:",
              String.valueOf(npc.getTemplate().getNpcId()),
              ", your classId:",
              String.valueOf(player.getClassId().getId()),
              "</body></html>");
      html.setHtml(sb);
      player.sendPacket(html);
      return;
    }

    if (!npc.getTemplate().canTeach(classId)) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile("data/html/trainer/" + npc.getTemplate().getNpcId() + "-noskills.htm");
      player.sendPacket(html);
      return;
    }

    AcquireSkillList asl = new AcquireSkillList(AcquireSkillList.SkillType.Usual);
    boolean empty = true;

    for (L2SkillLearn sl : SkillTreeTable.getInstance().getAvailableSkills(player, classId)) {
      L2Skill sk = SkillTable.getInstance().getInfo(sl.getId(), sl.getLevel());
      if (sk == null) continue;

      asl.addSkill(sl.getId(), sl.getLevel(), sl.getLevel(), sl.getSpCost(), 0);
      empty = false;
    }

    if (empty) {
      int minlevel = SkillTreeTable.getInstance().getMinLevelForNewSkill(player, classId);

      if (minlevel > 0)
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1)
                .addNumber(minlevel));
      else player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
    } else player.sendPacket(asl);

    player.sendPacket(ActionFailed.STATIC_PACKET);
  }