L2PlayableAI.java 4.5 KB

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