KamaelChange2.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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.KamaelChange2;
  20. import quests.Q00064_CertifiedBerserker.Q00064_CertifiedBerserker;
  21. import quests.Q00065_CertifiedSoulBreaker.Q00065_CertifiedSoulBreaker;
  22. import quests.Q00066_CertifiedArbalester.Q00066_CertifiedArbalester;
  23. import ai.npc.AbstractNpcAI;
  24. import com.l2jserver.gameserver.data.xml.impl.CategoryData;
  25. import com.l2jserver.gameserver.enums.CategoryType;
  26. import com.l2jserver.gameserver.enums.Race;
  27. import com.l2jserver.gameserver.model.actor.L2Npc;
  28. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  29. import com.l2jserver.gameserver.model.base.ClassId;
  30. import com.l2jserver.gameserver.model.quest.QuestState;
  31. import com.l2jserver.gameserver.util.Util;
  32. /**
  33. * Kamael class transfer AI.
  34. * @author Adry_85
  35. */
  36. public final class KamaelChange2 extends AbstractNpcAI
  37. {
  38. // NPCs
  39. private static int[] NPCS_MALE =
  40. {
  41. 32146, // Valpor
  42. 32205, // Aetonic
  43. 32209, // Ferdinand
  44. 32213, // Vitus
  45. 32217, // Barta
  46. 32221, // Brome
  47. 32225, // Taine
  48. 32229, // Hagel
  49. 32233, // Zoldart
  50. };
  51. private static int[] NPCS_FEMALE =
  52. {
  53. 32145, // Maynard
  54. 32206, // Pieche
  55. 32210, // Eddy
  56. 32214, // Meldina
  57. 32218, // Miya
  58. 32222, // Liane
  59. 32226, // Raula
  60. 32230, // Ceci
  61. 32234, // Nizer
  62. };
  63. // Items
  64. private static final int SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE = 8870;
  65. private static final int ORKURUS_RECOMMENDATION = 9760;
  66. private static final int KAMAEL_INQUISITOR_MARK = 9782;
  67. private static final int SOUL_BREAKER_CERTIFICATE = 9806;
  68. private KamaelChange2()
  69. {
  70. super(KamaelChange2.class.getSimpleName(), "village_master");
  71. addStartNpc(NPCS_MALE);
  72. addStartNpc(NPCS_FEMALE);
  73. addTalkId(NPCS_MALE);
  74. addTalkId(NPCS_FEMALE);
  75. }
  76. @Override
  77. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  78. {
  79. String htmltext = null;
  80. switch (event)
  81. {
  82. case "32145-05.htm": // master_all_kamael003t
  83. case "32145-06.htm": // master_all_kamael006ta
  84. case "32145-07.htm": // master_all_kamael007ta
  85. case "32145-08.htm": // master_all_kamael006msa
  86. case "32145-09.htm": // master_all_kamael007msa
  87. case "32145-11.htm": // master_all_kamael003w
  88. case "32145-12.htm": // master_all_kamael006wa
  89. case "32145-13.htm": // master_all_kamael007wa
  90. case "32145-14.htm": // master_all_kamael006fsa
  91. case "32145-15.htm": // master_all_kamael007fsa
  92. {
  93. htmltext = event;
  94. break;
  95. }
  96. case "127":
  97. case "128":
  98. case "129":
  99. case "130":
  100. {
  101. htmltext = ClassChangeRequested(player, npc, Integer.valueOf(event));
  102. break;
  103. }
  104. }
  105. return htmltext;
  106. }
  107. private String ClassChangeRequested(L2PcInstance player, L2Npc npc, int classId)
  108. {
  109. String htmltext = null;
  110. if (CategoryData.getInstance().isInCategory(CategoryType.KAMAEL_THIRD_CLASS_GROUP, classId))
  111. {
  112. if (player.isInCategory(CategoryType.KAMAEL_FIRST_CLASS_GROUP))
  113. {
  114. if (Util.contains(NPCS_MALE, npc.getId()))
  115. {
  116. htmltext = "32145-02.htm"; // master_all_kamael012b
  117. }
  118. else
  119. {
  120. htmltext = "32145-03.htm"; // master_all_kamael012c
  121. }
  122. }
  123. else if (player.isInCategory(CategoryType.KAMAEL_THIRD_CLASS_GROUP))
  124. {
  125. if (Util.contains(NPCS_MALE, npc.getId()))
  126. {
  127. htmltext = "32145-16.htm"; // master_all_kamael005b
  128. }
  129. else
  130. {
  131. htmltext = "32145-17.htm"; // master_all_kamael005c
  132. }
  133. }
  134. else if (player.isInCategory(CategoryType.KAMAEL_FOURTH_CLASS_GROUP))
  135. {
  136. if (Util.contains(NPCS_MALE, npc.getId()))
  137. {
  138. htmltext = "32145-18.htm"; // master_all_kamael100b
  139. }
  140. else
  141. {
  142. htmltext = "32145-19.htm"; // master_all_kamael100c
  143. }
  144. }
  145. else if (player.getClassId() == ClassId.trooper)
  146. {
  147. if (Util.contains(NPCS_MALE, npc.getId()))
  148. {
  149. if (classId == 127)
  150. {
  151. QuestState qs = player.getQuestState(Q00064_CertifiedBerserker.class.getSimpleName());
  152. if (player.getLevel() < 40)
  153. {
  154. if ((qs != null) && qs.isCompleted())
  155. {
  156. htmltext = "32145-20.htm"; // master_all_kamael008ta
  157. }
  158. else
  159. {
  160. htmltext = "32145-21.htm"; // master_all_kamael009ta
  161. }
  162. }
  163. else if ((qs == null) || !qs.isCompleted())
  164. {
  165. htmltext = "32145-22.htm"; // master_all_kamael010ta
  166. }
  167. else
  168. {
  169. takeItems(player, ORKURUS_RECOMMENDATION, -1);
  170. player.setClassId(127);
  171. player.setBaseClass(127);
  172. // SystemMessage and cast skill is done by setClassId
  173. player.broadcastUserInfo();
  174. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
  175. htmltext = "32145-23.htm"; // master_all_kamael011ta
  176. }
  177. }
  178. else if (classId == 128)
  179. {
  180. QuestState qs = player.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
  181. if (player.getLevel() < 40)
  182. {
  183. if ((qs != null) && qs.isCompleted())
  184. {
  185. htmltext = "32145-24.htm"; // master_all_kamael008msa
  186. }
  187. else
  188. {
  189. htmltext = "32145-25.htm"; // master_all_kamael009msa
  190. }
  191. }
  192. else if ((qs == null) || !qs.isCompleted())
  193. {
  194. htmltext = "32145-26.htm"; // master_all_kamael010msa
  195. }
  196. else
  197. {
  198. takeItems(player, SOUL_BREAKER_CERTIFICATE, -1);
  199. player.setClassId(128);
  200. player.setBaseClass(128);
  201. // SystemMessage and cast skill is done by setClassId
  202. player.broadcastUserInfo();
  203. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
  204. htmltext = "32145-27.htm"; // master_all_kamael011msa
  205. }
  206. }
  207. }
  208. else
  209. {
  210. htmltext = "32145-10.htm"; // master_all_kamael002c
  211. }
  212. }
  213. else if (player.getClassId() == ClassId.warder)
  214. {
  215. if (Util.contains(NPCS_MALE, npc.getId()))
  216. {
  217. htmltext = "32145-04.htm"; // master_all_kamael002b
  218. }
  219. else
  220. {
  221. if (classId == 129)
  222. {
  223. QuestState qs = player.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
  224. if (player.getLevel() < 40)
  225. {
  226. if ((qs != null) && qs.isCompleted())
  227. {
  228. htmltext = "32145-28.htm"; // master_all_kamael008fsa
  229. }
  230. else
  231. {
  232. htmltext = "32145-29.htm"; // master_all_kamael009fsa
  233. }
  234. }
  235. else if ((qs == null) || !qs.isCompleted())
  236. {
  237. htmltext = "32145-30.htm"; // master_all_kamael010fsa
  238. }
  239. else
  240. {
  241. takeItems(player, SOUL_BREAKER_CERTIFICATE, -1);
  242. player.setClassId(129);
  243. player.setBaseClass(129);
  244. // SystemMessage and cast skill is done by setClassId
  245. player.broadcastUserInfo();
  246. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
  247. htmltext = "32145-31.htm"; // master_all_kamael011fsa
  248. }
  249. }
  250. else if (classId == 130)
  251. {
  252. QuestState qs = player.getQuestState(Q00066_CertifiedArbalester.class.getSimpleName());
  253. if (player.getLevel() < 40)
  254. {
  255. if ((qs != null) && qs.isCompleted())
  256. {
  257. htmltext = "32145-32.htm"; // master_all_kamael008wa
  258. }
  259. else
  260. {
  261. htmltext = "32145-33.htm"; // master_all_kamael009wa
  262. }
  263. }
  264. else if ((qs == null) || !qs.isCompleted())
  265. {
  266. htmltext = "32145-34.htm"; // master_all_kamael010wa
  267. }
  268. else
  269. {
  270. takeItems(player, KAMAEL_INQUISITOR_MARK, -1);
  271. player.setClassId(130);
  272. player.setBaseClass(130);
  273. // SystemMessage and cast skill is done by setClassId
  274. player.broadcastUserInfo();
  275. giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
  276. htmltext = "32145-35.htm"; // master_all_kamael011wa
  277. }
  278. }
  279. }
  280. }
  281. }
  282. return htmltext;
  283. }
  284. @Override
  285. public String onTalk(L2Npc npc, L2PcInstance player)
  286. {
  287. String htmltext = null;
  288. if (player.getRace() != Race.KAMAEL)
  289. {
  290. htmltext = "32145-01.htm"; // master_all_kamael002a
  291. }
  292. else if (player.isInCategory(CategoryType.KAMAEL_FIRST_CLASS_GROUP))
  293. {
  294. if (player.getClassId() == ClassId.maleSoldier)
  295. {
  296. htmltext = "32145-02.htm"; // master_all_kamael012b
  297. }
  298. else if (player.getClassId() == ClassId.femaleSoldier)
  299. {
  300. htmltext = "32145-03.htm"; // master_all_kamael012c
  301. }
  302. }
  303. else if (player.isInCategory(CategoryType.KAMAEL_SECOND_CLASS_GROUP))
  304. {
  305. if (Util.contains(NPCS_MALE, npc.getId()))
  306. {
  307. if (player.isInCategory(CategoryType.KAMAEL_FEMALE_MAIN_OCCUPATION))
  308. {
  309. htmltext = "32145-04.htm"; // master_all_kamael002b
  310. return htmltext;
  311. }
  312. if (player.getClassId() == ClassId.trooper)
  313. {
  314. htmltext = "32145-05.htm"; // master_all_kamael003t
  315. }
  316. else if (player.getClassId() == ClassId.warder)
  317. {
  318. htmltext = "32145-02.htm"; // master_all_kamael012b
  319. }
  320. }
  321. else
  322. {
  323. if (player.isInCategory(CategoryType.KAMAEL_MALE_MAIN_OCCUPATION))
  324. {
  325. htmltext = "32145-10.htm"; // master_all_kamael002c
  326. return htmltext;
  327. }
  328. if (player.getClassId() == ClassId.trooper)
  329. {
  330. htmltext = "32145-03.htm"; // master_all_kamael012c
  331. }
  332. else if (player.getClassId() == ClassId.warder)
  333. {
  334. htmltext = "32145-11.htm"; // master_all_kamael003w
  335. }
  336. }
  337. }
  338. else if (player.isInCategory(CategoryType.KAMAEL_THIRD_CLASS_GROUP))
  339. {
  340. if (Util.contains(NPCS_MALE, npc.getId()))
  341. {
  342. if (player.isInCategory(CategoryType.KAMAEL_MALE_MAIN_OCCUPATION))
  343. {
  344. htmltext = "32145-16.htm"; // master_all_kamael005b
  345. }
  346. else
  347. {
  348. htmltext = "32145-04.htm"; // master_all_kamael002b
  349. }
  350. }
  351. else
  352. {
  353. if (player.isInCategory(CategoryType.KAMAEL_FEMALE_MAIN_OCCUPATION))
  354. {
  355. htmltext = "32145-17.htm"; // master_all_kamael005c
  356. }
  357. else
  358. {
  359. htmltext = "32145-10.htm"; // master_all_kamael002c
  360. }
  361. }
  362. }
  363. else if (player.isInCategory(CategoryType.KAMAEL_FOURTH_CLASS_GROUP))
  364. {
  365. if (Util.contains(NPCS_MALE, npc.getId()))
  366. {
  367. if (player.isInCategory(CategoryType.KAMAEL_MALE_MAIN_OCCUPATION))
  368. {
  369. htmltext = "32145-18.htm"; // master_all_kamael100b
  370. }
  371. else
  372. {
  373. htmltext = "32145-04.htm"; // master_all_kamael002b
  374. }
  375. }
  376. else
  377. {
  378. if (player.isInCategory(CategoryType.KAMAEL_FEMALE_MAIN_OCCUPATION))
  379. {
  380. htmltext = "32145-19.htm"; // master_all_kamael100c
  381. }
  382. else
  383. {
  384. htmltext = "32145-10.htm"; // master_all_kamael002c
  385. }
  386. }
  387. }
  388. return htmltext;
  389. }
  390. public static void main(String[] args)
  391. {
  392. new KamaelChange2();
  393. }
  394. }