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