L2PlayableAI.java 4.5 KB

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