DarkElvenChange1.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.DarkElvenChange1;
  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 1<br>
  30. * Original Jython script by DraX and DrLecter
  31. * @author nonom
  32. */
  33. public final class DarkElvenChange1 extends Quest
  34. {
  35. // NPCs
  36. private static int[] NPCS =
  37. {
  38. 30290, // Xenos
  39. 30297, // Tobias
  40. 30462, // Tronix
  41. 32160, // Devon
  42. };
  43. // Items
  44. private static int GAZE_OF_ABYSS = 1244;
  45. private static int IRON_HEART = 1252;
  46. private static int JEWEL_OF_DARKNESS = 1261;
  47. private static int ORB_OF_ABYSS = 1270;
  48. // Rewards
  49. private static int SHADOW_WEAPON_COUPON_DGRADE = 8869;
  50. // @formatter:off
  51. private static int[][] CLASSES =
  52. {
  53. { 32, 31, 15, 16, 17, 18, GAZE_OF_ABYSS }, // PK
  54. { 35, 31, 19, 20, 21, 22, IRON_HEART }, // AS
  55. { 39, 38, 23, 24, 25, 26, JEWEL_OF_DARKNESS }, // DW
  56. { 42, 38, 27, 28, 29, 30, ORB_OF_ABYSS }, // SO
  57. };
  58. // @formatter:on
  59. private DarkElvenChange1()
  60. {
  61. super(-1, DarkElvenChange1.class.getSimpleName(), "village_master");
  62. addStartNpc(NPCS);
  63. addTalkId(NPCS);
  64. }
  65. @Override
  66. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  67. {
  68. QuestState st = player.getQuestState(getName());
  69. if (st == null)
  70. {
  71. return getNoQuestMsg(player);
  72. }
  73. if (Util.isDigit(event))
  74. {
  75. int i = Integer.valueOf(event);
  76. final ClassId cid = player.getClassId();
  77. if ((cid.getRace() == Race.DARK_ELF) && (cid.getId() == CLASSES[i][1]))
  78. {
  79. int suffix;
  80. final boolean item = st.hasQuestItems(CLASSES[i][6]);
  81. if (player.getLevel() < 20)
  82. {
  83. suffix = (!item) ? CLASSES[i][2] : CLASSES[i][3];
  84. }
  85. else
  86. {
  87. if (!item)
  88. {
  89. suffix = CLASSES[i][4];
  90. }
  91. else
  92. {
  93. suffix = CLASSES[i][5];
  94. st.giveItems(SHADOW_WEAPON_COUPON_DGRADE, 15);
  95. st.takeItems(CLASSES[i][6], -1);
  96. player.setClassId(CLASSES[i][0]);
  97. player.setBaseClass(CLASSES[i][0]);
  98. st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_2);
  99. player.broadcastUserInfo();
  100. st.exitQuest(false);
  101. }
  102. }
  103. event = npc.getId() + "-" + suffix + ".html";
  104. }
  105. }
  106. return event;
  107. }
  108. @Override
  109. public String onTalk(L2Npc npc, L2PcInstance player)
  110. {
  111. String htmltext = getNoQuestMsg(player);
  112. QuestState st = player.getQuestState(getName());
  113. if (st == null)
  114. {
  115. st = newQuestState(player);
  116. }
  117. if (player.isSubClassActive())
  118. {
  119. return htmltext;
  120. }
  121. final ClassId cid = player.getClassId();
  122. if (cid.getRace() == Race.DARK_ELF)
  123. {
  124. switch (cid)
  125. {
  126. case darkFighter:
  127. {
  128. htmltext = npc.getId() + "-01.html";
  129. break;
  130. }
  131. case darkMage:
  132. {
  133. htmltext = npc.getId() + "-08.html";
  134. break;
  135. }
  136. default:
  137. {
  138. if (cid.level() == 1)
  139. {
  140. // first occupation change already made
  141. return npc.getId() + "-32.html";
  142. }
  143. else if (cid.level() >= 2)
  144. {
  145. // second/third occupation change already made
  146. return npc.getId() + "-31.html";
  147. }
  148. }
  149. }
  150. }
  151. else
  152. {
  153. htmltext = npc.getId() + "-33.html"; // other races
  154. }
  155. return htmltext;
  156. }
  157. public static void main(String[] args)
  158. {
  159. new DarkElvenChange1();
  160. }
  161. }