RequestExEnchantSkillInfoDetail.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import com.l2jserver.gameserver.data.xml.impl.EnchantSkillGroupsData;
  21. import com.l2jserver.gameserver.model.L2EnchantSkillLearn;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.serverpackets.ExEnchantSkillInfoDetail;
  24. /**
  25. * Format (ch) ddd c: (id) 0xD0 h: (subid) 0x31 d: type d: skill id d: skill lvl
  26. * @author -Wooden-
  27. */
  28. public final class RequestExEnchantSkillInfoDetail extends L2GameClientPacket
  29. {
  30. private static final String _C_D0_46_REQUESTEXENCHANTSKILLINFO = "[C] D0:46 RequestExEnchantSkillInfoDetail";
  31. private int _type;
  32. private int _skillId;
  33. private int _skillLvl;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _type = readD();
  38. _skillId = readD();
  39. _skillLvl = readD();
  40. }
  41. @Override
  42. protected void runImpl()
  43. {
  44. if ((_skillId <= 0) || (_skillLvl <= 0))
  45. {
  46. return;
  47. }
  48. L2PcInstance activeChar = getClient().getActiveChar();
  49. if (activeChar == null)
  50. {
  51. return;
  52. }
  53. int reqSkillLvl = -2;
  54. if ((_type == 0) || (_type == 1))
  55. {
  56. reqSkillLvl = _skillLvl - 1; // enchant
  57. }
  58. else if (_type == 2)
  59. {
  60. reqSkillLvl = _skillLvl + 1; // untrain
  61. }
  62. else if (_type == 3)
  63. {
  64. reqSkillLvl = _skillLvl; // change route
  65. }
  66. int playerSkillLvl = activeChar.getSkillLevel(_skillId);
  67. // dont have such skill
  68. if (playerSkillLvl == -1)
  69. {
  70. return;
  71. }
  72. // if reqlvl is 100,200,.. check base skill lvl enchant
  73. if ((reqSkillLvl % 100) == 0)
  74. {
  75. L2EnchantSkillLearn esl = EnchantSkillGroupsData.getInstance().getSkillEnchantmentBySkillId(_skillId);
  76. if (esl != null)
  77. {
  78. // if player dont have min level to enchant
  79. if (playerSkillLvl != esl.getBaseLevel())
  80. {
  81. return;
  82. }
  83. }
  84. // enchant data dont exist?
  85. else
  86. {
  87. return;
  88. }
  89. }
  90. else if (playerSkillLvl != reqSkillLvl)
  91. {
  92. // change route is different skill lvl but same enchant
  93. if ((_type == 3) && ((playerSkillLvl % 100) != (_skillLvl % 100)))
  94. {
  95. return;
  96. }
  97. }
  98. // send skill enchantment detail
  99. ExEnchantSkillInfoDetail esd = new ExEnchantSkillInfoDetail(_type, _skillId, _skillLvl, activeChar);
  100. activeChar.sendPacket(esd);
  101. }
  102. @Override
  103. public String getType()
  104. {
  105. return _C_D0_46_REQUESTEXENCHANTSKILLINFO;
  106. }
  107. }