2
0

Ride.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.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. case 16038: // red strider of wind
  44. case 16039: // red strider of star
  45. case 16040: // red strider of dusk
  46. case 16068: // Guardian Strider
  47. _rideType = 1;
  48. break;
  49. case 12621: // Wyvern
  50. _rideType = 2;
  51. break;
  52. case 16037: // Great Snow Wolf
  53. case 16041: // Fenrir Wolf
  54. case 16042: // White Fenrir Wolf
  55. _rideType = 3;
  56. break;
  57. case 13130: // Light Purple Maned Horse
  58. case 13146: // Tawny-Maned Lion
  59. case 13147: // Steam Sledge
  60. _rideType = 4;
  61. break;
  62. default:
  63. throw new IllegalArgumentException("Unsupported mount NpcId: " + rideClassId);
  64. }
  65. }
  66. @Override
  67. public void runImpl()
  68. {
  69. }
  70. public int getMountType()
  71. {
  72. return _rideType;
  73. }
  74. @Override
  75. protected final void writeImpl()
  76. {
  77. writeC(0x8c);
  78. writeD(_id);
  79. writeD(_bRide);
  80. writeD(_rideType);
  81. writeD(_rideClassID);
  82. writeD(_x);
  83. writeD(_y);
  84. writeD(_z);
  85. }
  86. /* (non-Javadoc)
  87. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  88. */
  89. @Override
  90. public String getType()
  91. {
  92. return _S__8c_Ride;
  93. }
  94. }