IceQueensCastleNormalBattle.java 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  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 instances.IceQueensCastleNormalBattle;
  20. import instances.AbstractInstance;
  21. import java.util.ArrayList;
  22. import java.util.Collections;
  23. import java.util.List;
  24. import java.util.concurrent.CopyOnWriteArrayList;
  25. import quests.Q10286_ReunionWithSirra.Q10286_ReunionWithSirra;
  26. import com.l2jserver.gameserver.ai.CtrlIntention;
  27. import com.l2jserver.gameserver.enums.MountType;
  28. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  29. import com.l2jserver.gameserver.model.L2CommandChannel;
  30. import com.l2jserver.gameserver.model.L2Party;
  31. import com.l2jserver.gameserver.model.Location;
  32. import com.l2jserver.gameserver.model.PcCondOverride;
  33. import com.l2jserver.gameserver.model.actor.L2Attackable;
  34. import com.l2jserver.gameserver.model.actor.L2Character;
  35. import com.l2jserver.gameserver.model.actor.L2Npc;
  36. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
  38. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  39. import com.l2jserver.gameserver.model.actor.instance.L2QuestGuardInstance;
  40. import com.l2jserver.gameserver.model.actor.instance.L2RaidBossInstance;
  41. import com.l2jserver.gameserver.model.holders.SkillHolder;
  42. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  43. import com.l2jserver.gameserver.model.quest.QuestState;
  44. import com.l2jserver.gameserver.model.quest.State;
  45. import com.l2jserver.gameserver.model.skills.Skill;
  46. import com.l2jserver.gameserver.model.variables.NpcVariables;
  47. import com.l2jserver.gameserver.network.NpcStringId;
  48. import com.l2jserver.gameserver.network.SystemMessageId;
  49. import com.l2jserver.gameserver.network.clientpackets.Say2;
  50. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  51. import com.l2jserver.gameserver.network.serverpackets.ExChangeClientEffectInfo;
  52. import com.l2jserver.gameserver.network.serverpackets.ExSendUIEvent;
  53. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  54. import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
  55. import com.l2jserver.gameserver.util.Util;
  56. /**
  57. * Ice Queen's Castle (Normal Battle) instance zone.
  58. * @author St3eT
  59. */
  60. public final class IceQueensCastleNormalBattle extends AbstractInstance
  61. {
  62. protected class IQCNBWorld extends InstanceWorld
  63. {
  64. protected List<L2PcInstance> playersInside = new ArrayList<>();
  65. protected List<L2Npc> knightStatues = new ArrayList<>();
  66. protected List<L2Attackable> spawnedMobs = new CopyOnWriteArrayList<>();
  67. protected L2NpcInstance controller = null;
  68. protected L2GrandBossInstance freya = null;
  69. protected L2QuestGuardInstance supp_Jinia = null;
  70. protected L2QuestGuardInstance supp_Kegor = null;
  71. protected boolean isSupportActive = false;
  72. protected boolean canSpawnMobs = true;
  73. }
  74. // Npcs
  75. private static final int FREYA_THRONE = 29177; // First freya
  76. private static final int FREYA_SPELLING = 29178; // Second freya
  77. private static final int FREYA_STAND = 29179; // Last freya
  78. private static final int INVISIBLE_NPC = 18919;
  79. private static final int KNIGHT = 18855; // Archery Knight
  80. private static final int GLACIER = 18853; // Glacier
  81. private static final int BREATH = 18854; // Archer's Breath
  82. private static final int GLAKIAS = 25699; // Glakias (Archery Knight Captain)
  83. private static final int SIRRA = 32762; // Sirra
  84. private static final int JINIA = 32781; // Jinia
  85. private static final int SUPP_JINIA = 18850; // Jinia
  86. private static final int SUPP_KEGOR = 18851; // Kegor
  87. // Skills
  88. private static final SkillHolder BLIZZARD = new SkillHolder(6274, 1); // Eternal Blizzard
  89. private static final SkillHolder BLIZZARD_BREATH = new SkillHolder(6299, 1); // Breath of Ice Palace - Ice Storm
  90. private static final SkillHolder SUICIDE_BREATH = new SkillHolder(6300, 1); // Self-Destruction
  91. private static final SkillHolder JINIA_SUPPORT = new SkillHolder(6288, 1); // Jinia's Prayer
  92. private static final SkillHolder KEGOR_SUPPORT = new SkillHolder(6289, 1); // Kegor's Courage
  93. private static final SkillHolder ICE_STONE = new SkillHolder(6301, 1); // Cold Mana's Fragment
  94. private static final SkillHolder CANCEL = new SkillHolder(4618, 1); // NPC Cancel PC Target
  95. private static final SkillHolder POWER_STRIKE = new SkillHolder(6293, 1); // Power Strike
  96. private static final SkillHolder POINT_TARGET = new SkillHolder(6295, 1); // Point Target
  97. private static final SkillHolder CYLINDER_THROW = new SkillHolder(6297, 1); // Cylinder Throw
  98. private static final SkillHolder SelfRangeBuff = new SkillHolder(6294, 1); // Leader's Roar
  99. private static final SkillHolder LEADER_RUSH = new SkillHolder(6296, 1); // Rush
  100. private static final SkillHolder ANTI_STRIDER = new SkillHolder(4258, 1); // Hinder Strider
  101. private static final SkillHolder ICE_BALL = new SkillHolder(6278, 1); // Ice Ball
  102. private static final SkillHolder SUMMON_ELEMENTAL = new SkillHolder(6277, 1); // Summon Spirits
  103. private static final SkillHolder SELF_NOVA = new SkillHolder(6279, 1); // Attack Nearby Range
  104. private static final SkillHolder REFLECT_MAGIC = new SkillHolder(6282, 1); // Reflect Magic
  105. // Locations
  106. private static final Location FREYA_SPAWN = new Location(114720, -117085, -11088, 15956);
  107. private static final Location FREYA_SPELLING_SPAWN = new Location(114723, -117502, -10672, 15956);
  108. private static final Location FREYA_CORPSE = new Location(114767, -114795, -11200, 0);
  109. private static final Location MIDDLE_POINT = new Location(114730, -114805, -11200);
  110. private static final Location KEGOR_FINISH = new Location(114659, -114796, -11205);
  111. private static final Location GLAKIAS_SPAWN = new Location(114707, -114799, -11199, 15956);
  112. private static final Location SUPP_JINIA_SPAWN = new Location(114751, -114781, -11205);
  113. private static final Location SUPP_KEGOR_SPAWN = new Location(114659, -114796, -11205);
  114. private static final Location BATTLE_PORT = new Location(114694, -113700, -11200);
  115. private static final Location CONTROLLER_LOC = new Location(114394, -112383, -11200);
  116. private static final Location[] ENTER_LOC =
  117. {
  118. new Location(114185, -112435, -11210),
  119. new Location(114183, -112280, -11210),
  120. new Location(114024, -112435, -11210),
  121. new Location(114024, -112278, -11210),
  122. new Location(113865, -112435, -11210),
  123. new Location(113865, -112276, -11210),
  124. };
  125. private static final Location[] STATUES_LOC =
  126. {
  127. new Location(113845, -116091, -11168, 8264),
  128. new Location(113381, -115622, -11168, 8264),
  129. new Location(113380, -113978, -11168, -8224),
  130. new Location(113845, -113518, -11168, -8224),
  131. new Location(115591, -113516, -11168, -24504),
  132. new Location(116053, -113981, -11168, -24504),
  133. new Location(116061, -115611, -11168, 24804),
  134. new Location(115597, -116080, -11168, 24804),
  135. new Location(112942, -115480, -10960, 52),
  136. new Location(112940, -115146, -10960, 52),
  137. new Location(112945, -114453, -10960, 52),
  138. new Location(112945, -114123, -10960, 52),
  139. new Location(116497, -114117, -10960, 32724),
  140. new Location(116499, -114454, -10960, 32724),
  141. new Location(116501, -115145, -10960, 32724),
  142. new Location(116502, -115473, -10960, 32724),
  143. };
  144. private static Location[] KNIGHTS_LOC =
  145. {
  146. new Location(114502, -115315, -11205, 15451),
  147. new Location(114937, -115323, -11205, 18106),
  148. new Location(114722, -115185, -11205, 16437),
  149. };
  150. // Misc
  151. private static final int MAX_PLAYERS = 27;
  152. private static final int MIN_PLAYERS = 10;
  153. private static final int MIN_LEVEL = 82;
  154. private static final int TEMPLATE_ID = 139; // Ice Queen's Castle
  155. private static final int DOOR_ID = 23140101;
  156. public IceQueensCastleNormalBattle()
  157. {
  158. super(IceQueensCastleNormalBattle.class.getSimpleName());
  159. addStartNpc(SIRRA, SUPP_KEGOR, SUPP_JINIA);
  160. addFirstTalkId(SUPP_KEGOR, SUPP_JINIA);
  161. addTalkId(SIRRA, JINIA, SUPP_KEGOR);
  162. addAttackId(FREYA_THRONE, FREYA_STAND, GLAKIAS, GLACIER, BREATH, KNIGHT);
  163. addKillId(GLAKIAS, FREYA_STAND, KNIGHT, GLACIER, BREATH);
  164. addSpawnId(GLAKIAS, FREYA_STAND, KNIGHT, GLACIER, BREATH);
  165. addSpellFinishedId(GLACIER, BREATH);
  166. }
  167. @Override
  168. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  169. {
  170. if (event.equals("enter"))
  171. {
  172. enterInstance(player, new IQCNBWorld(), "IceQueensCastleNormalBattle.xml", TEMPLATE_ID);
  173. }
  174. else
  175. {
  176. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  177. if ((tmpworld != null) && (tmpworld instanceof IQCNBWorld))
  178. {
  179. final IQCNBWorld world = (IQCNBWorld) tmpworld;
  180. switch (event)
  181. {
  182. case "openDoor":
  183. {
  184. if (npc.isScriptValue(0))
  185. {
  186. npc.setScriptValue(1);
  187. openDoor(DOOR_ID, world.getInstanceId());
  188. world.controller = (L2NpcInstance) addSpawn(INVISIBLE_NPC, CONTROLLER_LOC, false, 0, true, world.getInstanceId());
  189. for (Location loc : STATUES_LOC)
  190. {
  191. if (loc.getZ() == -11168)
  192. {
  193. final L2Npc statue = addSpawn(INVISIBLE_NPC, loc, false, 0, false, world.getInstanceId());
  194. world.knightStatues.add(statue);
  195. }
  196. }
  197. for (L2PcInstance players : world.playersInside)
  198. {
  199. if ((players != null) && !players.isDead() && (players.getInstanceId() == world.getInstanceId()))
  200. {
  201. final QuestState qs = player.getQuestState(Q10286_ReunionWithSirra.class.getSimpleName());
  202. if ((qs != null) && (qs.getState() == State.STARTED) && qs.isCond(5))
  203. {
  204. qs.setCond(6, true);
  205. }
  206. }
  207. }
  208. startQuestTimer("STAGE_1_MOVIE", 60000, world.controller, null);
  209. }
  210. break;
  211. }
  212. case "portInside":
  213. {
  214. teleportPlayer(player, BATTLE_PORT, world.getInstanceId());
  215. break;
  216. }
  217. case "killFreya":
  218. {
  219. final QuestState qs = player.getQuestState(Q10286_ReunionWithSirra.class.getSimpleName());
  220. if ((qs != null) && (qs.getState() == State.STARTED) && qs.isCond(6))
  221. {
  222. qs.setMemoState(10);
  223. qs.setCond(7, true);
  224. }
  225. world.supp_Kegor.deleteMe();
  226. world.freya.decayMe();
  227. manageMovie(world, 20);
  228. cancelQuestTimer("FINISH_WORLD", world.controller, null);
  229. startQuestTimer("FINISH_WORLD", 58500, world.controller, null);
  230. break;
  231. }
  232. case "18851-01.html":
  233. {
  234. return event;
  235. }
  236. case "STAGE_1_MOVIE":
  237. {
  238. closeDoor(DOOR_ID, world.getInstanceId());
  239. world.setStatus(1);
  240. manageMovie(world, 15);
  241. startQuestTimer("STAGE_1_START", 53500, world.controller, null);
  242. break;
  243. }
  244. case "STAGE_1_START":
  245. {
  246. world.freya = (L2GrandBossInstance) addSpawn(FREYA_THRONE, FREYA_SPAWN, false, 0, true, world.getInstanceId());
  247. world.freya.setIsMortal(false);
  248. manageScreenMsg(world, NpcStringId.BEGIN_STAGE_1);
  249. startQuestTimer("CAST_BLIZZARD", 50000, world.controller, null);
  250. startQuestTimer("STAGE_1_SPAWN", 2000, world.freya, null);
  251. break;
  252. }
  253. case "STAGE_1_SPAWN":
  254. {
  255. notifyEvent("START_SPAWN", world.controller, null);
  256. break;
  257. }
  258. case "STAGE_1_FINISH":
  259. {
  260. world.freya.deleteMe();
  261. world.freya = null;
  262. manageDespawnMinions(world);
  263. manageMovie(world, 16);
  264. startQuestTimer("STAGE_1_PAUSE", 24100 - 1000, world.controller, null);
  265. break;
  266. }
  267. case "STAGE_1_PAUSE":
  268. {
  269. world.freya = (L2GrandBossInstance) addSpawn(FREYA_SPELLING, FREYA_SPELLING_SPAWN, false, 0, true, world.getInstanceId());
  270. world.freya.setIsInvul(true);
  271. world.freya.disableCoreAI(true);
  272. manageTimer(world, 60);
  273. world.setStatus(2);
  274. startQuestTimer("STAGE_2_START", 60000, world.controller, null);
  275. break;
  276. }
  277. case "STAGE_2_START":
  278. {
  279. world.canSpawnMobs = true;
  280. notifyEvent("START_SPAWN", world.controller, null);
  281. manageScreenMsg(world, NpcStringId.BEGIN_STAGE_2);
  282. break;
  283. }
  284. case "STAGE_2_MOVIE":
  285. {
  286. manageMovie(world, 23);
  287. startQuestTimer("STAGE_2_GLAKIAS", 7000, world.controller, null);
  288. break;
  289. }
  290. case "STAGE_2_GLAKIAS":
  291. {
  292. for (Location loc : STATUES_LOC)
  293. {
  294. if (loc.getZ() == -10960)
  295. {
  296. final L2Npc statue = addSpawn(INVISIBLE_NPC, loc, false, 0, false, world.getInstanceId());
  297. world.knightStatues.add(statue);
  298. startQuestTimer("SPAWN_KNIGHT", 5000, statue, null);
  299. }
  300. }
  301. final L2RaidBossInstance glakias = (L2RaidBossInstance) addSpawn(GLAKIAS, GLAKIAS_SPAWN, false, 0, true, world.getInstanceId());
  302. startQuestTimer("LEADER_DELAY", 5000, glakias, null);
  303. break;
  304. }
  305. case "STAGE_3_MOVIE":
  306. {
  307. manageMovie(world, 17);
  308. startQuestTimer("STAGE_3_START", 21500, world.controller, null);
  309. break;
  310. }
  311. case "STAGE_3_START":
  312. {
  313. for (L2PcInstance players : world.playersInside)
  314. {
  315. if (players != null)
  316. {
  317. players.broadcastPacket(ExChangeClientEffectInfo.STATIC_FREYA_DESTROYED);
  318. }
  319. }
  320. world.setStatus(4);
  321. world.freya.deleteMe();
  322. world.canSpawnMobs = true;
  323. world.freya = (L2GrandBossInstance) addSpawn(FREYA_STAND, FREYA_SPAWN, false, 0, true, world.getInstanceId());
  324. world.controller.getVariables().set("FREYA_MOVE", 0);
  325. notifyEvent("START_SPAWN", world.controller, null);
  326. startQuestTimer("START_MOVE", 10000, world.controller, null);
  327. startQuestTimer("CAST_BLIZZARD", 50000, world.controller, null);
  328. manageScreenMsg(world, NpcStringId.BEGIN_STAGE_3);
  329. break;
  330. }
  331. case "START_MOVE":
  332. {
  333. if (npc.getVariables().getInt("FREYA_MOVE") == 0)
  334. {
  335. world.controller.getVariables().set("FREYA_MOVE", 1);
  336. world.freya.setIsRunning(true);
  337. world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
  338. }
  339. break;
  340. }
  341. case "CAST_BLIZZARD":
  342. {
  343. if (!world.freya.isInvul())
  344. {
  345. world.freya.doCast(BLIZZARD.getSkill());
  346. manageScreenMsg(world, NpcStringId.STRONG_MAGIC_POWER_CAN_BE_FELT_FROM_SOMEWHERE);
  347. }
  348. for (L2Attackable minion : world.spawnedMobs)
  349. {
  350. if ((minion != null) && !minion.isDead() && !minion.isInCombat())
  351. {
  352. manageRandomAttack(world, minion);
  353. }
  354. }
  355. startQuestTimer("CAST_BLIZZARD", getRandom(55, 60) * 1000, world.controller, null);
  356. break;
  357. }
  358. case "SPAWN_SUPPORT":
  359. {
  360. for (L2PcInstance players : world.playersInside)
  361. {
  362. if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
  363. {
  364. players.setIsInvul(false);
  365. }
  366. }
  367. world.freya.setIsInvul(false);
  368. world.freya.disableCoreAI(false);
  369. manageScreenMsg(world, NpcStringId.BEGIN_STAGE_4);
  370. world.supp_Jinia = (L2QuestGuardInstance) addSpawn(SUPP_JINIA, SUPP_JINIA_SPAWN, false, 0, true, world.getInstanceId());
  371. world.supp_Jinia.setIsRunning(true);
  372. world.supp_Jinia.setIsInvul(true);
  373. world.supp_Jinia.setCanReturnToSpawnPoint(false);
  374. world.supp_Kegor = (L2QuestGuardInstance) addSpawn(SUPP_KEGOR, SUPP_KEGOR_SPAWN, false, 0, true, world.getInstanceId());
  375. world.supp_Kegor.setIsRunning(true);
  376. world.supp_Kegor.setIsInvul(true);
  377. world.supp_Kegor.setCanReturnToSpawnPoint(false);
  378. startQuestTimer("ATTACK_FREYA", 5000, world.supp_Jinia, null);
  379. startQuestTimer("ATTACK_FREYA", 5000, world.supp_Kegor, null);
  380. startQuestTimer("GIVE_SUPPORT", 1000, world.controller, null);
  381. break;
  382. }
  383. case "GIVE_SUPPORT":
  384. {
  385. if (world.isSupportActive)
  386. {
  387. world.supp_Jinia.doCast(JINIA_SUPPORT.getSkill());
  388. world.supp_Kegor.doCast(KEGOR_SUPPORT.getSkill());
  389. startQuestTimer("GIVE_SUPPORT", 25000, world.controller, null);
  390. }
  391. break;
  392. }
  393. case "FINISH_STAGE":
  394. {
  395. world.supp_Jinia.deleteMe();
  396. world.supp_Jinia = null;
  397. world.freya.teleToLocation(FREYA_CORPSE);
  398. world.supp_Kegor.teleToLocation(KEGOR_FINISH);
  399. break;
  400. }
  401. case "START_SPAWN":
  402. {
  403. for (L2Npc statues : world.knightStatues)
  404. {
  405. notifyEvent("SPAWN_KNIGHT", statues, null);
  406. }
  407. for (Location loc : KNIGHTS_LOC)
  408. {
  409. final L2Attackable knight = (L2Attackable) addSpawn(KNIGHT, loc, false, 0, false, world.getInstanceId());
  410. knight.disableCoreAI(true);
  411. knight.setDisplayEffect(1);
  412. knight.getSpawn().setLocation(loc);
  413. world.spawnedMobs.add(knight);
  414. startQuestTimer("ICE_RUPTURE", getRandom(2, 5) * 1000, knight, null);
  415. }
  416. for (int i = 0; i < world.getStatus(); i++)
  417. {
  418. notifyEvent("SPAWN_GLACIER", world.controller, null);
  419. }
  420. break;
  421. }
  422. case "SPAWN_KNIGHT":
  423. {
  424. if (world.canSpawnMobs)
  425. {
  426. final Location loc = new Location(MIDDLE_POINT.getX() + getRandom(-1000, 1000), MIDDLE_POINT.getY() + getRandom(-1000, 1000), MIDDLE_POINT.getZ());
  427. final L2Attackable knight = (L2Attackable) addSpawn(KNIGHT, npc.getLocation(), false, 0, false, world.getInstanceId());
  428. knight.getVariables().set("SPAWNED_NPC", npc);
  429. knight.disableCoreAI(true);
  430. knight.setIsImmobilized(true);
  431. knight.setDisplayEffect(1);
  432. knight.getSpawn().setLocation(loc);
  433. world.spawnedMobs.add(knight);
  434. startQuestTimer("ICE_RUPTURE", getRandom(5, 10) * 1000, knight, null);
  435. }
  436. break;
  437. }
  438. case "SPAWN_GLACIER":
  439. {
  440. if (world.canSpawnMobs)
  441. {
  442. final Location loc = new Location(MIDDLE_POINT.getX() + getRandom(-1000, 1000), MIDDLE_POINT.getY() + getRandom(-1000, 1000), MIDDLE_POINT.getZ());
  443. final L2Attackable glacier = (L2Attackable) addSpawn(GLACIER, loc, false, 0, false, world.getInstanceId());
  444. glacier.setDisplayEffect(1);
  445. glacier.disableCoreAI(true);
  446. glacier.setIsImmobilized(true);
  447. world.spawnedMobs.add(glacier);
  448. startQuestTimer("CHANGE_STATE", 1400, glacier, null);
  449. }
  450. break;
  451. }
  452. case "ICE_RUPTURE":
  453. {
  454. if (npc.isCoreAIDisabled())
  455. {
  456. npc.disableCoreAI(false);
  457. npc.setIsImmobilized(false);
  458. npc.setDisplayEffect(2);
  459. manageRandomAttack(world, (L2Attackable) npc);
  460. }
  461. break;
  462. }
  463. case "FIND_TARGET":
  464. {
  465. manageRandomAttack(world, (L2Attackable) npc);
  466. break;
  467. }
  468. case "CHANGE_STATE":
  469. {
  470. npc.setDisplayEffect(2);
  471. startQuestTimer("CAST_SKILL", 20000, npc, null);
  472. break;
  473. }
  474. case "CAST_SKILL":
  475. {
  476. if (npc.isScriptValue(0) && !npc.isDead())
  477. {
  478. npc.setTarget(npc);
  479. npc.doCast(ICE_STONE.getSkill());
  480. npc.setScriptValue(1);
  481. }
  482. break;
  483. }
  484. case "SUICIDE":
  485. {
  486. npc.setDisplayEffect(3);
  487. npc.setIsMortal(true);
  488. npc.doDie(null);
  489. break;
  490. }
  491. case "BLIZZARD":
  492. {
  493. npc.getVariables().set("SUICIDE_COUNT", npc.getVariables().getInt("SUICIDE_COUNT") + 1);
  494. if (npc.getVariables().getInt("SUICIDE_ON") == 0)
  495. {
  496. if (npc.getVariables().getInt("SUICIDE_COUNT") == 2)
  497. {
  498. startQuestTimer("ELEMENTAL_SUICIDE", 20000, npc, null);
  499. }
  500. else
  501. {
  502. if (npc.checkDoCastConditions(BLIZZARD_BREATH.getSkill()) && !npc.isCastingNow())
  503. {
  504. npc.setTarget(npc);
  505. npc.doCast(BLIZZARD_BREATH.getSkill());
  506. }
  507. startQuestTimer("BLIZZARD", 20000, npc, null);
  508. }
  509. }
  510. break;
  511. }
  512. case "ELEMENTAL_SUICIDE":
  513. {
  514. npc.setTarget(npc);
  515. npc.doCast(SUICIDE_BREATH.getSkill());
  516. break;
  517. }
  518. case "ELEMENTAL_KILLED":
  519. {
  520. if (npc.getVariables().getInt("SUICIDE_ON") == 1)
  521. {
  522. npc.setTarget(npc);
  523. npc.doCast(SUICIDE_BREATH.getSkill());
  524. }
  525. break;
  526. }
  527. case "ATTACK_FREYA":
  528. {
  529. final SkillHolder skill = npc.getTemplate().getParameters().getObject("Skill01_ID", SkillHolder.class);
  530. if (npc.isInsideRadius(world.freya, 100, true, false))
  531. {
  532. if (npc.checkDoCastConditions(skill.getSkill()) && !npc.isCastingNow())
  533. {
  534. npc.setTarget(world.freya);
  535. npc.doCast(skill.getSkill());
  536. startQuestTimer("ATTACK_FREYA", 20000, npc, null);
  537. }
  538. else
  539. {
  540. startQuestTimer("ATTACK_FREYA", 5000, npc, null);
  541. }
  542. }
  543. else
  544. {
  545. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, world.freya);
  546. startQuestTimer("ATTACK_FREYA", 5000, npc, null);
  547. }
  548. break;
  549. }
  550. case "FINISH_WORLD":
  551. {
  552. if (world.freya != null)
  553. {
  554. world.freya.decayMe();
  555. }
  556. for (L2PcInstance players : world.playersInside)
  557. {
  558. if ((players != null))
  559. {
  560. players.broadcastPacket(ExChangeClientEffectInfo.STATIC_FREYA_DEFAULT);
  561. }
  562. }
  563. InstanceManager.getInstance().destroyInstance(world.getInstanceId());
  564. break;
  565. }
  566. case "LEADER_RANGEBUFF":
  567. {
  568. if (npc.checkDoCastConditions(SelfRangeBuff.getSkill()) && !npc.isCastingNow())
  569. {
  570. npc.setTarget(npc);
  571. npc.doCast(SelfRangeBuff.getSkill());
  572. }
  573. else
  574. {
  575. startQuestTimer("LEADER_RANGEBUFF", 30000, npc, null);
  576. }
  577. break;
  578. }
  579. case "LEADER_RANDOMIZE":
  580. {
  581. final L2Attackable mob = (L2Attackable) npc;
  582. mob.clearAggroList();
  583. for (L2Character characters : npc.getKnownList().getKnownPlayersInRadius(1000))
  584. {
  585. if ((characters != null))
  586. {
  587. mob.addDamageHate(characters, 0, getRandom(10000, 20000));
  588. }
  589. }
  590. startQuestTimer("LEADER_RANDOMIZE", 25000, npc, null);
  591. break;
  592. }
  593. case "LEADER_DASH":
  594. {
  595. final L2Character mostHated = ((L2Attackable) npc).getMostHated();
  596. if (getRandomBoolean() && !npc.isCastingNow() && (mostHated != null) && !mostHated.isDead() && (npc.calculateDistance(mostHated, true, false) < 1000))
  597. {
  598. npc.setTarget(mostHated);
  599. npc.doCast(LEADER_RUSH.getSkill());
  600. }
  601. startQuestTimer("LEADER_DASH", 10000, npc, null);
  602. break;
  603. }
  604. case "LEADER_DESTROY":
  605. {
  606. final L2Attackable mob = (L2Attackable) npc;
  607. if (npc.getVariables().getInt("OFF_SHOUT") == 0)
  608. {
  609. manageScreenMsg(world, NpcStringId.THE_SPACE_FEELS_LIKE_ITS_GRADUALLY_STARTING_TO_SHAKE);
  610. switch (getRandom(4))
  611. {
  612. case 0:
  613. {
  614. broadcastNpcSay(npc, Say2.SHOUT, NpcStringId.ARCHER_GIVE_YOUR_BREATH_FOR_THE_INTRUDER);
  615. break;
  616. }
  617. case 1:
  618. {
  619. broadcastNpcSay(npc, Say2.SHOUT, NpcStringId.MY_KNIGHTS_SHOW_YOUR_LOYALTY);
  620. break;
  621. }
  622. case 2:
  623. {
  624. broadcastNpcSay(npc, Say2.SHOUT, NpcStringId.I_CAN_TAKE_IT_NO_LONGER);
  625. break;
  626. }
  627. case 3:
  628. {
  629. broadcastNpcSay(npc, Say2.SHOUT, NpcStringId.ARCHER_HEED_MY_CALL);
  630. for (int i = 0; i < 3; i++)
  631. {
  632. final L2Attackable breath = (L2Attackable) addSpawn(BREATH, npc.getLocation(), true, 0, false, world.getInstanceId());
  633. breath.setIsRunning(true);
  634. breath.addDamageHate(mob.getMostHated(), 0, 999);
  635. breath.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, mob.getMostHated());
  636. startQuestTimer("BLIZZARD", 20000, breath, null);
  637. world.spawnedMobs.add(breath);
  638. }
  639. break;
  640. }
  641. }
  642. }
  643. break;
  644. }
  645. case "LEADER_DELAY":
  646. {
  647. if (npc.getVariables().getInt("DELAY_VAL") == 0)
  648. {
  649. npc.getVariables().set("DELAY_VAL", 1);
  650. }
  651. break;
  652. }
  653. }
  654. }
  655. }
  656. return super.onAdvEvent(event, npc, player);
  657. }
  658. @Override
  659. public String onSpawn(L2Npc npc)
  660. {
  661. ((L2Attackable) npc).setOnKillDelay(0);
  662. return super.onSpawn(npc);
  663. }
  664. @Override
  665. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  666. {
  667. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  668. if (tmpworld instanceof IQCNBWorld)
  669. {
  670. final IQCNBWorld world = (IQCNBWorld) tmpworld;
  671. if (npc.getId() == SUPP_JINIA)
  672. {
  673. player.sendPacket(ActionFailed.STATIC_PACKET);
  674. return null;
  675. }
  676. else if (npc.getId() == SUPP_KEGOR)
  677. {
  678. if (world.isSupportActive)
  679. {
  680. player.sendPacket(ActionFailed.STATIC_PACKET);
  681. return null;
  682. }
  683. return "18851.html";
  684. }
  685. }
  686. player.sendPacket(ActionFailed.STATIC_PACKET);
  687. return null;
  688. }
  689. @Override
  690. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  691. {
  692. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  693. if (tmpworld instanceof IQCNBWorld)
  694. {
  695. final IQCNBWorld world = (IQCNBWorld) tmpworld;
  696. switch (npc.getId())
  697. {
  698. case FREYA_THRONE:
  699. {
  700. if ((world.controller.getVariables().getInt("FREYA_MOVE") == 0) && world.isStatus(1))
  701. {
  702. world.controller.getVariables().set("FREYA_MOVE", 1);
  703. manageScreenMsg(world, NpcStringId.FREYA_HAS_STARTED_TO_MOVE);
  704. world.freya.setIsRunning(true);
  705. world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
  706. }
  707. if (npc.getCurrentHp() < (npc.getMaxHp() * 0.02))
  708. {
  709. notifyEvent("STAGE_1_FINISH", world.controller, null);
  710. cancelQuestTimer("CAST_BLIZZARD", world.controller, null);
  711. }
  712. else
  713. {
  714. if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTI_STRIDER.getSkillId()) && !npc.isCastingNow())
  715. {
  716. if (!npc.isSkillDisabled(ANTI_STRIDER.getSkill()))
  717. {
  718. npc.setTarget(attacker);
  719. npc.doCast(ANTI_STRIDER.getSkill());
  720. }
  721. }
  722. final L2Character mostHated = ((L2Attackable) npc).getMostHated();
  723. final boolean canReachMostHated = (mostHated != null) && !mostHated.isDead() && (npc.calculateDistance(mostHated, true, false) <= 800);
  724. if (getRandom(10000) < 3333)
  725. {
  726. if (getRandomBoolean())
  727. {
  728. if ((npc.calculateDistance(attacker, true, false) <= 800) && npc.checkDoCastConditions(ICE_BALL.getSkill()) && !npc.isCastingNow())
  729. {
  730. npc.setTarget(attacker);
  731. npc.doCast(ICE_BALL.getSkill());
  732. }
  733. }
  734. else
  735. {
  736. if (canReachMostHated && npc.checkDoCastConditions(ICE_BALL.getSkill()) && !npc.isCastingNow())
  737. {
  738. npc.setTarget(mostHated);
  739. npc.doCast(ICE_BALL.getSkill());
  740. }
  741. }
  742. }
  743. else if (getRandom(10000) < 800)
  744. {
  745. if (getRandomBoolean())
  746. {
  747. if ((npc.calculateDistance(attacker, true, false) <= 800) && npc.checkDoCastConditions(SUMMON_ELEMENTAL.getSkill()) && !npc.isCastingNow())
  748. {
  749. npc.setTarget(attacker);
  750. npc.doCast(SUMMON_ELEMENTAL.getSkill());
  751. }
  752. }
  753. else
  754. {
  755. if (canReachMostHated && npc.checkDoCastConditions(SUMMON_ELEMENTAL.getSkill()) && !npc.isCastingNow())
  756. {
  757. npc.setTarget(mostHated);
  758. npc.doCast(SUMMON_ELEMENTAL.getSkill());
  759. }
  760. }
  761. }
  762. else if (getRandom(10000) < 1500)
  763. {
  764. if (!npc.isAffectedBySkill(SELF_NOVA.getSkillId()) && npc.checkDoCastConditions(SELF_NOVA.getSkill()) && !npc.isCastingNow())
  765. {
  766. npc.setTarget(npc);
  767. npc.doCast(SELF_NOVA.getSkill());
  768. }
  769. }
  770. }
  771. break;
  772. }
  773. case FREYA_STAND:
  774. {
  775. if (world.controller.getVariables().getInt("FREYA_MOVE") == 0)
  776. {
  777. world.controller.getVariables().set("FREYA_MOVE", 1);
  778. world.freya.setIsRunning(true);
  779. world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
  780. }
  781. if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.2)) && !world.isSupportActive)
  782. {
  783. world.isSupportActive = true;
  784. world.freya.setIsInvul(true);
  785. world.freya.disableCoreAI(true);
  786. for (L2PcInstance players : world.playersInside)
  787. {
  788. players.setIsInvul(true);
  789. players.abortAttack();
  790. }
  791. manageMovie(world, 18);
  792. startQuestTimer("SPAWN_SUPPORT", 27000, world.controller, null);
  793. }
  794. if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTI_STRIDER.getSkillId()) && !npc.isCastingNow())
  795. {
  796. if (!npc.isSkillDisabled(ANTI_STRIDER.getSkill()))
  797. {
  798. npc.setTarget(attacker);
  799. npc.doCast(ANTI_STRIDER.getSkill());
  800. }
  801. }
  802. final L2Character mostHated = ((L2Attackable) npc).getMostHated();
  803. final boolean canReachMostHated = (mostHated != null) && !mostHated.isDead() && (npc.calculateDistance(mostHated, true, false) <= 800);
  804. if (getRandom(10000) < 3333)
  805. {
  806. if (getRandomBoolean())
  807. {
  808. if ((npc.calculateDistance(attacker, true, false) <= 800) && npc.checkDoCastConditions(ICE_BALL.getSkill()) && !npc.isCastingNow())
  809. {
  810. npc.setTarget(attacker);
  811. npc.doCast(ICE_BALL.getSkill());
  812. }
  813. }
  814. else
  815. {
  816. if (canReachMostHated && npc.checkDoCastConditions(ICE_BALL.getSkill()) && !npc.isCastingNow())
  817. {
  818. npc.setTarget(mostHated);
  819. npc.doCast(ICE_BALL.getSkill());
  820. }
  821. }
  822. }
  823. else if (getRandom(10000) < 1333)
  824. {
  825. if (getRandomBoolean())
  826. {
  827. if ((npc.calculateDistance(attacker, true, false) <= 800) && npc.checkDoCastConditions(SUMMON_ELEMENTAL.getSkill()) && !npc.isCastingNow())
  828. {
  829. npc.setTarget(attacker);
  830. npc.doCast(SUMMON_ELEMENTAL.getSkill());
  831. }
  832. }
  833. else
  834. {
  835. if (canReachMostHated && npc.checkDoCastConditions(SUMMON_ELEMENTAL.getSkill()) && !npc.isCastingNow())
  836. {
  837. npc.setTarget(mostHated);
  838. npc.doCast(SUMMON_ELEMENTAL.getSkill());
  839. }
  840. }
  841. }
  842. else if (getRandom(10000) < 1500)
  843. {
  844. if (!npc.isAffectedBySkill(SELF_NOVA.getSkillId()) && npc.checkDoCastConditions(SELF_NOVA.getSkill()) && !npc.isCastingNow())
  845. {
  846. npc.setTarget(npc);
  847. npc.doCast(SELF_NOVA.getSkill());
  848. }
  849. }
  850. else if (getRandom(10000) < 1333)
  851. {
  852. if (!npc.isAffectedBySkill(REFLECT_MAGIC.getSkillId()) && npc.checkDoCastConditions(REFLECT_MAGIC.getSkill()) && !npc.isCastingNow())
  853. {
  854. npc.setTarget(npc);
  855. npc.doCast(REFLECT_MAGIC.getSkill());
  856. }
  857. }
  858. break;
  859. }
  860. case GLACIER:
  861. {
  862. if (npc.isScriptValue(0) && (npc.getCurrentHp() < (npc.getMaxHp() * 0.5)))
  863. {
  864. npc.setTarget(attacker);
  865. npc.doCast(ICE_STONE.getSkill());
  866. npc.setScriptValue(1);
  867. }
  868. break;
  869. }
  870. case BREATH:
  871. {
  872. if ((npc.getCurrentHp() < (npc.getMaxHp() / 20)) && (npc.getVariables().getInt("SUICIDE_ON", 0) == 0))
  873. {
  874. npc.getVariables().set("SUICIDE_ON", 1);
  875. startQuestTimer("ELEMENTAL_KILLED", 1000, npc, null);
  876. }
  877. break;
  878. }
  879. case KNIGHT:
  880. {
  881. if (npc.isCoreAIDisabled())
  882. {
  883. manageRandomAttack(world, (L2Attackable) npc);
  884. npc.disableCoreAI(false);
  885. npc.setIsImmobilized(false);
  886. npc.setDisplayEffect(2);
  887. cancelQuestTimer("ICE_RUPTURE", npc, null);
  888. }
  889. break;
  890. }
  891. case GLAKIAS:
  892. {
  893. if (npc.getCurrentHp() < (npc.getMaxHp() * 0.02))
  894. {
  895. if (npc.getVariables().getInt("OFF_SHOUT") == 0)
  896. {
  897. npc.getVariables().set("OFF_SHOUT", 1);
  898. npc.getVariables().set("DELAY_VAL", 2);
  899. npc.setTarget(attacker);
  900. npc.doCast(CANCEL.getSkill());
  901. }
  902. else if (npc.getVariables().getInt("OFF_SHOUT") == 1)
  903. {
  904. npc.setTarget(attacker);
  905. npc.doCast(CANCEL.getSkill());
  906. }
  907. }
  908. else if ((npc.getVariables().getInt("OFF_SHOUT") == 0) && (npc.getVariables().getInt("DELAY_VAL") == 1))
  909. {
  910. final L2Character mostHated = ((L2Attackable) npc).getMostHated();
  911. final boolean canReachMostHated = (mostHated != null) && !mostHated.isDead() && (npc.calculateDistance(mostHated, true, false) < 1000);
  912. if (npc.getVariables().getInt("TIMER_ON") == 0)
  913. {
  914. npc.getVariables().set("TIMER_ON", 1);
  915. startQuestTimer("LEADER_RANGEBUFF", getRandom(5, 30) * 1000, npc, null);
  916. startQuestTimer("LEADER_RANDOMIZE", 25000, npc, null);
  917. startQuestTimer("LEADER_DASH", 5000, npc, null);
  918. startQuestTimer("LEADER_DESTROY", 60000, npc, null);
  919. }
  920. if (getRandom(10000) < 2500)
  921. {
  922. if (getRandom(10000) < 2500)
  923. {
  924. if (npc.checkDoCastConditions(POWER_STRIKE.getSkill()) && !npc.isCastingNow())
  925. {
  926. npc.setTarget(attacker);
  927. npc.doCast(POWER_STRIKE.getSkill());
  928. }
  929. }
  930. else if (npc.checkDoCastConditions(POWER_STRIKE.getSkill()) && !npc.isCastingNow() && canReachMostHated)
  931. {
  932. npc.setTarget(((L2Attackable) npc).getMostHated());
  933. npc.doCast(POWER_STRIKE.getSkill());
  934. }
  935. }
  936. else if (getRandom(10000) < 1500)
  937. {
  938. if (getRandomBoolean())
  939. {
  940. if (npc.checkDoCastConditions(POINT_TARGET.getSkill()) && !npc.isCastingNow())
  941. {
  942. npc.setTarget(attacker);
  943. npc.doCast(POINT_TARGET.getSkill());
  944. }
  945. }
  946. else if (npc.checkDoCastConditions(POINT_TARGET.getSkill()) && !npc.isCastingNow() && canReachMostHated)
  947. {
  948. npc.setTarget(((L2Attackable) npc).getMostHated());
  949. npc.doCast(POINT_TARGET.getSkill());
  950. }
  951. }
  952. else if (getRandom(10000) < 1500)
  953. {
  954. if (getRandomBoolean())
  955. {
  956. if (npc.checkDoCastConditions(CYLINDER_THROW.getSkill()) && !npc.isCastingNow())
  957. {
  958. npc.setTarget(attacker);
  959. npc.doCast(CYLINDER_THROW.getSkill());
  960. }
  961. }
  962. else if (npc.checkDoCastConditions(CYLINDER_THROW.getSkill()) && !npc.isCastingNow() && canReachMostHated)
  963. {
  964. npc.setTarget(((L2Attackable) npc).getMostHated());
  965. npc.doCast(CYLINDER_THROW.getSkill());
  966. }
  967. }
  968. }
  969. break;
  970. }
  971. }
  972. }
  973. return super.onAttack(npc, attacker, damage, isSummon, skill);
  974. }
  975. @Override
  976. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  977. {
  978. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  979. if (tmpworld instanceof IQCNBWorld)
  980. {
  981. final IQCNBWorld world = (IQCNBWorld) tmpworld;
  982. switch (npc.getId())
  983. {
  984. case GLACIER:
  985. {
  986. if (skill == ICE_STONE.getSkill())
  987. {
  988. if (getRandom(100) < 75)
  989. {
  990. final L2Attackable breath = (L2Attackable) addSpawn(BREATH, npc.getLocation(), false, 0, false, world.getInstanceId());
  991. if (player != null)
  992. {
  993. breath.setIsRunning(true);
  994. breath.addDamageHate(player, 0, 999);
  995. breath.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  996. }
  997. else
  998. {
  999. manageRandomAttack(world, breath);
  1000. }
  1001. world.spawnedMobs.add(breath);
  1002. startQuestTimer("BLIZZARD", 20000, breath, null);
  1003. }
  1004. notifyEvent("SUICIDE", npc, null);
  1005. }
  1006. break;
  1007. }
  1008. case BREATH:
  1009. {
  1010. if (skill == SUICIDE_BREATH.getSkill())
  1011. {
  1012. npc.doDie(null);
  1013. }
  1014. break;
  1015. }
  1016. }
  1017. }
  1018. return super.onSpellFinished(npc, player, skill);
  1019. }
  1020. @Override
  1021. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  1022. {
  1023. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1024. if (tmpworld instanceof IQCNBWorld)
  1025. {
  1026. final IQCNBWorld world = (IQCNBWorld) tmpworld;
  1027. switch (npc.getId())
  1028. {
  1029. case GLAKIAS:
  1030. {
  1031. manageDespawnMinions(world);
  1032. manageTimer(world, 60);
  1033. startQuestTimer("STAGE_3_MOVIE", 60000, world.controller, null);
  1034. break;
  1035. }
  1036. case FREYA_STAND:
  1037. {
  1038. world.isSupportActive = false;
  1039. manageMovie(world, 19);
  1040. manageDespawnMinions(world);
  1041. finishInstance(world);
  1042. DecayTaskManager.getInstance().cancel(world.freya);
  1043. cancelQuestTimer("ATTACK_FREYA", world.supp_Jinia, null);
  1044. cancelQuestTimer("ATTACK_FREYA", world.supp_Kegor, null);
  1045. cancelQuestTimer("GIVE_SUPPORT", world.controller, null);
  1046. cancelQuestTimer("CAST_BLIZZARD", world.controller, null);
  1047. startQuestTimer("FINISH_STAGE", 16000, world.controller, null);
  1048. startQuestTimer("FINISH_WORLD", 300000, world.controller, null);
  1049. break;
  1050. }
  1051. case KNIGHT:
  1052. {
  1053. final L2Npc spawnedBy = npc.getVariables().getObject("SPAWNED_NPC", L2Npc.class);
  1054. final NpcVariables var = world.controller.getVariables();
  1055. int knightCount = var.getInt("KNIGHT_COUNT");
  1056. if ((var.getInt("FREYA_MOVE") == 0) && world.isStatus(1))
  1057. {
  1058. var.set("FREYA_MOVE", 1);
  1059. manageScreenMsg(world, NpcStringId.FREYA_HAS_STARTED_TO_MOVE);
  1060. world.freya.setIsRunning(true);
  1061. world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
  1062. }
  1063. if ((knightCount < 10) && (world.isStatus(2)))
  1064. {
  1065. knightCount++;
  1066. var.set("KNIGHT_COUNT", knightCount);
  1067. if (knightCount == 10)
  1068. {
  1069. notifyEvent("STAGE_2_MOVIE", world.controller, null);
  1070. world.setStatus(3);
  1071. }
  1072. }
  1073. if (spawnedBy != null)
  1074. {
  1075. startQuestTimer("SPAWN_KNIGHT", getRandom(30, 60) * 1000, spawnedBy, null);
  1076. }
  1077. world.spawnedMobs.remove(npc);
  1078. break;
  1079. }
  1080. case GLACIER:
  1081. {
  1082. startQuestTimer("SPAWN_GLACIER", getRandom(30, 60) * 1000, world.controller, null);
  1083. world.spawnedMobs.remove(npc);
  1084. break;
  1085. }
  1086. case BREATH:
  1087. {
  1088. world.spawnedMobs.remove(npc);
  1089. break;
  1090. }
  1091. }
  1092. }
  1093. return super.onKill(npc, killer, isSummon);
  1094. }
  1095. @Override
  1096. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  1097. {
  1098. if (firstEntrance)
  1099. {
  1100. if (!player.isInParty())
  1101. {
  1102. managePlayerEnter(player, (IQCNBWorld) world);
  1103. }
  1104. else if (player.getParty().isInCommandChannel())
  1105. {
  1106. for (L2PcInstance players : player.getParty().getCommandChannel().getMembers())
  1107. {
  1108. managePlayerEnter(players, (IQCNBWorld) world);
  1109. }
  1110. }
  1111. else
  1112. {
  1113. for (L2PcInstance players : player.getParty().getMembers())
  1114. {
  1115. managePlayerEnter(players, (IQCNBWorld) world);
  1116. }
  1117. }
  1118. }
  1119. else
  1120. {
  1121. teleportPlayer(player, world.isStatus(4) ? BATTLE_PORT : ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId());
  1122. }
  1123. }
  1124. private void managePlayerEnter(L2PcInstance player, IQCNBWorld world)
  1125. {
  1126. world.playersInside.add(player);
  1127. world.addAllowed(player.getObjectId());
  1128. teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
  1129. }
  1130. @Override
  1131. protected boolean checkConditions(L2PcInstance player)
  1132. {
  1133. final L2Party party = player.getParty();
  1134. final L2CommandChannel channel = party != null ? party.getCommandChannel() : null;
  1135. if (player.isGM() && player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  1136. {
  1137. return true;
  1138. }
  1139. if (party == null)
  1140. {
  1141. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  1142. return false;
  1143. }
  1144. else if (channel == null)
  1145. {
  1146. player.sendPacket(SystemMessageId.NOT_IN_COMMAND_CHANNEL_CANT_ENTER);
  1147. return false;
  1148. }
  1149. else if (player != channel.getLeader())
  1150. {
  1151. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  1152. return false;
  1153. }
  1154. else if ((channel.getMemberCount() < MIN_PLAYERS) || (channel.getMemberCount() > MAX_PLAYERS))
  1155. {
  1156. player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
  1157. return false;
  1158. }
  1159. for (L2PcInstance channelMember : channel.getMembers())
  1160. {
  1161. if (channelMember.getLevel() < MIN_LEVEL)
  1162. {
  1163. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
  1164. sm.addPcName(channelMember);
  1165. party.broadcastPacket(sm);
  1166. return false;
  1167. }
  1168. else if (!Util.checkIfInRange(1000, player, channelMember, true))
  1169. {
  1170. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  1171. sm.addPcName(channelMember);
  1172. party.broadcastPacket(sm);
  1173. return false;
  1174. }
  1175. else if (System.currentTimeMillis() < InstanceManager.getInstance().getInstanceTime(channelMember.getObjectId(), TEMPLATE_ID))
  1176. {
  1177. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
  1178. sm.addPcName(channelMember);
  1179. party.broadcastPacket(sm);
  1180. return false;
  1181. }
  1182. }
  1183. return true;
  1184. }
  1185. private void manageRandomAttack(IQCNBWorld world, L2Attackable mob)
  1186. {
  1187. final List<L2PcInstance> players = new ArrayList<>();
  1188. for (L2PcInstance player : world.playersInside)
  1189. {
  1190. if ((player != null) && !player.isDead() && (player.getInstanceId() == world.getInstanceId()) && !player.isInvisible())
  1191. {
  1192. players.add(player);
  1193. }
  1194. }
  1195. Collections.shuffle(players);
  1196. final L2PcInstance target = (!players.isEmpty()) ? players.get(0) : null;
  1197. if (target != null)
  1198. {
  1199. mob.addDamageHate(target, 0, 999);
  1200. mob.setIsRunning(true);
  1201. mob.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  1202. }
  1203. else
  1204. {
  1205. startQuestTimer("FIND_TARGET", 10000, mob, null);
  1206. }
  1207. }
  1208. private void manageDespawnMinions(IQCNBWorld world)
  1209. {
  1210. world.canSpawnMobs = false;
  1211. for (L2Attackable mobs : world.spawnedMobs)
  1212. {
  1213. if ((mobs != null) && !mobs.isDead())
  1214. {
  1215. mobs.doDie(null);
  1216. }
  1217. }
  1218. }
  1219. private void manageTimer(IQCNBWorld world, int time)
  1220. {
  1221. for (L2PcInstance players : world.playersInside)
  1222. {
  1223. if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
  1224. {
  1225. players.sendPacket(new ExSendUIEvent(players, false, false, time, 0, "Time remaining until next battle"));
  1226. }
  1227. }
  1228. }
  1229. private void manageScreenMsg(IQCNBWorld world, NpcStringId stringId)
  1230. {
  1231. for (L2PcInstance players : world.playersInside)
  1232. {
  1233. if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
  1234. {
  1235. showOnScreenMsg(players, stringId, 2, 6000);
  1236. }
  1237. }
  1238. }
  1239. private void manageMovie(IQCNBWorld world, int movie)
  1240. {
  1241. for (L2PcInstance players : world.playersInside)
  1242. {
  1243. if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
  1244. {
  1245. players.showQuestMovie(movie);
  1246. }
  1247. }
  1248. }
  1249. }