CharacterBirthday.java 2.8 KB

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