SagasSuperClass.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  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 quests.SagasScripts;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.ai.CtrlIntention;
  18. import com.l2jserver.gameserver.instancemanager.QuestManager;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.L2Party;
  21. import com.l2jserver.gameserver.model.L2World;
  22. import com.l2jserver.gameserver.model.actor.L2Attackable;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. import com.l2jserver.gameserver.model.quest.jython.QuestJython;
  30. import com.l2jserver.gameserver.model.skills.L2Skill;
  31. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  32. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  33. import com.l2jserver.util.L2FastList;
  34. import com.l2jserver.util.L2FastMap;
  35. public class SagasSuperClass extends QuestJython
  36. {
  37. private static L2FastList<Quest> _scripts = new L2FastList<Quest>();
  38. public String qn = "SagasSuperClass";
  39. public int qnu;
  40. public int[] NPC = {};
  41. public int[] Items = {};
  42. public int[] Mob = {};
  43. public int[] classid = {};
  44. public int[] prevclass = {};
  45. public int[] X = {};
  46. public int[] Y = {};
  47. public int[] Z = {};
  48. public String[] Text = {};
  49. L2FastMap<L2Npc, Integer> _SpawnList = new L2FastMap<L2Npc, Integer>();
  50. int[] QuestClass[] =
  51. {
  52. {
  53. 0x7f
  54. },
  55. {
  56. 0x80,
  57. 0x81
  58. },
  59. {
  60. 0x82
  61. },
  62. {
  63. 0x05
  64. },
  65. {
  66. 0x14
  67. },
  68. {
  69. 0x15
  70. },
  71. {
  72. 0x02
  73. },
  74. {
  75. 0x03
  76. },
  77. {
  78. 0x2e
  79. },
  80. {
  81. 0x30
  82. },
  83. {
  84. 0x33
  85. },
  86. {
  87. 0x34
  88. },
  89. {
  90. 0x08
  91. },
  92. {
  93. 0x17
  94. },
  95. {
  96. 0x24
  97. },
  98. {
  99. 0x09
  100. },
  101. {
  102. 0x18
  103. },
  104. {
  105. 0x25
  106. },
  107. {
  108. 0x10
  109. },
  110. {
  111. 0x11
  112. },
  113. {
  114. 0x1e
  115. },
  116. {
  117. 0x0c
  118. },
  119. {
  120. 0x1b
  121. },
  122. {
  123. 0x28
  124. },
  125. {
  126. 0x0e
  127. },
  128. {
  129. 0x1c
  130. },
  131. {
  132. 0x29
  133. },
  134. {
  135. 0x0d
  136. },
  137. {
  138. 0x06
  139. },
  140. {
  141. 0x22
  142. },
  143. {
  144. 0x21
  145. },
  146. {
  147. 0x2b
  148. },
  149. {
  150. 0x37
  151. },
  152. {
  153. 0x39
  154. }
  155. };
  156. public SagasSuperClass(int id, String name, String descr)
  157. {
  158. super(id, name, descr);
  159. qnu = id;
  160. }
  161. public void registerNPCs()
  162. {
  163. addStartNpc(NPC[0]);
  164. addAttackId(Mob[2]);
  165. addAttackId(Mob[1]);
  166. addSkillSeeId(Mob[1]);
  167. addFirstTalkId(NPC[4]);
  168. for (int npc : NPC)
  169. {
  170. addTalkId(npc);
  171. }
  172. for (int mobid : Mob)
  173. {
  174. addKillId(mobid);
  175. }
  176. questItemIds = Items.clone();
  177. questItemIds[0] = 0;
  178. questItemIds[2] = 0; // remove Ice Crystal and Divine Stone of Wisdom
  179. for (int Archon_Minion = 21646; Archon_Minion < 21652; Archon_Minion++)
  180. {
  181. addKillId(Archon_Minion);
  182. }
  183. int[] Archon_Hellisha_Norm =
  184. {
  185. 18212,
  186. 18214,
  187. 18215,
  188. 18216,
  189. 18218
  190. };
  191. for (int element : Archon_Hellisha_Norm)
  192. {
  193. addKillId(element);
  194. }
  195. for (int Guardian_Angel = 27214; Guardian_Angel < 27217; Guardian_Angel++)
  196. {
  197. addKillId(Guardian_Angel);
  198. }
  199. }
  200. public void Cast(L2Npc npc, L2Character target, int skillId, int level)
  201. {
  202. target.broadcastPacket(new MagicSkillUse(target, target, skillId, level, 6000, 1));
  203. target.broadcastPacket(new MagicSkillUse(npc, npc, skillId, level, 6000, 1));
  204. }
  205. public void AutoChat(L2Npc npc, String text)
  206. {
  207. npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), text));
  208. }
  209. public void AddSpawn(QuestState st, L2Npc mob)
  210. {
  211. _SpawnList.put(mob, st.getPlayer().getObjectId());
  212. }
  213. public L2Npc FindSpawn(L2PcInstance player, L2Npc npc)
  214. {
  215. if (_SpawnList.containsKey(npc) && (_SpawnList.get(npc) == player.getObjectId()))
  216. {
  217. return npc;
  218. }
  219. return null;
  220. }
  221. public void DeleteSpawn(QuestState st, L2Npc npc)
  222. {
  223. if (_SpawnList.containsKey(npc))
  224. {
  225. _SpawnList.remove(npc);
  226. npc.deleteMe();
  227. }
  228. }
  229. public QuestState findRightState(L2Npc npc)
  230. {
  231. L2PcInstance player = null;
  232. QuestState st = null;
  233. if (_SpawnList.containsKey(npc))
  234. {
  235. player = L2World.getInstance().getPlayer(_SpawnList.get(npc));
  236. if (player != null)
  237. {
  238. st = player.getQuestState(qn);
  239. }
  240. }
  241. return st;
  242. }
  243. public void giveHallishaMark(QuestState st2)
  244. {
  245. if (st2.getInt("spawned") == 0)
  246. {
  247. if (st2.getQuestItemsCount(Items[3]) >= 700)
  248. {
  249. st2.takeItems(Items[3], 20);
  250. int xx = st2.getPlayer().getX();
  251. int yy = st2.getPlayer().getY();
  252. int zz = st2.getPlayer().getZ();
  253. L2Npc Archon = st2.addSpawn(Mob[1], xx, yy, zz);
  254. AddSpawn(st2, Archon);
  255. st2.set("spawned", "1");
  256. st2.startQuestTimer("Archon Hellisha has despawned", 600000, Archon);
  257. AutoChat(Archon, Text[13].replace("PLAYERNAME", st2.getPlayer().getName()));
  258. ((L2Attackable) Archon).addDamageHate(st2.getPlayer(), 0, 99999);
  259. Archon.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, st2.getPlayer(), null);
  260. }
  261. else
  262. {
  263. st2.giveItems(Items[3], getRandom(1, 4));
  264. }
  265. }
  266. }
  267. public QuestState findQuest(L2PcInstance player)
  268. {
  269. QuestState st = player.getQuestState(qn);
  270. if (st != null)
  271. {
  272. if (qnu != 68)
  273. {
  274. if (player.getClassId().getId() == QuestClass[qnu - 67][0])
  275. {
  276. return st;
  277. }
  278. }
  279. else
  280. {
  281. for (int q = 0; q < 2; q++)
  282. {
  283. if (player.getClassId().getId() == QuestClass[1][q])
  284. {
  285. return st;
  286. }
  287. }
  288. }
  289. }
  290. return null;
  291. }
  292. public int getClassId(L2PcInstance player)
  293. {
  294. if (player.getClassId().getId() == 0x81)
  295. {
  296. return classid[1];
  297. }
  298. return classid[0];
  299. }
  300. public int getPrevClass(L2PcInstance player)
  301. {
  302. if (player.getClassId().getId() == 0x81)
  303. {
  304. if (prevclass.length == 1)
  305. {
  306. return -1;
  307. }
  308. return prevclass[1];
  309. }
  310. return prevclass[0];
  311. }
  312. @Override
  313. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  314. {
  315. QuestState st = player.getQuestState(qn);
  316. String htmltext = "";
  317. if (st != null)
  318. {
  319. if (event.equalsIgnoreCase("0-011.htm") || event.equalsIgnoreCase("0-012.htm") || event.equalsIgnoreCase("0-013.htm") || event.equalsIgnoreCase("0-014.htm") || event.equalsIgnoreCase("0-015.htm"))
  320. {
  321. htmltext = event;
  322. }
  323. else if (event.equalsIgnoreCase("accept"))
  324. {
  325. st.set("cond", "1");
  326. st.setState(State.STARTED);
  327. st.playSound("ItemSound.quest_accept");
  328. st.giveItems(Items[10], 1);
  329. htmltext = "0-03.htm";
  330. }
  331. else if (event.equalsIgnoreCase("0-1"))
  332. {
  333. if (player.getLevel() < 76)
  334. {
  335. htmltext = "0-02.htm";
  336. if (st.getState() == State.CREATED)
  337. {
  338. st.exitQuest(true);
  339. }
  340. }
  341. else
  342. {
  343. htmltext = "0-05.htm";
  344. }
  345. }
  346. else if (event.equalsIgnoreCase("0-2"))
  347. {
  348. if (player.getLevel() >= 76)
  349. {
  350. st.exitQuest(false);
  351. st.set("cond", "0");
  352. htmltext = "0-07.htm";
  353. st.takeItems(Items[10], -1);
  354. st.addExpAndSp(2299404, 0);
  355. st.giveItems(57, 5000000);
  356. st.giveItems(6622, 1);
  357. int Class = getClassId(player);
  358. int prevClass = getPrevClass(player);
  359. player.setClassId(Class);
  360. if (!player.isSubClassActive() && (player.getBaseClass() == prevClass))
  361. {
  362. player.setBaseClass(Class);
  363. }
  364. player.broadcastUserInfo();
  365. Cast(npc, player, 4339, 1);
  366. }
  367. else
  368. {
  369. st.takeItems(Items[10], -1);
  370. st.playSound("ItemSound.quest_middle");
  371. st.set("cond", "20");
  372. htmltext = "0-08.htm";
  373. }
  374. }
  375. else if (event.equalsIgnoreCase("1-3"))
  376. {
  377. st.set("cond", "3");
  378. htmltext = "1-05.htm";
  379. }
  380. else if (event.equalsIgnoreCase("1-4"))
  381. {
  382. st.set("cond", "4");
  383. st.takeItems(Items[0], 1);
  384. if (Items[11] != 0)
  385. {
  386. st.takeItems(Items[11], 1);
  387. }
  388. st.giveItems(Items[1], 1);
  389. htmltext = "1-06.htm";
  390. }
  391. else if (event.equalsIgnoreCase("2-1"))
  392. {
  393. st.set("cond", "2");
  394. htmltext = "2-05.htm";
  395. }
  396. else if (event.equalsIgnoreCase("2-2"))
  397. {
  398. st.set("cond", "5");
  399. st.takeItems(Items[1], 1);
  400. st.giveItems(Items[4], 1);
  401. htmltext = "2-06.htm";
  402. }
  403. else if (event.equalsIgnoreCase("3-5"))
  404. {
  405. htmltext = "3-07.htm";
  406. }
  407. else if (event.equalsIgnoreCase("3-6"))
  408. {
  409. st.set("cond", "11");
  410. htmltext = "3-02.htm";
  411. }
  412. else if (event.equalsIgnoreCase("3-7"))
  413. {
  414. st.set("cond", "12");
  415. htmltext = "3-03.htm";
  416. }
  417. else if (event.equalsIgnoreCase("3-8"))
  418. {
  419. st.set("cond", "13");
  420. st.takeItems(Items[2], 1);
  421. st.giveItems(Items[7], 1);
  422. htmltext = "3-08.htm";
  423. }
  424. else if (event.equalsIgnoreCase("4-1"))
  425. {
  426. htmltext = "4-010.htm";
  427. }
  428. else if (event.equalsIgnoreCase("4-2"))
  429. {
  430. st.giveItems(Items[9], 1);
  431. st.set("cond", "18");
  432. st.playSound("ItemSound.quest_middle");
  433. htmltext = "4-011.htm";
  434. }
  435. else if (event.equalsIgnoreCase("4-3"))
  436. {
  437. st.giveItems(Items[9], 1);
  438. st.set("cond", "18");
  439. AutoChat(npc, Text[13].replace("PLAYERNAME", player.getName()));
  440. st.set("Quest0", "0");
  441. cancelQuestTimer("Mob_2 has despawned", npc, player);
  442. st.playSound("ItemSound.quest_middle");
  443. DeleteSpawn(st, npc);
  444. return null;
  445. }
  446. else if (event.equalsIgnoreCase("5-1"))
  447. {
  448. st.set("cond", "6");
  449. st.takeItems(Items[4], 1);
  450. Cast(npc, player, 4546, 1);
  451. st.playSound("ItemSound.quest_middle");
  452. htmltext = "5-02.htm";
  453. }
  454. else if (event.equalsIgnoreCase("6-1"))
  455. {
  456. st.set("cond", "8");
  457. st.takeItems(Items[5], 1);
  458. Cast(npc, player, 4546, 1);
  459. st.playSound("ItemSound.quest_middle");
  460. htmltext = "6-03.htm";
  461. }
  462. else if (event.equalsIgnoreCase("7-1"))
  463. {
  464. if (st.getInt("spawned") == 1)
  465. {
  466. htmltext = "7-03.htm";
  467. }
  468. else if (st.getInt("spawned") == 0)
  469. {
  470. L2Npc Mob_1 = st.addSpawn(Mob[0], X[0], Y[0], Z[0]);
  471. st.set("spawned", "1");
  472. st.startQuestTimer("Mob_1 Timer 1", 500, Mob_1);
  473. st.startQuestTimer("Mob_1 has despawned", 300000, Mob_1);
  474. AddSpawn(st, Mob_1);
  475. htmltext = "7-02.htm";
  476. }
  477. else
  478. {
  479. htmltext = "7-04.htm";
  480. }
  481. }
  482. else if (event.equalsIgnoreCase("7-2"))
  483. {
  484. st.set("cond", "10");
  485. st.takeItems(Items[6], 1);
  486. Cast(npc, player, 4546, 1);
  487. st.playSound("ItemSound.quest_middle");
  488. htmltext = "7-06.htm";
  489. }
  490. else if (event.equalsIgnoreCase("8-1"))
  491. {
  492. st.set("cond", "14");
  493. st.takeItems(Items[7], 1);
  494. Cast(npc, player, 4546, 1);
  495. st.playSound("ItemSound.quest_middle");
  496. htmltext = "8-02.htm";
  497. }
  498. else if (event.equalsIgnoreCase("9-1"))
  499. {
  500. st.set("cond", "17");
  501. st.takeItems(Items[8], 1);
  502. Cast(npc, player, 4546, 1);
  503. st.playSound("ItemSound.quest_middle");
  504. htmltext = "9-03.htm";
  505. }
  506. else if (event.equalsIgnoreCase("10-1"))
  507. {
  508. if (st.getInt("Quest0") == 0)
  509. {
  510. L2Npc Mob_3 = st.addSpawn(Mob[2], X[1], Y[1], Z[1]);
  511. L2Npc Mob_2 = st.addSpawn(NPC[4], X[2], Y[2], Z[2]);
  512. AddSpawn(st, Mob_3);
  513. AddSpawn(st, Mob_2);
  514. st.set("Mob_2", String.valueOf(Mob_2.getObjectId()));
  515. st.set("Quest0", "1");
  516. st.set("Quest1", "45");
  517. st.startRepeatingQuestTimer("Mob_3 Timer 1", 500, Mob_3);
  518. st.startQuestTimer("Mob_3 has despawned", 59000, Mob_3);
  519. st.startQuestTimer("Mob_2 Timer 1", 500, Mob_2);
  520. st.startQuestTimer("Mob_2 has despawned", 60000, Mob_2);
  521. htmltext = "10-02.htm";
  522. }
  523. else if (st.getInt("Quest1") == 45)
  524. {
  525. htmltext = "10-03.htm";
  526. }
  527. else
  528. {
  529. htmltext = "10-04.htm";
  530. }
  531. }
  532. else if (event.equalsIgnoreCase("10-2"))
  533. {
  534. st.set("cond", "19");
  535. st.takeItems(Items[9], 1);
  536. Cast(npc, player, 4546, 1);
  537. st.playSound("ItemSound.quest_middle");
  538. htmltext = "10-06.htm";
  539. }
  540. else if (event.equalsIgnoreCase("11-9"))
  541. {
  542. st.set("cond", "15");
  543. htmltext = "11-03.htm";
  544. }
  545. else if (event.equalsIgnoreCase("Mob_1 Timer 1"))
  546. {
  547. AutoChat(npc, Text[0].replace("PLAYERNAME", player.getName()));
  548. return null;
  549. }
  550. else if (event.equalsIgnoreCase("Mob_1 has despawned"))
  551. {
  552. AutoChat(npc, Text[1].replace("PLAYERNAME", player.getName()));
  553. st.set("spawned", "0");
  554. DeleteSpawn(st, npc);
  555. return null;
  556. }
  557. else if (event.equalsIgnoreCase("Archon Hellisha has despawned"))
  558. {
  559. AutoChat(npc, Text[6].replace("PLAYERNAME", player.getName()));
  560. st.set("spawned", "0");
  561. DeleteSpawn(st, npc);
  562. return null;
  563. }
  564. else if (event.equalsIgnoreCase("Mob_3 Timer 1"))
  565. {
  566. L2Npc Mob_2 = FindSpawn(player, (L2Npc) L2World.getInstance().findObject(st.getInt("Mob_2")));
  567. if (npc.getKnownList().knowsObject(Mob_2))
  568. {
  569. ((L2Attackable) npc).addDamageHate(Mob_2, 0, 99999);
  570. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, Mob_2, null);
  571. Mob_2.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc, null);
  572. AutoChat(npc, Text[14].replace("PLAYERNAME", player.getName()));
  573. cancelQuestTimer("Mob_3 Timer 1", npc, player);
  574. }
  575. return null;
  576. }
  577. else if (event.equalsIgnoreCase("Mob_3 has despawned"))
  578. {
  579. AutoChat(npc, Text[15].replace("PLAYERNAME", player.getName()));
  580. st.set("Quest0", "2");
  581. DeleteSpawn(st, npc);
  582. return null;
  583. }
  584. else if (event.equalsIgnoreCase("Mob_2 Timer 1"))
  585. {
  586. AutoChat(npc, Text[7].replace("PLAYERNAME", player.getName()));
  587. st.startQuestTimer("Mob_2 Timer 2", 1500, npc);
  588. if (st.getInt("Quest1") == 45)
  589. {
  590. st.set("Quest1", "0");
  591. }
  592. return null;
  593. }
  594. else if (event.equalsIgnoreCase("Mob_2 Timer 2"))
  595. {
  596. AutoChat(npc, Text[8].replace("PLAYERNAME", player.getName()));
  597. st.startQuestTimer("Mob_2 Timer 3", 10000, npc);
  598. return null;
  599. }
  600. else if (event.equalsIgnoreCase("Mob_2 Timer 3"))
  601. {
  602. if (st.getInt("Quest0") == 0)
  603. {
  604. st.startQuestTimer("Mob_2 Timer 3", 13000, npc);
  605. if (getRandom(2) == 0)
  606. {
  607. AutoChat(npc, Text[9].replace("PLAYERNAME", player.getName()));
  608. }
  609. else
  610. {
  611. AutoChat(npc, Text[10].replace("PLAYERNAME", player.getName()));
  612. }
  613. }
  614. return null;
  615. }
  616. else if (event.equalsIgnoreCase("Mob_2 has despawned"))
  617. {
  618. st.set("Quest1", String.valueOf(st.getInt("Quest1") + 1));
  619. if ((st.getInt("Quest0") == 1) || (st.getInt("Quest0") == 2) || (st.getInt("Quest1") > 3))
  620. {
  621. st.set("Quest0", "0");
  622. if (st.getInt("Quest0") == 1)
  623. {
  624. AutoChat(npc, Text[11].replace("PLAYERNAME", player.getName()));
  625. }
  626. else
  627. {
  628. AutoChat(npc, Text[12].replace("PLAYERNAME", player.getName()));
  629. }
  630. DeleteSpawn(st, npc);
  631. }
  632. else
  633. {
  634. st.startQuestTimer("Mob_2 has despawned", 1000, npc);
  635. }
  636. return null;
  637. }
  638. }
  639. else
  640. {
  641. return null;
  642. }
  643. return htmltext;
  644. }
  645. @Override
  646. public String onTalk(L2Npc npc, L2PcInstance player)
  647. {
  648. String htmltext = getNoQuestMsg(player);
  649. QuestState st = player.getQuestState(qn);
  650. if (st != null)
  651. {
  652. int npcId = npc.getNpcId();
  653. int cond = st.getInt("cond");
  654. if (st.isCompleted() && (npcId == NPC[0]))
  655. {
  656. htmltext = "<html><body>You have already completed this quest!</body></html>";
  657. }
  658. else if (player.getClassId().getId() == getPrevClass(player))
  659. {
  660. if (cond == 0)
  661. {
  662. if (npcId == NPC[0])
  663. {
  664. htmltext = "0-01.htm";
  665. }
  666. }
  667. else if (cond == 1)
  668. {
  669. if (npcId == NPC[0])
  670. {
  671. htmltext = "0-04.htm";
  672. }
  673. else if (npcId == NPC[2])
  674. {
  675. htmltext = "2-01.htm";
  676. }
  677. }
  678. else if (cond == 2)
  679. {
  680. if (npcId == NPC[2])
  681. {
  682. htmltext = "2-02.htm";
  683. }
  684. else if (npcId == NPC[1])
  685. {
  686. htmltext = "1-01.htm";
  687. }
  688. }
  689. else if (cond == 3)
  690. {
  691. if ((npcId == NPC[1]) && st.hasQuestItems(Items[0]))
  692. {
  693. htmltext = "1-02.htm";
  694. if ((Items[11] == 0) || st.hasQuestItems(Items[11]))
  695. {
  696. htmltext = "1-03.htm";
  697. }
  698. }
  699. }
  700. else if (cond == 4)
  701. {
  702. if (npcId == NPC[1])
  703. {
  704. htmltext = "1-04.htm";
  705. }
  706. else if (npcId == NPC[2])
  707. {
  708. htmltext = "2-03.htm";
  709. }
  710. }
  711. else if (cond == 5)
  712. {
  713. if (npcId == NPC[2])
  714. {
  715. htmltext = "2-04.htm";
  716. }
  717. else if (npcId == NPC[5])
  718. {
  719. htmltext = "5-01.htm";
  720. }
  721. }
  722. else if (cond == 6)
  723. {
  724. if (npcId == NPC[5])
  725. {
  726. htmltext = "5-03.htm";
  727. }
  728. else if (npcId == NPC[6])
  729. {
  730. htmltext = "6-01.htm";
  731. }
  732. }
  733. else if (cond == 7)
  734. {
  735. if (npcId == NPC[6])
  736. {
  737. htmltext = "6-02.htm";
  738. }
  739. }
  740. else if (cond == 8)
  741. {
  742. if (npcId == NPC[6])
  743. {
  744. htmltext = "6-04.htm";
  745. }
  746. else if (npcId == NPC[7])
  747. {
  748. htmltext = "7-01.htm";
  749. }
  750. }
  751. else if (cond == 9)
  752. {
  753. if (npcId == NPC[7])
  754. {
  755. htmltext = "7-05.htm";
  756. }
  757. }
  758. else if (cond == 10)
  759. {
  760. if (npcId == NPC[7])
  761. {
  762. htmltext = "7-07.htm";
  763. }
  764. else if (npcId == NPC[3])
  765. {
  766. htmltext = "3-01.htm";
  767. }
  768. }
  769. else if ((cond == 11) || (cond == 12))
  770. {
  771. if (npcId == NPC[3])
  772. {
  773. if (st.hasQuestItems(Items[2]))
  774. {
  775. htmltext = "3-05.htm";
  776. }
  777. else
  778. {
  779. htmltext = "3-04.htm";
  780. }
  781. }
  782. }
  783. else if (cond == 13)
  784. {
  785. if (npcId == NPC[3])
  786. {
  787. htmltext = "3-06.htm";
  788. }
  789. else if (npcId == NPC[8])
  790. {
  791. htmltext = "8-01.htm";
  792. }
  793. }
  794. else if (cond == 14)
  795. {
  796. if (npcId == NPC[8])
  797. {
  798. htmltext = "8-03.htm";
  799. }
  800. else if (npcId == NPC[11])
  801. {
  802. htmltext = "11-01.htm";
  803. }
  804. }
  805. else if (cond == 15)
  806. {
  807. if (npcId == NPC[11])
  808. {
  809. htmltext = "11-02.htm";
  810. }
  811. else if (npcId == NPC[9])
  812. {
  813. htmltext = "9-01.htm";
  814. }
  815. }
  816. else if (cond == 16)
  817. {
  818. if (npcId == NPC[9])
  819. {
  820. htmltext = "9-02.htm";
  821. }
  822. }
  823. else if (cond == 17)
  824. {
  825. if (npcId == NPC[9])
  826. {
  827. htmltext = "9-04.htm";
  828. }
  829. else if (npcId == NPC[10])
  830. {
  831. htmltext = "10-01.htm";
  832. }
  833. }
  834. else if (cond == 18)
  835. {
  836. if (npcId == NPC[10])
  837. {
  838. htmltext = "10-05.htm";
  839. }
  840. }
  841. else if (cond == 19)
  842. {
  843. if (npcId == NPC[10])
  844. {
  845. htmltext = "10-07.htm";
  846. }
  847. else if (npcId == NPC[0])
  848. {
  849. htmltext = "0-06.htm";
  850. }
  851. }
  852. else if (cond == 20)
  853. {
  854. if (npcId == NPC[0])
  855. {
  856. if (player.getLevel() >= 76)
  857. {
  858. htmltext = "0-09.htm";
  859. if ((getClassId(player) < 131) || (getClassId(player) > 135)) // in Kamael quests, npc wants to chat for a bit before changing class
  860. {
  861. st.exitQuest(false);
  862. st.set("cond", "0");
  863. st.addExpAndSp(2299404, 0);
  864. st.giveItems(57, 5000000);
  865. st.giveItems(6622, 1);
  866. int Class = getClassId(player);
  867. int prevClass = getPrevClass(player);
  868. player.setClassId(Class);
  869. if (!player.isSubClassActive() && (player.getBaseClass() == prevClass))
  870. {
  871. player.setBaseClass(Class);
  872. }
  873. player.broadcastUserInfo();
  874. Cast(npc, player, 4339, 1);
  875. }
  876. }
  877. else
  878. {
  879. htmltext = "0-010.htm";
  880. }
  881. }
  882. }
  883. }
  884. }
  885. return htmltext;
  886. }
  887. @Override
  888. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  889. {
  890. String htmltext = "";
  891. QuestState st = player.getQuestState(qn);
  892. int npcId = npc.getNpcId();
  893. if (st != null)
  894. {
  895. int cond = st.getInt("cond");
  896. if (npcId == NPC[4])
  897. {
  898. if (cond == 17)
  899. {
  900. QuestState st2 = findRightState(npc);
  901. if (st2 != null)
  902. {
  903. player.setLastQuestNpcObject(npc.getObjectId());
  904. if (st == st2)
  905. {
  906. if (st.getInt("Tab") == 1)
  907. {
  908. if (st.getInt("Quest0") == 0)
  909. {
  910. htmltext = "4-04.htm";
  911. }
  912. else if (st.getInt("Quest0") == 1)
  913. {
  914. htmltext = "4-06.htm";
  915. }
  916. }
  917. else
  918. {
  919. if (st.getInt("Quest0") == 0)
  920. {
  921. htmltext = "4-01.htm";
  922. }
  923. else if (st.getInt("Quest0") == 1)
  924. {
  925. htmltext = "4-03.htm";
  926. }
  927. }
  928. }
  929. else
  930. {
  931. if (st.getInt("Tab") == 1)
  932. {
  933. if (st.getInt("Quest0") == 0)
  934. {
  935. htmltext = "4-05.htm";
  936. }
  937. else if (st.getInt("Quest0") == 1)
  938. {
  939. htmltext = "4-07.htm";
  940. }
  941. }
  942. else
  943. {
  944. if (st.getInt("Quest0") == 0)
  945. {
  946. htmltext = "4-02.htm";
  947. }
  948. }
  949. }
  950. }
  951. }
  952. else if (cond == 18)
  953. {
  954. htmltext = "4-08.htm";
  955. }
  956. }
  957. }
  958. if (htmltext == "")
  959. {
  960. npc.showChatWindow(player);
  961. }
  962. return htmltext;
  963. }
  964. @Override
  965. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet)
  966. {
  967. QuestState st2 = findRightState(npc);
  968. if (st2 == null)
  969. {
  970. return super.onAttack(npc, player, damage, isPet);
  971. }
  972. int cond = st2.getInt("cond");
  973. QuestState st = player.getQuestState(qn);
  974. int npcId = npc.getNpcId();
  975. if ((npcId == Mob[2]) && (st == st2) && (cond == 17))
  976. {
  977. st.set("Quest0", String.valueOf(st.getInt("Quest0") + 1));
  978. if (st.getInt("Quest0") == 1)
  979. {
  980. AutoChat(npc, Text[16].replace("PLAYERNAME", player.getName()));
  981. }
  982. if (st.getInt("Quest0") > 15)
  983. {
  984. st.set("Quest0", "1");
  985. AutoChat(npc, Text[17].replace("PLAYERNAME", player.getName()));
  986. cancelQuestTimer("Mob_3 has despawned", npc, st2.getPlayer());
  987. st.set("Tab", "1");
  988. DeleteSpawn(st, npc);
  989. }
  990. }
  991. else if ((npcId == Mob[1]) && (cond == 15))
  992. {
  993. if ((st != st2) || ((st == st2) && player.isInParty()))
  994. {
  995. AutoChat(npc, Text[5].replace("PLAYERNAME", player.getName()));
  996. cancelQuestTimer("Archon Hellisha has despawned", npc, st2.getPlayer());
  997. st2.set("spawned", "0");
  998. DeleteSpawn(st2, npc);
  999. }
  1000. }
  1001. return super.onAttack(npc, player, damage, isPet);
  1002. }
  1003. @Override
  1004. public String onSkillSee(L2Npc npc, L2PcInstance player, L2Skill skill, L2Object[] targets, boolean isPet)
  1005. {
  1006. if (_SpawnList.containsKey(npc) && (_SpawnList.get(npc) != player.getObjectId()))
  1007. {
  1008. L2PcInstance quest_player = (L2PcInstance) L2World.getInstance().findObject(_SpawnList.get(npc));
  1009. if (quest_player == null)
  1010. {
  1011. return null;
  1012. }
  1013. for (L2Object obj : targets)
  1014. {
  1015. if ((obj == quest_player) || (obj == npc))
  1016. {
  1017. QuestState st2 = findRightState(npc);
  1018. if (st2 == null)
  1019. {
  1020. return null;
  1021. }
  1022. AutoChat(npc, Text[5].replace("PLAYERNAME", player.getName()));
  1023. cancelQuestTimer("Archon Hellisha has despawned", npc, st2.getPlayer());
  1024. st2.set("spawned", "0");
  1025. DeleteSpawn(st2, npc);
  1026. }
  1027. }
  1028. }
  1029. return super.onSkillSee(npc, player, skill, targets, isPet);
  1030. }
  1031. @Override
  1032. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  1033. {
  1034. int npcId = npc.getNpcId();
  1035. QuestState st = player.getQuestState(qn);
  1036. for (int Archon_Minion = 21646; Archon_Minion < 21652; Archon_Minion++)
  1037. {
  1038. if (npcId == Archon_Minion)
  1039. {
  1040. L2Party party = player.getParty();
  1041. if (party != null)
  1042. {
  1043. L2FastList<QuestState> PartyQuestMembers = new L2FastList<QuestState>();
  1044. for (L2PcInstance player1 : party.getMembers())
  1045. {
  1046. QuestState st1 = findQuest(player1);
  1047. if ((st1 != null) && player1.isInsideRadius(player, Config.ALT_PARTY_RANGE2, false, false))
  1048. {
  1049. if (st1.getInt("cond") == 15)
  1050. {
  1051. PartyQuestMembers.add(st1);
  1052. }
  1053. }
  1054. }
  1055. if (PartyQuestMembers.size() > 0)
  1056. {
  1057. QuestState st2 = PartyQuestMembers.get(getRandom(PartyQuestMembers.size()));
  1058. giveHallishaMark(st2);
  1059. }
  1060. }
  1061. else
  1062. {
  1063. QuestState st1 = findQuest(player);
  1064. if (st1 != null)
  1065. {
  1066. if (st1.getInt("cond") == 15)
  1067. {
  1068. giveHallishaMark(st1);
  1069. }
  1070. }
  1071. }
  1072. return super.onKill(npc, player, isPet);
  1073. }
  1074. }
  1075. int[] Archon_Hellisha_Norm =
  1076. {
  1077. 18212,
  1078. 18214,
  1079. 18215,
  1080. 18216,
  1081. 18218
  1082. };
  1083. for (int element : Archon_Hellisha_Norm)
  1084. {
  1085. if (npcId == element)
  1086. {
  1087. QuestState st1 = findQuest(player);
  1088. if (st1 != null)
  1089. {
  1090. if (st1.getInt("cond") == 15)
  1091. {
  1092. // This is just a guess....not really sure what it actually says, if anything
  1093. AutoChat(npc, Text[4].replace("PLAYERNAME", st1.getPlayer().getName()));
  1094. st1.giveItems(Items[8], 1);
  1095. st1.takeItems(Items[3], -1);
  1096. st1.set("cond", "16");
  1097. st1.playSound("ItemSound.quest_middle");
  1098. }
  1099. }
  1100. return super.onKill(npc, player, isPet);
  1101. }
  1102. }
  1103. for (int Guardian_Angel = 27214; Guardian_Angel < 27217; Guardian_Angel++)
  1104. {
  1105. if (npcId == Guardian_Angel)
  1106. {
  1107. QuestState st1 = findQuest(player);
  1108. if (st1 != null)
  1109. {
  1110. if (st1.getInt("cond") == 6)
  1111. {
  1112. if (st1.getInt("kills") < 9)
  1113. {
  1114. st1.set("kills", String.valueOf(st1.getInt("kills") + 1));
  1115. }
  1116. else
  1117. {
  1118. st1.playSound("ItemSound.quest_middle");
  1119. st1.giveItems(Items[5], 1);
  1120. st1.set("cond", "7");
  1121. }
  1122. }
  1123. }
  1124. return super.onKill(npc, player, isPet);
  1125. }
  1126. }
  1127. if ((st != null) && (npcId != Mob[2]))
  1128. {
  1129. QuestState st2 = findRightState(npc);
  1130. if (st2 == null)
  1131. {
  1132. return super.onKill(npc, player, isPet);
  1133. }
  1134. int cond = st.getInt("cond");
  1135. if ((npcId == Mob[0]) && (cond == 8))
  1136. {
  1137. if (!player.isInParty())
  1138. {
  1139. if (st == st2)
  1140. {
  1141. AutoChat(npc, Text[12].replace("PLAYERNAME", player.getName()));
  1142. st.giveItems(Items[6], 1);
  1143. st.set("cond", "9");
  1144. st.playSound("ItemSound.quest_middle");
  1145. }
  1146. }
  1147. cancelQuestTimer("Mob_1 has despawned", npc, st2.getPlayer());
  1148. st2.set("spawned", "0");
  1149. DeleteSpawn(st2, npc);
  1150. }
  1151. else if ((npcId == Mob[1]) && (cond == 15))
  1152. {
  1153. if (!player.isInParty())
  1154. {
  1155. if (st == st2)
  1156. {
  1157. AutoChat(npc, Text[4].replace("PLAYERNAME", player.getName()));
  1158. st.giveItems(Items[8], 1);
  1159. st.takeItems(Items[3], -1);
  1160. st.set("cond", "16");
  1161. st.playSound("ItemSound.quest_middle");
  1162. }
  1163. else
  1164. {
  1165. AutoChat(npc, Text[5].replace("PLAYERNAME", player.getName()));
  1166. }
  1167. }
  1168. cancelQuestTimer("Archon Hellisha has despawned", npc, st2.getPlayer());
  1169. st2.set("spawned", "0");
  1170. DeleteSpawn(st2, npc);
  1171. }
  1172. }
  1173. else
  1174. {
  1175. if (npcId == Mob[0])
  1176. {
  1177. st = findRightState(npc);
  1178. if (st != null)
  1179. {
  1180. cancelQuestTimer("Mob_1 has despawned", npc, st.getPlayer());
  1181. st.set("spawned", "0");
  1182. DeleteSpawn(st, npc);
  1183. }
  1184. }
  1185. else if (npcId == Mob[1])
  1186. {
  1187. st = findRightState(npc);
  1188. if (st != null)
  1189. {
  1190. cancelQuestTimer("Archon Hellisha has despawned", npc, st.getPlayer());
  1191. st.set("spawned", "0");
  1192. DeleteSpawn(st, npc);
  1193. }
  1194. }
  1195. }
  1196. return super.onKill(npc, player, isPet);
  1197. }
  1198. @Override
  1199. public boolean unload()
  1200. {
  1201. // if sub classes aren't loaded, just unload superclass
  1202. if (_scripts.size() == 0)
  1203. {
  1204. return super.unload();
  1205. }
  1206. // unload all subclasses
  1207. for (int index = 0; index < _scripts.size(); index++)
  1208. {
  1209. if (_scripts.get(index) == null)
  1210. {
  1211. continue;
  1212. }
  1213. QuestManager.getInstance().removeQuest(_scripts.get(index));
  1214. }
  1215. _scripts.clear();
  1216. // now unload superclass
  1217. return super.unload();
  1218. }
  1219. public static void main(String[] args)
  1220. {
  1221. // initialize superclass
  1222. new SagasSuperClass(-1, "SagasSuperClass", "Saga's SuperClass");
  1223. // initialize subclasses
  1224. _scripts.add(new SagaOfEvasSaint());
  1225. _scripts.add(new SagaOfEvasTemplar());
  1226. _scripts.add(new SagaOfTheAdventurer());
  1227. _scripts.add(new SagaOfTheArcanaLord());
  1228. _scripts.add(new SagaOfTheArchmage());
  1229. _scripts.add(new SagaOfTheCardinal());
  1230. _scripts.add(new SagaOfTheDominator());
  1231. _scripts.add(new SagaOfTheDoombringer());
  1232. _scripts.add(new SagaOfTheDoomcryer());
  1233. _scripts.add(new SagaOfTheDreadnoughts());
  1234. _scripts.add(new SagaOfTheDuelist());
  1235. _scripts.add(new SagaOfTheElementalMaster());
  1236. _scripts.add(new SagaOfTheFortuneSeeker());
  1237. _scripts.add(new SagaOfTheGhostHunter());
  1238. _scripts.add(new SagaOfTheGhostSentinel());
  1239. _scripts.add(new SagaOfTheGrandKhavatari());
  1240. _scripts.add(new SagaOfTheHellKnight());
  1241. _scripts.add(new SagaOfTheHierophant());
  1242. _scripts.add(new SagaOfTheMaestro());
  1243. _scripts.add(new SagaOfTheMoonlightSentinel());
  1244. _scripts.add(new SagaOfTheMysticMuse());
  1245. _scripts.add(new SagaOfThePhoenixKnight());
  1246. _scripts.add(new SagaOfTheSagittarius());
  1247. _scripts.add(new SagaOfTheShillienSaint());
  1248. _scripts.add(new SagaOfTheShillienTemplar());
  1249. _scripts.add(new SagaOfTheSoulHound());
  1250. _scripts.add(new SagaOfTheSoultaker());
  1251. _scripts.add(new SagaOfTheSpectralDancer());
  1252. _scripts.add(new SagaOfTheSpectralMaster());
  1253. _scripts.add(new SagaOfTheStormScreamer());
  1254. _scripts.add(new SagaOfTheSwordMuse());
  1255. _scripts.add(new SagaOfTheTitan());
  1256. _scripts.add(new SagaOfTheTrickster());
  1257. _scripts.add(new SagaOfTheWindRider());
  1258. }
  1259. }