KamaelChange2.java 11 KB

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