Q452_FindingtheLostSoldiers.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 quests.Q452_FindingtheLostSoldiers;
  16. import java.util.Calendar;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. import com.l2jserver.gameserver.model.quest.State;
  22. import com.l2jserver.gameserver.util.Util;
  23. /**
  24. ** @author Gigiikun
  25. **
  26. ** 2010-08-17 Based on Freya PTS
  27. */
  28. public class Q452_FindingtheLostSoldiers extends Quest
  29. {
  30. private static final String qn = "452_FindingtheLostSoldiers";
  31. private static final int JAKAN = 32773;
  32. private static final int TAG_ID = 15513;
  33. private static final int[] SOLDIER_CORPSES = { 32769, 32770, 32771, 32772 };
  34. /*
  35. * Reset time for Quest
  36. * Default: 6:30AM on server time
  37. */
  38. private static final int RESET_HOUR = 6;
  39. private static final int RESET_MIN = 30;
  40. @Override
  41. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  42. {
  43. String htmltext = event;
  44. QuestState st = player.getQuestState(qn);
  45. if (st == null)
  46. return htmltext;
  47. if (npc.getNpcId() == JAKAN)
  48. {
  49. if (event.equalsIgnoreCase("32773-3.htm"))
  50. {
  51. st.setState(State.STARTED);
  52. st.set("cond", "1");
  53. st.playSound("ItemSound.quest_accept");
  54. }
  55. }
  56. else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId()))
  57. {
  58. if (st.getInt("cond") == 1)
  59. {
  60. st.giveItems(TAG_ID, 1);
  61. st.set("cond", "2");
  62. st.playSound("ItemSound.quest_middle");
  63. npc.deleteMe();
  64. }
  65. else
  66. htmltext = getNoQuestMsg(player);
  67. }
  68. return htmltext;
  69. }
  70. @Override
  71. public String onTalk(L2Npc npc, L2PcInstance player)
  72. {
  73. String htmltext = getNoQuestMsg(player);
  74. QuestState st = player.getQuestState(qn);
  75. if (st == null)
  76. return htmltext;
  77. if (npc.getNpcId() == JAKAN)
  78. {
  79. switch(st.getState())
  80. {
  81. case State.CREATED :
  82. if (player.getLevel() >= 84)
  83. htmltext = "32773-1.htm";
  84. else
  85. htmltext = "32773-0.htm";
  86. break;
  87. case State.STARTED :
  88. if (st.getInt("cond") == 1)
  89. htmltext = "32773-4.htm";
  90. else if (st.getInt("cond") == 2)
  91. {
  92. htmltext = "32773-5.htm";
  93. st.unset("cond");
  94. st.takeItems(TAG_ID, 1);
  95. st.giveItems(57, 95200);
  96. st.addExpAndSp(435024, 50366);
  97. st.playSound("ItemSound.quest_finish");
  98. st.exitQuest(false);
  99. Calendar reDo = Calendar.getInstance();
  100. reDo.set(Calendar.MINUTE, RESET_MIN);
  101. if (reDo.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR)
  102. reDo.add(Calendar.DATE, 1);
  103. reDo.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
  104. st.set("reDoTime", String.valueOf(reDo.getTimeInMillis()));
  105. }
  106. break;
  107. case State.COMPLETED :
  108. Long reDoTime = Long.parseLong(st.get("reDoTime"));
  109. if (reDoTime > System.currentTimeMillis())
  110. htmltext = "32773-6.htm";
  111. else
  112. {
  113. st.setState(State.CREATED);
  114. if (player.getLevel() >= 84)
  115. htmltext = "32773-1.htm";
  116. else
  117. htmltext = "32773-0.htm";
  118. }
  119. break;
  120. }
  121. }
  122. else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId()))
  123. {
  124. if (st.getInt("cond") == 1)
  125. htmltext = "corpse-1.htm";
  126. }
  127. return htmltext;
  128. }
  129. public Q452_FindingtheLostSoldiers(int questId, String name, String descr)
  130. {
  131. super(questId, name, descr);
  132. questItemIds = new int[]{ TAG_ID };
  133. addStartNpc(JAKAN);
  134. addTalkId(JAKAN);
  135. for(int i : SOLDIER_CORPSES)
  136. addTalkId(i);
  137. }
  138. public static void main(String[] args)
  139. {
  140. new Q452_FindingtheLostSoldiers(452, qn, "Finding the Lost Soldiers");
  141. }
  142. }