From 1853e8aa564dadc07b4518b7366830e26f07b3b4 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 10 Mar 2026 13:18:04 -0700 Subject: [PATCH] physics: implement Water Walk movement state tracking and surface clamping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SMSG_MOVE_WATER_WALK / SMSG_MOVE_LAND_WALK now correctly set/clear WATER_WALK (0x00008000) in movementInfo.flags, ensuring the flag is included in movement ACKs sent to the server. In CameraController, when waterWalkActive_ is set and the player is at or above the water surface (within 0.5 units), clamp them to the water surface and mark as grounded — preventing water entry and allowing them to walk across the water surface as the spell intends. --- include/game/game_handler.hpp | 3 +++ include/game/world_packets.hpp | 1 + include/rendering/camera_controller.hpp | 3 +++ src/core/application.cpp | 1 + src/game/game_handler.cpp | 6 ++++-- src/rendering/camera_controller.cpp | 9 ++++++++- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index dcf8538e..fb1b0393 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -1163,6 +1163,9 @@ public: bool isFeatherFalling() const { return (movementInfo.flags & static_cast(MovementFlags::FEATHER_FALL)) != 0; } + bool isWaterWalking() const { + return (movementInfo.flags & static_cast(MovementFlags::WATER_WALK)) != 0; + } void dismount(); // Taxi / Flight Paths diff --git a/include/game/world_packets.hpp b/include/game/world_packets.hpp index 07a22d23..870e00b7 100644 --- a/include/game/world_packets.hpp +++ b/include/game/world_packets.hpp @@ -396,6 +396,7 @@ enum class MovementFlags : uint32_t { FALLING = 0x00001000, FALLINGFAR = 0x00002000, FEATHER_FALL = 0x00004000, // Slow fall / Parachute + WATER_WALK = 0x00008000, // Walk on water surface SWIMMING = 0x00200000, ASCENDING = 0x00400000, CAN_FLY = 0x00800000, diff --git a/include/rendering/camera_controller.hpp b/include/rendering/camera_controller.hpp index b82630f4..58fde4a1 100644 --- a/include/rendering/camera_controller.hpp +++ b/include/rendering/camera_controller.hpp @@ -98,6 +98,7 @@ public: bool isMovementRooted() const { return movementRooted_; } void setGravityDisabled(bool disabled) { gravityDisabled_ = disabled; } void setFeatherFallActive(bool active) { featherFallActive_ = active; } + void setWaterWalkActive(bool active) { waterWalkActive_ = active; } void setMounted(bool m) { mounted_ = m; } void setMountHeightOffset(float offset) { mountHeightOffset_ = offset; } void setExternalFollow(bool enabled) { externalFollow_ = enabled; } @@ -282,6 +283,8 @@ private: bool gravityDisabled_ = false; // Server-driven feather fall: cap downward velocity to slow-fall terminal. bool featherFallActive_ = false; + // Server-driven water walk: treat water surface as ground (don't swim). + bool waterWalkActive_ = false; bool mounted_ = false; float mountHeightOffset_ = 0.0f; bool externalMoving_ = false; diff --git a/src/core/application.cpp b/src/core/application.cpp index d494ada2..4134ee89 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -1014,6 +1014,7 @@ void Application::update(float deltaTime) { renderer->getCameraController()->setMovementRooted(gameHandler->isPlayerRooted()); renderer->getCameraController()->setGravityDisabled(gameHandler->isGravityDisabled()); renderer->getCameraController()->setFeatherFallActive(gameHandler->isFeatherFalling()); + renderer->getCameraController()->setWaterWalkActive(gameHandler->isWaterWalking()); } bool onTaxi = gameHandler && diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 44ab4bb7..df05652b 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -2459,7 +2459,8 @@ void GameHandler::handlePacket(network::Packet& packet) { static_cast(MovementFlags::FEATHER_FALL), true); break; case Opcode::SMSG_MOVE_WATER_WALK: - handleForceMoveFlagChange(packet, "WATER_WALK", Opcode::CMSG_MOVE_WATER_WALK_ACK, 0, true); + handleForceMoveFlagChange(packet, "WATER_WALK", Opcode::CMSG_MOVE_WATER_WALK_ACK, + static_cast(MovementFlags::WATER_WALK), true); break; case Opcode::SMSG_MOVE_SET_HOVER: handleForceMoveFlagChange(packet, "SET_HOVER", Opcode::CMSG_MOVE_HOVER_ACK, @@ -5588,7 +5589,8 @@ void GameHandler::handlePacket(network::Packet& packet) { static_cast(MovementFlags::LEVITATING), false); break; case Opcode::SMSG_MOVE_LAND_WALK: - handleForceMoveFlagChange(packet, "LAND_WALK", Opcode::CMSG_MOVE_WATER_WALK_ACK, 0, false); + handleForceMoveFlagChange(packet, "LAND_WALK", Opcode::CMSG_MOVE_WATER_WALK_ACK, + static_cast(MovementFlags::WATER_WALK), false); break; case Opcode::SMSG_MOVE_NORMAL_FALL: handleForceMoveFlagChange(packet, "NORMAL_FALL", Opcode::CMSG_MOVE_FEATHER_FALL_ACK, diff --git a/src/rendering/camera_controller.cpp b/src/rendering/camera_controller.cpp index 22887e83..1617b0d0 100644 --- a/src/rendering/camera_controller.cpp +++ b/src/rendering/camera_controller.cpp @@ -410,7 +410,14 @@ void CameraController::update(float deltaTime) { constexpr float MAX_SWIM_DEPTH_FROM_SURFACE = 12.0f; constexpr float MIN_SWIM_WATER_DEPTH = 1.0f; bool inWater = false; - if (waterH && targetPos.z < *waterH) { + // Water Walk: treat water surface as ground — player walks on top, not through. + if (waterWalkActive_ && waterH && targetPos.z >= *waterH - 0.5f) { + // Clamp to water surface so the player stands on it + targetPos.z = *waterH; + verticalVelocity = 0.0f; + grounded = true; + inWater = false; + } else if (waterH && targetPos.z < *waterH) { std::optional waterType; if (waterRenderer) { waterType = waterRenderer->getWaterTypeAt(targetPos.x, targetPos.y);