Selina.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.Selina;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import ai.npc.AbstractNpcAI;
  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.model.skills.Skill;
  27. /**
  28. * Mercenary Medic Selina AI.
  29. * @author Zoey76
  30. */
  31. public final class Selina extends AbstractNpcAI
  32. {
  33. // NPC
  34. private static final int SELINA = 31556;
  35. // Items
  36. private static final int GOLDEN_RAM_BADGE_RECRUIT = 7246;
  37. private static final int GOLDEN_RAM_BADGE_SOLDIER = 7247;
  38. private static final int GOLDEN_RAM_COIN = 7251;
  39. // Skills
  40. private static final Map<String, BuffHolder> BUFFS = new HashMap<>();
  41. static
  42. {
  43. BUFFS.put("4359", new BuffHolder(4359, 2, 2)); // Focus
  44. BUFFS.put("4360", new BuffHolder(4360, 2, 2)); // Death Whisper
  45. BUFFS.put("4345", new BuffHolder(4345, 3, 3)); // Might
  46. BUFFS.put("4355", new BuffHolder(4355, 2, 3)); // Acumen
  47. BUFFS.put("4352", new BuffHolder(4352, 1, 3)); // Berserker Spirit
  48. BUFFS.put("4354", new BuffHolder(4354, 2, 3)); // Vampiric Rage
  49. BUFFS.put("4356", new BuffHolder(4356, 1, 6)); // Empower
  50. BUFFS.put("4357", new BuffHolder(4357, 2, 6)); // Haste
  51. }
  52. public Selina()
  53. {
  54. super(Selina.class.getSimpleName(), "ai/npc");
  55. addStartNpc(SELINA);
  56. addTalkId(SELINA);
  57. addFirstTalkId(SELINA);
  58. addSpellFinishedId(SELINA);
  59. }
  60. @Override
  61. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  62. {
  63. final BuffHolder buff = BUFFS.get(event);
  64. if (buff != null)
  65. {
  66. if ((getQuestItemsCount(player, GOLDEN_RAM_COIN) >= buff.getCost()))
  67. {
  68. castSkill(npc, player, buff);
  69. return super.onAdvEvent(event, npc, player);
  70. }
  71. }
  72. else
  73. {
  74. _log.warning(Selina.class.getSimpleName() + " AI: player " + player + " sent invalid bypass: " + event);
  75. }
  76. return "31556-02.html";
  77. }
  78. @Override
  79. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  80. {
  81. final String htmltext;
  82. if (hasQuestItems(player, GOLDEN_RAM_BADGE_SOLDIER))
  83. {
  84. htmltext = "31556-08.html";
  85. }
  86. else if (hasQuestItems(player, GOLDEN_RAM_BADGE_RECRUIT))
  87. {
  88. htmltext = "31556-01.html";
  89. }
  90. else
  91. {
  92. htmltext = "31556-09.html";
  93. }
  94. return htmltext;
  95. }
  96. @Override
  97. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  98. {
  99. final BuffHolder buff = BUFFS.get(Integer.toString(skill.getId()));
  100. if (buff != null)
  101. {
  102. takeItems(player, GOLDEN_RAM_COIN, buff.getCost());
  103. }
  104. return super.onSpellFinished(npc, player, skill);
  105. }
  106. public static void main(String[] args)
  107. {
  108. new Selina();
  109. }
  110. private static class BuffHolder extends SkillHolder
  111. {
  112. private final int _cost;
  113. public BuffHolder(int skillId, int skillLvl, int cost)
  114. {
  115. super(skillId, skillLvl);
  116. _cost = cost;
  117. }
  118. public int getCost()
  119. {
  120. return _cost;
  121. }
  122. }
  123. }