RideWyvern.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 = { 12526, 12527, 12528, 16038, 16039, 16040, 16068, 13197 };
  31. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  32. {
  33. if (!(target instanceof L2WyvernManagerInstance))
  34. return false;
  35. L2WyvernManagerInstance npc = (L2WyvernManagerInstance)target;
  36. if (!npc.isOwnerClan(activeChar))
  37. return false;
  38. if(!Config.ALLOW_WYVERN_DURING_SIEGE && (npc.isInSiege() || activeChar.isInSiege()))
  39. {
  40. activeChar.sendMessage("You cannot ride wyvern during siege.");
  41. return false;
  42. }
  43. if ((SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) == SevenSigns.CABAL_DUSK) && SevenSigns.getInstance().isSealValidationPeriod())
  44. {
  45. activeChar.sendMessage("You cannot ride wyvern while Seal of Strife controlled by Dusk.");
  46. return false;
  47. }
  48. if(activeChar.getPet() == null)
  49. {
  50. if(activeChar.isMounted())
  51. activeChar.sendMessage("You already have a pet.");
  52. else
  53. activeChar.sendMessage("Summon your Strider first.");
  54. }
  55. else if (Util.contains(STRIDERS, activeChar.getPet().getNpcId()))
  56. {
  57. if (activeChar.getInventory().getItemByItemId(1460) != null && activeChar.getInventory().getItemByItemId(1460).getCount() >= 25)
  58. {
  59. if (activeChar.getPet().getLevel() < 55)
  60. {
  61. activeChar.sendMessage("Your Strider Has not reached the required level.");
  62. }
  63. else
  64. {
  65. activeChar.getPet().unSummon(activeChar);
  66. if (activeChar.mount(12621, 0, true))
  67. {
  68. activeChar.getInventory().destroyItemByItemId("Wyvern", 1460, 25, activeChar, npc);
  69. activeChar.addSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill());
  70. activeChar.sendMessage("The Wyvern has been summoned successfully!");
  71. }
  72. return true;
  73. }
  74. }
  75. else
  76. {
  77. activeChar.sendMessage("You need 25 Crystals: B Grade.");
  78. }
  79. }
  80. else
  81. {
  82. activeChar.sendMessage("Unsummon your pet.");
  83. }
  84. return false;
  85. }
  86. public String[] getBypassList()
  87. {
  88. return COMMANDS;
  89. }
  90. }