Q00450_GraveRobberRescue.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (C) 2004-2015 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 quests.Q00450_GraveRobberRescue;
  20. import com.l2jserver.gameserver.ai.CtrlIntention;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  22. import com.l2jserver.gameserver.enums.QuestType;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Attackable;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29. import com.l2jserver.gameserver.model.quest.State;
  30. import com.l2jserver.gameserver.network.NpcStringId;
  31. import com.l2jserver.gameserver.network.clientpackets.Say2;
  32. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  33. /**
  34. * Grave Robber Rescue (450)
  35. * @author malyelfik
  36. */
  37. public class Q00450_GraveRobberRescue extends Quest
  38. {
  39. // NPCs
  40. private static final int KANEMIKA = 32650;
  41. private static final int WARRIOR = 32651;
  42. // Monster
  43. private static final int WARRIOR_MON = 22741;
  44. // Item
  45. private static final int EVIDENCE_OF_MIGRATION = 14876;
  46. // Misc
  47. private static final int MIN_LEVEL = 80;
  48. public Q00450_GraveRobberRescue()
  49. {
  50. super(450, Q00450_GraveRobberRescue.class.getSimpleName(), "Grave Robber Rescue");
  51. addStartNpc(KANEMIKA);
  52. addTalkId(KANEMIKA, WARRIOR);
  53. registerQuestItems(EVIDENCE_OF_MIGRATION);
  54. }
  55. @Override
  56. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  57. {
  58. final QuestState st = getQuestState(player, false);
  59. if (st == null)
  60. {
  61. return null;
  62. }
  63. String htmltext = event;
  64. switch (event)
  65. {
  66. case "32650-04.htm":
  67. case "32650-05.htm":
  68. case "32650-06.html":
  69. break;
  70. case "32650-07.htm":
  71. st.startQuest();
  72. break;
  73. case "despawn":
  74. npc.setBusy(false);
  75. npc.deleteMe();
  76. htmltext = null;
  77. break;
  78. default:
  79. htmltext = null;
  80. break;
  81. }
  82. return htmltext;
  83. }
  84. @Override
  85. public String onTalk(L2Npc npc, L2PcInstance player)
  86. {
  87. String htmltext = getNoQuestMsg(player);
  88. final QuestState st = getQuestState(player, true);
  89. if (st == null)
  90. {
  91. return htmltext;
  92. }
  93. if (npc.getId() == KANEMIKA)
  94. {
  95. switch (st.getState())
  96. {
  97. case State.COMPLETED:
  98. if (!st.isNowAvailable())
  99. {
  100. htmltext = "32650-03.html";
  101. break;
  102. }
  103. st.setState(State.CREATED);
  104. case State.CREATED:
  105. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32650-01.htm" : "32650-02.htm";
  106. break;
  107. case State.STARTED:
  108. if (st.isCond(1))
  109. {
  110. htmltext = (!st.hasQuestItems(EVIDENCE_OF_MIGRATION)) ? "32650-08.html" : "32650-09.html";
  111. }
  112. else
  113. {
  114. st.giveAdena(65000, true); // Glory days reward: 6 886 980 exp, 8 116 410 sp, 371 400 Adena
  115. st.exitQuest(QuestType.DAILY, true);
  116. htmltext = "32650-10.html";
  117. }
  118. break;
  119. }
  120. }
  121. else if (st.isCond(1))
  122. {
  123. if (npc.isBusy())
  124. {
  125. return null;
  126. }
  127. if (getRandom(100) < 66)
  128. {
  129. st.giveItems(EVIDENCE_OF_MIGRATION, 1);
  130. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  131. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(npc.getX() + 100, npc.getY() + 100, npc.getZ(), 0));
  132. npc.setBusy(true);
  133. startQuestTimer("despawn", 3000, npc, player);
  134. if (st.getQuestItemsCount(EVIDENCE_OF_MIGRATION) == 10)
  135. {
  136. st.setCond(2, true);
  137. }
  138. htmltext = "32651-01.html";
  139. }
  140. else
  141. {
  142. if (getRandom(100) < 50)
  143. {
  144. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.GRUNT_OH));
  145. }
  146. else
  147. {
  148. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.GRUNT_WHATS_WRONG_WITH_ME));
  149. }
  150. npc.deleteMe();
  151. htmltext = null;
  152. final L2Attackable monster = (L2Attackable) addSpawn(WARRIOR_MON, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), true, 600000);
  153. monster.setRunning();
  154. monster.addDamageHate(player, 0, 999);
  155. monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  156. showOnScreenMsg(player, NpcStringId.THE_GRAVE_ROBBER_WARRIOR_HAS_BEEN_FILLED_WITH_DARK_ENERGY_AND_IS_ATTACKING_YOU, 5, 5000);
  157. }
  158. }
  159. return htmltext;
  160. }
  161. }