LairOfAntharas.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package ai.group_template;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.actor.L2Attackable;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.network.NpcStringId;
  25. import com.l2jserver.gameserver.network.clientpackets.Say2;
  26. import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
  27. /**
  28. * Lair of Antharas AI.
  29. * @author St3eT, UnAfraid
  30. */
  31. public final class LairOfAntharas extends AbstractNpcAI
  32. {
  33. // NPC
  34. final private static int KNORIKS = 22857;
  35. final private static int DRAGON_KNIGHT = 22844;
  36. final private static int DRAGON_KNIGHT2 = 22845;
  37. final private static int ELITE_DRAGON_KNIGHT = 22846;
  38. final private static int DRAGON_GUARD = 22852;
  39. final private static int DRAGON_MAGE = 22853;
  40. // Misc
  41. final private static int KNIGHT_CHANCE = 30;
  42. final private static int KNORIKS_CHANCE = 60;
  43. final private static int KNORIKS_CHANCE2 = 50;
  44. private LairOfAntharas()
  45. {
  46. super(LairOfAntharas.class.getSimpleName(), "ai/group_template");
  47. addKillId(DRAGON_KNIGHT, DRAGON_KNIGHT2, DRAGON_GUARD, DRAGON_MAGE);
  48. addSpawnId(DRAGON_KNIGHT, DRAGON_KNIGHT2, DRAGON_GUARD, DRAGON_MAGE);
  49. addMoveFinishedId(DRAGON_GUARD, DRAGON_MAGE);
  50. addAggroRangeEnterId(KNORIKS);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. if (event.equals("CHECK_HOME") && (npc != null) && !npc.isDead())
  56. {
  57. if ((npc.calculateDistance(npc.getSpawn().getLocation(), false, false) > 10) && !npc.isInCombat())
  58. {
  59. ((L2Attackable) npc).returnHome();
  60. }
  61. else if ((npc.getHeading() != npc.getSpawn().getHeading()) && !npc.isInCombat())
  62. {
  63. npc.setHeading(npc.getSpawn().getHeading());
  64. npc.broadcastPacket(new ValidateLocation(npc));
  65. }
  66. }
  67. return super.onAdvEvent(event, npc, player);
  68. }
  69. @Override
  70. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  71. {
  72. if (npc.isScriptValue(0) && (getRandom(100) < KNORIKS_CHANCE))
  73. {
  74. if (getRandom(100) < KNORIKS_CHANCE2)
  75. {
  76. npc.setScriptValue(1);
  77. }
  78. broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId.WHOS_THERE_IF_YOU_DISTURB_THE_TEMPER_OF_THE_GREAT_LAND_DRAGON_ANTHARAS_I_WILL_NEVER_FORGIVE_YOU);
  79. }
  80. return super.onAggroRangeEnter(npc, player, isSummon);
  81. }
  82. @Override
  83. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  84. {
  85. switch (npc.getId())
  86. {
  87. case DRAGON_KNIGHT:
  88. {
  89. if (getRandom(100) > KNIGHT_CHANCE)
  90. {
  91. final L2Npc newKnight = addSpawn(DRAGON_KNIGHT2, npc, false, 0, true);
  92. npc.deleteMe();
  93. broadcastNpcSay(newKnight, Say2.NPC_SHOUT, NpcStringId.THOSE_WHO_SET_FOOT_IN_THIS_PLACE_SHALL_NOT_LEAVE_ALIVE);
  94. addAttackPlayerDesire(newKnight, killer);
  95. }
  96. break;
  97. }
  98. case DRAGON_KNIGHT2:
  99. {
  100. if (getRandom(100) > KNIGHT_CHANCE)
  101. {
  102. final L2Npc eliteKnight = addSpawn(ELITE_DRAGON_KNIGHT, npc, false, 0, true);
  103. npc.deleteMe();
  104. broadcastNpcSay(eliteKnight, Say2.NPC_SHOUT, NpcStringId.IF_YOU_WISH_TO_SEE_HELL_I_WILL_GRANT_YOU_YOUR_WISH);
  105. addAttackPlayerDesire(eliteKnight, killer);
  106. }
  107. break;
  108. }
  109. case DRAGON_GUARD:
  110. case DRAGON_MAGE:
  111. {
  112. cancelQuestTimer("CHECK_HOME", npc, null);
  113. break;
  114. }
  115. }
  116. return super.onKill(npc, killer, isSummon);
  117. }
  118. @Override
  119. public String onSpawn(L2Npc npc)
  120. {
  121. final L2Attackable mob = (L2Attackable) npc;
  122. mob.setOnKillDelay(0);
  123. if ((npc.getId() == DRAGON_GUARD) || (npc.getId() == DRAGON_MAGE))
  124. {
  125. mob.setIsNoRndWalk(true);
  126. startQuestTimer("CHECK_HOME", 10000, npc, null, true);
  127. }
  128. return super.onSpawn(npc);
  129. }
  130. public static void main(String[] args)
  131. {
  132. new LairOfAntharas();
  133. }
  134. }