ConditionPlayerCallPc.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.entity.TvTEvent;
  23. import com.l2jserver.gameserver.model.items.L2Item;
  24. import com.l2jserver.gameserver.model.skills.Skill;
  25. import com.l2jserver.gameserver.model.zone.ZoneId;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. /**
  28. * Player Call Pc condition implementation.
  29. * @author Adry_85
  30. */
  31. public class ConditionPlayerCallPc extends Condition
  32. {
  33. private final boolean _val;
  34. public ConditionPlayerCallPc(boolean val)
  35. {
  36. _val = val;
  37. }
  38. @Override
  39. public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
  40. {
  41. boolean canCallPlayer = true;
  42. final L2PcInstance player = effector.getActingPlayer();
  43. if (player == null)
  44. {
  45. canCallPlayer = false;
  46. }
  47. else if (player.isInOlympiadMode())
  48. {
  49. player.sendPacket(SystemMessageId.YOU_MAY_NOT_SUMMON_FROM_YOUR_CURRENT_LOCATION);
  50. canCallPlayer = false;
  51. }
  52. else if (player.inObserverMode())
  53. {
  54. canCallPlayer = false;
  55. }
  56. else if (!TvTEvent.onEscapeUse(player.getObjectId()))
  57. {
  58. player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  59. canCallPlayer = false;
  60. }
  61. else if (player.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || player.isInsideZone(ZoneId.JAIL) || player.isFlyingMounted())
  62. {
  63. player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  64. canCallPlayer = false;
  65. }
  66. return (_val == canCallPlayer);
  67. }
  68. }