CrystalCaverns.java 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072
  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.CrystalCaverns;
  20. import instances.AbstractInstance;
  21. import java.util.List;
  22. import java.util.Map;
  23. import javolution.util.FastList;
  24. import javolution.util.FastMap;
  25. import quests.Q00131_BirdInACage.Q00131_BirdInACage;
  26. import com.l2jserver.Config;
  27. import com.l2jserver.gameserver.GeoData;
  28. import com.l2jserver.gameserver.ai.CtrlIntention;
  29. import com.l2jserver.gameserver.datatables.SkillData;
  30. import com.l2jserver.gameserver.enums.TrapAction;
  31. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  32. import com.l2jserver.gameserver.model.L2Object;
  33. import com.l2jserver.gameserver.model.L2Party;
  34. import com.l2jserver.gameserver.model.L2World;
  35. import com.l2jserver.gameserver.model.Location;
  36. import com.l2jserver.gameserver.model.PcCondOverride;
  37. import com.l2jserver.gameserver.model.actor.L2Attackable;
  38. import com.l2jserver.gameserver.model.actor.L2Character;
  39. import com.l2jserver.gameserver.model.actor.L2Npc;
  40. import com.l2jserver.gameserver.model.actor.L2Summon;
  41. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  42. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  43. import com.l2jserver.gameserver.model.actor.instance.L2TrapInstance;
  44. import com.l2jserver.gameserver.model.entity.Instance;
  45. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  46. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  47. import com.l2jserver.gameserver.model.quest.QuestState;
  48. import com.l2jserver.gameserver.model.skills.Skill;
  49. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  50. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  51. import com.l2jserver.gameserver.network.NpcStringId;
  52. import com.l2jserver.gameserver.network.SystemMessageId;
  53. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  54. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  55. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
  56. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
  57. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  58. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  59. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  60. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  61. import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
  62. import com.l2jserver.gameserver.util.Util;
  63. /**
  64. * Crystal Caverns instance zone.<br>
  65. * TODO: 1. Kechi's Henchmans spawn animation is missing.<br>
  66. * 2. NPC related Traps are not supported by core, so Darnels and Lahm door trap is not working.<br>
  67. * 3. Need retail spawn for Coral Garden (EmeraldSteam/Square - done).<br>
  68. * 4. Baylor Raid is missing a lot of things This script takes the best elements of different versions and combines them into one script to get the most optimal and retail-like experience.<br>
  69. * Original sources: theone, L2JEmu, L2JOfficial, L2JFree Contributing authors: TGS, Lantoc, Janiii, Gigiikun, RosT Please maintain consistency between the Crystal Caverns scripts.
  70. */
  71. public final class CrystalCaverns extends AbstractInstance
  72. {
  73. protected static class CrystalGolem
  74. {
  75. protected L2ItemInstance foodItem = null;
  76. protected boolean isAtDestination = false;
  77. protected Location oldLoc = null;
  78. }
  79. private class CCWorld extends InstanceWorld
  80. {
  81. public Map<L2Npc, Boolean> npcList1 = new FastMap<>();
  82. public L2Npc tears;
  83. public boolean isUsedInvulSkill = false;
  84. public long dragonScaleStart = 0;
  85. public int dragonScaleNeed = 0;
  86. public int cleanedRooms = 0;
  87. public long endTime = 0;
  88. public List<L2Npc> copys = new FastList<>();
  89. public Map<L2Npc, CrystalGolem> crystalGolems = new FastMap<>();
  90. public int correctGolems = 0;
  91. public boolean[] OracleTriggered =
  92. {
  93. false,
  94. false,
  95. false
  96. };
  97. public int kechisHenchmanSpawn = 0;
  98. public int[] roomsStatus =
  99. {
  100. 0,
  101. 0,
  102. 0,
  103. 0
  104. }; // 0: not spawned, 1: spawned, 2: cleared
  105. public Map<L2DoorInstance, L2PcInstance> openedDoors = new FastMap<>();
  106. public Map<Integer, Map<L2Npc, Boolean>> npcList2 = new FastMap<>();
  107. public Map<L2Npc, L2Npc> oracles = new FastMap<>();
  108. public List<L2Npc> keyKeepers = new FastList<>();
  109. public List<L2Npc> guards = new FastList<>();
  110. public List<L2Npc> oracle = new FastList<>();
  111. // baylor variables
  112. protected final List<L2PcInstance> _raiders = new FastList<>();
  113. protected int _raidStatus = 0;
  114. protected long _dragonClawStart = 0;
  115. protected int _dragonClawNeed = 0;
  116. protected final List<L2Npc> _animationMobs = new FastList<>();
  117. protected L2Npc _camera = null;
  118. protected L2Npc _baylor = null;
  119. protected L2Npc _alarm = null;
  120. public CCWorld(Long time)
  121. {
  122. endTime = time;
  123. }
  124. }
  125. // Items
  126. private static final int WHITE_SEED = 9597;
  127. private static final int BLACK_SEED = 9598;
  128. private static final int CONT_CRYSTAL = 9690; // Contaminated Crystal
  129. private static final int RED_CORAL = 9692; // Red Coral
  130. private static final int CRYSTALFOOD = 9693; // Food item for Crystal Golems
  131. final private static int RACE_KEY = 9694; // Race Key for Emerald doors
  132. private static final int BOSS_CRYSTAL_1 = 9695; // Clear Crystal
  133. private static final int BOSS_CRYSTAL_2 = 9696; // Clear Crystal
  134. private static final int BOSS_CRYSTAL_3 = 9697; // Clear Crystal
  135. // NPCs
  136. private static final int ORACLE_GUIDE_1 = 32281;
  137. private static final int ORACLE_GUIDE_2 = 32278;
  138. private static final int ORACLE_GUIDE_3 = 32280;
  139. private static final int ORACLE_GUIDE_4 = 32279;
  140. private static final int CRYSTAL_GOLEM = 32328;
  141. private static final int[] DOOR_OPENING_TRAP =
  142. {
  143. 18378,
  144. 143682,
  145. 142492,
  146. -11886,
  147. 16384
  148. };
  149. private static final int GK1 = 22275;
  150. private static final int GK2 = 22277;
  151. private static final int TOURMALINE = 22292;
  152. private static final int TEROD = 22301;
  153. private static final int DOLPH = 22299;
  154. private static final int WEYLIN = 22298;
  155. private static final int GUARDIAN = 22303;
  156. private static final int GUARDIAN2 = 22304;
  157. private static final int TEARS = 25534;
  158. private static final int TEARS_COPY = 25535;
  159. private static final int KECHI = 25532;
  160. private static final int KECHIGUARD = 25533;
  161. private static final int BAYLOR = 29099;
  162. private static final int DARNEL = 25531;
  163. private final static int ALARMID = 18474;
  164. // private static final int[] BOSSCR = {9695,9696,9697};
  165. private static final int[] CGMOBS =
  166. {
  167. 22311,
  168. 22312,
  169. 22313,
  170. 22314,
  171. 22315,
  172. 22316,
  173. 22317
  174. };
  175. private static final int[] SPAWN =
  176. {
  177. 60000,
  178. 120000,
  179. 90000,
  180. 60000,
  181. 50000,
  182. 40000
  183. }; // Kechi Hencmans spawn times
  184. private static final int[] MOBLIST =
  185. {
  186. 22279,
  187. 22280,
  188. 22281,
  189. 22282,
  190. 22283,
  191. 22285,
  192. 22286,
  193. 22287,
  194. 22288,
  195. 22289,
  196. 22293,
  197. 22294,
  198. 22295,
  199. 22296,
  200. 22297,
  201. 22305,
  202. 22306,
  203. 22307,
  204. 22416,
  205. 22418,
  206. 22419,
  207. 22420
  208. };
  209. // Locations
  210. private static final Location START_LOC = new Location(143348, 148707, -11972);
  211. // Misc
  212. private static final int TEMPLATE_ID = 10;
  213. private static final boolean debug = false;
  214. private static final int DOOR1 = 24220021;
  215. private static final int DOOR2 = 24220024;
  216. private static final int DOOR3 = 24220023;
  217. private static final int DOOR4 = 24220061;
  218. private static final int DOOR5 = 24220025;
  219. private static final int DOOR6 = 24220022;
  220. private static final int[] ZONES =
  221. {
  222. 20105,
  223. 20106,
  224. 20107
  225. };
  226. // @formatter:off
  227. private final static int[][] ALARMSPAWN =
  228. {
  229. {153572, 141277, -12738},
  230. {153572, 142852, -12738},
  231. {154358, 142075, -12738},
  232. {152788, 142075, -12738}
  233. };
  234. // Oracle order
  235. private static final int[][] ordreOracle1 =
  236. {
  237. {32274, 147090, 152505, -12169, 31613},
  238. {32275, 147090, 152575, -12169, 31613},
  239. {32274, 147090, 152645, -12169, 31613},
  240. {32274, 147090, 152715, -12169, 31613}
  241. };
  242. private static final int[][] ordreOracle2 =
  243. {
  244. {32274, 149783, 152505, -12169, 31613},
  245. // {32274, 149783, 152575, -12169, 31613},
  246. {32274, 149783, 152645, -12169, 31613},
  247. {32276, 149783, 152715, -12169, 31613}
  248. };
  249. private static final int[][] ordreOracle3 =
  250. {
  251. {32274, 152461, 152505, -12169, 31613},
  252. // {32274, 152461, 152575, -12169, 31613},
  253. {32277, 152461, 152645, -12169, 31613},
  254. // {32274, 152461, 152715, -12169, 31613}
  255. };
  256. private static int[][] HALL_SPAWNS =
  257. {
  258. {141842, 152556, -11814, 50449},
  259. {141503, 153395, -11814, 40738},
  260. {141070, 153201, -11814, 39292},
  261. {141371, 152986, -11814, 35575},
  262. {141602, 154188, -11814, 24575},
  263. {141382, 154719, -11814, 37640},
  264. {141376, 154359, -11814, 12054},
  265. {140895, 154383, -11814, 37508},
  266. {140972, 154740, -11814, 52690},
  267. {141045, 154504, -11814, 50674},
  268. {140757, 152740, -11814, 39463},
  269. {140406, 152376, -11814, 16599},
  270. {140268, 152007, -11817, 45316},
  271. {139996, 151485, -11814, 47403},
  272. {140378, 151190, -11814, 58116},
  273. {140521, 150711, -11815, 55997},
  274. {140816, 150215, -11814, 53682},
  275. {141528, 149909, -11814, 22020},
  276. {141644, 150360, -11817, 13283},
  277. {142048, 150695, -11815, 5929},
  278. {141852, 151065, -11817, 27071},
  279. {142408, 151211, -11815, 2402},
  280. {142481, 151762, -11815, 12876},
  281. {141929, 152193, -11815, 27511},
  282. {142083, 151791, -11814, 47176},
  283. {141435, 150402, -11814, 41798},
  284. {140390, 151199, -11814, 50069},
  285. {140557, 151849, -11814, 45293},
  286. {140964, 153445, -11814, 56672},
  287. {142851, 154109, -11814, 24920},
  288. {142379, 154725, -11814, 30342},
  289. {142816, 154712, -11814, 33193},
  290. {142276, 154223, -11814, 33922},
  291. {142459, 154490, -11814, 33184},
  292. {142819, 154372, -11814, 21318},
  293. {141157, 154541, -11814, 27090},
  294. {141095, 150281, -11814, 55186}
  295. };
  296. // first spawns
  297. private static int[][] FIRST_SPAWNS =
  298. {
  299. {22276, 148109, 149601, -12132, 34490},
  300. {22276, 148017, 149529, -12132, 33689},
  301. {22278, 148065, 151202, -12132, 35323},
  302. {22278, 147966, 151117, -12132, 33234},
  303. {22279, 144063, 150238, -12132, 29654},
  304. {22279, 144300, 149118, -12135, 5520},
  305. {22279, 144397, 149337, -12132, 644},
  306. {22279, 144426, 150639, -12132, 50655},
  307. {22282, 145841, 151097, -12132, 31810},
  308. {22282, 144387, 149958, -12132, 61173},
  309. {22282, 145821, 149498, -12132, 31490},
  310. {22282, 146619, 149694, -12132, 33374},
  311. {22282, 146669, 149244, -12132, 31360},
  312. {22284, 144147, 151375, -12132, 58395},
  313. {22284, 144485, 151067, -12132, 64786},
  314. {22284, 144356, 149571, -12132, 63516},
  315. {22285, 144151, 150962, -12132, 664},
  316. {22285, 146657, 151365, -12132, 33154},
  317. {22285, 146623, 150857, -12132, 28034},
  318. {22285, 147046, 151089, -12132, 32941},
  319. {22285, 145704, 151255, -12132, 32523},
  320. {22285, 145359, 151101, -12132, 32767},
  321. {22285, 147785, 150817, -12132, 27423},
  322. {22285, 147727, 151375, -12132, 37117},
  323. {22285, 145428, 149494, -12132, 890},
  324. {22285, 145601, 149682, -12132, 32442},
  325. {22285, 147003, 149476, -12132, 31554},
  326. {22285, 147738, 149210, -12132, 20971},
  327. {22285, 147769, 149757, -12132, 34980}
  328. };
  329. // Emerald Square
  330. private static int[][] EMERALD_SPAWNS =
  331. {
  332. {22280, 144437, 143395, -11969, 34248},
  333. {22281, 149241, 143735, -12230, 24575},
  334. {22281, 147917, 146861, -12289, 60306},
  335. {22281, 144406, 147782, -12133, 14349},
  336. {22281, 144960, 146881, -12039, 23881},
  337. {22281, 144985, 147679, -12135, 27594},
  338. {22283, 147784, 143540, -12222, 2058},
  339. {22283, 149091, 143491, -12230, 24836},
  340. {22287, 144479, 147569, -12133, 20723},
  341. {22287, 145158, 146986, -12058, 21970},
  342. {22287, 145142, 147175, -12092, 24420},
  343. {22287, 145110, 147133, -12088, 22465},
  344. {22287, 144664, 146604, -12028, 14861},
  345. {22287, 144596, 146600, -12028, 14461},
  346. {22288, 143925, 146773, -12037, 10813},
  347. {22288, 144415, 147070, -12069, 8568},
  348. {22288, 143794, 145584, -12027, 14849},
  349. {22288, 143429, 146166, -12030, 4078},
  350. {22288, 144477, 147009, -12056, 8752},
  351. {22289, 142577, 145319, -12029, 5403},
  352. {22289, 143831, 146902, -12051, 9717},
  353. {22289, 143714, 146705, -12028, 10044},
  354. {22289, 143937, 147134, -12078, 7517},
  355. {22293, 143356, 145287, -12027, 8126},
  356. {22293, 143462, 144352, -12008, 25905},
  357. {22293, 143745, 142529, -11882, 17102},
  358. {22293, 144574, 144032, -12005, 34668},
  359. {22295, 143992, 142419, -11884, 19697},
  360. {22295, 144671, 143966, -12004, 32088},
  361. {22295, 144440, 143269, -11957, 34169},
  362. {22295, 142642, 146362, -12028, 281},
  363. {22295, 143865, 142707, -11881, 21326},
  364. {22295, 143573, 142530, -11879, 16141},
  365. {22295, 143148, 146039, -12031, 65014},
  366. {22295, 143001, 144853, -12014, 0},
  367. {22296, 147505, 146580, -12260, 59041},
  368. {22296, 149366, 146932, -12358, 39407},
  369. {22296, 149284, 147029, -12352, 41120},
  370. {22296, 149439, 143940, -12230, 23189},
  371. {22296, 147698, 143995, -12220, 27028},
  372. {22296, 141885, 144969, -12007, 2526},
  373. {22296, 147843, 143763, -12220, 28386},
  374. {22296, 144753, 143650, -11982, 35429},
  375. {22296, 147613, 146760, -12271, 56296}
  376. };
  377. private static int[][] ROOM1_SPAWNS =
  378. {
  379. {22288, 143114, 140027, -11888, 15025},
  380. {22288, 142173, 140973, -11888, 55698},
  381. {22289, 143210, 140577, -11888, 17164},
  382. {22289, 142638, 140107, -11888, 6571},
  383. {22297, 142547, 140938, -11888, 48556},
  384. {22298, 142690, 140479, -11887, 7663}
  385. };
  386. private static int[][] ROOM2_SPAWNS =
  387. {
  388. {22303, 146276, 141483, -11880, 34643},
  389. {22287, 145707, 142161, -11880, 28799},
  390. {22288, 146857, 142129, -11880, 33647},
  391. {22288, 146869, 142000, -11880, 31215},
  392. {22289, 146897, 140880, -11880, 19210}
  393. };
  394. private static int[][] ROOM3_SPAWNS =
  395. {
  396. {22302, 145123, 143713, -12808, 65323},
  397. {22294, 145188, 143331, -12808, 496},
  398. {22294, 145181, 144104, -12808, 64415},
  399. {22293, 144994, 143431, -12808, 65431},
  400. {22293, 144976, 143915, -12808, 61461}
  401. };
  402. private static int[][] ROOM4_SPAWNS =
  403. {
  404. {22304, 150563, 142240, -12108, 16454},
  405. {22294, 150769, 142495, -12108, 16870},
  406. {22281, 150783, 141995, -12108, 20033},
  407. {22283, 150273, 141983, -12108, 16043},
  408. {22294, 150276, 142492, -12108, 13540}
  409. };
  410. // Steam Corridor
  411. private static int[][] STEAM1_SPAWNS =
  412. {
  413. {22305, 145260, 152387, -12165, 32767},
  414. {22305, 144967, 152390, -12165, 30464},
  415. {22305, 145610, 152586, -12165, 17107},
  416. {22305, 145620, 152397, -12165, 8191},
  417. {22418, 146081, 152847, -12165, 31396},
  418. {22418, 146795, 152641, -12165, 33850},
  419. // {22308, 145093, 152502, -12165, 31841},
  420. // {22308, 146158, 152776, -12165, 30810},
  421. // {22308, 146116, 152976, -12133, 32571}
  422. };
  423. private static int[][] STEAM2_SPAWNS =
  424. {
  425. {22306, 147740, 152767, -12165, 65043},
  426. {22306, 148215, 152828, -12165, 970},
  427. {22306, 147743, 152846, -12165, 64147},
  428. // {22308, 147849, 152854, -12165, 60534},
  429. // {22308, 147754, 152908, -12141, 59827},
  430. // {22308, 148194, 152681, -12165, 63620},
  431. // {22308, 147767, 152939, -12133, 63381},
  432. // {22309, 147737, 152671, -12165, 65320},
  433. {22418, 148207, 152725, -12165, 61801},
  434. {22419, 149058, 152828, -12165, 64564}
  435. };
  436. private static int[][] STEAM3_SPAWNS =
  437. {
  438. {22307, 150735, 152316, -12145, 31930},
  439. {22307, 150725, 152467, -12165, 33635},
  440. {22307, 151058, 152316, -12146, 65342},
  441. {22307, 151057, 152461, -12165, 2171},
  442. // {22308, 150794, 152455, -12165, 31613},
  443. // {22308, 150665, 152383, -12165, 32767},
  444. // {22308, 151697, 152621, -12167, 31423},
  445. // {22309, 151061, 152581, -12165, 6228},
  446. // {22309, 150653, 152253, -12132, 31343},
  447. // {22309, 150628, 152431, -12165, 33022},
  448. // {22309, 151620, 152487, -12165, 30114},
  449. // {22309, 151672, 152544, -12165, 31846},
  450. // {22309, 150488, 152350, -12165, 29072},
  451. // {22310, 151139, 152238, -12132, 1069}
  452. };
  453. private static int[][] STEAM4_SPAWNS =
  454. {
  455. // {22308, 151707, 150199, -12165, 32859},
  456. // {22308, 152091, 150140, -12165, 32938},
  457. // {22308, 149757, 150204, -12138, 65331},
  458. // {22308, 149950, 150307, -12132, 62437},
  459. // {22308, 149901, 150322, -12132, 62136},
  460. // {22309, 150071, 150173, -12165, 64943},
  461. {22416, 151636, 150280, -12142, 36869},
  462. {22416, 149893, 150232, -12165, 64258},
  463. {22416, 149864, 150110, -12165, 65054},
  464. {22416, 151926, 150218, -12165, 31613},
  465. {22420, 149986, 150051, -12165, 105},
  466. {22420, 151970, 149997, -12165, 32170},
  467. {22420, 150744, 150006, -12165, 63},
  468. // {22417, 149782, 150188, -12151, 64001}
  469. };
  470. // @formatter:on
  471. private static final int DRAGONSCALETIME = 3000;
  472. private static final int DRAGONCLAWTIME = 3000;
  473. public CrystalCaverns()
  474. {
  475. super(CrystalCaverns.class.getSimpleName());
  476. addStartNpc(ORACLE_GUIDE_1, ORACLE_GUIDE_4);
  477. addTalkId(ORACLE_GUIDE_1, ORACLE_GUIDE_3, ORACLE_GUIDE_4, 32275, 32276, 32277);
  478. addFirstTalkId(ORACLE_GUIDE_1, ORACLE_GUIDE_2, ORACLE_GUIDE_4, CRYSTAL_GOLEM, 32274, 32275, 32276, 32277);
  479. addKillId(TEARS, GK1, GK2, TEROD, WEYLIN, DOLPH, DARNEL, KECHI, GUARDIAN, GUARDIAN2, TOURMALINE, BAYLOR, ALARMID);
  480. addSkillSeeId(BAYLOR, 25534, 32275, 32276, 32277);
  481. addTrapActionId(DOOR_OPENING_TRAP[0]);
  482. addSpellFinishedId(BAYLOR);
  483. addAttackId(TEARS);
  484. addKillId(MOBLIST);
  485. addKillId(CGMOBS);
  486. for (int zones : ZONES)
  487. {
  488. addEnterZoneId(zones);
  489. addExitZoneId(zones);
  490. }
  491. }
  492. @Override
  493. protected boolean checkConditions(L2PcInstance player)
  494. {
  495. if (debug || player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  496. {
  497. if (debug)
  498. {
  499. return true;
  500. }
  501. }
  502. final L2Party party = player.getParty();
  503. if (party == null)
  504. {
  505. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  506. return false;
  507. }
  508. if (party.getLeader() != player)
  509. {
  510. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  511. return false;
  512. }
  513. for (L2PcInstance partyMember : party.getMembers())
  514. {
  515. if (partyMember.getLevel() < 78)
  516. {
  517. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
  518. sm.addPcName(partyMember);
  519. party.broadcastPacket(sm);
  520. return false;
  521. }
  522. L2ItemInstance item = partyMember.getInventory().getItemByItemId(CONT_CRYSTAL);
  523. if (item == null)
  524. {
  525. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  526. sm.addPcName(partyMember);
  527. party.broadcastPacket(sm);
  528. return false;
  529. }
  530. if (!Util.checkIfInRange(1000, player, partyMember, true))
  531. {
  532. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  533. sm.addPcName(partyMember);
  534. party.broadcastPacket(sm);
  535. return false;
  536. }
  537. Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
  538. if (System.currentTimeMillis() < reentertime)
  539. {
  540. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
  541. sm.addPcName(partyMember);
  542. party.broadcastPacket(sm);
  543. return false;
  544. }
  545. }
  546. return true;
  547. }
  548. private boolean checkOracleConditions(L2PcInstance player)
  549. {
  550. if (debug)
  551. {
  552. return true;
  553. }
  554. L2Party party = player.getParty();
  555. if (party == null)
  556. {
  557. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  558. return false;
  559. }
  560. if (party.getLeader() != player)
  561. {
  562. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  563. return false;
  564. }
  565. for (L2PcInstance partyMember : party.getMembers())
  566. {
  567. L2ItemInstance item = partyMember.getInventory().getItemByItemId(RED_CORAL);
  568. if (item == null)
  569. {
  570. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  571. sm.addPcName(partyMember);
  572. party.broadcastPacket(sm);
  573. return false;
  574. }
  575. if (!Util.checkIfInRange(1000, player, partyMember, true))
  576. {
  577. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  578. sm.addPcName(partyMember);
  579. party.broadcastPacket(sm);
  580. return false;
  581. }
  582. }
  583. return true;
  584. }
  585. private boolean checkBaylorConditions(L2PcInstance player)
  586. {
  587. L2Party party = player.getParty();
  588. if (party == null)
  589. {
  590. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  591. return false;
  592. }
  593. if (party.getLeader() != player)
  594. {
  595. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  596. return false;
  597. }
  598. for (L2PcInstance partyMember : party.getMembers())
  599. {
  600. L2ItemInstance item1 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_1);
  601. L2ItemInstance item2 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_2);
  602. L2ItemInstance item3 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_3);
  603. if ((item1 == null) || (item2 == null) || (item3 == null))
  604. {
  605. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  606. sm.addPcName(partyMember);
  607. party.broadcastPacket(sm);
  608. return false;
  609. }
  610. if (!Util.checkIfInRange(1000, player, partyMember, true))
  611. {
  612. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  613. sm.addPcName(partyMember);
  614. party.broadcastPacket(sm);
  615. return false;
  616. }
  617. }
  618. return true;
  619. }
  620. // this should be handled from skill effect
  621. private void Throw(L2Character effector, L2Character effected)
  622. {
  623. // Get current position of the L2Character
  624. final int curX = effected.getX();
  625. final int curY = effected.getY();
  626. final int curZ = effected.getZ();
  627. // Calculate distance between effector and effected current position
  628. double dx = effector.getX() - curX;
  629. double dy = effector.getY() - curY;
  630. double dz = effector.getZ() - curZ;
  631. double distance = Math.sqrt((dx * dx) + (dy * dy));
  632. int offset = Math.min((int) distance + 300, 1400);
  633. double cos;
  634. double sin;
  635. // approximation for moving futher when z coordinates are different
  636. // TODO: handle Z axis movement better
  637. offset += Math.abs(dz);
  638. if (offset < 5)
  639. {
  640. offset = 5;
  641. }
  642. if (distance < 1)
  643. {
  644. return;
  645. }
  646. // Calculate movement angles needed
  647. sin = dy / distance;
  648. cos = dx / distance;
  649. // Calculate the new destination with offset included
  650. int _x = effector.getX() - (int) (offset * cos);
  651. int _y = effector.getY() - (int) (offset * sin);
  652. int _z = effected.getZ();
  653. Location destination = GeoData.getInstance().moveCheck(effected.getX(), effected.getY(), effected.getZ(), _x, _y, _z, effected.getInstanceId());
  654. effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP));
  655. // maybe is need force set X,Y,Z
  656. effected.setXYZ(destination);
  657. effected.broadcastPacket(new ValidateLocation(effected));
  658. }
  659. @Override
  660. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  661. {
  662. if (firstEntrance)
  663. {
  664. if (player.getParty() == null)
  665. {
  666. // this can happen only if debug is true
  667. player.sendMessage("Welcome to Crystal Caverns.");
  668. teleportPlayer(player, START_LOC, world.getInstanceId());
  669. world.addAllowed(player.getObjectId());
  670. }
  671. else
  672. {
  673. for (L2PcInstance partyMember : player.getParty().getMembers())
  674. {
  675. partyMember.sendMessage("Welcome to Crystal Caverns.");
  676. teleportPlayer(partyMember, START_LOC, world.getInstanceId());
  677. world.addAllowed(partyMember.getObjectId());
  678. }
  679. }
  680. runOracle((CCWorld) world);
  681. }
  682. else
  683. {
  684. teleportPlayer(player, START_LOC, world.getInstanceId());
  685. }
  686. }
  687. protected void stopAttack(L2PcInstance player)
  688. {
  689. player.setTarget(null);
  690. player.abortAttack();
  691. player.abortCast();
  692. player.breakAttack();
  693. player.breakCast();
  694. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  695. L2Summon pet = player.getSummon();
  696. if (pet != null)
  697. {
  698. pet.setTarget(null);
  699. pet.abortAttack();
  700. pet.abortCast();
  701. pet.breakAttack();
  702. pet.breakCast();
  703. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  704. }
  705. }
  706. protected void runOracle(CCWorld world)
  707. {
  708. world.setStatus(0);
  709. world.oracle.add(addSpawn(ORACLE_GUIDE_1, 143172, 148894, -11975, 0, false, 0, false, world.getInstanceId()));
  710. }
  711. protected void runEmerald(CCWorld world)
  712. {
  713. world.setStatus(1);
  714. runFirst(world);
  715. openDoor(DOOR1, world.getInstanceId());
  716. }
  717. protected void runCoral(CCWorld world)
  718. {
  719. world.setStatus(1);
  720. runHall(world);
  721. openDoor(DOOR2, world.getInstanceId());
  722. openDoor(DOOR5, world.getInstanceId());
  723. }
  724. protected void runHall(CCWorld world)
  725. {
  726. world.setStatus(2);
  727. for (int[] spawn : HALL_SPAWNS)
  728. {
  729. L2Npc mob = addSpawn(CGMOBS[getRandom(CGMOBS.length)], spawn[0], spawn[1], spawn[2], spawn[3], false, 0, false, world.getInstanceId());
  730. world.npcList1.put(mob, false);
  731. }
  732. }
  733. protected void runFirst(CCWorld world)
  734. {
  735. world.setStatus(2);
  736. world.keyKeepers.add(addSpawn(GK1, 148206, 149486, -12140, 32308, false, 0, false, world.getInstanceId()));
  737. world.keyKeepers.add(addSpawn(GK2, 148203, 151093, -12140, 31100, false, 0, false, world.getInstanceId()));
  738. for (int[] spawn : FIRST_SPAWNS)
  739. {
  740. addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  741. }
  742. }
  743. protected void runEmeraldSquare(CCWorld world)
  744. {
  745. world.setStatus(3);
  746. Map<L2Npc, Boolean> spawnList = new FastMap<>();
  747. for (int[] spawn : EMERALD_SPAWNS)
  748. {
  749. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  750. spawnList.put(mob, false);
  751. }
  752. world.npcList2.put(0, spawnList);
  753. }
  754. protected void runEmeraldRooms(CCWorld world, int[][] spawnList, int room)
  755. {
  756. Map<L2Npc, Boolean> spawned = new FastMap<>();
  757. for (int[] spawn : spawnList)
  758. {
  759. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  760. spawned.put(mob, false);
  761. }
  762. if (room == 1)
  763. {
  764. addSpawn(32359, 142110, 139896, -11888, 8033, false, 0, false, world.getInstanceId());
  765. }
  766. world.npcList2.put(room, spawned);
  767. world.roomsStatus[room - 1] = 1;
  768. }
  769. protected void runDarnel(CCWorld world)
  770. {
  771. world.setStatus(9);
  772. addSpawn(DARNEL, 152759, 145949, -12588, 21592, false, 0, false, world.getInstanceId());
  773. // TODO: missing traps
  774. openDoor(24220005, world.getInstanceId());
  775. openDoor(24220006, world.getInstanceId());
  776. }
  777. protected void runSteamRooms(CCWorld world, int[][] spawnList, int status)
  778. {
  779. world.setStatus(status);
  780. Map<L2Npc, Boolean> spawned = new FastMap<>();
  781. for (int[] spawn : spawnList)
  782. {
  783. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  784. spawned.put(mob, false);
  785. }
  786. world.npcList2.put(0, spawned);
  787. }
  788. protected void runSteamOracles(CCWorld world, int[][] oracleOrder)
  789. {
  790. world.oracles.clear();
  791. for (int[] oracle : oracleOrder)
  792. {
  793. world.oracles.put(addSpawn(oracle[0], oracle[1], oracle[2], oracle[3], oracle[4], false, 0, false, world.getInstanceId()), null);
  794. }
  795. }
  796. protected boolean checkKillProgress(int room, L2Npc mob, CCWorld world)
  797. {
  798. if (world.npcList2.get(room).containsKey(mob))
  799. {
  800. world.npcList2.get(room).put(mob, true);
  801. }
  802. for (boolean isDead : world.npcList2.get(room).values())
  803. {
  804. if (!isDead)
  805. {
  806. return false;
  807. }
  808. }
  809. return true;
  810. }
  811. /*
  812. * protected void runBaylorRoom(CCWorld world) { world.status = 30; addSpawn(29101,152758,143479,-12706,52961,false,0,false,world.getInstanceId(),0);//up power addSpawn(29101,151951,142078,-12706,65203,false,0,false,world.getInstanceId(),0);//up power
  813. * addSpawn(29101,154396,140667,-12706,22197,false,0,false,world.getInstanceId(),0);//up power addSpawn(29102,152162,141249,-12706,5511,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,153571,140458,-12706,16699,false,0,false,world.getInstanceId(),0);//down power
  814. * addSpawn(29102,154976,141265,-12706,26908,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,155203,142071,-12706,31560,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,154380,143468,-12708,43943,false,0,false,world.getInstanceId(),0);//down power
  815. * addSpawn(32271,153573,142069,-9722,11175,false,0,false,world.getInstanceId()); world.Baylor = addSpawn(BAYLOR,153557,142089,-12735,11175,false,0,false,world.getInstanceId(),0); }
  816. */
  817. @Override
  818. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  819. {
  820. if (npc.getId() == ORACLE_GUIDE_1)
  821. {
  822. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  823. if (tmpworld instanceof CCWorld)
  824. {
  825. CCWorld world = (CCWorld) tmpworld;
  826. if ((world.getStatus() == 0) && world.oracle.contains(npc))
  827. {
  828. return "32281.htm";// TODO: Missing HTML.
  829. }
  830. }
  831. npc.showChatWindow(player);
  832. return null;
  833. }
  834. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277))
  835. {
  836. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  837. if (tmpworld instanceof CCWorld)
  838. {
  839. CCWorld world = (CCWorld) tmpworld;
  840. if (!world.OracleTriggered[npc.getId() - 32275])
  841. {
  842. return "no.htm"; // TODO: Missing HTML.
  843. }
  844. npc.showChatWindow(player);
  845. return null;
  846. }
  847. }
  848. else if (npc.getId() == 32274)
  849. {
  850. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  851. if (tmpworld instanceof CCWorld)
  852. {
  853. return "no.htm"; // TODO: Missing HTML.
  854. }
  855. }
  856. else if (npc.getId() == 32279)
  857. {
  858. final QuestState st = player.getQuestState(Q00131_BirdInACage.class.getSimpleName());
  859. return (st != null) && !st.isCompleted() ? "32279-01.htm" : "32279.htm";
  860. }
  861. else if (npc.getId() == CRYSTAL_GOLEM)
  862. {
  863. player.sendPacket(ActionFailed.STATIC_PACKET);
  864. }
  865. return "";
  866. }
  867. @Override
  868. public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  869. {
  870. boolean doReturn = true;
  871. for (L2Object obj : targets)
  872. {
  873. if (obj == npc)
  874. {
  875. doReturn = false;
  876. }
  877. }
  878. if (doReturn)
  879. {
  880. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  881. }
  882. switch (skill.getId())
  883. {
  884. case 1011:
  885. case 1015:
  886. case 1217:
  887. case 1218:
  888. case 1401:
  889. case 2360:
  890. case 2369:
  891. case 5146:
  892. doReturn = false;
  893. break;
  894. default:
  895. doReturn = true;
  896. }
  897. if (doReturn)
  898. {
  899. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  900. }
  901. if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && (skill.getId() != 2360) && (skill.getId() != 2369))
  902. {
  903. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  904. if ((tmpworld instanceof CCWorld) && (getRandom(100) < 15))
  905. {
  906. for (L2Npc oracle : ((CCWorld) tmpworld).oracles.keySet())
  907. {
  908. if (oracle != npc)
  909. {
  910. oracle.decayMe();
  911. }
  912. }
  913. ((CCWorld) tmpworld).OracleTriggered[npc.getId() - 32275] = true;
  914. }
  915. }
  916. else if (npc.isInvul() && (npc.getId() == BAYLOR) && (skill.getId() == 2360) && (caster != null))
  917. {
  918. if (caster.getParty() == null)
  919. {
  920. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  921. }
  922. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  923. if (tmpworld instanceof CCWorld)
  924. {
  925. CCWorld world = (CCWorld) tmpworld;
  926. if (((world._dragonClawStart + DRAGONCLAWTIME) <= System.currentTimeMillis()) || (world._dragonClawNeed <= 0))
  927. {
  928. world._dragonClawStart = System.currentTimeMillis();
  929. world._dragonClawNeed = caster.getParty().getMemberCount() - 1;
  930. }
  931. else
  932. {
  933. world._dragonClawNeed--;
  934. }
  935. if (world._dragonClawNeed == 0)
  936. {
  937. npc.stopSkillEffects(false, 5225);
  938. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5480, 1, 4000, 0));
  939. if (world._raidStatus == 3)
  940. {
  941. world._raidStatus++;
  942. }
  943. }
  944. }
  945. }
  946. else if (npc.isInvul() && (npc.getId() == TEARS) && (skill.getId() == 2369) && (caster != null))
  947. {
  948. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  949. if (tmpworld instanceof CCWorld)
  950. {
  951. CCWorld world = (CCWorld) tmpworld;
  952. if (caster.getParty() == null)
  953. {
  954. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  955. }
  956. else if (((world.dragonScaleStart + DRAGONSCALETIME) <= System.currentTimeMillis()) || (world.dragonScaleNeed <= 0))
  957. {
  958. world.dragonScaleStart = System.currentTimeMillis();
  959. world.dragonScaleNeed = caster.getParty().getMemberCount() - 1;
  960. }
  961. else
  962. {
  963. world.dragonScaleNeed--;
  964. }
  965. if ((world.dragonScaleNeed == 0) && (getRandom(100) < 80))
  966. {
  967. npc.setIsInvul(false);
  968. }
  969. }
  970. }
  971. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  972. }
  973. @Override
  974. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  975. {
  976. if (npc.getId() == TEARS)
  977. {
  978. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  979. if (tmpworld instanceof CCWorld)
  980. {
  981. CCWorld world = (CCWorld) tmpworld;
  982. if ((world.getStatus() != 4) && (attacker != null))
  983. {
  984. // Lucky cheater, the code only kicks his/her ass out of the dungeon
  985. teleportPlayer(attacker, new Location(149361, 172327, -945), 0);
  986. world.removeAllowed(attacker.getObjectId());
  987. }
  988. else if (world.tears != npc)
  989. {
  990. return "";
  991. }
  992. else if (!world.copys.isEmpty())
  993. {
  994. boolean notAOE = true;
  995. if ((skill != null) && ((skill.getTargetType() == L2TargetType.AREA) || (skill.getTargetType() == L2TargetType.FRONT_AREA) || (skill.getTargetType() == L2TargetType.BEHIND_AREA) || (skill.getTargetType() == L2TargetType.AURA) || (skill.getTargetType() == L2TargetType.FRONT_AURA) || (skill.getTargetType() == L2TargetType.BEHIND_AURA)))
  996. {
  997. notAOE = false;
  998. }
  999. if (notAOE)
  1000. {
  1001. for (L2Npc copy : world.copys)
  1002. {
  1003. copy.onDecay();
  1004. }
  1005. world.copys.clear();
  1006. }
  1007. return "";
  1008. }
  1009. int maxHp = npc.getMaxHp();
  1010. double nowHp = npc.getStatus().getCurrentHp();
  1011. int rand = getRandom(1000);
  1012. if ((nowHp < (maxHp * 0.4)) && (rand < 5))
  1013. {
  1014. L2Party party = attacker.getParty();
  1015. if (party != null)
  1016. {
  1017. for (L2PcInstance partyMember : party.getMembers())
  1018. {
  1019. stopAttack(partyMember);
  1020. }
  1021. }
  1022. else
  1023. {
  1024. stopAttack(attacker);
  1025. }
  1026. L2Character target = npc.getAI().getAttackTarget();
  1027. for (int i = 0; i < 10; i++)
  1028. {
  1029. L2Npc copy = addSpawn(TEARS_COPY, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false, attacker.getInstanceId());
  1030. copy.setRunning();
  1031. ((L2Attackable) copy).addDamageHate(target, 0, 99999);
  1032. copy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  1033. copy.setCurrentHp(nowHp);
  1034. world.copys.add(copy);
  1035. }
  1036. }
  1037. else if ((nowHp < (maxHp * 0.15)) && !world.isUsedInvulSkill)
  1038. {
  1039. if ((rand > 994) || (nowHp < (maxHp * 0.1)))
  1040. {
  1041. world.isUsedInvulSkill = true;
  1042. npc.setIsInvul(true);
  1043. }
  1044. }
  1045. }
  1046. }
  1047. return null;
  1048. }
  1049. @Override
  1050. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  1051. {
  1052. if ((npc.getId() == BAYLOR) && (skill.getId() == 5225))
  1053. {
  1054. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1055. if (tmpworld instanceof CCWorld)
  1056. {
  1057. ((CCWorld) tmpworld)._raidStatus++;
  1058. }
  1059. }
  1060. return super.onSpellFinished(npc, player, skill);
  1061. }
  1062. @Override
  1063. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  1064. {
  1065. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1066. if (tmpworld instanceof CCWorld)
  1067. {
  1068. CCWorld world = (CCWorld) tmpworld;
  1069. if (event.equalsIgnoreCase("TeleportOut"))
  1070. {
  1071. teleportPlayer(player, new Location(149413, 173078, -5014), 0);
  1072. }
  1073. else if (event.equalsIgnoreCase("TeleportParme"))
  1074. {
  1075. teleportPlayer(player, new Location(153689, 142226, -9750), world.getInstanceId());
  1076. }
  1077. else if (event.equalsIgnoreCase("Timer2") || event.equalsIgnoreCase("Timer3") || event.equalsIgnoreCase("Timer4") || event.equalsIgnoreCase("Timer5"))
  1078. {
  1079. if (player.getInstanceId() == world.getInstanceId())
  1080. {
  1081. teleportPlayer(player, new Location(144653, 152606, -12126), world.getInstanceId());
  1082. player.stopSkillEffects(true, 5239);
  1083. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  1084. startQuestTimer("Timer2", 300000, npc, player);
  1085. }
  1086. }
  1087. else if (event.equalsIgnoreCase("Timer21") || event.equalsIgnoreCase("Timer31") || event.equalsIgnoreCase("Timer41") || event.equalsIgnoreCase("Timer51"))
  1088. {
  1089. InstanceManager.getInstance().getInstance(world.getInstanceId()).removeNpcs();
  1090. world.npcList2.clear();
  1091. runSteamRooms(world, STEAM1_SPAWNS, 22);
  1092. startQuestTimer("Timer21", 300000, npc, null);
  1093. }
  1094. else if (event.equalsIgnoreCase("checkKechiAttack"))
  1095. {
  1096. if (npc.isInCombat())
  1097. {
  1098. startQuestTimer("spawnGuards", SPAWN[0], npc, null);
  1099. cancelQuestTimers("checkKechiAttack");
  1100. closeDoor(DOOR4, npc.getInstanceId());
  1101. closeDoor(DOOR3, npc.getInstanceId());
  1102. }
  1103. else
  1104. {
  1105. startQuestTimer("checkKechiAttack", 1000, npc, null);
  1106. }
  1107. }
  1108. else if (event.equalsIgnoreCase("spawnGuards"))
  1109. {
  1110. world.kechisHenchmanSpawn++;
  1111. world.guards.add(addSpawn(KECHIGUARD, 153622, 149699, -12131, 56890, false, 0, false, world.getInstanceId()));
  1112. world.guards.add(addSpawn(KECHIGUARD, 153609, 149622, -12131, 64023, false, 0, false, world.getInstanceId()));
  1113. world.guards.add(addSpawn(KECHIGUARD, 153606, 149428, -12131, 64541, false, 0, false, world.getInstanceId()));
  1114. world.guards.add(addSpawn(KECHIGUARD, 153601, 149534, -12131, 64901, false, 0, false, world.getInstanceId()));
  1115. world.guards.add(addSpawn(KECHIGUARD, 153620, 149354, -12131, 1164, false, 0, false, world.getInstanceId()));
  1116. world.guards.add(addSpawn(KECHIGUARD, 153637, 149776, -12131, 61733, false, 0, false, world.getInstanceId()));
  1117. world.guards.add(addSpawn(KECHIGUARD, 153638, 149292, -12131, 64071, false, 0, false, world.getInstanceId()));
  1118. world.guards.add(addSpawn(KECHIGUARD, 153647, 149857, -12131, 59402, false, 0, false, world.getInstanceId()));
  1119. world.guards.add(addSpawn(KECHIGUARD, 153661, 149227, -12131, 65275, false, 0, false, world.getInstanceId()));
  1120. if (world.kechisHenchmanSpawn <= 5)
  1121. {
  1122. startQuestTimer("spawnGuards", SPAWN[world.kechisHenchmanSpawn], npc, null);
  1123. }
  1124. else
  1125. {
  1126. cancelQuestTimers("spawnGuards");
  1127. }
  1128. }
  1129. else if (event.equalsIgnoreCase("EmeraldSteam"))
  1130. {
  1131. runEmerald(world);
  1132. for (L2Npc oracle : world.oracle)
  1133. {
  1134. oracle.decayMe();
  1135. }
  1136. }
  1137. else if (event.equalsIgnoreCase("CoralGarden"))
  1138. {
  1139. runCoral(world);
  1140. for (L2Npc oracle : world.oracle)
  1141. {
  1142. oracle.decayMe();
  1143. }
  1144. }
  1145. else if (event.equalsIgnoreCase("spawn_oracle"))
  1146. {
  1147. addSpawn(32271, 153572, 142075, -9728, 10800, false, 0, false, world.getInstanceId());
  1148. addSpawn((getRandom(10) < 5 ? 29116 : 29117), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, world.getInstanceId()); // Baylor's Chest
  1149. addSpawn(ORACLE_GUIDE_4, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  1150. cancelQuestTimer("baylor_despawn", npc, null);
  1151. cancelQuestTimers("baylor_skill");
  1152. }
  1153. else if (event.equalsIgnoreCase("baylorEffect0"))
  1154. {
  1155. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1156. npc.broadcastSocialAction(1);
  1157. startQuestTimer("baylorCamera0", 11000, npc, null);
  1158. startQuestTimer("baylorEffect1", 19000, npc, null);
  1159. }
  1160. else if (event.equalsIgnoreCase("baylorCamera0"))
  1161. {
  1162. npc.broadcastPacket(new SpecialCamera(npc, 500, -45, 170, 5000, 9000, 0, 0, 1, 0, 0));
  1163. }
  1164. else if (event.equalsIgnoreCase("baylorEffect1"))
  1165. {
  1166. npc.broadcastPacket(new SpecialCamera(npc, 300, 0, 120, 2000, 5000, 0, 0, 1, 0, 0));
  1167. npc.broadcastSocialAction(3);
  1168. startQuestTimer("baylorEffect2", 4000, npc, null);
  1169. }
  1170. else if (event.equalsIgnoreCase("baylorEffect2"))
  1171. {
  1172. npc.broadcastPacket(new SpecialCamera(npc, 747, 0, 160, 2000, 3000, 0, 0, 1, 0, 0));
  1173. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5402, 1, 2000, 0));
  1174. startQuestTimer("RaidStart", 2000, npc, null);
  1175. }
  1176. else if (event.equalsIgnoreCase("BaylorMinions"))
  1177. {
  1178. for (int i = 0; i < 10; i++)
  1179. {
  1180. int radius = 300;
  1181. int x = (int) (radius * Math.cos(i * 0.618));
  1182. int y = (int) (radius * Math.sin(i * 0.618));
  1183. L2Npc mob = addSpawn(29104, 153571 + x, 142075 + y, -12737, 0, false, 0, false, world.getInstanceId());
  1184. mob.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1185. world._animationMobs.add(mob);
  1186. }
  1187. startQuestTimer("baylorEffect0", 200, npc, null);
  1188. }
  1189. else if (event.equalsIgnoreCase("RaidStart"))
  1190. {
  1191. world._camera.decayMe();
  1192. world._camera = null;
  1193. npc.setIsParalyzed(false);
  1194. for (L2PcInstance p : world._raiders)
  1195. {
  1196. p.setIsParalyzed(false);
  1197. Throw(npc, p);
  1198. if (p.getSummon() != null)
  1199. {
  1200. Throw(npc, p.getSummon());
  1201. }
  1202. }
  1203. world._raidStatus = 0;
  1204. for (L2Npc mob : world._animationMobs)
  1205. {
  1206. mob.doDie(mob);
  1207. }
  1208. world._animationMobs.clear();
  1209. startQuestTimer("baylor_despawn", 60000, npc, null, true);
  1210. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  1211. }
  1212. else if (event.equalsIgnoreCase("checkBaylorAttack"))
  1213. {
  1214. if (npc.isInCombat())
  1215. {
  1216. cancelQuestTimers("checkBaylorAttack");
  1217. startQuestTimer("baylor_alarm", 40000, npc, null);
  1218. startQuestTimer("baylor_skill", 5000, npc, null, true);
  1219. world._raidStatus++;
  1220. }
  1221. else
  1222. {
  1223. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  1224. }
  1225. }
  1226. else if (event.equalsIgnoreCase("baylor_alarm"))
  1227. {
  1228. if (world._alarm == null)
  1229. {
  1230. int[] spawnLoc = ALARMSPAWN[getRandom(ALARMSPAWN.length)];
  1231. npc.addSkill(SkillData.getInstance().getSkill(5244, 1));
  1232. npc.addSkill(SkillData.getInstance().getSkill(5245, 1));
  1233. world._alarm = addSpawn(ALARMID, spawnLoc[0], spawnLoc[1], spawnLoc[2], 10800, false, 0, false, world.getInstanceId());
  1234. world._alarm.disableCoreAI(true);
  1235. world._alarm.setIsImmobilized(true);
  1236. world._alarm.broadcastPacket(new CreatureSay(world._alarm.getObjectId(), 1, world._alarm.getName(), NpcStringId.AN_ALARM_HAS_BEEN_SET_OFF_EVERYBODY_WILL_BE_IN_DANGER_IF_THEY_ARE_NOT_TAKEN_CARE_OF_IMMEDIATELY));
  1237. }
  1238. }
  1239. else if (event.equalsIgnoreCase("baylor_skill"))
  1240. {
  1241. if (world._baylor == null)
  1242. {
  1243. cancelQuestTimers("baylor_skill");
  1244. }
  1245. else
  1246. {
  1247. int maxHp = npc.getMaxHp();
  1248. double nowHp = npc.getStatus().getCurrentHp();
  1249. int rand = getRandom(100);
  1250. if ((nowHp < (maxHp * 0.2)) && (world._raidStatus < 3) && !npc.isAffectedBySkill(5224) && !npc.isAffectedBySkill(5225))
  1251. {
  1252. if ((nowHp < (maxHp * 0.15)) && (world._raidStatus == 2))
  1253. {
  1254. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  1255. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  1256. }
  1257. else if ((rand < 10) || (nowHp < (maxHp * 0.15)))
  1258. {
  1259. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  1260. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  1261. startQuestTimer("baylor_remove_invul", 30000, world._baylor, null);
  1262. }
  1263. }
  1264. else if ((nowHp < (maxHp * 0.3)) && (rand > 50) && !npc.isAffectedBySkill(5225) && !npc.isAffectedBySkill(5224))
  1265. {
  1266. npc.doCast(SkillData.getInstance().getSkill(5224, 1));
  1267. }
  1268. else if (rand < 33)
  1269. {
  1270. npc.setTarget(world._raiders.get(getRandom(world._raiders.size())));
  1271. npc.doCast(SkillData.getInstance().getSkill(5229, 1));
  1272. }
  1273. }
  1274. }
  1275. else if (event.equalsIgnoreCase("baylor_remove_invul"))
  1276. {
  1277. npc.stopSkillEffects(false, 5225);
  1278. }
  1279. else if (event.equalsIgnoreCase("Baylor"))
  1280. {
  1281. world._baylor = addSpawn(29099, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  1282. world._baylor.setIsParalyzed(true);
  1283. world._camera = addSpawn(29120, 153273, 141400, -12738, 10800, false, 0, false, world.getInstanceId());
  1284. world._camera.broadcastPacket(new SpecialCamera(world._camera, 700, -45, 160, 500, 15200, 0, 0, 1, 0, 0));
  1285. startQuestTimer("baylorMinions", 2000, world._baylor, null);
  1286. }
  1287. else if (!event.endsWith("Food"))
  1288. {
  1289. return "";
  1290. }
  1291. else if (event.equalsIgnoreCase("autoFood"))
  1292. {
  1293. if (!world.crystalGolems.containsKey(npc))
  1294. {
  1295. world.crystalGolems.put(npc, new CrystalGolem());
  1296. }
  1297. if ((world.getStatus() != 3) || !world.crystalGolems.containsKey(npc) || (world.crystalGolems.get(npc).foodItem != null) || world.crystalGolems.get(npc).isAtDestination)
  1298. {
  1299. return "";
  1300. }
  1301. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1302. List<L2Object> crystals = new FastList<>();
  1303. for (L2Object object : L2World.getInstance().getVisibleObjects(npc, 300))
  1304. {
  1305. if ((object instanceof L2ItemInstance) && (object.getId() == CRYSTALFOOD))
  1306. {
  1307. crystals.add(object);
  1308. }
  1309. }
  1310. int minDist = 300000;
  1311. for (L2Object crystal : crystals)
  1312. {
  1313. int dx = npc.getX() - crystal.getX();
  1314. int dy = npc.getY() - crystal.getY();
  1315. int d = (dx * dx) + (dy * dy);
  1316. if (d < minDist)
  1317. {
  1318. minDist = d;
  1319. cryGolem.foodItem = (L2ItemInstance) crystal;
  1320. }
  1321. }
  1322. if (minDist != 300000)
  1323. {
  1324. startQuestTimer("getFood", 2000, npc, null);
  1325. }
  1326. else
  1327. {
  1328. if (getRandom(100) < 5)
  1329. {
  1330. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.AH_IM_HUNGRY));
  1331. }
  1332. startQuestTimer("autoFood", 2000, npc, null);
  1333. }
  1334. return "";
  1335. }
  1336. else if (!world.crystalGolems.containsKey(npc) || world.crystalGolems.get(npc).isAtDestination)
  1337. {
  1338. return "";
  1339. }
  1340. else if (event.equalsIgnoreCase("backFood"))
  1341. {
  1342. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  1343. {
  1344. cancelQuestTimers("backFood");
  1345. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  1346. world.crystalGolems.get(npc).foodItem = null;
  1347. startQuestTimer("autoFood", 2000, npc, null);
  1348. }
  1349. }
  1350. else if (event.equalsIgnoreCase("reachFood"))
  1351. {
  1352. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1353. int dx;
  1354. int dy;
  1355. if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isVisible())
  1356. {
  1357. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, cryGolem.oldLoc);
  1358. cancelQuestTimers("reachFood");
  1359. startQuestTimer("backFood", 2000, npc, null, true);
  1360. return "";
  1361. }
  1362. else if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  1363. {
  1364. L2World.getInstance().removeVisibleObject(cryGolem.foodItem, cryGolem.foodItem.getWorldRegion());
  1365. L2World.getInstance().removeObject(cryGolem.foodItem);
  1366. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  1367. cryGolem.foodItem = null;
  1368. dx = npc.getX() - 142999;
  1369. dy = npc.getY() - 151671;
  1370. int d1 = (dx * dx) + (dy * dy);
  1371. dx = npc.getX() - 139494;
  1372. dy = npc.getY() - 151668;
  1373. int d2 = (dx * dx) + (dy * dy);
  1374. if ((d1 < 10000) || (d2 < 10000))
  1375. {
  1376. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  1377. cryGolem.isAtDestination = true;
  1378. world.correctGolems++;
  1379. if (world.correctGolems >= 2)
  1380. {
  1381. openDoor(24220026, world.getInstanceId());
  1382. world.setStatus(4);
  1383. }
  1384. }
  1385. else
  1386. {
  1387. startQuestTimer("autoFood", 2000, npc, null);
  1388. }
  1389. cancelQuestTimers("reachFood");
  1390. }
  1391. return "";
  1392. }
  1393. else if (event.equalsIgnoreCase("getFood"))
  1394. {
  1395. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1396. Location newLoc = new Location(cryGolem.foodItem.getX(), cryGolem.foodItem.getY(), cryGolem.foodItem.getZ(), 0);
  1397. cryGolem.oldLoc = new Location(npc.getX(), npc.getY(), npc.getZ(), npc.getHeading());
  1398. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newLoc);
  1399. startQuestTimer("reachFood", 2000, npc, null, true);
  1400. cancelQuestTimers("getFood");
  1401. }
  1402. }
  1403. return "";
  1404. }
  1405. private void giveRewards(L2PcInstance player, int instanceId, int bossCry, boolean isBaylor)
  1406. {
  1407. final int num = Math.max((int) Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER, 1);
  1408. L2Party party = player.getParty();
  1409. if (party != null)
  1410. {
  1411. for (L2PcInstance partyMember : party.getMembers())
  1412. {
  1413. if (partyMember.getInstanceId() == instanceId)
  1414. {
  1415. if (!isBaylor && hasQuestItems(partyMember, CONT_CRYSTAL))
  1416. {
  1417. takeItems(partyMember, CONT_CRYSTAL, 1);
  1418. giveItems(partyMember, bossCry, 1);
  1419. }
  1420. if (getRandom(10) < 5)
  1421. {
  1422. giveItems(partyMember, WHITE_SEED, num);
  1423. }
  1424. else
  1425. {
  1426. giveItems(partyMember, BLACK_SEED, num);
  1427. }
  1428. }
  1429. }
  1430. }
  1431. else if (player.getInstanceId() == instanceId)
  1432. {
  1433. if (!isBaylor && hasQuestItems(player, CONT_CRYSTAL))
  1434. {
  1435. takeItems(player, CONT_CRYSTAL, 1);
  1436. giveItems(player, bossCry, 1);
  1437. }
  1438. if (getRandom(10) < 5)
  1439. {
  1440. giveItems(player, WHITE_SEED, num);
  1441. }
  1442. else
  1443. {
  1444. giveItems(player, BLACK_SEED, num);
  1445. }
  1446. }
  1447. }
  1448. @Override
  1449. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  1450. {
  1451. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1452. if (tmpworld instanceof CCWorld)
  1453. {
  1454. CCWorld world = (CCWorld) tmpworld;
  1455. if ((world.getStatus() == 2) && world.npcList1.containsKey(npc))
  1456. {
  1457. world.npcList1.put(npc, true);
  1458. for (boolean isDead : world.npcList1.values())
  1459. {
  1460. if (!isDead)
  1461. {
  1462. return "";
  1463. }
  1464. }
  1465. world.setStatus(3);
  1466. world.tears = addSpawn(TEARS, 144298, 154420, -11854, 32767, false, 0, false, world.getInstanceId()); // Tears
  1467. CrystalGolem crygolem1 = new CrystalGolem();
  1468. CrystalGolem crygolem2 = new CrystalGolem();
  1469. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 140547, 151670, -11813, 32767, false, 0, false, world.getInstanceId()), crygolem1);
  1470. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 141941, 151684, -11813, 63371, false, 0, false, world.getInstanceId()), crygolem2);
  1471. for (L2Npc crygolem : world.crystalGolems.keySet())
  1472. {
  1473. startQuestTimer("autoFood", 2000, crygolem, null);
  1474. }
  1475. }
  1476. else if ((world.getStatus() == 4) && (npc.getId() == TEARS))
  1477. {
  1478. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  1479. addSpawn(32280, 144312, 154420, -11855, 0, false, 0, false, world.getInstanceId());
  1480. giveRewards(player, npc.getInstanceId(), BOSS_CRYSTAL_3, false);
  1481. }
  1482. else if ((world.getStatus() == 2) && world.keyKeepers.contains(npc))
  1483. {
  1484. if (npc.getId() == GK1)
  1485. {
  1486. npc.dropItem(player, 9698, 1);
  1487. runEmeraldSquare(world);
  1488. }
  1489. else if (npc.getId() == GK2)
  1490. {
  1491. npc.dropItem(player, 9699, 1);
  1492. runSteamRooms(world, STEAM1_SPAWNS, 22);
  1493. L2Party party = player.getParty();
  1494. if (party != null)
  1495. {
  1496. for (L2PcInstance partyMember : party.getMembers())
  1497. {
  1498. if (partyMember.getInstanceId() == world.getInstanceId())
  1499. {
  1500. SkillData.getInstance().getSkill(5239, 1).applyEffects(partyMember, partyMember);
  1501. startQuestTimer("Timer2", 300000, npc, partyMember);
  1502. }
  1503. }
  1504. }
  1505. else
  1506. {
  1507. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  1508. startQuestTimer("Timer2", 300000, npc, player);
  1509. }
  1510. startQuestTimer("Timer21", 300000, npc, null);
  1511. }
  1512. for (L2Npc gk : world.keyKeepers)
  1513. {
  1514. if (gk != npc)
  1515. {
  1516. gk.decayMe();
  1517. }
  1518. }
  1519. }
  1520. else if (world.getStatus() == 3)
  1521. {
  1522. if (checkKillProgress(0, npc, world))
  1523. {
  1524. world.setStatus(4);
  1525. addSpawn(TOURMALINE, 148202, 144791, -12235, 0, false, 0, false, world.getInstanceId());
  1526. }
  1527. else
  1528. {
  1529. return "";
  1530. }
  1531. }
  1532. else if (world.getStatus() == 4)
  1533. {
  1534. if (npc.getId() == TOURMALINE)
  1535. {
  1536. world.setStatus(5);
  1537. addSpawn(TEROD, 147777, 146780, -12281, 0, false, 0, false, world.getInstanceId());
  1538. }
  1539. }
  1540. else if (world.getStatus() == 5)
  1541. {
  1542. if (npc.getId() == TEROD)
  1543. {
  1544. world.setStatus(6);
  1545. addSpawn(TOURMALINE, 143694, 142659, -11882, 0, false, 0, false, world.getInstanceId());
  1546. }
  1547. }
  1548. else if (world.getStatus() == 6)
  1549. {
  1550. if (npc.getId() == TOURMALINE)
  1551. {
  1552. world.setStatus(7);
  1553. addSpawn(DOLPH, 142054, 143288, -11825, 0, false, 0, false, world.getInstanceId());
  1554. }
  1555. }
  1556. else if (world.getStatus() == 7)
  1557. {
  1558. if (npc.getId() == DOLPH)
  1559. {
  1560. world.setStatus(8);
  1561. // first door opener trap
  1562. addTrap(DOOR_OPENING_TRAP[0], DOOR_OPENING_TRAP[1], DOOR_OPENING_TRAP[2], DOOR_OPENING_TRAP[3], DOOR_OPENING_TRAP[4], null, world.getInstanceId());
  1563. }
  1564. }
  1565. else if (world.getStatus() == 8)
  1566. {
  1567. for (int i = 0; i < 4; i++)
  1568. {
  1569. if ((world.roomsStatus[i] == 1) && checkKillProgress(i + 1, npc, world))
  1570. {
  1571. world.roomsStatus[i] = 2;
  1572. }
  1573. if (world.roomsStatus[i] == 2)
  1574. {
  1575. world.cleanedRooms++;
  1576. if (world.cleanedRooms == 21)
  1577. {
  1578. runDarnel(world);
  1579. }
  1580. }
  1581. }
  1582. }
  1583. else if ((world.getStatus() >= 22) && (world.getStatus() <= 25))
  1584. {
  1585. if (npc.getId() == 22416)
  1586. {
  1587. for (L2Npc oracle : world.oracles.keySet())
  1588. {
  1589. if (world.oracles.get(oracle) == npc)
  1590. {
  1591. world.oracles.put(oracle, null);
  1592. }
  1593. }
  1594. }
  1595. if (checkKillProgress(0, npc, world))
  1596. {
  1597. world.npcList2.clear();
  1598. int[][] oracleOrder;
  1599. switch (world.getStatus())
  1600. {
  1601. case 22:
  1602. closeDoor(DOOR6, npc.getInstanceId());
  1603. oracleOrder = ordreOracle1;
  1604. break;
  1605. case 23:
  1606. oracleOrder = ordreOracle2;
  1607. break;
  1608. case 24:
  1609. oracleOrder = ordreOracle3;
  1610. break;
  1611. case 25:
  1612. world.setStatus(26);
  1613. L2Party party = player.getParty();
  1614. if (party != null)
  1615. {
  1616. for (L2PcInstance partyMember : party.getMembers())
  1617. {
  1618. partyMember.stopSkillEffects(true, 5239);
  1619. }
  1620. }
  1621. cancelQuestTimers("Timer5");
  1622. cancelQuestTimers("Timer51");
  1623. openDoor(DOOR3, npc.getInstanceId());
  1624. openDoor(DOOR4, npc.getInstanceId());
  1625. L2Npc kechi = addSpawn(KECHI, 154069, 149525, -12158, 51165, false, 0, false, world.getInstanceId());
  1626. startQuestTimer("checkKechiAttack", 1000, kechi, null);
  1627. return "";
  1628. default:
  1629. _log.warning("CrystalCavern-SteamCorridor: status " + world.getStatus() + " error. OracleOrder not found in " + world.getInstanceId());
  1630. return "";
  1631. }
  1632. runSteamOracles(world, oracleOrder);
  1633. }
  1634. }
  1635. else if (((world.getStatus() == 9) && (npc.getId() == DARNEL)) || ((world.getStatus() == 26) && (npc.getId() == KECHI)))
  1636. {
  1637. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  1638. int bossCry;
  1639. if (npc.getId() == KECHI)
  1640. {
  1641. bossCry = BOSS_CRYSTAL_2;
  1642. cancelQuestTimers("spawnGuards");
  1643. addSpawn(32280, 154077, 149527, -12159, 0, false, 0, false, world.getInstanceId());
  1644. }
  1645. else if (npc.getId() == DARNEL)
  1646. {
  1647. bossCry = BOSS_CRYSTAL_1;
  1648. addSpawn(32280, 152761, 145950, -12588, 0, false, 0, false, world.getInstanceId());
  1649. }
  1650. else
  1651. {
  1652. // something is wrong
  1653. return "";
  1654. }
  1655. giveRewards(player, npc.getInstanceId(), bossCry, false);
  1656. }
  1657. if (npc.getId() == ALARMID)
  1658. {
  1659. world._baylor.removeSkill(5244);
  1660. world._baylor.removeSkill(5245);
  1661. world._alarm = null;
  1662. if ((world._baylor.getMaxHp() * 0.3) < world._baylor.getStatus().getCurrentHp())
  1663. {
  1664. startQuestTimer("baylor_alarm", 40000, world._baylor, null);
  1665. }
  1666. }
  1667. else if (npc.getId() == BAYLOR)
  1668. {
  1669. world.setStatus(31);
  1670. world._baylor = null;
  1671. npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  1672. Instance baylorInstance = InstanceManager.getInstance().getInstance(npc.getInstanceId());
  1673. baylorInstance.setDuration(300000);
  1674. this.startQuestTimer("spawn_oracle", 1000, npc, null);
  1675. giveRewards(player, npc.getInstanceId(), -1, true);
  1676. }
  1677. }
  1678. return "";
  1679. }
  1680. @Override
  1681. public String onTalk(L2Npc npc, L2PcInstance player)
  1682. {
  1683. int npcId = npc.getId();
  1684. QuestState st = getQuestState(player, false);
  1685. if (st == null)
  1686. {
  1687. st = newQuestState(player);
  1688. }
  1689. if (npcId == ORACLE_GUIDE_1)
  1690. {
  1691. enterInstance(player, new CCWorld(System.currentTimeMillis() + 5400000), "CrystalCaverns.xml", TEMPLATE_ID);
  1692. return "";
  1693. }
  1694. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1695. if (tmpworld instanceof CCWorld)
  1696. {
  1697. CCWorld world = (CCWorld) tmpworld;
  1698. if (npcId == CRYSTAL_GOLEM)
  1699. {
  1700. }
  1701. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && world.OracleTriggered[npc.getId() - 32275])
  1702. {
  1703. boolean doTeleport = false;
  1704. Location loc = null;
  1705. L2Party party = player.getParty();
  1706. doTeleport = true;
  1707. switch (npc.getId())
  1708. {
  1709. case 32275:
  1710. if (world.getStatus() == 22)
  1711. {
  1712. runSteamRooms(world, STEAM2_SPAWNS, 23);
  1713. }
  1714. loc = new Location(147529, 152587, -12169);
  1715. cancelQuestTimers("Timer2");
  1716. cancelQuestTimers("Timer21");
  1717. if (party != null)
  1718. {
  1719. for (L2PcInstance partyMember : party.getMembers())
  1720. {
  1721. if (partyMember.getInstanceId() == world.getInstanceId())
  1722. {
  1723. partyMember.stopSkillEffects(true, 5239);
  1724. SkillData.getInstance().getSkill(5239, 2).applyEffects(partyMember, partyMember);
  1725. startQuestTimer("Timer3", 600000, npc, partyMember);
  1726. }
  1727. }
  1728. }
  1729. else
  1730. {
  1731. player.stopSkillEffects(true, 5239);
  1732. SkillData.getInstance().getSkill(5239, 2).applyEffects(player, player);
  1733. startQuestTimer("Timer3", 600000, npc, player);
  1734. }
  1735. startQuestTimer("Timer31", 600000, npc, null);
  1736. break;
  1737. case 32276:
  1738. if (world.getStatus() == 23)
  1739. {
  1740. runSteamRooms(world, STEAM3_SPAWNS, 24);
  1741. }
  1742. loc = new Location(150194, 152610, -12169);
  1743. cancelQuestTimers("Timer3");
  1744. cancelQuestTimers("Timer31");
  1745. if (party != null)
  1746. {
  1747. for (L2PcInstance partyMember : party.getMembers())
  1748. {
  1749. if (partyMember.getInstanceId() == world.getInstanceId())
  1750. {
  1751. partyMember.stopSkillEffects(true, 5239);
  1752. SkillData.getInstance().getSkill(5239, 4).applyEffects(partyMember, partyMember);
  1753. startQuestTimer("Timer4", 1200000, npc, partyMember);
  1754. }
  1755. }
  1756. }
  1757. else
  1758. {
  1759. player.stopSkillEffects(true, 5239);
  1760. SkillData.getInstance().getSkill(5239, 4).applyEffects(player, player);
  1761. startQuestTimer("Timer4", 1200000, npc, player);
  1762. }
  1763. startQuestTimer("Timer41", 1200000, npc, null);
  1764. break;
  1765. case 32277:
  1766. if (world.getStatus() == 24)
  1767. {
  1768. runSteamRooms(world, STEAM4_SPAWNS, 25);
  1769. }
  1770. loc = new Location(149743, 149986, -12141);
  1771. cancelQuestTimers("Timer4");
  1772. cancelQuestTimers("Timer41");
  1773. if (party != null)
  1774. {
  1775. for (L2PcInstance partyMember : party.getMembers())
  1776. {
  1777. if (partyMember.getInstanceId() == world.getInstanceId())
  1778. {
  1779. partyMember.stopSkillEffects(true, 5239);
  1780. SkillData.getInstance().getSkill(5239, 3).applyEffects(partyMember, partyMember);
  1781. startQuestTimer("Timer5", 900000, npc, partyMember);
  1782. }
  1783. }
  1784. }
  1785. else
  1786. {
  1787. player.stopSkillEffects(true, 5239);
  1788. SkillData.getInstance().getSkill(5239, 3).applyEffects(player, player);
  1789. startQuestTimer("Timer5", 900000, npc, player);
  1790. }
  1791. startQuestTimer("Timer51", 900000, npc, null);
  1792. break;
  1793. default:
  1794. // something is wrong
  1795. doTeleport = false;
  1796. }
  1797. if (doTeleport && (loc != null))
  1798. {
  1799. if (!checkOracleConditions(player))
  1800. {
  1801. return "";
  1802. }
  1803. else if (party != null)
  1804. {
  1805. for (L2PcInstance partyMember : party.getMembers())
  1806. {
  1807. partyMember.destroyItemByItemId("Quest", RED_CORAL, 1, player, true);
  1808. teleportPlayer(partyMember, loc, npc.getInstanceId());
  1809. }
  1810. }
  1811. else
  1812. {
  1813. teleportPlayer(player, loc, npc.getInstanceId());
  1814. }
  1815. }
  1816. }
  1817. else if (npc.getId() == ORACLE_GUIDE_3)
  1818. {
  1819. if ((world.getStatus() < 30) && checkBaylorConditions(player))
  1820. {
  1821. world._raiders.clear();
  1822. L2Party party = player.getParty();
  1823. if (party == null)
  1824. {
  1825. world._raiders.add(player);
  1826. }
  1827. else
  1828. {
  1829. for (L2PcInstance partyMember : party.getMembers())
  1830. {
  1831. // int rnd = getRandom(100);
  1832. // partyMember.destroyItemByItemId("Quest", (rnd < 33 ? BOSS_CRYSTAL_1:(rnd < 67 ? BOSS_CRYSTAL_2:BOSS_CRYSTAL_3)), 1, partyMember, true); Crystals are no longer beign cunsumed while entering to Baylor Lair.
  1833. world._raiders.add(partyMember);
  1834. }
  1835. }
  1836. }
  1837. else
  1838. {
  1839. return "";
  1840. }
  1841. world.setStatus(30);
  1842. long time = world.endTime - System.currentTimeMillis();
  1843. Instance baylorInstance = InstanceManager.getInstance().getInstance(world.getInstanceId());
  1844. baylorInstance.setDuration((int) time);
  1845. int radius = 150;
  1846. int i = 0;
  1847. int members = world._raiders.size();
  1848. for (L2PcInstance p : world._raiders)
  1849. {
  1850. int x = (int) (radius * Math.cos((i * 2 * Math.PI) / members));
  1851. int y = (int) (radius * Math.sin((i++ * 2 * Math.PI) / members));
  1852. p.teleToLocation(new Location(153571 + x, 142075 + y, -12737));
  1853. L2Summon pet = p.getSummon();
  1854. if (pet != null)
  1855. {
  1856. pet.teleToLocation(new Location(153571 + x, 142075 + y, -12737), true);
  1857. pet.broadcastPacket(new ValidateLocation(pet));
  1858. }
  1859. p.setIsParalyzed(true);
  1860. p.broadcastPacket(new ValidateLocation(p));
  1861. }
  1862. startQuestTimer("Baylor", 30000, npc, null);
  1863. }
  1864. else if ((npc.getId() == ORACLE_GUIDE_4) && (world.getStatus() == 31))
  1865. {
  1866. teleportPlayer(player, new Location(153522, 144212, -9747), npc.getInstanceId());
  1867. }
  1868. }
  1869. return "";
  1870. }
  1871. @Override
  1872. public String onTrapAction(L2TrapInstance trap, L2Character trigger, TrapAction action)
  1873. {
  1874. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
  1875. if (tmpworld instanceof CCWorld)
  1876. {
  1877. CCWorld world = (CCWorld) tmpworld;
  1878. switch (action)
  1879. {
  1880. case TRAP_DISARMED:
  1881. if (trap.getId() == DOOR_OPENING_TRAP[0])
  1882. {
  1883. openDoor(24220001, world.getInstanceId());
  1884. runEmeraldRooms(world, ROOM1_SPAWNS, 1);
  1885. }
  1886. break;
  1887. }
  1888. }
  1889. return null;
  1890. }
  1891. @Override
  1892. public String onEnterZone(L2Character character, L2ZoneType zone)
  1893. {
  1894. if (character instanceof L2PcInstance)
  1895. {
  1896. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  1897. if (tmpworld instanceof CCWorld)
  1898. {
  1899. CCWorld world = (CCWorld) tmpworld;
  1900. if (world.getStatus() == 8)
  1901. {
  1902. int room;
  1903. int[][] spawns;
  1904. switch (zone.getId())
  1905. {
  1906. case 20105:
  1907. spawns = ROOM2_SPAWNS;
  1908. room = 2;
  1909. break;
  1910. case 20106:
  1911. spawns = ROOM3_SPAWNS;
  1912. room = 3;
  1913. break;
  1914. case 20107:
  1915. spawns = ROOM4_SPAWNS;
  1916. room = 4;
  1917. break;
  1918. default:
  1919. return super.onEnterZone(character, zone);
  1920. }
  1921. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  1922. {
  1923. if (door.getId() == (room + 24220000))
  1924. {
  1925. if (door.getOpen())
  1926. {
  1927. return "";
  1928. }
  1929. if (!hasQuestItems((L2PcInstance) character, RACE_KEY))
  1930. {
  1931. return "";
  1932. }
  1933. if (world.roomsStatus[zone.getId() - 20104] == 0)
  1934. {
  1935. runEmeraldRooms(world, spawns, room);
  1936. }
  1937. door.openMe();
  1938. takeItems((L2PcInstance) character, RACE_KEY, 1);
  1939. world.openedDoors.put(door, (L2PcInstance) character);
  1940. break;
  1941. }
  1942. }
  1943. }
  1944. }
  1945. }
  1946. return super.onEnterZone(character, zone);
  1947. }
  1948. @Override
  1949. public String onExitZone(L2Character character, L2ZoneType zone)
  1950. {
  1951. if (character instanceof L2PcInstance)
  1952. {
  1953. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  1954. if (tmpworld instanceof CCWorld)
  1955. {
  1956. CCWorld world = (CCWorld) tmpworld;
  1957. if (world.getStatus() == 8)
  1958. {
  1959. int doorId;
  1960. switch (zone.getId())
  1961. {
  1962. case 20105:
  1963. doorId = 24220002;
  1964. break;
  1965. case 20106:
  1966. doorId = 24220003;
  1967. break;
  1968. case 20107:
  1969. doorId = 24220004;
  1970. break;
  1971. default:
  1972. return super.onExitZone(character, zone);
  1973. }
  1974. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  1975. {
  1976. if (door.getId() == doorId)
  1977. {
  1978. if (door.getOpen() && (world.openedDoors.get(door) == character))
  1979. {
  1980. door.closeMe();
  1981. world.openedDoors.remove(door);
  1982. }
  1983. break;
  1984. }
  1985. }
  1986. }
  1987. }
  1988. }
  1989. return super.onExitZone(character, zone);
  1990. }
  1991. }