Q00251_NoSecrets.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.Q00251_NoSecrets;
  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. import com.l2jserver.gameserver.util.Util;
  27. /**
  28. * No Secrets (251)
  29. * @author Dumpster
  30. */
  31. public class Q00251_NoSecrets extends Quest
  32. {
  33. public static final int PINAPS = 30201;
  34. public static final int DIARY = 15508;
  35. public static final int TABLE = 15509;
  36. private static final int[] MOBS =
  37. {
  38. 22783,
  39. 22785,
  40. 22780,
  41. 22782,
  42. 22784
  43. };
  44. private static final int[] MOBS2 =
  45. {
  46. 22775,
  47. 22776,
  48. 22778
  49. };
  50. public Q00251_NoSecrets()
  51. {
  52. super(251, Q00251_NoSecrets.class.getSimpleName(), "No Secrets");
  53. addStartNpc(PINAPS);
  54. addTalkId(PINAPS);
  55. addKillId(MOBS);
  56. addKillId(MOBS2);
  57. registerQuestItems(DIARY, TABLE);
  58. }
  59. @Override
  60. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  61. {
  62. QuestState st = getQuestState(player, false);
  63. if (st == null)
  64. {
  65. return getNoQuestMsg(player);
  66. }
  67. if (event.equals("30201-03.htm"))
  68. {
  69. st.startQuest();
  70. }
  71. return event;
  72. }
  73. @Override
  74. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  75. {
  76. final QuestState st = getQuestState(player, false);
  77. if ((st != null) && st.isStarted() && st.isCond(1))
  78. {
  79. final int npcId = npc.getId();
  80. if (Util.contains(MOBS, npcId) && (getRandom(100) < 10) && (st.getQuestItemsCount(DIARY) < 10))
  81. {
  82. st.giveItems(DIARY, 1);
  83. if ((st.getQuestItemsCount(DIARY) >= 10) && (st.getQuestItemsCount(TABLE) >= 5))
  84. {
  85. st.setCond(2, true);
  86. }
  87. else
  88. {
  89. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  90. }
  91. }
  92. else if (Util.contains(MOBS2, npcId) && (getRandom(100) < 5) && (st.getQuestItemsCount(TABLE) < 5))
  93. {
  94. st.giveItems(TABLE, 1);
  95. if ((st.getQuestItemsCount(DIARY) >= 10) && (st.getQuestItemsCount(TABLE) >= 5))
  96. {
  97. st.setCond(2, true);
  98. }
  99. else
  100. {
  101. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  102. }
  103. }
  104. }
  105. return super.onKill(npc, player, isSummon);
  106. }
  107. @Override
  108. public String onTalk(L2Npc npc, L2PcInstance player)
  109. {
  110. String htmltext = getNoQuestMsg(player);
  111. final QuestState st = getQuestState(player, true);
  112. if (st == null)
  113. {
  114. return htmltext;
  115. }
  116. switch (st.getState())
  117. {
  118. case State.CREATED:
  119. htmltext = (player.getLevel() > 81) ? "30201-01.htm" : "30201-00.htm";
  120. break;
  121. case State.STARTED:
  122. if (st.isCond(1))
  123. {
  124. htmltext = "30201-05.htm";
  125. }
  126. else if ((st.isCond(2)) && (st.getQuestItemsCount(DIARY) >= 10) && (st.getQuestItemsCount(TABLE) >= 5))
  127. {
  128. htmltext = "30201-04.htm";
  129. st.giveAdena(313355, true);
  130. st.addExpAndSp(56787, 160578);
  131. st.exitQuest(false, true);
  132. }
  133. break;
  134. case State.COMPLETED:
  135. htmltext = "30201-06.htm";
  136. break;
  137. }
  138. return htmltext;
  139. }
  140. }