CrystalCaverns.java 72 KB

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