CrystalCaverns.java 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077
  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 java.util.List;
  21. import java.util.Map;
  22. import javolution.util.FastList;
  23. import javolution.util.FastMap;
  24. import com.l2jserver.Config;
  25. import com.l2jserver.gameserver.GeoData;
  26. import com.l2jserver.gameserver.ai.CtrlIntention;
  27. import com.l2jserver.gameserver.datatables.SkillData;
  28. import com.l2jserver.gameserver.enums.TrapAction;
  29. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  30. import com.l2jserver.gameserver.model.L2Object;
  31. import com.l2jserver.gameserver.model.L2Party;
  32. import com.l2jserver.gameserver.model.L2World;
  33. import com.l2jserver.gameserver.model.Location;
  34. import com.l2jserver.gameserver.model.actor.L2Attackable;
  35. import com.l2jserver.gameserver.model.actor.L2Character;
  36. import com.l2jserver.gameserver.model.actor.L2Npc;
  37. import com.l2jserver.gameserver.model.actor.L2Summon;
  38. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  39. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  40. import com.l2jserver.gameserver.model.actor.instance.L2TrapInstance;
  41. import com.l2jserver.gameserver.model.entity.Instance;
  42. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  43. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  44. import com.l2jserver.gameserver.model.quest.Quest;
  45. import com.l2jserver.gameserver.model.quest.QuestState;
  46. import com.l2jserver.gameserver.model.skills.Skill;
  47. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  48. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  49. import com.l2jserver.gameserver.network.NpcStringId;
  50. import com.l2jserver.gameserver.network.SystemMessageId;
  51. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  52. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  53. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
  54. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
  55. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  56. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  57. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  58. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  59. import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
  60. import com.l2jserver.gameserver.util.Util;
  61. /**
  62. * Crystal Caverns instance zone.<br>
  63. * TODO: 1. Kechi's Henchmans spawn animation is missing.<br>
  64. * 2. NPC related Traps are not supported by core, so Darnels and Lahm door trap is not working.<br>
  65. * 3. Need retail spawn for Coral Garden (EmeraldSteam/Square - done).<br>
  66. * 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>
  67. * Original sources: theone, L2JEmu, L2JOfficial, L2JFree Contributing authors: TGS, Lantoc, Janiii, Gigiikun, RosT Please maintain consistency between the Crystal Caverns scripts.
  68. */
  69. public final class CrystalCaverns extends Quest
  70. {
  71. protected static class CrystalGolem
  72. {
  73. public L2ItemInstance foodItem = null;
  74. public boolean isAtDestination = false;
  75. public Location oldLoc = null;
  76. }
  77. private class CCWorld extends InstanceWorld
  78. {
  79. public Map<L2Npc, Boolean> npcList1 = new FastMap<>();
  80. public L2Npc tears;
  81. public boolean isUsedInvulSkill = false;
  82. public long dragonScaleStart = 0;
  83. public int dragonScaleNeed = 0;
  84. public int cleanedRooms = 0;
  85. public long endTime = 0;
  86. public List<L2Npc> copys = new FastList<>();
  87. public Map<L2Npc, CrystalGolem> crystalGolems = new FastMap<>();
  88. public int correctGolems = 0;
  89. public boolean[] OracleTriggered =
  90. {
  91. false,
  92. false,
  93. false
  94. };
  95. public int kechisHenchmanSpawn = 0;
  96. public int[] roomsStatus =
  97. {
  98. 0,
  99. 0,
  100. 0,
  101. 0
  102. }; // 0: not spawned, 1: spawned, 2: cleared
  103. public Map<L2DoorInstance, L2PcInstance> openedDoors = new FastMap<>();
  104. public Map<Integer, Map<L2Npc, Boolean>> npcList2 = new FastMap<>();
  105. public Map<L2Npc, L2Npc> oracles = new FastMap<>();
  106. public List<L2Npc> keyKeepers = new FastList<>();
  107. public List<L2Npc> guards = new FastList<>();
  108. public List<L2Npc> oracle = new FastList<>();
  109. // baylor variables
  110. protected final List<L2PcInstance> _raiders = new FastList<>();
  111. protected int _raidStatus = 0;
  112. protected long _dragonClawStart = 0;
  113. protected int _dragonClawNeed = 0;
  114. protected final List<L2Npc> _animationMobs = new FastList<>();
  115. protected L2Npc _camera = null;
  116. protected L2Npc _baylor = null;
  117. protected L2Npc _alarm = null;
  118. public CCWorld(Long time)
  119. {
  120. endTime = time;
  121. }
  122. }
  123. private static final int TEMPLATE_ID = 10;
  124. private static final boolean debug = false;
  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. // mobs
  150. private static final int GK1 = 22275;
  151. private static final int GK2 = 22277;
  152. private static final int TOURMALINE = 22292;
  153. private static final int TEROD = 22301;
  154. private static final int DOLPH = 22299;
  155. private static final int WEYLIN = 22298;
  156. private static final int GUARDIAN = 22303;
  157. private static final int GUARDIAN2 = 22304;
  158. private static final int TEARS = 25534;
  159. private static final int TEARS_COPY = 25535;
  160. private static final int KECHI = 25532;
  161. private static final int KECHIGUARD = 25533;
  162. private static final int BAYLOR = 29099;
  163. private static final int DARNEL = 25531;
  164. private final static int ALARMID = 18474;
  165. // private static final int[] BOSSCR = {9695,9696,9697};
  166. private static final int[] CGMOBS =
  167. {
  168. 22311,
  169. 22312,
  170. 22313,
  171. 22314,
  172. 22315,
  173. 22316,
  174. 22317
  175. };
  176. private static final int[] SPAWN =
  177. {
  178. 60000,
  179. 120000,
  180. 90000,
  181. 60000,
  182. 50000,
  183. 40000
  184. }; // Kechi Hencmans spawn times
  185. private static final int[] MOBLIST =
  186. {
  187. 22279,
  188. 22280,
  189. 22281,
  190. 22282,
  191. 22283,
  192. 22285,
  193. 22286,
  194. 22287,
  195. 22288,
  196. 22289,
  197. 22293,
  198. 22294,
  199. 22295,
  200. 22296,
  201. 22297,
  202. 22305,
  203. 22306,
  204. 22307,
  205. 22416,
  206. 22418,
  207. 22419,
  208. 22420
  209. };
  210. // Doors/Walls/Zones
  211. private static final int DOOR1 = 24220021;
  212. private static final int DOOR2 = 24220024;
  213. private static final int DOOR3 = 24220023;
  214. private static final int DOOR4 = 24220061;
  215. private static final int DOOR5 = 24220025;
  216. private static final int DOOR6 = 24220022;
  217. private static final int[] ZONES =
  218. {
  219. 20105,
  220. 20106,
  221. 20107
  222. };
  223. // Baylor alarm spawns
  224. private final static int[][] ALARMSPAWN =
  225. {
  226. {
  227. 153572,
  228. 141277,
  229. -12738
  230. },
  231. {
  232. 153572,
  233. 142852,
  234. -12738
  235. },
  236. {
  237. 154358,
  238. 142075,
  239. -12738
  240. },
  241. {
  242. 152788,
  243. 142075,
  244. -12738
  245. }
  246. };
  247. // Oracle order
  248. private static final int[][] ordreOracle1 =
  249. {
  250. {
  251. 32274,
  252. 147090,
  253. 152505,
  254. -12169,
  255. 31613
  256. },
  257. {
  258. 32275,
  259. 147090,
  260. 152575,
  261. -12169,
  262. 31613
  263. },
  264. {
  265. 32274,
  266. 147090,
  267. 152645,
  268. -12169,
  269. 31613
  270. },
  271. {
  272. 32274,
  273. 147090,
  274. 152715,
  275. -12169,
  276. 31613
  277. }
  278. };
  279. private static final int[][] ordreOracle2 =
  280. {
  281. {
  282. 32274,
  283. 149783,
  284. 152505,
  285. -12169,
  286. 31613
  287. },
  288. // {32274, 149783, 152575, -12169, 31613},
  289. {
  290. 32274,
  291. 149783,
  292. 152645,
  293. -12169,
  294. 31613
  295. },
  296. {
  297. 32276,
  298. 149783,
  299. 152715,
  300. -12169,
  301. 31613
  302. }
  303. };
  304. private static final int[][] ordreOracle3 =
  305. {
  306. {
  307. 32274,
  308. 152461,
  309. 152505,
  310. -12169,
  311. 31613
  312. },
  313. // {32274, 152461, 152575, -12169, 31613},
  314. {
  315. 32277,
  316. 152461,
  317. 152645,
  318. -12169,
  319. 31613
  320. }
  321. // {32274, 152461, 152715, -12169, 31613}
  322. };
  323. // Hall spawns
  324. private static int[][] SPAWNS =
  325. {
  326. {
  327. 141842,
  328. 152556,
  329. -11814,
  330. 50449
  331. },
  332. {
  333. 141503,
  334. 153395,
  335. -11814,
  336. 40738
  337. },
  338. {
  339. 141070,
  340. 153201,
  341. -11814,
  342. 39292
  343. },
  344. {
  345. 141371,
  346. 152986,
  347. -11814,
  348. 35575
  349. },
  350. {
  351. 141602,
  352. 154188,
  353. -11814,
  354. 24575
  355. },
  356. {
  357. 141382,
  358. 154719,
  359. -11814,
  360. 37640
  361. },
  362. {
  363. 141376,
  364. 154359,
  365. -11814,
  366. 12054
  367. },
  368. {
  369. 140895,
  370. 154383,
  371. -11814,
  372. 37508
  373. },
  374. {
  375. 140972,
  376. 154740,
  377. -11814,
  378. 52690
  379. },
  380. {
  381. 141045,
  382. 154504,
  383. -11814,
  384. 50674
  385. },
  386. {
  387. 140757,
  388. 152740,
  389. -11814,
  390. 39463
  391. },
  392. {
  393. 140406,
  394. 152376,
  395. -11814,
  396. 16599
  397. },
  398. {
  399. 140268,
  400. 152007,
  401. -11817,
  402. 45316
  403. },
  404. {
  405. 139996,
  406. 151485,
  407. -11814,
  408. 47403
  409. },
  410. {
  411. 140378,
  412. 151190,
  413. -11814,
  414. 58116
  415. },
  416. {
  417. 140521,
  418. 150711,
  419. -11815,
  420. 55997
  421. },
  422. {
  423. 140816,
  424. 150215,
  425. -11814,
  426. 53682
  427. },
  428. {
  429. 141528,
  430. 149909,
  431. -11814,
  432. 22020
  433. },
  434. {
  435. 141644,
  436. 150360,
  437. -11817,
  438. 13283
  439. },
  440. {
  441. 142048,
  442. 150695,
  443. -11815,
  444. 5929
  445. },
  446. {
  447. 141852,
  448. 151065,
  449. -11817,
  450. 27071
  451. },
  452. {
  453. 142408,
  454. 151211,
  455. -11815,
  456. 2402
  457. },
  458. {
  459. 142481,
  460. 151762,
  461. -11815,
  462. 12876
  463. },
  464. {
  465. 141929,
  466. 152193,
  467. -11815,
  468. 27511
  469. },
  470. {
  471. 142083,
  472. 151791,
  473. -11814,
  474. 47176
  475. },
  476. {
  477. 141435,
  478. 150402,
  479. -11814,
  480. 41798
  481. },
  482. {
  483. 140390,
  484. 151199,
  485. -11814,
  486. 50069
  487. },
  488. {
  489. 140557,
  490. 151849,
  491. -11814,
  492. 45293
  493. },
  494. {
  495. 140964,
  496. 153445,
  497. -11814,
  498. 56672
  499. },
  500. {
  501. 142851,
  502. 154109,
  503. -11814,
  504. 24920
  505. },
  506. {
  507. 142379,
  508. 154725,
  509. -11814,
  510. 30342
  511. },
  512. {
  513. 142816,
  514. 154712,
  515. -11814,
  516. 33193
  517. },
  518. {
  519. 142276,
  520. 154223,
  521. -11814,
  522. 33922
  523. },
  524. {
  525. 142459,
  526. 154490,
  527. -11814,
  528. 33184
  529. },
  530. {
  531. 142819,
  532. 154372,
  533. -11814,
  534. 21318
  535. },
  536. {
  537. 141157,
  538. 154541,
  539. -11814,
  540. 27090
  541. },
  542. {
  543. 141095,
  544. 150281,
  545. -11814,
  546. 55186
  547. }
  548. };
  549. // first spawns
  550. private static int[][] FIRST_SPAWNS =
  551. {
  552. {
  553. 22276,
  554. 148109,
  555. 149601,
  556. -12132,
  557. 34490
  558. },
  559. {
  560. 22276,
  561. 148017,
  562. 149529,
  563. -12132,
  564. 33689
  565. },
  566. {
  567. 22278,
  568. 148065,
  569. 151202,
  570. -12132,
  571. 35323
  572. },
  573. {
  574. 22278,
  575. 147966,
  576. 151117,
  577. -12132,
  578. 33234
  579. },
  580. {
  581. 22279,
  582. 144063,
  583. 150238,
  584. -12132,
  585. 29654
  586. },
  587. {
  588. 22279,
  589. 144300,
  590. 149118,
  591. -12135,
  592. 5520
  593. },
  594. {
  595. 22279,
  596. 144397,
  597. 149337,
  598. -12132,
  599. 644
  600. },
  601. {
  602. 22279,
  603. 144426,
  604. 150639,
  605. -12132,
  606. 50655
  607. },
  608. {
  609. 22282,
  610. 145841,
  611. 151097,
  612. -12132,
  613. 31810
  614. },
  615. {
  616. 22282,
  617. 144387,
  618. 149958,
  619. -12132,
  620. 61173
  621. },
  622. {
  623. 22282,
  624. 145821,
  625. 149498,
  626. -12132,
  627. 31490
  628. },
  629. {
  630. 22282,
  631. 146619,
  632. 149694,
  633. -12132,
  634. 33374
  635. },
  636. {
  637. 22282,
  638. 146669,
  639. 149244,
  640. -12132,
  641. 31360
  642. },
  643. {
  644. 22284,
  645. 144147,
  646. 151375,
  647. -12132,
  648. 58395
  649. },
  650. {
  651. 22284,
  652. 144485,
  653. 151067,
  654. -12132,
  655. 64786
  656. },
  657. {
  658. 22284,
  659. 144356,
  660. 149571,
  661. -12132,
  662. 63516
  663. },
  664. {
  665. 22285,
  666. 144151,
  667. 150962,
  668. -12132,
  669. 664
  670. },
  671. {
  672. 22285,
  673. 146657,
  674. 151365,
  675. -12132,
  676. 33154
  677. },
  678. {
  679. 22285,
  680. 146623,
  681. 150857,
  682. -12132,
  683. 28034
  684. },
  685. {
  686. 22285,
  687. 147046,
  688. 151089,
  689. -12132,
  690. 32941
  691. },
  692. {
  693. 22285,
  694. 145704,
  695. 151255,
  696. -12132,
  697. 32523
  698. },
  699. {
  700. 22285,
  701. 145359,
  702. 151101,
  703. -12132,
  704. 32767
  705. },
  706. {
  707. 22285,
  708. 147785,
  709. 150817,
  710. -12132,
  711. 27423
  712. },
  713. {
  714. 22285,
  715. 147727,
  716. 151375,
  717. -12132,
  718. 37117
  719. },
  720. {
  721. 22285,
  722. 145428,
  723. 149494,
  724. -12132,
  725. 890
  726. },
  727. {
  728. 22285,
  729. 145601,
  730. 149682,
  731. -12132,
  732. 32442
  733. },
  734. {
  735. 22285,
  736. 147003,
  737. 149476,
  738. -12132,
  739. 31554
  740. },
  741. {
  742. 22285,
  743. 147738,
  744. 149210,
  745. -12132,
  746. 20971
  747. },
  748. {
  749. 22285,
  750. 147769,
  751. 149757,
  752. -12132,
  753. 34980
  754. }
  755. };
  756. // Emerald Square
  757. private static int[][] EMERALD_SPAWNS =
  758. {
  759. {
  760. 22280,
  761. 144437,
  762. 143395,
  763. -11969,
  764. 34248
  765. },
  766. {
  767. 22281,
  768. 149241,
  769. 143735,
  770. -12230,
  771. 24575
  772. },
  773. {
  774. 22281,
  775. 147917,
  776. 146861,
  777. -12289,
  778. 60306
  779. },
  780. {
  781. 22281,
  782. 144406,
  783. 147782,
  784. -12133,
  785. 14349
  786. },
  787. {
  788. 22281,
  789. 144960,
  790. 146881,
  791. -12039,
  792. 23881
  793. },
  794. {
  795. 22281,
  796. 144985,
  797. 147679,
  798. -12135,
  799. 27594
  800. },
  801. {
  802. 22283,
  803. 147784,
  804. 143540,
  805. -12222,
  806. 2058
  807. },
  808. {
  809. 22283,
  810. 149091,
  811. 143491,
  812. -12230,
  813. 24836
  814. },
  815. {
  816. 22287,
  817. 144479,
  818. 147569,
  819. -12133,
  820. 20723
  821. },
  822. {
  823. 22287,
  824. 145158,
  825. 146986,
  826. -12058,
  827. 21970
  828. },
  829. {
  830. 22287,
  831. 145142,
  832. 147175,
  833. -12092,
  834. 24420
  835. },
  836. {
  837. 22287,
  838. 145110,
  839. 147133,
  840. -12088,
  841. 22465
  842. },
  843. {
  844. 22287,
  845. 144664,
  846. 146604,
  847. -12028,
  848. 14861
  849. },
  850. {
  851. 22287,
  852. 144596,
  853. 146600,
  854. -12028,
  855. 14461
  856. },
  857. {
  858. 22288,
  859. 143925,
  860. 146773,
  861. -12037,
  862. 10813
  863. },
  864. {
  865. 22288,
  866. 144415,
  867. 147070,
  868. -12069,
  869. 8568
  870. },
  871. {
  872. 22288,
  873. 143794,
  874. 145584,
  875. -12027,
  876. 14849
  877. },
  878. {
  879. 22288,
  880. 143429,
  881. 146166,
  882. -12030,
  883. 4078
  884. },
  885. {
  886. 22288,
  887. 144477,
  888. 147009,
  889. -12056,
  890. 8752
  891. },
  892. {
  893. 22289,
  894. 142577,
  895. 145319,
  896. -12029,
  897. 5403
  898. },
  899. {
  900. 22289,
  901. 143831,
  902. 146902,
  903. -12051,
  904. 9717
  905. },
  906. {
  907. 22289,
  908. 143714,
  909. 146705,
  910. -12028,
  911. 10044
  912. },
  913. {
  914. 22289,
  915. 143937,
  916. 147134,
  917. -12078,
  918. 7517
  919. },
  920. {
  921. 22293,
  922. 143356,
  923. 145287,
  924. -12027,
  925. 8126
  926. },
  927. {
  928. 22293,
  929. 143462,
  930. 144352,
  931. -12008,
  932. 25905
  933. },
  934. {
  935. 22293,
  936. 143745,
  937. 142529,
  938. -11882,
  939. 17102
  940. },
  941. {
  942. 22293,
  943. 144574,
  944. 144032,
  945. -12005,
  946. 34668
  947. },
  948. {
  949. 22295,
  950. 143992,
  951. 142419,
  952. -11884,
  953. 19697
  954. },
  955. {
  956. 22295,
  957. 144671,
  958. 143966,
  959. -12004,
  960. 32088
  961. },
  962. {
  963. 22295,
  964. 144440,
  965. 143269,
  966. -11957,
  967. 34169
  968. },
  969. {
  970. 22295,
  971. 142642,
  972. 146362,
  973. -12028,
  974. 281
  975. },
  976. {
  977. 22295,
  978. 143865,
  979. 142707,
  980. -11881,
  981. 21326
  982. },
  983. {
  984. 22295,
  985. 143573,
  986. 142530,
  987. -11879,
  988. 16141
  989. },
  990. {
  991. 22295,
  992. 143148,
  993. 146039,
  994. -12031,
  995. 65014
  996. },
  997. {
  998. 22295,
  999. 143001,
  1000. 144853,
  1001. -12014,
  1002. 0
  1003. },
  1004. {
  1005. 22296,
  1006. 147505,
  1007. 146580,
  1008. -12260,
  1009. 59041
  1010. },
  1011. {
  1012. 22296,
  1013. 149366,
  1014. 146932,
  1015. -12358,
  1016. 39407
  1017. },
  1018. {
  1019. 22296,
  1020. 149284,
  1021. 147029,
  1022. -12352,
  1023. 41120
  1024. },
  1025. {
  1026. 22296,
  1027. 149439,
  1028. 143940,
  1029. -12230,
  1030. 23189
  1031. },
  1032. {
  1033. 22296,
  1034. 147698,
  1035. 143995,
  1036. -12220,
  1037. 27028
  1038. },
  1039. {
  1040. 22296,
  1041. 141885,
  1042. 144969,
  1043. -12007,
  1044. 2526
  1045. },
  1046. {
  1047. 22296,
  1048. 147843,
  1049. 143763,
  1050. -12220,
  1051. 28386
  1052. },
  1053. {
  1054. 22296,
  1055. 144753,
  1056. 143650,
  1057. -11982,
  1058. 35429
  1059. },
  1060. {
  1061. 22296,
  1062. 147613,
  1063. 146760,
  1064. -12271,
  1065. 56296
  1066. }
  1067. };
  1068. private static int[][] ROOM1_SPAWNS =
  1069. {
  1070. {
  1071. 22288,
  1072. 143114,
  1073. 140027,
  1074. -11888,
  1075. 15025
  1076. },
  1077. {
  1078. 22288,
  1079. 142173,
  1080. 140973,
  1081. -11888,
  1082. 55698
  1083. },
  1084. {
  1085. 22289,
  1086. 143210,
  1087. 140577,
  1088. -11888,
  1089. 17164
  1090. },
  1091. {
  1092. 22289,
  1093. 142638,
  1094. 140107,
  1095. -11888,
  1096. 6571
  1097. },
  1098. {
  1099. 22297,
  1100. 142547,
  1101. 140938,
  1102. -11888,
  1103. 48556
  1104. },
  1105. {
  1106. 22298,
  1107. 142690,
  1108. 140479,
  1109. -11887,
  1110. 7663
  1111. }
  1112. };
  1113. private static int[][] ROOM2_SPAWNS =
  1114. {
  1115. {
  1116. 22303,
  1117. 146276,
  1118. 141483,
  1119. -11880,
  1120. 34643
  1121. },
  1122. {
  1123. 22287,
  1124. 145707,
  1125. 142161,
  1126. -11880,
  1127. 28799
  1128. },
  1129. {
  1130. 22288,
  1131. 146857,
  1132. 142129,
  1133. -11880,
  1134. 33647
  1135. },
  1136. {
  1137. 22288,
  1138. 146869,
  1139. 142000,
  1140. -11880,
  1141. 31215
  1142. },
  1143. {
  1144. 22289,
  1145. 146897,
  1146. 140880,
  1147. -11880,
  1148. 19210
  1149. }
  1150. };
  1151. private static int[][] ROOM3_SPAWNS =
  1152. {
  1153. {
  1154. 22302,
  1155. 145123,
  1156. 143713,
  1157. -12808,
  1158. 65323
  1159. },
  1160. {
  1161. 22294,
  1162. 145188,
  1163. 143331,
  1164. -12808,
  1165. 496
  1166. },
  1167. {
  1168. 22294,
  1169. 145181,
  1170. 144104,
  1171. -12808,
  1172. 64415
  1173. },
  1174. {
  1175. 22293,
  1176. 144994,
  1177. 143431,
  1178. -12808,
  1179. 65431
  1180. },
  1181. {
  1182. 22293,
  1183. 144976,
  1184. 143915,
  1185. -12808,
  1186. 61461
  1187. }
  1188. };
  1189. private static int[][] ROOM4_SPAWNS =
  1190. {
  1191. {
  1192. 22304,
  1193. 150563,
  1194. 142240,
  1195. -12108,
  1196. 16454
  1197. },
  1198. {
  1199. 22294,
  1200. 150769,
  1201. 142495,
  1202. -12108,
  1203. 16870
  1204. },
  1205. {
  1206. 22281,
  1207. 150783,
  1208. 141995,
  1209. -12108,
  1210. 20033
  1211. },
  1212. {
  1213. 22283,
  1214. 150273,
  1215. 141983,
  1216. -12108,
  1217. 16043
  1218. },
  1219. {
  1220. 22294,
  1221. 150276,
  1222. 142492,
  1223. -12108,
  1224. 13540
  1225. }
  1226. };
  1227. // Steam Corridor
  1228. private static int[][] STEAM1_SPAWNS =
  1229. {
  1230. {
  1231. 22305,
  1232. 145260,
  1233. 152387,
  1234. -12165,
  1235. 32767
  1236. },
  1237. {
  1238. 22305,
  1239. 144967,
  1240. 152390,
  1241. -12165,
  1242. 30464
  1243. },
  1244. {
  1245. 22305,
  1246. 145610,
  1247. 152586,
  1248. -12165,
  1249. 17107
  1250. },
  1251. {
  1252. 22305,
  1253. 145620,
  1254. 152397,
  1255. -12165,
  1256. 8191
  1257. },
  1258. {
  1259. 22418,
  1260. 146081,
  1261. 152847,
  1262. -12165,
  1263. 31396
  1264. },
  1265. {
  1266. 22418,
  1267. 146795,
  1268. 152641,
  1269. -12165,
  1270. 33850
  1271. }
  1272. // {22308, 145093, 152502, -12165, 31841},{22308, 146158, 152776, -12165, 30810},
  1273. // {22308, 146116, 152976, -12133, 32571},
  1274. };
  1275. private static int[][] STEAM2_SPAWNS =
  1276. {
  1277. {
  1278. 22306,
  1279. 147740,
  1280. 152767,
  1281. -12165,
  1282. 65043
  1283. },
  1284. {
  1285. 22306,
  1286. 148215,
  1287. 152828,
  1288. -12165,
  1289. 970
  1290. },
  1291. {
  1292. 22306,
  1293. 147743,
  1294. 152846,
  1295. -12165,
  1296. 64147
  1297. },// {22308, 147849, 152854, -12165, 60534},
  1298. // {22308, 147754, 152908, -12141, 59827},{22308, 148194, 152681, -12165, 63620},
  1299. // {22308, 147767, 152939, -12133, 63381},{22309, 147737, 152671, -12165, 65320},
  1300. {
  1301. 22418,
  1302. 148207,
  1303. 152725,
  1304. -12165,
  1305. 61801
  1306. },
  1307. {
  1308. 22419,
  1309. 149058,
  1310. 152828,
  1311. -12165,
  1312. 64564
  1313. }
  1314. };
  1315. private static int[][] STEAM3_SPAWNS =
  1316. {
  1317. {
  1318. 22307,
  1319. 150735,
  1320. 152316,
  1321. -12145,
  1322. 31930
  1323. },
  1324. {
  1325. 22307,
  1326. 150725,
  1327. 152467,
  1328. -12165,
  1329. 33635
  1330. },
  1331. {
  1332. 22307,
  1333. 151058,
  1334. 152316,
  1335. -12146,
  1336. 65342
  1337. },
  1338. {
  1339. 22307,
  1340. 151057,
  1341. 152461,
  1342. -12165,
  1343. 2171
  1344. }
  1345. /*
  1346. * {22308, 150794, 152455, -12165, 31613},{22308, 150665, 152383, -12165, 32767}, {22308, 151697, 152621, -12167, 31423},{22309, 151061, 152581, -12165, 6228}, {22309, 150653, 152253, -12132, 31343},{22309, 150628, 152431, -12165, 33022}, {22309, 151620, 152487, -12165, 30114},{22309, 151672,
  1347. * 152544, -12165, 31846}, {22309, 150488, 152350, -12165, 29072},{22310, 151139, 152238, -12132, 1069}
  1348. */
  1349. };
  1350. private static int[][] STEAM4_SPAWNS =
  1351. {// {22308, 151707, 150199, -12165, 32859},{22308, 152091, 150140, -12165, 32938},
  1352. // {22308, 149757, 150204, -12138, 65331},{22308, 149950, 150307, -12132, 62437},
  1353. // {22308, 149901, 150322, -12132, 62136},{22309, 150071, 150173, -12165, 64943},
  1354. {
  1355. 22416,
  1356. 151636,
  1357. 150280,
  1358. -12142,
  1359. 36869
  1360. },
  1361. {
  1362. 22416,
  1363. 149893,
  1364. 150232,
  1365. -12165,
  1366. 64258
  1367. },
  1368. {
  1369. 22416,
  1370. 149864,
  1371. 150110,
  1372. -12165,
  1373. 65054
  1374. },
  1375. {
  1376. 22416,
  1377. 151926,
  1378. 150218,
  1379. -12165,
  1380. 31613
  1381. },
  1382. {
  1383. 22420,
  1384. 149986,
  1385. 150051,
  1386. -12165,
  1387. 105
  1388. },
  1389. {
  1390. 22420,
  1391. 151970,
  1392. 149997,
  1393. -12165,
  1394. 32170
  1395. },
  1396. {
  1397. 22420,
  1398. 150744,
  1399. 150006,
  1400. -12165,
  1401. 63
  1402. }
  1403. // ,{22417, 149782, 150188, -12151, 64001}
  1404. };
  1405. // Instance reenter time
  1406. // default: 86400000ms(24h)
  1407. private static final int INSTANCEPENALTY = 86400000;
  1408. private static final int DRAGONSCALETIME = 3000;
  1409. private static final int DRAGONCLAWTIME = 3000;
  1410. private CrystalCaverns()
  1411. {
  1412. super(-1, CrystalCaverns.class.getSimpleName(), "instances");
  1413. addStartNpc(ORACLE_GUIDE_1);
  1414. addTalkId(ORACLE_GUIDE_1);
  1415. addTalkId(ORACLE_GUIDE_3);
  1416. addStartNpc(ORACLE_GUIDE_4);
  1417. addFirstTalkId(ORACLE_GUIDE_4);
  1418. addTalkId(ORACLE_GUIDE_4);
  1419. addFirstTalkId(CRYSTAL_GOLEM);
  1420. addAttackId(TEARS);
  1421. addTrapActionId(DOOR_OPENING_TRAP[0]);
  1422. addKillId(TEARS);
  1423. addKillId(GK1);
  1424. addKillId(GK2);
  1425. addKillId(TEROD);
  1426. addKillId(WEYLIN);
  1427. addKillId(DOLPH);
  1428. addKillId(DARNEL);
  1429. addKillId(KECHI);
  1430. addKillId(GUARDIAN);
  1431. addKillId(GUARDIAN2);
  1432. addKillId(TOURMALINE);
  1433. addKillId(BAYLOR);
  1434. addSpellFinishedId(BAYLOR);
  1435. addKillId(ALARMID);
  1436. addFirstTalkId(32274, 32275, 32276, 32277, ORACLE_GUIDE_1, ORACLE_GUIDE_2);
  1437. addTalkId(32275, 32276, 32277);
  1438. addSkillSeeId(25534, 32275, 32276, 32277, BAYLOR);
  1439. addKillId(MOBLIST);
  1440. addKillId(CGMOBS);
  1441. for (int zones : ZONES)
  1442. {
  1443. addEnterZoneId(zones);
  1444. addExitZoneId(zones);
  1445. }
  1446. }
  1447. private boolean checkConditions(L2PcInstance player)
  1448. {
  1449. if (debug)
  1450. {
  1451. return true;
  1452. }
  1453. L2Party party = player.getParty();
  1454. if (party == null)
  1455. {
  1456. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  1457. return false;
  1458. }
  1459. if (party.getLeader() != player)
  1460. {
  1461. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  1462. return false;
  1463. }
  1464. for (L2PcInstance partyMember : party.getMembers())
  1465. {
  1466. if (partyMember.getLevel() < 78)
  1467. {
  1468. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  1469. sm.addPcName(partyMember);
  1470. party.broadcastPacket(sm);
  1471. return false;
  1472. }
  1473. L2ItemInstance item = partyMember.getInventory().getItemByItemId(CONT_CRYSTAL);
  1474. if (item == null)
  1475. {
  1476. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  1477. sm.addPcName(partyMember);
  1478. party.broadcastPacket(sm);
  1479. return false;
  1480. }
  1481. if (!Util.checkIfInRange(1000, player, partyMember, true))
  1482. {
  1483. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  1484. sm.addPcName(partyMember);
  1485. party.broadcastPacket(sm);
  1486. return false;
  1487. }
  1488. Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
  1489. if (System.currentTimeMillis() < reentertime)
  1490. {
  1491. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET);
  1492. sm.addPcName(partyMember);
  1493. party.broadcastPacket(sm);
  1494. return false;
  1495. }
  1496. }
  1497. return true;
  1498. }
  1499. private boolean checkOracleConditions(L2PcInstance player)
  1500. {
  1501. if (debug)
  1502. {
  1503. return true;
  1504. }
  1505. L2Party party = player.getParty();
  1506. if (party == null)
  1507. {
  1508. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  1509. return false;
  1510. }
  1511. if (party.getLeader() != player)
  1512. {
  1513. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  1514. return false;
  1515. }
  1516. for (L2PcInstance partyMember : party.getMembers())
  1517. {
  1518. L2ItemInstance item = partyMember.getInventory().getItemByItemId(RED_CORAL);
  1519. if (item == null)
  1520. {
  1521. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  1522. sm.addPcName(partyMember);
  1523. party.broadcastPacket(sm);
  1524. return false;
  1525. }
  1526. if (!Util.checkIfInRange(1000, player, partyMember, true))
  1527. {
  1528. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  1529. sm.addPcName(partyMember);
  1530. party.broadcastPacket(sm);
  1531. return false;
  1532. }
  1533. }
  1534. return true;
  1535. }
  1536. private boolean checkBaylorConditions(L2PcInstance player)
  1537. {
  1538. L2Party party = player.getParty();
  1539. if (party == null)
  1540. {
  1541. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  1542. return false;
  1543. }
  1544. if (party.getLeader() != player)
  1545. {
  1546. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  1547. return false;
  1548. }
  1549. for (L2PcInstance partyMember : party.getMembers())
  1550. {
  1551. L2ItemInstance item1 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_1);
  1552. L2ItemInstance item2 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_2);
  1553. L2ItemInstance item3 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_3);
  1554. if ((item1 == null) || (item2 == null) || (item3 == null))
  1555. {
  1556. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  1557. sm.addPcName(partyMember);
  1558. party.broadcastPacket(sm);
  1559. return false;
  1560. }
  1561. if (!Util.checkIfInRange(1000, player, partyMember, true))
  1562. {
  1563. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  1564. sm.addPcName(partyMember);
  1565. party.broadcastPacket(sm);
  1566. return false;
  1567. }
  1568. }
  1569. return true;
  1570. }
  1571. // this should be handled from skill effect
  1572. private void Throw(L2Character effector, L2Character effected)
  1573. {
  1574. // Get current position of the L2Character
  1575. final int curX = effected.getX();
  1576. final int curY = effected.getY();
  1577. final int curZ = effected.getZ();
  1578. // Calculate distance between effector and effected current position
  1579. double dx = effector.getX() - curX;
  1580. double dy = effector.getY() - curY;
  1581. double dz = effector.getZ() - curZ;
  1582. double distance = Math.sqrt((dx * dx) + (dy * dy));
  1583. int offset = Math.min((int) distance + 300, 1400);
  1584. double cos;
  1585. double sin;
  1586. // approximation for moving futher when z coordinates are different
  1587. // TODO: handle Z axis movement better
  1588. offset += Math.abs(dz);
  1589. if (offset < 5)
  1590. {
  1591. offset = 5;
  1592. }
  1593. if (distance < 1)
  1594. {
  1595. return;
  1596. }
  1597. // Calculate movement angles needed
  1598. sin = dy / distance;
  1599. cos = dx / distance;
  1600. // Calculate the new destination with offset included
  1601. int _x = effector.getX() - (int) (offset * cos);
  1602. int _y = effector.getY() - (int) (offset * sin);
  1603. int _z = effected.getZ();
  1604. Location destination = GeoData.getInstance().moveCheck(effected.getX(), effected.getY(), effected.getZ(), _x, _y, _z, effected.getInstanceId());
  1605. effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP));
  1606. // maybe is need force set X,Y,Z
  1607. effected.setXYZ(destination);
  1608. effected.broadcastPacket(new ValidateLocation(effected));
  1609. }
  1610. protected int enterInstance(L2PcInstance player, String template, Location loc)
  1611. {
  1612. // check for existing instances for this player
  1613. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  1614. // existing instance
  1615. if (world != null)
  1616. {
  1617. if (!(world instanceof CCWorld))
  1618. {
  1619. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  1620. return 0;
  1621. }
  1622. teleportPlayer(player, loc, world.getInstanceId());
  1623. return world.getInstanceId();
  1624. }
  1625. // New instance
  1626. if (!checkConditions(player))
  1627. {
  1628. return 0;
  1629. }
  1630. L2Party party = player.getParty();
  1631. int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  1632. world = new CCWorld(System.currentTimeMillis() + 5400000);
  1633. world.setInstanceId(instanceId);
  1634. world.setTemplateId(TEMPLATE_ID);
  1635. InstanceManager.getInstance().addWorld(world);
  1636. _log.info("Crystal Caverns started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  1637. runOracle((CCWorld) world);
  1638. // teleport players
  1639. if (player.getParty() == null)
  1640. {
  1641. // this can happen only if debug is true
  1642. player.sendMessage("Welcome to Crystal Caverns.");
  1643. InstanceManager.getInstance().setInstanceTime(player.getObjectId(), TEMPLATE_ID, ((System.currentTimeMillis() + INSTANCEPENALTY)));
  1644. teleportPlayer(player, loc, world.getInstanceId());
  1645. world.isAllowed(player.getObjectId());
  1646. }
  1647. else
  1648. {
  1649. for (L2PcInstance partyMember : party.getMembers())
  1650. {
  1651. partyMember.sendMessage("Welcome to Crystal Caverns.");
  1652. InstanceManager.getInstance().setInstanceTime(partyMember.getObjectId(), TEMPLATE_ID, ((System.currentTimeMillis() + INSTANCEPENALTY)));
  1653. teleportPlayer(partyMember, loc, world.getInstanceId());
  1654. world.addAllowed(partyMember.getObjectId());
  1655. }
  1656. }
  1657. return instanceId;
  1658. }
  1659. protected void stopAttack(L2PcInstance player)
  1660. {
  1661. player.setTarget(null);
  1662. player.abortAttack();
  1663. player.abortCast();
  1664. player.breakAttack();
  1665. player.breakCast();
  1666. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1667. L2Summon pet = player.getSummon();
  1668. if (pet != null)
  1669. {
  1670. pet.setTarget(null);
  1671. pet.abortAttack();
  1672. pet.abortCast();
  1673. pet.breakAttack();
  1674. pet.breakCast();
  1675. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1676. }
  1677. }
  1678. protected void runOracle(CCWorld world)
  1679. {
  1680. world.setStatus(0);
  1681. world.oracle.add(addSpawn(ORACLE_GUIDE_1, 143172, 148894, -11975, 0, false, 0, false, world.getInstanceId()));
  1682. }
  1683. protected void runEmerald(CCWorld world)
  1684. {
  1685. world.setStatus(1);
  1686. runFirst(world);
  1687. openDoor(DOOR1, world.getInstanceId());
  1688. }
  1689. protected void runCoral(CCWorld world)
  1690. {
  1691. world.setStatus(1);
  1692. runHall(world);
  1693. openDoor(DOOR2, world.getInstanceId());
  1694. openDoor(DOOR5, world.getInstanceId());
  1695. }
  1696. protected void runHall(CCWorld world)
  1697. {
  1698. world.setStatus(2);
  1699. for (int[] spawn : SPAWNS)
  1700. {
  1701. L2Npc mob = addSpawn(CGMOBS[getRandom(CGMOBS.length)], spawn[0], spawn[1], spawn[2], spawn[3], false, 0, false, world.getInstanceId());
  1702. world.npcList1.put(mob, false);
  1703. }
  1704. }
  1705. protected void runFirst(CCWorld world)
  1706. {
  1707. world.setStatus(2);
  1708. world.keyKeepers.add(addSpawn(GK1, 148206, 149486, -12140, 32308, false, 0, false, world.getInstanceId()));
  1709. world.keyKeepers.add(addSpawn(GK2, 148203, 151093, -12140, 31100, false, 0, false, world.getInstanceId()));
  1710. for (int[] spawn : FIRST_SPAWNS)
  1711. {
  1712. addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  1713. }
  1714. }
  1715. protected void runEmeraldSquare(CCWorld world)
  1716. {
  1717. world.setStatus(3);
  1718. Map<L2Npc, Boolean> spawnList = new FastMap<>();
  1719. for (int[] spawn : EMERALD_SPAWNS)
  1720. {
  1721. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  1722. spawnList.put(mob, false);
  1723. }
  1724. world.npcList2.put(0, spawnList);
  1725. }
  1726. protected void runEmeraldRooms(CCWorld world, int[][] spawnList, int room)
  1727. {
  1728. Map<L2Npc, Boolean> spawned = new FastMap<>();
  1729. for (int[] spawn : spawnList)
  1730. {
  1731. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  1732. spawned.put(mob, false);
  1733. }
  1734. if (room == 1)
  1735. {
  1736. addSpawn(32359, 142110, 139896, -11888, 8033, false, 0, false, world.getInstanceId());
  1737. }
  1738. world.npcList2.put(room, spawned);
  1739. world.roomsStatus[room - 1] = 1;
  1740. }
  1741. protected void runDarnel(CCWorld world)
  1742. {
  1743. world.setStatus(9);
  1744. addSpawn(DARNEL, 152759, 145949, -12588, 21592, false, 0, false, world.getInstanceId());
  1745. // TODO: missing traps
  1746. openDoor(24220005, world.getInstanceId());
  1747. openDoor(24220006, world.getInstanceId());
  1748. }
  1749. protected void runSteamRooms(CCWorld world, int[][] spawnList, int status)
  1750. {
  1751. world.setStatus(status);
  1752. Map<L2Npc, Boolean> spawned = new FastMap<>();
  1753. for (int[] spawn : spawnList)
  1754. {
  1755. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  1756. spawned.put(mob, false);
  1757. }
  1758. world.npcList2.put(0, spawned);
  1759. }
  1760. protected void runSteamOracles(CCWorld world, int[][] oracleOrder)
  1761. {
  1762. world.oracles.clear();
  1763. for (int[] oracle : oracleOrder)
  1764. {
  1765. world.oracles.put(addSpawn(oracle[0], oracle[1], oracle[2], oracle[3], oracle[4], false, 0, false, world.getInstanceId()), null);
  1766. }
  1767. }
  1768. protected boolean checkKillProgress(int room, L2Npc mob, CCWorld world)
  1769. {
  1770. if (world.npcList2.get(room).containsKey(mob))
  1771. {
  1772. world.npcList2.get(room).put(mob, true);
  1773. }
  1774. for (boolean isDead : world.npcList2.get(room).values())
  1775. {
  1776. if (!isDead)
  1777. {
  1778. return false;
  1779. }
  1780. }
  1781. return true;
  1782. }
  1783. /*
  1784. * 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
  1785. * 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
  1786. * 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
  1787. * 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); }
  1788. */
  1789. @Override
  1790. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  1791. {
  1792. if (npc.getId() == ORACLE_GUIDE_1)
  1793. {
  1794. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1795. if (tmpworld instanceof CCWorld)
  1796. {
  1797. CCWorld world = (CCWorld) tmpworld;
  1798. if ((world.getStatus() == 0) && world.oracle.contains(npc))
  1799. {
  1800. String htmltext = "32281.htm";
  1801. return htmltext;
  1802. }
  1803. }
  1804. npc.showChatWindow(player);
  1805. return null;
  1806. }
  1807. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277))
  1808. {
  1809. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1810. if (tmpworld instanceof CCWorld)
  1811. {
  1812. CCWorld world = (CCWorld) tmpworld;
  1813. if (!world.OracleTriggered[npc.getId() - 32275])
  1814. {
  1815. String htmltext = "no.htm";
  1816. return htmltext;
  1817. }
  1818. npc.showChatWindow(player);
  1819. return null;
  1820. }
  1821. }
  1822. else if (npc.getId() == 32274)
  1823. {
  1824. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1825. if (tmpworld instanceof CCWorld)
  1826. {
  1827. String htmltext = "no.htm";
  1828. return htmltext;
  1829. }
  1830. }
  1831. else if (npc.getId() == 32279)
  1832. {
  1833. QuestState st = player.getQuestState("131_BirdInACage");
  1834. String htmltext = "32279.htm";
  1835. if ((st != null) && !st.isCompleted())
  1836. {
  1837. htmltext = "32279-01.htm";
  1838. }
  1839. return htmltext;
  1840. }
  1841. else if (npc.getId() == CRYSTAL_GOLEM)
  1842. {
  1843. player.sendPacket(ActionFailed.STATIC_PACKET);
  1844. }
  1845. return "";
  1846. }
  1847. @Override
  1848. public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  1849. {
  1850. boolean doReturn = true;
  1851. for (L2Object obj : targets)
  1852. {
  1853. if (obj == npc)
  1854. {
  1855. doReturn = false;
  1856. }
  1857. }
  1858. if (doReturn)
  1859. {
  1860. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  1861. }
  1862. switch (skill.getId())
  1863. {
  1864. case 1011:
  1865. case 1015:
  1866. case 1217:
  1867. case 1218:
  1868. case 1401:
  1869. case 2360:
  1870. case 2369:
  1871. case 5146:
  1872. doReturn = false;
  1873. break;
  1874. default:
  1875. doReturn = true;
  1876. }
  1877. if (doReturn)
  1878. {
  1879. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  1880. }
  1881. if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && (skill.getId() != 2360) && (skill.getId() != 2369))
  1882. {
  1883. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1884. if ((tmpworld instanceof CCWorld) && (getRandom(100) < 15))
  1885. {
  1886. for (L2Npc oracle : ((CCWorld) tmpworld).oracles.keySet())
  1887. {
  1888. if (oracle != npc)
  1889. {
  1890. oracle.decayMe();
  1891. }
  1892. }
  1893. ((CCWorld) tmpworld).OracleTriggered[npc.getId() - 32275] = true;
  1894. }
  1895. }
  1896. else if (npc.isInvul() && (npc.getId() == BAYLOR) && (skill.getId() == 2360) && (caster != null))
  1897. {
  1898. if (caster.getParty() == null)
  1899. {
  1900. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  1901. }
  1902. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1903. if (tmpworld instanceof CCWorld)
  1904. {
  1905. CCWorld world = (CCWorld) tmpworld;
  1906. if (((world._dragonClawStart + DRAGONCLAWTIME) <= System.currentTimeMillis()) || (world._dragonClawNeed <= 0))
  1907. {
  1908. world._dragonClawStart = System.currentTimeMillis();
  1909. world._dragonClawNeed = caster.getParty().getMemberCount() - 1;
  1910. }
  1911. else
  1912. {
  1913. world._dragonClawNeed--;
  1914. }
  1915. if (world._dragonClawNeed == 0)
  1916. {
  1917. npc.stopSkillEffects(false, 5225);
  1918. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5480, 1, 4000, 0));
  1919. if (world._raidStatus == 3)
  1920. {
  1921. world._raidStatus++;
  1922. }
  1923. }
  1924. }
  1925. }
  1926. else if (npc.isInvul() && (npc.getId() == TEARS) && (skill.getId() == 2369) && (caster != null))
  1927. {
  1928. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1929. if (tmpworld instanceof CCWorld)
  1930. {
  1931. CCWorld world = (CCWorld) tmpworld;
  1932. if (caster.getParty() == null)
  1933. {
  1934. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  1935. }
  1936. else if (((world.dragonScaleStart + DRAGONSCALETIME) <= System.currentTimeMillis()) || (world.dragonScaleNeed <= 0))
  1937. {
  1938. world.dragonScaleStart = System.currentTimeMillis();
  1939. world.dragonScaleNeed = caster.getParty().getMemberCount() - 1;
  1940. }
  1941. else
  1942. {
  1943. world.dragonScaleNeed--;
  1944. }
  1945. if ((world.dragonScaleNeed == 0) && (getRandom(100) < 80))
  1946. {
  1947. npc.setIsInvul(false);
  1948. }
  1949. }
  1950. }
  1951. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  1952. }
  1953. @Override
  1954. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  1955. {
  1956. if (npc.getId() == TEARS)
  1957. {
  1958. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1959. if (tmpworld instanceof CCWorld)
  1960. {
  1961. CCWorld world = (CCWorld) tmpworld;
  1962. if ((world.getStatus() != 4) && (attacker != null))
  1963. {
  1964. // Lucky cheater, the code only kicks his/her ass out of the dungeon
  1965. teleportPlayer(attacker, new Location(149361, 172327, -945), 0);
  1966. world.removeAllowed(attacker.getObjectId());
  1967. }
  1968. else if (world.tears != npc)
  1969. {
  1970. return "";
  1971. }
  1972. else if (!world.copys.isEmpty())
  1973. {
  1974. boolean notAOE = true;
  1975. 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)))
  1976. {
  1977. notAOE = false;
  1978. }
  1979. if (notAOE)
  1980. {
  1981. for (L2Npc copy : world.copys)
  1982. {
  1983. copy.onDecay();
  1984. }
  1985. world.copys.clear();
  1986. }
  1987. return "";
  1988. }
  1989. int maxHp = npc.getMaxHp();
  1990. double nowHp = npc.getStatus().getCurrentHp();
  1991. int rand = getRandom(1000);
  1992. if ((nowHp < (maxHp * 0.4)) && (rand < 5))
  1993. {
  1994. L2Party party = attacker.getParty();
  1995. if (party != null)
  1996. {
  1997. for (L2PcInstance partyMember : party.getMembers())
  1998. {
  1999. stopAttack(partyMember);
  2000. }
  2001. }
  2002. else
  2003. {
  2004. stopAttack(attacker);
  2005. }
  2006. L2Character target = npc.getAI().getAttackTarget();
  2007. for (int i = 0; i < 10; i++)
  2008. {
  2009. L2Npc copy = addSpawn(TEARS_COPY, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false, attacker.getInstanceId());
  2010. copy.setRunning();
  2011. ((L2Attackable) copy).addDamageHate(target, 0, 99999);
  2012. copy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  2013. copy.setCurrentHp(nowHp);
  2014. world.copys.add(copy);
  2015. }
  2016. }
  2017. else if ((nowHp < (maxHp * 0.15)) && !world.isUsedInvulSkill)
  2018. {
  2019. if ((rand > 994) || (nowHp < (maxHp * 0.1)))
  2020. {
  2021. world.isUsedInvulSkill = true;
  2022. npc.setIsInvul(true);
  2023. }
  2024. }
  2025. }
  2026. }
  2027. return null;
  2028. }
  2029. @Override
  2030. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  2031. {
  2032. if ((npc.getId() == BAYLOR) && (skill.getId() == 5225))
  2033. {
  2034. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  2035. if (tmpworld instanceof CCWorld)
  2036. {
  2037. ((CCWorld) tmpworld)._raidStatus++;
  2038. }
  2039. }
  2040. return super.onSpellFinished(npc, player, skill);
  2041. }
  2042. @Override
  2043. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  2044. {
  2045. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  2046. if (tmpworld instanceof CCWorld)
  2047. {
  2048. CCWorld world = (CCWorld) tmpworld;
  2049. if (event.equalsIgnoreCase("TeleportOut"))
  2050. {
  2051. teleportPlayer(player, new Location(149413, 173078, -5014), 0);
  2052. }
  2053. else if (event.equalsIgnoreCase("TeleportParme"))
  2054. {
  2055. teleportPlayer(player, new Location(153689, 142226, -9750), world.getInstanceId());
  2056. }
  2057. else if (event.equalsIgnoreCase("Timer2") || event.equalsIgnoreCase("Timer3") || event.equalsIgnoreCase("Timer4") || event.equalsIgnoreCase("Timer5"))
  2058. {
  2059. if (player.getInstanceId() == world.getInstanceId())
  2060. {
  2061. teleportPlayer(player, new Location(144653, 152606, -12126), world.getInstanceId());
  2062. player.stopSkillEffects(true, 5239);
  2063. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  2064. startQuestTimer("Timer2", 300000, npc, player);
  2065. }
  2066. }
  2067. else if (event.equalsIgnoreCase("Timer21") || event.equalsIgnoreCase("Timer31") || event.equalsIgnoreCase("Timer41") || event.equalsIgnoreCase("Timer51"))
  2068. {
  2069. InstanceManager.getInstance().getInstance(world.getInstanceId()).removeNpcs();
  2070. world.npcList2.clear();
  2071. runSteamRooms(world, STEAM1_SPAWNS, 22);
  2072. startQuestTimer("Timer21", 300000, npc, null);
  2073. }
  2074. else if (event.equalsIgnoreCase("checkKechiAttack"))
  2075. {
  2076. if (npc.isInCombat())
  2077. {
  2078. startQuestTimer("spawnGuards", SPAWN[0], npc, null);
  2079. cancelQuestTimers("checkKechiAttack");
  2080. closeDoor(DOOR4, npc.getInstanceId());
  2081. closeDoor(DOOR3, npc.getInstanceId());
  2082. }
  2083. else
  2084. {
  2085. startQuestTimer("checkKechiAttack", 1000, npc, null);
  2086. }
  2087. }
  2088. else if (event.equalsIgnoreCase("spawnGuards"))
  2089. {
  2090. world.kechisHenchmanSpawn++;
  2091. world.guards.add(addSpawn(KECHIGUARD, 153622, 149699, -12131, 56890, false, 0, false, world.getInstanceId()));
  2092. world.guards.add(addSpawn(KECHIGUARD, 153609, 149622, -12131, 64023, false, 0, false, world.getInstanceId()));
  2093. world.guards.add(addSpawn(KECHIGUARD, 153606, 149428, -12131, 64541, false, 0, false, world.getInstanceId()));
  2094. world.guards.add(addSpawn(KECHIGUARD, 153601, 149534, -12131, 64901, false, 0, false, world.getInstanceId()));
  2095. world.guards.add(addSpawn(KECHIGUARD, 153620, 149354, -12131, 1164, false, 0, false, world.getInstanceId()));
  2096. world.guards.add(addSpawn(KECHIGUARD, 153637, 149776, -12131, 61733, false, 0, false, world.getInstanceId()));
  2097. world.guards.add(addSpawn(KECHIGUARD, 153638, 149292, -12131, 64071, false, 0, false, world.getInstanceId()));
  2098. world.guards.add(addSpawn(KECHIGUARD, 153647, 149857, -12131, 59402, false, 0, false, world.getInstanceId()));
  2099. world.guards.add(addSpawn(KECHIGUARD, 153661, 149227, -12131, 65275, false, 0, false, world.getInstanceId()));
  2100. if (world.kechisHenchmanSpawn <= 5)
  2101. {
  2102. startQuestTimer("spawnGuards", SPAWN[world.kechisHenchmanSpawn], npc, null);
  2103. }
  2104. else
  2105. {
  2106. cancelQuestTimers("spawnGuards");
  2107. }
  2108. }
  2109. else if (event.equalsIgnoreCase("EmeraldSteam"))
  2110. {
  2111. runEmerald(world);
  2112. for (L2Npc oracle : world.oracle)
  2113. {
  2114. oracle.decayMe();
  2115. }
  2116. }
  2117. else if (event.equalsIgnoreCase("CoralGarden"))
  2118. {
  2119. runCoral(world);
  2120. for (L2Npc oracle : world.oracle)
  2121. {
  2122. oracle.decayMe();
  2123. }
  2124. }
  2125. else if (event.equalsIgnoreCase("spawn_oracle"))
  2126. {
  2127. addSpawn(32271, 153572, 142075, -9728, 10800, false, 0, false, world.getInstanceId());
  2128. addSpawn((getRandom(10) < 5 ? 29116 : 29117), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, world.getInstanceId()); // Baylor's Chest
  2129. addSpawn(ORACLE_GUIDE_4, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  2130. cancelQuestTimer("baylor_despawn", npc, null);
  2131. cancelQuestTimers("baylor_skill");
  2132. }
  2133. else if (event.equalsIgnoreCase("baylorEffect0"))
  2134. {
  2135. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  2136. npc.broadcastSocialAction(1);
  2137. startQuestTimer("baylorCamera0", 11000, npc, null);
  2138. startQuestTimer("baylorEffect1", 19000, npc, null);
  2139. }
  2140. else if (event.equalsIgnoreCase("baylorCamera0"))
  2141. {
  2142. npc.broadcastPacket(new SpecialCamera(npc, 500, -45, 170, 5000, 9000, 0, 0, 1, 0, 0));
  2143. }
  2144. else if (event.equalsIgnoreCase("baylorEffect1"))
  2145. {
  2146. npc.broadcastPacket(new SpecialCamera(npc, 300, 0, 120, 2000, 5000, 0, 0, 1, 0, 0));
  2147. npc.broadcastSocialAction(3);
  2148. startQuestTimer("baylorEffect2", 4000, npc, null);
  2149. }
  2150. else if (event.equalsIgnoreCase("baylorEffect2"))
  2151. {
  2152. npc.broadcastPacket(new SpecialCamera(npc, 747, 0, 160, 2000, 3000, 0, 0, 1, 0, 0));
  2153. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5402, 1, 2000, 0));
  2154. startQuestTimer("RaidStart", 2000, npc, null);
  2155. }
  2156. else if (event.equalsIgnoreCase("BaylorMinions"))
  2157. {
  2158. for (int i = 0; i < 10; i++)
  2159. {
  2160. int radius = 300;
  2161. int x = (int) (radius * Math.cos(i * 0.618));
  2162. int y = (int) (radius * Math.sin(i * 0.618));
  2163. L2Npc mob = addSpawn(29104, 153571 + x, 142075 + y, -12737, 0, false, 0, false, world.getInstanceId());
  2164. mob.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  2165. world._animationMobs.add(mob);
  2166. }
  2167. startQuestTimer("baylorEffect0", 200, npc, null);
  2168. }
  2169. else if (event.equalsIgnoreCase("RaidStart"))
  2170. {
  2171. world._camera.decayMe();
  2172. world._camera = null;
  2173. npc.setIsParalyzed(false);
  2174. for (L2PcInstance p : world._raiders)
  2175. {
  2176. p.setIsParalyzed(false);
  2177. Throw(npc, p);
  2178. if (p.getSummon() != null)
  2179. {
  2180. Throw(npc, p.getSummon());
  2181. }
  2182. }
  2183. world._raidStatus = 0;
  2184. for (L2Npc mob : world._animationMobs)
  2185. {
  2186. mob.doDie(mob);
  2187. }
  2188. world._animationMobs.clear();
  2189. startQuestTimer("baylor_despawn", 60000, npc, null, true);
  2190. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  2191. }
  2192. else if (event.equalsIgnoreCase("checkBaylorAttack"))
  2193. {
  2194. if (npc.isInCombat())
  2195. {
  2196. cancelQuestTimers("checkBaylorAttack");
  2197. startQuestTimer("baylor_alarm", 40000, npc, null);
  2198. startQuestTimer("baylor_skill", 5000, npc, null, true);
  2199. world._raidStatus++;
  2200. }
  2201. else
  2202. {
  2203. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  2204. }
  2205. }
  2206. else if (event.equalsIgnoreCase("baylor_alarm"))
  2207. {
  2208. if (world._alarm == null)
  2209. {
  2210. int[] spawnLoc = ALARMSPAWN[getRandom(ALARMSPAWN.length)];
  2211. npc.addSkill(SkillData.getInstance().getSkill(5244, 1));
  2212. npc.addSkill(SkillData.getInstance().getSkill(5245, 1));
  2213. world._alarm = addSpawn(ALARMID, spawnLoc[0], spawnLoc[1], spawnLoc[2], 10800, false, 0, false, world.getInstanceId());
  2214. world._alarm.disableCoreAI(true);
  2215. world._alarm.setIsImmobilized(true);
  2216. 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));
  2217. }
  2218. }
  2219. else if (event.equalsIgnoreCase("baylor_skill"))
  2220. {
  2221. if (world._baylor == null)
  2222. {
  2223. cancelQuestTimers("baylor_skill");
  2224. }
  2225. else
  2226. {
  2227. int maxHp = npc.getMaxHp();
  2228. double nowHp = npc.getStatus().getCurrentHp();
  2229. int rand = getRandom(100);
  2230. if ((nowHp < (maxHp * 0.2)) && (world._raidStatus < 3) && !npc.isAffectedBySkill(5224) && !npc.isAffectedBySkill(5225))
  2231. {
  2232. if ((nowHp < (maxHp * 0.15)) && (world._raidStatus == 2))
  2233. {
  2234. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  2235. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  2236. }
  2237. else if ((rand < 10) || (nowHp < (maxHp * 0.15)))
  2238. {
  2239. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  2240. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  2241. startQuestTimer("baylor_remove_invul", 30000, world._baylor, null);
  2242. }
  2243. }
  2244. else if ((nowHp < (maxHp * 0.3)) && (rand > 50) && !npc.isAffectedBySkill(5225) && !npc.isAffectedBySkill(5224))
  2245. {
  2246. npc.doCast(SkillData.getInstance().getSkill(5224, 1));
  2247. }
  2248. else if (rand < 33)
  2249. {
  2250. npc.setTarget(world._raiders.get(getRandom(world._raiders.size())));
  2251. npc.doCast(SkillData.getInstance().getSkill(5229, 1));
  2252. }
  2253. }
  2254. }
  2255. else if (event.equalsIgnoreCase("baylor_remove_invul"))
  2256. {
  2257. npc.stopSkillEffects(false, 5225);
  2258. }
  2259. else if (event.equalsIgnoreCase("Baylor"))
  2260. {
  2261. world._baylor = addSpawn(29099, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  2262. world._baylor.setIsParalyzed(true);
  2263. world._camera = addSpawn(29120, 153273, 141400, -12738, 10800, false, 0, false, world.getInstanceId());
  2264. world._camera.broadcastPacket(new SpecialCamera(world._camera, 700, -45, 160, 500, 15200, 0, 0, 1, 0, 0));
  2265. startQuestTimer("baylorMinions", 2000, world._baylor, null);
  2266. }
  2267. else if (!event.endsWith("Food"))
  2268. {
  2269. return "";
  2270. }
  2271. else if (event.equalsIgnoreCase("autoFood"))
  2272. {
  2273. if (!world.crystalGolems.containsKey(npc))
  2274. {
  2275. world.crystalGolems.put(npc, new CrystalGolem());
  2276. }
  2277. if ((world.getStatus() != 3) || !world.crystalGolems.containsKey(npc) || (world.crystalGolems.get(npc).foodItem != null) || world.crystalGolems.get(npc).isAtDestination)
  2278. {
  2279. return "";
  2280. }
  2281. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  2282. List<L2Object> crystals = new FastList<>();
  2283. for (L2Object object : L2World.getInstance().getVisibleObjects(npc, 300))
  2284. {
  2285. if ((object instanceof L2ItemInstance) && (object.getId() == CRYSTALFOOD))
  2286. {
  2287. crystals.add(object);
  2288. }
  2289. }
  2290. int minDist = 300000;
  2291. for (L2Object crystal : crystals)
  2292. {
  2293. int dx = npc.getX() - crystal.getX();
  2294. int dy = npc.getY() - crystal.getY();
  2295. int d = (dx * dx) + (dy * dy);
  2296. if (d < minDist)
  2297. {
  2298. minDist = d;
  2299. cryGolem.foodItem = (L2ItemInstance) crystal;
  2300. }
  2301. }
  2302. if (minDist != 300000)
  2303. {
  2304. startQuestTimer("getFood", 2000, npc, null);
  2305. }
  2306. else
  2307. {
  2308. if (getRandom(100) < 5)
  2309. {
  2310. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.AH_IM_HUNGRY));
  2311. }
  2312. startQuestTimer("autoFood", 2000, npc, null);
  2313. }
  2314. return "";
  2315. }
  2316. else if (!world.crystalGolems.containsKey(npc) || world.crystalGolems.get(npc).isAtDestination)
  2317. {
  2318. return "";
  2319. }
  2320. else if (event.equalsIgnoreCase("backFood"))
  2321. {
  2322. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  2323. {
  2324. cancelQuestTimers("backFood");
  2325. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  2326. world.crystalGolems.get(npc).foodItem = null;
  2327. startQuestTimer("autoFood", 2000, npc, null);
  2328. }
  2329. }
  2330. else if (event.equalsIgnoreCase("reachFood"))
  2331. {
  2332. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  2333. int dx;
  2334. int dy;
  2335. if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isVisible())
  2336. {
  2337. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, cryGolem.oldLoc);
  2338. cancelQuestTimers("reachFood");
  2339. startQuestTimer("backFood", 2000, npc, null, true);
  2340. return "";
  2341. }
  2342. else if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  2343. {
  2344. L2World.getInstance().removeVisibleObject(cryGolem.foodItem, cryGolem.foodItem.getWorldRegion());
  2345. L2World.getInstance().removeObject(cryGolem.foodItem);
  2346. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  2347. cryGolem.foodItem = null;
  2348. dx = npc.getX() - 142999;
  2349. dy = npc.getY() - 151671;
  2350. int d1 = (dx * dx) + (dy * dy);
  2351. dx = npc.getX() - 139494;
  2352. dy = npc.getY() - 151668;
  2353. int d2 = (dx * dx) + (dy * dy);
  2354. if ((d1 < 10000) || (d2 < 10000))
  2355. {
  2356. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  2357. cryGolem.isAtDestination = true;
  2358. world.correctGolems++;
  2359. if (world.correctGolems >= 2)
  2360. {
  2361. openDoor(24220026, world.getInstanceId());
  2362. world.setStatus(4);
  2363. }
  2364. }
  2365. else
  2366. {
  2367. startQuestTimer("autoFood", 2000, npc, null);
  2368. }
  2369. cancelQuestTimers("reachFood");
  2370. }
  2371. return "";
  2372. }
  2373. else if (event.equalsIgnoreCase("getFood"))
  2374. {
  2375. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  2376. Location newLoc = new Location(cryGolem.foodItem.getX(), cryGolem.foodItem.getY(), cryGolem.foodItem.getZ(), 0);
  2377. cryGolem.oldLoc = new Location(npc.getX(), npc.getY(), npc.getZ(), npc.getHeading());
  2378. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newLoc);
  2379. startQuestTimer("reachFood", 2000, npc, null, true);
  2380. cancelQuestTimers("getFood");
  2381. }
  2382. }
  2383. return "";
  2384. }
  2385. private void giveRewards(L2PcInstance player, int instanceId, int bossCry, boolean isBaylor)
  2386. {
  2387. final int num = Math.max((int) Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER, 1);
  2388. L2Party party = player.getParty();
  2389. if (party != null)
  2390. {
  2391. for (L2PcInstance partyMember : party.getMembers())
  2392. {
  2393. if (partyMember.getInstanceId() == instanceId)
  2394. {
  2395. final QuestState st = getQuestState(partyMember, true);
  2396. if (!isBaylor && st.hasQuestItems(CONT_CRYSTAL))
  2397. {
  2398. st.takeItems(CONT_CRYSTAL, 1);
  2399. st.giveItems(bossCry, 1);
  2400. }
  2401. if (getRandom(10) < 5)
  2402. {
  2403. st.giveItems(WHITE_SEED, num);
  2404. }
  2405. else
  2406. {
  2407. st.giveItems(BLACK_SEED, num);
  2408. }
  2409. }
  2410. }
  2411. }
  2412. else if (player.getInstanceId() == instanceId)
  2413. {
  2414. QuestState st = getQuestState(player, false);
  2415. if (st == null)
  2416. {
  2417. st = newQuestState(player);
  2418. }
  2419. if (!isBaylor && st.hasQuestItems(CONT_CRYSTAL))
  2420. {
  2421. st.takeItems(CONT_CRYSTAL, 1);
  2422. st.giveItems(bossCry, 1);
  2423. }
  2424. if (getRandom(10) < 5)
  2425. {
  2426. st.giveItems(WHITE_SEED, num);
  2427. }
  2428. else
  2429. {
  2430. st.giveItems(BLACK_SEED, num);
  2431. }
  2432. }
  2433. }
  2434. @Override
  2435. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  2436. {
  2437. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  2438. if (tmpworld instanceof CCWorld)
  2439. {
  2440. CCWorld world = (CCWorld) tmpworld;
  2441. if ((world.getStatus() == 2) && world.npcList1.containsKey(npc))
  2442. {
  2443. world.npcList1.put(npc, true);
  2444. for (boolean isDead : world.npcList1.values())
  2445. {
  2446. if (!isDead)
  2447. {
  2448. return "";
  2449. }
  2450. }
  2451. world.setStatus(3);
  2452. world.tears = addSpawn(TEARS, 144298, 154420, -11854, 32767, false, 0, false, world.getInstanceId()); // Tears
  2453. CrystalGolem crygolem1 = new CrystalGolem();
  2454. CrystalGolem crygolem2 = new CrystalGolem();
  2455. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 140547, 151670, -11813, 32767, false, 0, false, world.getInstanceId()), crygolem1);
  2456. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 141941, 151684, -11813, 63371, false, 0, false, world.getInstanceId()), crygolem2);
  2457. for (L2Npc crygolem : world.crystalGolems.keySet())
  2458. {
  2459. startQuestTimer("autoFood", 2000, crygolem, null);
  2460. }
  2461. }
  2462. else if ((world.getStatus() == 4) && (npc.getId() == TEARS))
  2463. {
  2464. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  2465. addSpawn(32280, 144312, 154420, -11855, 0, false, 0, false, world.getInstanceId());
  2466. giveRewards(player, npc.getInstanceId(), BOSS_CRYSTAL_3, false);
  2467. }
  2468. else if ((world.getStatus() == 2) && world.keyKeepers.contains(npc))
  2469. {
  2470. if (npc.getId() == GK1)
  2471. {
  2472. npc.dropItem(player, 9698, 1);
  2473. runEmeraldSquare(world);
  2474. }
  2475. else if (npc.getId() == GK2)
  2476. {
  2477. npc.dropItem(player, 9699, 1);
  2478. runSteamRooms(world, STEAM1_SPAWNS, 22);
  2479. L2Party party = player.getParty();
  2480. if (party != null)
  2481. {
  2482. for (L2PcInstance partyMember : party.getMembers())
  2483. {
  2484. if (partyMember.getInstanceId() == world.getInstanceId())
  2485. {
  2486. SkillData.getInstance().getSkill(5239, 1).applyEffects(partyMember, partyMember);
  2487. startQuestTimer("Timer2", 300000, npc, partyMember);
  2488. }
  2489. }
  2490. }
  2491. else
  2492. {
  2493. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  2494. startQuestTimer("Timer2", 300000, npc, player);
  2495. }
  2496. startQuestTimer("Timer21", 300000, npc, null);
  2497. }
  2498. for (L2Npc gk : world.keyKeepers)
  2499. {
  2500. if (gk != npc)
  2501. {
  2502. gk.decayMe();
  2503. }
  2504. }
  2505. }
  2506. else if (world.getStatus() == 3)
  2507. {
  2508. if (checkKillProgress(0, npc, world))
  2509. {
  2510. world.setStatus(4);
  2511. addSpawn(TOURMALINE, 148202, 144791, -12235, 0, false, 0, false, world.getInstanceId());
  2512. }
  2513. else
  2514. {
  2515. return "";
  2516. }
  2517. }
  2518. else if (world.getStatus() == 4)
  2519. {
  2520. if (npc.getId() == TOURMALINE)
  2521. {
  2522. world.setStatus(5);
  2523. addSpawn(TEROD, 147777, 146780, -12281, 0, false, 0, false, world.getInstanceId());
  2524. }
  2525. }
  2526. else if (world.getStatus() == 5)
  2527. {
  2528. if (npc.getId() == TEROD)
  2529. {
  2530. world.setStatus(6);
  2531. addSpawn(TOURMALINE, 143694, 142659, -11882, 0, false, 0, false, world.getInstanceId());
  2532. }
  2533. }
  2534. else if (world.getStatus() == 6)
  2535. {
  2536. if (npc.getId() == TOURMALINE)
  2537. {
  2538. world.setStatus(7);
  2539. addSpawn(DOLPH, 142054, 143288, -11825, 0, false, 0, false, world.getInstanceId());
  2540. }
  2541. }
  2542. else if (world.getStatus() == 7)
  2543. {
  2544. if (npc.getId() == DOLPH)
  2545. {
  2546. world.setStatus(8);
  2547. // first door opener trap
  2548. addTrap(DOOR_OPENING_TRAP[0], DOOR_OPENING_TRAP[1], DOOR_OPENING_TRAP[2], DOOR_OPENING_TRAP[3], DOOR_OPENING_TRAP[4], null, world.getInstanceId());
  2549. }
  2550. }
  2551. else if (world.getStatus() == 8)
  2552. {
  2553. for (int i = 0; i < 4; i++)
  2554. {
  2555. if ((world.roomsStatus[i] == 1) && checkKillProgress(i + 1, npc, world))
  2556. {
  2557. world.roomsStatus[i] = 2;
  2558. }
  2559. if (world.roomsStatus[i] == 2)
  2560. {
  2561. world.cleanedRooms++;
  2562. if (world.cleanedRooms == 21)
  2563. {
  2564. runDarnel(world);
  2565. }
  2566. }
  2567. }
  2568. }
  2569. else if ((world.getStatus() >= 22) && (world.getStatus() <= 25))
  2570. {
  2571. if (npc.getId() == 22416)
  2572. {
  2573. for (L2Npc oracle : world.oracles.keySet())
  2574. {
  2575. if (world.oracles.get(oracle) == npc)
  2576. {
  2577. world.oracles.put(oracle, null);
  2578. }
  2579. }
  2580. }
  2581. if (checkKillProgress(0, npc, world))
  2582. {
  2583. world.npcList2.clear();
  2584. int[][] oracleOrder;
  2585. switch (world.getStatus())
  2586. {
  2587. case 22:
  2588. closeDoor(DOOR6, npc.getInstanceId());
  2589. oracleOrder = ordreOracle1;
  2590. break;
  2591. case 23:
  2592. oracleOrder = ordreOracle2;
  2593. break;
  2594. case 24:
  2595. oracleOrder = ordreOracle3;
  2596. break;
  2597. case 25:
  2598. world.setStatus(26);
  2599. L2Party party = player.getParty();
  2600. if (party != null)
  2601. {
  2602. for (L2PcInstance partyMember : party.getMembers())
  2603. {
  2604. partyMember.stopSkillEffects(true, 5239);
  2605. }
  2606. }
  2607. cancelQuestTimers("Timer5");
  2608. cancelQuestTimers("Timer51");
  2609. openDoor(DOOR3, npc.getInstanceId());
  2610. openDoor(DOOR4, npc.getInstanceId());
  2611. L2Npc kechi = addSpawn(KECHI, 154069, 149525, -12158, 51165, false, 0, false, world.getInstanceId());
  2612. startQuestTimer("checkKechiAttack", 1000, kechi, null);
  2613. return "";
  2614. default:
  2615. _log.warning("CrystalCavern-SteamCorridor: status " + world.getStatus() + " error. OracleOrder not found in " + world.getInstanceId());
  2616. return "";
  2617. }
  2618. runSteamOracles(world, oracleOrder);
  2619. }
  2620. }
  2621. else if (((world.getStatus() == 9) && (npc.getId() == DARNEL)) || ((world.getStatus() == 26) && (npc.getId() == KECHI)))
  2622. {
  2623. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  2624. int bossCry;
  2625. if (npc.getId() == KECHI)
  2626. {
  2627. bossCry = BOSS_CRYSTAL_2;
  2628. cancelQuestTimers("spawnGuards");
  2629. addSpawn(32280, 154077, 149527, -12159, 0, false, 0, false, world.getInstanceId());
  2630. }
  2631. else if (npc.getId() == DARNEL)
  2632. {
  2633. bossCry = BOSS_CRYSTAL_1;
  2634. addSpawn(32280, 152761, 145950, -12588, 0, false, 0, false, world.getInstanceId());
  2635. }
  2636. else
  2637. {
  2638. // something is wrong
  2639. return "";
  2640. }
  2641. giveRewards(player, npc.getInstanceId(), bossCry, false);
  2642. }
  2643. if (npc.getId() == ALARMID)
  2644. {
  2645. world._baylor.removeSkill(5244);
  2646. world._baylor.removeSkill(5245);
  2647. world._alarm = null;
  2648. if ((world._baylor.getMaxHp() * 0.3) < world._baylor.getStatus().getCurrentHp())
  2649. {
  2650. startQuestTimer("baylor_alarm", 40000, world._baylor, null);
  2651. }
  2652. }
  2653. else if (npc.getId() == BAYLOR)
  2654. {
  2655. world.setStatus(31);
  2656. world._baylor = null;
  2657. npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  2658. Instance baylorInstance = InstanceManager.getInstance().getInstance(npc.getInstanceId());
  2659. baylorInstance.setDuration(300000);
  2660. this.startQuestTimer("spawn_oracle", 1000, npc, null);
  2661. giveRewards(player, npc.getInstanceId(), -1, true);
  2662. }
  2663. }
  2664. return "";
  2665. }
  2666. @Override
  2667. public String onTalk(L2Npc npc, L2PcInstance player)
  2668. {
  2669. int npcId = npc.getId();
  2670. QuestState st = getQuestState(player, false);
  2671. if (st == null)
  2672. {
  2673. st = newQuestState(player);
  2674. }
  2675. if (npcId == ORACLE_GUIDE_1)
  2676. {
  2677. enterInstance(player, "CrystalCaverns.xml", new Location(143348, 148707, -11972));
  2678. return "";
  2679. }
  2680. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  2681. if (tmpworld instanceof CCWorld)
  2682. {
  2683. CCWorld world = (CCWorld) tmpworld;
  2684. if (npcId == CRYSTAL_GOLEM)
  2685. {
  2686. }
  2687. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && world.OracleTriggered[npc.getId() - 32275])
  2688. {
  2689. boolean doTeleport = false;
  2690. Location loc = null;
  2691. L2Party party = player.getParty();
  2692. doTeleport = true;
  2693. switch (npc.getId())
  2694. {
  2695. case 32275:
  2696. if (world.getStatus() == 22)
  2697. {
  2698. runSteamRooms(world, STEAM2_SPAWNS, 23);
  2699. }
  2700. loc = new Location(147529, 152587, -12169);
  2701. cancelQuestTimers("Timer2");
  2702. cancelQuestTimers("Timer21");
  2703. if (party != null)
  2704. {
  2705. for (L2PcInstance partyMember : party.getMembers())
  2706. {
  2707. if (partyMember.getInstanceId() == world.getInstanceId())
  2708. {
  2709. partyMember.stopSkillEffects(true, 5239);
  2710. SkillData.getInstance().getSkill(5239, 2).applyEffects(partyMember, partyMember);
  2711. startQuestTimer("Timer3", 600000, npc, partyMember);
  2712. }
  2713. }
  2714. }
  2715. else
  2716. {
  2717. player.stopSkillEffects(true, 5239);
  2718. SkillData.getInstance().getSkill(5239, 2).applyEffects(player, player);
  2719. startQuestTimer("Timer3", 600000, npc, player);
  2720. }
  2721. startQuestTimer("Timer31", 600000, npc, null);
  2722. break;
  2723. case 32276:
  2724. if (world.getStatus() == 23)
  2725. {
  2726. runSteamRooms(world, STEAM3_SPAWNS, 24);
  2727. }
  2728. loc = new Location(150194, 152610, -12169);
  2729. cancelQuestTimers("Timer3");
  2730. cancelQuestTimers("Timer31");
  2731. if (party != null)
  2732. {
  2733. for (L2PcInstance partyMember : party.getMembers())
  2734. {
  2735. if (partyMember.getInstanceId() == world.getInstanceId())
  2736. {
  2737. partyMember.stopSkillEffects(true, 5239);
  2738. SkillData.getInstance().getSkill(5239, 4).applyEffects(partyMember, partyMember);
  2739. startQuestTimer("Timer4", 1200000, npc, partyMember);
  2740. }
  2741. }
  2742. }
  2743. else
  2744. {
  2745. player.stopSkillEffects(true, 5239);
  2746. SkillData.getInstance().getSkill(5239, 4).applyEffects(player, player);
  2747. startQuestTimer("Timer4", 1200000, npc, player);
  2748. }
  2749. startQuestTimer("Timer41", 1200000, npc, null);
  2750. break;
  2751. case 32277:
  2752. if (world.getStatus() == 24)
  2753. {
  2754. runSteamRooms(world, STEAM4_SPAWNS, 25);
  2755. }
  2756. loc = new Location(149743, 149986, -12141);
  2757. cancelQuestTimers("Timer4");
  2758. cancelQuestTimers("Timer41");
  2759. if (party != null)
  2760. {
  2761. for (L2PcInstance partyMember : party.getMembers())
  2762. {
  2763. if (partyMember.getInstanceId() == world.getInstanceId())
  2764. {
  2765. partyMember.stopSkillEffects(true, 5239);
  2766. SkillData.getInstance().getSkill(5239, 3).applyEffects(partyMember, partyMember);
  2767. startQuestTimer("Timer5", 900000, npc, partyMember);
  2768. }
  2769. }
  2770. }
  2771. else
  2772. {
  2773. player.stopSkillEffects(true, 5239);
  2774. SkillData.getInstance().getSkill(5239, 3).applyEffects(player, player);
  2775. startQuestTimer("Timer5", 900000, npc, player);
  2776. }
  2777. startQuestTimer("Timer51", 900000, npc, null);
  2778. break;
  2779. default:
  2780. // something is wrong
  2781. doTeleport = false;
  2782. }
  2783. if (doTeleport && (loc != null))
  2784. {
  2785. if (!checkOracleConditions(player))
  2786. {
  2787. return "";
  2788. }
  2789. else if (party != null)
  2790. {
  2791. for (L2PcInstance partyMember : party.getMembers())
  2792. {
  2793. partyMember.destroyItemByItemId("Quest", RED_CORAL, 1, player, true);
  2794. teleportPlayer(partyMember, loc, npc.getInstanceId());
  2795. }
  2796. }
  2797. else
  2798. {
  2799. teleportPlayer(player, loc, npc.getInstanceId());
  2800. }
  2801. }
  2802. }
  2803. else if (npc.getId() == ORACLE_GUIDE_3)
  2804. {
  2805. if ((world.getStatus() < 30) && checkBaylorConditions(player))
  2806. {
  2807. world._raiders.clear();
  2808. L2Party party = player.getParty();
  2809. if (party == null)
  2810. {
  2811. world._raiders.add(player);
  2812. }
  2813. else
  2814. {
  2815. for (L2PcInstance partyMember : party.getMembers())
  2816. {
  2817. // int rnd = getRandom(100);
  2818. // 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.
  2819. world._raiders.add(partyMember);
  2820. }
  2821. }
  2822. }
  2823. else
  2824. {
  2825. return "";
  2826. }
  2827. world.setStatus(30);
  2828. long time = world.endTime - System.currentTimeMillis();
  2829. Instance baylorInstance = InstanceManager.getInstance().getInstance(world.getInstanceId());
  2830. baylorInstance.setDuration((int) time);
  2831. int radius = 150;
  2832. int i = 0;
  2833. int members = world._raiders.size();
  2834. for (L2PcInstance p : world._raiders)
  2835. {
  2836. int x = (int) (radius * Math.cos((i * 2 * Math.PI) / members));
  2837. int y = (int) (radius * Math.sin((i++ * 2 * Math.PI) / members));
  2838. p.teleToLocation(new Location(153571 + x, 142075 + y, -12737));
  2839. L2Summon pet = p.getSummon();
  2840. if (pet != null)
  2841. {
  2842. pet.teleToLocation(new Location(153571 + x, 142075 + y, -12737), true);
  2843. pet.broadcastPacket(new ValidateLocation(pet));
  2844. }
  2845. p.setIsParalyzed(true);
  2846. p.broadcastPacket(new ValidateLocation(p));
  2847. }
  2848. startQuestTimer("Baylor", 30000, npc, null);
  2849. }
  2850. else if ((npc.getId() == ORACLE_GUIDE_4) && (world.getStatus() == 31))
  2851. {
  2852. teleportPlayer(player, new Location(153522, 144212, -9747), npc.getInstanceId());
  2853. }
  2854. }
  2855. return "";
  2856. }
  2857. @Override
  2858. public String onTrapAction(L2TrapInstance trap, L2Character trigger, TrapAction action)
  2859. {
  2860. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
  2861. if (tmpworld instanceof CCWorld)
  2862. {
  2863. CCWorld world = (CCWorld) tmpworld;
  2864. switch (action)
  2865. {
  2866. case TRAP_DISARMED:
  2867. if (trap.getId() == DOOR_OPENING_TRAP[0])
  2868. {
  2869. openDoor(24220001, world.getInstanceId());
  2870. runEmeraldRooms(world, ROOM1_SPAWNS, 1);
  2871. }
  2872. break;
  2873. }
  2874. }
  2875. return null;
  2876. }
  2877. @Override
  2878. public String onEnterZone(L2Character character, L2ZoneType zone)
  2879. {
  2880. if (character instanceof L2PcInstance)
  2881. {
  2882. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  2883. if (tmpworld instanceof CCWorld)
  2884. {
  2885. CCWorld world = (CCWorld) tmpworld;
  2886. if (world.getStatus() == 8)
  2887. {
  2888. int room;
  2889. int[][] spawns;
  2890. switch (zone.getId())
  2891. {
  2892. case 20105:
  2893. spawns = ROOM2_SPAWNS;
  2894. room = 2;
  2895. break;
  2896. case 20106:
  2897. spawns = ROOM3_SPAWNS;
  2898. room = 3;
  2899. break;
  2900. case 20107:
  2901. spawns = ROOM4_SPAWNS;
  2902. room = 4;
  2903. break;
  2904. default:
  2905. return super.onEnterZone(character, zone);
  2906. }
  2907. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  2908. {
  2909. if (door.getId() == (room + 24220000))
  2910. {
  2911. if (door.getOpen())
  2912. {
  2913. return "";
  2914. }
  2915. QuestState st = ((L2PcInstance) character).getQuestState(getName());
  2916. if (st == null)
  2917. {
  2918. st = newQuestState((L2PcInstance) character);
  2919. }
  2920. if (!st.hasQuestItems(RACE_KEY))
  2921. {
  2922. return "";
  2923. }
  2924. if (world.roomsStatus[zone.getId() - 20104] == 0)
  2925. {
  2926. runEmeraldRooms(world, spawns, room);
  2927. }
  2928. door.openMe();
  2929. st.takeItems(RACE_KEY, 1);
  2930. world.openedDoors.put(door, (L2PcInstance) character);
  2931. break;
  2932. }
  2933. }
  2934. }
  2935. }
  2936. }
  2937. return super.onEnterZone(character, zone);
  2938. }
  2939. @Override
  2940. public String onExitZone(L2Character character, L2ZoneType zone)
  2941. {
  2942. if (character instanceof L2PcInstance)
  2943. {
  2944. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  2945. if (tmpworld instanceof CCWorld)
  2946. {
  2947. CCWorld world = (CCWorld) tmpworld;
  2948. if (world.getStatus() == 8)
  2949. {
  2950. int doorId;
  2951. switch (zone.getId())
  2952. {
  2953. case 20105:
  2954. doorId = 24220002;
  2955. break;
  2956. case 20106:
  2957. doorId = 24220003;
  2958. break;
  2959. case 20107:
  2960. doorId = 24220004;
  2961. break;
  2962. default:
  2963. return super.onExitZone(character, zone);
  2964. }
  2965. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  2966. {
  2967. if (door.getId() == doorId)
  2968. {
  2969. if (door.getOpen() && (world.openedDoors.get(door) == character))
  2970. {
  2971. door.closeMe();
  2972. world.openedDoors.remove(door);
  2973. }
  2974. break;
  2975. }
  2976. }
  2977. }
  2978. }
  2979. }
  2980. return super.onExitZone(character, zone);
  2981. }
  2982. public static void main(String[] args)
  2983. {
  2984. // now call the constructor (starts up the)
  2985. new CrystalCaverns();
  2986. }
  2987. }