ConditionPlayerCanEscape.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.conditions;
  20. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  21. import com.l2jserver.gameserver.model.PcCondOverride;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.entity.TvTEvent;
  25. import com.l2jserver.gameserver.model.items.L2Item;
  26. import com.l2jserver.gameserver.model.skills.Skill;
  27. /**
  28. * Player Can Escape condition implementation.
  29. * @author Adry_85
  30. */
  31. public class ConditionPlayerCanEscape extends Condition
  32. {
  33. private final boolean _val;
  34. public ConditionPlayerCanEscape(boolean val)
  35. {
  36. _val = val;
  37. }
  38. @Override
  39. public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
  40. {
  41. boolean canTeleport = true;
  42. final L2PcInstance player = effector.getActingPlayer();
  43. if (player == null)
  44. {
  45. canTeleport = false;
  46. }
  47. else if (!TvTEvent.onEscapeUse(player.getObjectId()))
  48. {
  49. canTeleport = false;
  50. }
  51. else if (player.isInDuel())
  52. {
  53. canTeleport = false;
  54. }
  55. else if (player.isAfraid())
  56. {
  57. canTeleport = false;
  58. }
  59. else if (player.isCombatFlagEquipped())
  60. {
  61. canTeleport = false;
  62. }
  63. else if (player.isFlying() || player.isFlyingMounted())
  64. {
  65. canTeleport = false;
  66. }
  67. else if (player.isInOlympiadMode())
  68. {
  69. canTeleport = false;
  70. }
  71. else if ((GrandBossManager.getInstance().getZone(player) != null) && !player.canOverrideCond(PcCondOverride.SKILL_CONDITIONS))
  72. {
  73. canTeleport = false;
  74. }
  75. return (_val == canTeleport);
  76. }
  77. }