FishingSkill.java 3.4 KB

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