EffectHide.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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.CtrlIntention;
  17. import com.l2jserver.gameserver.model.L2Effect;
  18. import com.l2jserver.gameserver.model.actor.L2Character;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.serverpackets.DeleteObject;
  21. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  22. import com.l2jserver.gameserver.skills.AbnormalEffect;
  23. import com.l2jserver.gameserver.skills.Env;
  24. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  25. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  26. /**
  27. *
  28. * @author ZaKaX - nBd
  29. */
  30. public class EffectHide extends L2Effect
  31. {
  32. public EffectHide(Env env, EffectTemplate template)
  33. {
  34. super(env, template);
  35. }
  36. public EffectHide(Env env, L2Effect effect)
  37. {
  38. super(env, effect);
  39. }
  40. /**
  41. *
  42. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  43. */
  44. @Override
  45. public L2EffectType getEffectType()
  46. {
  47. return L2EffectType.HIDE;
  48. }
  49. /**
  50. *
  51. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  52. */
  53. @Override
  54. public boolean onStart()
  55. {
  56. if (getEffected() instanceof L2PcInstance)
  57. {
  58. L2PcInstance activeChar = ((L2PcInstance) getEffected());
  59. activeChar.getAppearance().setInvisible();
  60. activeChar.startAbnormalEffect(AbnormalEffect.STEALTH);
  61. if (activeChar.getAI().getNextIntention() != null
  62. && activeChar.getAI().getNextIntention().getCtrlIntention() == CtrlIntention.AI_INTENTION_ATTACK)
  63. activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  64. L2GameServerPacket del = new DeleteObject(activeChar);
  65. for (L2Character target : activeChar.getKnownList().getKnownCharacters())
  66. {
  67. try
  68. {
  69. if (target.getTarget() == activeChar)
  70. {
  71. target.setTarget(null);
  72. target.abortAttack();
  73. target.abortCast();
  74. target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  75. }
  76. if (target instanceof L2PcInstance)
  77. target.sendPacket(del);
  78. }
  79. catch (NullPointerException e)
  80. {
  81. }
  82. }
  83. }
  84. return true;
  85. }
  86. /**
  87. *
  88. * @see com.l2jserver.gameserver.model.L2Effect#onExit()
  89. */
  90. @Override
  91. public void onExit()
  92. {
  93. if (getEffected() instanceof L2PcInstance)
  94. {
  95. L2PcInstance activeChar = ((L2PcInstance) getEffected());
  96. if (!activeChar.inObserverMode())
  97. activeChar.getAppearance().setVisible();
  98. activeChar.stopAbnormalEffect(AbnormalEffect.STEALTH);
  99. }
  100. }
  101. /**
  102. *
  103. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  104. */
  105. @Override
  106. public boolean onActionTime()
  107. {
  108. return false;
  109. }
  110. }