Bring over various autowalker improvements.
This commit is contained in:
parent
9c5bad5959
commit
40b2d7f45d
2 changed files with 22 additions and 7 deletions
|
@ -112,7 +112,7 @@ void Autowalker::path_fail(const std::string& msg, Matrix& bad_paths, Point pos)
|
|||
}
|
||||
|
||||
bool Autowalker::path_player(Pathing& paths, Point& target_out) {
|
||||
auto &level = GameDB::current_level();
|
||||
auto& level = GameDB::current_level();
|
||||
auto found = paths.find_path(target_out, PATHING_TOWARD, false);
|
||||
|
||||
if(found == PathingResult::FAIL) {
|
||||
|
@ -132,20 +132,32 @@ bool Autowalker::path_player(Pathing& paths, Point& target_out) {
|
|||
}
|
||||
|
||||
void Autowalker::rotate_player(Point target) {
|
||||
auto player = GameDB::player_position();
|
||||
auto &player = GameDB::player_position();
|
||||
|
||||
if(target == player.location) {
|
||||
dbc::log("!!!!!!!!!!!! maybe this is wrong");
|
||||
dbc::log("player stuck at a locatoin");
|
||||
fsm.autowalking = false;
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir = System::shortest_rotate(player.location, player.aiming_at, target);
|
||||
|
||||
while(rayview->aiming_at != target) {
|
||||
for(int i = 0; player.aiming_at != target; i++) {
|
||||
if(i > 10) {
|
||||
dbc::log("HIT OVER ROTATE BUG!");
|
||||
break;
|
||||
}
|
||||
|
||||
send_event(dir);
|
||||
while(fsm.in_state(gui::State::ROTATING)) send_event(gui::Event::TICK);
|
||||
|
||||
while(fsm.in_state(gui::State::ROTATING) ||
|
||||
fsm.in_state(gui::State::COMBAT_ROTATE))
|
||||
{
|
||||
send_event(gui::Event::TICK);
|
||||
}
|
||||
}
|
||||
|
||||
dbc::check(rayview->aiming_at == target, "failed to aim at target");
|
||||
fsm.autowalking = player.aiming_at == target;
|
||||
}
|
||||
|
||||
ai::State Autowalker::update_state(ai::State start) {
|
||||
|
@ -305,7 +317,7 @@ void Autowalker::process_move(Pathing& paths) {
|
|||
}
|
||||
|
||||
bool Autowalker::found_enemy() {
|
||||
auto level = GameDB::current_level();
|
||||
auto& level = GameDB::current_level();
|
||||
auto player = GameDB::player_position();
|
||||
|
||||
for(matrix::compass it{level.map->$walls, player.location.x, player.location.y}; it.next();) {
|
||||
|
|
|
@ -239,6 +239,9 @@ namespace gui {
|
|||
case MOUSE_MOVE: {
|
||||
mouse_action({1 << guecs::ModBit::hover});
|
||||
} break;
|
||||
case TICK:
|
||||
run_systems();
|
||||
break;
|
||||
case ATTACK:
|
||||
$main_ui.dirty();
|
||||
sound::play("Sword_Hit_1");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue