DarkElvenChange2.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * Copyright (C) 2004-2014 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 village_master.DarkElvenChange2;
  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.util.Util;
  28. /**
  29. * Dark Elven Change Part 2<br>
  30. * Original Jython script by DraX and DrLecter
  31. * @author nonom
  32. */
  33. public final class DarkElvenChange2 extends Quest
  34. {
  35. // NPCs
  36. private static int[] NPCS =
  37. {
  38. 31328, // Innocentin
  39. 30195, // Brecson
  40. 30699, // Medown
  41. 30474, // Angus
  42. 31324, // Andromeda
  43. 30862, // Oltran
  44. 30910, // Xairakin
  45. 31285, // Samael
  46. 31331, // Valdis
  47. 31334, // Tifaren
  48. 31974, // Drizzit
  49. 32096, // Helminter
  50. };
  51. // Items
  52. private static int MARK_OF_CHALLENGER = 2627;
  53. private static int MARK_OF_DUTY = 2633;
  54. private static int MARK_OF_SEEKER = 2673;
  55. private static int MARK_OF_SCHOLAR = 2674;
  56. private static int MARK_OF_PILGRIM = 2721;
  57. private static int MARK_OF_DUELIST = 2762;
  58. private static int MARK_OF_SEARCHER = 2809;
  59. private static int MARK_OF_REFORMER = 2821;
  60. private static int MARK_OF_MAGUS = 2840;
  61. private static int MARK_OF_FATE = 3172;
  62. private static int MARK_OF_SAGITTARIUS = 3293;
  63. private static int MARK_OF_WITCHCRAFT = 3307;
  64. private static int MARK_OF_SUMMONER = 3336;
  65. // @formatter:off
  66. private static int[][] CLASSES =
  67. {
  68. { 33, 32, 26, 27, 28, 29, MARK_OF_DUTY, MARK_OF_FATE, MARK_OF_WITCHCRAFT }, // SK
  69. { 34, 32, 30, 31, 32, 33, MARK_OF_CHALLENGER, MARK_OF_FATE, MARK_OF_DUELIST }, // BD
  70. { 43, 42, 34, 35, 36, 37, MARK_OF_PILGRIM, MARK_OF_FATE, MARK_OF_REFORMER }, // SE
  71. { 36, 35, 38, 39, 40, 41, MARK_OF_SEEKER, MARK_OF_FATE, MARK_OF_SEARCHER }, // AW
  72. { 37, 35, 42, 43, 44, 45, MARK_OF_SEEKER, MARK_OF_FATE, MARK_OF_SAGITTARIUS }, // PR
  73. { 40, 39, 46, 47, 48, 49, MARK_OF_SCHOLAR, MARK_OF_FATE, MARK_OF_MAGUS }, // SH
  74. { 41, 39, 50, 51, 52, 53, MARK_OF_SCHOLAR, MARK_OF_FATE, MARK_OF_SUMMONER }, // PS
  75. };
  76. // @formatter:on
  77. private DarkElvenChange2()
  78. {
  79. super(-1, DarkElvenChange2.class.getSimpleName(), "village_master");
  80. addStartNpc(NPCS);
  81. addTalkId(NPCS);
  82. }
  83. @Override
  84. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  85. {
  86. QuestState st = player.getQuestState(getName());
  87. if (st == null)
  88. {
  89. return getNoQuestMsg(player);
  90. }
  91. if (Util.isDigit(event))
  92. {
  93. int i = Integer.valueOf(event);
  94. final ClassId cid = player.getClassId();
  95. if ((cid.getRace() == Race.DARK_ELF) && (cid.getId() == CLASSES[i][1]))
  96. {
  97. int suffix;
  98. final boolean item1 = st.hasQuestItems(CLASSES[i][6]);
  99. final boolean item2 = st.hasQuestItems(CLASSES[i][7]);
  100. final boolean item3 = st.hasQuestItems(CLASSES[i][8]);
  101. if (player.getLevel() < 40)
  102. {
  103. suffix = (!item1 || !item2 || !item3) ? CLASSES[i][2] : CLASSES[i][3];
  104. }
  105. else
  106. {
  107. if (!item1 || !item2 || !item3)
  108. {
  109. suffix = CLASSES[i][4];
  110. }
  111. else
  112. {
  113. suffix = CLASSES[i][5];
  114. st.takeItems(CLASSES[i][6], -1);
  115. st.takeItems(CLASSES[i][7], -1);
  116. st.takeItems(CLASSES[i][8], -1);
  117. st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_2);
  118. player.setClassId(CLASSES[i][0]);
  119. player.setBaseClass(CLASSES[i][0]);
  120. player.broadcastUserInfo();
  121. st.exitQuest(false);
  122. }
  123. }
  124. event = "30474-" + suffix + ".html";
  125. }
  126. }
  127. return event;
  128. }
  129. @Override
  130. public String onTalk(L2Npc npc, L2PcInstance player)
  131. {
  132. String htmltext = getNoQuestMsg(player);
  133. QuestState st = player.getQuestState(getName());
  134. if (st == null)
  135. {
  136. st = newQuestState(player);
  137. }
  138. if (player.isSubClassActive())
  139. {
  140. return htmltext;
  141. }
  142. final ClassId cid = player.getClassId();
  143. if (cid.getRace() == Race.DARK_ELF)
  144. {
  145. switch (cid)
  146. {
  147. case palusKnight:
  148. {
  149. htmltext = "30474-01.html";
  150. break;
  151. }
  152. case shillienOracle:
  153. {
  154. htmltext = "30474-08.html";
  155. break;
  156. }
  157. case assassin:
  158. {
  159. htmltext = "30474-12.html";
  160. break;
  161. }
  162. case darkWizard:
  163. {
  164. htmltext = "30474-19.html";
  165. break;
  166. }
  167. default:
  168. {
  169. if (cid.level() == 0)
  170. {
  171. // first occupation not made yet
  172. htmltext = "30474-55.html";
  173. }
  174. else if (cid.level() >= 2)
  175. {
  176. // second/third occupation change already made
  177. htmltext = "30474-54.html";
  178. }
  179. else
  180. {
  181. htmltext = "30474-56.html";
  182. }
  183. }
  184. }
  185. }
  186. else
  187. {
  188. htmltext = "30474-56.html"; // other races
  189. }
  190. return htmltext;
  191. }
  192. public static void main(String[] args)
  193. {
  194. new DarkElvenChange2();
  195. }
  196. }