QueenShyeed.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 ai.individual;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  22. import com.l2jserver.gameserver.model.Location;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.zone.type.L2EffectZone;
  26. import com.l2jserver.gameserver.network.NpcStringId;
  27. import com.l2jserver.gameserver.network.clientpackets.Say2;
  28. /**
  29. * Queen Shyeed AI
  30. * @author malyelfik
  31. */
  32. public final class QueenShyeed extends AbstractNpcAI
  33. {
  34. // NPC
  35. private static final int SHYEED = 25671;
  36. private static final Location SHYEED_LOC = new Location(79634, -55428, -6104, 0);
  37. // Respawn
  38. private static final int RESPAWN = 86400000; // 24 h
  39. private static final int RANDOM_RESPAWN = 43200000; // 12 h
  40. // Zones
  41. private static final L2EffectZone MOB_BUFF_ZONE = ZoneManager.getInstance().getZoneById(200103, L2EffectZone.class);
  42. private static final L2EffectZone MOB_BUFF_DISPLAY_ZONE = ZoneManager.getInstance().getZoneById(200104, L2EffectZone.class);
  43. private static final L2EffectZone PC_BUFF_ZONE = ZoneManager.getInstance().getZoneById(200105, L2EffectZone.class);
  44. @Override
  45. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  46. {
  47. switch (event)
  48. {
  49. case "respawn":
  50. spawnShyeed();
  51. break;
  52. case "despawn":
  53. if (!npc.isDead())
  54. {
  55. npc.deleteMe();
  56. startRespawn();
  57. }
  58. break;
  59. }
  60. return null;
  61. }
  62. @Override
  63. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  64. {
  65. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.SHYEEDS_CRY_IS_STEADILY_DYING_DOWN);
  66. startRespawn();
  67. PC_BUFF_ZONE.setEnabled(true);
  68. return super.onKill(npc, killer, isSummon);
  69. }
  70. private QueenShyeed()
  71. {
  72. super(QueenShyeed.class.getSimpleName(), "ai/individual");
  73. addKillId(SHYEED);
  74. spawnShyeed();
  75. }
  76. private void spawnShyeed()
  77. {
  78. String respawn = loadGlobalQuestVar("Respawn");
  79. long remain = (!respawn.isEmpty()) ? Long.parseLong(respawn) - System.currentTimeMillis() : 0;
  80. if (remain > 0)
  81. {
  82. startQuestTimer("respawn", remain, null, null);
  83. return;
  84. }
  85. final L2Npc npc = addSpawn(SHYEED, SHYEED_LOC, false, 0);
  86. startQuestTimer("despawn", 10800000, npc, null);
  87. PC_BUFF_ZONE.setEnabled(false);
  88. MOB_BUFF_ZONE.setEnabled(true);
  89. MOB_BUFF_DISPLAY_ZONE.setEnabled(true);
  90. }
  91. private void startRespawn()
  92. {
  93. int respawnTime = RESPAWN - getRandom(RANDOM_RESPAWN);
  94. saveGlobalQuestVar("Respawn", Long.toString(System.currentTimeMillis() + respawnTime));
  95. startQuestTimer("respawn", respawnTime, null, null);
  96. MOB_BUFF_ZONE.setEnabled(false);
  97. MOB_BUFF_DISPLAY_ZONE.setEnabled(false);
  98. }
  99. public static void main(String[] args)
  100. {
  101. new QueenShyeed();
  102. }
  103. }