Hide.java 3.0 KB

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