FishShots.java 3.3 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 handlers.itemhandlers;
  16. import com.l2jserver.gameserver.handler.IItemHandler;
  17. import com.l2jserver.gameserver.model.L2Object;
  18. import com.l2jserver.gameserver.model.actor.L2Playable;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.model.item.L2Item;
  21. import com.l2jserver.gameserver.model.item.L2Weapon;
  22. import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
  23. import com.l2jserver.gameserver.model.item.type.L2WeaponType;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. import com.l2jserver.gameserver.util.Broadcast;
  28. /**
  29. * @author -Nemesiss-
  30. *
  31. */
  32. public class FishShots implements IItemHandler
  33. {
  34. private static final int[] SKILL_IDS =
  35. {
  36. 2181, 2182, 2183, 2184, 2185, 2186
  37. };
  38. /**
  39. *
  40. * @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
  41. */
  42. public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
  43. {
  44. if (!(playable instanceof L2PcInstance))
  45. return;
  46. L2PcInstance activeChar = (L2PcInstance) playable;
  47. L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
  48. L2Weapon weaponItem = activeChar.getActiveWeaponItem();
  49. if (weaponInst == null || weaponItem.getItemType() != L2WeaponType.FISHINGROD)
  50. return;
  51. if (weaponInst.getChargedFishshot())
  52. // spirit shot is already active
  53. return;
  54. int FishshotId = item.getItemId();
  55. int grade = weaponItem.getCrystalType();
  56. long count = item.getCount();
  57. if ((grade == L2Item.CRYSTAL_NONE && FishshotId != 6535) || (grade == L2Item.CRYSTAL_D && FishshotId != 6536) || (grade == L2Item.CRYSTAL_C && FishshotId != 6537) || (grade == L2Item.CRYSTAL_B && FishshotId != 6538)
  58. || (grade == L2Item.CRYSTAL_A && FishshotId != 6539) || (FishshotId != 6540 && grade == L2Item.CRYSTAL_S ))
  59. {
  60. //1479 - This fishing shot is not fit for the fishing pole crystal.
  61. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WRONG_FISHINGSHOT_GRADE));
  62. return;
  63. }
  64. if (count < 1)
  65. return;
  66. weaponInst.setChargedFishshot(true);
  67. activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
  68. L2Object oldTarget = activeChar.getTarget();
  69. activeChar.setTarget(activeChar);
  70. Broadcast.toSelfAndKnownPlayers(activeChar, new MagicSkillUse(activeChar, SKILL_IDS[grade], 1, 0, 0));
  71. activeChar.setTarget(oldTarget);
  72. }
  73. }