L2PlayableAI.java 4.7 KB

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