Dummy.java 3.6 KB

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