FishingSkill.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.skillhandlers;
  16. import com.l2jserver.gameserver.handler.ISkillHandler;
  17. import com.l2jserver.gameserver.model.L2Fishing;
  18. import com.l2jserver.gameserver.model.L2Object;
  19. import com.l2jserver.gameserver.model.L2Skill;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.item.L2Weapon;
  23. import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  28. public class FishingSkill implements ISkillHandler
  29. {
  30. private static final L2SkillType[] SKILL_IDS =
  31. {
  32. L2SkillType.PUMPING,
  33. L2SkillType.REELING
  34. };
  35. /**
  36. *
  37. * @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
  38. */
  39. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  40. {
  41. if (!(activeChar instanceof L2PcInstance))
  42. return;
  43. L2PcInstance player = (L2PcInstance) activeChar;
  44. L2Fishing fish = player.getFishCombat();
  45. if (fish == null)
  46. {
  47. if (skill.getSkillType() == L2SkillType.PUMPING)
  48. {
  49. //Pumping skill is available only while fishing
  50. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CAN_USE_PUMPING_ONLY_WHILE_FISHING));
  51. }
  52. else if (skill.getSkillType() == L2SkillType.REELING)
  53. {
  54. //Reeling skill is available only while fishing
  55. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING));
  56. }
  57. player.sendPacket(ActionFailed.STATIC_PACKET);
  58. return;
  59. }
  60. L2Weapon weaponItem = player.getActiveWeaponItem();
  61. L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
  62. if (weaponInst == null || weaponItem == null)
  63. return;
  64. int SS = 1;
  65. int pen = 0;
  66. if (weaponInst.getChargedFishshot())
  67. SS = 2;
  68. double gradebonus = 1 + weaponItem.getCrystalType() * 0.1;
  69. int dmg = (int) (skill.getPower() * gradebonus * SS);
  70. if (player.getSkillLevel(1315) <= skill.getLevel() - 2) //1315 - Fish Expertise
  71. {//Penalty
  72. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY));
  73. pen = 50;
  74. int penatlydmg = dmg - pen;
  75. if (player.isGM())
  76. player.sendMessage("Dmg w/o penalty = " + dmg);
  77. dmg = penatlydmg;
  78. }
  79. if (SS > 1)
  80. {
  81. weaponInst.setChargedFishshot(false);
  82. }
  83. if (skill.getSkillType() == L2SkillType.REELING)//Realing
  84. {
  85. fish.useRealing(dmg, pen);
  86. }
  87. else
  88. //Pumping
  89. {
  90. fish.usePomping(dmg, pen);
  91. }
  92. }
  93. /**
  94. *
  95. * @see com.l2jserver.gameserver.handler.ISkillHandler#getSkillIds()
  96. */
  97. public L2SkillType[] getSkillIds()
  98. {
  99. return SKILL_IDS;
  100. }
  101. }