VarkaSilenosSupport.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package custom.VarkaSilenosSupport;
  16. import gnu.trove.TIntObjectHashMap;
  17. import com.l2jserver.gameserver.datatables.SkillTable;
  18. import com.l2jserver.gameserver.model.L2Skill;
  19. import com.l2jserver.gameserver.model.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.quest.Quest;
  22. import com.l2jserver.gameserver.model.quest.QuestState;
  23. import com.l2jserver.gameserver.model.quest.State;
  24. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  25. import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
  26. import com.l2jserver.gameserver.util.Util;
  27. /**
  28. * @authors Emperorc (python), Nyaran (java)
  29. * @notes Finished by Kerberos_20 (python) 10/23/07
  30. */
  31. public class VarkaSilenosSupport extends Quest
  32. {
  33. private static final String qn = "VarkaSilenosSupport";
  34. private static final int ASHAS = 31377; //Hierarch
  35. private static final int NARAN = 31378; //Messenger
  36. private static final int UDAN = 31379; //Buffer
  37. private static final int DIYABU= 31380; //Grocer
  38. private static final int HAGOS = 31381; //Warehouse Keeper
  39. private static final int SHIKON= 31382; //Trader
  40. private static final int TERANU= 31383; //Teleporter
  41. private static final int[] NPCS =
  42. {
  43. ASHAS, NARAN, UDAN, DIYABU, HAGOS, SHIKON, TERANU
  44. };
  45. private static final int SEED = 7187;
  46. private static final TIntObjectHashMap<BuffsData> BUFF = new TIntObjectHashMap<BuffsData>();
  47. private class BuffsData
  48. {
  49. private int _skill;
  50. private int _cost;
  51. public BuffsData(int skill, int cost)
  52. {
  53. super();
  54. _skill = skill;
  55. _cost = cost;
  56. }
  57. public L2Skill getSkill()
  58. {
  59. return SkillTable.getInstance().getInfo(_skill, 1);
  60. }
  61. public int getCost()
  62. {
  63. return _cost;
  64. }
  65. }
  66. @Override
  67. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  68. {
  69. String htmltext = event;
  70. QuestState st = player.getQuestState(qn);
  71. if (st == null)
  72. return htmltext;
  73. int Alevel = player.getAllianceWithVarkaKetra();
  74. if (Util.isDigit(event) && BUFF.containsKey(Integer.parseInt(event)))
  75. {
  76. BuffsData buff = BUFF.get(Integer.parseInt(event));
  77. if (st.getQuestItemsCount(SEED) >= buff.getCost())
  78. {
  79. st.takeItems(SEED, buff.getCost());
  80. npc.setTarget(player);
  81. npc.doCast(buff.getSkill());
  82. npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
  83. htmltext = "31379-4.htm";
  84. }
  85. }
  86. else if (event.equals("Withdraw"))
  87. {
  88. if (player.getWarehouse().getSize() == 0)
  89. htmltext = "31381-0.htm";
  90. else
  91. {
  92. player.sendPacket(ActionFailed.STATIC_PACKET);
  93. player.setActiveWarehouse(player.getWarehouse());
  94. player.sendPacket(new WareHouseWithdrawalList(player, 1));
  95. }
  96. }
  97. else if (event.equals("Teleport"))
  98. {
  99. if (Alevel == -4)
  100. htmltext = "31383-4.htm";
  101. else if (Alevel == -5)
  102. htmltext = "31383-5.htm";
  103. }
  104. return htmltext;
  105. }
  106. @Override
  107. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  108. {
  109. String htmltext = Quest.getNoQuestMsg(player);
  110. QuestState st = player.getQuestState(qn);
  111. if (st == null)
  112. st = this.newQuestState(player);
  113. int npcId = npc.getNpcId();
  114. int Alevel = player.getAllianceWithVarkaKetra();
  115. long seeds = st.getQuestItemsCount(SEED);
  116. if (npcId == ASHAS)
  117. {
  118. if (Alevel < 0)
  119. htmltext = "31377-friend.htm";
  120. else
  121. htmltext = "31377-no.htm";
  122. }
  123. else if (npcId == NARAN)
  124. {
  125. if (Alevel < 0)
  126. htmltext = "31378-friend.htm";
  127. else
  128. htmltext = "31378-no.htm";
  129. }
  130. else if (npcId == UDAN)
  131. {
  132. st.setState(State.STARTED);
  133. if (Alevel > -1)
  134. htmltext = "31379-3.htm";
  135. else if (Alevel > -3 && Alevel > 0)
  136. htmltext = "31379-1.htm";
  137. else if (Alevel < -2)
  138. if (seeds != 0)
  139. htmltext = "31379-4.htm";
  140. else
  141. htmltext = "31379-2.htm";
  142. }
  143. else if (npcId == DIYABU)
  144. {
  145. if (player.getKarma() >= 1)
  146. htmltext = "31380-pk.htm";
  147. else if (Alevel >= 0)
  148. htmltext = "31380-no.htm";
  149. else if (Alevel == -1 || Alevel == -2)
  150. htmltext = "31380-1.htm";
  151. else
  152. htmltext = "31380-2.htm";
  153. }
  154. else if (npcId == HAGOS)
  155. {
  156. if (Alevel >= 0)
  157. htmltext = "31381-no.htm";
  158. else if (Alevel == -1)
  159. htmltext = "31381-1.htm";
  160. else if (player.getWarehouse().getSize() == 0)
  161. htmltext = "31381-3.htm";
  162. else if (Alevel == -2 || Alevel == -3)
  163. htmltext = "31381-2.htm";
  164. else
  165. htmltext = "31381-4.htm";
  166. }
  167. else if (npcId == SHIKON)
  168. {
  169. if (Alevel == -2)
  170. htmltext = "31382-1.htm";
  171. else if (Alevel == -3 || Alevel == -4)
  172. htmltext = "31382-2.htm";
  173. else if (Alevel == -5)
  174. htmltext = "31382-3.htm";
  175. else
  176. htmltext = "31382-no.htm";
  177. }
  178. else if (npcId == TERANU)
  179. {
  180. if (Alevel >= 0)
  181. htmltext = "31383-no.htm";
  182. else if (Alevel < 0 && Alevel > -4)
  183. htmltext = "31383-1.htm";
  184. else if (Alevel == -4)
  185. htmltext = "31383-2.htm";
  186. else
  187. htmltext = "31383-3.htm";
  188. }
  189. return htmltext;
  190. }
  191. public VarkaSilenosSupport(int id, String name, String descr)
  192. {
  193. super(id, name, descr);
  194. for (int i : NPCS)
  195. addFirstTalkId(i);
  196. addTalkId(UDAN);
  197. addTalkId(HAGOS);
  198. addTalkId(TERANU);
  199. addStartNpc(HAGOS);
  200. addStartNpc(TERANU);
  201. BUFF.put(1, new BuffsData(4359, 2)); // Focus: Requires 2 Nepenthese Seeds
  202. BUFF.put(2, new BuffsData(4360, 2)); // Death Whisper: Requires 2 Nepenthese Seeds
  203. BUFF.put(3, new BuffsData(4345, 3)); // Might: Requires 3 Nepenthese Seeds
  204. BUFF.put(4, new BuffsData(4355, 3)); // Acumen: Requires 3 Nepenthese Seeds
  205. BUFF.put(5, new BuffsData(4352, 3)); // Berserker: Requires 3 Nepenthese Seeds
  206. BUFF.put(6, new BuffsData(4354, 3)); // Vampiric Rage: Requires 3 Nepenthese Seeds
  207. BUFF.put(7, new BuffsData(4356, 6)); // Empower: Requires 6 Nepenthese Seeds
  208. BUFF.put(8, new BuffsData(4357, 6)); // Haste: Requires 6 Nepenthese Seeds
  209. }
  210. public static void main(String args[])
  211. {
  212. new VarkaSilenosSupport(-1, qn, "custom");
  213. }
  214. }