2
0

Ride.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 32: //Jet Bike
  58. case 13130: // Light Purple Maned Horse
  59. case 13146: // Tawny-Maned Lion
  60. case 13147: // Steam Sledge
  61. _rideType = 4;
  62. break;
  63. default:
  64. throw new IllegalArgumentException("Unsupported mount NpcId: " + rideClassId);
  65. }
  66. }
  67. @Override
  68. public void runImpl()
  69. {
  70. }
  71. public int getMountType()
  72. {
  73. return _rideType;
  74. }
  75. @Override
  76. protected final void writeImpl()
  77. {
  78. writeC(0x8c);
  79. writeD(_id);
  80. writeD(_bRide);
  81. writeD(_rideType);
  82. writeD(_rideClassID);
  83. writeD(_x);
  84. writeD(_y);
  85. writeD(_z);
  86. }
  87. /* (non-Javadoc)
  88. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  89. */
  90. @Override
  91. public String getType()
  92. {
  93. return _S__8c_Ride;
  94. }
  95. }