ConditionPlayerCanResurrect.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.L2Summon;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.items.L2Item;
  24. import com.l2jserver.gameserver.model.skills.Skill;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. /**
  28. * Player Can Resurrect condition implementation.
  29. * @author UnAfraid
  30. */
  31. public class ConditionPlayerCanResurrect extends Condition
  32. {
  33. private final boolean _val;
  34. public ConditionPlayerCanResurrect(boolean val)
  35. {
  36. _val = val;
  37. }
  38. @Override
  39. public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
  40. {
  41. // Need skill rework for fix that properly
  42. if (skill.getAffectRange() > 0)
  43. {
  44. return true;
  45. }
  46. if (effected == null)
  47. {
  48. return false;
  49. }
  50. boolean canResurrect = true;
  51. if (effected.isPlayer())
  52. {
  53. final L2PcInstance player = effected.getActingPlayer();
  54. if (!player.isDead())
  55. {
  56. canResurrect = false;
  57. if (effector.isPlayer())
  58. {
  59. final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  60. msg.addSkillName(skill);
  61. effector.sendPacket(msg);
  62. }
  63. }
  64. else if (player.isResurrectionBlocked())
  65. {
  66. canResurrect = false;
  67. if (effector.isPlayer())
  68. {
  69. effector.sendPacket(SystemMessageId.REJECT_RESURRECTION);
  70. }
  71. }
  72. else if (player.isReviveRequested())
  73. {
  74. canResurrect = false;
  75. if (effector.isPlayer())
  76. {
  77. effector.sendPacket(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED);
  78. }
  79. }
  80. }
  81. else if (effected.isSummon())
  82. {
  83. final L2Summon summon = (L2Summon) effected;
  84. final L2PcInstance player = summon.getOwner();
  85. if (!summon.isDead())
  86. {
  87. canResurrect = false;
  88. if (effector.isPlayer())
  89. {
  90. final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  91. msg.addSkillName(skill);
  92. effector.sendPacket(msg);
  93. }
  94. }
  95. else if (summon.isResurrectionBlocked())
  96. {
  97. canResurrect = false;
  98. if (effector.isPlayer())
  99. {
  100. effector.sendPacket(SystemMessageId.REJECT_RESURRECTION);
  101. }
  102. }
  103. else if ((player != null) && player.isRevivingPet())
  104. {
  105. canResurrect = false;
  106. if (effector.isPlayer())
  107. {
  108. effector.sendPacket(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED); // Resurrection is already been proposed.
  109. }
  110. }
  111. }
  112. return (_val == canResurrect);
  113. }
  114. }