Q00032_AnObviousLie.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.Q00032_AnObviousLie;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.holders.ItemHolder;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. /**
  28. * An Obvious Lie (32).
  29. * @author janiko
  30. */
  31. public final class Q00032_AnObviousLie extends Quest
  32. {
  33. // NPCs
  34. private static final int MAXIMILIAN = 30120;
  35. private static final int GENTLER = 30094;
  36. private static final int MIKI_THE_CAT = 31706;
  37. // Monster
  38. private static final int ALLIGATOR = 20135;
  39. // Items
  40. private static final int MAP_OF_GENTLER = 7165;
  41. private static final ItemHolder MEDICINAL_HERB = new ItemHolder(7166, 20);
  42. private static final ItemHolder SPIRIT_ORE = new ItemHolder(3031, 500);
  43. private static final ItemHolder THREAD = new ItemHolder(1868, 1000);
  44. private static final ItemHolder SUEDE = new ItemHolder(1866, 500);
  45. // Misc
  46. private static final int MIN_LVL = 45;
  47. // Reward
  48. private static final Map<String, Integer> EARS = new HashMap<>();
  49. {
  50. EARS.put("cat", 6843); // Cat Ears
  51. EARS.put("raccoon", 7680); // Raccoon ears
  52. EARS.put("rabbit", 7683); // Rabbit ears
  53. }
  54. public Q00032_AnObviousLie()
  55. {
  56. super(32, Q00032_AnObviousLie.class.getSimpleName(), "An Obvious Lie");
  57. addStartNpc(MAXIMILIAN);
  58. addTalkId(MAXIMILIAN, GENTLER, MIKI_THE_CAT);
  59. addKillId(ALLIGATOR);
  60. registerQuestItems(MAP_OF_GENTLER, MEDICINAL_HERB.getId());
  61. }
  62. @Override
  63. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  64. {
  65. final QuestState qs = getQuestState(player, false);
  66. String htmltext = null;
  67. if (qs == null)
  68. {
  69. return htmltext;
  70. }
  71. switch (event)
  72. {
  73. case "30120-02.html":
  74. {
  75. if (qs.isCreated())
  76. {
  77. qs.startQuest();
  78. htmltext = event;
  79. }
  80. break;
  81. }
  82. case "30094-02.html":
  83. {
  84. if (qs.isCond(1))
  85. {
  86. giveItems(player, MAP_OF_GENTLER, 1);
  87. qs.setCond(2, true);
  88. htmltext = event;
  89. }
  90. break;
  91. }
  92. case "31706-02.html":
  93. {
  94. if (qs.isCond(2) && hasQuestItems(player, MAP_OF_GENTLER))
  95. {
  96. takeItems(player, MAP_OF_GENTLER, -1);
  97. qs.setCond(3, true);
  98. htmltext = event;
  99. }
  100. break;
  101. }
  102. case "30094-06.html":
  103. {
  104. if (qs.isCond(4) && hasItem(player, MEDICINAL_HERB))
  105. {
  106. takeItem(player, MEDICINAL_HERB);
  107. qs.setCond(5, true);
  108. htmltext = event;
  109. }
  110. break;
  111. }
  112. case "30094-09.html":
  113. {
  114. if (qs.isCond(5) && hasItem(player, SPIRIT_ORE))
  115. {
  116. takeItem(player, SPIRIT_ORE);
  117. qs.setCond(6, true);
  118. htmltext = event;
  119. }
  120. break;
  121. }
  122. case "30094-12.html":
  123. {
  124. if (qs.isCond(7))
  125. {
  126. qs.setCond(8, true);
  127. htmltext = event;
  128. }
  129. break;
  130. }
  131. case "30094-15.html":
  132. {
  133. htmltext = event;
  134. break;
  135. }
  136. case "31706-05.html":
  137. {
  138. if (qs.isCond(6))
  139. {
  140. qs.setCond(7, true);
  141. htmltext = event;
  142. }
  143. break;
  144. }
  145. case "cat":
  146. case "raccoon":
  147. case "rabbit":
  148. {
  149. if (qs.isCond(8) && takeAllItems(player, THREAD, SUEDE))
  150. {
  151. giveItems(player, EARS.get(event), 1);
  152. qs.exitQuest(false, true);
  153. htmltext = "30094-16.html";
  154. }
  155. else
  156. {
  157. htmltext = "30094-17.html";
  158. }
  159. break;
  160. }
  161. }
  162. return htmltext;
  163. }
  164. @Override
  165. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  166. {
  167. final QuestState qs = getRandomPartyMemberState(killer, 3, 3, npc);
  168. if ((qs != null) && giveItemRandomly(qs.getPlayer(), npc, MEDICINAL_HERB.getId(), 1, MEDICINAL_HERB.getCount(), 1.0, true))
  169. {
  170. qs.setCond(4);
  171. }
  172. return super.onKill(npc, killer, isSummon);
  173. }
  174. @Override
  175. public String onTalk(L2Npc npc, L2PcInstance player)
  176. {
  177. final QuestState qs = getQuestState(player, true);
  178. String htmltext = getNoQuestMsg(player);
  179. if (qs == null)
  180. {
  181. return htmltext;
  182. }
  183. switch (npc.getId())
  184. {
  185. case MAXIMILIAN:
  186. {
  187. if (qs.isCreated())
  188. {
  189. htmltext = ((player.getLevel() >= MIN_LVL) ? "30120-01.htm" : "30120-03.htm");
  190. }
  191. else if (qs.isStarted())
  192. {
  193. if (qs.isCond(1))
  194. {
  195. htmltext = "30120-04.html";
  196. }
  197. }
  198. else
  199. {
  200. htmltext = getAlreadyCompletedMsg(player);
  201. }
  202. break;
  203. }
  204. case GENTLER:
  205. {
  206. switch (qs.getCond())
  207. {
  208. case 1:
  209. {
  210. htmltext = "30094-01.html";
  211. break;
  212. }
  213. case 2:
  214. {
  215. htmltext = "30094-03.html";
  216. break;
  217. }
  218. case 4:
  219. {
  220. htmltext = (hasItem(player, MEDICINAL_HERB) ? "30094-04.html" : "30094-05.html");
  221. break;
  222. }
  223. case 5:
  224. {
  225. htmltext = (hasItem(player, SPIRIT_ORE) ? "30094-07.html" : "30094-08.html");
  226. break;
  227. }
  228. case 6:
  229. {
  230. htmltext = "30094-10.html";
  231. break;
  232. }
  233. case 7:
  234. {
  235. htmltext = "30094-11.html";
  236. break;
  237. }
  238. case 8:
  239. {
  240. if (hasAllItems(player, true, THREAD, SUEDE))
  241. {
  242. htmltext = "30094-13.html";
  243. }
  244. else
  245. {
  246. htmltext = "30094-14.html";
  247. }
  248. break;
  249. }
  250. }
  251. break;
  252. }
  253. case MIKI_THE_CAT:
  254. {
  255. switch (qs.getCond())
  256. {
  257. case 2:
  258. {
  259. if (hasQuestItems(player, MAP_OF_GENTLER))
  260. {
  261. htmltext = "31706-01.html";
  262. }
  263. break;
  264. }
  265. case 3:
  266. case 4:
  267. case 5:
  268. {
  269. htmltext = "31706-03.html";
  270. break;
  271. }
  272. case 6:
  273. {
  274. htmltext = "31706-04.html";
  275. break;
  276. }
  277. case 7:
  278. {
  279. htmltext = "31706-06.html";
  280. break;
  281. }
  282. }
  283. break;
  284. }
  285. }
  286. return htmltext;
  287. }
  288. }