Autowalker is now using the GOAP AI system and works way better. Still quite a lot of jank in the code but that'll get removed over time. Next thing is being able to detect when its near an item/enemy and properly react.
This commit is contained in:
parent
ff81c78d13
commit
d15c9b12fd
9 changed files with 84 additions and 47 deletions
14
pathing.cpp
14
pathing.cpp
|
@ -74,15 +74,21 @@ void Pathing::clear_target(const Point &at) {
|
|||
$input[at.y][at.x] = 1;
|
||||
}
|
||||
|
||||
bool Pathing::random_walk(Point &out, bool random, int direction) {
|
||||
bool Pathing::random_walk(Point &out, bool random, int direction, size_t dir_count) {
|
||||
bool zero_found = false;
|
||||
dbc::check(dir_count == 4 || dir_count == 8, "Only 8 or 4 directions allowed.");
|
||||
|
||||
// just make a list of the four directions
|
||||
std::array<Point, 4> dirs{{
|
||||
std::array<Point, 8> dirs{{
|
||||
{out.x,out.y-1}, // north
|
||||
{out.x+1,out.y}, // east
|
||||
{out.x,out.y+1}, // south
|
||||
{out.x-1,out.y} // west
|
||||
{out.x-1,out.y}, // west
|
||||
|
||||
{out.x+1,out.y-1}, // north east
|
||||
{out.x+1,out.y+1}, // south east
|
||||
{out.x-1,out.y+1}, // south west
|
||||
{out.x-1,out.y-1} // north west
|
||||
}};
|
||||
|
||||
// get the current dijkstra number
|
||||
|
@ -93,7 +99,7 @@ bool Pathing::random_walk(Point &out, bool random, int direction) {
|
|||
int rand_start = Random::uniform<int>(0, dirs.size());
|
||||
|
||||
// go through all possible directions
|
||||
for(size_t i = 0; i < dirs.size(); i++) {
|
||||
for(size_t i = 0; i < dir_count; i++) {
|
||||
// but start at the random start, effectively randomizing
|
||||
// which valid direction to go
|
||||
// BUG: this might be wrong given the above ranom from 0-size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue