KamaelChange1.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.KamaelChange1;
  20. import quests.Q00062_PathOfTheTrooper.Q00062_PathOfTheTrooper;
  21. import quests.Q00063_PathOfTheWarder.Q00063_PathOfTheWarder;
  22. import ai.npc.AbstractNpcAI;
  23. import com.l2jserver.gameserver.data.xml.impl.CategoryData;
  24. import com.l2jserver.gameserver.enums.CategoryType;
  25. import com.l2jserver.gameserver.enums.Race;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.base.ClassId;
  29. import com.l2jserver.gameserver.model.quest.QuestState;
  30. /**
  31. * Kamael class transfer AI.
  32. * @author Adry_85
  33. */
  34. public final class KamaelChange1 extends AbstractNpcAI
  35. {
  36. // NPCs
  37. private static int[] NPCS =
  38. {
  39. 32191, // Hanarin
  40. 32193, // Yeniche
  41. 32196, // Gershwin
  42. 32199, // Holst
  43. 32202, // Khadava
  44. };
  45. // Items
  46. private static final int SHADOW_ITEM_EXCHANGE_COUPON_D_GRADE = 8869;
  47. private static final int GWAINS_RECOMMENDATION = 9753;
  48. private static final int STEELRAZOR_EVALUATION = 9772;
  49. private KamaelChange1()
  50. {
  51. super(KamaelChange1.class.getSimpleName(), "village_master");
  52. addStartNpc(NPCS);
  53. addTalkId(NPCS);
  54. }
  55. @Override
  56. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  57. {
  58. String htmltext = null;
  59. switch (event)
  60. {
  61. case "32191-02.htm": // master_all_kamael003m
  62. case "32191-03.htm": // master_all_kamael006ma
  63. case "32191-04.htm": // master_all_kamael007ma
  64. case "32191-05.htm": // master_all_kamael007mait
  65. case "32191-06.htm": // master_all_kamael003f
  66. case "32191-07.htm": // master_all_kamael006fa
  67. case "32191-08.htm": // master_all_kamael007fa
  68. case "32191-09.htm": // master_all_kamael007fa
  69. {
  70. htmltext = event;
  71. break;
  72. }
  73. case "125":
  74. case "126":
  75. {
  76. htmltext = ClassChangeRequested(player, Integer.valueOf(event));
  77. break;
  78. }
  79. }
  80. return htmltext;
  81. }
  82. private String ClassChangeRequested(L2PcInstance player, int classId)
  83. {
  84. String htmltext = null;
  85. if (CategoryData.getInstance().isInCategory(CategoryType.KAMAEL_SECOND_CLASS_GROUP, classId))
  86. {
  87. if (player.isInCategory(CategoryType.KAMAEL_SECOND_CLASS_GROUP))
  88. {
  89. htmltext = "32191-10.htm"; // master_all_kamael004a
  90. }
  91. else if (player.isInCategory(CategoryType.KAMAEL_THIRD_CLASS_GROUP))
  92. {
  93. htmltext = "32191-11.htm"; // master_all_kamael005a
  94. }
  95. else if (player.isInCategory(CategoryType.KAMAEL_FOURTH_CLASS_GROUP))
  96. {
  97. htmltext = "32191-12.htm"; // master_all_kamael100a
  98. }
  99. else if ((classId == 125) && (player.getClassId() == ClassId.maleSoldier))
  100. {
  101. QuestState qs = player.getQuestState(Q00062_PathOfTheTrooper.class.getSimpleName());
  102. if (player.getLevel() < 20)
  103. {
  104. if ((qs != null) && qs.isCompleted())
  105. {
  106. htmltext = "32191-13.htm"; // master_all_kamael009ma
  107. }
  108. else
  109. {
  110. htmltext = "32191-14.htm"; // master_all_kamael008ma
  111. }
  112. }
  113. else if ((qs == null) || !qs.isCompleted())
  114. {
  115. htmltext = "32191-15.htm"; // master_all_kamael010ma
  116. }
  117. else
  118. {
  119. takeItems(player, GWAINS_RECOMMENDATION, -1);
  120. player.setClassId(125);
  121. player.setBaseClass(125);
  122. // SystemMessage and cast skill is done by setClassId
  123. player.broadcastUserInfo();
  124. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_D_GRADE, 15);
  125. htmltext = "32191-16.htm"; // master_all_kamael011ma
  126. }
  127. }
  128. else if ((classId == 126) && (player.getClassId() == ClassId.femaleSoldier))
  129. {
  130. QuestState qs = player.getQuestState(Q00063_PathOfTheWarder.class.getSimpleName());
  131. if (player.getLevel() < 20)
  132. {
  133. if ((qs != null) && qs.isCompleted())
  134. {
  135. htmltext = "32191-17.htm"; // master_all_kamael008fa
  136. }
  137. else
  138. {
  139. htmltext = "32191-18.htm"; // master_all_kamael009fa
  140. }
  141. }
  142. else if ((qs == null) || !qs.isCompleted())
  143. {
  144. htmltext = "32191-19.htm"; // master_all_kamael010fa
  145. }
  146. else
  147. {
  148. takeItems(player, STEELRAZOR_EVALUATION, -1);
  149. player.setClassId(126);
  150. player.setBaseClass(126);
  151. // SystemMessage and cast skill is done by setClassId
  152. player.broadcastUserInfo();
  153. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_D_GRADE, 15);
  154. htmltext = "32191-20.htm"; // master_all_kamael011fa
  155. }
  156. }
  157. }
  158. return htmltext;
  159. }
  160. @Override
  161. public String onTalk(L2Npc npc, L2PcInstance player)
  162. {
  163. String htmltext = null;
  164. if (player.getRace() != Race.KAMAEL)
  165. {
  166. htmltext = "32191-01.htm"; // master_all_kamael002a
  167. }
  168. else if (player.isInCategory(CategoryType.KAMAEL_FIRST_CLASS_GROUP))
  169. {
  170. if (player.getClassId() == ClassId.maleSoldier)
  171. {
  172. htmltext = "32191-02.htm"; // master_all_kamael003m
  173. }
  174. else if (player.getClassId() == ClassId.femaleSoldier)
  175. {
  176. htmltext = "32191-06.htm"; // master_all_kamael003f
  177. }
  178. }
  179. else if (player.isInCategory(CategoryType.KAMAEL_SECOND_CLASS_GROUP))
  180. {
  181. htmltext = "32191-10.htm"; // master_all_kamael004a
  182. }
  183. else if (player.isInCategory(CategoryType.KAMAEL_THIRD_CLASS_GROUP))
  184. {
  185. htmltext = "32191-11.htm"; // master_all_kamael005a
  186. }
  187. else
  188. {
  189. htmltext = "32191-12.htm"; // master_all_kamael100a
  190. }
  191. return htmltext;
  192. }
  193. public static void main(String[] args)
  194. {
  195. new KamaelChange1();
  196. }
  197. }