TheValentineEvent.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // NPC
  28. private static final int NPC = 4301;
  29. // Item
  30. private static final int RECIPE = 20191;
  31. public TheValentineEvent(String name, String descr)
  32. {
  33. super(name, descr);
  34. addStartNpc(NPC);
  35. addFirstTalkId(NPC);
  36. addTalkId(NPC);
  37. }
  38. @Override
  39. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  40. {
  41. final QuestState st = player.getQuestState(getName());
  42. if (st == null)
  43. {
  44. return getNoQuestMsg(player);
  45. }
  46. String htmltext = event;
  47. if (event.equalsIgnoreCase("4301-3.htm"))
  48. {
  49. if (st.isCompleted())
  50. {
  51. htmltext = "4301-4.htm";
  52. }
  53. else
  54. {
  55. st.giveItems(RECIPE, 1);
  56. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  57. st.setState(State.COMPLETED);
  58. }
  59. }
  60. return htmltext;
  61. }
  62. @Override
  63. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  64. {
  65. if (player.getQuestState(getName()) == null)
  66. {
  67. newQuestState(player);
  68. }
  69. return npc.getNpcId() + ".htm";
  70. }
  71. public static void main(String[] args)
  72. {
  73. new TheValentineEvent(TheValentineEvent.class.getSimpleName(), "events");
  74. }
  75. }