RequestAutoSoulShot.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.Config;
  18. import net.sf.l2j.gameserver.model.L2ItemInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.serverpackets.ExAutoSoulShot;
  22. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  23. import net.sf.l2j.gameserver.templates.L2Item;
  24. /**
  25. * This class ...
  26. *
  27. * @version $Revision: 1.0.0.0 $ $Date: 2005/07/11 15:29:30 $
  28. */
  29. public final class RequestAutoSoulShot extends L2GameClientPacket
  30. {
  31. private static final String _C__CF_REQUESTAUTOSOULSHOT = "[C] CF RequestAutoSoulShot";
  32. private static Logger _log = Logger.getLogger(RequestAutoSoulShot.class.getName());
  33. // format cd
  34. private int _itemId;
  35. private int _type; // 1 = on : 0 = off;
  36. @Override
  37. protected void readImpl()
  38. {
  39. _itemId = readD();
  40. _type = readD();
  41. }
  42. @Override
  43. protected void runImpl()
  44. {
  45. L2PcInstance activeChar = getClient().getActiveChar();
  46. if (activeChar == null)
  47. return;
  48. if (activeChar.getPrivateStoreType() == 0 &&
  49. activeChar.getActiveRequester() == null &&
  50. !activeChar.isDead())
  51. {
  52. if (Config.DEBUG)
  53. _log.fine("AutoSoulShot:" + _itemId);
  54. L2ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);
  55. if (item != null)
  56. {
  57. if (_type == 1)
  58. {
  59. //Fishingshots are not automatic on retail
  60. if (_itemId < 6535 || _itemId > 6540) {
  61. // Attempt to charge first shot on activation
  62. if (_itemId == 6645 || _itemId == 6646 || _itemId == 6647)
  63. {
  64. activeChar.addAutoSoulShot(_itemId);
  65. ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
  66. activeChar.sendPacket(atk);
  67. //start the auto soulshot use
  68. SystemMessage sm = new SystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
  69. sm.addString(item.getItemName());
  70. activeChar.sendPacket(sm);
  71. sm = null;
  72. activeChar.rechargeAutoSoulShot(true, true, true);
  73. }
  74. else {
  75. if (activeChar.getActiveWeaponItem() != activeChar.getFistsWeaponItem())
  76. {
  77. if (item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getCrystalType() ||
  78. (item.getItem().getCrystalType() == L2Item.CRYSTAL_S && activeChar.getActiveWeaponItem().getCrystalType() == L2Item.CRYSTAL_S80))
  79. if (_itemId>=3947 && _itemId<=3952 && activeChar.isInOlympiadMode()){
  80. SystemMessage sm = new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
  81. sm.addString(item.getItemName());
  82. activeChar.sendPacket(sm);
  83. sm = null;
  84. }else{
  85. activeChar.addAutoSoulShot(_itemId);
  86. ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
  87. activeChar.sendPacket(atk);
  88. // start the auto soulshot use
  89. SystemMessage sm = new SystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
  90. sm.addString(item.getItemName());
  91. activeChar.sendPacket(sm);
  92. sm = null;
  93. activeChar.rechargeAutoSoulShot(true, true, false);
  94. }
  95. }
  96. else {
  97. if ((_itemId >= 2509 && _itemId <= 2514) || (_itemId >= 3947 && _itemId <= 3952) || _itemId == 5790)
  98. activeChar.sendPacket(new SystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
  99. else
  100. activeChar.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
  101. }
  102. }
  103. }
  104. }
  105. else if (_type == 0)
  106. {
  107. activeChar.removeAutoSoulShot(_itemId);
  108. ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
  109. activeChar.sendPacket(atk);
  110. //cancel the auto soulshot use
  111. SystemMessage sm = new SystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED);
  112. sm.addString(item.getItemName());
  113. activeChar.sendPacket(sm);
  114. sm = null;
  115. }
  116. }
  117. }
  118. }
  119. /* (non-Javadoc)
  120. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  121. */
  122. @Override
  123. public String getType()
  124. {
  125. return _C__CF_REQUESTAUTOSOULSHOT;
  126. }
  127. }