From b2d1edc9dbacbf523affa0a01b467b7f5e8520de Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 22:41:26 -0700 Subject: [PATCH] Show corpse distance on reclaim corpse button When the player is a ghost, the 'Resurrect from Corpse' popup now shows how many yards away the corpse is, updating in real-time as the ghost moves. Distance is only shown when the corpse is on the same map. --- include/game/game_handler.hpp | 8 ++++++++ src/ui/game_screen.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 4173fbdb..b2901486 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -888,6 +888,14 @@ public: void cancelTalentWipe() { talentWipePending_ = false; } /** True when ghost is within 40 yards of corpse position (same map). */ bool canReclaimCorpse() const; + /** Distance (yards) from ghost to corpse, or -1 if no corpse data. */ + float getCorpseDistance() const { + if (corpseMapId_ == 0 || currentMapId_ != corpseMapId_) return -1.0f; + float dx = movementInfo.x - corpseX_; + float dy = movementInfo.y - corpseY_; + float dz = movementInfo.z - corpseZ_; + return std::sqrt(dx*dx + dy*dy + dz*dz); + } /** Send CMSG_RECLAIM_CORPSE; noop if not a ghost or not near corpse. */ void reclaimCorpse(); void releaseSpirit(); diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index c7d541c5..fdcda962 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -8942,6 +8942,14 @@ void GameScreen::renderReclaimCorpseButton(game::GameHandler& gameHandler) { gameHandler.reclaimCorpse(); } ImGui::PopStyleColor(2); + float corpDist = gameHandler.getCorpseDistance(); + if (corpDist >= 0.0f) { + char distBuf[48]; + snprintf(distBuf, sizeof(distBuf), "Corpse: %.0f yards away", corpDist); + float dw = ImGui::CalcTextSize(distBuf).x; + ImGui::SetCursorPosX((btnW + 16.0f - dw) * 0.5f); + ImGui::TextDisabled("%s", distBuf); + } } ImGui::End(); ImGui::PopStyleColor();