L2PlayableAI.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 com.l2jserver.gameserver.ai;
  16. import com.l2jserver.gameserver.model.L2Object;
  17. import com.l2jserver.gameserver.model.actor.L2Character;
  18. import com.l2jserver.gameserver.model.actor.L2Character.AIAccessor;
  19. import com.l2jserver.gameserver.model.actor.L2Playable;
  20. import com.l2jserver.gameserver.model.skills.L2Skill;
  21. import com.l2jserver.gameserver.network.SystemMessageId;
  22. /**
  23. *
  24. * This class manages AI of L2Playable.<BR><BR>
  25. *
  26. * L2PlayableAI :<BR><BR>
  27. * <li>L2SummonAI</li>
  28. * <li>L2PlayerAI</li>
  29. * <BR> <BR>
  30. *
  31. * @author JIV
  32. */
  33. public abstract class L2PlayableAI extends L2CharacterAI
  34. {
  35. /**
  36. * @param accessor
  37. */
  38. public L2PlayableAI(AIAccessor accessor)
  39. {
  40. super(accessor);
  41. }
  42. /**
  43. * @see com.l2jserver.gameserver.ai.L2CharacterAI#onIntentionAttack(com.l2jserver.gameserver.model.actor.L2Character)
  44. */
  45. @Override
  46. protected void onIntentionAttack(L2Character target)
  47. {
  48. if (target instanceof L2Playable)
  49. {
  50. if (target.getActingPlayer().getProtectionBlessing()
  51. && (_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10
  52. && _actor.getActingPlayer().getKarma() > 0
  53. && !(target.isInsideZone(L2Character.ZONE_PVP)))
  54. {
  55. // If attacker have karma and have level >= 10 than his target and target have
  56. // Newbie Protection Buff,
  57. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  58. clientActionFailed();
  59. return;
  60. }
  61. if (_actor.getActingPlayer().getProtectionBlessing()
  62. && (target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10
  63. && target.getActingPlayer().getKarma() > 0
  64. && !(target.isInsideZone(L2Character.ZONE_PVP)))
  65. {
  66. // If target have karma and have level >= 10 than his target and actor have
  67. // Newbie Protection Buff,
  68. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  69. clientActionFailed();
  70. return;
  71. }
  72. if (target.getActingPlayer().isCursedWeaponEquipped()
  73. && _actor.getActingPlayer().getLevel() <= 20)
  74. {
  75. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  76. clientActionFailed();
  77. return;
  78. }
  79. if (_actor.getActingPlayer().isCursedWeaponEquipped()
  80. && target.getActingPlayer().getLevel() <= 20)
  81. {
  82. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  83. clientActionFailed();
  84. return;
  85. }
  86. }
  87. super.onIntentionAttack(target);
  88. }
  89. /**
  90. * @see com.l2jserver.gameserver.ai.L2CharacterAI#onIntentionCast(com.l2jserver.gameserver.model.skills.L2Skill, com.l2jserver.gameserver.model.L2Object)
  91. */
  92. @Override
  93. protected void onIntentionCast(L2Skill skill, L2Object target)
  94. {
  95. if (target instanceof L2Playable && skill.isOffensive())
  96. {
  97. if (target.getActingPlayer().getProtectionBlessing()
  98. && (_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10
  99. && _actor.getActingPlayer().getKarma() > 0
  100. && !(((L2Playable) target).isInsideZone(L2Character.ZONE_PVP)))
  101. {
  102. // If attacker have karma and have level >= 10 than his target and target have
  103. // Newbie Protection Buff,
  104. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  105. clientActionFailed();
  106. _actor.setIsCastingNow(false);
  107. return;
  108. }
  109. if (_actor.getActingPlayer().getProtectionBlessing()
  110. && (target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10
  111. && target.getActingPlayer().getKarma() > 0
  112. && !(((L2Playable) target).isInsideZone(L2Character.ZONE_PVP)))
  113. {
  114. // If target have karma and have level >= 10 than his target and actor have
  115. // Newbie Protection Buff,
  116. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  117. clientActionFailed();
  118. _actor.setIsCastingNow(false);
  119. return;
  120. }
  121. if (target.getActingPlayer().isCursedWeaponEquipped()
  122. && _actor.getActingPlayer().getLevel() <= 20)
  123. {
  124. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  125. clientActionFailed();
  126. _actor.setIsCastingNow(false);
  127. return;
  128. }
  129. if (_actor.getActingPlayer().isCursedWeaponEquipped()
  130. && target.getActingPlayer().getLevel() <= 20)
  131. {
  132. _actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  133. clientActionFailed();
  134. _actor.setIsCastingNow(false);
  135. return;
  136. }
  137. }
  138. super.onIntentionCast(skill, target);
  139. }
  140. }