Q00403_PathOfTheRogue.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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.Q00403_PathOfTheRogue;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.base.ClassId;
  26. import com.l2jserver.gameserver.model.holders.ItemChanceHolder;
  27. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  28. import com.l2jserver.gameserver.model.quest.Quest;
  29. import com.l2jserver.gameserver.model.quest.QuestState;
  30. import com.l2jserver.gameserver.network.NpcStringId;
  31. import com.l2jserver.gameserver.network.clientpackets.Say2;
  32. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  33. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  34. import com.l2jserver.gameserver.util.Util;
  35. /**
  36. * Path Of The Rogue (403)
  37. * @author ivantotov
  38. */
  39. public final class Q00403_PathOfTheRogue extends Quest
  40. {
  41. // NPCs
  42. private static final int CAPTAIN_BEZIQUE = 30379;
  43. private static final int NETI = 30425;
  44. // Items
  45. private static final int BEZIQUES_LETTER = 1180;
  46. private static final int NETIS_BOW = 1181;
  47. private static final int NETIS_DAGGER = 1182;
  48. private static final int SPARTOIS_BONES = 1183;
  49. private static final int HORSESHOE_OF_LIGHT = 1184;
  50. private static final int MOST_WANTED_LIST = 1185;
  51. private static final int STOLEN_JEWELRY = 1186;
  52. private static final int STOLEN_TOMES = 1187;
  53. private static final int STOLEN_RING = 1188;
  54. private static final int STOLEN_NECKLACE = 1189;
  55. private static final int[] STOLEN_ITEMS =
  56. {
  57. STOLEN_JEWELRY,
  58. STOLEN_TOMES,
  59. STOLEN_RING,
  60. STOLEN_NECKLACE
  61. };
  62. // Reward
  63. private static final int BEZIQUES_RECOMMENDATION = 1190;
  64. // Misc
  65. private static final int MIN_LEVEL = 18;
  66. private static final int REQUIRED_ITEM_COUNT = 10;
  67. // Quest Monster
  68. private static final int CATS_EYE_BANDIT = 27038;
  69. // Monster
  70. private static final Map<Integer, ItemChanceHolder> MONSTER_DROPS = new HashMap<>();
  71. static
  72. {
  73. MONSTER_DROPS.put(20035, new ItemChanceHolder(SPARTOIS_BONES, 2)); // Tracker Skeleton
  74. MONSTER_DROPS.put(20042, new ItemChanceHolder(SPARTOIS_BONES, 3)); // Tracker Skeleton Leader
  75. MONSTER_DROPS.put(20045, new ItemChanceHolder(SPARTOIS_BONES, 2)); // Skeleton Scout
  76. MONSTER_DROPS.put(20051, new ItemChanceHolder(SPARTOIS_BONES, 2)); // Skeleton Bowman
  77. MONSTER_DROPS.put(20054, new ItemChanceHolder(SPARTOIS_BONES, 8)); // Ruin Spartoi
  78. MONSTER_DROPS.put(20060, new ItemChanceHolder(SPARTOIS_BONES, 8)); // Raging Spartoi
  79. }
  80. public Q00403_PathOfTheRogue()
  81. {
  82. super(403, Q00403_PathOfTheRogue.class.getSimpleName(), "Path Of The Rogue");
  83. addStartNpc(CAPTAIN_BEZIQUE);
  84. addTalkId(CAPTAIN_BEZIQUE, NETI);
  85. addAttackId(MONSTER_DROPS.keySet());
  86. addAttackId(CATS_EYE_BANDIT);
  87. addKillId(MONSTER_DROPS.keySet());
  88. addKillId(CATS_EYE_BANDIT);
  89. registerQuestItems(BEZIQUES_LETTER, NETIS_BOW, NETIS_DAGGER, SPARTOIS_BONES, HORSESHOE_OF_LIGHT, MOST_WANTED_LIST, STOLEN_JEWELRY, STOLEN_TOMES, STOLEN_RING, STOLEN_NECKLACE);
  90. }
  91. @Override
  92. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  93. {
  94. final QuestState qs = getQuestState(player, false);
  95. if (qs == null)
  96. {
  97. return null;
  98. }
  99. String htmltext = null;
  100. switch (event)
  101. {
  102. case "ACCEPT":
  103. {
  104. if (player.getClassId() == ClassId.fighter)
  105. {
  106. if (player.getLevel() >= MIN_LEVEL)
  107. {
  108. if (hasQuestItems(player, BEZIQUES_RECOMMENDATION))
  109. {
  110. htmltext = "30379-04.htm";
  111. }
  112. else
  113. {
  114. htmltext = "30379-05.htm";
  115. }
  116. }
  117. else
  118. {
  119. htmltext = "30379-03.htm";
  120. }
  121. }
  122. else if (player.getClassId() == ClassId.rogue)
  123. {
  124. htmltext = "30379-02a.htm";
  125. }
  126. else
  127. {
  128. htmltext = "30379-02.htm";
  129. }
  130. break;
  131. }
  132. case "30379-06.htm":
  133. {
  134. qs.startQuest();
  135. giveItems(player, BEZIQUES_LETTER, 1);
  136. htmltext = event;
  137. break;
  138. }
  139. case "30425-02.html":
  140. case "30425-03.html":
  141. case "30425-04.html":
  142. {
  143. htmltext = event;
  144. break;
  145. }
  146. case "30425-05.html":
  147. {
  148. if (hasQuestItems(player, BEZIQUES_LETTER))
  149. {
  150. takeItems(player, BEZIQUES_LETTER, 1);
  151. if (!hasQuestItems(player, NETIS_BOW))
  152. {
  153. giveItems(player, NETIS_BOW, 1);
  154. }
  155. if (!hasQuestItems(player, NETIS_DAGGER))
  156. {
  157. giveItems(player, NETIS_DAGGER, 1);
  158. }
  159. qs.setCond(2, true);
  160. }
  161. htmltext = event;
  162. break;
  163. }
  164. }
  165. return htmltext;
  166. }
  167. @Override
  168. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  169. {
  170. final QuestState qs = getQuestState(attacker, false);
  171. if ((qs != null) && qs.isStarted())
  172. {
  173. switch (npc.getScriptValue())
  174. {
  175. case 0:
  176. {
  177. npc.getVariables().set("lastAttacker", attacker.getObjectId());
  178. if (!checkWeapon(attacker))
  179. {
  180. npc.setScriptValue(2);
  181. }
  182. else
  183. {
  184. if (npc.getId() == CATS_EYE_BANDIT)
  185. {
  186. attacker.sendPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId.YOU_CHILDISH_FOOL_DO_YOU_THINK_YOU_CAN_CATCH_ME));
  187. }
  188. npc.setScriptValue(1);
  189. }
  190. break;
  191. }
  192. case 1:
  193. {
  194. if (!checkWeapon(attacker))
  195. {
  196. npc.setScriptValue(2);
  197. }
  198. else if (npc.getVariables().getInt("lastAttacker") != attacker.getObjectId())
  199. {
  200. npc.setScriptValue(2);
  201. }
  202. break;
  203. }
  204. }
  205. }
  206. return super.onAttack(npc, attacker, damage, isSummon);
  207. }
  208. @Override
  209. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  210. {
  211. final QuestState qs = getQuestState(killer, false);
  212. if ((qs != null) && qs.isStarted() && npc.isScriptValue(1) && Util.checkIfInRange(1500, npc, killer, true))
  213. {
  214. if (npc.getId() == CATS_EYE_BANDIT)
  215. {
  216. npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId.I_MUST_DO_SOMETHING_ABOUT_THIS_SHAMEFUL_INCIDENT));
  217. if (hasQuestItems(killer, MOST_WANTED_LIST))
  218. {
  219. int randomItem = STOLEN_ITEMS[getRandom(STOLEN_ITEMS.length)];
  220. if (!hasQuestItems(killer, randomItem))
  221. {
  222. giveItems(killer, randomItem, 1);
  223. if (hasQuestItems(killer, STOLEN_ITEMS))
  224. {
  225. qs.setCond(6, true);
  226. }
  227. else
  228. {
  229. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  230. }
  231. }
  232. }
  233. }
  234. else
  235. {
  236. final ItemChanceHolder reward = MONSTER_DROPS.get(npc.getId());
  237. if ((getQuestItemsCount(killer, reward.getId()) < REQUIRED_ITEM_COUNT) && npc.isScriptValue(1) && (getRandom(REQUIRED_ITEM_COUNT) < reward.getChance()))
  238. {
  239. giveItems(killer, reward.getId(), reward.getCount());
  240. if (getQuestItemsCount(killer, reward.getId()) >= REQUIRED_ITEM_COUNT)
  241. {
  242. qs.setCond(3, true);
  243. }
  244. else
  245. {
  246. playSound(qs.getPlayer(), QuestSound.ITEMSOUND_QUEST_ITEMGET);
  247. }
  248. }
  249. }
  250. }
  251. return super.onKill(npc, killer, isSummon);
  252. }
  253. private boolean checkWeapon(L2PcInstance player)
  254. {
  255. L2ItemInstance weapon = player.getActiveWeaponInstance();
  256. return ((weapon != null) && ((weapon.getId() == NETIS_BOW) || (weapon.getId() == NETIS_DAGGER)));
  257. }
  258. @Override
  259. public String onTalk(L2Npc npc, L2PcInstance player)
  260. {
  261. final QuestState qs = getQuestState(player, true);
  262. String htmltext = getNoQuestMsg(player);
  263. if (qs.isCreated() || qs.isCompleted())
  264. {
  265. if (npc.getId() == CAPTAIN_BEZIQUE)
  266. {
  267. htmltext = "30379-01.htm";
  268. }
  269. }
  270. else if (qs.isStarted())
  271. {
  272. switch (npc.getId())
  273. {
  274. case CAPTAIN_BEZIQUE:
  275. {
  276. if (hasQuestItems(player, STOLEN_JEWELRY, STOLEN_TOMES, STOLEN_RING, STOLEN_NECKLACE))
  277. {
  278. giveAdena(player, 163800, true);
  279. takeItems(player, NETIS_BOW, 1);
  280. takeItems(player, NETIS_DAGGER, 1);
  281. takeItems(player, MOST_WANTED_LIST, 1);
  282. takeItems(player, STOLEN_JEWELRY, 1);
  283. takeItems(player, STOLEN_TOMES, 1);
  284. takeItems(player, STOLEN_RING, 1);
  285. takeItems(player, STOLEN_NECKLACE, 1);
  286. giveItems(player, BEZIQUES_RECOMMENDATION, 1);
  287. final int level = player.getLevel();
  288. if (level >= 20)
  289. {
  290. addExpAndSp(player, 320534, 20232);
  291. }
  292. else if (level == 19)
  293. {
  294. addExpAndSp(player, 456128, 26930);
  295. }
  296. else
  297. {
  298. addExpAndSp(player, 591724, 33628);
  299. }
  300. qs.exitQuest(false, true);
  301. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  302. qs.saveGlobalQuestVar("1ClassQuestFinished", "1");
  303. htmltext = "30379-09.html";
  304. }
  305. else if (!hasQuestItems(player, HORSESHOE_OF_LIGHT) && hasQuestItems(player, BEZIQUES_LETTER))
  306. {
  307. htmltext = "30379-07.html";
  308. }
  309. else if (hasQuestItems(player, HORSESHOE_OF_LIGHT))
  310. {
  311. takeItems(player, HORSESHOE_OF_LIGHT, 1);
  312. giveItems(player, MOST_WANTED_LIST, 1);
  313. qs.setCond(5, true);
  314. htmltext = "30379-08.html";
  315. }
  316. else if (hasQuestItems(player, NETIS_BOW, NETIS_DAGGER) && !hasQuestItems(player, MOST_WANTED_LIST))
  317. {
  318. htmltext = "30379-10.html";
  319. }
  320. else if (hasQuestItems(player, MOST_WANTED_LIST))
  321. {
  322. htmltext = "30379-11.html";
  323. }
  324. break;
  325. }
  326. case NETI:
  327. {
  328. if (hasQuestItems(player, BEZIQUES_LETTER))
  329. {
  330. htmltext = "30425-01.html";
  331. }
  332. else if (!hasAtLeastOneQuestItem(player, HORSESHOE_OF_LIGHT, BEZIQUES_LETTER))
  333. {
  334. if (hasQuestItems(player, MOST_WANTED_LIST))
  335. {
  336. htmltext = "30425-08.html";
  337. }
  338. else if (getQuestItemsCount(player, SPARTOIS_BONES) < REQUIRED_ITEM_COUNT)
  339. {
  340. htmltext = "30425-06.html";
  341. }
  342. else
  343. {
  344. takeItems(player, SPARTOIS_BONES, REQUIRED_ITEM_COUNT);
  345. giveItems(player, HORSESHOE_OF_LIGHT, 1);
  346. qs.setCond(4, true);
  347. htmltext = "30425-07.html";
  348. }
  349. }
  350. else if (hasQuestItems(player, HORSESHOE_OF_LIGHT))
  351. {
  352. htmltext = "30425-08.html";
  353. }
  354. break;
  355. }
  356. }
  357. }
  358. return htmltext;
  359. }
  360. }