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