FishingSkill.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.datatables.FishingRodsData;
  17. import com.l2jserver.gameserver.datatables.SkillTable;
  18. import com.l2jserver.gameserver.handler.ISkillHandler;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.ShotType;
  21. import com.l2jserver.gameserver.model.actor.L2Character;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.fishing.L2Fishing;
  24. import com.l2jserver.gameserver.model.fishing.L2FishingRod;
  25. import com.l2jserver.gameserver.model.items.L2Weapon;
  26. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  27. import com.l2jserver.gameserver.model.skills.L2Skill;
  28. import com.l2jserver.gameserver.model.skills.L2SkillType;
  29. import com.l2jserver.gameserver.network.SystemMessageId;
  30. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  31. public class FishingSkill implements ISkillHandler
  32. {
  33. private static final L2SkillType[] SKILL_IDS =
  34. {
  35. L2SkillType.PUMPING,
  36. L2SkillType.REELING
  37. };
  38. @Override
  39. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  40. {
  41. if (!activeChar.isPlayer())
  42. {
  43. return;
  44. }
  45. L2PcInstance player = activeChar.getActingPlayer();
  46. L2Fishing fish = player.getFishCombat();
  47. if (fish == null)
  48. {
  49. if (skill.getSkillType() == L2SkillType.PUMPING)
  50. {
  51. // Pumping skill is available only while fishing
  52. player.sendPacket(SystemMessageId.CAN_USE_PUMPING_ONLY_WHILE_FISHING);
  53. }
  54. else if (skill.getSkillType() == L2SkillType.REELING)
  55. {
  56. // Reeling skill is available only while fishing
  57. player.sendPacket(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING);
  58. }
  59. player.sendPacket(ActionFailed.STATIC_PACKET);
  60. return;
  61. }
  62. L2Weapon weaponItem = player.getActiveWeaponItem();
  63. L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
  64. if ((weaponInst == null) || (weaponItem == null))
  65. {
  66. return;
  67. }
  68. int SS = 1;
  69. int pen = 0;
  70. if (activeChar.isChargedShot(ShotType.FISH_SOULSHOTS))
  71. {
  72. SS = 2;
  73. }
  74. L2FishingRod fishingRod = FishingRodsData.getInstance().getFishingRod(weaponItem.getItemId());
  75. double gradeBonus = fishingRod.getFishingRodLevel() * 0.1; // TODO: Check this formula (is guessed)
  76. final L2Skill expertiseSkill = SkillTable.getInstance().getInfo(1315, player.getSkillLevel(1315));
  77. int dmg = (int) ((fishingRod.getFishingRodDamage() + expertiseSkill.getPower() + skill.getPower()) * gradeBonus * SS);
  78. // Penalty 5% less damage dealt
  79. if (player.getSkillLevel(1315) <= (skill.getLevel() - 2)) // 1315 - Fish Expertise
  80. {
  81. player.sendPacket(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY);
  82. pen = (int) (dmg * 0.05);
  83. dmg = dmg - pen;
  84. }
  85. if (SS > 1)
  86. {
  87. weaponInst.setChargedShot(ShotType.FISH_SOULSHOTS, false);
  88. }
  89. if (skill.getSkillType() == L2SkillType.REELING)
  90. {
  91. fish.useReeling(dmg, pen);
  92. }
  93. else
  94. {
  95. fish.usePumping(dmg, pen);
  96. }
  97. }
  98. @Override
  99. public L2SkillType[] getSkillIds()
  100. {
  101. return SKILL_IDS;
  102. }
  103. }