Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void updateThisPlayerMovement(stream str) {
- if (mapRegionDidChange) {
- str.createFrame(73);
- str.writeWordA(mapRegionX + 6); // for some reason the client substracts 6
- // from those values
- str.writeWord(mapRegionY + 6);
- }
- if (didTeleport == true) {
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- str.writeBits(2, 3);
- // updateType
- str.writeBits(2, heightLevel);
- str.writeBits(1, 1);
- // set to true, if discarding (clientside) walking queue
- str.writeBits(1, (updateRequired) ? 1 : 0);
- str.writeBits(7, currentY);
- str.writeBits(7, currentX);
- return;
- }
- if (dir1 == -1) {
- isMoving = false;
- // don't have to update the character position, because we're just
- // standing
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- if (updateRequired) {
- // tell client there's an update block appended at the end
- str.writeBits(1, 1);
- str.writeBits(2, 0);
- } else {
- str.writeBits(1, 0);
- }
- if (DirectionCount < 50) {
- DirectionCount++;
- }
- } else {
- DirectionCount = 0;
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- if (dir2 == -1) {
- isMoving = true;
- // send "walking packet"
- str.writeBits(2, 1);
- // updateType
- str.writeBits(3, misc.xlateDirectionToClient[dir1]);
- if (updateRequired)
- str.writeBits(1, 1);
- // tell client there's an update block appended at the end
- else
- str.writeBits(1, 0);
- } else {
- isMoving = true;
- // send "running packet"
- str.writeBits(2, 2);
- // updateType
- str.writeBits(3, misc.xlateDirectionToClient[dir1]);
- str.writeBits(3, misc.xlateDirectionToClient[dir2]);
- if (updateRequired)
- str.writeBits(1, 1);
- // tell client there's an update block appended at the end
- else
- str.writeBits(1, 0);
- /*
- * This is what drains the running energy. I've commented it out so it won't be used now.
- * Should you ever change your mind, simply uncomment it ;)
- if (playerEnergy > 0) {
- playerEnergy -= 1;
- } else {
- isRunning2 = false;
- }
- */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement