DrChaos.java 4.1 KB

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