Ride.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.serverpackets;
  16. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  17. public final class Ride extends L2GameServerPacket
  18. {
  19. private static final String _S__8c_Ride = "[S] 8c Ride";
  20. public static final int ACTION_MOUNT = 1;
  21. public static final int ACTION_DISMOUNT = 0;
  22. private final int _id;
  23. private final int _bRide;
  24. private final int _rideType;
  25. private final int _rideClassID;
  26. private final int _x, _y, _z;
  27. public Ride(L2PcInstance cha, boolean mount, int rideClassId)
  28. {
  29. _id = cha.getObjectId();
  30. _bRide = mount ? 1 : 0;
  31. _rideClassID = rideClassId + 1000000; // npcID
  32. _x = cha.getX();
  33. _y = cha.getY();
  34. _z = cha.getZ();
  35. switch(rideClassId)
  36. {
  37. case 0: // dismount
  38. _rideType = 0;
  39. break;
  40. case 12526: // Wind
  41. case 12527: // Star
  42. case 12528: // Twilight
  43. _rideType = 1;
  44. break;
  45. case 12621: // Wyvern
  46. _rideType = 2;
  47. break;
  48. case 16037: // Great Snow Wolf
  49. case 16041: // Fenrir Wolf
  50. case 16042: // White Fenrir Wolf
  51. _rideType = 3;
  52. break;
  53. default:
  54. throw new IllegalArgumentException("Unsupported mount NpcId: "+rideClassId);
  55. }
  56. }
  57. @Override
  58. public void runImpl()
  59. {
  60. }
  61. public int getMountType()
  62. {
  63. return _rideType;
  64. }
  65. @Override
  66. protected final void writeImpl()
  67. {
  68. writeC(0x8c);
  69. writeD(_id);
  70. writeD(_bRide);
  71. writeD(_rideType);
  72. writeD(_rideClassID);
  73. writeD(_x);
  74. writeD(_y);
  75. writeD(_z);
  76. }
  77. /* (non-Javadoc)
  78. * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
  79. */
  80. @Override
  81. public String getType()
  82. {
  83. return _S__8c_Ride;
  84. }
  85. }