MysteryPotion.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.ThreadPoolManager;
  17. import net.sf.l2j.gameserver.handler.IItemHandler;
  18. import net.sf.l2j.gameserver.model.L2ItemInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  21. import net.sf.l2j.gameserver.network.SystemMessageId;
  22. import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  23. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  24. /**
  25. * This class ...
  26. *
  27. * @version $Revision: 1.1.6.4 $ $Date: 2005/04/06 18:25:18 $
  28. */
  29. public class MysteryPotion implements IItemHandler
  30. {
  31. private static final int[] ITEM_IDS =
  32. {
  33. 5234
  34. };
  35. private static final int BIGHEAD_EFFECT = 0x2000;
  36. private static final int MYSTERY_POTION_SKILL = 2103;
  37. private static final int EFFECT_DURATION = 1200000; // 20 mins
  38. /**
  39. *
  40. * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
  41. */
  42. public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  43. {
  44. if (!(playable instanceof L2PcInstance))
  45. return;
  46. L2PcInstance activeChar = (L2PcInstance) playable;
  47. // Use a summon skill effect for fun ;)
  48. MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2103, 1, 0, 0);
  49. activeChar.sendPacket(MSU);
  50. activeChar.broadcastPacket(MSU);
  51. activeChar.startAbnormalEffect(BIGHEAD_EFFECT);
  52. activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
  53. SystemMessage sm = new SystemMessage(SystemMessageId.USE_S1);
  54. sm.addSkillName(MYSTERY_POTION_SKILL);
  55. activeChar.sendPacket(sm);
  56. MysteryPotionStop mp = new MysteryPotionStop(playable);
  57. ThreadPoolManager.getInstance().scheduleEffect(mp, EFFECT_DURATION);
  58. }
  59. public class MysteryPotionStop implements Runnable
  60. {
  61. private L2PlayableInstance _playable;
  62. public MysteryPotionStop(L2PlayableInstance playable)
  63. {
  64. _playable = playable;
  65. }
  66. public void run()
  67. {
  68. try
  69. {
  70. if (!(_playable instanceof L2PcInstance))
  71. return;
  72. ((L2PcInstance) _playable).stopAbnormalEffect(BIGHEAD_EFFECT);
  73. }
  74. catch (Throwable t)
  75. {
  76. }
  77. }
  78. }
  79. /**
  80. *
  81. * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
  82. */
  83. public int[] getItemIds()
  84. {
  85. return ITEM_IDS;
  86. }
  87. }