CompSpiritShotPacks.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.handler.itemhandlers;
  16. import net.sf.l2j.gameserver.handler.IItemHandler;
  17. import net.sf.l2j.gameserver.model.L2ItemInstance;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.network.serverpackets.ItemList;
  22. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  23. /**
  24. * This class ...
  25. *
  26. * @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:30:07 $
  27. */
  28. public class CompSpiritShotPacks implements IItemHandler
  29. {
  30. private static final int[] ITEM_IDS =
  31. {
  32. 5140, 5141, 5142, 5143, 5144, 5145,
  33. 5256, 5257, 5258, 5259, 5260, 5261
  34. };
  35. /**
  36. *
  37. * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
  38. */
  39. public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  40. {
  41. if (!(playable instanceof L2PcInstance))
  42. return;
  43. L2PcInstance activeChar = (L2PcInstance) playable;
  44. int itemId = item.getItemId();
  45. int itemToCreateId;
  46. int amount;
  47. if (itemId < 5200)
  48. { // Normal Compressed Package of SpiritShots
  49. itemToCreateId = itemId - 2631; // Gives id of matching item for this pack
  50. amount = 300;
  51. }
  52. else
  53. { // Greater Compressed Package of Spiri Shots
  54. itemToCreateId = itemId - 2747; // Gives id of matching item for this pack
  55. amount = 1000;
  56. }
  57. activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
  58. activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);
  59. SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
  60. sm.addItemName(itemToCreateId);
  61. sm.addNumber(amount);
  62. activeChar.sendPacket(sm);
  63. ItemList playerUI = new ItemList(activeChar, false);
  64. activeChar.sendPacket(playerUI);
  65. }
  66. /**
  67. *
  68. * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
  69. */
  70. public int[] getItemIds()
  71. {
  72. return ITEM_IDS;
  73. }
  74. }