FishingSkill.java 3.5 KB

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