CrystalCaverns.java 72 KB

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