CrystalCaverns.java 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package instances.CrystalCaverns;
  20. import instances.AbstractInstance;
  21. import java.util.ArrayList;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.concurrent.ConcurrentHashMap;
  26. import quests.Q00131_BirdInACage.Q00131_BirdInACage;
  27. import com.l2jserver.Config;
  28. import com.l2jserver.gameserver.GeoData;
  29. import com.l2jserver.gameserver.ai.CtrlIntention;
  30. import com.l2jserver.gameserver.datatables.SkillData;
  31. import com.l2jserver.gameserver.enums.TrapAction;
  32. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  33. import com.l2jserver.gameserver.model.L2Object;
  34. import com.l2jserver.gameserver.model.L2Party;
  35. import com.l2jserver.gameserver.model.L2World;
  36. import com.l2jserver.gameserver.model.Location;
  37. import com.l2jserver.gameserver.model.PcCondOverride;
  38. import com.l2jserver.gameserver.model.actor.L2Attackable;
  39. import com.l2jserver.gameserver.model.actor.L2Character;
  40. import com.l2jserver.gameserver.model.actor.L2Npc;
  41. import com.l2jserver.gameserver.model.actor.L2Summon;
  42. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  43. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  44. import com.l2jserver.gameserver.model.actor.instance.L2TrapInstance;
  45. import com.l2jserver.gameserver.model.entity.Instance;
  46. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  47. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  48. import com.l2jserver.gameserver.model.quest.QuestState;
  49. import com.l2jserver.gameserver.model.skills.Skill;
  50. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  51. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  52. import com.l2jserver.gameserver.network.NpcStringId;
  53. import com.l2jserver.gameserver.network.SystemMessageId;
  54. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  55. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  56. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
  57. import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
  58. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  59. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  60. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  61. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  62. import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
  63. import com.l2jserver.gameserver.util.Util;
  64. /**
  65. * Crystal Caverns instance zone.<br>
  66. * TODO: 1. Kechi's Henchmans spawn animation is missing.<br>
  67. * 2. NPC related Traps are not supported by core, so Darnels and Lahm door trap is not working.<br>
  68. * 3. Need retail spawn for Coral Garden (EmeraldSteam/Square - done).<br>
  69. * 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>
  70. * Original sources: theone, L2JEmu, L2JOfficial, L2JFree Contributing authors: TGS, Lantoc, Janiii, Gigiikun, RosT Please maintain consistency between the Crystal Caverns scripts.
  71. */
  72. public final class CrystalCaverns extends AbstractInstance
  73. {
  74. protected static class CrystalGolem
  75. {
  76. protected L2ItemInstance foodItem = null;
  77. protected boolean isAtDestination = false;
  78. protected Location oldLoc = null;
  79. }
  80. private class CCWorld extends InstanceWorld
  81. {
  82. public Map<L2Npc, Boolean> npcList1 = new HashMap<>();
  83. public L2Npc tears;
  84. public boolean isUsedInvulSkill = false;
  85. public long dragonScaleStart = 0;
  86. public int dragonScaleNeed = 0;
  87. public int cleanedRooms = 0;
  88. public long endTime = 0;
  89. public List<L2Npc> copys = new ArrayList<>();
  90. public Map<L2Npc, CrystalGolem> crystalGolems = new HashMap<>();
  91. public int correctGolems = 0;
  92. public boolean[] OracleTriggered =
  93. {
  94. false,
  95. false,
  96. false
  97. };
  98. public int kechisHenchmanSpawn = 0;
  99. public int[] roomsStatus =
  100. {
  101. 0,
  102. 0,
  103. 0,
  104. 0
  105. }; // 0: not spawned, 1: spawned, 2: cleared
  106. public Map<L2DoorInstance, L2PcInstance> openedDoors = new ConcurrentHashMap<>();
  107. public Map<Integer, Map<L2Npc, Boolean>> npcList2 = new HashMap<>();
  108. public Map<L2Npc, L2Npc> oracles = new HashMap<>();
  109. public List<L2Npc> keyKeepers = new ArrayList<>();
  110. public List<L2Npc> guards = new ArrayList<>();
  111. public List<L2Npc> oracle = new ArrayList<>();
  112. // baylor variables
  113. protected final List<L2PcInstance> _raiders = new ArrayList<>();
  114. protected int _raidStatus = 0;
  115. protected long _dragonClawStart = 0;
  116. protected int _dragonClawNeed = 0;
  117. protected final List<L2Npc> _animationMobs = new ArrayList<>();
  118. protected L2Npc _camera = null;
  119. protected L2Npc _baylor = null;
  120. protected L2Npc _alarm = null;
  121. public CCWorld(Long time)
  122. {
  123. endTime = time;
  124. }
  125. }
  126. // Items
  127. private static final int WHITE_SEED = 9597;
  128. private static final int BLACK_SEED = 9598;
  129. private static final int CONT_CRYSTAL = 9690; // Contaminated Crystal
  130. private static final int RED_CORAL = 9692; // Red Coral
  131. private static final int CRYSTALFOOD = 9693; // Food item for Crystal Golems
  132. final private static int RACE_KEY = 9694; // Race Key for Emerald doors
  133. private static final int BOSS_CRYSTAL_1 = 9695; // Clear Crystal
  134. private static final int BOSS_CRYSTAL_2 = 9696; // Clear Crystal
  135. private static final int BOSS_CRYSTAL_3 = 9697; // Clear Crystal
  136. // NPCs
  137. private static final int ORACLE_GUIDE_1 = 32281;
  138. private static final int ORACLE_GUIDE_2 = 32278;
  139. private static final int ORACLE_GUIDE_3 = 32280;
  140. private static final int ORACLE_GUIDE_4 = 32279;
  141. private static final int CRYSTAL_GOLEM = 32328;
  142. private static final int[] DOOR_OPENING_TRAP =
  143. {
  144. 18378,
  145. 143682,
  146. 142492,
  147. -11886,
  148. 16384
  149. };
  150. 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. // Locations
  211. private static final Location START_LOC = new Location(143348, 148707, -11972);
  212. // Misc
  213. private static final int TEMPLATE_ID = 10;
  214. private static final boolean debug = false;
  215. private static final int DOOR1 = 24220021;
  216. private static final int DOOR2 = 24220024;
  217. private static final int DOOR3 = 24220023;
  218. private static final int DOOR4 = 24220061;
  219. private static final int DOOR5 = 24220025;
  220. private static final int DOOR6 = 24220022;
  221. private static final int[] ZONES =
  222. {
  223. 20105,
  224. 20106,
  225. 20107
  226. };
  227. // @formatter:off
  228. private final static int[][] ALARMSPAWN =
  229. {
  230. {153572, 141277, -12738},
  231. {153572, 142852, -12738},
  232. {154358, 142075, -12738},
  233. {152788, 142075, -12738}
  234. };
  235. // Oracle order
  236. private static final int[][] ordreOracle1 =
  237. {
  238. {32274, 147090, 152505, -12169, 31613},
  239. {32275, 147090, 152575, -12169, 31613},
  240. {32274, 147090, 152645, -12169, 31613},
  241. {32274, 147090, 152715, -12169, 31613}
  242. };
  243. private static final int[][] ordreOracle2 =
  244. {
  245. {32274, 149783, 152505, -12169, 31613},
  246. // {32274, 149783, 152575, -12169, 31613},
  247. {32274, 149783, 152645, -12169, 31613},
  248. {32276, 149783, 152715, -12169, 31613}
  249. };
  250. private static final int[][] ordreOracle3 =
  251. {
  252. {32274, 152461, 152505, -12169, 31613},
  253. // {32274, 152461, 152575, -12169, 31613},
  254. {32277, 152461, 152645, -12169, 31613},
  255. // {32274, 152461, 152715, -12169, 31613}
  256. };
  257. private static int[][] HALL_SPAWNS =
  258. {
  259. {141842, 152556, -11814, 50449},
  260. {141503, 153395, -11814, 40738},
  261. {141070, 153201, -11814, 39292},
  262. {141371, 152986, -11814, 35575},
  263. {141602, 154188, -11814, 24575},
  264. {141382, 154719, -11814, 37640},
  265. {141376, 154359, -11814, 12054},
  266. {140895, 154383, -11814, 37508},
  267. {140972, 154740, -11814, 52690},
  268. {141045, 154504, -11814, 50674},
  269. {140757, 152740, -11814, 39463},
  270. {140406, 152376, -11814, 16599},
  271. {140268, 152007, -11817, 45316},
  272. {139996, 151485, -11814, 47403},
  273. {140378, 151190, -11814, 58116},
  274. {140521, 150711, -11815, 55997},
  275. {140816, 150215, -11814, 53682},
  276. {141528, 149909, -11814, 22020},
  277. {141644, 150360, -11817, 13283},
  278. {142048, 150695, -11815, 5929},
  279. {141852, 151065, -11817, 27071},
  280. {142408, 151211, -11815, 2402},
  281. {142481, 151762, -11815, 12876},
  282. {141929, 152193, -11815, 27511},
  283. {142083, 151791, -11814, 47176},
  284. {141435, 150402, -11814, 41798},
  285. {140390, 151199, -11814, 50069},
  286. {140557, 151849, -11814, 45293},
  287. {140964, 153445, -11814, 56672},
  288. {142851, 154109, -11814, 24920},
  289. {142379, 154725, -11814, 30342},
  290. {142816, 154712, -11814, 33193},
  291. {142276, 154223, -11814, 33922},
  292. {142459, 154490, -11814, 33184},
  293. {142819, 154372, -11814, 21318},
  294. {141157, 154541, -11814, 27090},
  295. {141095, 150281, -11814, 55186}
  296. };
  297. // first spawns
  298. private static int[][] FIRST_SPAWNS =
  299. {
  300. {22276, 148109, 149601, -12132, 34490},
  301. {22276, 148017, 149529, -12132, 33689},
  302. {22278, 148065, 151202, -12132, 35323},
  303. {22278, 147966, 151117, -12132, 33234},
  304. {22279, 144063, 150238, -12132, 29654},
  305. {22279, 144300, 149118, -12135, 5520},
  306. {22279, 144397, 149337, -12132, 644},
  307. {22279, 144426, 150639, -12132, 50655},
  308. {22282, 145841, 151097, -12132, 31810},
  309. {22282, 144387, 149958, -12132, 61173},
  310. {22282, 145821, 149498, -12132, 31490},
  311. {22282, 146619, 149694, -12132, 33374},
  312. {22282, 146669, 149244, -12132, 31360},
  313. {22284, 144147, 151375, -12132, 58395},
  314. {22284, 144485, 151067, -12132, 64786},
  315. {22284, 144356, 149571, -12132, 63516},
  316. {22285, 144151, 150962, -12132, 664},
  317. {22285, 146657, 151365, -12132, 33154},
  318. {22285, 146623, 150857, -12132, 28034},
  319. {22285, 147046, 151089, -12132, 32941},
  320. {22285, 145704, 151255, -12132, 32523},
  321. {22285, 145359, 151101, -12132, 32767},
  322. {22285, 147785, 150817, -12132, 27423},
  323. {22285, 147727, 151375, -12132, 37117},
  324. {22285, 145428, 149494, -12132, 890},
  325. {22285, 145601, 149682, -12132, 32442},
  326. {22285, 147003, 149476, -12132, 31554},
  327. {22285, 147738, 149210, -12132, 20971},
  328. {22285, 147769, 149757, -12132, 34980}
  329. };
  330. // Emerald Square
  331. private static int[][] EMERALD_SPAWNS =
  332. {
  333. {22280, 144437, 143395, -11969, 34248},
  334. {22281, 149241, 143735, -12230, 24575},
  335. {22281, 147917, 146861, -12289, 60306},
  336. {22281, 144406, 147782, -12133, 14349},
  337. {22281, 144960, 146881, -12039, 23881},
  338. {22281, 144985, 147679, -12135, 27594},
  339. {22283, 147784, 143540, -12222, 2058},
  340. {22283, 149091, 143491, -12230, 24836},
  341. {22287, 144479, 147569, -12133, 20723},
  342. {22287, 145158, 146986, -12058, 21970},
  343. {22287, 145142, 147175, -12092, 24420},
  344. {22287, 145110, 147133, -12088, 22465},
  345. {22287, 144664, 146604, -12028, 14861},
  346. {22287, 144596, 146600, -12028, 14461},
  347. {22288, 143925, 146773, -12037, 10813},
  348. {22288, 144415, 147070, -12069, 8568},
  349. {22288, 143794, 145584, -12027, 14849},
  350. {22288, 143429, 146166, -12030, 4078},
  351. {22288, 144477, 147009, -12056, 8752},
  352. {22289, 142577, 145319, -12029, 5403},
  353. {22289, 143831, 146902, -12051, 9717},
  354. {22289, 143714, 146705, -12028, 10044},
  355. {22289, 143937, 147134, -12078, 7517},
  356. {22293, 143356, 145287, -12027, 8126},
  357. {22293, 143462, 144352, -12008, 25905},
  358. {22293, 143745, 142529, -11882, 17102},
  359. {22293, 144574, 144032, -12005, 34668},
  360. {22295, 143992, 142419, -11884, 19697},
  361. {22295, 144671, 143966, -12004, 32088},
  362. {22295, 144440, 143269, -11957, 34169},
  363. {22295, 142642, 146362, -12028, 281},
  364. {22295, 143865, 142707, -11881, 21326},
  365. {22295, 143573, 142530, -11879, 16141},
  366. {22295, 143148, 146039, -12031, 65014},
  367. {22295, 143001, 144853, -12014, 0},
  368. {22296, 147505, 146580, -12260, 59041},
  369. {22296, 149366, 146932, -12358, 39407},
  370. {22296, 149284, 147029, -12352, 41120},
  371. {22296, 149439, 143940, -12230, 23189},
  372. {22296, 147698, 143995, -12220, 27028},
  373. {22296, 141885, 144969, -12007, 2526},
  374. {22296, 147843, 143763, -12220, 28386},
  375. {22296, 144753, 143650, -11982, 35429},
  376. {22296, 147613, 146760, -12271, 56296}
  377. };
  378. private static int[][] ROOM1_SPAWNS =
  379. {
  380. {22288, 143114, 140027, -11888, 15025},
  381. {22288, 142173, 140973, -11888, 55698},
  382. {22289, 143210, 140577, -11888, 17164},
  383. {22289, 142638, 140107, -11888, 6571},
  384. {22297, 142547, 140938, -11888, 48556},
  385. {22298, 142690, 140479, -11887, 7663}
  386. };
  387. private static int[][] ROOM2_SPAWNS =
  388. {
  389. {22303, 146276, 141483, -11880, 34643},
  390. {22287, 145707, 142161, -11880, 28799},
  391. {22288, 146857, 142129, -11880, 33647},
  392. {22288, 146869, 142000, -11880, 31215},
  393. {22289, 146897, 140880, -11880, 19210}
  394. };
  395. private static int[][] ROOM3_SPAWNS =
  396. {
  397. {22302, 145123, 143713, -12808, 65323},
  398. {22294, 145188, 143331, -12808, 496},
  399. {22294, 145181, 144104, -12808, 64415},
  400. {22293, 144994, 143431, -12808, 65431},
  401. {22293, 144976, 143915, -12808, 61461}
  402. };
  403. private static int[][] ROOM4_SPAWNS =
  404. {
  405. {22304, 150563, 142240, -12108, 16454},
  406. {22294, 150769, 142495, -12108, 16870},
  407. {22281, 150783, 141995, -12108, 20033},
  408. {22283, 150273, 141983, -12108, 16043},
  409. {22294, 150276, 142492, -12108, 13540}
  410. };
  411. // Steam Corridor
  412. private static int[][] STEAM1_SPAWNS =
  413. {
  414. {22305, 145260, 152387, -12165, 32767},
  415. {22305, 144967, 152390, -12165, 30464},
  416. {22305, 145610, 152586, -12165, 17107},
  417. {22305, 145620, 152397, -12165, 8191},
  418. {22418, 146081, 152847, -12165, 31396},
  419. {22418, 146795, 152641, -12165, 33850},
  420. // {22308, 145093, 152502, -12165, 31841},
  421. // {22308, 146158, 152776, -12165, 30810},
  422. // {22308, 146116, 152976, -12133, 32571}
  423. };
  424. private static int[][] STEAM2_SPAWNS =
  425. {
  426. {22306, 147740, 152767, -12165, 65043},
  427. {22306, 148215, 152828, -12165, 970},
  428. {22306, 147743, 152846, -12165, 64147},
  429. // {22308, 147849, 152854, -12165, 60534},
  430. // {22308, 147754, 152908, -12141, 59827},
  431. // {22308, 148194, 152681, -12165, 63620},
  432. // {22308, 147767, 152939, -12133, 63381},
  433. // {22309, 147737, 152671, -12165, 65320},
  434. {22418, 148207, 152725, -12165, 61801},
  435. {22419, 149058, 152828, -12165, 64564}
  436. };
  437. private static int[][] STEAM3_SPAWNS =
  438. {
  439. {22307, 150735, 152316, -12145, 31930},
  440. {22307, 150725, 152467, -12165, 33635},
  441. {22307, 151058, 152316, -12146, 65342},
  442. {22307, 151057, 152461, -12165, 2171},
  443. // {22308, 150794, 152455, -12165, 31613},
  444. // {22308, 150665, 152383, -12165, 32767},
  445. // {22308, 151697, 152621, -12167, 31423},
  446. // {22309, 151061, 152581, -12165, 6228},
  447. // {22309, 150653, 152253, -12132, 31343},
  448. // {22309, 150628, 152431, -12165, 33022},
  449. // {22309, 151620, 152487, -12165, 30114},
  450. // {22309, 151672, 152544, -12165, 31846},
  451. // {22309, 150488, 152350, -12165, 29072},
  452. // {22310, 151139, 152238, -12132, 1069}
  453. };
  454. private static int[][] STEAM4_SPAWNS =
  455. {
  456. // {22308, 151707, 150199, -12165, 32859},
  457. // {22308, 152091, 150140, -12165, 32938},
  458. // {22308, 149757, 150204, -12138, 65331},
  459. // {22308, 149950, 150307, -12132, 62437},
  460. // {22308, 149901, 150322, -12132, 62136},
  461. // {22309, 150071, 150173, -12165, 64943},
  462. {22416, 151636, 150280, -12142, 36869},
  463. {22416, 149893, 150232, -12165, 64258},
  464. {22416, 149864, 150110, -12165, 65054},
  465. {22416, 151926, 150218, -12165, 31613},
  466. {22420, 149986, 150051, -12165, 105},
  467. {22420, 151970, 149997, -12165, 32170},
  468. {22420, 150744, 150006, -12165, 63},
  469. // {22417, 149782, 150188, -12151, 64001}
  470. };
  471. // @formatter:on
  472. private static final int DRAGONSCALETIME = 3000;
  473. private static final int DRAGONCLAWTIME = 3000;
  474. public CrystalCaverns()
  475. {
  476. super(CrystalCaverns.class.getSimpleName());
  477. addStartNpc(ORACLE_GUIDE_1, ORACLE_GUIDE_4);
  478. addTalkId(ORACLE_GUIDE_1, ORACLE_GUIDE_3, ORACLE_GUIDE_4, 32275, 32276, 32277);
  479. addFirstTalkId(ORACLE_GUIDE_1, ORACLE_GUIDE_2, ORACLE_GUIDE_4, CRYSTAL_GOLEM, 32274, 32275, 32276, 32277);
  480. addKillId(TEARS, GK1, GK2, TEROD, WEYLIN, DOLPH, DARNEL, KECHI, GUARDIAN, GUARDIAN2, TOURMALINE, BAYLOR, ALARMID);
  481. addSkillSeeId(BAYLOR, 25534, 32275, 32276, 32277);
  482. addTrapActionId(DOOR_OPENING_TRAP[0]);
  483. addSpellFinishedId(BAYLOR);
  484. addAttackId(TEARS);
  485. addKillId(MOBLIST);
  486. addKillId(CGMOBS);
  487. for (int zones : ZONES)
  488. {
  489. addEnterZoneId(zones);
  490. addExitZoneId(zones);
  491. }
  492. }
  493. @Override
  494. protected boolean checkConditions(L2PcInstance player)
  495. {
  496. if (debug || player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  497. {
  498. if (debug)
  499. {
  500. return true;
  501. }
  502. }
  503. final L2Party party = player.getParty();
  504. if (party == null)
  505. {
  506. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  507. return false;
  508. }
  509. if (party.getLeader() != player)
  510. {
  511. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  512. return false;
  513. }
  514. for (L2PcInstance partyMember : party.getMembers())
  515. {
  516. if (partyMember.getLevel() < 78)
  517. {
  518. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
  519. sm.addPcName(partyMember);
  520. party.broadcastPacket(sm);
  521. return false;
  522. }
  523. L2ItemInstance item = partyMember.getInventory().getItemByItemId(CONT_CRYSTAL);
  524. if (item == null)
  525. {
  526. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  527. sm.addPcName(partyMember);
  528. party.broadcastPacket(sm);
  529. return false;
  530. }
  531. if (!Util.checkIfInRange(1000, player, partyMember, true))
  532. {
  533. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  534. sm.addPcName(partyMember);
  535. party.broadcastPacket(sm);
  536. return false;
  537. }
  538. Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
  539. if (System.currentTimeMillis() < reentertime)
  540. {
  541. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
  542. sm.addPcName(partyMember);
  543. party.broadcastPacket(sm);
  544. return false;
  545. }
  546. }
  547. return true;
  548. }
  549. private boolean checkOracleConditions(L2PcInstance player)
  550. {
  551. if (debug)
  552. {
  553. return true;
  554. }
  555. L2Party party = player.getParty();
  556. if (party == null)
  557. {
  558. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  559. return false;
  560. }
  561. if (party.getLeader() != player)
  562. {
  563. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  564. return false;
  565. }
  566. for (L2PcInstance partyMember : party.getMembers())
  567. {
  568. L2ItemInstance item = partyMember.getInventory().getItemByItemId(RED_CORAL);
  569. if (item == null)
  570. {
  571. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  572. sm.addPcName(partyMember);
  573. party.broadcastPacket(sm);
  574. return false;
  575. }
  576. if (!Util.checkIfInRange(1000, player, partyMember, true))
  577. {
  578. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  579. sm.addPcName(partyMember);
  580. party.broadcastPacket(sm);
  581. return false;
  582. }
  583. }
  584. return true;
  585. }
  586. private boolean checkBaylorConditions(L2PcInstance player)
  587. {
  588. L2Party party = player.getParty();
  589. if (party == null)
  590. {
  591. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  592. return false;
  593. }
  594. if (party.getLeader() != player)
  595. {
  596. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  597. return false;
  598. }
  599. for (L2PcInstance partyMember : party.getMembers())
  600. {
  601. L2ItemInstance item1 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_1);
  602. L2ItemInstance item2 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_2);
  603. L2ItemInstance item3 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_3);
  604. if ((item1 == null) || (item2 == null) || (item3 == null))
  605. {
  606. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
  607. sm.addPcName(partyMember);
  608. party.broadcastPacket(sm);
  609. return false;
  610. }
  611. if (!Util.checkIfInRange(1000, player, partyMember, true))
  612. {
  613. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  614. sm.addPcName(partyMember);
  615. party.broadcastPacket(sm);
  616. return false;
  617. }
  618. }
  619. return true;
  620. }
  621. // this should be handled from skill effect
  622. private void Throw(L2Character effector, L2Character effected)
  623. {
  624. // Get current position of the L2Character
  625. final int curX = effected.getX();
  626. final int curY = effected.getY();
  627. final int curZ = effected.getZ();
  628. // Calculate distance between effector and effected current position
  629. double dx = effector.getX() - curX;
  630. double dy = effector.getY() - curY;
  631. double dz = effector.getZ() - curZ;
  632. double distance = Math.sqrt((dx * dx) + (dy * dy));
  633. int offset = Math.min((int) distance + 300, 1400);
  634. double cos;
  635. double sin;
  636. // approximation for moving futher when z coordinates are different
  637. // TODO: handle Z axis movement better
  638. offset += Math.abs(dz);
  639. if (offset < 5)
  640. {
  641. offset = 5;
  642. }
  643. if (distance < 1)
  644. {
  645. return;
  646. }
  647. // Calculate movement angles needed
  648. sin = dy / distance;
  649. cos = dx / distance;
  650. // Calculate the new destination with offset included
  651. int _x = effector.getX() - (int) (offset * cos);
  652. int _y = effector.getY() - (int) (offset * sin);
  653. int _z = effected.getZ();
  654. Location destination = GeoData.getInstance().moveCheck(effected.getX(), effected.getY(), effected.getZ(), _x, _y, _z, effected.getInstanceId());
  655. effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP));
  656. // maybe is need force set X,Y,Z
  657. effected.setXYZ(destination);
  658. effected.broadcastPacket(new ValidateLocation(effected));
  659. }
  660. @Override
  661. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  662. {
  663. if (firstEntrance)
  664. {
  665. if (player.getParty() == null)
  666. {
  667. // this can happen only if debug is true
  668. player.sendMessage("Welcome to Crystal Caverns.");
  669. teleportPlayer(player, START_LOC, world.getInstanceId());
  670. world.addAllowed(player.getObjectId());
  671. }
  672. else
  673. {
  674. for (L2PcInstance partyMember : player.getParty().getMembers())
  675. {
  676. partyMember.sendMessage("Welcome to Crystal Caverns.");
  677. teleportPlayer(partyMember, START_LOC, world.getInstanceId());
  678. world.addAllowed(partyMember.getObjectId());
  679. }
  680. }
  681. runOracle((CCWorld) world);
  682. }
  683. else
  684. {
  685. teleportPlayer(player, START_LOC, world.getInstanceId());
  686. }
  687. }
  688. protected void stopAttack(L2PcInstance player)
  689. {
  690. player.setTarget(null);
  691. player.abortAttack();
  692. player.abortCast();
  693. player.breakAttack();
  694. player.breakCast();
  695. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  696. L2Summon pet = player.getSummon();
  697. if (pet != null)
  698. {
  699. pet.setTarget(null);
  700. pet.abortAttack();
  701. pet.abortCast();
  702. pet.breakAttack();
  703. pet.breakCast();
  704. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  705. }
  706. }
  707. protected void runOracle(CCWorld world)
  708. {
  709. world.setStatus(0);
  710. world.oracle.add(addSpawn(ORACLE_GUIDE_1, 143172, 148894, -11975, 0, false, 0, false, world.getInstanceId()));
  711. }
  712. protected void runEmerald(CCWorld world)
  713. {
  714. world.setStatus(1);
  715. runFirst(world);
  716. openDoor(DOOR1, world.getInstanceId());
  717. }
  718. protected void runCoral(CCWorld world)
  719. {
  720. world.setStatus(1);
  721. runHall(world);
  722. openDoor(DOOR2, world.getInstanceId());
  723. openDoor(DOOR5, world.getInstanceId());
  724. }
  725. protected void runHall(CCWorld world)
  726. {
  727. world.setStatus(2);
  728. for (int[] spawn : HALL_SPAWNS)
  729. {
  730. L2Npc mob = addSpawn(CGMOBS[getRandom(CGMOBS.length)], spawn[0], spawn[1], spawn[2], spawn[3], false, 0, false, world.getInstanceId());
  731. world.npcList1.put(mob, false);
  732. }
  733. }
  734. protected void runFirst(CCWorld world)
  735. {
  736. world.setStatus(2);
  737. world.keyKeepers.add(addSpawn(GK1, 148206, 149486, -12140, 32308, false, 0, false, world.getInstanceId()));
  738. world.keyKeepers.add(addSpawn(GK2, 148203, 151093, -12140, 31100, false, 0, false, world.getInstanceId()));
  739. for (int[] spawn : FIRST_SPAWNS)
  740. {
  741. addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  742. }
  743. }
  744. protected void runEmeraldSquare(CCWorld world)
  745. {
  746. world.setStatus(3);
  747. Map<L2Npc, Boolean> spawnList = new HashMap<>();
  748. for (int[] spawn : EMERALD_SPAWNS)
  749. {
  750. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  751. spawnList.put(mob, false);
  752. }
  753. world.npcList2.put(0, spawnList);
  754. }
  755. protected void runEmeraldRooms(CCWorld world, int[][] spawnList, int room)
  756. {
  757. Map<L2Npc, Boolean> spawned = new HashMap<>();
  758. for (int[] spawn : spawnList)
  759. {
  760. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  761. spawned.put(mob, false);
  762. }
  763. if (room == 1)
  764. {
  765. addSpawn(32359, 142110, 139896, -11888, 8033, false, 0, false, world.getInstanceId());
  766. }
  767. world.npcList2.put(room, spawned);
  768. world.roomsStatus[room - 1] = 1;
  769. }
  770. protected void runDarnel(CCWorld world)
  771. {
  772. world.setStatus(9);
  773. addSpawn(DARNEL, 152759, 145949, -12588, 21592, false, 0, false, world.getInstanceId());
  774. // TODO: missing traps
  775. openDoor(24220005, world.getInstanceId());
  776. openDoor(24220006, world.getInstanceId());
  777. }
  778. protected void runSteamRooms(CCWorld world, int[][] spawnList, int status)
  779. {
  780. world.setStatus(status);
  781. Map<L2Npc, Boolean> spawned = new HashMap<>();
  782. for (int[] spawn : spawnList)
  783. {
  784. L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
  785. spawned.put(mob, false);
  786. }
  787. world.npcList2.put(0, spawned);
  788. }
  789. protected void runSteamOracles(CCWorld world, int[][] oracleOrder)
  790. {
  791. world.oracles.clear();
  792. for (int[] oracle : oracleOrder)
  793. {
  794. world.oracles.put(addSpawn(oracle[0], oracle[1], oracle[2], oracle[3], oracle[4], false, 0, false, world.getInstanceId()), null);
  795. }
  796. }
  797. protected boolean checkKillProgress(int room, L2Npc mob, CCWorld world)
  798. {
  799. if (world.npcList2.get(room).containsKey(mob))
  800. {
  801. world.npcList2.get(room).put(mob, true);
  802. }
  803. for (boolean isDead : world.npcList2.get(room).values())
  804. {
  805. if (!isDead)
  806. {
  807. return false;
  808. }
  809. }
  810. return true;
  811. }
  812. /*
  813. * 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
  814. * 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
  815. * 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
  816. * 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); }
  817. */
  818. @Override
  819. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  820. {
  821. if (npc.getId() == ORACLE_GUIDE_1)
  822. {
  823. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  824. if (tmpworld instanceof CCWorld)
  825. {
  826. CCWorld world = (CCWorld) tmpworld;
  827. if ((world.getStatus() == 0) && world.oracle.contains(npc))
  828. {
  829. return "32281.htm";// TODO: Missing HTML.
  830. }
  831. }
  832. npc.showChatWindow(player);
  833. return null;
  834. }
  835. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277))
  836. {
  837. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  838. if (tmpworld instanceof CCWorld)
  839. {
  840. CCWorld world = (CCWorld) tmpworld;
  841. if (!world.OracleTriggered[npc.getId() - 32275])
  842. {
  843. return "no.htm"; // TODO: Missing HTML.
  844. }
  845. npc.showChatWindow(player);
  846. return null;
  847. }
  848. }
  849. else if (npc.getId() == 32274)
  850. {
  851. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  852. if (tmpworld instanceof CCWorld)
  853. {
  854. return "no.htm"; // TODO: Missing HTML.
  855. }
  856. }
  857. else if (npc.getId() == 32279)
  858. {
  859. final QuestState st = player.getQuestState(Q00131_BirdInACage.class.getSimpleName());
  860. return (st != null) && !st.isCompleted() ? "32279-01.htm" : "32279.htm";
  861. }
  862. else if (npc.getId() == CRYSTAL_GOLEM)
  863. {
  864. player.sendPacket(ActionFailed.STATIC_PACKET);
  865. }
  866. return "";
  867. }
  868. @Override
  869. public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  870. {
  871. boolean doReturn = true;
  872. for (L2Object obj : targets)
  873. {
  874. if (obj == npc)
  875. {
  876. doReturn = false;
  877. }
  878. }
  879. if (doReturn)
  880. {
  881. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  882. }
  883. switch (skill.getId())
  884. {
  885. case 1011:
  886. case 1015:
  887. case 1217:
  888. case 1218:
  889. case 1401:
  890. case 2360:
  891. case 2369:
  892. case 5146:
  893. doReturn = false;
  894. break;
  895. default:
  896. doReturn = true;
  897. }
  898. if (doReturn)
  899. {
  900. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  901. }
  902. if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && (skill.getId() != 2360) && (skill.getId() != 2369))
  903. {
  904. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  905. if ((tmpworld instanceof CCWorld) && (getRandom(100) < 15))
  906. {
  907. for (L2Npc oracle : ((CCWorld) tmpworld).oracles.keySet())
  908. {
  909. if (oracle != npc)
  910. {
  911. oracle.decayMe();
  912. }
  913. }
  914. ((CCWorld) tmpworld).OracleTriggered[npc.getId() - 32275] = true;
  915. }
  916. }
  917. else if (npc.isInvul() && (npc.getId() == BAYLOR) && (skill.getId() == 2360) && (caster != null))
  918. {
  919. if (caster.getParty() == null)
  920. {
  921. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  922. }
  923. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  924. if (tmpworld instanceof CCWorld)
  925. {
  926. CCWorld world = (CCWorld) tmpworld;
  927. if (((world._dragonClawStart + DRAGONCLAWTIME) <= System.currentTimeMillis()) || (world._dragonClawNeed <= 0))
  928. {
  929. world._dragonClawStart = System.currentTimeMillis();
  930. world._dragonClawNeed = caster.getParty().getMemberCount() - 1;
  931. }
  932. else
  933. {
  934. world._dragonClawNeed--;
  935. }
  936. if (world._dragonClawNeed == 0)
  937. {
  938. npc.stopSkillEffects(false, 5225);
  939. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5480, 1, 4000, 0));
  940. if (world._raidStatus == 3)
  941. {
  942. world._raidStatus++;
  943. }
  944. }
  945. }
  946. }
  947. else if (npc.isInvul() && (npc.getId() == TEARS) && (skill.getId() == 2369) && (caster != null))
  948. {
  949. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  950. if (tmpworld instanceof CCWorld)
  951. {
  952. CCWorld world = (CCWorld) tmpworld;
  953. if (caster.getParty() == null)
  954. {
  955. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  956. }
  957. else if (((world.dragonScaleStart + DRAGONSCALETIME) <= System.currentTimeMillis()) || (world.dragonScaleNeed <= 0))
  958. {
  959. world.dragonScaleStart = System.currentTimeMillis();
  960. world.dragonScaleNeed = caster.getParty().getMemberCount() - 1;
  961. }
  962. else
  963. {
  964. world.dragonScaleNeed--;
  965. }
  966. if ((world.dragonScaleNeed == 0) && (getRandom(100) < 80))
  967. {
  968. npc.setIsInvul(false);
  969. }
  970. }
  971. }
  972. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  973. }
  974. @Override
  975. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  976. {
  977. if (npc.getId() == TEARS)
  978. {
  979. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  980. if (tmpworld instanceof CCWorld)
  981. {
  982. CCWorld world = (CCWorld) tmpworld;
  983. if ((world.getStatus() != 4) && (attacker != null))
  984. {
  985. // Lucky cheater, the code only kicks his/her ass out of the dungeon
  986. teleportPlayer(attacker, new Location(149361, 172327, -945), 0);
  987. world.removeAllowed(attacker.getObjectId());
  988. }
  989. else if (world.tears != npc)
  990. {
  991. return "";
  992. }
  993. else if (!world.copys.isEmpty())
  994. {
  995. boolean notAOE = true;
  996. 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)))
  997. {
  998. notAOE = false;
  999. }
  1000. if (notAOE)
  1001. {
  1002. for (L2Npc copy : world.copys)
  1003. {
  1004. copy.onDecay();
  1005. }
  1006. world.copys.clear();
  1007. }
  1008. return "";
  1009. }
  1010. int maxHp = npc.getMaxHp();
  1011. double nowHp = npc.getStatus().getCurrentHp();
  1012. int rand = getRandom(1000);
  1013. if ((nowHp < (maxHp * 0.4)) && (rand < 5))
  1014. {
  1015. L2Party party = attacker.getParty();
  1016. if (party != null)
  1017. {
  1018. for (L2PcInstance partyMember : party.getMembers())
  1019. {
  1020. stopAttack(partyMember);
  1021. }
  1022. }
  1023. else
  1024. {
  1025. stopAttack(attacker);
  1026. }
  1027. L2Character target = npc.getAI().getAttackTarget();
  1028. for (int i = 0; i < 10; i++)
  1029. {
  1030. L2Npc copy = addSpawn(TEARS_COPY, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false, attacker.getInstanceId());
  1031. copy.setRunning();
  1032. ((L2Attackable) copy).addDamageHate(target, 0, 99999);
  1033. copy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  1034. copy.setCurrentHp(nowHp);
  1035. world.copys.add(copy);
  1036. }
  1037. }
  1038. else if ((nowHp < (maxHp * 0.15)) && !world.isUsedInvulSkill)
  1039. {
  1040. if ((rand > 994) || (nowHp < (maxHp * 0.1)))
  1041. {
  1042. world.isUsedInvulSkill = true;
  1043. npc.setIsInvul(true);
  1044. }
  1045. }
  1046. }
  1047. }
  1048. return null;
  1049. }
  1050. @Override
  1051. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  1052. {
  1053. if ((npc.getId() == BAYLOR) && (skill.getId() == 5225))
  1054. {
  1055. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1056. if (tmpworld instanceof CCWorld)
  1057. {
  1058. ((CCWorld) tmpworld)._raidStatus++;
  1059. }
  1060. }
  1061. return super.onSpellFinished(npc, player, skill);
  1062. }
  1063. @Override
  1064. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  1065. {
  1066. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1067. if (tmpworld instanceof CCWorld)
  1068. {
  1069. CCWorld world = (CCWorld) tmpworld;
  1070. if (event.equalsIgnoreCase("TeleportOut"))
  1071. {
  1072. teleportPlayer(player, new Location(149413, 173078, -5014), 0);
  1073. }
  1074. else if (event.equalsIgnoreCase("TeleportParme"))
  1075. {
  1076. teleportPlayer(player, new Location(153689, 142226, -9750), world.getInstanceId());
  1077. }
  1078. else if (event.equalsIgnoreCase("Timer2") || event.equalsIgnoreCase("Timer3") || event.equalsIgnoreCase("Timer4") || event.equalsIgnoreCase("Timer5"))
  1079. {
  1080. if (player.getInstanceId() == world.getInstanceId())
  1081. {
  1082. teleportPlayer(player, new Location(144653, 152606, -12126), world.getInstanceId());
  1083. player.stopSkillEffects(true, 5239);
  1084. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  1085. startQuestTimer("Timer2", 300000, npc, player);
  1086. }
  1087. }
  1088. else if (event.equalsIgnoreCase("Timer21") || event.equalsIgnoreCase("Timer31") || event.equalsIgnoreCase("Timer41") || event.equalsIgnoreCase("Timer51"))
  1089. {
  1090. InstanceManager.getInstance().getInstance(world.getInstanceId()).removeNpcs();
  1091. world.npcList2.clear();
  1092. runSteamRooms(world, STEAM1_SPAWNS, 22);
  1093. startQuestTimer("Timer21", 300000, npc, null);
  1094. }
  1095. else if (event.equalsIgnoreCase("checkKechiAttack"))
  1096. {
  1097. if (npc.isInCombat())
  1098. {
  1099. startQuestTimer("spawnGuards", SPAWN[0], npc, null);
  1100. cancelQuestTimers("checkKechiAttack");
  1101. closeDoor(DOOR4, npc.getInstanceId());
  1102. closeDoor(DOOR3, npc.getInstanceId());
  1103. }
  1104. else
  1105. {
  1106. startQuestTimer("checkKechiAttack", 1000, npc, null);
  1107. }
  1108. }
  1109. else if (event.equalsIgnoreCase("spawnGuards"))
  1110. {
  1111. world.kechisHenchmanSpawn++;
  1112. world.guards.add(addSpawn(KECHIGUARD, 153622, 149699, -12131, 56890, false, 0, false, world.getInstanceId()));
  1113. world.guards.add(addSpawn(KECHIGUARD, 153609, 149622, -12131, 64023, false, 0, false, world.getInstanceId()));
  1114. world.guards.add(addSpawn(KECHIGUARD, 153606, 149428, -12131, 64541, false, 0, false, world.getInstanceId()));
  1115. world.guards.add(addSpawn(KECHIGUARD, 153601, 149534, -12131, 64901, false, 0, false, world.getInstanceId()));
  1116. world.guards.add(addSpawn(KECHIGUARD, 153620, 149354, -12131, 1164, false, 0, false, world.getInstanceId()));
  1117. world.guards.add(addSpawn(KECHIGUARD, 153637, 149776, -12131, 61733, false, 0, false, world.getInstanceId()));
  1118. world.guards.add(addSpawn(KECHIGUARD, 153638, 149292, -12131, 64071, false, 0, false, world.getInstanceId()));
  1119. world.guards.add(addSpawn(KECHIGUARD, 153647, 149857, -12131, 59402, false, 0, false, world.getInstanceId()));
  1120. world.guards.add(addSpawn(KECHIGUARD, 153661, 149227, -12131, 65275, false, 0, false, world.getInstanceId()));
  1121. if (world.kechisHenchmanSpawn <= 5)
  1122. {
  1123. startQuestTimer("spawnGuards", SPAWN[world.kechisHenchmanSpawn], npc, null);
  1124. }
  1125. else
  1126. {
  1127. cancelQuestTimers("spawnGuards");
  1128. }
  1129. }
  1130. else if (event.equalsIgnoreCase("EmeraldSteam"))
  1131. {
  1132. runEmerald(world);
  1133. for (L2Npc oracle : world.oracle)
  1134. {
  1135. oracle.decayMe();
  1136. }
  1137. }
  1138. else if (event.equalsIgnoreCase("CoralGarden"))
  1139. {
  1140. runCoral(world);
  1141. for (L2Npc oracle : world.oracle)
  1142. {
  1143. oracle.decayMe();
  1144. }
  1145. }
  1146. else if (event.equalsIgnoreCase("spawn_oracle"))
  1147. {
  1148. addSpawn(32271, 153572, 142075, -9728, 10800, false, 0, false, world.getInstanceId());
  1149. addSpawn((getRandom(10) < 5 ? 29116 : 29117), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, world.getInstanceId()); // Baylor's Chest
  1150. addSpawn(ORACLE_GUIDE_4, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  1151. cancelQuestTimer("baylor_despawn", npc, null);
  1152. cancelQuestTimers("baylor_skill");
  1153. }
  1154. else if (event.equalsIgnoreCase("baylorEffect0"))
  1155. {
  1156. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1157. npc.broadcastSocialAction(1);
  1158. startQuestTimer("baylorCamera0", 11000, npc, null);
  1159. startQuestTimer("baylorEffect1", 19000, npc, null);
  1160. }
  1161. else if (event.equalsIgnoreCase("baylorCamera0"))
  1162. {
  1163. npc.broadcastPacket(new SpecialCamera(npc, 500, -45, 170, 5000, 9000, 0, 0, 1, 0, 0));
  1164. }
  1165. else if (event.equalsIgnoreCase("baylorEffect1"))
  1166. {
  1167. npc.broadcastPacket(new SpecialCamera(npc, 300, 0, 120, 2000, 5000, 0, 0, 1, 0, 0));
  1168. npc.broadcastSocialAction(3);
  1169. startQuestTimer("baylorEffect2", 4000, npc, null);
  1170. }
  1171. else if (event.equalsIgnoreCase("baylorEffect2"))
  1172. {
  1173. npc.broadcastPacket(new SpecialCamera(npc, 747, 0, 160, 2000, 3000, 0, 0, 1, 0, 0));
  1174. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5402, 1, 2000, 0));
  1175. startQuestTimer("RaidStart", 2000, npc, null);
  1176. }
  1177. else if (event.equalsIgnoreCase("BaylorMinions"))
  1178. {
  1179. for (int i = 0; i < 10; i++)
  1180. {
  1181. int radius = 300;
  1182. int x = (int) (radius * Math.cos(i * 0.618));
  1183. int y = (int) (radius * Math.sin(i * 0.618));
  1184. L2Npc mob = addSpawn(29104, 153571 + x, 142075 + y, -12737, 0, false, 0, false, world.getInstanceId());
  1185. mob.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  1186. world._animationMobs.add(mob);
  1187. }
  1188. startQuestTimer("baylorEffect0", 200, npc, null);
  1189. }
  1190. else if (event.equalsIgnoreCase("RaidStart"))
  1191. {
  1192. world._camera.decayMe();
  1193. world._camera = null;
  1194. npc.setIsParalyzed(false);
  1195. for (L2PcInstance p : world._raiders)
  1196. {
  1197. p.setIsParalyzed(false);
  1198. Throw(npc, p);
  1199. if (p.getSummon() != null)
  1200. {
  1201. Throw(npc, p.getSummon());
  1202. }
  1203. }
  1204. world._raidStatus = 0;
  1205. for (L2Npc mob : world._animationMobs)
  1206. {
  1207. mob.doDie(mob);
  1208. }
  1209. world._animationMobs.clear();
  1210. startQuestTimer("baylor_despawn", 60000, npc, null, true);
  1211. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  1212. }
  1213. else if (event.equalsIgnoreCase("checkBaylorAttack"))
  1214. {
  1215. if (npc.isInCombat())
  1216. {
  1217. cancelQuestTimers("checkBaylorAttack");
  1218. startQuestTimer("baylor_alarm", 40000, npc, null);
  1219. startQuestTimer("baylor_skill", 5000, npc, null, true);
  1220. world._raidStatus++;
  1221. }
  1222. else
  1223. {
  1224. startQuestTimer("checkBaylorAttack", 1000, npc, null);
  1225. }
  1226. }
  1227. else if (event.equalsIgnoreCase("baylor_alarm"))
  1228. {
  1229. if (world._alarm == null)
  1230. {
  1231. int[] spawnLoc = ALARMSPAWN[getRandom(ALARMSPAWN.length)];
  1232. npc.addSkill(SkillData.getInstance().getSkill(5244, 1));
  1233. npc.addSkill(SkillData.getInstance().getSkill(5245, 1));
  1234. world._alarm = addSpawn(ALARMID, spawnLoc[0], spawnLoc[1], spawnLoc[2], 10800, false, 0, false, world.getInstanceId());
  1235. world._alarm.disableCoreAI(true);
  1236. world._alarm.setIsImmobilized(true);
  1237. 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));
  1238. }
  1239. }
  1240. else if (event.equalsIgnoreCase("baylor_skill"))
  1241. {
  1242. if (world._baylor == null)
  1243. {
  1244. cancelQuestTimers("baylor_skill");
  1245. }
  1246. else
  1247. {
  1248. int maxHp = npc.getMaxHp();
  1249. double nowHp = npc.getStatus().getCurrentHp();
  1250. int rand = getRandom(100);
  1251. if ((nowHp < (maxHp * 0.2)) && (world._raidStatus < 3) && !npc.isAffectedBySkill(5224) && !npc.isAffectedBySkill(5225))
  1252. {
  1253. if ((nowHp < (maxHp * 0.15)) && (world._raidStatus == 2))
  1254. {
  1255. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  1256. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  1257. }
  1258. else if ((rand < 10) || (nowHp < (maxHp * 0.15)))
  1259. {
  1260. npc.doCast(SkillData.getInstance().getSkill(5225, 1));
  1261. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
  1262. startQuestTimer("baylor_remove_invul", 30000, world._baylor, null);
  1263. }
  1264. }
  1265. else if ((nowHp < (maxHp * 0.3)) && (rand > 50) && !npc.isAffectedBySkill(5225) && !npc.isAffectedBySkill(5224))
  1266. {
  1267. npc.doCast(SkillData.getInstance().getSkill(5224, 1));
  1268. }
  1269. else if (rand < 33)
  1270. {
  1271. npc.setTarget(world._raiders.get(getRandom(world._raiders.size())));
  1272. npc.doCast(SkillData.getInstance().getSkill(5229, 1));
  1273. }
  1274. }
  1275. }
  1276. else if (event.equalsIgnoreCase("baylor_remove_invul"))
  1277. {
  1278. npc.stopSkillEffects(false, 5225);
  1279. }
  1280. else if (event.equalsIgnoreCase("Baylor"))
  1281. {
  1282. world._baylor = addSpawn(29099, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
  1283. world._baylor.setIsParalyzed(true);
  1284. world._camera = addSpawn(29120, 153273, 141400, -12738, 10800, false, 0, false, world.getInstanceId());
  1285. world._camera.broadcastPacket(new SpecialCamera(world._camera, 700, -45, 160, 500, 15200, 0, 0, 1, 0, 0));
  1286. startQuestTimer("baylorMinions", 2000, world._baylor, null);
  1287. }
  1288. else if (!event.endsWith("Food"))
  1289. {
  1290. return "";
  1291. }
  1292. else if (event.equalsIgnoreCase("autoFood"))
  1293. {
  1294. if (!world.crystalGolems.containsKey(npc))
  1295. {
  1296. world.crystalGolems.put(npc, new CrystalGolem());
  1297. }
  1298. if ((world.getStatus() != 3) || !world.crystalGolems.containsKey(npc) || (world.crystalGolems.get(npc).foodItem != null) || world.crystalGolems.get(npc).isAtDestination)
  1299. {
  1300. return "";
  1301. }
  1302. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1303. int minDist = 300000;
  1304. for (L2Object object : L2World.getInstance().getVisibleObjects(npc, 300))
  1305. {
  1306. if (object.isItem() && (object.getId() == CRYSTALFOOD))
  1307. {
  1308. int dx = npc.getX() - object.getX();
  1309. int dy = npc.getY() - object.getY();
  1310. int d = (dx * dx) + (dy * dy);
  1311. if (d < minDist)
  1312. {
  1313. minDist = d;
  1314. cryGolem.foodItem = (L2ItemInstance) object;
  1315. }
  1316. }
  1317. }
  1318. if (minDist != 300000)
  1319. {
  1320. startQuestTimer("getFood", 2000, npc, null);
  1321. }
  1322. else
  1323. {
  1324. if (getRandom(100) < 5)
  1325. {
  1326. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.AH_IM_HUNGRY));
  1327. }
  1328. startQuestTimer("autoFood", 2000, npc, null);
  1329. }
  1330. return "";
  1331. }
  1332. else if (!world.crystalGolems.containsKey(npc) || world.crystalGolems.get(npc).isAtDestination)
  1333. {
  1334. return "";
  1335. }
  1336. else if (event.equalsIgnoreCase("backFood"))
  1337. {
  1338. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  1339. {
  1340. cancelQuestTimers("backFood");
  1341. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  1342. world.crystalGolems.get(npc).foodItem = null;
  1343. startQuestTimer("autoFood", 2000, npc, null);
  1344. }
  1345. }
  1346. else if (event.equalsIgnoreCase("reachFood"))
  1347. {
  1348. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1349. int dx;
  1350. int dy;
  1351. if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isVisible())
  1352. {
  1353. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, cryGolem.oldLoc);
  1354. cancelQuestTimers("reachFood");
  1355. startQuestTimer("backFood", 2000, npc, null, true);
  1356. return "";
  1357. }
  1358. else if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
  1359. {
  1360. L2World.getInstance().removeVisibleObject(cryGolem.foodItem, cryGolem.foodItem.getWorldRegion());
  1361. L2World.getInstance().removeObject(cryGolem.foodItem);
  1362. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
  1363. cryGolem.foodItem = null;
  1364. dx = npc.getX() - 142999;
  1365. dy = npc.getY() - 151671;
  1366. int d1 = (dx * dx) + (dy * dy);
  1367. dx = npc.getX() - 139494;
  1368. dy = npc.getY() - 151668;
  1369. int d2 = (dx * dx) + (dy * dy);
  1370. if ((d1 < 10000) || (d2 < 10000))
  1371. {
  1372. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  1373. cryGolem.isAtDestination = true;
  1374. world.correctGolems++;
  1375. if (world.correctGolems >= 2)
  1376. {
  1377. openDoor(24220026, world.getInstanceId());
  1378. world.setStatus(4);
  1379. }
  1380. }
  1381. else
  1382. {
  1383. startQuestTimer("autoFood", 2000, npc, null);
  1384. }
  1385. cancelQuestTimers("reachFood");
  1386. }
  1387. return "";
  1388. }
  1389. else if (event.equalsIgnoreCase("getFood"))
  1390. {
  1391. CrystalGolem cryGolem = world.crystalGolems.get(npc);
  1392. Location newLoc = new Location(cryGolem.foodItem.getX(), cryGolem.foodItem.getY(), cryGolem.foodItem.getZ(), 0);
  1393. cryGolem.oldLoc = new Location(npc.getX(), npc.getY(), npc.getZ(), npc.getHeading());
  1394. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newLoc);
  1395. startQuestTimer("reachFood", 2000, npc, null, true);
  1396. cancelQuestTimers("getFood");
  1397. }
  1398. }
  1399. return "";
  1400. }
  1401. private void giveRewards(L2PcInstance player, int instanceId, int bossCry, boolean isBaylor)
  1402. {
  1403. final int num = Math.max((int) Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER, 1);
  1404. L2Party party = player.getParty();
  1405. if (party != null)
  1406. {
  1407. for (L2PcInstance partyMember : party.getMembers())
  1408. {
  1409. if (partyMember.getInstanceId() == instanceId)
  1410. {
  1411. if (!isBaylor && hasQuestItems(partyMember, CONT_CRYSTAL))
  1412. {
  1413. takeItems(partyMember, CONT_CRYSTAL, 1);
  1414. giveItems(partyMember, bossCry, 1);
  1415. }
  1416. if (getRandom(10) < 5)
  1417. {
  1418. giveItems(partyMember, WHITE_SEED, num);
  1419. }
  1420. else
  1421. {
  1422. giveItems(partyMember, BLACK_SEED, num);
  1423. }
  1424. }
  1425. }
  1426. }
  1427. else if (player.getInstanceId() == instanceId)
  1428. {
  1429. if (!isBaylor && hasQuestItems(player, CONT_CRYSTAL))
  1430. {
  1431. takeItems(player, CONT_CRYSTAL, 1);
  1432. giveItems(player, bossCry, 1);
  1433. }
  1434. if (getRandom(10) < 5)
  1435. {
  1436. giveItems(player, WHITE_SEED, num);
  1437. }
  1438. else
  1439. {
  1440. giveItems(player, BLACK_SEED, num);
  1441. }
  1442. }
  1443. }
  1444. @Override
  1445. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  1446. {
  1447. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1448. if (tmpworld instanceof CCWorld)
  1449. {
  1450. CCWorld world = (CCWorld) tmpworld;
  1451. if ((world.getStatus() == 2) && world.npcList1.containsKey(npc))
  1452. {
  1453. world.npcList1.put(npc, true);
  1454. for (boolean isDead : world.npcList1.values())
  1455. {
  1456. if (!isDead)
  1457. {
  1458. return "";
  1459. }
  1460. }
  1461. world.setStatus(3);
  1462. world.tears = addSpawn(TEARS, 144298, 154420, -11854, 32767, false, 0, false, world.getInstanceId()); // Tears
  1463. CrystalGolem crygolem1 = new CrystalGolem();
  1464. CrystalGolem crygolem2 = new CrystalGolem();
  1465. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 140547, 151670, -11813, 32767, false, 0, false, world.getInstanceId()), crygolem1);
  1466. world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 141941, 151684, -11813, 63371, false, 0, false, world.getInstanceId()), crygolem2);
  1467. for (L2Npc crygolem : world.crystalGolems.keySet())
  1468. {
  1469. startQuestTimer("autoFood", 2000, crygolem, null);
  1470. }
  1471. }
  1472. else if ((world.getStatus() == 4) && (npc.getId() == TEARS))
  1473. {
  1474. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  1475. addSpawn(32280, 144312, 154420, -11855, 0, false, 0, false, world.getInstanceId());
  1476. giveRewards(player, npc.getInstanceId(), BOSS_CRYSTAL_3, false);
  1477. }
  1478. else if ((world.getStatus() == 2) && world.keyKeepers.contains(npc))
  1479. {
  1480. if (npc.getId() == GK1)
  1481. {
  1482. npc.dropItem(player, 9698, 1);
  1483. runEmeraldSquare(world);
  1484. }
  1485. else if (npc.getId() == GK2)
  1486. {
  1487. npc.dropItem(player, 9699, 1);
  1488. runSteamRooms(world, STEAM1_SPAWNS, 22);
  1489. L2Party party = player.getParty();
  1490. if (party != null)
  1491. {
  1492. for (L2PcInstance partyMember : party.getMembers())
  1493. {
  1494. if (partyMember.getInstanceId() == world.getInstanceId())
  1495. {
  1496. SkillData.getInstance().getSkill(5239, 1).applyEffects(partyMember, partyMember);
  1497. startQuestTimer("Timer2", 300000, npc, partyMember);
  1498. }
  1499. }
  1500. }
  1501. else
  1502. {
  1503. SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
  1504. startQuestTimer("Timer2", 300000, npc, player);
  1505. }
  1506. startQuestTimer("Timer21", 300000, npc, null);
  1507. }
  1508. for (L2Npc gk : world.keyKeepers)
  1509. {
  1510. if (gk != npc)
  1511. {
  1512. gk.decayMe();
  1513. }
  1514. }
  1515. }
  1516. else if (world.getStatus() == 3)
  1517. {
  1518. if (checkKillProgress(0, npc, world))
  1519. {
  1520. world.setStatus(4);
  1521. addSpawn(TOURMALINE, 148202, 144791, -12235, 0, false, 0, false, world.getInstanceId());
  1522. }
  1523. else
  1524. {
  1525. return "";
  1526. }
  1527. }
  1528. else if (world.getStatus() == 4)
  1529. {
  1530. if (npc.getId() == TOURMALINE)
  1531. {
  1532. world.setStatus(5);
  1533. addSpawn(TEROD, 147777, 146780, -12281, 0, false, 0, false, world.getInstanceId());
  1534. }
  1535. }
  1536. else if (world.getStatus() == 5)
  1537. {
  1538. if (npc.getId() == TEROD)
  1539. {
  1540. world.setStatus(6);
  1541. addSpawn(TOURMALINE, 143694, 142659, -11882, 0, false, 0, false, world.getInstanceId());
  1542. }
  1543. }
  1544. else if (world.getStatus() == 6)
  1545. {
  1546. if (npc.getId() == TOURMALINE)
  1547. {
  1548. world.setStatus(7);
  1549. addSpawn(DOLPH, 142054, 143288, -11825, 0, false, 0, false, world.getInstanceId());
  1550. }
  1551. }
  1552. else if (world.getStatus() == 7)
  1553. {
  1554. if (npc.getId() == DOLPH)
  1555. {
  1556. world.setStatus(8);
  1557. // first door opener trap
  1558. addTrap(DOOR_OPENING_TRAP[0], DOOR_OPENING_TRAP[1], DOOR_OPENING_TRAP[2], DOOR_OPENING_TRAP[3], DOOR_OPENING_TRAP[4], null, world.getInstanceId());
  1559. }
  1560. }
  1561. else if (world.getStatus() == 8)
  1562. {
  1563. for (int i = 0; i < 4; i++)
  1564. {
  1565. if ((world.roomsStatus[i] == 1) && checkKillProgress(i + 1, npc, world))
  1566. {
  1567. world.roomsStatus[i] = 2;
  1568. }
  1569. if (world.roomsStatus[i] == 2)
  1570. {
  1571. world.cleanedRooms++;
  1572. if (world.cleanedRooms == 21)
  1573. {
  1574. runDarnel(world);
  1575. }
  1576. }
  1577. }
  1578. }
  1579. else if ((world.getStatus() >= 22) && (world.getStatus() <= 25))
  1580. {
  1581. if (npc.getId() == 22416)
  1582. {
  1583. for (L2Npc oracle : world.oracles.keySet())
  1584. {
  1585. if (world.oracles.get(oracle) == npc)
  1586. {
  1587. world.oracles.put(oracle, null);
  1588. }
  1589. }
  1590. }
  1591. if (checkKillProgress(0, npc, world))
  1592. {
  1593. world.npcList2.clear();
  1594. int[][] oracleOrder;
  1595. switch (world.getStatus())
  1596. {
  1597. case 22:
  1598. closeDoor(DOOR6, npc.getInstanceId());
  1599. oracleOrder = ordreOracle1;
  1600. break;
  1601. case 23:
  1602. oracleOrder = ordreOracle2;
  1603. break;
  1604. case 24:
  1605. oracleOrder = ordreOracle3;
  1606. break;
  1607. case 25:
  1608. world.setStatus(26);
  1609. L2Party party = player.getParty();
  1610. if (party != null)
  1611. {
  1612. for (L2PcInstance partyMember : party.getMembers())
  1613. {
  1614. partyMember.stopSkillEffects(true, 5239);
  1615. }
  1616. }
  1617. cancelQuestTimers("Timer5");
  1618. cancelQuestTimers("Timer51");
  1619. openDoor(DOOR3, npc.getInstanceId());
  1620. openDoor(DOOR4, npc.getInstanceId());
  1621. L2Npc kechi = addSpawn(KECHI, 154069, 149525, -12158, 51165, false, 0, false, world.getInstanceId());
  1622. startQuestTimer("checkKechiAttack", 1000, kechi, null);
  1623. return "";
  1624. default:
  1625. _log.warning("CrystalCavern-SteamCorridor: status " + world.getStatus() + " error. OracleOrder not found in " + world.getInstanceId());
  1626. return "";
  1627. }
  1628. runSteamOracles(world, oracleOrder);
  1629. }
  1630. }
  1631. else if (((world.getStatus() == 9) && (npc.getId() == DARNEL)) || ((world.getStatus() == 26) && (npc.getId() == KECHI)))
  1632. {
  1633. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  1634. int bossCry;
  1635. if (npc.getId() == KECHI)
  1636. {
  1637. bossCry = BOSS_CRYSTAL_2;
  1638. cancelQuestTimers("spawnGuards");
  1639. addSpawn(32280, 154077, 149527, -12159, 0, false, 0, false, world.getInstanceId());
  1640. }
  1641. else if (npc.getId() == DARNEL)
  1642. {
  1643. bossCry = BOSS_CRYSTAL_1;
  1644. addSpawn(32280, 152761, 145950, -12588, 0, false, 0, false, world.getInstanceId());
  1645. }
  1646. else
  1647. {
  1648. // something is wrong
  1649. return "";
  1650. }
  1651. giveRewards(player, npc.getInstanceId(), bossCry, false);
  1652. }
  1653. if (npc.getId() == ALARMID)
  1654. {
  1655. world._baylor.removeSkill(5244);
  1656. world._baylor.removeSkill(5245);
  1657. world._alarm = null;
  1658. if ((world._baylor.getMaxHp() * 0.3) < world._baylor.getStatus().getCurrentHp())
  1659. {
  1660. startQuestTimer("baylor_alarm", 40000, world._baylor, null);
  1661. }
  1662. }
  1663. else if (npc.getId() == BAYLOR)
  1664. {
  1665. world.setStatus(31);
  1666. world._baylor = null;
  1667. npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  1668. Instance baylorInstance = InstanceManager.getInstance().getInstance(npc.getInstanceId());
  1669. baylorInstance.setDuration(300000);
  1670. this.startQuestTimer("spawn_oracle", 1000, npc, null);
  1671. giveRewards(player, npc.getInstanceId(), -1, true);
  1672. }
  1673. }
  1674. return "";
  1675. }
  1676. @Override
  1677. public String onTalk(L2Npc npc, L2PcInstance player)
  1678. {
  1679. int npcId = npc.getId();
  1680. QuestState st = getQuestState(player, false);
  1681. if (st == null)
  1682. {
  1683. st = newQuestState(player);
  1684. }
  1685. if (npcId == ORACLE_GUIDE_1)
  1686. {
  1687. enterInstance(player, new CCWorld(System.currentTimeMillis() + 5400000), "CrystalCaverns.xml", TEMPLATE_ID);
  1688. return "";
  1689. }
  1690. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1691. if (tmpworld instanceof CCWorld)
  1692. {
  1693. CCWorld world = (CCWorld) tmpworld;
  1694. if (npcId == CRYSTAL_GOLEM)
  1695. {
  1696. }
  1697. else if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && world.OracleTriggered[npc.getId() - 32275])
  1698. {
  1699. boolean doTeleport = false;
  1700. Location loc = null;
  1701. L2Party party = player.getParty();
  1702. doTeleport = true;
  1703. switch (npc.getId())
  1704. {
  1705. case 32275:
  1706. if (world.getStatus() == 22)
  1707. {
  1708. runSteamRooms(world, STEAM2_SPAWNS, 23);
  1709. }
  1710. loc = new Location(147529, 152587, -12169);
  1711. cancelQuestTimers("Timer2");
  1712. cancelQuestTimers("Timer21");
  1713. if (party != null)
  1714. {
  1715. for (L2PcInstance partyMember : party.getMembers())
  1716. {
  1717. if (partyMember.getInstanceId() == world.getInstanceId())
  1718. {
  1719. partyMember.stopSkillEffects(true, 5239);
  1720. SkillData.getInstance().getSkill(5239, 2).applyEffects(partyMember, partyMember);
  1721. startQuestTimer("Timer3", 600000, npc, partyMember);
  1722. }
  1723. }
  1724. }
  1725. else
  1726. {
  1727. player.stopSkillEffects(true, 5239);
  1728. SkillData.getInstance().getSkill(5239, 2).applyEffects(player, player);
  1729. startQuestTimer("Timer3", 600000, npc, player);
  1730. }
  1731. startQuestTimer("Timer31", 600000, npc, null);
  1732. break;
  1733. case 32276:
  1734. if (world.getStatus() == 23)
  1735. {
  1736. runSteamRooms(world, STEAM3_SPAWNS, 24);
  1737. }
  1738. loc = new Location(150194, 152610, -12169);
  1739. cancelQuestTimers("Timer3");
  1740. cancelQuestTimers("Timer31");
  1741. if (party != null)
  1742. {
  1743. for (L2PcInstance partyMember : party.getMembers())
  1744. {
  1745. if (partyMember.getInstanceId() == world.getInstanceId())
  1746. {
  1747. partyMember.stopSkillEffects(true, 5239);
  1748. SkillData.getInstance().getSkill(5239, 4).applyEffects(partyMember, partyMember);
  1749. startQuestTimer("Timer4", 1200000, npc, partyMember);
  1750. }
  1751. }
  1752. }
  1753. else
  1754. {
  1755. player.stopSkillEffects(true, 5239);
  1756. SkillData.getInstance().getSkill(5239, 4).applyEffects(player, player);
  1757. startQuestTimer("Timer4", 1200000, npc, player);
  1758. }
  1759. startQuestTimer("Timer41", 1200000, npc, null);
  1760. break;
  1761. case 32277:
  1762. if (world.getStatus() == 24)
  1763. {
  1764. runSteamRooms(world, STEAM4_SPAWNS, 25);
  1765. }
  1766. loc = new Location(149743, 149986, -12141);
  1767. cancelQuestTimers("Timer4");
  1768. cancelQuestTimers("Timer41");
  1769. if (party != null)
  1770. {
  1771. for (L2PcInstance partyMember : party.getMembers())
  1772. {
  1773. if (partyMember.getInstanceId() == world.getInstanceId())
  1774. {
  1775. partyMember.stopSkillEffects(true, 5239);
  1776. SkillData.getInstance().getSkill(5239, 3).applyEffects(partyMember, partyMember);
  1777. startQuestTimer("Timer5", 900000, npc, partyMember);
  1778. }
  1779. }
  1780. }
  1781. else
  1782. {
  1783. player.stopSkillEffects(true, 5239);
  1784. SkillData.getInstance().getSkill(5239, 3).applyEffects(player, player);
  1785. startQuestTimer("Timer5", 900000, npc, player);
  1786. }
  1787. startQuestTimer("Timer51", 900000, npc, null);
  1788. break;
  1789. default:
  1790. // something is wrong
  1791. doTeleport = false;
  1792. }
  1793. if (doTeleport && (loc != null))
  1794. {
  1795. if (!checkOracleConditions(player))
  1796. {
  1797. return "";
  1798. }
  1799. else if (party != null)
  1800. {
  1801. for (L2PcInstance partyMember : party.getMembers())
  1802. {
  1803. partyMember.destroyItemByItemId("Quest", RED_CORAL, 1, player, true);
  1804. teleportPlayer(partyMember, loc, npc.getInstanceId());
  1805. }
  1806. }
  1807. else
  1808. {
  1809. teleportPlayer(player, loc, npc.getInstanceId());
  1810. }
  1811. }
  1812. }
  1813. else if (npc.getId() == ORACLE_GUIDE_3)
  1814. {
  1815. if ((world.getStatus() < 30) && checkBaylorConditions(player))
  1816. {
  1817. world._raiders.clear();
  1818. L2Party party = player.getParty();
  1819. if (party == null)
  1820. {
  1821. world._raiders.add(player);
  1822. }
  1823. else
  1824. {
  1825. for (L2PcInstance partyMember : party.getMembers())
  1826. {
  1827. // int rnd = getRandom(100);
  1828. // 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.
  1829. world._raiders.add(partyMember);
  1830. }
  1831. }
  1832. }
  1833. else
  1834. {
  1835. return "";
  1836. }
  1837. world.setStatus(30);
  1838. long time = world.endTime - System.currentTimeMillis();
  1839. Instance baylorInstance = InstanceManager.getInstance().getInstance(world.getInstanceId());
  1840. baylorInstance.setDuration((int) time);
  1841. int radius = 150;
  1842. int i = 0;
  1843. int members = world._raiders.size();
  1844. for (L2PcInstance p : world._raiders)
  1845. {
  1846. int x = (int) (radius * Math.cos((i * 2 * Math.PI) / members));
  1847. int y = (int) (radius * Math.sin((i++ * 2 * Math.PI) / members));
  1848. p.teleToLocation(new Location(153571 + x, 142075 + y, -12737));
  1849. L2Summon pet = p.getSummon();
  1850. if (pet != null)
  1851. {
  1852. pet.teleToLocation(new Location(153571 + x, 142075 + y, -12737), true);
  1853. pet.broadcastPacket(new ValidateLocation(pet));
  1854. }
  1855. p.setIsParalyzed(true);
  1856. p.broadcastPacket(new ValidateLocation(p));
  1857. }
  1858. startQuestTimer("Baylor", 30000, npc, null);
  1859. }
  1860. else if ((npc.getId() == ORACLE_GUIDE_4) && (world.getStatus() == 31))
  1861. {
  1862. teleportPlayer(player, new Location(153522, 144212, -9747), npc.getInstanceId());
  1863. }
  1864. }
  1865. return "";
  1866. }
  1867. @Override
  1868. public String onTrapAction(L2TrapInstance trap, L2Character trigger, TrapAction action)
  1869. {
  1870. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
  1871. if (tmpworld instanceof CCWorld)
  1872. {
  1873. CCWorld world = (CCWorld) tmpworld;
  1874. switch (action)
  1875. {
  1876. case TRAP_DISARMED:
  1877. if (trap.getId() == DOOR_OPENING_TRAP[0])
  1878. {
  1879. openDoor(24220001, world.getInstanceId());
  1880. runEmeraldRooms(world, ROOM1_SPAWNS, 1);
  1881. }
  1882. break;
  1883. }
  1884. }
  1885. return null;
  1886. }
  1887. @Override
  1888. public String onEnterZone(L2Character character, L2ZoneType zone)
  1889. {
  1890. if (character instanceof L2PcInstance)
  1891. {
  1892. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  1893. if (tmpworld instanceof CCWorld)
  1894. {
  1895. CCWorld world = (CCWorld) tmpworld;
  1896. if (world.getStatus() == 8)
  1897. {
  1898. int room;
  1899. int[][] spawns;
  1900. switch (zone.getId())
  1901. {
  1902. case 20105:
  1903. spawns = ROOM2_SPAWNS;
  1904. room = 2;
  1905. break;
  1906. case 20106:
  1907. spawns = ROOM3_SPAWNS;
  1908. room = 3;
  1909. break;
  1910. case 20107:
  1911. spawns = ROOM4_SPAWNS;
  1912. room = 4;
  1913. break;
  1914. default:
  1915. return super.onEnterZone(character, zone);
  1916. }
  1917. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  1918. {
  1919. if (door.getId() == (room + 24220000))
  1920. {
  1921. if (door.getOpen())
  1922. {
  1923. return "";
  1924. }
  1925. if (!hasQuestItems((L2PcInstance) character, RACE_KEY))
  1926. {
  1927. return "";
  1928. }
  1929. if (world.roomsStatus[zone.getId() - 20104] == 0)
  1930. {
  1931. runEmeraldRooms(world, spawns, room);
  1932. }
  1933. door.openMe();
  1934. takeItems((L2PcInstance) character, RACE_KEY, 1);
  1935. world.openedDoors.put(door, (L2PcInstance) character);
  1936. break;
  1937. }
  1938. }
  1939. }
  1940. }
  1941. }
  1942. return super.onEnterZone(character, zone);
  1943. }
  1944. @Override
  1945. public String onExitZone(L2Character character, L2ZoneType zone)
  1946. {
  1947. if (character instanceof L2PcInstance)
  1948. {
  1949. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  1950. if (tmpworld instanceof CCWorld)
  1951. {
  1952. CCWorld world = (CCWorld) tmpworld;
  1953. if (world.getStatus() == 8)
  1954. {
  1955. int doorId;
  1956. switch (zone.getId())
  1957. {
  1958. case 20105:
  1959. doorId = 24220002;
  1960. break;
  1961. case 20106:
  1962. doorId = 24220003;
  1963. break;
  1964. case 20107:
  1965. doorId = 24220004;
  1966. break;
  1967. default:
  1968. return super.onExitZone(character, zone);
  1969. }
  1970. for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
  1971. {
  1972. if (door.getId() == doorId)
  1973. {
  1974. if (door.getOpen() && (world.openedDoors.get(door) == character))
  1975. {
  1976. door.closeMe();
  1977. world.openedDoors.remove(door);
  1978. }
  1979. break;
  1980. }
  1981. }
  1982. }
  1983. }
  1984. }
  1985. return super.onExitZone(character, zone);
  1986. }
  1987. }