L2DoorAI.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.L2SiegeGuardInstance;
  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. public L2DoorAI(L2DoorInstance.AIAccessor accessor)
  31. {
  32. super(accessor);
  33. }
  34. // rather stupid AI... well, it's for doors :D
  35. @Override
  36. protected void onIntentionIdle() {}
  37. @Override
  38. protected void onIntentionActive() {}
  39. @Override
  40. protected void onIntentionRest() {}
  41. @Override
  42. @SuppressWarnings("unused")
  43. protected void onIntentionAttack(L2Character target) {}
  44. @Override
  45. @SuppressWarnings("unused")
  46. protected void onIntentionCast(L2Skill skill, L2Object target) {}
  47. @Override
  48. @SuppressWarnings("unused")
  49. protected void onIntentionMoveTo(L2CharPosition destination) {}
  50. @Override
  51. @SuppressWarnings("unused")
  52. protected void onIntentionFollow(L2Character target) {}
  53. @Override
  54. @SuppressWarnings("unused")
  55. protected void onIntentionPickUp(L2Object item) {}
  56. @Override
  57. @SuppressWarnings("unused")
  58. protected void onIntentionInteract(L2Object object) {}
  59. @Override
  60. protected void onEvtThink() {}
  61. @Override
  62. @SuppressWarnings("unused")
  63. protected void onEvtAttacked(L2Character attacker)
  64. {
  65. L2DoorInstance me = (L2DoorInstance)_actor;
  66. ThreadPoolManager.getInstance().executeTask(new onEventAttackedDoorTask(me, attacker));
  67. }
  68. @Override
  69. @SuppressWarnings("unused")
  70. protected void onEvtAggression(L2Character target, int aggro) {}
  71. @Override
  72. @SuppressWarnings("unused")
  73. protected void onEvtStunned(L2Character attacker) {}
  74. @Override
  75. @SuppressWarnings("unused")
  76. protected void onEvtSleeping(L2Character attacker) {}
  77. @Override
  78. @SuppressWarnings("unused")
  79. protected void onEvtRooted(L2Character attacker) {}
  80. @Override
  81. protected void onEvtReadyToAct() {}
  82. @Override
  83. @SuppressWarnings("unused")
  84. protected void onEvtUserCmd(Object arg0, Object arg1) {}
  85. @Override
  86. protected void onEvtArrived() {}
  87. @Override
  88. protected void onEvtArrivedRevalidate() {}
  89. @Override
  90. @SuppressWarnings("unused")
  91. protected void onEvtArrivedBlocked(L2CharPosition blocked_at_pos) {}
  92. @Override
  93. @SuppressWarnings("unused")
  94. protected void onEvtForgetObject(L2Object object) {}
  95. @Override
  96. protected void onEvtCancel() {}
  97. @Override
  98. protected void onEvtDead() {}
  99. private class onEventAttackedDoorTask implements Runnable
  100. {
  101. private L2DoorInstance _door;
  102. private L2Character _attacker;
  103. public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker)
  104. {
  105. _door = door;
  106. _attacker = attacker;
  107. }
  108. /* (non-Javadoc)
  109. * @see java.lang.Runnable#run()
  110. */
  111. public void run()
  112. {
  113. for (L2SiegeGuardInstance guard : _door.getKnownSiegeGuards()) {
  114. if (_actor.isInsideRadius(guard, guard.getFactionRange(), false, true)
  115. && Math.abs(_attacker.getZ()-guard.getZ()) < 200)
  116. {
  117. guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
  118. }
  119. }
  120. }
  121. }
  122. }