Q00277_GatekeepersOffering.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.Q00277_GatekeepersOffering;
  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. * Gatekeeper's Offering (277)
  28. * @author malyelfik
  29. */
  30. public class Q00277_GatekeepersOffering extends Quest
  31. {
  32. // NPC
  33. private static final int TAMIL = 30576;
  34. // Monster
  35. private static final int GREYSTONE_GOLEM = 20333;
  36. // Items
  37. private static final int STARSTONE = 1572;
  38. private static final int GATEKEEPER_CHARM = 1658;
  39. // Misc
  40. private static final int MIN_LEVEL = 15;
  41. private static final int STARSTONE_COUT = 20;
  42. public Q00277_GatekeepersOffering()
  43. {
  44. super(277, Q00277_GatekeepersOffering.class.getSimpleName(), "Gatekeeper's Offering");
  45. addStartNpc(TAMIL);
  46. addTalkId(TAMIL);
  47. addKillId(GREYSTONE_GOLEM);
  48. registerQuestItems(STARSTONE);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. final QuestState st = getQuestState(player, false);
  54. if ((st != null) && event.equalsIgnoreCase("30576-03.htm"))
  55. {
  56. if (player.getLevel() < MIN_LEVEL)
  57. {
  58. return "30576-01.htm";
  59. }
  60. st.startQuest();
  61. return event;
  62. }
  63. return null;
  64. }
  65. @Override
  66. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  67. {
  68. final QuestState st = getQuestState(killer, false);
  69. if ((st != null) && st.isStarted() && (st.getQuestItemsCount(STARSTONE) < STARSTONE_COUT))
  70. {
  71. st.giveItems(STARSTONE, 1);
  72. if (st.getQuestItemsCount(STARSTONE) >= STARSTONE_COUT)
  73. {
  74. st.setCond(2, true);
  75. }
  76. else
  77. {
  78. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  79. }
  80. }
  81. return super.onKill(npc, killer, isSummon);
  82. }
  83. @Override
  84. public String onTalk(L2Npc npc, L2PcInstance player)
  85. {
  86. String htmltext = getNoQuestMsg(player);
  87. final QuestState st = getQuestState(player, true);
  88. if (st == null)
  89. {
  90. return htmltext;
  91. }
  92. switch (st.getState())
  93. {
  94. case State.CREATED:
  95. htmltext = "30576-02.htm";
  96. break;
  97. case State.STARTED:
  98. if (st.isCond(1))
  99. {
  100. htmltext = "30576-04.html";
  101. }
  102. else if (st.isCond(2) && (st.getQuestItemsCount(STARSTONE) >= STARSTONE_COUT))
  103. {
  104. st.giveItems(GATEKEEPER_CHARM, 2);
  105. st.exitQuest(true, true);
  106. htmltext = "30576-05.html";
  107. }
  108. break;
  109. }
  110. return htmltext;
  111. }
  112. }