NornilsGarden.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package instances.NornilsGarden;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.datatables.SkillTable;
  18. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  19. import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
  20. import com.l2jserver.gameserver.instancemanager.QuestManager;
  21. import com.l2jserver.gameserver.model.L2Effect;
  22. import com.l2jserver.gameserver.model.L2Party;
  23. import com.l2jserver.gameserver.model.L2Skill;
  24. import com.l2jserver.gameserver.model.actor.L2Character;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  27. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  28. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  29. import com.l2jserver.gameserver.model.entity.Instance;
  30. import com.l2jserver.gameserver.model.quest.Quest;
  31. import com.l2jserver.gameserver.model.quest.QuestState;
  32. import com.l2jserver.gameserver.model.quest.State;
  33. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  34. import com.l2jserver.gameserver.network.SystemMessageId;
  35. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  36. import com.l2jserver.gameserver.util.Util;
  37. import com.l2jserver.util.Rnd;
  38. /**
  39. ** @author Gnacik
  40. **
  41. ** 2010-10-15 Based on official server Naia
  42. */
  43. public class NornilsGarden extends Quest
  44. {
  45. private class NornilsWorld extends InstanceWorld
  46. {
  47. public L2Npc first_npc = null;
  48. public boolean spawned_1 = false;
  49. public boolean spawned_2 = false;
  50. public boolean spawned_3 = false;
  51. public boolean spawned_4 = false;
  52. public NornilsWorld()
  53. {
  54. }
  55. }
  56. private static final String qn = "NornilsGarden";
  57. private static final int INSTANCE_ID = 11;
  58. private static final int DURATION_TIME = 70;
  59. private static final int EMPTY_DESTROY_TIME = 5;
  60. private static final int INSTANCE_LVL_MIN = 18;
  61. private static final int INSTANCE_LVL_MAX = 22;
  62. private static final int _garden_guard = 32330;
  63. private static final int[] _final_gates = { 32260, 32261, 32262 };
  64. private static final int[] SPAWN_PPL = { -111184, 74540, -12430 };
  65. private static final int[] EXIT_PPL = { -74058, 52040, -3680 };
  66. private static final int[][] _auto_gates =
  67. {
  68. { 20110, 16200001 }, // Warriors gate
  69. { 20111, 16200004 }, // Midway gate
  70. { 20112, 16200013 } // Gate
  71. };
  72. private static final L2Skill skill1 = SkillTable.getInstance().getInfo(4322, 1);
  73. private static final L2Skill skill2 = SkillTable.getInstance().getInfo(4327, 1);
  74. private static final L2Skill skill3 = SkillTable.getInstance().getInfo(4329, 1);
  75. private static final L2Skill skill4 = SkillTable.getInstance().getInfo(4324, 1);
  76. private static final int _herb_jar = 18478;
  77. private static final int[][] _gatekeepers =
  78. {
  79. { 18352, 9703, 0 }, // Kamael Guard
  80. { 18353, 9704, 0 }, // Guardian of Records
  81. { 18354, 9705, 0 }, // Guardian of Observation
  82. { 18355, 9706, 0 }, // Spicula's Guard
  83. { 18356, 9707, 16200024 }, // Harkilgamed's Gatekeeper
  84. { 18357, 9708, 16200025 }, // Rodenpicula's Gatekeeper
  85. { 18358, 9713, 0 }, // Guardian of Secrets
  86. { 18359, 9709, 16200023 }, // Arviterre's Guardian
  87. { 18360, 9710, 0 }, // Katenar's Gatekeeper
  88. { 18361, 9711, 0 }, // Guardian of Prediction
  89. { 25528, 9712, 0 } // Tiberias
  90. };
  91. private static final int[][] HP_HERBS_DROPLIST =
  92. {
  93. // itemId, count, chance
  94. { 8602, 1, 10 }, { 8601, 2, 40 }, { 8600, 3, 70 }
  95. };
  96. private static final int[][] _group_1 =
  97. {
  98. { 18363, -109899, 74431, -12528, 16488 },
  99. { 18483, -109701, 74501, -12528, 24576 },
  100. { 18483, -109892, 74886, -12528, 0 },
  101. { 18363, -109703, 74879, -12528, 49336 }
  102. };
  103. private static final int[][] _group_2 =
  104. {
  105. { 18363, -110393, 78276, -12848, 49152 },
  106. { 18363, -110561, 78276, -12848, 49152 },
  107. { 18362, -110414, 78495, -12905, 48112 },
  108. { 18362, -110545, 78489, -12903, 48939 },
  109. { 18483, -110474, 78601, -12915, 49488 },
  110. { 18362, -110474, 78884, -12915, 49338 },
  111. { 18483, -110389, 79131, -12915, 48539 },
  112. { 18483, -110551, 79134, -12915, 49151 }
  113. };
  114. private static final int[][] _group_3 =
  115. {
  116. { 18483, -107798, 80721, -12912, 0 },
  117. { 18483, -107798, 80546, -12912, 0 },
  118. { 18347, -108033, 80644, -12912, 0 },
  119. { 18363, -108520, 80647, -12912, 0 },
  120. { 18483, -108740, 80752, -12912, 0 },
  121. { 18363, -109016, 80642, -12912, 0 },
  122. { 18483, -108740, 80546, -12912, 0 }
  123. };
  124. private static final int[][] _group_4 =
  125. {
  126. { 18362, -110082, 83998, -12928, 0 },
  127. { 18362, -110082, 84210, -12928, 0 },
  128. { 18363, -109963, 84102, -12896, 0 },
  129. { 18347, -109322, 84102, -12880, 0 },
  130. { 18362, -109131, 84097, -12880, 0 },
  131. { 18483, -108932, 84101, -12880, 0 },
  132. { 18483, -109313, 84488, -12880, 0 },
  133. { 18362, -109122, 84490, -12880, 0 },
  134. { 18347, -108939, 84489, -12880, 0 }
  135. };
  136. private static final int[][] MP_HERBS_DROPLIST =
  137. {
  138. // itemId, count, chance
  139. { 8605, 1, 10 }, { 8604, 2, 40 }, { 8603, 3, 70 }
  140. };
  141. private static final void dropHerb(L2Npc mob, L2PcInstance player, int[][] drop)
  142. {
  143. final int chance = Rnd.get(100);
  144. for (int i = 0; i < drop.length; i++)
  145. {
  146. if (chance < drop[i][2])
  147. ((L2MonsterInstance)mob).dropItem(player, drop[i][0], drop[i][1]);
  148. }
  149. }
  150. private static final void removeBuffs(L2Character ch)
  151. {
  152. for (L2Effect e : ch.getAllEffects())
  153. {
  154. if (e == null)
  155. continue;
  156. L2Skill skill = e.getSkill();
  157. if (skill.isDebuff() || skill.isStayAfterDeath())
  158. continue;
  159. e.exit();
  160. }
  161. }
  162. private static final void giveBuffs(L2Character ch)
  163. {
  164. if(skill1 != null)
  165. skill1.getEffects(ch, ch);
  166. if(skill2 != null)
  167. skill2.getEffects(ch, ch);
  168. if(skill3 != null)
  169. skill3.getEffects(ch, ch);
  170. if(skill4 != null)
  171. skill4.getEffects(ch, ch);
  172. }
  173. private static final void teleportPlayer(L2PcInstance player, int[] coords, int instanceId)
  174. {
  175. QuestState st = player.getQuestState(qn);
  176. if (st == null)
  177. {
  178. Quest q = QuestManager.getInstance().getQuest(qn);
  179. st = q.newQuestState(player);
  180. }
  181. removeBuffs(player);
  182. giveBuffs(player);
  183. if (player.getPet() != null)
  184. {
  185. removeBuffs(player.getPet());
  186. giveBuffs(player.getPet());
  187. }
  188. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  189. player.setInstanceId(instanceId);
  190. player.teleToLocation(coords[0], coords[1], coords[2], true);
  191. }
  192. private void exitInstance(L2PcInstance player)
  193. {
  194. InstanceWorld inst = InstanceManager.getInstance().getWorld(player.getInstanceId());
  195. if (inst instanceof NornilsWorld)
  196. {
  197. NornilsWorld world = ((NornilsWorld) inst);
  198. world.allowed.remove(Integer.valueOf(player.getObjectId()));
  199. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  200. player.setInstanceId(0);
  201. player.teleToLocation(EXIT_PPL[0], EXIT_PPL[1], EXIT_PPL[2], true);
  202. }
  203. }
  204. private final synchronized String enterInstance(L2Npc npc, L2PcInstance player)
  205. {
  206. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  207. if (world != null)
  208. {
  209. if (!(world instanceof NornilsWorld) || world.templateId != INSTANCE_ID)
  210. {
  211. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
  212. return null;
  213. }
  214. // check for level difference again on reenter
  215. if (player.getLevel() > INSTANCE_LVL_MAX || player.getLevel() < INSTANCE_LVL_MIN)
  216. {
  217. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  218. sm.addPcName(player);
  219. player.sendPacket(sm);
  220. return null;
  221. }
  222. // check what instance still exist
  223. Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
  224. if (inst != null)
  225. {
  226. teleportPlayer(player, SPAWN_PPL , world.instanceId);
  227. }
  228. return null;
  229. }
  230. // Creating new instance
  231. else
  232. {
  233. String result = checkConditions(npc, player);
  234. if (!(result.equalsIgnoreCase("ok")))
  235. return result;
  236. final int instanceId = InstanceManager.getInstance().createDynamicInstance("NornilsGarden.xml");
  237. final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
  238. inst.setName(InstanceManager.getInstance().getInstanceIdName(INSTANCE_ID));
  239. final int[] returnLoc = { player.getX(), player.getY(), player.getZ() };
  240. inst.setSpawnLoc(returnLoc);
  241. inst.setAllowSummon(false);
  242. inst.setDuration(DURATION_TIME * 60000);
  243. inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
  244. world = new NornilsWorld();
  245. world.instanceId = instanceId;
  246. world.templateId = INSTANCE_ID;
  247. InstanceManager.getInstance().addWorld(world);
  248. _log.info("Nornils Garden: started, Instance: " + instanceId + " created by player: " + player.getName());
  249. prepareInstance((NornilsWorld) world);
  250. // and finally teleport party into instance
  251. final L2Party party = player.getParty();
  252. if(party != null)
  253. {
  254. for (L2PcInstance partyMember : party.getPartyMembers())
  255. {
  256. world.allowed.add(partyMember.getObjectId());
  257. teleportPlayer(partyMember, SPAWN_PPL, instanceId);
  258. }
  259. }
  260. return null;
  261. }
  262. }
  263. private void prepareInstance(NornilsWorld world)
  264. {
  265. world.first_npc = addSpawn(18362,-109702,74696,-12528, 49568, false, 0, false, world.instanceId);
  266. L2DoorInstance door = InstanceManager.getInstance().getInstance(world.instanceId).getDoor(16200010);
  267. if (door != null)
  268. {
  269. door.setTargetable(false);
  270. door.setMeshIndex(2);
  271. }
  272. }
  273. private void spawn1(L2Npc npc)
  274. {
  275. InstanceWorld inst = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  276. if (inst instanceof NornilsWorld)
  277. {
  278. NornilsWorld world = ((NornilsWorld) inst);
  279. if (npc.equals(world.first_npc) && !world.spawned_1)
  280. {
  281. world.spawned_1 = true;
  282. for (int mob[] : _group_1)
  283. {
  284. addSpawn(mob[0], mob[1], mob[2], mob[3], mob[4], false, 0, false, world.instanceId);
  285. }
  286. }
  287. }
  288. }
  289. private void spawn2(L2Npc npc)
  290. {
  291. InstanceWorld inst = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  292. if (inst instanceof NornilsWorld)
  293. {
  294. NornilsWorld world = ((NornilsWorld) inst);
  295. if (!world.spawned_2)
  296. {
  297. world.spawned_2 = true;
  298. for (int mob[] : _group_2)
  299. {
  300. addSpawn(mob[0], mob[1], mob[2], mob[3], mob[4], false, 0, false, world.instanceId);
  301. }
  302. }
  303. }
  304. }
  305. private void spawn3(L2Character cha)
  306. {
  307. InstanceWorld inst = InstanceManager.getInstance().getWorld(cha.getInstanceId());
  308. if (inst instanceof NornilsWorld)
  309. {
  310. NornilsWorld world = ((NornilsWorld) inst);
  311. if (!world.spawned_3)
  312. {
  313. world.spawned_3 = true;
  314. for (int mob[] : _group_3)
  315. {
  316. addSpawn(mob[0], mob[1], mob[2], mob[3], mob[4], false, 0, false, world.instanceId);
  317. }
  318. }
  319. }
  320. }
  321. private void spawn4(L2Character cha)
  322. {
  323. InstanceWorld inst = InstanceManager.getInstance().getWorld(cha.getInstanceId());
  324. if (inst instanceof NornilsWorld)
  325. {
  326. NornilsWorld world = ((NornilsWorld) inst);
  327. if (!world.spawned_4)
  328. {
  329. world.spawned_4 = true;
  330. for (int mob[] : _group_4)
  331. {
  332. addSpawn(mob[0], mob[1], mob[2], mob[3], mob[4], false, 0, false, world.instanceId);
  333. }
  334. }
  335. }
  336. }
  337. private void openDoor(QuestState st, L2PcInstance player, int doorId)
  338. {
  339. st.unset("correct");
  340. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
  341. if (tmpworld instanceof NornilsWorld)
  342. {
  343. L2DoorInstance door = InstanceManager.getInstance().getInstance(tmpworld.instanceId).getDoor(doorId);
  344. if (door != null)
  345. door.openMe();
  346. }
  347. }
  348. private static final String checkConditions(L2Npc npc, L2PcInstance player)
  349. {
  350. final L2Party party = player.getParty();
  351. // player must be in party
  352. if (party == null)
  353. {
  354. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_IN_PARTY_CANT_ENTER));
  355. return "32330-05.html";
  356. }
  357. // ...and be party leader
  358. if (party.getLeader() != player)
  359. {
  360. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER));
  361. return "32330-08.html";
  362. }
  363. boolean _kamael = false;
  364. // for each party member
  365. for (L2PcInstance partyMember : party.getPartyMembers())
  366. {
  367. // player level must be in range
  368. if (partyMember.getLevel() > INSTANCE_LVL_MAX)
  369. {
  370. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  371. sm.addPcName(partyMember);
  372. player.sendPacket(sm);
  373. return "32330-06.html";
  374. }
  375. if (partyMember.getLevel() < INSTANCE_LVL_MIN)
  376. {
  377. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  378. sm.addPcName(partyMember);
  379. player.sendPacket(sm);
  380. return "32330-07.html";
  381. }
  382. if ( partyMember.getClassId().level() != 0)
  383. {
  384. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  385. sm.addPcName(partyMember);
  386. player.sendPacket(sm);
  387. return "32330-06.html";
  388. }
  389. // player must be near party leader
  390. if (!partyMember.isInsideRadius(player, 500, true, true))
  391. {
  392. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  393. sm.addPcName(partyMember);
  394. player.sendPacket(sm);
  395. return "32330-08.html";
  396. }
  397. if (partyMember.getRace().ordinal() == 5)
  398. {
  399. QuestState checkst = partyMember.getQuestState("179_IntoTheLargeCavern");
  400. if(checkst != null && checkst.getState() == State.STARTED)
  401. {
  402. _kamael = true;
  403. }
  404. else
  405. {
  406. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_QUEST_REQUIREMENT_NOT_SUFFICIENT);
  407. sm.addPcName(partyMember);
  408. player.sendPacket(sm);
  409. return "32330-08.html";
  410. }
  411. }
  412. }
  413. if (!_kamael)
  414. {
  415. return "32330-08.html";
  416. }
  417. return "ok";
  418. }
  419. @Override
  420. public String onEnterZone(L2Character character, L2ZoneType zone)
  421. {
  422. if (character instanceof L2PcInstance
  423. && !character.isDead()
  424. && !character.isTeleporting()
  425. && ((L2PcInstance)character).isOnline())
  426. {
  427. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
  428. if (tmpworld instanceof NornilsWorld)
  429. {
  430. for (int _auto[] : _auto_gates)
  431. {
  432. if (zone.getId() == _auto[0])
  433. {
  434. L2DoorInstance door = InstanceManager.getInstance().getInstance(tmpworld.instanceId).getDoor(_auto[1]);
  435. if (door != null)
  436. door.openMe();
  437. }
  438. if (zone.getId() == 20111)
  439. spawn3(character);
  440. else if(zone.getId() == 20112)
  441. spawn4(character);
  442. }
  443. }
  444. }
  445. return super.onEnterZone(character,zone);
  446. }
  447. @Override
  448. public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  449. {
  450. player.sendMessage("On Event");
  451. String htmltext = event;
  452. QuestState st = player.getQuestState(qn);
  453. if(st == null)
  454. return getNoQuestMsg(player);
  455. if(npc.getNpcId() == _garden_guard && event.equalsIgnoreCase("enter_instance"))
  456. {
  457. try
  458. {
  459. htmltext = enterInstance(npc, player);
  460. }
  461. catch (Exception e)
  462. {
  463. }
  464. }
  465. else if (npc.getNpcId() == 32258 && event.equalsIgnoreCase("exit"))
  466. {
  467. try
  468. {
  469. exitInstance(player);
  470. }
  471. catch (Exception e)
  472. {
  473. }
  474. }
  475. else if (Util.contains(_final_gates, npc.getNpcId()))
  476. {
  477. if(event.equalsIgnoreCase("32260-02.html") || event.equalsIgnoreCase("32261-02.html") || event.equalsIgnoreCase("32262-02.html"))
  478. {
  479. st.unset("correct");
  480. }
  481. else if(Util.isDigit(event))
  482. {
  483. int correct = st.getInt("correct");
  484. correct++;
  485. st.set("correct", String.valueOf(correct));
  486. htmltext = npc.getNpcId()+"-0"+String.valueOf(correct+2)+".html";
  487. }
  488. else if (event.equalsIgnoreCase("check"))
  489. {
  490. int correct = st.getInt("correct");
  491. if(npc.getNpcId() == 32260 && correct == 3)
  492. openDoor(st, player, 16200014);
  493. else if (npc.getNpcId() == 32261 && correct == 3)
  494. openDoor(st, player, 16200015);
  495. else if (npc.getNpcId() == 32262 && correct == 4)
  496. openDoor(st, player, 16200016);
  497. else
  498. return npc.getNpcId()+"-00.html";
  499. }
  500. }
  501. return htmltext;
  502. }
  503. @Override
  504. public final String onTalk(L2Npc npc, L2PcInstance player)
  505. {
  506. if (Util.contains(_final_gates, npc.getNpcId()))
  507. {
  508. QuestState cst = player.getQuestState("179_IntoTheLargeCavern");
  509. if (cst != null && cst.getState() == State.STARTED)
  510. {
  511. return npc.getNpcId()+"-01.html";
  512. }
  513. else
  514. return getNoQuestMsg(player);
  515. }
  516. return null;
  517. }
  518. @Override
  519. public final String onFirstTalk (L2Npc npc, L2PcInstance player)
  520. {
  521. QuestState st = player.getQuestState(qn);
  522. if (st == null)
  523. {
  524. Quest q = QuestManager.getInstance().getQuest(qn);
  525. st = q.newQuestState(player);
  526. }
  527. return npc.getNpcId()+".html";
  528. }
  529. @Override
  530. public final String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  531. {
  532. if (npc.getNpcId() == _herb_jar && !npc.isDead())
  533. {
  534. dropHerb(npc, attacker, HP_HERBS_DROPLIST);
  535. dropHerb(npc, attacker, MP_HERBS_DROPLIST);
  536. npc.doDie(attacker);
  537. }
  538. else if (npc.getNpcId() == 18362 && npc.getInstanceId() > 0)
  539. {
  540. spawn1(npc);
  541. }
  542. return null;
  543. }
  544. @Override
  545. public final String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  546. {
  547. QuestState st = player.getQuestState(qn);
  548. if (st == null)
  549. return null;
  550. for (int _gk[] : _gatekeepers)
  551. {
  552. if (npc.getNpcId() == _gk[0])
  553. {
  554. // Drop key
  555. ((L2MonsterInstance)npc).dropItem(player, _gk[1], 1);
  556. // Check if gatekeeper should open bridge, and open it
  557. if (_gk[2] > 0)
  558. {
  559. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
  560. if (tmpworld instanceof NornilsWorld)
  561. {
  562. L2DoorInstance door = InstanceManager.getInstance().getInstance(tmpworld.instanceId).getDoor(_gk[2]);
  563. if (door != null)
  564. {
  565. door.openMe();
  566. door.sendInfo(player);
  567. }
  568. }
  569. }
  570. }
  571. if(npc.getNpcId() == 18355)
  572. spawn2(npc);
  573. }
  574. return super.onKill(npc, player, isPet);
  575. }
  576. public NornilsGarden(int questId, String name, String descr)
  577. {
  578. super(questId, name, descr);
  579. addStartNpc(_garden_guard);
  580. addFirstTalkId(_garden_guard);
  581. addTalkId(_garden_guard);
  582. for(int i[] : _gatekeepers)
  583. addKillId(i[0]);
  584. for(int i[] : _auto_gates)
  585. addEnterZoneId(i[0]);
  586. for(int i : _final_gates)
  587. addTalkId(i);
  588. addAttackId(_herb_jar);
  589. addAttackId(18362); // first garden guard
  590. }
  591. public static void main(String[] args)
  592. {
  593. new NornilsGarden(-1, qn, "instances");
  594. }
  595. }