Q00053_LinnaeusSpecialBait.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.Q00053_LinnaeusSpecialBait;
  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. import com.l2jserver.gameserver.model.skills.BuffInfo;
  28. /**
  29. * Linnaeus Special Bait (53)<br>
  30. * Original Jython script by Next and DooMita.
  31. * @author nonom
  32. */
  33. public class Q00053_LinnaeusSpecialBait extends Quest
  34. {
  35. // NPCs
  36. private static final int LINNAEUS = 31577;
  37. private static final int CRIMSON_DRAKE = 20670;
  38. // Items
  39. private static final int CRIMSON_DRAKE_HEART = 7624;
  40. private static final int FLAMING_FISHING_LURE = 7613;
  41. // Misc
  42. // Custom setting: whether or not to check for fishing skill level?
  43. // Default False to require fishing skill level, any other value to ignore fishing and evaluate char level only.
  44. private static final boolean ALT_IGNORE_FISHING = false;
  45. public Q00053_LinnaeusSpecialBait()
  46. {
  47. super(53, Q00053_LinnaeusSpecialBait.class.getSimpleName(), "Linnaeus Special Bait");
  48. addStartNpc(LINNAEUS);
  49. addTalkId(LINNAEUS);
  50. addKillId(CRIMSON_DRAKE);
  51. registerQuestItems(CRIMSON_DRAKE_HEART);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. QuestState st = getQuestState(player, false);
  57. if (st == null)
  58. {
  59. return getNoQuestMsg(player);
  60. }
  61. String htmltext = event;
  62. switch (event)
  63. {
  64. case "31577-1.htm":
  65. st.startQuest();
  66. break;
  67. case "31577-3.htm":
  68. if (st.isCond(2) && (st.getQuestItemsCount(CRIMSON_DRAKE_HEART) >= 100))
  69. {
  70. st.giveItems(FLAMING_FISHING_LURE, 4);
  71. st.exitQuest(false, true);
  72. }
  73. else
  74. {
  75. htmltext = "31577-5.html";
  76. }
  77. break;
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  83. {
  84. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  85. if (partyMember == null)
  86. {
  87. return null;
  88. }
  89. final QuestState st = getQuestState(partyMember, false);
  90. if (st.getQuestItemsCount(CRIMSON_DRAKE_HEART) < 100)
  91. {
  92. float chance = 33 * Config.RATE_QUEST_DROP;
  93. if (getRandom(100) < chance)
  94. {
  95. st.rewardItems(CRIMSON_DRAKE_HEART, 1);
  96. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  97. }
  98. }
  99. if (st.getQuestItemsCount(CRIMSON_DRAKE_HEART) >= 100)
  100. {
  101. st.setCond(2, true);
  102. }
  103. return super.onKill(npc, player, isSummon);
  104. }
  105. @Override
  106. public String onTalk(L2Npc npc, L2PcInstance player)
  107. {
  108. String htmltext = getNoQuestMsg(player);
  109. final QuestState st = getQuestState(player, true);
  110. if (st == null)
  111. {
  112. return htmltext;
  113. }
  114. switch (st.getState())
  115. {
  116. case State.COMPLETED:
  117. htmltext = getAlreadyCompletedMsg(player);
  118. break;
  119. case State.CREATED:
  120. htmltext = ((player.getLevel() > 59) && (fishingLevel(player) > 19)) ? "31577-0.htm" : "31577-0a.html";
  121. break;
  122. case State.STARTED:
  123. htmltext = (st.isCond(1)) ? "31577-4.html" : "31577-2.html";
  124. break;
  125. }
  126. return htmltext;
  127. }
  128. private static int fishingLevel(L2PcInstance player)
  129. {
  130. int level = 20;
  131. if (!ALT_IGNORE_FISHING)
  132. {
  133. level = player.getSkillLevel(1315);
  134. final BuffInfo info = player.getEffectList().getBuffInfoBySkillId(2274);
  135. if (info != null)
  136. {
  137. level = (int) info.getSkill().getPower();
  138. }
  139. }
  140. return level;
  141. }
  142. }