2
0

EffectTargetMe.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 com.l2jserver.gameserver.skills.effects;
  16. import com.l2jserver.gameserver.model.L2Effect;
  17. import com.l2jserver.gameserver.model.actor.L2Attackable;
  18. import com.l2jserver.gameserver.model.actor.L2Playable;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
  21. import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
  22. import com.l2jserver.gameserver.skills.Env;
  23. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  24. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  25. /**
  26. *
  27. * @author -Nemesiss-
  28. */
  29. public class EffectTargetMe extends L2Effect
  30. {
  31. public EffectTargetMe(Env env, EffectTemplate template)
  32. {
  33. super(env, template);
  34. }
  35. /**
  36. *
  37. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  38. */
  39. @Override
  40. public L2EffectType getEffectType()
  41. {
  42. return L2EffectType.TARGET_ME;
  43. }
  44. /**
  45. *
  46. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  47. */
  48. @Override
  49. public boolean onStart()
  50. {
  51. if (getEffected() instanceof L2Playable)
  52. {
  53. if (getEffected() instanceof L2SiegeSummonInstance)
  54. return false;
  55. if (getEffected().getTarget() != getEffector())
  56. {
  57. // Target is different
  58. getEffected().setTarget(getEffector());
  59. if (getEffected() instanceof L2PcInstance)
  60. getEffected().sendPacket(new MyTargetSelected(getEffector().getObjectId(), 0));
  61. }
  62. ((L2Playable)getEffected()).setLockedTarget(getEffector());
  63. return true;
  64. }
  65. else if (getEffected() instanceof L2Attackable && !getEffected().isRaid())
  66. return true;
  67. return false;
  68. }
  69. /**
  70. *
  71. * @see com.l2jserver.gameserver.model.L2Effect#onExit()
  72. */
  73. @Override
  74. public void onExit()
  75. {
  76. if (getEffected() instanceof L2Playable)
  77. ((L2Playable)getEffected()).setLockedTarget(null);
  78. }
  79. /**
  80. *
  81. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  82. */
  83. @Override
  84. public boolean onActionTime()
  85. {
  86. // nothing
  87. return false;
  88. }
  89. }