DarkElvenChange1.java 3.8 KB

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