12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077 |
- /*
- * Copyright (C) 2004-2015 L2J DataPack
- *
- * This file is part of L2J DataPack.
- *
- * L2J DataPack is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J DataPack is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package instances.CrystalCaverns;
- import java.util.List;
- import java.util.Map;
- import javolution.util.FastList;
- import javolution.util.FastMap;
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.GeoData;
- import com.l2jserver.gameserver.ai.CtrlIntention;
- import com.l2jserver.gameserver.datatables.SkillData;
- import com.l2jserver.gameserver.enums.TrapAction;
- import com.l2jserver.gameserver.instancemanager.InstanceManager;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.L2Party;
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.Location;
- import com.l2jserver.gameserver.model.actor.L2Attackable;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.L2Summon;
- import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2TrapInstance;
- import com.l2jserver.gameserver.model.entity.Instance;
- import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
- import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
- import com.l2jserver.gameserver.model.quest.Quest;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.model.skills.Skill;
- import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
- import com.l2jserver.gameserver.model.zone.L2ZoneType;
- import com.l2jserver.gameserver.network.NpcStringId;
- import com.l2jserver.gameserver.network.SystemMessageId;
- import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
- import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
- import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
- import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
- import com.l2jserver.gameserver.network.serverpackets.PlaySound;
- import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
- import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
- import com.l2jserver.gameserver.util.Util;
- /**
- * Crystal Caverns instance zone.<br>
- * TODO: 1. Kechi's Henchmans spawn animation is missing.<br>
- * 2. NPC related Traps are not supported by core, so Darnels and Lahm door trap is not working.<br>
- * 3. Need retail spawn for Coral Garden (EmeraldSteam/Square - done).<br>
- * 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>
- * Original sources: theone, L2JEmu, L2JOfficial, L2JFree Contributing authors: TGS, Lantoc, Janiii, Gigiikun, RosT Please maintain consistency between the Crystal Caverns scripts.
- */
- public final class CrystalCaverns extends Quest
- {
- protected static class CrystalGolem
- {
- public L2ItemInstance foodItem = null;
- public boolean isAtDestination = false;
- public Location oldLoc = null;
- }
-
- private class CCWorld extends InstanceWorld
- {
- public Map<L2Npc, Boolean> npcList1 = new FastMap<>();
- public L2Npc tears;
- public boolean isUsedInvulSkill = false;
- public long dragonScaleStart = 0;
- public int dragonScaleNeed = 0;
- public int cleanedRooms = 0;
- public long endTime = 0;
- public List<L2Npc> copys = new FastList<>();
- public Map<L2Npc, CrystalGolem> crystalGolems = new FastMap<>();
- public int correctGolems = 0;
- public boolean[] OracleTriggered =
- {
- false,
- false,
- false
- };
- public int kechisHenchmanSpawn = 0;
- public int[] roomsStatus =
- {
- 0,
- 0,
- 0,
- 0
- }; // 0: not spawned, 1: spawned, 2: cleared
- public Map<L2DoorInstance, L2PcInstance> openedDoors = new FastMap<>();
- public Map<Integer, Map<L2Npc, Boolean>> npcList2 = new FastMap<>();
- public Map<L2Npc, L2Npc> oracles = new FastMap<>();
- public List<L2Npc> keyKeepers = new FastList<>();
- public List<L2Npc> guards = new FastList<>();
- public List<L2Npc> oracle = new FastList<>();
- // baylor variables
- protected final List<L2PcInstance> _raiders = new FastList<>();
- protected int _raidStatus = 0;
- protected long _dragonClawStart = 0;
- protected int _dragonClawNeed = 0;
- protected final List<L2Npc> _animationMobs = new FastList<>();
- protected L2Npc _camera = null;
- protected L2Npc _baylor = null;
- protected L2Npc _alarm = null;
-
- public CCWorld(Long time)
- {
- endTime = time;
- }
- }
-
- private static final int TEMPLATE_ID = 10;
- private static final boolean debug = false;
-
- // Items
- private static final int WHITE_SEED = 9597;
- private static final int BLACK_SEED = 9598;
- private static final int CONT_CRYSTAL = 9690; // Contaminated Crystal
- private static final int RED_CORAL = 9692; // Red Coral
- private static final int CRYSTALFOOD = 9693; // Food item for Crystal Golems
- final private static int RACE_KEY = 9694; // Race Key for Emerald doors
- private static final int BOSS_CRYSTAL_1 = 9695; // Clear Crystal
- private static final int BOSS_CRYSTAL_2 = 9696; // Clear Crystal
- private static final int BOSS_CRYSTAL_3 = 9697; // Clear Crystal
-
- // NPCs
- private static final int ORACLE_GUIDE_1 = 32281;
- private static final int ORACLE_GUIDE_2 = 32278;
- private static final int ORACLE_GUIDE_3 = 32280;
- private static final int ORACLE_GUIDE_4 = 32279;
- private static final int CRYSTAL_GOLEM = 32328;
- private static final int[] DOOR_OPENING_TRAP =
- {
- 18378,
- 143682,
- 142492,
- -11886,
- 16384
- };
-
- // mobs
- private static final int GK1 = 22275;
- private static final int GK2 = 22277;
-
- private static final int TOURMALINE = 22292;
- private static final int TEROD = 22301;
- private static final int DOLPH = 22299;
- private static final int WEYLIN = 22298;
- private static final int GUARDIAN = 22303;
- private static final int GUARDIAN2 = 22304;
-
- private static final int TEARS = 25534;
- private static final int TEARS_COPY = 25535;
- private static final int KECHI = 25532;
- private static final int KECHIGUARD = 25533;
- private static final int BAYLOR = 29099;
- private static final int DARNEL = 25531;
- private final static int ALARMID = 18474;
-
- // private static final int[] BOSSCR = {9695,9696,9697};
- private static final int[] CGMOBS =
- {
- 22311,
- 22312,
- 22313,
- 22314,
- 22315,
- 22316,
- 22317
- };
- private static final int[] SPAWN =
- {
- 60000,
- 120000,
- 90000,
- 60000,
- 50000,
- 40000
- }; // Kechi Hencmans spawn times
- private static final int[] MOBLIST =
- {
- 22279,
- 22280,
- 22281,
- 22282,
- 22283,
- 22285,
- 22286,
- 22287,
- 22288,
- 22289,
- 22293,
- 22294,
- 22295,
- 22296,
- 22297,
- 22305,
- 22306,
- 22307,
- 22416,
- 22418,
- 22419,
- 22420
- };
-
- // Doors/Walls/Zones
- private static final int DOOR1 = 24220021;
- private static final int DOOR2 = 24220024;
- private static final int DOOR3 = 24220023;
- private static final int DOOR4 = 24220061;
- private static final int DOOR5 = 24220025;
- private static final int DOOR6 = 24220022;
- private static final int[] ZONES =
- {
- 20105,
- 20106,
- 20107
- };
-
- // Baylor alarm spawns
- private final static int[][] ALARMSPAWN =
- {
- {
- 153572,
- 141277,
- -12738
- },
- {
- 153572,
- 142852,
- -12738
- },
- {
- 154358,
- 142075,
- -12738
- },
- {
- 152788,
- 142075,
- -12738
- }
- };
-
- // Oracle order
- private static final int[][] ordreOracle1 =
- {
- {
- 32274,
- 147090,
- 152505,
- -12169,
- 31613
- },
- {
- 32275,
- 147090,
- 152575,
- -12169,
- 31613
- },
- {
- 32274,
- 147090,
- 152645,
- -12169,
- 31613
- },
- {
- 32274,
- 147090,
- 152715,
- -12169,
- 31613
- }
- };
-
- private static final int[][] ordreOracle2 =
- {
- {
- 32274,
- 149783,
- 152505,
- -12169,
- 31613
- },
- // {32274, 149783, 152575, -12169, 31613},
- {
- 32274,
- 149783,
- 152645,
- -12169,
- 31613
- },
- {
- 32276,
- 149783,
- 152715,
- -12169,
- 31613
- }
- };
-
- private static final int[][] ordreOracle3 =
- {
- {
- 32274,
- 152461,
- 152505,
- -12169,
- 31613
- },
- // {32274, 152461, 152575, -12169, 31613},
- {
- 32277,
- 152461,
- 152645,
- -12169,
- 31613
- }
- // {32274, 152461, 152715, -12169, 31613}
- };
-
- // Hall spawns
- private static int[][] SPAWNS =
- {
- {
- 141842,
- 152556,
- -11814,
- 50449
- },
- {
- 141503,
- 153395,
- -11814,
- 40738
- },
- {
- 141070,
- 153201,
- -11814,
- 39292
- },
- {
- 141371,
- 152986,
- -11814,
- 35575
- },
- {
- 141602,
- 154188,
- -11814,
- 24575
- },
- {
- 141382,
- 154719,
- -11814,
- 37640
- },
- {
- 141376,
- 154359,
- -11814,
- 12054
- },
- {
- 140895,
- 154383,
- -11814,
- 37508
- },
- {
- 140972,
- 154740,
- -11814,
- 52690
- },
- {
- 141045,
- 154504,
- -11814,
- 50674
- },
- {
- 140757,
- 152740,
- -11814,
- 39463
- },
- {
- 140406,
- 152376,
- -11814,
- 16599
- },
- {
- 140268,
- 152007,
- -11817,
- 45316
- },
- {
- 139996,
- 151485,
- -11814,
- 47403
- },
- {
- 140378,
- 151190,
- -11814,
- 58116
- },
- {
- 140521,
- 150711,
- -11815,
- 55997
- },
- {
- 140816,
- 150215,
- -11814,
- 53682
- },
- {
- 141528,
- 149909,
- -11814,
- 22020
- },
- {
- 141644,
- 150360,
- -11817,
- 13283
- },
- {
- 142048,
- 150695,
- -11815,
- 5929
- },
- {
- 141852,
- 151065,
- -11817,
- 27071
- },
- {
- 142408,
- 151211,
- -11815,
- 2402
- },
- {
- 142481,
- 151762,
- -11815,
- 12876
- },
- {
- 141929,
- 152193,
- -11815,
- 27511
- },
- {
- 142083,
- 151791,
- -11814,
- 47176
- },
- {
- 141435,
- 150402,
- -11814,
- 41798
- },
- {
- 140390,
- 151199,
- -11814,
- 50069
- },
- {
- 140557,
- 151849,
- -11814,
- 45293
- },
- {
- 140964,
- 153445,
- -11814,
- 56672
- },
- {
- 142851,
- 154109,
- -11814,
- 24920
- },
- {
- 142379,
- 154725,
- -11814,
- 30342
- },
- {
- 142816,
- 154712,
- -11814,
- 33193
- },
- {
- 142276,
- 154223,
- -11814,
- 33922
- },
- {
- 142459,
- 154490,
- -11814,
- 33184
- },
- {
- 142819,
- 154372,
- -11814,
- 21318
- },
- {
- 141157,
- 154541,
- -11814,
- 27090
- },
- {
- 141095,
- 150281,
- -11814,
- 55186
- }
- };
-
- // first spawns
- private static int[][] FIRST_SPAWNS =
- {
- {
- 22276,
- 148109,
- 149601,
- -12132,
- 34490
- },
- {
- 22276,
- 148017,
- 149529,
- -12132,
- 33689
- },
- {
- 22278,
- 148065,
- 151202,
- -12132,
- 35323
- },
- {
- 22278,
- 147966,
- 151117,
- -12132,
- 33234
- },
- {
- 22279,
- 144063,
- 150238,
- -12132,
- 29654
- },
- {
- 22279,
- 144300,
- 149118,
- -12135,
- 5520
- },
- {
- 22279,
- 144397,
- 149337,
- -12132,
- 644
- },
- {
- 22279,
- 144426,
- 150639,
- -12132,
- 50655
- },
- {
- 22282,
- 145841,
- 151097,
- -12132,
- 31810
- },
- {
- 22282,
- 144387,
- 149958,
- -12132,
- 61173
- },
- {
- 22282,
- 145821,
- 149498,
- -12132,
- 31490
- },
- {
- 22282,
- 146619,
- 149694,
- -12132,
- 33374
- },
- {
- 22282,
- 146669,
- 149244,
- -12132,
- 31360
- },
- {
- 22284,
- 144147,
- 151375,
- -12132,
- 58395
- },
- {
- 22284,
- 144485,
- 151067,
- -12132,
- 64786
- },
- {
- 22284,
- 144356,
- 149571,
- -12132,
- 63516
- },
- {
- 22285,
- 144151,
- 150962,
- -12132,
- 664
- },
- {
- 22285,
- 146657,
- 151365,
- -12132,
- 33154
- },
- {
- 22285,
- 146623,
- 150857,
- -12132,
- 28034
- },
- {
- 22285,
- 147046,
- 151089,
- -12132,
- 32941
- },
- {
- 22285,
- 145704,
- 151255,
- -12132,
- 32523
- },
- {
- 22285,
- 145359,
- 151101,
- -12132,
- 32767
- },
- {
- 22285,
- 147785,
- 150817,
- -12132,
- 27423
- },
- {
- 22285,
- 147727,
- 151375,
- -12132,
- 37117
- },
- {
- 22285,
- 145428,
- 149494,
- -12132,
- 890
- },
- {
- 22285,
- 145601,
- 149682,
- -12132,
- 32442
- },
- {
- 22285,
- 147003,
- 149476,
- -12132,
- 31554
- },
- {
- 22285,
- 147738,
- 149210,
- -12132,
- 20971
- },
- {
- 22285,
- 147769,
- 149757,
- -12132,
- 34980
- }
- };
-
- // Emerald Square
- private static int[][] EMERALD_SPAWNS =
- {
- {
- 22280,
- 144437,
- 143395,
- -11969,
- 34248
- },
- {
- 22281,
- 149241,
- 143735,
- -12230,
- 24575
- },
- {
- 22281,
- 147917,
- 146861,
- -12289,
- 60306
- },
- {
- 22281,
- 144406,
- 147782,
- -12133,
- 14349
- },
- {
- 22281,
- 144960,
- 146881,
- -12039,
- 23881
- },
- {
- 22281,
- 144985,
- 147679,
- -12135,
- 27594
- },
- {
- 22283,
- 147784,
- 143540,
- -12222,
- 2058
- },
- {
- 22283,
- 149091,
- 143491,
- -12230,
- 24836
- },
- {
- 22287,
- 144479,
- 147569,
- -12133,
- 20723
- },
- {
- 22287,
- 145158,
- 146986,
- -12058,
- 21970
- },
- {
- 22287,
- 145142,
- 147175,
- -12092,
- 24420
- },
- {
- 22287,
- 145110,
- 147133,
- -12088,
- 22465
- },
- {
- 22287,
- 144664,
- 146604,
- -12028,
- 14861
- },
- {
- 22287,
- 144596,
- 146600,
- -12028,
- 14461
- },
- {
- 22288,
- 143925,
- 146773,
- -12037,
- 10813
- },
- {
- 22288,
- 144415,
- 147070,
- -12069,
- 8568
- },
- {
- 22288,
- 143794,
- 145584,
- -12027,
- 14849
- },
- {
- 22288,
- 143429,
- 146166,
- -12030,
- 4078
- },
- {
- 22288,
- 144477,
- 147009,
- -12056,
- 8752
- },
- {
- 22289,
- 142577,
- 145319,
- -12029,
- 5403
- },
- {
- 22289,
- 143831,
- 146902,
- -12051,
- 9717
- },
- {
- 22289,
- 143714,
- 146705,
- -12028,
- 10044
- },
- {
- 22289,
- 143937,
- 147134,
- -12078,
- 7517
- },
- {
- 22293,
- 143356,
- 145287,
- -12027,
- 8126
- },
- {
- 22293,
- 143462,
- 144352,
- -12008,
- 25905
- },
- {
- 22293,
- 143745,
- 142529,
- -11882,
- 17102
- },
- {
- 22293,
- 144574,
- 144032,
- -12005,
- 34668
- },
- {
- 22295,
- 143992,
- 142419,
- -11884,
- 19697
- },
- {
- 22295,
- 144671,
- 143966,
- -12004,
- 32088
- },
- {
- 22295,
- 144440,
- 143269,
- -11957,
- 34169
- },
- {
- 22295,
- 142642,
- 146362,
- -12028,
- 281
- },
- {
- 22295,
- 143865,
- 142707,
- -11881,
- 21326
- },
- {
- 22295,
- 143573,
- 142530,
- -11879,
- 16141
- },
- {
- 22295,
- 143148,
- 146039,
- -12031,
- 65014
- },
- {
- 22295,
- 143001,
- 144853,
- -12014,
- 0
- },
- {
- 22296,
- 147505,
- 146580,
- -12260,
- 59041
- },
- {
- 22296,
- 149366,
- 146932,
- -12358,
- 39407
- },
- {
- 22296,
- 149284,
- 147029,
- -12352,
- 41120
- },
- {
- 22296,
- 149439,
- 143940,
- -12230,
- 23189
- },
- {
- 22296,
- 147698,
- 143995,
- -12220,
- 27028
- },
- {
- 22296,
- 141885,
- 144969,
- -12007,
- 2526
- },
- {
- 22296,
- 147843,
- 143763,
- -12220,
- 28386
- },
- {
- 22296,
- 144753,
- 143650,
- -11982,
- 35429
- },
- {
- 22296,
- 147613,
- 146760,
- -12271,
- 56296
- }
- };
-
- private static int[][] ROOM1_SPAWNS =
- {
- {
- 22288,
- 143114,
- 140027,
- -11888,
- 15025
- },
- {
- 22288,
- 142173,
- 140973,
- -11888,
- 55698
- },
- {
- 22289,
- 143210,
- 140577,
- -11888,
- 17164
- },
- {
- 22289,
- 142638,
- 140107,
- -11888,
- 6571
- },
- {
- 22297,
- 142547,
- 140938,
- -11888,
- 48556
- },
- {
- 22298,
- 142690,
- 140479,
- -11887,
- 7663
- }
- };
-
- private static int[][] ROOM2_SPAWNS =
- {
- {
- 22303,
- 146276,
- 141483,
- -11880,
- 34643
- },
- {
- 22287,
- 145707,
- 142161,
- -11880,
- 28799
- },
- {
- 22288,
- 146857,
- 142129,
- -11880,
- 33647
- },
- {
- 22288,
- 146869,
- 142000,
- -11880,
- 31215
- },
- {
- 22289,
- 146897,
- 140880,
- -11880,
- 19210
- }
- };
-
- private static int[][] ROOM3_SPAWNS =
- {
- {
- 22302,
- 145123,
- 143713,
- -12808,
- 65323
- },
- {
- 22294,
- 145188,
- 143331,
- -12808,
- 496
- },
- {
- 22294,
- 145181,
- 144104,
- -12808,
- 64415
- },
- {
- 22293,
- 144994,
- 143431,
- -12808,
- 65431
- },
- {
- 22293,
- 144976,
- 143915,
- -12808,
- 61461
- }
- };
-
- private static int[][] ROOM4_SPAWNS =
- {
- {
- 22304,
- 150563,
- 142240,
- -12108,
- 16454
- },
- {
- 22294,
- 150769,
- 142495,
- -12108,
- 16870
- },
- {
- 22281,
- 150783,
- 141995,
- -12108,
- 20033
- },
- {
- 22283,
- 150273,
- 141983,
- -12108,
- 16043
- },
- {
- 22294,
- 150276,
- 142492,
- -12108,
- 13540
- }
- };
-
- // Steam Corridor
- private static int[][] STEAM1_SPAWNS =
- {
- {
- 22305,
- 145260,
- 152387,
- -12165,
- 32767
- },
- {
- 22305,
- 144967,
- 152390,
- -12165,
- 30464
- },
- {
- 22305,
- 145610,
- 152586,
- -12165,
- 17107
- },
- {
- 22305,
- 145620,
- 152397,
- -12165,
- 8191
- },
- {
- 22418,
- 146081,
- 152847,
- -12165,
- 31396
- },
- {
- 22418,
- 146795,
- 152641,
- -12165,
- 33850
- }
- // {22308, 145093, 152502, -12165, 31841},{22308, 146158, 152776, -12165, 30810},
- // {22308, 146116, 152976, -12133, 32571},
-
- };
- private static int[][] STEAM2_SPAWNS =
- {
- {
- 22306,
- 147740,
- 152767,
- -12165,
- 65043
- },
- {
- 22306,
- 148215,
- 152828,
- -12165,
- 970
- },
- {
- 22306,
- 147743,
- 152846,
- -12165,
- 64147
- },// {22308, 147849, 152854, -12165, 60534},
- // {22308, 147754, 152908, -12141, 59827},{22308, 148194, 152681, -12165, 63620},
- // {22308, 147767, 152939, -12133, 63381},{22309, 147737, 152671, -12165, 65320},
- {
- 22418,
- 148207,
- 152725,
- -12165,
- 61801
- },
- {
- 22419,
- 149058,
- 152828,
- -12165,
- 64564
- }
- };
-
- private static int[][] STEAM3_SPAWNS =
- {
- {
- 22307,
- 150735,
- 152316,
- -12145,
- 31930
- },
- {
- 22307,
- 150725,
- 152467,
- -12165,
- 33635
- },
- {
- 22307,
- 151058,
- 152316,
- -12146,
- 65342
- },
- {
- 22307,
- 151057,
- 152461,
- -12165,
- 2171
- }
- /*
- * {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,
- * 152544, -12165, 31846}, {22309, 150488, 152350, -12165, 29072},{22310, 151139, 152238, -12132, 1069}
- */
- };
-
- private static int[][] STEAM4_SPAWNS =
- {// {22308, 151707, 150199, -12165, 32859},{22308, 152091, 150140, -12165, 32938},
- // {22308, 149757, 150204, -12138, 65331},{22308, 149950, 150307, -12132, 62437},
- // {22308, 149901, 150322, -12132, 62136},{22309, 150071, 150173, -12165, 64943},
- {
- 22416,
- 151636,
- 150280,
- -12142,
- 36869
- },
- {
- 22416,
- 149893,
- 150232,
- -12165,
- 64258
- },
- {
- 22416,
- 149864,
- 150110,
- -12165,
- 65054
- },
- {
- 22416,
- 151926,
- 150218,
- -12165,
- 31613
- },
- {
- 22420,
- 149986,
- 150051,
- -12165,
- 105
- },
- {
- 22420,
- 151970,
- 149997,
- -12165,
- 32170
- },
- {
- 22420,
- 150744,
- 150006,
- -12165,
- 63
- }
- // ,{22417, 149782, 150188, -12151, 64001}
- };
-
- // Instance reenter time
- // default: 86400000ms(24h)
- private static final int INSTANCEPENALTY = 86400000;
- private static final int DRAGONSCALETIME = 3000;
- private static final int DRAGONCLAWTIME = 3000;
-
- private CrystalCaverns()
- {
- super(-1, CrystalCaverns.class.getSimpleName(), "instances");
- addStartNpc(ORACLE_GUIDE_1);
- addTalkId(ORACLE_GUIDE_1);
- addTalkId(ORACLE_GUIDE_3);
- addStartNpc(ORACLE_GUIDE_4);
- addFirstTalkId(ORACLE_GUIDE_4);
- addTalkId(ORACLE_GUIDE_4);
- addFirstTalkId(CRYSTAL_GOLEM);
- addAttackId(TEARS);
- addTrapActionId(DOOR_OPENING_TRAP[0]);
- addKillId(TEARS);
- addKillId(GK1);
- addKillId(GK2);
- addKillId(TEROD);
- addKillId(WEYLIN);
- addKillId(DOLPH);
- addKillId(DARNEL);
- addKillId(KECHI);
- addKillId(GUARDIAN);
- addKillId(GUARDIAN2);
- addKillId(TOURMALINE);
- addKillId(BAYLOR);
- addSpellFinishedId(BAYLOR);
- addKillId(ALARMID);
- addFirstTalkId(32274, 32275, 32276, 32277, ORACLE_GUIDE_1, ORACLE_GUIDE_2);
- addTalkId(32275, 32276, 32277);
- addSkillSeeId(25534, 32275, 32276, 32277, BAYLOR);
- addKillId(MOBLIST);
- addKillId(CGMOBS);
- for (int zones : ZONES)
- {
- addEnterZoneId(zones);
- addExitZoneId(zones);
- }
- }
-
- private boolean checkConditions(L2PcInstance player)
- {
- if (debug)
- {
- return true;
- }
- L2Party party = player.getParty();
- if (party == null)
- {
- player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
- return false;
- }
- if (party.getLeader() != player)
- {
- player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
- return false;
- }
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getLevel() < 78)
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- L2ItemInstance item = partyMember.getInventory().getItemByItemId(CONT_CRYSTAL);
- if (item == null)
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- if (!Util.checkIfInRange(1000, player, partyMember, true))
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
- if (System.currentTimeMillis() < reentertime)
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- }
- return true;
- }
-
- private boolean checkOracleConditions(L2PcInstance player)
- {
- if (debug)
- {
- return true;
- }
- L2Party party = player.getParty();
- if (party == null)
- {
- player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
- return false;
- }
- if (party.getLeader() != player)
- {
- player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
- return false;
- }
- for (L2PcInstance partyMember : party.getMembers())
- {
- L2ItemInstance item = partyMember.getInventory().getItemByItemId(RED_CORAL);
- if (item == null)
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- if (!Util.checkIfInRange(1000, player, partyMember, true))
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- }
- return true;
- }
-
- private boolean checkBaylorConditions(L2PcInstance player)
- {
- L2Party party = player.getParty();
- if (party == null)
- {
- player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
- return false;
- }
- if (party.getLeader() != player)
- {
- player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
- return false;
- }
- for (L2PcInstance partyMember : party.getMembers())
- {
- L2ItemInstance item1 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_1);
- L2ItemInstance item2 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_2);
- L2ItemInstance item3 = partyMember.getInventory().getItemByItemId(BOSS_CRYSTAL_3);
- if ((item1 == null) || (item2 == null) || (item3 == null))
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ITEM_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- if (!Util.checkIfInRange(1000, player, partyMember, true))
- {
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(partyMember);
- party.broadcastPacket(sm);
- return false;
- }
- }
- return true;
- }
-
- // this should be handled from skill effect
- private void Throw(L2Character effector, L2Character effected)
- {
- // Get current position of the L2Character
- final int curX = effected.getX();
- final int curY = effected.getY();
- final int curZ = effected.getZ();
-
- // Calculate distance between effector and effected current position
- double dx = effector.getX() - curX;
- double dy = effector.getY() - curY;
- double dz = effector.getZ() - curZ;
- double distance = Math.sqrt((dx * dx) + (dy * dy));
- int offset = Math.min((int) distance + 300, 1400);
-
- double cos;
- double sin;
-
- // approximation for moving futher when z coordinates are different
- // TODO: handle Z axis movement better
- offset += Math.abs(dz);
- if (offset < 5)
- {
- offset = 5;
- }
-
- if (distance < 1)
- {
- return;
- }
- // Calculate movement angles needed
- sin = dy / distance;
- cos = dx / distance;
-
- // Calculate the new destination with offset included
- int _x = effector.getX() - (int) (offset * cos);
- int _y = effector.getY() - (int) (offset * sin);
- int _z = effected.getZ();
-
- Location destination = GeoData.getInstance().moveCheck(effected.getX(), effected.getY(), effected.getZ(), _x, _y, _z, effected.getInstanceId());
-
- effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP));
-
- // maybe is need force set X,Y,Z
- effected.setXYZ(destination);
- effected.broadcastPacket(new ValidateLocation(effected));
- }
-
- protected int enterInstance(L2PcInstance player, String template, Location loc)
- {
- // check for existing instances for this player
- InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
- // existing instance
- if (world != null)
- {
- if (!(world instanceof CCWorld))
- {
- player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
- return 0;
- }
- teleportPlayer(player, loc, world.getInstanceId());
- return world.getInstanceId();
- }
-
- // New instance
- if (!checkConditions(player))
- {
- return 0;
- }
- L2Party party = player.getParty();
- int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- world = new CCWorld(System.currentTimeMillis() + 5400000);
- world.setInstanceId(instanceId);
- world.setTemplateId(TEMPLATE_ID);
- InstanceManager.getInstance().addWorld(world);
- _log.info("Crystal Caverns started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
- runOracle((CCWorld) world);
- // teleport players
- if (player.getParty() == null)
- {
- // this can happen only if debug is true
- player.sendMessage("Welcome to Crystal Caverns.");
- InstanceManager.getInstance().setInstanceTime(player.getObjectId(), TEMPLATE_ID, ((System.currentTimeMillis() + INSTANCEPENALTY)));
- teleportPlayer(player, loc, world.getInstanceId());
- world.isAllowed(player.getObjectId());
- }
- else
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- partyMember.sendMessage("Welcome to Crystal Caverns.");
- InstanceManager.getInstance().setInstanceTime(partyMember.getObjectId(), TEMPLATE_ID, ((System.currentTimeMillis() + INSTANCEPENALTY)));
- teleportPlayer(partyMember, loc, world.getInstanceId());
- world.addAllowed(partyMember.getObjectId());
- }
- }
- return instanceId;
- }
-
- protected void stopAttack(L2PcInstance player)
- {
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.breakAttack();
- player.breakCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- L2Summon pet = player.getSummon();
- if (pet != null)
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.breakAttack();
- pet.breakCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- }
- }
-
- protected void runOracle(CCWorld world)
- {
- world.setStatus(0);
-
- world.oracle.add(addSpawn(ORACLE_GUIDE_1, 143172, 148894, -11975, 0, false, 0, false, world.getInstanceId()));
- }
-
- protected void runEmerald(CCWorld world)
- {
- world.setStatus(1);
- runFirst(world);
- openDoor(DOOR1, world.getInstanceId());
- }
-
- protected void runCoral(CCWorld world)
- {
- world.setStatus(1);
- runHall(world);
- openDoor(DOOR2, world.getInstanceId());
- openDoor(DOOR5, world.getInstanceId());
- }
-
- protected void runHall(CCWorld world)
- {
- world.setStatus(2);
-
- for (int[] spawn : SPAWNS)
- {
- L2Npc mob = addSpawn(CGMOBS[getRandom(CGMOBS.length)], spawn[0], spawn[1], spawn[2], spawn[3], false, 0, false, world.getInstanceId());
- world.npcList1.put(mob, false);
- }
- }
-
- protected void runFirst(CCWorld world)
- {
- world.setStatus(2);
-
- world.keyKeepers.add(addSpawn(GK1, 148206, 149486, -12140, 32308, false, 0, false, world.getInstanceId()));
- world.keyKeepers.add(addSpawn(GK2, 148203, 151093, -12140, 31100, false, 0, false, world.getInstanceId()));
-
- for (int[] spawn : FIRST_SPAWNS)
- {
- addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
- }
- }
-
- protected void runEmeraldSquare(CCWorld world)
- {
- world.setStatus(3);
-
- Map<L2Npc, Boolean> spawnList = new FastMap<>();
- for (int[] spawn : EMERALD_SPAWNS)
- {
- L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
- spawnList.put(mob, false);
- }
- world.npcList2.put(0, spawnList);
- }
-
- protected void runEmeraldRooms(CCWorld world, int[][] spawnList, int room)
- {
- Map<L2Npc, Boolean> spawned = new FastMap<>();
- for (int[] spawn : spawnList)
- {
- L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
- spawned.put(mob, false);
- }
- if (room == 1)
- {
- addSpawn(32359, 142110, 139896, -11888, 8033, false, 0, false, world.getInstanceId());
- }
- world.npcList2.put(room, spawned);
- world.roomsStatus[room - 1] = 1;
- }
-
- protected void runDarnel(CCWorld world)
- {
- world.setStatus(9);
-
- addSpawn(DARNEL, 152759, 145949, -12588, 21592, false, 0, false, world.getInstanceId());
- // TODO: missing traps
- openDoor(24220005, world.getInstanceId());
- openDoor(24220006, world.getInstanceId());
- }
-
- protected void runSteamRooms(CCWorld world, int[][] spawnList, int status)
- {
- world.setStatus(status);
-
- Map<L2Npc, Boolean> spawned = new FastMap<>();
- for (int[] spawn : spawnList)
- {
- L2Npc mob = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
- spawned.put(mob, false);
- }
- world.npcList2.put(0, spawned);
- }
-
- protected void runSteamOracles(CCWorld world, int[][] oracleOrder)
- {
- world.oracles.clear();
- for (int[] oracle : oracleOrder)
- {
- world.oracles.put(addSpawn(oracle[0], oracle[1], oracle[2], oracle[3], oracle[4], false, 0, false, world.getInstanceId()), null);
- }
- }
-
- protected boolean checkKillProgress(int room, L2Npc mob, CCWorld world)
- {
- if (world.npcList2.get(room).containsKey(mob))
- {
- world.npcList2.get(room).put(mob, true);
- }
- for (boolean isDead : world.npcList2.get(room).values())
- {
- if (!isDead)
- {
- return false;
- }
- }
- return true;
- }
-
- /*
- * 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
- * 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
- * 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
- * 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); }
- */
-
- @Override
- public String onFirstTalk(L2Npc npc, L2PcInstance player)
- {
- if (npc.getId() == ORACLE_GUIDE_1)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if ((world.getStatus() == 0) && world.oracle.contains(npc))
- {
- String htmltext = "32281.htm";
- return htmltext;
- }
- }
- npc.showChatWindow(player);
- return null;
- }
- else if ((npc.getId() >= 32275) && (npc.getId() <= 32277))
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (!world.OracleTriggered[npc.getId() - 32275])
- {
- String htmltext = "no.htm";
- return htmltext;
- }
- npc.showChatWindow(player);
- return null;
- }
- }
- else if (npc.getId() == 32274)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- String htmltext = "no.htm";
- return htmltext;
- }
- }
- else if (npc.getId() == 32279)
- {
- QuestState st = player.getQuestState("131_BirdInACage");
- String htmltext = "32279.htm";
- if ((st != null) && !st.isCompleted())
- {
- htmltext = "32279-01.htm";
- }
- return htmltext;
- }
- else if (npc.getId() == CRYSTAL_GOLEM)
- {
- player.sendPacket(ActionFailed.STATIC_PACKET);
- }
- return "";
- }
-
- @Override
- public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
- {
-
- boolean doReturn = true;
- for (L2Object obj : targets)
- {
- if (obj == npc)
- {
- doReturn = false;
- }
- }
- if (doReturn)
- {
- return super.onSkillSee(npc, caster, skill, targets, isSummon);
- }
-
- switch (skill.getId())
- {
- case 1011:
- case 1015:
- case 1217:
- case 1218:
- case 1401:
- case 2360:
- case 2369:
- case 5146:
- doReturn = false;
- break;
- default:
- doReturn = true;
- }
- if (doReturn)
- {
- return super.onSkillSee(npc, caster, skill, targets, isSummon);
- }
-
- if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && (skill.getId() != 2360) && (skill.getId() != 2369))
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if ((tmpworld instanceof CCWorld) && (getRandom(100) < 15))
- {
- for (L2Npc oracle : ((CCWorld) tmpworld).oracles.keySet())
- {
- if (oracle != npc)
- {
- oracle.decayMe();
- }
- }
- ((CCWorld) tmpworld).OracleTriggered[npc.getId() - 32275] = true;
- }
- }
- else if (npc.isInvul() && (npc.getId() == BAYLOR) && (skill.getId() == 2360) && (caster != null))
- {
- if (caster.getParty() == null)
- {
- return super.onSkillSee(npc, caster, skill, targets, isSummon);
- }
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
-
- if (((world._dragonClawStart + DRAGONCLAWTIME) <= System.currentTimeMillis()) || (world._dragonClawNeed <= 0))
- {
- world._dragonClawStart = System.currentTimeMillis();
- world._dragonClawNeed = caster.getParty().getMemberCount() - 1;
- }
- else
- {
- world._dragonClawNeed--;
- }
- if (world._dragonClawNeed == 0)
- {
- npc.stopSkillEffects(false, 5225);
- npc.broadcastPacket(new MagicSkillUse(npc, npc, 5480, 1, 4000, 0));
- if (world._raidStatus == 3)
- {
- world._raidStatus++;
- }
- }
- }
- }
- else if (npc.isInvul() && (npc.getId() == TEARS) && (skill.getId() == 2369) && (caster != null))
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (caster.getParty() == null)
- {
- return super.onSkillSee(npc, caster, skill, targets, isSummon);
- }
- else if (((world.dragonScaleStart + DRAGONSCALETIME) <= System.currentTimeMillis()) || (world.dragonScaleNeed <= 0))
- {
- world.dragonScaleStart = System.currentTimeMillis();
- world.dragonScaleNeed = caster.getParty().getMemberCount() - 1;
- }
- else
- {
- world.dragonScaleNeed--;
- }
- if ((world.dragonScaleNeed == 0) && (getRandom(100) < 80))
- {
- npc.setIsInvul(false);
- }
- }
- }
- return super.onSkillSee(npc, caster, skill, targets, isSummon);
- }
-
- @Override
- public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
- {
- if (npc.getId() == TEARS)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if ((world.getStatus() != 4) && (attacker != null))
- {
- // Lucky cheater, the code only kicks his/her ass out of the dungeon
- teleportPlayer(attacker, new Location(149361, 172327, -945), 0);
- world.removeAllowed(attacker.getObjectId());
- }
- else if (world.tears != npc)
- {
- return "";
- }
- else if (!world.copys.isEmpty())
- {
- boolean notAOE = true;
- 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)))
- {
- notAOE = false;
- }
- if (notAOE)
- {
- for (L2Npc copy : world.copys)
- {
- copy.onDecay();
- }
- world.copys.clear();
- }
- return "";
- }
-
- int maxHp = npc.getMaxHp();
- double nowHp = npc.getStatus().getCurrentHp();
- int rand = getRandom(1000);
-
- if ((nowHp < (maxHp * 0.4)) && (rand < 5))
- {
- L2Party party = attacker.getParty();
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- stopAttack(partyMember);
- }
- }
- else
- {
- stopAttack(attacker);
- }
- L2Character target = npc.getAI().getAttackTarget();
- for (int i = 0; i < 10; i++)
- {
- L2Npc copy = addSpawn(TEARS_COPY, npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, false, attacker.getInstanceId());
- copy.setRunning();
- ((L2Attackable) copy).addDamageHate(target, 0, 99999);
- copy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
- copy.setCurrentHp(nowHp);
- world.copys.add(copy);
- }
- }
- else if ((nowHp < (maxHp * 0.15)) && !world.isUsedInvulSkill)
- {
- if ((rand > 994) || (nowHp < (maxHp * 0.1)))
- {
- world.isUsedInvulSkill = true;
- npc.setIsInvul(true);
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
- {
- if ((npc.getId() == BAYLOR) && (skill.getId() == 5225))
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- ((CCWorld) tmpworld)._raidStatus++;
- }
- }
- return super.onSpellFinished(npc, player, skill);
- }
-
- @Override
- public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (event.equalsIgnoreCase("TeleportOut"))
- {
- teleportPlayer(player, new Location(149413, 173078, -5014), 0);
- }
- else if (event.equalsIgnoreCase("TeleportParme"))
- {
- teleportPlayer(player, new Location(153689, 142226, -9750), world.getInstanceId());
- }
- else if (event.equalsIgnoreCase("Timer2") || event.equalsIgnoreCase("Timer3") || event.equalsIgnoreCase("Timer4") || event.equalsIgnoreCase("Timer5"))
- {
- if (player.getInstanceId() == world.getInstanceId())
- {
- teleportPlayer(player, new Location(144653, 152606, -12126), world.getInstanceId());
- player.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
- startQuestTimer("Timer2", 300000, npc, player);
- }
- }
- else if (event.equalsIgnoreCase("Timer21") || event.equalsIgnoreCase("Timer31") || event.equalsIgnoreCase("Timer41") || event.equalsIgnoreCase("Timer51"))
- {
- InstanceManager.getInstance().getInstance(world.getInstanceId()).removeNpcs();
- world.npcList2.clear();
- runSteamRooms(world, STEAM1_SPAWNS, 22);
- startQuestTimer("Timer21", 300000, npc, null);
- }
-
- else if (event.equalsIgnoreCase("checkKechiAttack"))
- {
- if (npc.isInCombat())
- {
- startQuestTimer("spawnGuards", SPAWN[0], npc, null);
- cancelQuestTimers("checkKechiAttack");
- closeDoor(DOOR4, npc.getInstanceId());
- closeDoor(DOOR3, npc.getInstanceId());
- }
- else
- {
- startQuestTimer("checkKechiAttack", 1000, npc, null);
- }
- }
- else if (event.equalsIgnoreCase("spawnGuards"))
- {
- world.kechisHenchmanSpawn++;
- world.guards.add(addSpawn(KECHIGUARD, 153622, 149699, -12131, 56890, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153609, 149622, -12131, 64023, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153606, 149428, -12131, 64541, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153601, 149534, -12131, 64901, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153620, 149354, -12131, 1164, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153637, 149776, -12131, 61733, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153638, 149292, -12131, 64071, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153647, 149857, -12131, 59402, false, 0, false, world.getInstanceId()));
- world.guards.add(addSpawn(KECHIGUARD, 153661, 149227, -12131, 65275, false, 0, false, world.getInstanceId()));
- if (world.kechisHenchmanSpawn <= 5)
- {
- startQuestTimer("spawnGuards", SPAWN[world.kechisHenchmanSpawn], npc, null);
- }
- else
- {
- cancelQuestTimers("spawnGuards");
- }
- }
- else if (event.equalsIgnoreCase("EmeraldSteam"))
- {
- runEmerald(world);
- for (L2Npc oracle : world.oracle)
- {
- oracle.decayMe();
- }
- }
- else if (event.equalsIgnoreCase("CoralGarden"))
- {
- runCoral(world);
- for (L2Npc oracle : world.oracle)
- {
- oracle.decayMe();
- }
- }
- else if (event.equalsIgnoreCase("spawn_oracle"))
- {
- addSpawn(32271, 153572, 142075, -9728, 10800, false, 0, false, world.getInstanceId());
- addSpawn((getRandom(10) < 5 ? 29116 : 29117), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, world.getInstanceId()); // Baylor's Chest
- addSpawn(ORACLE_GUIDE_4, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
- cancelQuestTimer("baylor_despawn", npc, null);
- cancelQuestTimers("baylor_skill");
- }
- else if (event.equalsIgnoreCase("baylorEffect0"))
- {
- npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- npc.broadcastSocialAction(1);
- startQuestTimer("baylorCamera0", 11000, npc, null);
- startQuestTimer("baylorEffect1", 19000, npc, null);
- }
- else if (event.equalsIgnoreCase("baylorCamera0"))
- {
- npc.broadcastPacket(new SpecialCamera(npc, 500, -45, 170, 5000, 9000, 0, 0, 1, 0, 0));
- }
- else if (event.equalsIgnoreCase("baylorEffect1"))
- {
- npc.broadcastPacket(new SpecialCamera(npc, 300, 0, 120, 2000, 5000, 0, 0, 1, 0, 0));
- npc.broadcastSocialAction(3);
- startQuestTimer("baylorEffect2", 4000, npc, null);
- }
- else if (event.equalsIgnoreCase("baylorEffect2"))
- {
- npc.broadcastPacket(new SpecialCamera(npc, 747, 0, 160, 2000, 3000, 0, 0, 1, 0, 0));
- npc.broadcastPacket(new MagicSkillUse(npc, npc, 5402, 1, 2000, 0));
- startQuestTimer("RaidStart", 2000, npc, null);
- }
- else if (event.equalsIgnoreCase("BaylorMinions"))
- {
- for (int i = 0; i < 10; i++)
- {
- int radius = 300;
- int x = (int) (radius * Math.cos(i * 0.618));
- int y = (int) (radius * Math.sin(i * 0.618));
- L2Npc mob = addSpawn(29104, 153571 + x, 142075 + y, -12737, 0, false, 0, false, world.getInstanceId());
- mob.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- world._animationMobs.add(mob);
- }
- startQuestTimer("baylorEffect0", 200, npc, null);
- }
- else if (event.equalsIgnoreCase("RaidStart"))
- {
- world._camera.decayMe();
- world._camera = null;
- npc.setIsParalyzed(false);
- for (L2PcInstance p : world._raiders)
- {
- p.setIsParalyzed(false);
- Throw(npc, p);
- if (p.getSummon() != null)
- {
- Throw(npc, p.getSummon());
- }
- }
- world._raidStatus = 0;
- for (L2Npc mob : world._animationMobs)
- {
- mob.doDie(mob);
- }
- world._animationMobs.clear();
- startQuestTimer("baylor_despawn", 60000, npc, null, true);
- startQuestTimer("checkBaylorAttack", 1000, npc, null);
- }
- else if (event.equalsIgnoreCase("checkBaylorAttack"))
- {
- if (npc.isInCombat())
- {
- cancelQuestTimers("checkBaylorAttack");
- startQuestTimer("baylor_alarm", 40000, npc, null);
- startQuestTimer("baylor_skill", 5000, npc, null, true);
- world._raidStatus++;
- }
- else
- {
- startQuestTimer("checkBaylorAttack", 1000, npc, null);
- }
- }
- else if (event.equalsIgnoreCase("baylor_alarm"))
- {
- if (world._alarm == null)
- {
- int[] spawnLoc = ALARMSPAWN[getRandom(ALARMSPAWN.length)];
- npc.addSkill(SkillData.getInstance().getSkill(5244, 1));
- npc.addSkill(SkillData.getInstance().getSkill(5245, 1));
- world._alarm = addSpawn(ALARMID, spawnLoc[0], spawnLoc[1], spawnLoc[2], 10800, false, 0, false, world.getInstanceId());
- world._alarm.disableCoreAI(true);
- world._alarm.setIsImmobilized(true);
- 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));
- }
- }
- else if (event.equalsIgnoreCase("baylor_skill"))
- {
- if (world._baylor == null)
- {
- cancelQuestTimers("baylor_skill");
- }
- else
- {
- int maxHp = npc.getMaxHp();
- double nowHp = npc.getStatus().getCurrentHp();
- int rand = getRandom(100);
-
- if ((nowHp < (maxHp * 0.2)) && (world._raidStatus < 3) && !npc.isAffectedBySkill(5224) && !npc.isAffectedBySkill(5225))
- {
- if ((nowHp < (maxHp * 0.15)) && (world._raidStatus == 2))
- {
- npc.doCast(SkillData.getInstance().getSkill(5225, 1));
- npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
- }
- else if ((rand < 10) || (nowHp < (maxHp * 0.15)))
- {
- npc.doCast(SkillData.getInstance().getSkill(5225, 1));
- npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.DEMON_KING_BELETH_GIVE_ME_THE_POWER_AAAHH));
- startQuestTimer("baylor_remove_invul", 30000, world._baylor, null);
- }
- }
- else if ((nowHp < (maxHp * 0.3)) && (rand > 50) && !npc.isAffectedBySkill(5225) && !npc.isAffectedBySkill(5224))
- {
- npc.doCast(SkillData.getInstance().getSkill(5224, 1));
- }
- else if (rand < 33)
- {
- npc.setTarget(world._raiders.get(getRandom(world._raiders.size())));
- npc.doCast(SkillData.getInstance().getSkill(5229, 1));
- }
- }
- }
- else if (event.equalsIgnoreCase("baylor_remove_invul"))
- {
- npc.stopSkillEffects(false, 5225);
- }
- else if (event.equalsIgnoreCase("Baylor"))
- {
- world._baylor = addSpawn(29099, 153572, 142075, -12738, 10800, false, 0, false, world.getInstanceId());
- world._baylor.setIsParalyzed(true);
- world._camera = addSpawn(29120, 153273, 141400, -12738, 10800, false, 0, false, world.getInstanceId());
- world._camera.broadcastPacket(new SpecialCamera(world._camera, 700, -45, 160, 500, 15200, 0, 0, 1, 0, 0));
- startQuestTimer("baylorMinions", 2000, world._baylor, null);
- }
- else if (!event.endsWith("Food"))
- {
- return "";
- }
- else if (event.equalsIgnoreCase("autoFood"))
- {
- if (!world.crystalGolems.containsKey(npc))
- {
- world.crystalGolems.put(npc, new CrystalGolem());
- }
- if ((world.getStatus() != 3) || !world.crystalGolems.containsKey(npc) || (world.crystalGolems.get(npc).foodItem != null) || world.crystalGolems.get(npc).isAtDestination)
- {
- return "";
- }
- CrystalGolem cryGolem = world.crystalGolems.get(npc);
- List<L2Object> crystals = new FastList<>();
- for (L2Object object : L2World.getInstance().getVisibleObjects(npc, 300))
- {
- if ((object instanceof L2ItemInstance) && (object.getId() == CRYSTALFOOD))
- {
- crystals.add(object);
- }
- }
- int minDist = 300000;
- for (L2Object crystal : crystals)
- {
- int dx = npc.getX() - crystal.getX();
- int dy = npc.getY() - crystal.getY();
- int d = (dx * dx) + (dy * dy);
- if (d < minDist)
- {
- minDist = d;
- cryGolem.foodItem = (L2ItemInstance) crystal;
- }
- }
- if (minDist != 300000)
- {
- startQuestTimer("getFood", 2000, npc, null);
- }
- else
- {
- if (getRandom(100) < 5)
- {
- npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 1, npc.getName(), NpcStringId.AH_IM_HUNGRY));
- }
- startQuestTimer("autoFood", 2000, npc, null);
- }
- return "";
- }
- else if (!world.crystalGolems.containsKey(npc) || world.crystalGolems.get(npc).isAtDestination)
- {
- return "";
- }
- else if (event.equalsIgnoreCase("backFood"))
- {
- if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
- {
- cancelQuestTimers("backFood");
- npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
- world.crystalGolems.get(npc).foodItem = null;
- startQuestTimer("autoFood", 2000, npc, null);
- }
- }
- else if (event.equalsIgnoreCase("reachFood"))
- {
- CrystalGolem cryGolem = world.crystalGolems.get(npc);
- int dx;
- int dy;
- if ((cryGolem.foodItem == null) || !cryGolem.foodItem.isVisible())
- {
- npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, cryGolem.oldLoc);
- cancelQuestTimers("reachFood");
- startQuestTimer("backFood", 2000, npc, null, true);
- return "";
- }
- else if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
- {
- L2World.getInstance().removeVisibleObject(cryGolem.foodItem, cryGolem.foodItem.getWorldRegion());
- L2World.getInstance().removeObject(cryGolem.foodItem);
- npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
- cryGolem.foodItem = null;
- dx = npc.getX() - 142999;
- dy = npc.getY() - 151671;
- int d1 = (dx * dx) + (dy * dy);
- dx = npc.getX() - 139494;
- dy = npc.getY() - 151668;
- int d2 = (dx * dx) + (dy * dy);
- if ((d1 < 10000) || (d2 < 10000))
- {
- npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
- cryGolem.isAtDestination = true;
- world.correctGolems++;
- if (world.correctGolems >= 2)
- {
- openDoor(24220026, world.getInstanceId());
- world.setStatus(4);
- }
- }
- else
- {
- startQuestTimer("autoFood", 2000, npc, null);
- }
- cancelQuestTimers("reachFood");
- }
- return "";
- }
- else if (event.equalsIgnoreCase("getFood"))
- {
- CrystalGolem cryGolem = world.crystalGolems.get(npc);
- Location newLoc = new Location(cryGolem.foodItem.getX(), cryGolem.foodItem.getY(), cryGolem.foodItem.getZ(), 0);
- cryGolem.oldLoc = new Location(npc.getX(), npc.getY(), npc.getZ(), npc.getHeading());
- npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newLoc);
- startQuestTimer("reachFood", 2000, npc, null, true);
- cancelQuestTimers("getFood");
- }
- }
- return "";
- }
-
- private void giveRewards(L2PcInstance player, int instanceId, int bossCry, boolean isBaylor)
- {
- final int num = Math.max((int) Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER, 1);
-
- L2Party party = player.getParty();
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getInstanceId() == instanceId)
- {
- final QuestState st = getQuestState(partyMember, true);
- if (!isBaylor && st.hasQuestItems(CONT_CRYSTAL))
- {
- st.takeItems(CONT_CRYSTAL, 1);
- st.giveItems(bossCry, 1);
- }
- if (getRandom(10) < 5)
- {
- st.giveItems(WHITE_SEED, num);
- }
- else
- {
- st.giveItems(BLACK_SEED, num);
- }
- }
- }
- }
- else if (player.getInstanceId() == instanceId)
- {
- QuestState st = getQuestState(player, false);
- if (st == null)
- {
- st = newQuestState(player);
- }
- if (!isBaylor && st.hasQuestItems(CONT_CRYSTAL))
- {
- st.takeItems(CONT_CRYSTAL, 1);
- st.giveItems(bossCry, 1);
- }
- if (getRandom(10) < 5)
- {
- st.giveItems(WHITE_SEED, num);
- }
- else
- {
- st.giveItems(BLACK_SEED, num);
- }
- }
-
- }
-
- @Override
- public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if ((world.getStatus() == 2) && world.npcList1.containsKey(npc))
- {
- world.npcList1.put(npc, true);
- for (boolean isDead : world.npcList1.values())
- {
- if (!isDead)
- {
- return "";
- }
- }
- world.setStatus(3);
- world.tears = addSpawn(TEARS, 144298, 154420, -11854, 32767, false, 0, false, world.getInstanceId()); // Tears
- CrystalGolem crygolem1 = new CrystalGolem();
- CrystalGolem crygolem2 = new CrystalGolem();
- world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 140547, 151670, -11813, 32767, false, 0, false, world.getInstanceId()), crygolem1);
- world.crystalGolems.put(addSpawn(CRYSTAL_GOLEM, 141941, 151684, -11813, 63371, false, 0, false, world.getInstanceId()), crygolem2);
- for (L2Npc crygolem : world.crystalGolems.keySet())
- {
- startQuestTimer("autoFood", 2000, crygolem, null);
- }
- }
- else if ((world.getStatus() == 4) && (npc.getId() == TEARS))
- {
- InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
- addSpawn(32280, 144312, 154420, -11855, 0, false, 0, false, world.getInstanceId());
- giveRewards(player, npc.getInstanceId(), BOSS_CRYSTAL_3, false);
- }
- else if ((world.getStatus() == 2) && world.keyKeepers.contains(npc))
- {
- if (npc.getId() == GK1)
- {
- npc.dropItem(player, 9698, 1);
- runEmeraldSquare(world);
- }
- else if (npc.getId() == GK2)
- {
- npc.dropItem(player, 9699, 1);
- runSteamRooms(world, STEAM1_SPAWNS, 22);
- L2Party party = player.getParty();
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getInstanceId() == world.getInstanceId())
- {
- SkillData.getInstance().getSkill(5239, 1).applyEffects(partyMember, partyMember);
- startQuestTimer("Timer2", 300000, npc, partyMember);
- }
- }
- }
- else
- {
- SkillData.getInstance().getSkill(5239, 1).applyEffects(player, player);
- startQuestTimer("Timer2", 300000, npc, player);
- }
- startQuestTimer("Timer21", 300000, npc, null);
- }
- for (L2Npc gk : world.keyKeepers)
- {
- if (gk != npc)
- {
- gk.decayMe();
- }
- }
- }
- else if (world.getStatus() == 3)
- {
- if (checkKillProgress(0, npc, world))
- {
- world.setStatus(4);
- addSpawn(TOURMALINE, 148202, 144791, -12235, 0, false, 0, false, world.getInstanceId());
- }
- else
- {
- return "";
- }
- }
- else if (world.getStatus() == 4)
- {
- if (npc.getId() == TOURMALINE)
- {
- world.setStatus(5);
- addSpawn(TEROD, 147777, 146780, -12281, 0, false, 0, false, world.getInstanceId());
- }
- }
- else if (world.getStatus() == 5)
- {
- if (npc.getId() == TEROD)
- {
- world.setStatus(6);
- addSpawn(TOURMALINE, 143694, 142659, -11882, 0, false, 0, false, world.getInstanceId());
- }
- }
- else if (world.getStatus() == 6)
- {
- if (npc.getId() == TOURMALINE)
- {
- world.setStatus(7);
- addSpawn(DOLPH, 142054, 143288, -11825, 0, false, 0, false, world.getInstanceId());
- }
- }
- else if (world.getStatus() == 7)
- {
- if (npc.getId() == DOLPH)
- {
- world.setStatus(8);
- // first door opener trap
- addTrap(DOOR_OPENING_TRAP[0], DOOR_OPENING_TRAP[1], DOOR_OPENING_TRAP[2], DOOR_OPENING_TRAP[3], DOOR_OPENING_TRAP[4], null, world.getInstanceId());
- }
- }
- else if (world.getStatus() == 8)
- {
- for (int i = 0; i < 4; i++)
- {
- if ((world.roomsStatus[i] == 1) && checkKillProgress(i + 1, npc, world))
- {
- world.roomsStatus[i] = 2;
- }
- if (world.roomsStatus[i] == 2)
- {
- world.cleanedRooms++;
- if (world.cleanedRooms == 21)
- {
- runDarnel(world);
- }
- }
- }
- }
- else if ((world.getStatus() >= 22) && (world.getStatus() <= 25))
- {
- if (npc.getId() == 22416)
- {
- for (L2Npc oracle : world.oracles.keySet())
- {
- if (world.oracles.get(oracle) == npc)
- {
- world.oracles.put(oracle, null);
- }
- }
- }
- if (checkKillProgress(0, npc, world))
- {
- world.npcList2.clear();
- int[][] oracleOrder;
- switch (world.getStatus())
- {
- case 22:
- closeDoor(DOOR6, npc.getInstanceId());
- oracleOrder = ordreOracle1;
- break;
- case 23:
- oracleOrder = ordreOracle2;
- break;
- case 24:
- oracleOrder = ordreOracle3;
- break;
- case 25:
- world.setStatus(26);
- L2Party party = player.getParty();
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- partyMember.stopSkillEffects(true, 5239);
- }
- }
- cancelQuestTimers("Timer5");
- cancelQuestTimers("Timer51");
- openDoor(DOOR3, npc.getInstanceId());
- openDoor(DOOR4, npc.getInstanceId());
- L2Npc kechi = addSpawn(KECHI, 154069, 149525, -12158, 51165, false, 0, false, world.getInstanceId());
- startQuestTimer("checkKechiAttack", 1000, kechi, null);
- return "";
- default:
- _log.warning("CrystalCavern-SteamCorridor: status " + world.getStatus() + " error. OracleOrder not found in " + world.getInstanceId());
- return "";
- }
- runSteamOracles(world, oracleOrder);
- }
- }
- else if (((world.getStatus() == 9) && (npc.getId() == DARNEL)) || ((world.getStatus() == 26) && (npc.getId() == KECHI)))
- {
- InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
- int bossCry;
- if (npc.getId() == KECHI)
- {
- bossCry = BOSS_CRYSTAL_2;
- cancelQuestTimers("spawnGuards");
- addSpawn(32280, 154077, 149527, -12159, 0, false, 0, false, world.getInstanceId());
- }
- else if (npc.getId() == DARNEL)
- {
- bossCry = BOSS_CRYSTAL_1;
- addSpawn(32280, 152761, 145950, -12588, 0, false, 0, false, world.getInstanceId());
- }
- else
- {
- // something is wrong
- return "";
- }
- giveRewards(player, npc.getInstanceId(), bossCry, false);
- }
- if (npc.getId() == ALARMID)
- {
- world._baylor.removeSkill(5244);
- world._baylor.removeSkill(5245);
- world._alarm = null;
- if ((world._baylor.getMaxHp() * 0.3) < world._baylor.getStatus().getCurrentHp())
- {
- startQuestTimer("baylor_alarm", 40000, world._baylor, null);
- }
- }
- else if (npc.getId() == BAYLOR)
- {
- world.setStatus(31);
- world._baylor = null;
- npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
- Instance baylorInstance = InstanceManager.getInstance().getInstance(npc.getInstanceId());
- baylorInstance.setDuration(300000);
- this.startQuestTimer("spawn_oracle", 1000, npc, null);
- giveRewards(player, npc.getInstanceId(), -1, true);
- }
- }
- return "";
- }
-
- @Override
- public String onTalk(L2Npc npc, L2PcInstance player)
- {
- int npcId = npc.getId();
- QuestState st = getQuestState(player, false);
- if (st == null)
- {
- st = newQuestState(player);
- }
- if (npcId == ORACLE_GUIDE_1)
- {
- enterInstance(player, "CrystalCaverns.xml", new Location(143348, 148707, -11972));
- return "";
- }
-
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (npcId == CRYSTAL_GOLEM)
- {
- }
- else if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && world.OracleTriggered[npc.getId() - 32275])
- {
- boolean doTeleport = false;
- Location loc = null;
- L2Party party = player.getParty();
- doTeleport = true;
- switch (npc.getId())
- {
- case 32275:
- if (world.getStatus() == 22)
- {
- runSteamRooms(world, STEAM2_SPAWNS, 23);
- }
- loc = new Location(147529, 152587, -12169);
- cancelQuestTimers("Timer2");
- cancelQuestTimers("Timer21");
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getInstanceId() == world.getInstanceId())
- {
- partyMember.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 2).applyEffects(partyMember, partyMember);
- startQuestTimer("Timer3", 600000, npc, partyMember);
- }
- }
- }
- else
- {
- player.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 2).applyEffects(player, player);
- startQuestTimer("Timer3", 600000, npc, player);
- }
- startQuestTimer("Timer31", 600000, npc, null);
- break;
- case 32276:
- if (world.getStatus() == 23)
- {
- runSteamRooms(world, STEAM3_SPAWNS, 24);
- }
- loc = new Location(150194, 152610, -12169);
- cancelQuestTimers("Timer3");
- cancelQuestTimers("Timer31");
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getInstanceId() == world.getInstanceId())
- {
- partyMember.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 4).applyEffects(partyMember, partyMember);
- startQuestTimer("Timer4", 1200000, npc, partyMember);
- }
- }
- }
- else
- {
- player.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 4).applyEffects(player, player);
- startQuestTimer("Timer4", 1200000, npc, player);
- }
- startQuestTimer("Timer41", 1200000, npc, null);
- break;
- case 32277:
- if (world.getStatus() == 24)
- {
- runSteamRooms(world, STEAM4_SPAWNS, 25);
- }
- loc = new Location(149743, 149986, -12141);
- cancelQuestTimers("Timer4");
- cancelQuestTimers("Timer41");
- if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- if (partyMember.getInstanceId() == world.getInstanceId())
- {
- partyMember.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 3).applyEffects(partyMember, partyMember);
- startQuestTimer("Timer5", 900000, npc, partyMember);
- }
- }
- }
- else
- {
- player.stopSkillEffects(true, 5239);
- SkillData.getInstance().getSkill(5239, 3).applyEffects(player, player);
- startQuestTimer("Timer5", 900000, npc, player);
- }
- startQuestTimer("Timer51", 900000, npc, null);
- break;
- default:
- // something is wrong
- doTeleport = false;
- }
- if (doTeleport && (loc != null))
- {
- if (!checkOracleConditions(player))
- {
- return "";
- }
- else if (party != null)
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- partyMember.destroyItemByItemId("Quest", RED_CORAL, 1, player, true);
- teleportPlayer(partyMember, loc, npc.getInstanceId());
- }
- }
- else
- {
- teleportPlayer(player, loc, npc.getInstanceId());
- }
- }
- }
- else if (npc.getId() == ORACLE_GUIDE_3)
- {
- if ((world.getStatus() < 30) && checkBaylorConditions(player))
- {
- world._raiders.clear();
- L2Party party = player.getParty();
- if (party == null)
- {
- world._raiders.add(player);
- }
- else
- {
- for (L2PcInstance partyMember : party.getMembers())
- {
- // int rnd = getRandom(100);
- // 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.
- world._raiders.add(partyMember);
- }
- }
- }
- else
- {
- return "";
- }
- world.setStatus(30);
- long time = world.endTime - System.currentTimeMillis();
- Instance baylorInstance = InstanceManager.getInstance().getInstance(world.getInstanceId());
- baylorInstance.setDuration((int) time);
-
- int radius = 150;
- int i = 0;
- int members = world._raiders.size();
- for (L2PcInstance p : world._raiders)
- {
- int x = (int) (radius * Math.cos((i * 2 * Math.PI) / members));
- int y = (int) (radius * Math.sin((i++ * 2 * Math.PI) / members));
- p.teleToLocation(new Location(153571 + x, 142075 + y, -12737));
- L2Summon pet = p.getSummon();
- if (pet != null)
- {
- pet.teleToLocation(new Location(153571 + x, 142075 + y, -12737), true);
- pet.broadcastPacket(new ValidateLocation(pet));
- }
- p.setIsParalyzed(true);
- p.broadcastPacket(new ValidateLocation(p));
- }
- startQuestTimer("Baylor", 30000, npc, null);
- }
- else if ((npc.getId() == ORACLE_GUIDE_4) && (world.getStatus() == 31))
- {
- teleportPlayer(player, new Location(153522, 144212, -9747), npc.getInstanceId());
- }
- }
- return "";
- }
-
- @Override
- public String onTrapAction(L2TrapInstance trap, L2Character trigger, TrapAction action)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- switch (action)
- {
- case TRAP_DISARMED:
- if (trap.getId() == DOOR_OPENING_TRAP[0])
- {
- openDoor(24220001, world.getInstanceId());
- runEmeraldRooms(world, ROOM1_SPAWNS, 1);
- }
- break;
- }
- }
- return null;
- }
-
- @Override
- public String onEnterZone(L2Character character, L2ZoneType zone)
- {
- if (character instanceof L2PcInstance)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (world.getStatus() == 8)
- {
- int room;
- int[][] spawns;
- switch (zone.getId())
- {
- case 20105:
- spawns = ROOM2_SPAWNS;
- room = 2;
- break;
- case 20106:
- spawns = ROOM3_SPAWNS;
- room = 3;
- break;
- case 20107:
- spawns = ROOM4_SPAWNS;
- room = 4;
- break;
- default:
- return super.onEnterZone(character, zone);
- }
- for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
- {
- if (door.getId() == (room + 24220000))
- {
- if (door.getOpen())
- {
- return "";
- }
- QuestState st = ((L2PcInstance) character).getQuestState(getName());
- if (st == null)
- {
- st = newQuestState((L2PcInstance) character);
- }
- if (!st.hasQuestItems(RACE_KEY))
- {
- return "";
- }
- if (world.roomsStatus[zone.getId() - 20104] == 0)
- {
- runEmeraldRooms(world, spawns, room);
- }
- door.openMe();
- st.takeItems(RACE_KEY, 1);
- world.openedDoors.put(door, (L2PcInstance) character);
- break;
- }
- }
- }
- }
- }
- return super.onEnterZone(character, zone);
- }
-
- @Override
- public String onExitZone(L2Character character, L2ZoneType zone)
- {
- if (character instanceof L2PcInstance)
- {
- InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
- if (tmpworld instanceof CCWorld)
- {
- CCWorld world = (CCWorld) tmpworld;
- if (world.getStatus() == 8)
- {
- int doorId;
- switch (zone.getId())
- {
- case 20105:
- doorId = 24220002;
- break;
- case 20106:
- doorId = 24220003;
- break;
- case 20107:
- doorId = 24220004;
- break;
- default:
- return super.onExitZone(character, zone);
- }
- for (L2DoorInstance door : InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoors())
- {
- if (door.getId() == doorId)
- {
- if (door.getOpen() && (world.openedDoors.get(door) == character))
- {
- door.closeMe();
- world.openedDoors.remove(door);
- }
- break;
- }
- }
-
- }
- }
- }
- return super.onExitZone(character, zone);
- }
-
- public static void main(String[] args)
- {
- // now call the constructor (starts up the)
- new CrystalCaverns();
- }
- }
|