L2DoorAI.java 3.8 KB

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