Mount.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 net.sf.l2j.gameserver.handler.usercommandhandlers;
  16. import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  17. import net.sf.l2j.gameserver.model.L2Character;
  18. import net.sf.l2j.gameserver.model.L2Summon;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  22. /**
  23. * Support for /mount command.
  24. * @author Tempy
  25. */
  26. public class Mount implements IUserCommandHandler
  27. {
  28. private static final int[] COMMAND_IDS =
  29. {
  30. 61
  31. };
  32. /**
  33. *
  34. * @see net.sf.l2j.gameserver.handler.IUserCommandHandler#useUserCommand(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance)
  35. */
  36. public synchronized boolean useUserCommand(int id, L2PcInstance activeChar)
  37. {
  38. if (id != COMMAND_IDS[0])
  39. return false;
  40. L2Summon pet = activeChar.getPet();
  41. if (pet != null && pet.isMountable() && pet.isMountableOverTime() && !activeChar.isMounted())
  42. {
  43. if (activeChar.isTransformed())
  44. {
  45. // You cannot mount a steed while transformed.
  46. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_TRANSFORMED);
  47. activeChar.sendPacket(msg);
  48. return false;
  49. }
  50. else if (activeChar.isParalyzed())
  51. {
  52. // You cannot mount a steed while petrified.
  53. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_PETRIFIED);
  54. activeChar.sendPacket(msg);
  55. return false;
  56. }
  57. else if (activeChar.isDead())
  58. {
  59. // You cannot mount a steed while dead.
  60. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_DEAD);
  61. activeChar.sendPacket(msg);
  62. return false;
  63. }
  64. else if (activeChar.isFishing())
  65. {
  66. // You cannot mount a steed while fishing.
  67. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_FISHING);
  68. activeChar.sendPacket(msg);
  69. return false;
  70. }
  71. else if (activeChar.isInDuel())
  72. {
  73. // You cannot mount a steed while in a duel.
  74. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_IN_A_DUEL);
  75. activeChar.sendPacket(msg);
  76. return false;
  77. }
  78. else if (activeChar.isSitting())
  79. {
  80. // You cannot mount a steed while sitting.
  81. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_SITTING);
  82. activeChar.sendPacket(msg);
  83. return false;
  84. }
  85. else if (activeChar.isCastingNow())
  86. {
  87. // You cannot mount a steed while skill casting.
  88. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_SKILL_CASTING);
  89. activeChar.sendPacket(msg);
  90. return false;
  91. }
  92. else if (activeChar.isCursedWeaponEquipped())
  93. {
  94. // You cannot mount a steed while a cursed weapon is equipped.
  95. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_A_CURSED_WEAPON_IS_EQUIPPED);
  96. activeChar.sendPacket(msg);
  97. return false;
  98. }
  99. /**
  100. * TODO: Add Siege Flag Restriction,
  101. else if (activeChar.isFlagEquipped())
  102. {
  103. // You cannot mount a steed while holding a flag.
  104. SystemMessage msg = new SystemMessage(SystemMessageId.YOU_CANNOT_MOUNT_A_STEED_WHILE_HOLDING_A_FLAG);
  105. activeChar.sendPacket(msg);
  106. }
  107. */
  108. else if (activeChar.isInCombat() || activeChar.getPvpFlag() != 0)
  109. {
  110. // A pet cannot be ridden while player is in battle.
  111. SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_IN_BATTLE);
  112. activeChar.sendPacket(msg);
  113. return false;
  114. }
  115. else if (activeChar.isRentedPet())
  116. {
  117. activeChar.stopRentPet();
  118. return false;
  119. }
  120. else if (activeChar.isMoving() || activeChar.isInsideZone(L2Character.ZONE_WATER))
  121. {
  122. // A strider can be ridden only when player is standing.
  123. SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CAN_BE_RIDDEN_ONLY_WHILE_STANDING);
  124. activeChar.sendPacket(msg);
  125. return false;
  126. }
  127. else if (pet.isInCombat())
  128. {
  129. // A strider in battle cannot be ridden.
  130. SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_IN_BATLLE_CANT_BE_RIDDEN);
  131. activeChar.sendPacket(msg);
  132. return false;
  133. }
  134. else if (pet.isDead())
  135. {
  136. // A dead strider cannot be ridden.
  137. SystemMessage msg = new SystemMessage(SystemMessageId.DEAD_STRIDER_CANT_BE_RIDDEN);
  138. activeChar.sendPacket(msg);
  139. return false;
  140. }
  141. else
  142. activeChar.mount(pet);
  143. }
  144. return true;
  145. }
  146. /**
  147. *
  148. * @see net.sf.l2j.gameserver.handler.IUserCommandHandler#getUserCommandList()
  149. */
  150. public int[] getUserCommandList()
  151. {
  152. return COMMAND_IDS;
  153. }
  154. }