Reeling.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2004-2015 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.effecthandlers;
  20. import com.l2jserver.gameserver.data.xml.impl.FishingRodsData;
  21. import com.l2jserver.gameserver.enums.ShotType;
  22. import com.l2jserver.gameserver.model.StatsSet;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.conditions.Condition;
  26. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  27. import com.l2jserver.gameserver.model.effects.L2EffectType;
  28. import com.l2jserver.gameserver.model.fishing.L2Fishing;
  29. import com.l2jserver.gameserver.model.fishing.L2FishingRod;
  30. import com.l2jserver.gameserver.model.items.L2Weapon;
  31. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  32. import com.l2jserver.gameserver.model.skills.BuffInfo;
  33. import com.l2jserver.gameserver.model.stats.Stats;
  34. import com.l2jserver.gameserver.network.SystemMessageId;
  35. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  36. /**
  37. * Reeling effect implementation.
  38. * @author UnAfraid
  39. */
  40. public final class Reeling extends AbstractEffect
  41. {
  42. private final double _power;
  43. public Reeling(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
  44. {
  45. super(attachCond, applyCond, set, params);
  46. if (params.getString("power", null) == null)
  47. {
  48. throw new IllegalArgumentException(getClass().getSimpleName() + ": effect without power!");
  49. }
  50. _power = params.getDouble("power");
  51. }
  52. @Override
  53. public boolean isInstant()
  54. {
  55. return true;
  56. }
  57. @Override
  58. public L2EffectType getEffectType()
  59. {
  60. return L2EffectType.FISHING;
  61. }
  62. @Override
  63. public void onStart(BuffInfo info)
  64. {
  65. final L2Character activeChar = info.getEffector();
  66. if (!activeChar.isPlayer())
  67. {
  68. return;
  69. }
  70. final L2PcInstance player = activeChar.getActingPlayer();
  71. final L2Fishing fish = player.getFishCombat();
  72. if (fish == null)
  73. {
  74. // Reeling skill is available only while fishing
  75. player.sendPacket(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING);
  76. player.sendPacket(ActionFailed.STATIC_PACKET);
  77. return;
  78. }
  79. final L2Weapon weaponItem = player.getActiveWeaponItem();
  80. final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
  81. if ((weaponInst == null) || (weaponItem == null))
  82. {
  83. return;
  84. }
  85. int SS = 1;
  86. int pen = 0;
  87. if (activeChar.isChargedShot(ShotType.FISH_SOULSHOTS))
  88. {
  89. SS = 2;
  90. }
  91. final L2FishingRod fishingRod = FishingRodsData.getInstance().getFishingRod(weaponItem.getId());
  92. final double gradeBonus = fishingRod.getFishingRodLevel() * 0.1; // TODO: Check this formula (is guessed)
  93. int dmg = (int) ((fishingRod.getFishingRodDamage() + player.calcStat(Stats.FISHING_EXPERTISE, 1, null, null) + _power) * gradeBonus * SS);
  94. // Penalty 5% less damage dealt
  95. if (player.getSkillLevel(1315) <= (info.getSkill().getLevel() - 2)) // 1315 - Fish Expertise
  96. {
  97. player.sendPacket(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY);
  98. pen = (int) (dmg * 0.05);
  99. dmg = dmg - pen;
  100. }
  101. if (SS > 1)
  102. {
  103. weaponInst.setChargedShot(ShotType.FISH_SOULSHOTS, false);
  104. }
  105. fish.useReeling(dmg, pen);
  106. }
  107. }