Q00324_SweetestVenom.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.Q00324_SweetestVenom;
  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. * Sweetest Venom (324)
  30. * @author xban1x
  31. */
  32. public class Q00324_SweetestVenom extends Quest
  33. {
  34. // NPCs
  35. private static final int ASTARON = 30351;
  36. // Monsters
  37. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  38. static
  39. {
  40. MONSTERS.put(20034, 26);
  41. MONSTERS.put(20038, 29);
  42. MONSTERS.put(20043, 30);
  43. }
  44. // Items
  45. private static final int VENOM_SAC = 1077;
  46. // Misc
  47. private static final int MIN_LVL = 18;
  48. private static final int REQUIRED_COUNT = 10;
  49. private static final int ADENA_COUNT = 5810;
  50. public Q00324_SweetestVenom()
  51. {
  52. super(324, Q00324_SweetestVenom.class.getSimpleName(), "Sweetest Venom");
  53. addStartNpc(ASTARON);
  54. addTalkId(ASTARON);
  55. addKillId(MONSTERS.keySet());
  56. registerQuestItems(VENOM_SAC);
  57. }
  58. @Override
  59. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  60. {
  61. final QuestState st = getQuestState(player, false);
  62. String htmltext = null;
  63. if (st != null)
  64. {
  65. if (event.equals("30351-04.htm"))
  66. {
  67. st.startQuest();
  68. htmltext = event;
  69. }
  70. }
  71. return htmltext;
  72. }
  73. @Override
  74. public String onTalk(L2Npc npc, L2PcInstance player)
  75. {
  76. final QuestState st = getQuestState(player, true);
  77. String htmltext = getNoQuestMsg(player);
  78. if (st != null)
  79. {
  80. switch (st.getState())
  81. {
  82. case State.CREATED:
  83. {
  84. htmltext = player.getLevel() < MIN_LVL ? "30351-02.html" : "30351-03.htm";
  85. break;
  86. }
  87. case State.STARTED:
  88. {
  89. if (st.isCond(2))
  90. {
  91. st.giveAdena(ADENA_COUNT, true);
  92. st.exitQuest(true, true);
  93. htmltext = "30351-06.html";
  94. }
  95. else
  96. {
  97. htmltext = "30351-05.html";
  98. }
  99. break;
  100. }
  101. }
  102. }
  103. return htmltext;
  104. }
  105. @Override
  106. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  107. {
  108. final QuestState st = getQuestState(player, false);
  109. if ((st != null) && st.isCond(1))
  110. {
  111. long sacs = st.getQuestItemsCount(VENOM_SAC);
  112. if (sacs < REQUIRED_COUNT)
  113. {
  114. if (getRandom(100) < MONSTERS.get(npc.getId()))
  115. {
  116. st.giveItems(VENOM_SAC, 1);
  117. if ((++sacs) < REQUIRED_COUNT)
  118. {
  119. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  120. }
  121. else
  122. {
  123. st.setCond(2, true);
  124. }
  125. }
  126. }
  127. }
  128. return super.onKill(npc, player, isPet);
  129. }
  130. }