DrChaos.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. switch (event)
  52. {
  53. case "1":
  54. {
  55. L2Npc machine = null;
  56. for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(STRANGE_MACHINE))
  57. {
  58. if (spawn != null)
  59. {
  60. machine = spawn.getLastSpawn();
  61. }
  62. }
  63. if (machine != null)
  64. {
  65. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, machine);
  66. machine.broadcastPacket(new SpecialCamera(machine, 1, -200, 15, 10000, 1000, 20000, 0, 0, 0, 0, 0));
  67. }
  68. else
  69. {
  70. startQuestTimer("2", 2000, npc, player);
  71. }
  72. startQuestTimer("3", 10000, npc, player);
  73. break;
  74. }
  75. case "2":
  76. {
  77. npc.broadcastSocialAction(3);
  78. break;
  79. }
  80. case "3":
  81. {
  82. npc.broadcastPacket(new SpecialCamera(npc, 1, -150, 10, 3000, 1000, 20000, 0, 0, 0, 0, 0));
  83. startQuestTimer("4", 2500, npc, player);
  84. break;
  85. }
  86. case "4":
  87. {
  88. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96055, -110759, -3312, 0));
  89. startQuestTimer("5", 2000, npc, player);
  90. break;
  91. }
  92. case "5":
  93. {
  94. player.teleToLocation(PLAYER_TELEPORT);
  95. npc.teleToLocation(NPC_LOCATION);
  96. if (!_IsGolemSpawned)
  97. {
  98. L2Npc golem = addSpawn(CHAOS_GOLEM, 94640, -112496, -3336, 0, false, 0);
  99. _IsGolemSpawned = true;
  100. startQuestTimer("6", 1000, golem, player);
  101. player.sendPacket(new PlaySound(1, "Rm03_A", 0, 0, 0, 0, 0));
  102. }
  103. break;
  104. }
  105. case "6":
  106. {
  107. npc.broadcastPacket(new SpecialCamera(npc, 30, -200, 20, 6000, 700, 8000, 0, 0, 0, 0, 0));
  108. break;
  109. }
  110. }
  111. return super.onAdvEvent(event, npc, player);
  112. }
  113. @Override
  114. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  115. {
  116. if (npc.getId() == DR_CHAOS)
  117. {
  118. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96323, -110914, -3328, 0));
  119. this.startQuestTimer("1", 3000, npc, player);
  120. }
  121. return "";
  122. }
  123. public static void main(String[] args)
  124. {
  125. new DrChaos();
  126. }
  127. }