SagasSuperClass.java 30 KB

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