DrChaos.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.individual;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.datatables.SpawnTable;
  18. import com.l2jserver.gameserver.model.L2CharPosition;
  19. import com.l2jserver.gameserver.model.L2Spawn;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  24. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  25. /**
  26. * DrChaos AI
  27. * @author Kerberos
  28. */
  29. public class DrChaos extends Quest
  30. {
  31. private static final int DOCTER_CHAOS = 32033;
  32. private static final int STRANGE_MACHINE = 32032;
  33. private static final int CHAOS_GOLEM = 25512;
  34. private static boolean _IsGolemSpawned;
  35. public DrChaos(int questId, String name, String descr)
  36. {
  37. super(questId, name, descr);
  38. addFirstTalkId(32033);
  39. _IsGolemSpawned = false;
  40. }
  41. public L2Npc findTemplate(int npcId)
  42. {
  43. for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
  44. {
  45. if (spawn != null && spawn.getNpcid() == npcId)
  46. {
  47. return spawn.getLastSpawn();
  48. }
  49. }
  50. return null;
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. if (event.equalsIgnoreCase("1"))
  56. {
  57. L2Npc machine_instance = findTemplate(STRANGE_MACHINE);
  58. if (machine_instance != null)
  59. {
  60. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, machine_instance);
  61. machine_instance.broadcastPacket(new SpecialCamera(machine_instance.getObjectId(), 1, -200, 15, 10000, 20000, 0, 0, 1, 0));
  62. }
  63. else
  64. // print "Dr Chaos AI: problem finding Strange Machine (npcid = "+STRANGE_MACHINE+"). Error: not spawned!"
  65. startQuestTimer("2", 2000, npc, player);
  66. startQuestTimer("3", 10000, npc, player);
  67. }
  68. else if (event.equalsIgnoreCase("2"))
  69. npc.broadcastSocialAction(3);
  70. else if (event.equalsIgnoreCase("3"))
  71. {
  72. npc.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1, -150, 10, 3000, 20000, 0, 0, 1, 0));
  73. startQuestTimer("4", 2500, npc, player);
  74. }
  75. else if (event.equalsIgnoreCase("4"))
  76. {
  77. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(96055, -110759, -3312, 0));
  78. startQuestTimer("5", 2000, npc, player);
  79. }
  80. else if (event.equalsIgnoreCase("5"))
  81. {
  82. player.teleToLocation(94832, -112624, -3304);
  83. npc.teleToLocation(-113091, -243942, -15536);
  84. if (!_IsGolemSpawned)
  85. {
  86. L2Npc golem = addSpawn(CHAOS_GOLEM, 94640, -112496, -3336, 0, false, 0);
  87. _IsGolemSpawned = true;
  88. startQuestTimer("6", 1000, golem, player);
  89. player.sendPacket(new PlaySound(1, "Rm03_A", 0, 0, 0, 0, 0));
  90. }
  91. }
  92. else if (event.equalsIgnoreCase("6"))
  93. npc.broadcastPacket(new SpecialCamera(npc.getObjectId(), 30, -200, 20, 6000, 8000, 0, 0, 1, 0));
  94. return super.onAdvEvent(event, npc, player);
  95. }
  96. @Override
  97. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  98. {
  99. if (npc.getNpcId() == DOCTER_CHAOS)
  100. {
  101. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(96323, -110914, -3328, 0));
  102. this.startQuestTimer("1", 3000, npc, player);
  103. }
  104. return "";
  105. }
  106. public static void main(String[] args)
  107. {
  108. new DrChaos(-1, "Doctor Chaos", "ai");
  109. }
  110. }