Q00601_WatchingEyes.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.Q00601_WatchingEyes;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. /**
  29. * Watching Eyes (601)<br>
  30. * Original Jython script by disKret.
  31. * @author malyelfik
  32. */
  33. public class Q00601_WatchingEyes extends Quest
  34. {
  35. // NPC
  36. private static final int EYE_OF_ARGOS = 31683;
  37. // Item
  38. private static final int PROOF_OF_AVENGER = 7188;
  39. // Monsters
  40. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  41. static
  42. {
  43. MOBS.put(21308, 790);
  44. MOBS.put(21309, 820);
  45. MOBS.put(21306, 850);
  46. MOBS.put(21310, 680);
  47. MOBS.put(21311, 630);
  48. }
  49. // Reward
  50. private static final int[][] REWARD =
  51. {
  52. {
  53. 6699,
  54. 90000
  55. },
  56. {
  57. 6698,
  58. 80000
  59. },
  60. {
  61. 6700,
  62. 40000
  63. },
  64. {
  65. 0,
  66. 230000
  67. }
  68. };
  69. public Q00601_WatchingEyes()
  70. {
  71. super(601, Q00601_WatchingEyes.class.getSimpleName(), "Watching Eyes");
  72. addStartNpc(EYE_OF_ARGOS);
  73. addTalkId(EYE_OF_ARGOS);
  74. addKillId(MOBS.keySet());
  75. registerQuestItems(PROOF_OF_AVENGER);
  76. }
  77. @Override
  78. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  79. {
  80. final QuestState st = getQuestState(player, false);
  81. if (st == null)
  82. {
  83. return null;
  84. }
  85. String htmltext = event;
  86. switch (event)
  87. {
  88. case "31683-02.htm":
  89. st.startQuest();
  90. break;
  91. case "31683-05.html":
  92. if (st.getQuestItemsCount(PROOF_OF_AVENGER) < 100)
  93. {
  94. return "31683-06.html";
  95. }
  96. int i = getRandom(4);
  97. if (i < 3)
  98. {
  99. st.giveItems(REWARD[i][0], 5);
  100. st.addExpAndSp(120000, 10000);
  101. }
  102. st.giveAdena(REWARD[i][1], true);
  103. st.exitQuest(true, true);
  104. break;
  105. default:
  106. htmltext = null;
  107. break;
  108. }
  109. return htmltext;
  110. }
  111. @Override
  112. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  113. {
  114. final QuestState st = getQuestState(player, false);
  115. if ((st != null) && st.isCond(1) && (getRandom(1000) < MOBS.get(npc.getId())))
  116. {
  117. st.giveItems(PROOF_OF_AVENGER, 1);
  118. if (st.getQuestItemsCount(PROOF_OF_AVENGER) == 100)
  119. {
  120. st.setCond(2, true);
  121. }
  122. else
  123. {
  124. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  125. }
  126. }
  127. return super.onKill(npc, player, isSummon);
  128. }
  129. @Override
  130. public String onTalk(L2Npc npc, L2PcInstance player)
  131. {
  132. String htmltext = getNoQuestMsg(player);
  133. final QuestState st = getQuestState(player, true);
  134. if (st == null)
  135. {
  136. return htmltext;
  137. }
  138. switch (st.getState())
  139. {
  140. case State.CREATED:
  141. htmltext = (player.getLevel() >= 71) ? "31683-01.htm" : "31683-00.htm";
  142. break;
  143. case State.STARTED:
  144. htmltext = (st.isCond(1)) ? "31683-03.html" : "31683-04.html";
  145. break;
  146. }
  147. return htmltext;
  148. }
  149. }