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 "autowalker.hpp"
|
||||||
#include "inventory.hpp"
|
#include "inventory.hpp"
|
||||||
#include "ai_debug.hpp"
|
#include "ai_debug.hpp"
|
||||||
|
#include "ritual_ui.hpp"
|
||||||
|
|
||||||
template<typename Comp>
|
template<typename Comp>
|
||||||
int number_left(gui::FSM& fsm) {
|
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() {
|
void Autowalker::autowalk() {
|
||||||
handle_window_events();
|
handle_window_events();
|
||||||
|
@ -265,17 +302,15 @@ void Autowalker::autowalk() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
craft_weapon();
|
||||||
|
open_map();
|
||||||
|
|
||||||
int move_attempts = 0;
|
int move_attempts = 0;
|
||||||
|
|
||||||
auto start = ai::load_state("Host::initial_state");
|
auto start = ai::load_state("Host::initial_state");
|
||||||
auto goal = ai::load_state("Host::final_state");
|
auto goal = ai::load_state("Host::final_state");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if(!fsm.$map_open && !map_opened_once) {
|
|
||||||
send_event(gui::Event::MAP_OPEN);
|
|
||||||
map_opened_once = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_window_events();
|
handle_window_events();
|
||||||
handle_boss_fight();
|
handle_boss_fight();
|
||||||
handle_player_walk(start, goal);
|
handle_player_walk(start, goal);
|
||||||
|
|
|
@ -10,6 +10,7 @@ struct Autowalker {
|
||||||
int item_count = 0;
|
int item_count = 0;
|
||||||
int device_count = 0;
|
int device_count = 0;
|
||||||
bool map_opened_once = false;
|
bool map_opened_once = false;
|
||||||
|
bool weapon_crafted = false;
|
||||||
gui::FSM& fsm;
|
gui::FSM& fsm;
|
||||||
|
|
||||||
Autowalker(gui::FSM& fsm)
|
Autowalker(gui::FSM& fsm)
|
||||||
|
@ -17,6 +18,8 @@ struct Autowalker {
|
||||||
|
|
||||||
void autowalk();
|
void autowalk();
|
||||||
void start_autowalk();
|
void start_autowalk();
|
||||||
|
void craft_weapon();
|
||||||
|
void open_map();
|
||||||
|
|
||||||
void handle_window_events();
|
void handle_window_events();
|
||||||
void handle_boss_fight();
|
void handle_boss_fight();
|
||||||
|
|
|
@ -23,10 +23,10 @@ namespace gui {
|
||||||
"[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]"
|
"[inv_slot8 | inv_slot9 | inv_slot10| inv_slot11]"
|
||||||
"[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]"
|
"[inv_slot12 | inv_slot13 | inv_slot14| inv_slot15]"
|
||||||
"[inv_slot16 | inv_slot17 | inv_slot18| inv_slot19]"
|
"[inv_slot16 | inv_slot17 | inv_slot18| inv_slot19]"
|
||||||
"[reset |*%(200,400)result_text|_]"
|
"[_ |*%(200,400)result_text|_]"
|
||||||
"[*%(100,200)result_image|_ |_]"
|
"[*%(100,200)result_image|_ |_]"
|
||||||
"[_|_|_]"
|
"[_|_|_]"
|
||||||
"[combine|_|_]"
|
"[_|_|_]"
|
||||||
"[_]"
|
"[_]"
|
||||||
"[ ritual_ui ]");
|
"[ ritual_ui ]");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue