Dummy.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.enums.ShotType;
  21. import com.l2jserver.gameserver.handler.ISkillHandler;
  22. import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
  23. import com.l2jserver.gameserver.model.ArenaParticipantsHolder;
  24. import com.l2jserver.gameserver.model.L2Object;
  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.skills.L2Skill;
  29. import com.l2jserver.gameserver.model.skills.L2SkillType;
  30. import com.l2jserver.gameserver.model.stats.Formulas;
  31. public class Dummy implements ISkillHandler
  32. {
  33. private static final L2SkillType[] SKILL_IDS =
  34. {
  35. L2SkillType.DUMMY
  36. };
  37. @Override
  38. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  39. {
  40. switch (skill.getId())
  41. {
  42. case 5852:
  43. case 5853:
  44. {
  45. final L2Object obj = targets[0];
  46. if (obj != null)
  47. {
  48. useBlockCheckerSkill(activeChar.getActingPlayer(), skill, obj);
  49. }
  50. break;
  51. }
  52. default:
  53. {
  54. if (skill.hasEffects())
  55. {
  56. for (L2Character target : (L2Character[]) targets)
  57. {
  58. if (Formulas.calcBuffDebuffReflection(target, skill))
  59. {
  60. skill.applyEffects(target, activeChar);
  61. }
  62. else
  63. {
  64. skill.applyEffects(activeChar, target);
  65. }
  66. }
  67. }
  68. break;
  69. }
  70. }
  71. // Self Effect
  72. if (skill.hasSelfEffects())
  73. {
  74. if (activeChar.isAffectedBySkill(skill.getId()))
  75. {
  76. activeChar.stopSkillEffects(true, skill.getId());
  77. }
  78. skill.applyEffects(activeChar, null, activeChar, true, false, true, 0);
  79. }
  80. if (skill.useSpiritShot())
  81. {
  82. activeChar.setChargedShot(activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
  83. }
  84. else
  85. {
  86. activeChar.setChargedShot(ShotType.SOULSHOTS, false);
  87. }
  88. }
  89. @Override
  90. public L2SkillType[] getSkillIds()
  91. {
  92. return SKILL_IDS;
  93. }
  94. private final void useBlockCheckerSkill(L2PcInstance activeChar, L2Skill skill, L2Object target)
  95. {
  96. if (!(target instanceof L2BlockInstance))
  97. {
  98. return;
  99. }
  100. L2BlockInstance block = (L2BlockInstance) target;
  101. final int arena = activeChar.getBlockCheckerArena();
  102. if (arena != -1)
  103. {
  104. final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena);
  105. if (holder == null)
  106. {
  107. return;
  108. }
  109. final int team = holder.getPlayerTeam(activeChar);
  110. final int color = block.getColorEffect();
  111. if ((team == 0) && (color == 0x00))
  112. {
  113. block.changeColor(activeChar, holder, team);
  114. }
  115. else if ((team == 1) && (color == 0x53))
  116. {
  117. block.changeColor(activeChar, holder, team);
  118. }
  119. }
  120. }
  121. }