TargetAura.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package handlers.targethandlers;
  16. import java.util.Collection;
  17. import java.util.List;
  18. import javolution.util.FastList;
  19. import com.l2jserver.gameserver.handler.ITargetTypeHandler;
  20. import com.l2jserver.gameserver.model.L2Object;
  21. import com.l2jserver.gameserver.model.actor.L2Attackable;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.L2Playable;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.skills.L2Skill;
  27. import com.l2jserver.gameserver.model.skills.L2SkillType;
  28. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  29. /**
  30. * @author UnAfraid
  31. */
  32. public class TargetAura implements ITargetTypeHandler
  33. {
  34. @Override
  35. public L2Object[] getTargetList(L2Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
  36. {
  37. List<L2Character> targetList = new FastList<L2Character>();
  38. final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  39. final L2PcInstance sourcePlayer = activeChar.getActingPlayer();
  40. final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(skill.getSkillRadius());
  41. if (skill.getSkillType() == L2SkillType.DUMMY)
  42. {
  43. if (onlyFirst)
  44. return new L2Character[] { activeChar };
  45. targetList.add(activeChar);
  46. for (L2Character obj : objs)
  47. {
  48. if (!(obj == activeChar || obj == sourcePlayer || obj instanceof L2Npc || obj instanceof L2Attackable))
  49. continue;
  50. if (skill.getMaxTargets() > -1 && targetList.size() >= skill.getMaxTargets())
  51. break;
  52. targetList.add(obj);
  53. }
  54. }
  55. else
  56. {
  57. for (L2Character obj : objs)
  58. {
  59. if (obj instanceof L2Attackable || obj instanceof L2Playable)
  60. {
  61. if (!L2Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))
  62. continue;
  63. if (onlyFirst)
  64. return new L2Character[] { obj };
  65. if (skill.getMaxTargets() > -1 && targetList.size() >= skill.getMaxTargets())
  66. break;
  67. targetList.add(obj);
  68. }
  69. }
  70. }
  71. return targetList.toArray(new L2Character[targetList.size()]);
  72. }
  73. @Override
  74. public Enum<L2TargetType> getTargetType()
  75. {
  76. return L2TargetType.TARGET_AURA;
  77. }
  78. }