KamaelChange2.java 11 KB

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