CharacterBirthday.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C) 2004-2014 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.CharacterBirthday;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. import com.l2jserver.gameserver.util.Util;
  26. /**
  27. * Character Birthday event AI.<br>
  28. * Updated to H5 by Nyaran.
  29. * @author Gnacik
  30. */
  31. public final class CharacterBirthday extends Quest
  32. {
  33. private static final int ALEGRIA = 32600;
  34. private static int SPAWNS = 0;
  35. private final static int[] GK =
  36. {
  37. 30006,
  38. 30059,
  39. 30080,
  40. 30134,
  41. 30146,
  42. 30177,
  43. 30233,
  44. 30256,
  45. 30320,
  46. 30540,
  47. 30576,
  48. 30836,
  49. 30848,
  50. 30878,
  51. 30899,
  52. 31275,
  53. 31320,
  54. 31964,
  55. 32163
  56. };
  57. private CharacterBirthday()
  58. {
  59. super(-1, CharacterBirthday.class.getSimpleName(), "events");
  60. addStartNpc(ALEGRIA);
  61. addStartNpc(GK);
  62. addTalkId(ALEGRIA);
  63. addTalkId(GK);
  64. }
  65. @Override
  66. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  67. {
  68. String htmltext = event;
  69. QuestState st = getQuestState(player, false);
  70. if (event.equalsIgnoreCase("despawn_npc"))
  71. {
  72. npc.doDie(player);
  73. SPAWNS--;
  74. htmltext = null;
  75. }
  76. else if (event.equalsIgnoreCase("change"))
  77. {
  78. // Change Hat
  79. if (st.hasQuestItems(10250))
  80. {
  81. st.takeItems(10250, 1); // Adventurer Hat (Event)
  82. st.giveItems(21594, 1); // Birthday Hat
  83. htmltext = null; // FIXME: Probably has html
  84. // Despawn npc
  85. npc.doDie(player);
  86. SPAWNS--;
  87. }
  88. else
  89. {
  90. htmltext = "32600-nohat.htm";
  91. }
  92. }
  93. return htmltext;
  94. }
  95. @Override
  96. public String onTalk(L2Npc npc, L2PcInstance player)
  97. {
  98. if (SPAWNS >= 3)
  99. {
  100. return "busy.htm";
  101. }
  102. QuestState st = getQuestState(player, true);
  103. if (!Util.checkIfInRange(10, npc, player, true))
  104. {
  105. L2Npc spawned = st.addSpawn(32600, player.getX() + 10, player.getY() + 10, player.getZ() + 10, 0, false, 0, true);
  106. st.setState(State.STARTED);
  107. st.startQuestTimer("despawn_npc", 180000, spawned);
  108. SPAWNS++;
  109. }
  110. else
  111. {
  112. return "tooclose.htm";
  113. }
  114. return null;
  115. }
  116. public static void main(String[] args)
  117. {
  118. new CharacterBirthday();
  119. }
  120. }