RideWyvern.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 handlers.bypasshandlers;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.SevenSigns;
  18. import com.l2jserver.gameserver.datatables.SkillTable;
  19. import com.l2jserver.gameserver.handler.IBypassHandler;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2WyvernManagerInstance;
  23. import com.l2jserver.gameserver.util.Util;
  24. public class RideWyvern implements IBypassHandler
  25. {
  26. private static final String[] COMMANDS =
  27. {
  28. "RideWyvern"
  29. };
  30. private static final int[] STRIDERS =
  31. {
  32. 12526, 12527, 12528, 16038, 16039, 16040, 16068, 13197
  33. };
  34. @Override
  35. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  36. {
  37. if (!(target instanceof L2WyvernManagerInstance))
  38. {
  39. return false;
  40. }
  41. L2WyvernManagerInstance npc = (L2WyvernManagerInstance) target;
  42. if (!npc.isOwnerClan(activeChar))
  43. {
  44. return false;
  45. }
  46. if (!Config.ALLOW_WYVERN_DURING_SIEGE && (npc.isInSiege() || activeChar.isInSiege()))
  47. {
  48. activeChar.sendMessage("You cannot ride wyvern during siege.");
  49. return false;
  50. }
  51. if ((SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) == SevenSigns.CABAL_DUSK) && SevenSigns.getInstance().isSealValidationPeriod())
  52. {
  53. activeChar.sendMessage("You cannot ride wyvern while Seal of Strife controlled by Dusk.");
  54. return false;
  55. }
  56. if (activeChar.getPet() == null)
  57. {
  58. if (activeChar.isMounted())
  59. {
  60. activeChar.sendMessage("You already have a pet.");
  61. }
  62. else
  63. {
  64. activeChar.sendMessage("Summon your Strider first.");
  65. }
  66. }
  67. else if (Util.contains(STRIDERS, activeChar.getPet().getNpcId()))
  68. {
  69. if ((activeChar.getInventory().getItemByItemId(1460) != null) && (activeChar.getInventory().getItemByItemId(1460).getCount() >= 25))
  70. {
  71. if (activeChar.getPet().getLevel() < 55)
  72. {
  73. activeChar.sendMessage("Your Strider Has not reached the required level.");
  74. }
  75. else
  76. {
  77. activeChar.getPet().unSummon(activeChar);
  78. if (activeChar.mount(12621, 0, true))
  79. {
  80. activeChar.getInventory().destroyItemByItemId("Wyvern", 1460, 25, activeChar, npc);
  81. activeChar.addSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill());
  82. activeChar.sendMessage("The Wyvern has been summoned successfully!");
  83. }
  84. return true;
  85. }
  86. }
  87. else
  88. {
  89. activeChar.sendMessage("You need 25 Crystals: B Grade.");
  90. }
  91. }
  92. else
  93. {
  94. activeChar.sendMessage("Unsummon your pet.");
  95. }
  96. return false;
  97. }
  98. @Override
  99. public String[] getBypassList()
  100. {
  101. return COMMANDS;
  102. }
  103. }