CrystalCaverns.java 71 KB

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