CrystalCaverns.java 72 KB

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