CastleCourtMagician.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 ai.npc.CastleCourtMagician;
  20. import handlers.effecthandlers.CallPc;
  21. import ai.npc.AbstractNpcAI;
  22. import com.l2jserver.gameserver.model.ClanPrivilege;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.holders.SkillHolder;
  26. import com.l2jserver.gameserver.network.clientpackets.RequestAcquireSkill;
  27. /**
  28. * Castle Court Magician AI.
  29. * @author St3eT
  30. */
  31. public final class CastleCourtMagician extends AbstractNpcAI
  32. {
  33. // NPCs
  34. private static final int[] COURT_MAGICIAN =
  35. {
  36. 35648, // Gludio
  37. 35649, // Dion
  38. 35650, // Giran
  39. 35651, // Oren
  40. 35652, // Aden
  41. 35653, // Innadril
  42. 35654, // Goddard
  43. 35655, // Rune
  44. 35656, // Schuttgard
  45. };
  46. // Skills
  47. private static final int CLAN_GATE = 3632; // Clan Gate
  48. private static final SkillHolder DISPLAY_CLAN_GATE = new SkillHolder(5109, 1); // Production - Clan Gate
  49. // Items
  50. private static final int EPAULETTE = 9912; // Knight's Epaulette
  51. private static final int RED_MEDITATION = 9931; // Red Talisman of Meditation
  52. private static final int BLUE_DIV_PROTECTION = 9932; // Blue Talisman - Divine Protection
  53. private static final int BLUE_EXPLOSION = 10416; // Blue Talisman - Explosion
  54. private static final int BLUE_M_EXPLOSION = 10417; // Blue Talisman - Magic Explosion
  55. private static final int RED_MIN_CLARITY = 9917; // Red Talisman of Minimum Clarity
  56. private static final int RED_MAX_CLARITY = 9918; // Red Talisman of Maximum Clarity
  57. private static final int RED_MENTAL_REG = 9928; // Red Talisman of Mental Regeneration
  58. private static final int BLUE_PROTECTION = 9929; // Blue Talisman of Protection
  59. private static final int BLUE_INVIS = 9920; // Blue Talisman of Invisibility
  60. private static final int BLUE_DEFENSE = 9916; // Blue Talisman of Defense
  61. private static final int BLACK_ESCAPE = 9923; // Black Talisman - Escape
  62. private static final int BLUE_HEALING = 9924; // Blue Talisman of Healing
  63. private static final int RED_RECOVERY = 9925; // Red Talisman of Recovery
  64. private static final int BLUE_DEFENSE2 = 9926; // Blue Talisman of Defense
  65. private static final int BLUE_M_DEFENSE = 9927; // Blue Talisman of Magic Defense
  66. private static final int RED_LIFE_FORCE = 10518; // Red Talisman - Life Force
  67. private static final int BLUE_GREAT_HEAL = 10424; // Blue Talisman - Greater Healing
  68. private static final int WHITE_FIRE = 10421; // White Talisman - Fire
  69. private static final int[] COMMON_TALISMANS =
  70. {
  71. 9914, // Blue Talisman of Power
  72. 9915, // Blue Talisman of Wild Magic
  73. 9920, // Blue Talisman of Invisibility
  74. 9921, // Blue Talisman - Shield Protection
  75. 9922, // Black Talisman - Mending
  76. 9933, // Yellow Talisman of Power
  77. 9934, // Yellow Talisman of Violent Haste
  78. 9935, // Yellow Talisman of Arcane Defense
  79. 9936, // Yellow Talisman of Arcane Power
  80. 9937, // Yellow Talisman of Arcane Haste
  81. 9938, // Yellow Talisman of Accuracy
  82. 9939, // Yellow Talisman of Defense
  83. 9940, // Yellow Talisman of Alacrity
  84. 9941, // Yellow Talisman of Speed
  85. 9942, // Yellow Talisman of Critical Reduction
  86. 9943, // Yellow Talisman of Critical Damage
  87. 9944, // Yellow Talisman of Critical Dodging
  88. 9945, // Yellow Talisman of Evasion
  89. 9946, // Yellow Talisman of Healing
  90. 9947, // Yellow Talisman of CP Regeneration
  91. 9948, // Yellow Talisman of Physical Regeneration
  92. 9949, // Yellow Talisman of Mental Regeneration
  93. 9950, // Grey Talisman of Weight Training
  94. 9952, // Orange Talisman - Hot Springs CP Potion
  95. 9953, // Orange Talisman - Elixir of Life
  96. 9954, // Orange Talisman - Elixir of Mental Strength
  97. 9955, // Black Talisman - Vocalization
  98. 9956, // Black Talisman - Arcane Freedom
  99. 9957, // Black Talisman - Physical Freedom
  100. 9958, // Black Talisman - Rescue
  101. 9959, // Black Talisman - Free Speech
  102. 9960, // White Talisman of Bravery
  103. 9961, // White Talisman of Motion
  104. 9962, // White Talisman of Grounding
  105. 9963, // White Talisman of Attention
  106. 9964, // White Talisman of Bandages
  107. 9965, // White Talisman of Protection
  108. 10418, // White Talisman - Storm
  109. 10420, // White Talisman - Water
  110. 10519, // White Talisman - Earth
  111. 10422, // White Talisman - Light
  112. 10423, // Blue Talisman - Self-Destruction
  113. 10419, // White Talisman - Darkness
  114. };
  115. private CastleCourtMagician()
  116. {
  117. super(CastleCourtMagician.class.getSimpleName(), "ai/npc");
  118. addStartNpc(COURT_MAGICIAN);
  119. addTalkId(COURT_MAGICIAN);
  120. addFirstTalkId(COURT_MAGICIAN);
  121. }
  122. @Override
  123. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  124. {
  125. if ((player.getClan() == null) && (player.getClanId() != npc.getCastle().getOwnerId()))
  126. {
  127. return "courtmagician-01.html";
  128. }
  129. String htmltext = null;
  130. int itemId = 0;
  131. switch (event)
  132. {
  133. case "courtmagician.html":
  134. case "courtmagician-03.html":
  135. {
  136. htmltext = event;
  137. break;
  138. }
  139. case "giveTalisman":
  140. {
  141. if (getQuestItemsCount(player, EPAULETTE) < 10)
  142. {
  143. htmltext = "courtmagician-06.html";
  144. break;
  145. }
  146. final int categoryChance = getRandom(100);
  147. if (categoryChance <= 5)
  148. {
  149. final int chance = getRandom(100);
  150. if (chance <= 25)
  151. {
  152. itemId = RED_MEDITATION;
  153. }
  154. else if (chance <= 50)
  155. {
  156. itemId = BLUE_DIV_PROTECTION;
  157. }
  158. else if (chance <= 75)
  159. {
  160. itemId = BLUE_EXPLOSION;
  161. }
  162. else
  163. {
  164. itemId = BLUE_M_EXPLOSION;
  165. }
  166. }
  167. else if (categoryChance <= 15)
  168. {
  169. final int chance = getRandom(100);
  170. if (chance <= 20)
  171. {
  172. itemId = RED_MIN_CLARITY;
  173. }
  174. else if (chance <= 40)
  175. {
  176. itemId = RED_MAX_CLARITY;
  177. }
  178. else if (chance <= 60)
  179. {
  180. itemId = RED_MENTAL_REG;
  181. }
  182. else if (chance <= 80)
  183. {
  184. itemId = BLUE_PROTECTION;
  185. }
  186. else
  187. {
  188. itemId = BLUE_INVIS;
  189. }
  190. }
  191. else if (categoryChance <= 30)
  192. {
  193. final int chance = getRandom(100);
  194. if (chance <= 12)
  195. {
  196. itemId = BLUE_DEFENSE;
  197. }
  198. else if (chance <= 25)
  199. {
  200. itemId = BLACK_ESCAPE;
  201. }
  202. else if (chance <= 37)
  203. {
  204. itemId = BLUE_HEALING;
  205. }
  206. else if (chance <= 50)
  207. {
  208. itemId = RED_RECOVERY;
  209. }
  210. else if (chance <= 62)
  211. {
  212. itemId = BLUE_DEFENSE2;
  213. }
  214. else if (chance <= 75)
  215. {
  216. itemId = BLUE_M_DEFENSE;
  217. }
  218. else if (chance <= 87)
  219. {
  220. itemId = RED_LIFE_FORCE;
  221. }
  222. else
  223. {
  224. itemId = BLUE_GREAT_HEAL;
  225. }
  226. }
  227. else
  228. {
  229. final int chance = getRandom(46);
  230. if (chance <= 42)
  231. {
  232. itemId = COMMON_TALISMANS[chance];
  233. }
  234. else
  235. {
  236. itemId = WHITE_FIRE;
  237. }
  238. }
  239. takeItems(player, EPAULETTE, 10);
  240. giveItems(player, itemId, 1);
  241. htmltext = "courtmagician-04.html";
  242. break;
  243. }
  244. case "squadSkill":
  245. {
  246. if (player.isClanLeader() || player.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
  247. {
  248. RequestAcquireSkill.showSubUnitSkillList(player);
  249. }
  250. else
  251. {
  252. htmltext = "courtmagician-05.html";
  253. }
  254. break;
  255. }
  256. case "clanTeleport":
  257. {
  258. if (player.getClanId() == npc.getCastle().getOwnerId())
  259. {
  260. final L2PcInstance clanLeader = player.getClan().getLeader().getPlayerInstance();
  261. if ((clanLeader != null) && clanLeader.isAffectedBySkill(CLAN_GATE))
  262. {
  263. if (CallPc.checkSummonTargetStatus(player, clanLeader)) // TODO: Custom one, retail dont check it but for sure lets check same conditions like when summon player by skill.
  264. {
  265. npc.setTarget(player);
  266. npc.doCast(DISPLAY_CLAN_GATE.getSkill());
  267. player.teleToLocation(clanLeader.getLocation(), true);
  268. }
  269. }
  270. else
  271. {
  272. htmltext = "courtmagician-02.html";
  273. }
  274. }
  275. break;
  276. }
  277. }
  278. return htmltext;
  279. }
  280. @Override
  281. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  282. {
  283. return ((player.getClan() != null) && (player.getClanId() == npc.getCastle().getOwnerId())) ? "courtmagician.html" : "courtmagician-01.html";
  284. }
  285. public static void main(String[] args)
  286. {
  287. new CastleCourtMagician();
  288. }
  289. }