From 11ea08bc7f8ebdaef33b6ccbed2ec17699aebb7e Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 27 Feb 2025 11:02:02 -0500 Subject: [PATCH] Have a little debug minimap in the top right when autowalking with debug on. --- autowalker.cpp | 29 ++++++++++++++++++++++++++++- autowalker.hpp | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/autowalker.cpp b/autowalker.cpp index 7f843ac..6d08c8b 100644 --- a/autowalker.cpp +++ b/autowalker.cpp @@ -130,6 +130,32 @@ void Autowalker::rotate_player(Point current, Point target) { "player isn't facing the correct direction"); } +void Autowalker::show_map_overlay(matrix::Matrix& map, Point current) { + auto debug = fsm.$level.world->get_the(); + if(!debug.FPS) { + fsm.$main_ui.$overlay_ui.close_text("top_right"); + return; + } + + std::string map_overlay; + for(matrix::box it{map, current.x, current.y, 6}; it.next();) { + if(it.x == it.left) map_overlay += "\n"; + int cell = map[it.y][it.x]; + + if(it.x == current.x && it.y == current.y) { + map_overlay += fmt::format("{:x}<", cell); + } else if(cell == WALL_PATH_LIMIT) { + map_overlay += fmt::format("# "); + } else if(cell > 15) { + map_overlay += fmt::format("* "); + } else { + map_overlay += fmt::format("{:x} ", cell); + } + } + + fsm.$main_ui.$overlay_ui.show_text("top_right", map_overlay); +} + void Autowalker::autowalk() { window_events(); if(!fsm.autowalking) return; @@ -159,7 +185,8 @@ void Autowalker::autowalk() { Point current = get_current_position(); Point target = current; - matrix::dump("AUTO PATHS", paths.$paths, current.x, current.y); + show_map_overlay(paths.$paths, current); + if(!path_player(paths, target)) { dbc::log("no paths found, aborting autowalk"); diff --git a/autowalker.hpp b/autowalker.hpp index b136a3d..7e9b519 100644 --- a/autowalker.hpp +++ b/autowalker.hpp @@ -24,4 +24,5 @@ struct Autowalker { Pathing path_to_enemies(); Pathing path_to_items(); Pathing path_to_devices(); + void show_map_overlay(matrix::Matrix& map, Point current); };