Dummy.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.HandysBlockCheckerManager;
  22. import com.l2jserver.gameserver.model.ArenaParticipantsHolder;
  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.L2BlockInstance;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.effects.L2Effect;
  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. * @version $Revision: 1.1.2.5.2.4 $ $Date: 2005/04/03 15:55:03 $
  34. */
  35. public class Dummy implements ISkillHandler
  36. {
  37. private static final L2SkillType[] SKILL_IDS =
  38. {
  39. L2SkillType.DUMMY
  40. };
  41. @Override
  42. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  43. {
  44. switch (skill.getId())
  45. {
  46. case 5852:
  47. case 5853:
  48. {
  49. final L2Object obj = targets[0];
  50. if (obj != null)
  51. {
  52. useBlockCheckerSkill(activeChar.getActingPlayer(), skill, obj);
  53. }
  54. break;
  55. }
  56. default:
  57. {
  58. if (skill.hasEffects())
  59. {
  60. for (L2Character target : (L2Character[]) targets)
  61. {
  62. if (Formulas.calcBuffDebuffReflection(target, skill))
  63. {
  64. skill.getEffects(target, activeChar);
  65. }
  66. else
  67. {
  68. skill.getEffects(activeChar, target);
  69. }
  70. }
  71. }
  72. break;
  73. }
  74. }
  75. // Self Effect
  76. if (skill.hasSelfEffects())
  77. {
  78. final L2Effect effect = activeChar.getFirstEffect(skill.getId());
  79. if ((effect != null) && effect.isSelfEffect())
  80. {
  81. // Replace old effect with new one.
  82. effect.exit();
  83. }
  84. skill.getEffectsSelf(activeChar);
  85. }
  86. if (skill.useSpiritShot())
  87. {
  88. activeChar.setChargedShot(activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
  89. }
  90. else
  91. {
  92. activeChar.setChargedShot(ShotType.SOULSHOTS, false);
  93. }
  94. }
  95. @Override
  96. public L2SkillType[] getSkillIds()
  97. {
  98. return SKILL_IDS;
  99. }
  100. private final void useBlockCheckerSkill(L2PcInstance activeChar, L2Skill skill, L2Object target)
  101. {
  102. if (!(target instanceof L2BlockInstance))
  103. {
  104. return;
  105. }
  106. L2BlockInstance block = (L2BlockInstance) target;
  107. final int arena = activeChar.getBlockCheckerArena();
  108. if (arena != -1)
  109. {
  110. final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena);
  111. if (holder == null)
  112. {
  113. return;
  114. }
  115. final int team = holder.getPlayerTeam(activeChar);
  116. final int color = block.getColorEffect();
  117. if ((team == 0) && (color == 0x00))
  118. {
  119. block.changeColor(activeChar, holder, team);
  120. }
  121. else if ((team == 1) && (color == 0x53))
  122. {
  123. block.changeColor(activeChar, holder, team);
  124. }
  125. }
  126. }
  127. }