Autowalker now paths reliably and can attack enemies by facing them. Just need to make it fight diagonally.
This commit is contained in:
parent
4365aa4bfc
commit
f98cc543f6
1 changed files with 4 additions and 19 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "ai_debug.hpp"
|
||||
#include "gui/ritual_ui.hpp"
|
||||
#include "game_level.hpp"
|
||||
#include "systems.hpp"
|
||||
#define DEBUG
|
||||
|
||||
struct InventoryStats {
|
||||
|
@ -29,28 +30,11 @@ int number_left() {
|
|||
template<typename Comp>
|
||||
Pathing compute_paths() {
|
||||
auto& level = GameDB::current_level();
|
||||
auto& walls_original = level.map->$walls;
|
||||
auto walls_copy = walls_original;
|
||||
auto walls_copy = level.map->$walls;
|
||||
|
||||
Pathing paths{matrix::width(walls_copy), matrix::height(walls_copy)};
|
||||
|
||||
// first, put everything of this type as a target
|
||||
level.world->query<components::Position, Comp>(
|
||||
[&](const auto ent, auto& position, auto&) {
|
||||
if(ent != level.player) {
|
||||
paths.set_target(position.location);
|
||||
}
|
||||
});
|
||||
|
||||
level.world->query<components::Collision>(
|
||||
[&](const auto ent, auto& collision) {
|
||||
if(collision.has) {
|
||||
auto& pos = level.world->get<components::Position>(ent);
|
||||
walls_copy[pos.location.y][pos.location.x] = WALL_VALUE;
|
||||
}
|
||||
});
|
||||
|
||||
paths.compute_paths(walls_copy);
|
||||
System::multi_path<Comp>(level, paths, walls_copy);
|
||||
|
||||
auto pos = GameDB::player_position().location;
|
||||
matrix::dump("compute_paths walls", walls_copy, pos.x, pos.y);
|
||||
|
@ -133,6 +117,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 found = paths.find_path(target_out, PATHING_TOWARD, false);
|
||||
|
||||
if(found == PathingResult::FAIL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue