L2DoorAI.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. protected void onIntentionAttack(L2Character target) {}
  43. @Override
  44. protected void onIntentionCast(L2Skill skill, L2Object target) {}
  45. @Override
  46. protected void onIntentionMoveTo(L2CharPosition destination) {}
  47. @Override
  48. protected void onIntentionFollow(L2Character target) {}
  49. @Override
  50. protected void onIntentionPickUp(L2Object item) {}
  51. @Override
  52. protected void onIntentionInteract(L2Object object) {}
  53. @Override
  54. protected void onEvtThink() {}
  55. @Override
  56. protected void onEvtAttacked(L2Character attacker)
  57. {
  58. L2DoorInstance me = (L2DoorInstance)_actor;
  59. ThreadPoolManager.getInstance().executeTask(new onEventAttackedDoorTask(me, attacker));
  60. }
  61. @Override
  62. protected void onEvtAggression(L2Character target, int aggro) {}
  63. @Override
  64. protected void onEvtStunned(L2Character attacker) {}
  65. @Override
  66. protected void onEvtSleeping(L2Character attacker) {}
  67. @Override
  68. protected void onEvtRooted(L2Character attacker) {}
  69. @Override
  70. protected void onEvtReadyToAct() {}
  71. @Override
  72. protected void onEvtUserCmd(Object arg0, Object arg1) {}
  73. @Override
  74. protected void onEvtArrived() {}
  75. @Override
  76. protected void onEvtArrivedRevalidate() {}
  77. @Override
  78. protected void onEvtArrivedBlocked(L2CharPosition blocked_at_pos) {}
  79. @Override
  80. protected void onEvtForgetObject(L2Object object) {}
  81. @Override
  82. protected void onEvtCancel() {}
  83. @Override
  84. protected void onEvtDead() {}
  85. private class onEventAttackedDoorTask implements Runnable
  86. {
  87. private L2DoorInstance _door;
  88. private L2Character _attacker;
  89. public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker)
  90. {
  91. _door = door;
  92. _attacker = attacker;
  93. }
  94. /* (non-Javadoc)
  95. * @see java.lang.Runnable#run()
  96. */
  97. public void run()
  98. {
  99. for (L2SiegeGuardInstance guard : _door.getKnownSiegeGuards()) {
  100. if (_actor.isInsideRadius(guard, guard.getFactionRange(), false, true)
  101. && Math.abs(_attacker.getZ()-guard.getZ()) < 200)
  102. {
  103. guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
  104. }
  105. }
  106. }
  107. }
  108. }