Q00432_BirthdayPartySong.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.Q00432_BirthdayPartySong;
  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. * Birthday Party Song (432)<br>
  28. * Original Jython script by CubicVirtuoso.
  29. * @author malyelfik
  30. */
  31. public class Q00432_BirthdayPartySong extends Quest
  32. {
  33. // NPC
  34. private static final int OCTAVIA = 31043;
  35. // Monster
  36. private static final int GOLEM = 21103;
  37. // Item
  38. private static final int RED_CRYSTAL = 7541;
  39. // Reward
  40. private static final int ECHO_CRYSTAL = 7061;
  41. public Q00432_BirthdayPartySong()
  42. {
  43. super(432, Q00432_BirthdayPartySong.class.getSimpleName(), "Birthday Party Song");
  44. addStartNpc(OCTAVIA);
  45. addTalkId(OCTAVIA);
  46. addKillId(GOLEM);
  47. registerQuestItems(RED_CRYSTAL);
  48. }
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. final QuestState st = getQuestState(player, false);
  53. if (st == null)
  54. {
  55. return null;
  56. }
  57. String htmltext = event;
  58. switch (event)
  59. {
  60. case "31043-02.htm":
  61. st.startQuest();
  62. break;
  63. case "31043-05.html":
  64. if (st.getQuestItemsCount(RED_CRYSTAL) < 50)
  65. {
  66. return "31043-06.html";
  67. }
  68. st.giveItems(ECHO_CRYSTAL, 25);
  69. st.exitQuest(true, true);
  70. break;
  71. default:
  72. htmltext = null;
  73. break;
  74. }
  75. return htmltext;
  76. }
  77. @Override
  78. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  79. {
  80. final QuestState st = getQuestState(player, false);
  81. if ((st != null) && st.isCond(1) && getRandomBoolean())
  82. {
  83. st.giveItems(RED_CRYSTAL, 1);
  84. if (st.getQuestItemsCount(RED_CRYSTAL) == 50)
  85. {
  86. st.setCond(2, true);
  87. }
  88. else
  89. {
  90. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  91. }
  92. }
  93. return super.onKill(npc, player, isSummon);
  94. }
  95. @Override
  96. public String onTalk(L2Npc npc, L2PcInstance player)
  97. {
  98. String htmltext = getNoQuestMsg(player);
  99. final QuestState st = getQuestState(player, true);
  100. if (st == null)
  101. {
  102. return htmltext;
  103. }
  104. switch (st.getState())
  105. {
  106. case State.CREATED:
  107. htmltext = (player.getLevel() >= 31) ? "31043-01.htm" : "31043-00.htm";
  108. break;
  109. case State.STARTED:
  110. htmltext = (st.isCond(1)) ? "31043-03.html" : "31043-04.html";
  111. break;
  112. }
  113. return htmltext;
  114. }
  115. }