VarkaSilenosSupport.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.VarkaSilenosSupport;
  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. * Varka Silenos Support AI.<br>
  30. * Original Jython script by Emperorc and Kerberos_20.
  31. * @author Nyaran
  32. */
  33. public final class VarkaSilenosSupport 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 ASHAS = 31377; // Hierarch
  55. private static final int NARAN = 31378; // Messenger
  56. private static final int UDAN = 31379; // Buffer
  57. private static final int DIYABU = 31380; // Grocer
  58. private static final int HAGOS = 31381; // Warehouse Keeper
  59. private static final int SHIKON = 31382; // Trader
  60. private static final int TERANU = 31383; // Teleporter
  61. // Items
  62. private static final int SEED = 7187;
  63. private static final int[] VARKA_MARKS =
  64. {
  65. 7221, // Mark of Varka's Alliance - Level 1
  66. 7222, // Mark of Varka's Alliance - Level 2
  67. 7223, // Mark of Varka's Alliance - Level 3
  68. 7224, // Mark of Varka's Alliance - Level 4
  69. 7225, // Mark of Varka'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 Nepenthese Seeds
  76. BUFF.put(2, new BuffsData(4360, 2)); // Death Whisper: Requires 2 Nepenthese Seeds
  77. BUFF.put(3, new BuffsData(4345, 3)); // Might: Requires 3 Nepenthese Seeds
  78. BUFF.put(4, new BuffsData(4355, 3)); // Acumen: Requires 3 Nepenthese Seeds
  79. BUFF.put(5, new BuffsData(4352, 3)); // Berserker: Requires 3 Nepenthese Seeds
  80. BUFF.put(6, new BuffsData(4354, 3)); // Vampiric Rage: Requires 3 Nepenthese Seeds
  81. BUFF.put(7, new BuffsData(4356, 6)); // Empower: Requires 6 Nepenthese Seeds
  82. BUFF.put(8, new BuffsData(4357, 6)); // Haste: Requires 6 Nepenthese Seeds
  83. }
  84. private VarkaSilenosSupport()
  85. {
  86. super(VarkaSilenosSupport.class.getSimpleName(), "ai/npc");
  87. addFirstTalkId(ASHAS, NARAN, UDAN, DIYABU, HAGOS, SHIKON, TERANU);
  88. addTalkId(UDAN, HAGOS, TERANU);
  89. addStartNpc(HAGOS, TERANU);
  90. }
  91. private int getAllianceLevel(L2PcInstance player)
  92. {
  93. for (int i = 0; i < VARKA_MARKS.length; i++)
  94. {
  95. if (hasQuestItems(player, VARKA_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, SEED) >= buff.getCost())
  110. {
  111. takeItems(player, SEED, buff.getCost());
  112. npc.setTarget(player);
  113. npc.doCast(buff.getSkill());
  114. npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
  115. }
  116. else
  117. {
  118. htmltext = "31379-02.html";
  119. }
  120. }
  121. else if (event.equals("Teleport"))
  122. {
  123. final int AllianceLevel = getAllianceLevel(player);
  124. if (AllianceLevel == -4)
  125. {
  126. htmltext = "31383-04.html";
  127. }
  128. else if (AllianceLevel == -5)
  129. {
  130. htmltext = "31383-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 ASHAS:
  143. htmltext = (AllianceLevel < 0) ? "31377-friend.html" : "31377-no.html";
  144. break;
  145. case NARAN:
  146. htmltext = (AllianceLevel < 0) ? "31378-friend.html" : "31378-no.html";
  147. break;
  148. case UDAN:
  149. htmltext = (AllianceLevel < 0) ? (AllianceLevel > -3) ? "31379-01.html" : "31379-04.html" : "31379-03.html";
  150. break;
  151. case DIYABU:
  152. htmltext = (AllianceLevel < 0) ? "31380-friend.html" : "31380-no.html";
  153. break;
  154. case HAGOS:
  155. htmltext = (AllianceLevel < 0) ? (AllianceLevel == -1) ? "31381-01.html" : "31381-02.html" : "31381-no.html";
  156. break;
  157. case SHIKON:
  158. switch (AllianceLevel)
  159. {
  160. case -1:
  161. case -2:
  162. htmltext = "31382-01.html";
  163. break;
  164. case -3:
  165. case -4:
  166. htmltext = "31382-02.html";
  167. break;
  168. case -5:
  169. htmltext = "31382-03.html";
  170. break;
  171. default:
  172. htmltext = "31382-no.html";
  173. break;
  174. }
  175. break;
  176. case TERANU:
  177. switch (AllianceLevel)
  178. {
  179. case -1:
  180. case -2:
  181. case -3:
  182. htmltext = "31383-01.html";
  183. break;
  184. case -4:
  185. htmltext = "31383-02.html";
  186. break;
  187. case -5:
  188. htmltext = "31383-03.html";
  189. break;
  190. default:
  191. htmltext = "31383-no.html";
  192. break;
  193. }
  194. break;
  195. }
  196. return htmltext;
  197. }
  198. public static void main(String args[])
  199. {
  200. new VarkaSilenosSupport();
  201. }
  202. }