Advertisement
Sarada-L2

Core 100% Funcional L2jBAN yo: Sarada ^^

Nov 25th, 2020
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. package ai.individual;
  2.  
  3. import ai.AbstractNpcAI;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.List;
  7.  
  8. import net.sf.l2j.Config;
  9. import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
  10. import net.sf.l2j.gameserver.model.actor.L2Attackable;
  11. import net.sf.l2j.gameserver.model.actor.L2Npc;
  12. import net.sf.l2j.gameserver.model.actor.instance.L2GrandBossInstance;
  13. import net.sf.l2j.gameserver.model.actor.Player;
  14. import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  15. import net.sf.l2j.gameserver.templates.StatsSet;
  16. import net.sf.l2j.util.Rnd;
  17.  
  18.  
  19. public class Core extends AbstractNpcAI
  20. {
  21. private static final int CORE = 29006;
  22. private static final int DEATH_KNIGHT = 29007;
  23. private static final int DOOM_WRAITH = 29008;
  24. private static final int SUSCEPTOR = 29011;
  25.  
  26. private static final byte ALIVE = 0; // Core is spawned.
  27. private static final byte DEAD = 1; // Core has been killed.
  28.  
  29. private final List<L2Attackable> _minions = new ArrayList<>();
  30.  
  31. public Core(String name, String descr)
  32. {
  33. super(name, descr);
  34.  
  35. addAttackId(CORE);
  36. addKillId(CORE, DEATH_KNIGHT, DOOM_WRAITH, SUSCEPTOR);
  37.  
  38. final StatsSet info = GrandBossManager.getInstance().getStatsSet(CORE);
  39. final int status = GrandBossManager.getInstance().getBossStatus(CORE);
  40. if (status == DEAD)
  41. {
  42. // load the unlock date and time for Core from DB
  43. final long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
  44. if (temp > 0)
  45. {
  46. // The time has not yet expired. Mark Core as currently locked (dead).
  47. startQuestTimer("core_unlock", temp, null, null, false);
  48. }
  49. else
  50. {
  51. // The time has expired while the server was offline. Spawn Core.
  52. final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0, false);
  53. GrandBossManager.getInstance().setBossStatus(CORE, ALIVE);
  54. spawnBoss(core);
  55.  
  56. }
  57. }
  58. else
  59. {
  60. info.getInteger("loc_x");
  61. info.getInteger("loc_y");
  62. info.getInteger("loc_z");
  63. info.getInteger("heading");
  64. final int hp = info.getInteger("currentHP");
  65. final int mp = info.getInteger("currentMP");
  66.  
  67. final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6500, 0, false, 0,false);
  68. core.setCurrentHpMp(hp, mp);
  69. spawnBoss(core);
  70.  
  71. }
  72. }
  73.  
  74.  
  75.  
  76. public void spawnBoss(L2GrandBossInstance npc)
  77. {
  78. GrandBossManager.getInstance().addBoss(npc);
  79. npc.broadcastPacket(new PlaySound("BS01_A"));
  80.  
  81. // Spawn minions
  82. L2Attackable mob;
  83. for (int i = 0; i < 5; i++)
  84. {
  85. int x = 16800 + i * 360;
  86. mob = (L2Attackable) addSpawn(DEATH_KNIGHT, x, 110000, npc.getZ(), 280 + Rnd.get(40), false, 0, false);
  87. mob.setIsRaidMinion(true);
  88. _minions.add(mob);
  89. mob = (L2Attackable) addSpawn(DEATH_KNIGHT, x, 109000, npc.getZ(), 280 + Rnd.get(40), false, 0, false);
  90. mob.setIsRaidMinion(true);
  91. _minions.add(mob);
  92. int x2 = 16800 + i * 600;
  93. mob = (L2Attackable) addSpawn(DOOM_WRAITH, x2, 109300, npc.getZ(), 280 + Rnd.get(40), false, 0, false);
  94. mob.setIsRaidMinion(true);
  95. _minions.add(mob);
  96. }
  97.  
  98. for (int i = 0; i < 4; i++)
  99. {
  100. int x = 16800 + i * 450;
  101. mob = (L2Attackable) addSpawn(SUSCEPTOR, x, 110300, npc.getZ(), 280 + Rnd.get(40), false, 0, false);
  102. mob.setIsRaidMinion(true);
  103. _minions.add(mob);
  104. }
  105. }
  106.  
  107. @Override
  108. public String onAdvEvent(String event, L2Npc npc, Player player)
  109. {
  110. if (event.equalsIgnoreCase("core_unlock"))
  111. {
  112. final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6500, 0, false,0, false);
  113. GrandBossManager.getInstance().setBossStatus(CORE, ALIVE);
  114. spawnBoss(core);
  115.  
  116. }
  117. else if (event.equalsIgnoreCase("spawn_minion"))
  118. {
  119. final L2Attackable mob = (L2Attackable) addSpawn(npc.getNpcId(), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false);
  120. mob.setIsRaidMinion(true);
  121. _minions.add(mob);
  122. }
  123. else if (event.equalsIgnoreCase("despawn_minions"))
  124. {
  125. for (int i = 0; i < _minions.size(); i++)
  126. {
  127. final L2Attackable mob = _minions.get(i);
  128. if (mob != null)
  129. mob.decayMe();
  130. }
  131. _minions.clear();
  132. }
  133. return super.onAdvEvent(event, npc, player);
  134. }
  135.  
  136. @Override
  137. public String onAttack(L2Npc npc, Player attacker, int damage, boolean isPet)
  138. {
  139. if (npc.isScriptValue(1))
  140. {
  141. if (Rnd.get(100) == 0)
  142. npc.broadcastNpcSay("Removing intruders.");
  143. }
  144. else
  145. {
  146. npc.setScriptValue(1);
  147. npc.broadcastNpcSay("A non-permitted target has been discovered.");
  148. npc.broadcastNpcSay("Starting intruder removal system.");
  149. }
  150. return super.onAttack(npc, attacker, damage, isPet);
  151. }
  152.  
  153. @Override
  154. public String onKill(L2Npc npc, Player killer, boolean isPet)
  155. {
  156. if (npc.getNpcId() == CORE)
  157. {
  158. npc.broadcastPacket(new PlaySound("BS02_D"));
  159. npc.broadcastNpcSay("A fatal error has occurred.");
  160. npc.broadcastNpcSay("System is being shut down...");
  161. npc.broadcastNpcSay("......");
  162.  
  163. addSpawn(31842, 16502, 110165, -6394, 0, false, 900000, false);
  164. addSpawn(31842, 18948, 110166, -6397, 0, false, 900000, false);
  165. GrandBossManager.getInstance().setBossStatus(CORE, DEAD);
  166.  
  167. long respawnTime = (long) Config.SPAWN_INTERVAL_CORE + Rnd.get(-Config.RANDOM_SPAWN_TIME_CORE, Config.RANDOM_SPAWN_TIME_CORE);
  168. respawnTime *= 3600000;
  169.  
  170. startQuestTimer("core_unlock", respawnTime, null, null, false);
  171.  
  172. final StatsSet info = GrandBossManager.getInstance().getStatsSet(CORE);
  173. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  174. GrandBossManager.getInstance().setStatsSet(CORE, info);
  175. startQuestTimer("despawn_minions", 20000, null, null, false);
  176. cancelQuestTimers("spawn_minion");
  177. }
  178. else if (GrandBossManager.getInstance().getBossStatus(CORE) == ALIVE && _minions != null && _minions.contains(npc))
  179. {
  180. _minions.remove(npc);
  181. startQuestTimer("spawn_minion", 60000, npc, null, false);
  182. }
  183. return super.onKill(npc, killer, isPet);
  184. }
  185. public static void main(String[] args)
  186. {
  187. new Core(Core.class.getSimpleName(), "ai/individual");
  188. }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement