Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. public void updateThisPlayerMovement(stream str) {
  2. if (mapRegionDidChange) {
  3. str.createFrame(73);
  4. str.writeWordA(mapRegionX + 6); // for some reason the client substracts 6
  5. // from those values
  6. str.writeWord(mapRegionY + 6);
  7. }
  8.  
  9. if (didTeleport == true) {
  10. str.createFrameVarSizeWord(81);
  11. str.initBitAccess();
  12. str.writeBits(1, 1);
  13. str.writeBits(2, 3);
  14. // updateType
  15. str.writeBits(2, heightLevel);
  16. str.writeBits(1, 1);
  17. // set to true, if discarding (clientside) walking queue
  18. str.writeBits(1, (updateRequired) ? 1 : 0);
  19. str.writeBits(7, currentY);
  20. str.writeBits(7, currentX);
  21. return;
  22. }
  23.  
  24. if (dir1 == -1) {
  25. isMoving = false;
  26. // don't have to update the character position, because we're just
  27. // standing
  28. str.createFrameVarSizeWord(81);
  29. str.initBitAccess();
  30. if (updateRequired) {
  31. // tell client there's an update block appended at the end
  32. str.writeBits(1, 1);
  33. str.writeBits(2, 0);
  34. } else {
  35. str.writeBits(1, 0);
  36. }
  37. if (DirectionCount < 50) {
  38. DirectionCount++;
  39. }
  40. } else {
  41.  
  42. DirectionCount = 0;
  43. str.createFrameVarSizeWord(81);
  44. str.initBitAccess();
  45. str.writeBits(1, 1);
  46.  
  47. if (dir2 == -1) {
  48. isMoving = true;
  49. // send "walking packet"
  50. str.writeBits(2, 1);
  51. // updateType
  52. str.writeBits(3, misc.xlateDirectionToClient[dir1]);
  53. if (updateRequired)
  54. str.writeBits(1, 1);
  55. // tell client there's an update block appended at the end
  56. else
  57. str.writeBits(1, 0);
  58. } else {
  59. isMoving = true;
  60. // send "running packet"
  61. str.writeBits(2, 2);
  62. // updateType
  63. str.writeBits(3, misc.xlateDirectionToClient[dir1]);
  64. str.writeBits(3, misc.xlateDirectionToClient[dir2]);
  65. if (updateRequired)
  66. str.writeBits(1, 1);
  67. // tell client there's an update block appended at the end
  68. else
  69. str.writeBits(1, 0);
  70. /*
  71. * This is what drains the running energy. I've commented it out so it won't be used now.
  72. * Should you ever change your mind, simply uncomment it ;)
  73. if (playerEnergy > 0) {
  74. playerEnergy -= 1;
  75. } else {
  76. isRunning2 = false;
  77. }
  78. */
  79. }
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement