diff --git a/autowalker.cpp b/autowalker.cpp index bc80764..5ef81b8 100644 --- a/autowalker.cpp +++ b/autowalker.cpp @@ -1,6 +1,7 @@ #include "autowalker.hpp" #include "inventory.hpp" #include "ai_debug.hpp" +#include "ritual_ui.hpp" template int number_left(gui::FSM& fsm) { @@ -257,6 +258,42 @@ void Autowalker::handle_player_walk(ai::State& start, ai::State& goal) { } } +void Autowalker::craft_weapon() { + if(!weapon_crafted) { + auto& ritual_ui = fsm.$status_ui.$ritual_ui; + fsm.$status_ui.$gui.click_on("ritual_ui"); + + while(!ritual_ui.in_state(gui::ritual::State::OPENED)) { + send_event(gui::Event::TICK); + } + + ritual_ui.$gui.click_on("inv_slot0"); + send_event(gui::Event::TICK); + ritual_ui.$gui.click_on("inv_slot1"); + send_event(gui::Event::TICK); + + while(!ritual_ui.in_state(gui::ritual::State::CRAFTING)) { + send_event(gui::Event::TICK); + } + + ritual_ui.$gui.click_on("result_image", true); + send_event(gui::Event::TICK); + + ritual_ui.$gui.click_on("ritual_ui"); + send_event(gui::Event::TICK); + weapon_crafted = true; + } +} + +void Autowalker::open_map() { + if(map_opened_once) return; + + if(!fsm.$map_open) { + send_event(gui::Event::MAP_OPEN); + map_opened_once = true; + } +} + void Autowalker::autowalk() { handle_window_events(); @@ -265,17 +302,15 @@ void Autowalker::autowalk() { return; } + craft_weapon(); + open_map(); + int move_attempts = 0; auto start = ai::load_state("Host::initial_state"); auto goal = ai::load_state("Host::final_state"); do { - if(!fsm.$map_open && !map_opened_once) { - send_event(gui::Event::MAP_OPEN); - map_opened_once = true; - } - handle_window_events(); handle_boss_fight(); handle_player_walk(start, goal); diff --git a/autowalker.hpp b/autowalker.hpp index 118ab61..88dea04 100644 --- a/autowalker.hpp +++ b/autowalker.hpp @@ -10,6 +10,7 @@ struct Autowalker { int item_count = 0; int device_count = 0; bool map_opened_once = false; + bool weapon_crafted = false; gui::FSM& fsm; Autowalker(gui::FSM& fsm) @@ -17,6 +18,8 @@ struct Autowalker { void autowalk(); void start_autowalk(); + void craft_weapon(); + void open_map(); void handle_window_events(); void handle_boss_fight(); diff --git a/ritual_ui.cpp b/ritual_ui.cpp index a98442c..c0166ed 100644 --- a/ritual_ui.cpp +++ b/ritual_ui.cpp @@ -23,10 +23,10 @@ namespace gui { "[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]" "[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]" "[inv_slot16 | inv_slot17 | inv_slot18| inv_slot19]" - "[reset |*%(200,400)result_text|_]" + "[_ |*%(200,400)result_text|_]" "[*%(100,200)result_image|_ |_]" "[_|_|_]" - "[combine|_|_]" + "[_|_|_]" "[_]" "[ ritual_ui ]"); }