Q00602_ShadowOfLight.java 3.8 KB

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