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