Q00064_CertifiedBerserker.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package quests.Q00064_CertifiedBerserker;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.Race;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.base.ClassId;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.network.NpcStringId;
  28. import com.l2jserver.gameserver.network.clientpackets.Say2;
  29. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  30. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  31. import com.l2jserver.gameserver.util.Util;
  32. /**
  33. * Certified Berserker (64)
  34. * @author ivantotov
  35. */
  36. public final class Q00064_CertifiedBerserker extends Quest
  37. {
  38. // NPCs
  39. private static final int MASTER_ENTIENS = 32200;
  40. private static final int MASTER_ORKURUS = 32207;
  41. private static final int MASTER_TENAIN = 32215;
  42. private static final int CARAVANER_GORT = 32252;
  43. private static final int HARKILGAMED = 32253;
  44. // Items
  45. private static final int BREKA_ORC_HEAD = 9754;
  46. private static final int MESSAGE_PLATE = 9755;
  47. private static final int REPORT_EAST = 9756;
  48. private static final int REPORT_NORTH = 9757;
  49. private static final int HARKILGAMEDS_LETTER = 9758;
  50. private static final int TENAINS_RECOMMENDATION = 9759;
  51. // Reward
  52. private static final int DIMENSIONAL_DIAMOND = 7562;
  53. private static final int ORKURUS_RECOMMENDATION = 9760;
  54. // Monster
  55. private static final int DEAD_SEEKER = 20202;
  56. private static final int MARSH_STAKATO_DRONE = 20234;
  57. private static final int BREKA_ORC = 20267;
  58. private static final int BREKA_ORC_ARCHER = 20268;
  59. private static final int BREKA_ORC_SHAMAN = 20269;
  60. private static final int BREKA_ORC_OVERLORD = 20270;
  61. private static final int BREKA_ORC_WARRIOR = 20271;
  62. private static final int ROAD_SCAVENGER = 20551;
  63. // Quest Monster
  64. private static final int DIVINE_EMISSARY = 27323;
  65. // Misc
  66. private static final int MIN_LEVEL = 39;
  67. public Q00064_CertifiedBerserker()
  68. {
  69. super(64, Q00064_CertifiedBerserker.class.getSimpleName(), "Certified Berserker");
  70. addStartNpc(MASTER_ORKURUS);
  71. addTalkId(MASTER_ORKURUS, MASTER_ENTIENS, MASTER_TENAIN, CARAVANER_GORT, HARKILGAMED);
  72. addKillId(DEAD_SEEKER, MARSH_STAKATO_DRONE, BREKA_ORC, BREKA_ORC_ARCHER, BREKA_ORC_SHAMAN, BREKA_ORC_OVERLORD, BREKA_ORC_WARRIOR, ROAD_SCAVENGER, DIVINE_EMISSARY);
  73. registerQuestItems(BREKA_ORC_HEAD, MESSAGE_PLATE, REPORT_EAST, REPORT_NORTH, HARKILGAMEDS_LETTER, TENAINS_RECOMMENDATION);
  74. }
  75. @Override
  76. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  77. {
  78. final QuestState qs = getQuestState(player, false);
  79. if (qs == null)
  80. {
  81. return null;
  82. }
  83. String htmltext = null;
  84. switch (event)
  85. {
  86. case "ACCEPT":
  87. {
  88. if (qs.isCreated())
  89. {
  90. qs.startQuest();
  91. qs.setMemoState(1);
  92. if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0)
  93. {
  94. giveItems(player, DIMENSIONAL_DIAMOND, 48);
  95. player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1);
  96. htmltext = "32207-06.htm";
  97. }
  98. else
  99. {
  100. htmltext = "32207-06a.htm";
  101. }
  102. }
  103. break;
  104. }
  105. case "32207-10.html":
  106. {
  107. if (qs.isMemoState(11))
  108. {
  109. htmltext = event;
  110. }
  111. break;
  112. }
  113. case "32207-11.html":
  114. {
  115. if (qs.isMemoState(11))
  116. {
  117. giveAdena(player, 63104, true);
  118. giveItems(player, ORKURUS_RECOMMENDATION, 1);
  119. addExpAndSp(player, 349006, 23948);
  120. qs.exitQuest(false, true);
  121. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  122. htmltext = event;
  123. }
  124. break;
  125. }
  126. case "32215-02.html":
  127. {
  128. if (qs.isMemoState(1))
  129. {
  130. qs.setMemoState(2);
  131. qs.setCond(2, true);
  132. htmltext = event;
  133. }
  134. break;
  135. }
  136. case "32215-07.html":
  137. case "32215-08.html":
  138. case "32215-09.html":
  139. {
  140. if (qs.isMemoState(5))
  141. {
  142. htmltext = event;
  143. }
  144. break;
  145. }
  146. case "32215-10.html":
  147. {
  148. if (qs.isMemoState(5))
  149. {
  150. takeItems(player, MESSAGE_PLATE, 1);
  151. qs.setMemoState(6);
  152. qs.setCond(8, true);
  153. htmltext = event;
  154. }
  155. break;
  156. }
  157. case "32215-15.html":
  158. {
  159. if (qs.isMemoState(10))
  160. {
  161. takeItems(player, HARKILGAMEDS_LETTER, 1);
  162. giveItems(player, TENAINS_RECOMMENDATION, 1);
  163. qs.setMemoState(11);
  164. qs.setCond(14, true);
  165. htmltext = event;
  166. }
  167. break;
  168. }
  169. case "32252-02.html":
  170. {
  171. if (qs.isMemoState(3))
  172. {
  173. qs.setMemoState(4);
  174. qs.setCond(5, true);
  175. htmltext = event;
  176. }
  177. break;
  178. }
  179. case "32253-02.html":
  180. {
  181. if (qs.isMemoState(9))
  182. {
  183. giveItems(player, HARKILGAMEDS_LETTER, 1);
  184. qs.setMemoState(10);
  185. qs.setCond(13, true);
  186. htmltext = event;
  187. }
  188. break;
  189. }
  190. }
  191. return htmltext;
  192. }
  193. @Override
  194. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  195. {
  196. final QuestState qs = getQuestState(killer, false);
  197. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  198. {
  199. switch (npc.getId())
  200. {
  201. case DEAD_SEEKER:
  202. {
  203. if (qs.isMemoState(7) && !hasQuestItems(killer, REPORT_EAST))
  204. {
  205. if (getRandom(100) < 20)
  206. {
  207. giveItems(killer, REPORT_EAST, 1);
  208. if (hasQuestItems(killer, REPORT_NORTH))
  209. {
  210. qs.setCond(10, true);
  211. }
  212. else
  213. {
  214. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  215. }
  216. }
  217. }
  218. break;
  219. }
  220. case MARSH_STAKATO_DRONE:
  221. {
  222. if (qs.isMemoState(7) && !hasQuestItems(killer, REPORT_NORTH))
  223. {
  224. if (getRandom(100) < 20)
  225. {
  226. giveItems(killer, REPORT_NORTH, 1);
  227. if (hasQuestItems(killer, REPORT_EAST))
  228. {
  229. qs.setCond(10, true);
  230. }
  231. else
  232. {
  233. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  234. }
  235. }
  236. }
  237. break;
  238. }
  239. case BREKA_ORC:
  240. case BREKA_ORC_ARCHER:
  241. case BREKA_ORC_SHAMAN:
  242. case BREKA_ORC_OVERLORD:
  243. case BREKA_ORC_WARRIOR:
  244. {
  245. if (qs.isMemoState(2) && (getQuestItemsCount(killer, BREKA_ORC_HEAD) < 20))
  246. {
  247. if (getQuestItemsCount(killer, BREKA_ORC_HEAD) >= 19)
  248. {
  249. giveItems(killer, BREKA_ORC_HEAD, 1);
  250. qs.setCond(3, true);
  251. }
  252. else
  253. {
  254. giveItems(killer, BREKA_ORC_HEAD, 1);
  255. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  256. }
  257. }
  258. break;
  259. }
  260. case ROAD_SCAVENGER:
  261. {
  262. if (qs.isMemoState(4) && !hasQuestItems(killer, MESSAGE_PLATE))
  263. {
  264. if (getRandom(100) < 20)
  265. {
  266. giveItems(killer, MESSAGE_PLATE, 1);
  267. qs.setCond(6, true);
  268. }
  269. }
  270. break;
  271. }
  272. case DIVINE_EMISSARY:
  273. {
  274. if (qs.isMemoState(9))
  275. {
  276. if (getRandom(100) < 20)
  277. {
  278. final L2Npc kamael = addSpawn(HARKILGAMED, npc, true, 60000);
  279. kamael.broadcastPacket(new NpcSay(kamael, Say2.NPC_ALL, NpcStringId.S1_DID_YOU_COME_TO_HELP_ME).addStringParameter(killer.getAppearance().getVisibleName()));
  280. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  281. }
  282. }
  283. break;
  284. }
  285. }
  286. }
  287. return super.onKill(npc, killer, isSummon);
  288. }
  289. @Override
  290. public String onTalk(L2Npc npc, L2PcInstance player)
  291. {
  292. final QuestState qs = getQuestState(player, true);
  293. final int memoState = qs.getMemoState();
  294. String htmltext = getNoQuestMsg(player);
  295. if (qs.isCreated())
  296. {
  297. if (npc.getId() == MASTER_ORKURUS)
  298. {
  299. if (player.getRace() == Race.KAMAEL)
  300. {
  301. if (player.getClassId() == ClassId.trooper)
  302. {
  303. if (player.getLevel() >= MIN_LEVEL)
  304. {
  305. htmltext = "32207-01.htm";
  306. }
  307. else
  308. {
  309. htmltext = "32207-02.html";
  310. }
  311. }
  312. else
  313. {
  314. htmltext = "32207-03.html";
  315. }
  316. }
  317. else
  318. {
  319. htmltext = "32207-04.html";
  320. }
  321. }
  322. }
  323. else if (qs.isStarted())
  324. {
  325. switch (npc.getId())
  326. {
  327. case MASTER_ORKURUS:
  328. {
  329. if (memoState == 1)
  330. {
  331. htmltext = "32207-07.html";
  332. }
  333. else if ((memoState >= 2) && (memoState < 11))
  334. {
  335. htmltext = "32207-08.html";
  336. }
  337. else if (memoState == 11)
  338. {
  339. htmltext = "32207-09.html";
  340. }
  341. break;
  342. }
  343. case MASTER_ENTIENS:
  344. {
  345. if (memoState == 6)
  346. {
  347. qs.setMemoState(7);
  348. qs.setCond(9, true);
  349. player.getRadar().addMarker(27956, 106003, -3831);
  350. player.getRadar().addMarker(50568, 152408, -2656);
  351. htmltext = "32200-01.html";
  352. }
  353. else if (memoState == 7)
  354. {
  355. if (!hasQuestItems(player, REPORT_EAST, REPORT_NORTH))
  356. {
  357. htmltext = "32200-02.html";
  358. }
  359. else
  360. {
  361. takeItems(player, REPORT_EAST, 1);
  362. takeItems(player, REPORT_NORTH, 1);
  363. qs.setMemoState(8);
  364. qs.setCond(11, true);
  365. htmltext = "32200-03.html";
  366. }
  367. }
  368. else if (memoState == 8)
  369. {
  370. htmltext = "32200-04.html";
  371. }
  372. break;
  373. }
  374. case MASTER_TENAIN:
  375. {
  376. if (memoState == 1)
  377. {
  378. htmltext = "32215-01.html";
  379. }
  380. else if (memoState == 2)
  381. {
  382. if (getQuestItemsCount(player, BREKA_ORC_HEAD) < 20)
  383. {
  384. htmltext = "32215-03.html";
  385. }
  386. else
  387. {
  388. takeItems(player, BREKA_ORC_HEAD, -1);
  389. qs.setMemoState(3);
  390. qs.setCond(4, true);
  391. htmltext = "32215-04.html";
  392. }
  393. }
  394. else if (memoState == 3)
  395. {
  396. htmltext = "32215-05.html";
  397. }
  398. else if (memoState == 5)
  399. {
  400. htmltext = "32215-06.html";
  401. }
  402. else if (memoState == 6)
  403. {
  404. htmltext = "32215-11.html";
  405. }
  406. else if (memoState == 8)
  407. {
  408. qs.setMemoState(9);
  409. qs.setCond(12, true);
  410. htmltext = "32215-12.html";
  411. }
  412. else if (memoState == 9)
  413. {
  414. htmltext = "32215-13.html";
  415. }
  416. else if (memoState == 10)
  417. {
  418. htmltext = "32215-14.html";
  419. }
  420. else if (memoState == 11)
  421. {
  422. htmltext = "32215-16.html";
  423. }
  424. break;
  425. }
  426. case CARAVANER_GORT:
  427. {
  428. if (memoState == 3)
  429. {
  430. htmltext = "32252-01.html";
  431. }
  432. else if (memoState == 4)
  433. {
  434. if (!hasQuestItems(player, MESSAGE_PLATE))
  435. {
  436. htmltext = "32252-03.html";
  437. }
  438. else
  439. {
  440. qs.setMemoState(5);
  441. qs.setCond(7, true);
  442. htmltext = "32252-04.html";
  443. }
  444. }
  445. else if (memoState == 5)
  446. {
  447. htmltext = "32252-05.html";
  448. }
  449. break;
  450. }
  451. case HARKILGAMED:
  452. {
  453. if (memoState == 9)
  454. {
  455. htmltext = "32253-01.html";
  456. }
  457. else if (memoState == 10)
  458. {
  459. htmltext = "32253-03.html";
  460. }
  461. break;
  462. }
  463. }
  464. }
  465. else if (qs.isCompleted())
  466. {
  467. if (npc.getId() == MASTER_ORKURUS)
  468. {
  469. htmltext = "32207-05.html";
  470. }
  471. }
  472. return htmltext;
  473. }
  474. }