DrChaos.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) 2004-2014 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.individual;
  20. import com.l2jserver.gameserver.ai.CtrlIntention;
  21. import com.l2jserver.gameserver.datatables.SpawnTable;
  22. import com.l2jserver.gameserver.model.L2Spawn;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  28. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  29. /**
  30. * DrChaos' AI.
  31. * @author Kerberos
  32. */
  33. public final class DrChaos extends Quest
  34. {
  35. private static final int DR_CHAOS = 32033;
  36. private static final int STRANGE_MACHINE = 32032;
  37. private static final int CHAOS_GOLEM = 25703;
  38. private static boolean _IsGolemSpawned;
  39. private static final Location PLAYER_TELEPORT = new Location(94832, -112624, -3304);
  40. private static final Location NPC_LOCATION = new Location(-113091, -243942, -15536);
  41. private DrChaos()
  42. {
  43. // TODO extends AbstractNpcAI
  44. super(-1, "Doctor Chaos", "ai/individual");
  45. addFirstTalkId(DR_CHAOS);
  46. _IsGolemSpawned = false;
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. if (event.equalsIgnoreCase("1"))
  52. {
  53. L2Npc machine = null;
  54. for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(STRANGE_MACHINE))
  55. {
  56. if (spawn != null)
  57. {
  58. machine = spawn.getLastSpawn();
  59. }
  60. }
  61. if (machine != null)
  62. {
  63. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, machine);
  64. machine.broadcastPacket(new SpecialCamera(machine, 1, -200, 15, 10000, 1000, 20000, 0, 0, 0, 0, 0));
  65. }
  66. else
  67. {
  68. startQuestTimer("2", 2000, npc, player);
  69. }
  70. startQuestTimer("3", 10000, npc, player);
  71. }
  72. else if (event.equalsIgnoreCase("2"))
  73. {
  74. npc.broadcastSocialAction(3);
  75. }
  76. else if (event.equalsIgnoreCase("3"))
  77. {
  78. npc.broadcastPacket(new SpecialCamera(npc, 1, -150, 10, 3000, 1000, 20000, 0, 0, 0, 0, 0));
  79. startQuestTimer("4", 2500, npc, player);
  80. }
  81. else if (event.equalsIgnoreCase("4"))
  82. {
  83. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96055, -110759, -3312, 0));
  84. startQuestTimer("5", 2000, npc, player);
  85. }
  86. else if (event.equalsIgnoreCase("5"))
  87. {
  88. player.teleToLocation(PLAYER_TELEPORT);
  89. npc.teleToLocation(NPC_LOCATION);
  90. if (!_IsGolemSpawned)
  91. {
  92. L2Npc golem = addSpawn(CHAOS_GOLEM, 94640, -112496, -3336, 0, false, 0);
  93. _IsGolemSpawned = true;
  94. startQuestTimer("6", 1000, golem, player);
  95. player.sendPacket(new PlaySound(1, "Rm03_A", 0, 0, 0, 0, 0));
  96. }
  97. }
  98. else if (event.equalsIgnoreCase("6"))
  99. {
  100. npc.broadcastPacket(new SpecialCamera(npc, 30, -200, 20, 6000, 700, 8000, 0, 0, 0, 0, 0));
  101. }
  102. return super.onAdvEvent(event, npc, player);
  103. }
  104. @Override
  105. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  106. {
  107. if (npc.getId() == DR_CHAOS)
  108. {
  109. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96323, -110914, -3328, 0));
  110. this.startQuestTimer("1", 3000, npc, player);
  111. }
  112. return "";
  113. }
  114. public static void main(String[] args)
  115. {
  116. new DrChaos();
  117. }
  118. }