L2DoorAI.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 net.sf.l2j.gameserver.ai;
  16. import net.sf.l2j.gameserver.ThreadPoolManager;
  17. import net.sf.l2j.gameserver.model.L2CharPosition;
  18. import net.sf.l2j.gameserver.model.L2Character;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.L2Skill;
  21. import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2FortSiegeGuardInstance;
  23. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeGuardInstance;
  24. /**
  25. * @author mkizub
  26. *
  27. * TODO To change the template for this generated type comment go to
  28. * Window - Preferences - Java - Code Style - Code Templates
  29. */
  30. public class L2DoorAI extends L2CharacterAI
  31. {
  32. public L2DoorAI(L2DoorInstance.AIAccessor accessor)
  33. {
  34. super(accessor);
  35. }
  36. // rather stupid AI... well, it's for doors :D
  37. @Override
  38. protected void onIntentionIdle()
  39. {
  40. }
  41. @Override
  42. protected void onIntentionActive()
  43. {
  44. }
  45. @Override
  46. protected void onIntentionRest()
  47. {
  48. }
  49. @Override
  50. protected void onIntentionAttack(L2Character target)
  51. {
  52. }
  53. @Override
  54. protected void onIntentionCast(L2Skill skill, L2Object target)
  55. {
  56. }
  57. @Override
  58. protected void onIntentionMoveTo(L2CharPosition destination)
  59. {
  60. }
  61. @Override
  62. protected void onIntentionFollow(L2Character target)
  63. {
  64. }
  65. @Override
  66. protected void onIntentionPickUp(L2Object item)
  67. {
  68. }
  69. @Override
  70. protected void onIntentionInteract(L2Object object)
  71. {
  72. }
  73. @Override
  74. protected void onEvtThink()
  75. {
  76. }
  77. @Override
  78. protected void onEvtAttacked(L2Character attacker)
  79. {
  80. L2DoorInstance me = (L2DoorInstance) _actor;
  81. ThreadPoolManager.getInstance().executeTask(new onEventAttackedDoorTask(me, attacker));
  82. }
  83. @Override
  84. protected void onEvtAggression(L2Character target, int aggro)
  85. {
  86. }
  87. @Override
  88. protected void onEvtStunned(L2Character attacker)
  89. {
  90. }
  91. @Override
  92. protected void onEvtSleeping(L2Character attacker)
  93. {
  94. }
  95. @Override
  96. protected void onEvtRooted(L2Character attacker)
  97. {
  98. }
  99. @Override
  100. protected void onEvtReadyToAct()
  101. {
  102. }
  103. @Override
  104. protected void onEvtUserCmd(Object arg0, Object arg1)
  105. {
  106. }
  107. @Override
  108. protected void onEvtArrived()
  109. {
  110. }
  111. @Override
  112. protected void onEvtArrivedRevalidate()
  113. {
  114. }
  115. @Override
  116. protected void onEvtArrivedBlocked(L2CharPosition blocked_at_pos)
  117. {
  118. }
  119. @Override
  120. protected void onEvtForgetObject(L2Object object)
  121. {
  122. }
  123. @Override
  124. protected void onEvtCancel()
  125. {
  126. }
  127. @Override
  128. protected void onEvtDead()
  129. {
  130. }
  131. private class onEventAttackedDoorTask implements Runnable
  132. {
  133. private L2DoorInstance _door;
  134. private L2Character _attacker;
  135. public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker)
  136. {
  137. _door = door;
  138. _attacker = attacker;
  139. }
  140. /* (non-Javadoc)
  141. * @see java.lang.Runnable#run()
  142. */
  143. public void run()
  144. {
  145. for (L2SiegeGuardInstance guard : _door.getKnownSiegeGuards())
  146. {
  147. if (_actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && Math.abs(_attacker.getZ() - guard.getZ()) < 200)
  148. {
  149. guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
  150. }
  151. }
  152. for (L2FortSiegeGuardInstance guard : _door.getKnownFortSiegeGuards())
  153. {
  154. if (_actor.isInsideRadius(guard, guard.getFactionRange(), false, true) && Math.abs(_attacker.getZ() - guard.getZ()) < 200)
  155. {
  156. guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
  157. }
  158. }
  159. }
  160. }
  161. }