Q00431_WeddingMarch.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.Q00431_WeddingMarch;
  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. * Wedding March (431)<br>
  28. * Original Jython script by CubicVirtuoso.
  29. * @author eyjine
  30. */
  31. public class Q00431_WeddingMarch extends Quest
  32. {
  33. // NPC
  34. private static final int KANTABILON = 31042;
  35. // Monsters
  36. private static final int[] MOBS =
  37. {
  38. 20786, // Lienrik
  39. 20787, // Lienrik Lad
  40. };
  41. // Items
  42. private static final int SILVER_CRYSTAL = 7540;
  43. private static final int WEDDING_ECHO_CRYSTAL = 7062;
  44. // Misc
  45. private static final int MIN_LEVEL = 38;
  46. private static final int CRYSTAL_COUNT = 50;
  47. public Q00431_WeddingMarch()
  48. {
  49. super(431, Q00431_WeddingMarch.class.getSimpleName(), "Wedding March");
  50. addStartNpc(KANTABILON);
  51. addTalkId(KANTABILON);
  52. addKillId(MOBS);
  53. registerQuestItems(SILVER_CRYSTAL);
  54. }
  55. @Override
  56. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  57. {
  58. final QuestState st = getQuestState(player, false);
  59. if (st == null)
  60. {
  61. return null;
  62. }
  63. String htmltext = null;
  64. if (event.equalsIgnoreCase("31042-02.htm"))
  65. {
  66. st.startQuest();
  67. htmltext = event;
  68. }
  69. else if (event.equalsIgnoreCase("31042-06.html"))
  70. {
  71. if (st.getQuestItemsCount(SILVER_CRYSTAL) < CRYSTAL_COUNT)
  72. {
  73. return "31042-05.html";
  74. }
  75. st.giveItems(WEDDING_ECHO_CRYSTAL, 25);
  76. st.exitQuest(true, true);
  77. htmltext = event;
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  83. {
  84. final L2PcInstance member = getRandomPartyMember(player, 1);
  85. if (member != null)
  86. {
  87. final QuestState st = getQuestState(member, false);
  88. if (getRandomBoolean())
  89. {
  90. st.giveItems(SILVER_CRYSTAL, 1);
  91. if (st.getQuestItemsCount(SILVER_CRYSTAL) >= CRYSTAL_COUNT)
  92. {
  93. st.setCond(2, true);
  94. }
  95. else
  96. {
  97. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  98. }
  99. }
  100. }
  101. return super.onKill(npc, player, isSummon);
  102. }
  103. @Override
  104. public String onTalk(L2Npc npc, L2PcInstance player)
  105. {
  106. String htmltext = getNoQuestMsg(player);
  107. final QuestState st = getQuestState(player, true);
  108. if (st == null)
  109. {
  110. return htmltext;
  111. }
  112. switch (st.getState())
  113. {
  114. case State.CREATED:
  115. htmltext = (player.getLevel() >= MIN_LEVEL) ? "31042-01.htm" : "31042-00.htm";
  116. break;
  117. case State.STARTED:
  118. htmltext = (st.isCond(1)) ? "31042-03.html" : "31042-04.html";
  119. break;
  120. }
  121. return htmltext;
  122. }
  123. }