RequestExEnchantSkillInfoDetail.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. if (_skillId <= 0 || _skillLvl <= 0) // minimal sanity check
  49. return;
  50. L2PcInstance activeChar = getClient().getActiveChar();
  51. if (activeChar == null)
  52. return;
  53. int reqSkillLvl = -2;
  54. if (_type == 0 || _type == 1)
  55. reqSkillLvl = _skillLvl - 1; // enchant
  56. else if (_type == 2)
  57. reqSkillLvl = _skillLvl + 1; // untrain
  58. else if (_type == 3)
  59. reqSkillLvl = _skillLvl; // change route
  60. int playerSkillLvl = activeChar.getSkillLevel(_skillId);
  61. // dont have such skill
  62. if (playerSkillLvl == -1)
  63. return;
  64. // if reqlvl is 100,200,.. check base skill lvl enchant
  65. if ((reqSkillLvl % 100) == 0)
  66. {
  67. L2EnchantSkillLearn esl = EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(_skillId);
  68. if (esl != null)
  69. {
  70. // if player dont have min level to enchant
  71. if (playerSkillLvl != esl.getBaseLevel())
  72. return;
  73. }
  74. // enchant data dont exist?
  75. else
  76. return;
  77. }
  78. else if (playerSkillLvl != reqSkillLvl)
  79. {
  80. // change route is different skill lvl but same enchant
  81. if (_type == 3 && ((playerSkillLvl % 100) != (_skillLvl % 100)))
  82. return;
  83. }
  84. // send skill enchantment detail
  85. ExEnchantSkillInfoDetail esd = new ExEnchantSkillInfoDetail(_type, _skillId, _skillLvl, activeChar);
  86. activeChar.sendPacket(esd);
  87. }
  88. /*
  89. * (non-Javadoc)
  90. *
  91. * @see com.l2jserver.gameserver.BasePacket#getType()
  92. */
  93. @Override
  94. public String getType()
  95. {
  96. return "[C] D0:46 RequestExEnchantSkillInfo";
  97. }
  98. }