DrChaos.java 4.0 KB

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