TheValentineEvent.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package events.TheValentineEvent;
  16. import com.l2jserver.gameserver.model.actor.L2Npc;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.model.event.LongTimeEvent;
  19. import com.l2jserver.gameserver.model.quest.QuestState;
  20. import com.l2jserver.gameserver.model.quest.State;
  21. /**
  22. * The Valentine Event event AI.
  23. * @author Gnacik
  24. */
  25. public class TheValentineEvent extends LongTimeEvent
  26. {
  27. private static final int _npc = 4301;
  28. private static final int _recipe = 20191;
  29. public TheValentineEvent(int questId, String name, String descr)
  30. {
  31. super(questId, name, descr);
  32. addStartNpc(_npc);
  33. addFirstTalkId(_npc);
  34. addTalkId(_npc);
  35. }
  36. @Override
  37. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  38. {
  39. final QuestState st = player.getQuestState(getName());
  40. if (st == null)
  41. {
  42. return getNoQuestMsg(player);
  43. }
  44. String htmltext = event;
  45. if (event.equalsIgnoreCase("4301-3.htm"))
  46. {
  47. if (st.isCompleted())
  48. {
  49. htmltext = "4301-4.htm";
  50. }
  51. else
  52. {
  53. st.giveItems(_recipe, 1);
  54. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  55. st.setState(State.COMPLETED);
  56. }
  57. }
  58. return htmltext;
  59. }
  60. @Override
  61. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  62. {
  63. if (player.getQuestState(getName()) == null)
  64. {
  65. newQuestState(player);
  66. }
  67. return npc.getNpcId() + ".htm";
  68. }
  69. public static void main(String[] args)
  70. {
  71. new TheValentineEvent(-1, "TheValentineEvent", "events");
  72. }
  73. }