FishingSkill.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (C) 2004-2013 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.skillhandlers;
  20. import com.l2jserver.gameserver.datatables.FishingRodsData;
  21. import com.l2jserver.gameserver.datatables.SkillTable;
  22. import com.l2jserver.gameserver.handler.ISkillHandler;
  23. import com.l2jserver.gameserver.model.L2Object;
  24. import com.l2jserver.gameserver.model.ShotType;
  25. import com.l2jserver.gameserver.model.actor.L2Character;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.fishing.L2Fishing;
  28. import com.l2jserver.gameserver.model.fishing.L2FishingRod;
  29. import com.l2jserver.gameserver.model.items.L2Weapon;
  30. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  31. import com.l2jserver.gameserver.model.skills.L2Skill;
  32. import com.l2jserver.gameserver.model.skills.L2SkillType;
  33. import com.l2jserver.gameserver.network.SystemMessageId;
  34. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  35. public class FishingSkill implements ISkillHandler
  36. {
  37. private static final L2SkillType[] SKILL_IDS =
  38. {
  39. L2SkillType.PUMPING,
  40. L2SkillType.REELING
  41. };
  42. @Override
  43. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  44. {
  45. if (!activeChar.isPlayer())
  46. {
  47. return;
  48. }
  49. L2PcInstance player = activeChar.getActingPlayer();
  50. L2Fishing fish = player.getFishCombat();
  51. if (fish == null)
  52. {
  53. if (skill.getSkillType() == L2SkillType.PUMPING)
  54. {
  55. // Pumping skill is available only while fishing
  56. player.sendPacket(SystemMessageId.CAN_USE_PUMPING_ONLY_WHILE_FISHING);
  57. }
  58. else if (skill.getSkillType() == L2SkillType.REELING)
  59. {
  60. // Reeling skill is available only while fishing
  61. player.sendPacket(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING);
  62. }
  63. player.sendPacket(ActionFailed.STATIC_PACKET);
  64. return;
  65. }
  66. L2Weapon weaponItem = player.getActiveWeaponItem();
  67. L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
  68. if ((weaponInst == null) || (weaponItem == null))
  69. {
  70. return;
  71. }
  72. int SS = 1;
  73. int pen = 0;
  74. if (activeChar.isChargedShot(ShotType.FISH_SOULSHOTS))
  75. {
  76. SS = 2;
  77. }
  78. L2FishingRod fishingRod = FishingRodsData.getInstance().getFishingRod(weaponItem.getId());
  79. double gradeBonus = fishingRod.getFishingRodLevel() * 0.1; // TODO: Check this formula (is guessed)
  80. final L2Skill expertiseSkill = SkillTable.getInstance().getInfo(1315, player.getSkillLevel(1315));
  81. int dmg = (int) ((fishingRod.getFishingRodDamage() + expertiseSkill.getPower() + skill.getPower()) * gradeBonus * SS);
  82. // Penalty 5% less damage dealt
  83. if (player.getSkillLevel(1315) <= (skill.getLevel() - 2)) // 1315 - Fish Expertise
  84. {
  85. player.sendPacket(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY);
  86. pen = (int) (dmg * 0.05);
  87. dmg = dmg - pen;
  88. }
  89. if (SS > 1)
  90. {
  91. weaponInst.setChargedShot(ShotType.FISH_SOULSHOTS, false);
  92. }
  93. if (skill.getSkillType() == L2SkillType.REELING)
  94. {
  95. fish.useReeling(dmg, pen);
  96. }
  97. else
  98. {
  99. fish.usePumping(dmg, pen);
  100. }
  101. }
  102. @Override
  103. public L2SkillType[] getSkillIds()
  104. {
  105. return SKILL_IDS;
  106. }
  107. }