Q00052_WilliesSpecialBait.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.Q00052_WilliesSpecialBait;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Willie's Special Bait (52)<br>
  29. * Original Jython script by Kilkenny.
  30. * @author nonom
  31. */
  32. public class Q00052_WilliesSpecialBait extends Quest
  33. {
  34. // NPCs
  35. private static final int WILLIE = 31574;
  36. private static final int TARLK_BASILISK = 20573;
  37. // Items
  38. private static final int TARLK_EYE = 7623;
  39. private static final int EARTH_FISHING_LURE = 7612;
  40. public Q00052_WilliesSpecialBait()
  41. {
  42. super(52, Q00052_WilliesSpecialBait.class.getSimpleName(), "Willie's Special Bait");
  43. addStartNpc(WILLIE);
  44. addTalkId(WILLIE);
  45. addKillId(TARLK_BASILISK);
  46. registerQuestItems(TARLK_EYE);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. final QuestState st = getQuestState(player, false);
  52. if (st == null)
  53. {
  54. return getNoQuestMsg(player);
  55. }
  56. String htmltext = event;
  57. switch (event)
  58. {
  59. case "31574-03.htm":
  60. st.startQuest();
  61. break;
  62. case "31574-07.html":
  63. if (st.isCond(2) && (st.getQuestItemsCount(TARLK_EYE) >= 100))
  64. {
  65. htmltext = "31574-06.htm";
  66. st.giveItems(EARTH_FISHING_LURE, 4);
  67. st.exitQuest(false, true);
  68. }
  69. break;
  70. }
  71. return htmltext;
  72. }
  73. @Override
  74. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  75. {
  76. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  77. if (partyMember == null)
  78. {
  79. return null;
  80. }
  81. final QuestState st = getQuestState(partyMember, false);
  82. if (st.getQuestItemsCount(TARLK_EYE) < 100)
  83. {
  84. float chance = 33 * Config.RATE_QUEST_DROP;
  85. if (getRandom(100) < chance)
  86. {
  87. st.rewardItems(TARLK_EYE, 1);
  88. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  89. }
  90. }
  91. if (st.getQuestItemsCount(TARLK_EYE) >= 100)
  92. {
  93. st.setCond(2, true);
  94. }
  95. return super.onKill(npc, player, isSummon);
  96. }
  97. @Override
  98. public String onTalk(L2Npc npc, L2PcInstance player)
  99. {
  100. String htmltext = getNoQuestMsg(player);
  101. final QuestState st = getQuestState(player, true);
  102. if (st == null)
  103. {
  104. return htmltext;
  105. }
  106. switch (st.getState())
  107. {
  108. case State.COMPLETED:
  109. htmltext = getAlreadyCompletedMsg(player);
  110. break;
  111. case State.CREATED:
  112. htmltext = (player.getLevel() >= 48) ? "31574-01.htm" : "31574-02.html";
  113. break;
  114. case State.STARTED:
  115. htmltext = (st.isCond(1)) ? "31574-05.html" : "31574-04.html";
  116. break;
  117. }
  118. return htmltext;
  119. }
  120. }