TheValentineEvent.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2004-2013 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 events.TheValentineEvent;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.event.LongTimeEvent;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. /**
  26. * The Valentine Event event AI.
  27. * @author Gnacik
  28. */
  29. public class TheValentineEvent extends LongTimeEvent
  30. {
  31. // NPC
  32. private static final int NPC = 4301;
  33. // Item
  34. private static final int RECIPE = 20191;
  35. public TheValentineEvent(String name, String descr)
  36. {
  37. super(name, descr);
  38. addStartNpc(NPC);
  39. addFirstTalkId(NPC);
  40. addTalkId(NPC);
  41. }
  42. @Override
  43. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  44. {
  45. final QuestState st = player.getQuestState(getName());
  46. if (st == null)
  47. {
  48. return getNoQuestMsg(player);
  49. }
  50. String htmltext = event;
  51. if (event.equalsIgnoreCase("4301-3.htm"))
  52. {
  53. if (st.isCompleted())
  54. {
  55. htmltext = "4301-4.htm";
  56. }
  57. else
  58. {
  59. st.giveItems(RECIPE, 1);
  60. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  61. st.setState(State.COMPLETED);
  62. }
  63. }
  64. return htmltext;
  65. }
  66. @Override
  67. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  68. {
  69. if (player.getQuestState(getName()) == null)
  70. {
  71. newQuestState(player);
  72. }
  73. return npc.getId() + ".htm";
  74. }
  75. public static void main(String[] args)
  76. {
  77. new TheValentineEvent(TheValentineEvent.class.getSimpleName(), "events");
  78. }
  79. }