DrChaos.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2004-2013 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 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 DrChaos(int questId, String name, String descr)
  40. {
  41. super(questId, name, descr);
  42. addFirstTalkId(DR_CHAOS);
  43. _IsGolemSpawned = false;
  44. }
  45. @Override
  46. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  47. {
  48. if (event.equalsIgnoreCase("1"))
  49. {
  50. L2Npc machine = null;
  51. for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(STRANGE_MACHINE))
  52. {
  53. if (spawn != null)
  54. {
  55. machine = spawn.getLastSpawn();
  56. }
  57. }
  58. if (machine != null)
  59. {
  60. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, machine);
  61. machine.broadcastPacket(new SpecialCamera(machine.getObjectId(), 1, -200, 15, 10000, 20000, 0, 0, 1, 0));
  62. }
  63. else
  64. {
  65. // print "Dr Chaos AI: problem finding Strange Machine (npcid = "+STRANGE_MACHINE+"). Error: not spawned!"
  66. startQuestTimer("2", 2000, npc, player);
  67. }
  68. startQuestTimer("3", 10000, npc, player);
  69. }
  70. else if (event.equalsIgnoreCase("2"))
  71. {
  72. npc.broadcastSocialAction(3);
  73. }
  74. else if (event.equalsIgnoreCase("3"))
  75. {
  76. npc.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1, -150, 10, 3000, 20000, 0, 0, 1, 0));
  77. startQuestTimer("4", 2500, npc, player);
  78. }
  79. else if (event.equalsIgnoreCase("4"))
  80. {
  81. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96055, -110759, -3312, 0));
  82. startQuestTimer("5", 2000, npc, player);
  83. }
  84. else if (event.equalsIgnoreCase("5"))
  85. {
  86. player.teleToLocation(94832, -112624, -3304);
  87. npc.teleToLocation(-113091, -243942, -15536);
  88. if (!_IsGolemSpawned)
  89. {
  90. L2Npc golem = addSpawn(CHAOS_GOLEM, 94640, -112496, -3336, 0, false, 0);
  91. _IsGolemSpawned = true;
  92. startQuestTimer("6", 1000, golem, player);
  93. player.sendPacket(new PlaySound(1, "Rm03_A", 0, 0, 0, 0, 0));
  94. }
  95. }
  96. else if (event.equalsIgnoreCase("6"))
  97. {
  98. npc.broadcastPacket(new SpecialCamera(npc.getObjectId(), 30, -200, 20, 6000, 8000, 0, 0, 1, 0));
  99. }
  100. return super.onAdvEvent(event, npc, player);
  101. }
  102. @Override
  103. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  104. {
  105. if (npc.getId() == DR_CHAOS)
  106. {
  107. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(96323, -110914, -3328, 0));
  108. this.startQuestTimer("1", 3000, npc, player);
  109. }
  110. return "";
  111. }
  112. public static void main(String[] args)
  113. {
  114. new DrChaos(-1, "Doctor Chaos", "ai");
  115. }
  116. }