L2DoorAI.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2, or (at your option)
  5. * any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. * 02111-1307, USA.
  16. *
  17. * http://www.gnu.org/copyleft/gpl.html
  18. */
  19. package net.sf.l2j.gameserver.ai;
  20. import net.sf.l2j.gameserver.ThreadPoolManager;
  21. import net.sf.l2j.gameserver.model.L2CharPosition;
  22. import net.sf.l2j.gameserver.model.L2Character;
  23. import net.sf.l2j.gameserver.model.L2Object;
  24. import net.sf.l2j.gameserver.model.L2Skill;
  25. import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
  26. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeGuardInstance;
  27. /**
  28. * @author mkizub
  29. *
  30. * TODO To change the template for this generated type comment go to
  31. * Window - Preferences - Java - Code Style - Code Templates
  32. */
  33. public class L2DoorAI extends L2CharacterAI {
  34. public L2DoorAI(L2DoorInstance.AIAccessor accessor)
  35. {
  36. super(accessor);
  37. }
  38. // rather stupid AI... well, it's for doors :D
  39. @Override
  40. protected void onIntentionIdle() {}
  41. @Override
  42. protected void onIntentionActive() {}
  43. @Override
  44. protected void onIntentionRest() {}
  45. @Override
  46. @SuppressWarnings("unused")
  47. protected void onIntentionAttack(L2Character target) {}
  48. @Override
  49. @SuppressWarnings("unused")
  50. protected void onIntentionCast(L2Skill skill, L2Object target) {}
  51. @Override
  52. @SuppressWarnings("unused")
  53. protected void onIntentionMoveTo(L2CharPosition destination) {}
  54. @Override
  55. @SuppressWarnings("unused")
  56. protected void onIntentionFollow(L2Character target) {}
  57. @Override
  58. @SuppressWarnings("unused")
  59. protected void onIntentionPickUp(L2Object item) {}
  60. @Override
  61. @SuppressWarnings("unused")
  62. protected void onIntentionInteract(L2Object object) {}
  63. @Override
  64. protected void onEvtThink() {}
  65. @Override
  66. @SuppressWarnings("unused")
  67. protected void onEvtAttacked(L2Character attacker)
  68. {
  69. L2DoorInstance me = (L2DoorInstance)_actor;
  70. ThreadPoolManager.getInstance().executeTask(new onEventAttackedDoorTask(me, attacker));
  71. }
  72. @Override
  73. @SuppressWarnings("unused")
  74. protected void onEvtAggression(L2Character target, int aggro) {}
  75. @Override
  76. @SuppressWarnings("unused")
  77. protected void onEvtStunned(L2Character attacker) {}
  78. @Override
  79. @SuppressWarnings("unused")
  80. protected void onEvtSleeping(L2Character attacker) {}
  81. @Override
  82. @SuppressWarnings("unused")
  83. protected void onEvtRooted(L2Character attacker) {}
  84. @Override
  85. protected void onEvtReadyToAct() {}
  86. @Override
  87. @SuppressWarnings("unused")
  88. protected void onEvtUserCmd(Object arg0, Object arg1) {}
  89. @Override
  90. protected void onEvtArrived() {}
  91. @Override
  92. protected void onEvtArrivedRevalidate() {}
  93. @Override
  94. @SuppressWarnings("unused")
  95. protected void onEvtArrivedBlocked(L2CharPosition blocked_at_pos) {}
  96. @Override
  97. @SuppressWarnings("unused")
  98. protected void onEvtForgetObject(L2Object object) {}
  99. @Override
  100. protected void onEvtCancel() {}
  101. @Override
  102. protected void onEvtDead() {}
  103. private class onEventAttackedDoorTask implements Runnable
  104. {
  105. private L2DoorInstance _door;
  106. private L2Character _attacker;
  107. public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker)
  108. {
  109. _door = door;
  110. _attacker = attacker;
  111. }
  112. /* (non-Javadoc)
  113. * @see java.lang.Runnable#run()
  114. */
  115. public void run()
  116. {
  117. _door.getKnownList().updateKnownObjects();
  118. for (L2SiegeGuardInstance guard : _door.getKnownSiegeGuards()) {
  119. if (_actor.isInsideRadius(guard, guard.getFactionRange(), false, true)
  120. && Math.abs(_attacker.getZ()-guard.getZ()) < 200)
  121. {
  122. guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
  123. }
  124. }
  125. }
  126. }
  127. }