KetraOrcSupport.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.KetraOrcSupport;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import ai.npc.AbstractNpcAI;
  23. import com.l2jserver.gameserver.datatables.SkillData;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.skills.Skill;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Ketra Orc Support AI.<br>
  30. * Original Jython script by Emperorc and Kerberos_20.
  31. * @authors Nyaran
  32. */
  33. public final class KetraOrcSupport extends AbstractNpcAI
  34. {
  35. private static class BuffsData
  36. {
  37. private final int _skill;
  38. private final int _cost;
  39. public BuffsData(int skill, int cost)
  40. {
  41. _skill = skill;
  42. _cost = cost;
  43. }
  44. public Skill getSkill()
  45. {
  46. return SkillData.getInstance().getSkill(_skill, 1);
  47. }
  48. public int getCost()
  49. {
  50. return _cost;
  51. }
  52. }
  53. // NPCs
  54. private static final int KADUN = 31370; // Hierarch
  55. private static final int WAHKAN = 31371; // Messenger
  56. private static final int ASEFA = 31372; // Soul Guide
  57. private static final int ATAN = 31373; // Grocer
  58. private static final int JAFF = 31374; // Warehouse Keeper
  59. private static final int JUMARA = 31375; // Trader
  60. private static final int KURFA = 31376; // Gate Keeper
  61. // Items
  62. private static final int HORN = 7186;
  63. private static final int[] KETRA_MARKS =
  64. {
  65. 7211, // Mark of Ketra's Alliance - Level 1
  66. 7212, // Mark of Ketra's Alliance - Level 2
  67. 7213, // Mark of Ketra's Alliance - Level 3
  68. 7214, // Mark of Ketra's Alliance - Level 4
  69. 7215, // Mark of Ketra's Alliance - Level 5
  70. };
  71. // Misc
  72. private static final Map<Integer, BuffsData> BUFF = new HashMap<>();
  73. static
  74. {
  75. BUFF.put(1, new BuffsData(4359, 2)); // Focus: Requires 2 Buffalo Horns
  76. BUFF.put(2, new BuffsData(4360, 2)); // Death Whisper: Requires 2 Buffalo Horns
  77. BUFF.put(3, new BuffsData(4345, 3)); // Might: Requires 3 Buffalo Horns
  78. BUFF.put(4, new BuffsData(4355, 3)); // Acumen: Requires 3 Buffalo Horns
  79. BUFF.put(5, new BuffsData(4352, 3)); // Berserker: Requires 3 Buffalo Horns
  80. BUFF.put(6, new BuffsData(4354, 3)); // Vampiric Rage: Requires 3 Buffalo Horns
  81. BUFF.put(7, new BuffsData(4356, 6)); // Empower: Requires 6 Buffalo Horns
  82. BUFF.put(8, new BuffsData(4357, 6)); // Haste: Requires 6 Buffalo Horns
  83. }
  84. private KetraOrcSupport()
  85. {
  86. super(KetraOrcSupport.class.getSimpleName(), "ai/npc");
  87. addFirstTalkId(KADUN, WAHKAN, ASEFA, ATAN, JAFF, JUMARA, KURFA);
  88. addTalkId(ASEFA, KURFA, JAFF);
  89. addStartNpc(KURFA, JAFF);
  90. }
  91. private int getAllianceLevel(L2PcInstance player)
  92. {
  93. for (int i = 0; i < KETRA_MARKS.length; i++)
  94. {
  95. if (hasQuestItems(player, KETRA_MARKS[i]))
  96. {
  97. return (i + 1);
  98. }
  99. }
  100. return 0;
  101. }
  102. @Override
  103. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  104. {
  105. String htmltext = null;
  106. if (Util.isDigit(event) && BUFF.containsKey(Integer.parseInt(event)))
  107. {
  108. final BuffsData buff = BUFF.get(Integer.parseInt(event));
  109. if (getQuestItemsCount(player, HORN) >= buff.getCost())
  110. {
  111. takeItems(player, HORN, buff.getCost());
  112. npc.setTarget(player);
  113. npc.doCast(buff.getSkill());
  114. npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
  115. }
  116. else
  117. {
  118. htmltext = "31372-02.html";
  119. }
  120. }
  121. else if (event.equals("Teleport"))
  122. {
  123. final int AllianceLevel = getAllianceLevel(player);
  124. if (AllianceLevel == 4)
  125. {
  126. htmltext = "31376-04.html";
  127. }
  128. else if (AllianceLevel == 5)
  129. {
  130. htmltext = "31376-05.html";
  131. }
  132. }
  133. return htmltext;
  134. }
  135. @Override
  136. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  137. {
  138. String htmltext = getNoQuestMsg(player);
  139. final int AllianceLevel = getAllianceLevel(player);
  140. switch (npc.getId())
  141. {
  142. case KADUN:
  143. htmltext = (AllianceLevel > 0) ? "31370-friend.html" : "31370-no.html";
  144. break;
  145. case WAHKAN:
  146. htmltext = (AllianceLevel > 0) ? "31371-friend.html" : "31371-no.html";
  147. break;
  148. case ASEFA:
  149. htmltext = (AllianceLevel > 0) ? (AllianceLevel < 3) ? "31372-01.html" : "31372-04.html" : "31372-03.html";
  150. break;
  151. case ATAN:
  152. htmltext = (AllianceLevel > 0) ? "31373-friend.html" : "31373-no.html";
  153. break;
  154. case JAFF:
  155. htmltext = (AllianceLevel > 0) ? (AllianceLevel == 1) ? "31374-01.html" : "31374-02.html" : "31374-no.html";
  156. break;
  157. case JUMARA:
  158. switch (AllianceLevel)
  159. {
  160. case 1:
  161. case 2:
  162. htmltext = "31375-01.html";
  163. break;
  164. case 3:
  165. case 4:
  166. htmltext = "31375-02.html";
  167. break;
  168. case 5:
  169. htmltext = "31375-03.html";
  170. break;
  171. default:
  172. htmltext = "31375-no.html";
  173. break;
  174. }
  175. break;
  176. case KURFA:
  177. switch (AllianceLevel)
  178. {
  179. case 1:
  180. case 2:
  181. case 3:
  182. htmltext = "31376-01.html";
  183. break;
  184. case 4:
  185. htmltext = "31376-02.html";
  186. break;
  187. case 5:
  188. htmltext = "31376-03.html";
  189. break;
  190. default:
  191. htmltext = "31376-no.html";
  192. break;
  193. }
  194. break;
  195. }
  196. return htmltext;
  197. }
  198. public static void main(String args[])
  199. {
  200. new KetraOrcSupport();
  201. }
  202. }