RequestExEnchantSkillInfoDetail.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 com.l2jserver.gameserver.network.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.gameserver.datatables.EnchantGroupsTable;
  18. import com.l2jserver.gameserver.model.L2EnchantSkillLearn;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.serverpackets.ExEnchantSkillInfoDetail;
  21. /**
  22. * Format (ch) ddd c: (id) 0xD0 h: (subid) 0x31 d: type d: skill id d: skill lvl
  23. *
  24. * @author -Wooden-
  25. *
  26. */
  27. public final class RequestExEnchantSkillInfoDetail extends L2GameClientPacket
  28. {
  29. protected static final Logger _log = Logger.getLogger(RequestExEnchantSkillInfoDetail.class.getName());
  30. private int _type;
  31. private int _skillId;
  32. private int _skillLvl;
  33. @Override
  34. protected void readImpl()
  35. {
  36. _type = readD();
  37. _skillId = readD();
  38. _skillLvl = readD();
  39. }
  40. /*
  41. * (non-Javadoc)
  42. *
  43. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
  44. */
  45. @Override
  46. protected void runImpl()
  47. {
  48. L2PcInstance activeChar = getClient().getActiveChar();
  49. if (activeChar == null)
  50. return;
  51. int reqSkillLvl = -2;
  52. if (_type == 0 || _type == 1)
  53. reqSkillLvl = _skillLvl - 1; // enchant
  54. else if (_type == 2)
  55. reqSkillLvl = _skillLvl + 1; // untrain
  56. else if (_type == 3)
  57. reqSkillLvl = _skillLvl; // change route
  58. int playerSkillLvl = activeChar.getSkillLevel(_skillId);
  59. // dont have such skill
  60. if (playerSkillLvl == -1)
  61. return;
  62. // if reqlvl is 100,200,.. check base skill lvl enchant
  63. if ((reqSkillLvl % 100) == 0)
  64. {
  65. L2EnchantSkillLearn esl = EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(_skillId);
  66. if (esl != null)
  67. {
  68. // if player dont have min level to enchant
  69. if (playerSkillLvl != esl.getBaseLevel())
  70. return;
  71. }
  72. // enchant data dont exist?
  73. else
  74. return;
  75. }
  76. else if (playerSkillLvl != reqSkillLvl)
  77. {
  78. // change route is different skill lvl but same enchant
  79. if (_type == 3 && ((playerSkillLvl % 100) != (_skillLvl % 100)))
  80. return;
  81. }
  82. // send skill enchantment detail
  83. ExEnchantSkillInfoDetail esd = new ExEnchantSkillInfoDetail(_type, _skillId, _skillLvl, activeChar);
  84. activeChar.sendPacket(esd);
  85. }
  86. /*
  87. * (non-Javadoc)
  88. *
  89. * @see com.l2jserver.gameserver.BasePacket#getType()
  90. */
  91. @Override
  92. public String getType()
  93. {
  94. return "[C] D0:46 RequestExEnchantSkillInfo";
  95. }
  96. }