RequestExEnchantSkillInfoDetail.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.clientpackets;
  16. import java.util.logging.Logger;
  17. import net.sf.l2j.gameserver.datatables.SkillTreeTable;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.serverpackets.ExEnchantSkillInfoDetail;
  20. /**
  21. * Format (ch) ddd
  22. * c: (id) 0xD0
  23. * h: (subid) 0x31
  24. * d: skill id
  25. * d: skill lvl ?
  26. * d: ?
  27. * @author -Wooden-
  28. *
  29. */
  30. public final class RequestExEnchantSkillInfoDetail extends L2GameClientPacket
  31. {
  32. protected static final Logger _log = Logger.getLogger(RequestExEnchantSkillInfoDetail.class.getName());
  33. private static final int TYPE_NORMAL_ENCHANT = 0;
  34. private static final int TYPE_SAFE_ENCHANT = 1;
  35. private static final int TYPE_UNTRAIN_ENCHANT = 2;
  36. private static final int TYPE_CHANGE_ENCHANT = 3;
  37. private int _type;
  38. @SuppressWarnings("unused")
  39. private int _skillId;
  40. private int _skillLvl;
  41. @Override
  42. protected void readImpl()
  43. {
  44. _type = readD();
  45. _skillId = readD();
  46. _skillLvl = readD();
  47. }
  48. /* (non-Javadoc)
  49. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#runImpl()
  50. */
  51. @Override
  52. protected void runImpl()
  53. {
  54. L2PcInstance activeChar = getClient().getActiveChar();
  55. if (activeChar == null)
  56. return;
  57. int bookId = 0;
  58. int reqCount = 0;
  59. // require book for first level
  60. int enchantLevel = _skillLvl%100;
  61. // if going to first level OR going to Original level(untraining)
  62. // OR changing route OR safe enchant then require book
  63. if ((_skillLvl > 100 && enchantLevel == 1) || (_skillLvl < 100)
  64. || _type == TYPE_CHANGE_ENCHANT || _type == TYPE_SAFE_ENCHANT)
  65. {
  66. switch (_type)
  67. {
  68. case TYPE_NORMAL_ENCHANT:
  69. bookId = SkillTreeTable.NORMAL_ENCHANT_BOOK;
  70. reqCount = 1;
  71. break;
  72. case TYPE_SAFE_ENCHANT:
  73. bookId = SkillTreeTable.SAFE_ENCHANT_BOOK;
  74. reqCount = 1;
  75. break;
  76. case TYPE_UNTRAIN_ENCHANT:
  77. bookId = SkillTreeTable.UNTRAIN_ENCHANT_BOOK;
  78. reqCount = 1;
  79. break;
  80. case TYPE_CHANGE_ENCHANT:
  81. bookId = SkillTreeTable.CHANGE_ENCHANT_BOOK;
  82. reqCount = 1;
  83. break;
  84. default:
  85. _log.severe("Unknown skill enchant type: "+_type);
  86. return;
  87. }
  88. }
  89. // send skill enchantment detail
  90. ExEnchantSkillInfoDetail esd = new ExEnchantSkillInfoDetail(bookId, reqCount);
  91. activeChar.sendPacket(esd);
  92. }
  93. /* (non-Javadoc)
  94. * @see net.sf.l2j.gameserver.BasePacket#getType()
  95. */
  96. @Override
  97. public String getType()
  98. {
  99. return "[C] D0:31 RequestExEnchantSkillInfo";
  100. }
  101. }