Autowalker now knows how to craft its first weapon and open the map.
This commit is contained in:
parent
70d27b9a95
commit
82ce3cb6be
3 changed files with 45 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "autowalker.hpp"
|
||||
#include "inventory.hpp"
|
||||
#include "ai_debug.hpp"
|
||||
#include "ritual_ui.hpp"
|
||||
|
||||
template<typename Comp>
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue