StrSiegeAssault.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.handler.ISkillHandler;
  21. import com.l2jserver.gameserver.instancemanager.CastleManager;
  22. import com.l2jserver.gameserver.instancemanager.FortManager;
  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.entity.Castle;
  28. import com.l2jserver.gameserver.model.entity.Fort;
  29. import com.l2jserver.gameserver.model.skills.L2Skill;
  30. import com.l2jserver.gameserver.model.skills.L2SkillType;
  31. import com.l2jserver.gameserver.model.stats.Formulas;
  32. /**
  33. * @author _tomciaaa_
  34. */
  35. public class StrSiegeAssault implements ISkillHandler
  36. {
  37. private static final L2SkillType[] SKILL_IDS =
  38. {
  39. L2SkillType.STRSIEGEASSAULT
  40. };
  41. @Override
  42. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  43. {
  44. if (!activeChar.isPlayer())
  45. {
  46. return;
  47. }
  48. L2PcInstance player = activeChar.getActingPlayer();
  49. if (!player.isRidingStrider())
  50. {
  51. return;
  52. }
  53. if (!player.getTarget().isDoor())
  54. {
  55. return;
  56. }
  57. Castle castle = CastleManager.getInstance().getCastle(player);
  58. Fort fort = FortManager.getInstance().getFort(player);
  59. if ((castle == null) && (fort == null))
  60. {
  61. return;
  62. }
  63. if (castle != null)
  64. {
  65. if (!player.checkIfOkToUseStriderSiegeAssault(castle))
  66. {
  67. return;
  68. }
  69. }
  70. else
  71. {
  72. if (!player.checkIfOkToUseStriderSiegeAssault(fort))
  73. {
  74. return;
  75. }
  76. }
  77. try
  78. {
  79. // damage calculation
  80. int damage = 0;
  81. boolean ss = skill.useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS);
  82. for (L2Character target : (L2Character[]) targets)
  83. {
  84. if (activeChar.isPlayer() && target.isPlayer() && target.getActingPlayer().isFakeDeath())
  85. {
  86. target.stopFakeDeath(true);
  87. }
  88. else if (target.isDead())
  89. {
  90. continue;
  91. }
  92. boolean dual = activeChar.isUsingDualWeapon();
  93. byte shld = Formulas.calcShldUse(activeChar, target, skill);
  94. boolean crit = Formulas.calcCrit(activeChar.getCriticalHit(target, skill), true, target);
  95. if (!crit && ((skill.getCondition() & L2Skill.COND_CRIT) != 0))
  96. {
  97. damage = 0;
  98. }
  99. else
  100. {
  101. damage = skill.isStaticDamage() ? (int) skill.getPower() : (int) Formulas.calcPhysDam(activeChar, target, skill, shld, crit, dual, ss);
  102. }
  103. if (damage > 0)
  104. {
  105. target.reduceCurrentHp(damage, activeChar, skill);
  106. activeChar.sendDamageMessage(target, damage, false, false, false);
  107. }
  108. else
  109. {
  110. activeChar.sendMessage(skill.getName() + " failed.");
  111. }
  112. }
  113. activeChar.setChargedShot(ShotType.SOULSHOTS, false);
  114. }
  115. catch (Exception e)
  116. {
  117. player.sendMessage("Error using siege assault:" + e);
  118. }
  119. }
  120. @Override
  121. public L2SkillType[] getSkillIds()
  122. {
  123. return SKILL_IDS;
  124. }
  125. public static void main(String[] args)
  126. {
  127. new StrSiegeAssault();
  128. }
  129. }