EffectSignetAntiSummon.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.ai.CtrlEvent;
  17. import com.l2jserver.gameserver.model.L2Effect;
  18. import com.l2jserver.gameserver.model.actor.L2Character;
  19. import com.l2jserver.gameserver.model.actor.L2Playable;
  20. import com.l2jserver.gameserver.model.actor.L2Summon;
  21. import com.l2jserver.gameserver.model.actor.instance.L2EffectPointInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.SystemMessageId;
  24. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  25. import com.l2jserver.gameserver.skills.Env;
  26. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  27. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  28. /**
  29. * @author Forsaiken
  30. */
  31. public class EffectSignetAntiSummon extends L2Effect
  32. {
  33. private L2EffectPointInstance _actor;
  34. public EffectSignetAntiSummon(Env env, EffectTemplate template)
  35. {
  36. super(env, template);
  37. }
  38. /**
  39. *
  40. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  41. */
  42. @Override
  43. public L2EffectType getEffectType()
  44. {
  45. return L2EffectType.SIGNET_GROUND;
  46. }
  47. /**
  48. *
  49. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  50. */
  51. @Override
  52. public boolean onStart()
  53. {
  54. _actor = (L2EffectPointInstance) getEffected();
  55. return true;
  56. }
  57. /**
  58. *
  59. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  60. */
  61. @Override
  62. public boolean onActionTime()
  63. {
  64. if (getCount() == getTotalCount() - 1)
  65. return true; // do nothing first time
  66. int mpConsume = getSkill().getMpConsume();
  67. L2PcInstance caster = (L2PcInstance) getEffector();
  68. for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(getSkill().getSkillRadius()))
  69. {
  70. if (cha == null)
  71. continue;
  72. if (cha instanceof L2Playable)
  73. {
  74. if (caster.canAttackCharacter(cha))
  75. {
  76. L2PcInstance owner = null;
  77. if (cha instanceof L2Summon)
  78. owner = ((L2Summon) cha).getOwner();
  79. else
  80. owner = (L2PcInstance) cha;
  81. if (owner != null && owner.getPet() != null)
  82. {
  83. if (mpConsume > getEffector().getCurrentMp())
  84. {
  85. getEffector().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP));
  86. return false;
  87. }
  88. getEffector().reduceCurrentMp(mpConsume);
  89. owner.getPet().unSummon(owner);
  90. owner.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, getEffector());
  91. }
  92. }
  93. }
  94. }
  95. return true;
  96. }
  97. /**
  98. *
  99. * @see com.l2jserver.gameserver.model.L2Effect#onExit()
  100. */
  101. @Override
  102. public void onExit()
  103. {
  104. if (_actor != null)
  105. _actor.deleteMe();
  106. }
  107. }