Q00105_SkirmishWithOrcs.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.Q00105_SkirmishWithOrcs;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00281_HeadForTheHills.Q00281_HeadForTheHills;
  23. import com.l2jserver.gameserver.enums.Race;
  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.network.serverpackets.SocialAction;
  30. import com.l2jserver.gameserver.util.Util;
  31. /**
  32. * Skimirish with Orcs (105)
  33. * @author janiko
  34. */
  35. public final class Q00105_SkirmishWithOrcs extends Quest
  36. {
  37. // NPC
  38. private static final int KENDNELL = 30218;
  39. // Items
  40. private static final int KENDELLS_1ST_ORDER = 1836;
  41. private static final int KENDELLS_2ND_ORDER = 1837;
  42. private static final int KENDELLS_3RD_ORDER = 1838;
  43. private static final int KENDELLS_4TH_ORDER = 1839;
  44. private static final int KENDELLS_5TH_ORDER = 1840;
  45. private static final int KENDELLS_6TH_ORDER = 1841;
  46. private static final int KENDELLS_7TH_ORDER = 1842;
  47. private static final int KENDELLS_8TH_ORDER = 1843;
  48. private static final int KABOO_CHIEFS_1ST_TORQUE = 1844;
  49. private static final int KABOO_CHIEFS_2ST_TORQUE = 1845;
  50. private static final Map<Integer, Integer> MONSTER_DROP = new HashMap<>();
  51. static
  52. {
  53. MONSTER_DROP.put(27059, KENDELLS_1ST_ORDER); // Uoph (Kaboo Chief)
  54. MONSTER_DROP.put(27060, KENDELLS_2ND_ORDER); // Kracha (Kaboo Chief)
  55. MONSTER_DROP.put(27061, KENDELLS_3RD_ORDER); // Batoh (Kaboo Chief)
  56. MONSTER_DROP.put(27062, KENDELLS_4TH_ORDER); // Tanukia (Kaboo Chief)
  57. MONSTER_DROP.put(27064, KENDELLS_5TH_ORDER); // Turel (Kaboo Chief)
  58. MONSTER_DROP.put(27065, KENDELLS_6TH_ORDER); // Roko (Kaboo Chief)
  59. MONSTER_DROP.put(27067, KENDELLS_7TH_ORDER); // Kamut (Kaboo Chief)
  60. MONSTER_DROP.put(27068, KENDELLS_8TH_ORDER); // Murtika (Kaboo Chief)
  61. }
  62. private static final int[] KENDNELLS_ORDERS =
  63. {
  64. KENDELLS_1ST_ORDER,
  65. KENDELLS_2ND_ORDER,
  66. KENDELLS_3RD_ORDER,
  67. KENDELLS_4TH_ORDER,
  68. KENDELLS_5TH_ORDER,
  69. KENDELLS_6TH_ORDER,
  70. KENDELLS_7TH_ORDER,
  71. KENDELLS_8TH_ORDER
  72. };
  73. // Misc
  74. private static final int MIN_LVL = 10;
  75. public Q00105_SkirmishWithOrcs()
  76. {
  77. super(105, Q00105_SkirmishWithOrcs.class.getSimpleName(), "Skirmish with Orcs");
  78. addStartNpc(KENDNELL);
  79. addTalkId(KENDNELL);
  80. addKillId(MONSTER_DROP.keySet());
  81. registerQuestItems(KENDNELLS_ORDERS);
  82. }
  83. @Override
  84. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  85. {
  86. final QuestState st = getQuestState(player, false);
  87. String htmltext = null;
  88. if (st == null)
  89. {
  90. return htmltext;
  91. }
  92. switch (event)
  93. {
  94. case "30218-04.html":
  95. {
  96. if (st.isCreated())
  97. {
  98. st.startQuest();
  99. st.giveItems(KENDNELLS_ORDERS[getRandom(0, 3)], 1);
  100. htmltext = event;
  101. }
  102. break;
  103. }
  104. case "30218-05.html":
  105. {
  106. htmltext = event;
  107. break;
  108. }
  109. }
  110. return htmltext;
  111. }
  112. @Override
  113. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  114. {
  115. final QuestState st = getQuestState(killer, false);
  116. if ((st != null) && Util.checkIfInRange(1500, npc, killer, true))
  117. {
  118. switch (npc.getId())
  119. {
  120. case 27059:
  121. case 27060:
  122. case 27061:
  123. case 27062:
  124. {
  125. if (st.isCond(1) && st.hasQuestItems(MONSTER_DROP.get(npc.getId())))
  126. {
  127. st.giveItems(KABOO_CHIEFS_1ST_TORQUE, 1);
  128. st.setCond(2, true);
  129. }
  130. break;
  131. }
  132. case 27064:
  133. case 27065:
  134. case 27067:
  135. case 27068:
  136. {
  137. if (st.isCond(3) && st.hasQuestItems(MONSTER_DROP.get(npc.getId())))
  138. {
  139. st.giveItems(KABOO_CHIEFS_2ST_TORQUE, 1);
  140. st.setCond(4, true);
  141. }
  142. break;
  143. }
  144. }
  145. }
  146. return super.onKill(npc, killer, isSummon);
  147. }
  148. @Override
  149. public String onTalk(L2Npc npc, L2PcInstance talker)
  150. {
  151. final QuestState st = getQuestState(talker, true);
  152. String htmltext = getNoQuestMsg(talker);
  153. if (st == null)
  154. {
  155. return htmltext;
  156. }
  157. switch (st.getState())
  158. {
  159. case State.CREATED:
  160. {
  161. if (talker.getRace() == Race.ELF)
  162. {
  163. htmltext = (talker.getLevel() >= MIN_LVL) ? "30218-03.htm" : "30218-02.htm";
  164. }
  165. else
  166. {
  167. htmltext = "30218-01.htm";
  168. }
  169. break;
  170. }
  171. case State.STARTED:
  172. {
  173. if (hasAtLeastOneQuestItem(talker, KENDELLS_1ST_ORDER, KENDELLS_2ND_ORDER, KENDELLS_3RD_ORDER, KENDELLS_4TH_ORDER))
  174. {
  175. htmltext = "30218-06.html";
  176. }
  177. if (st.isCond(2) && st.hasQuestItems(KABOO_CHIEFS_1ST_TORQUE))
  178. {
  179. for (int i = 0; i < 4; i++)
  180. {
  181. st.takeItems(KENDNELLS_ORDERS[i], -1);
  182. }
  183. st.takeItems(KABOO_CHIEFS_1ST_TORQUE, 1);
  184. st.giveItems(KENDNELLS_ORDERS[getRandom(4, 7)], 1);
  185. st.setCond(3, true);
  186. htmltext = "30218-07.html";
  187. }
  188. if (hasAtLeastOneQuestItem(talker, KENDELLS_5TH_ORDER, KENDELLS_6TH_ORDER, KENDELLS_7TH_ORDER, KENDELLS_8TH_ORDER))
  189. {
  190. htmltext = "30218-08.html";
  191. }
  192. if (st.isCond(4) && st.hasQuestItems(KABOO_CHIEFS_2ST_TORQUE))
  193. {
  194. Q00281_HeadForTheHills.giveNewbieReward(talker);
  195. talker.sendPacket(new SocialAction(talker.getObjectId(), 3));
  196. st.giveAdena(17599, true);
  197. st.addExpAndSp(41478, 3555);
  198. st.exitQuest(false, true);
  199. htmltext = "30218-09.html";
  200. }
  201. break;
  202. }
  203. case State.COMPLETED:
  204. {
  205. htmltext = getAlreadyCompletedMsg(talker);
  206. break;
  207. }
  208. }
  209. return htmltext;
  210. }
  211. }