From 29ab9721afe759c02c423f8c679f29abbd645cfa Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Fri, 5 Sep 2025 23:48:59 -0400 Subject: [PATCH] Now they AI will heal when they can, but not yet go get itesm before/during combat. --- autowalker.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/autowalker.cpp b/autowalker.cpp index 8e0af59..1611e18 100644 --- a/autowalker.cpp +++ b/autowalker.cpp @@ -361,11 +361,35 @@ bool Autowalker::player_health_good() { InventoryStats Autowalker::player_item_count() { InventoryStats stats; - stats.healing = 0; + auto& level = GameDB::current_level(); + auto& inventory = level.world->get(level.player); + + if(inventory.has("pocket_r")) { + stats.other += 1; + stats.healing += 1; + } + + if(inventory.has("pocket_l")) { + stats.other += 1; + stats.healing += 1; + } + return stats; } void Autowalker::player_use_healing() { + auto& level = GameDB::current_level(); + auto& inventory = level.world->get(level.player); + + if(inventory.has("pocket_r")) { + auto gui_id = fsm.$status_ui.$gui.entity("pocket_r"); + send_event(gui::Event::USE_ITEM, gui_id); + } + + if(inventory.has("pocket_l")) { + auto gui_id = fsm.$status_ui.$gui.entity("pocket_l"); + send_event(gui::Event::USE_ITEM, gui_id); + } } void Autowalker::start_autowalk() { @@ -402,8 +426,7 @@ void Autowalker::pocket_potion(GameDB::Level &level) { auto& inventory = level.world->get(level.player); if(inventory.has("pocket_r") && inventory.has("pocket_l")) { - auto gui_id = fsm.$status_ui.$gui.entity("pocket_r"); - send_event(gui::Event::USE_ITEM, gui_id); + player_use_healing(); } send_event(gui::Event::AIM_CLICK);