Fix various navbot issues
This commit is contained in:
parent
d48e221054
commit
d281627191
@ -10,7 +10,7 @@ extern bool init;
|
|||||||
extern bool ReadyForCommands;
|
extern bool ReadyForCommands;
|
||||||
extern std::vector<CNavArea> areas;
|
extern std::vector<CNavArea> areas;
|
||||||
std::vector<Vector> findPath(Vector loc, Vector dest);
|
std::vector<Vector> findPath(Vector loc, Vector dest);
|
||||||
bool NavTo(Vector dest);
|
bool NavTo(Vector dest, bool navToLocalCenter = true);
|
||||||
bool Prepare();
|
bool Prepare();
|
||||||
void CreateMove();
|
void CreateMove();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ std::vector<CNavArea> areas;
|
|||||||
bool init = false;
|
bool init = false;
|
||||||
bool pathfinding = true;
|
bool pathfinding = true;
|
||||||
bool ReadyForCommands = false;
|
bool ReadyForCommands = false;
|
||||||
std::vector<int> ignores;
|
std::vector<std::pair<int, int>> ignores;
|
||||||
|
|
||||||
static settings::Bool enabled{ "misc.pathing", "true" };
|
static settings::Bool enabled{ "misc.pathing", "true" };
|
||||||
|
|
||||||
@ -25,11 +25,12 @@ int FindInVector(int id)
|
|||||||
struct MAP : public micropather::Graph
|
struct MAP : public micropather::Graph
|
||||||
{
|
{
|
||||||
std::unique_ptr<micropather::MicroPather> pather;
|
std::unique_ptr<micropather::MicroPather> pather;
|
||||||
bool IsIgnored(int connectionID)
|
bool IsIgnored(int currState, int connectionID)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ignores.size(); i++)
|
for (int i = 0; i < ignores.size(); i++)
|
||||||
{
|
{
|
||||||
if (ignores.at(i) == connectionID)
|
if (ignores.at(i).first == currState &&
|
||||||
|
ignores.at(i).second == connectionID)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -98,7 +99,7 @@ struct MAP : public micropather::Graph
|
|||||||
{
|
{
|
||||||
if (GetZBetweenAreas(area, i.area) > 42)
|
if (GetZBetweenAreas(area, i.area) > 42)
|
||||||
continue;
|
continue;
|
||||||
if (IsIgnored(i.id))
|
if (IsIgnored(area->m_id, i.area->m_id))
|
||||||
continue;
|
continue;
|
||||||
micropather::StateCost cost;
|
micropather::StateCost cost;
|
||||||
cost.state =
|
cost.state =
|
||||||
@ -226,7 +227,7 @@ static Timer inactivity{};
|
|||||||
Timer lastJump{};
|
Timer lastJump{};
|
||||||
static std::vector<Vector> crumbs;
|
static std::vector<Vector> crumbs;
|
||||||
|
|
||||||
bool NavTo(Vector dest)
|
bool NavTo(Vector dest, bool navToLocalCenter)
|
||||||
{
|
{
|
||||||
if (CE_BAD(LOCAL_E))
|
if (CE_BAD(LOCAL_E))
|
||||||
return false;
|
return false;
|
||||||
@ -237,6 +238,8 @@ bool NavTo(Vector dest)
|
|||||||
return false;
|
return false;
|
||||||
crumbs.clear();
|
crumbs.clear();
|
||||||
crumbs = std::move(path);
|
crumbs = std::move(path);
|
||||||
|
if (!navToLocalCenter)
|
||||||
|
crumbs.erase(crumbs.begin());
|
||||||
inactivity.update();
|
inactivity.update();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -263,10 +266,9 @@ void ignoreConnection()
|
|||||||
|
|
||||||
for (auto i : currnode.m_connections)
|
for (auto i : currnode.m_connections)
|
||||||
{
|
{
|
||||||
logging::Info(format("1 ", i.area->m_id, " ", nextnode.m_id).c_str());
|
|
||||||
if (i.area->m_id == nextnode.m_id)
|
if (i.area->m_id == nextnode.m_id)
|
||||||
{
|
{
|
||||||
ignores.push_back(i.id);
|
ignores.push_back({currnode.m_id, i.area->m_id});
|
||||||
TF2MAP->pather->Reset();
|
TF2MAP->pather->Reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -279,6 +281,7 @@ void clearIgnores()
|
|||||||
if (ignoreReset.test_and_set(120000))
|
if (ignoreReset.test_and_set(120000))
|
||||||
{
|
{
|
||||||
ignores.clear();
|
ignores.clear();
|
||||||
|
if (TF2MAP && TF2MAP->pather)
|
||||||
TF2MAP->pather->Reset();
|
TF2MAP->pather->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,7 +311,8 @@ void CreateMove()
|
|||||||
current_user_cmd->buttons |= IN_JUMP;
|
current_user_cmd->buttons |= IN_JUMP;
|
||||||
if (inactivity.test_and_set(5000))
|
if (inactivity.test_and_set(5000))
|
||||||
{
|
{
|
||||||
logging::Info("NavBot inactive for too long. Canceling tasks and ignoring connection...");
|
logging::Info("Pathing: NavBot inactive for too long. Canceling tasks and "
|
||||||
|
"ignoring connection...");
|
||||||
ignoreConnection();
|
ignoreConnection();
|
||||||
crumbs.clear();
|
crumbs.clear();
|
||||||
return;
|
return;
|
||||||
@ -323,6 +327,8 @@ Vector loc;
|
|||||||
|
|
||||||
CatCommand navset("nav_set", "Debug nav set",
|
CatCommand navset("nav_set", "Debug nav set",
|
||||||
[](const CCommand &args) { loc = LOCAL_E->m_vecOrigin(); });
|
[](const CCommand &args) { loc = LOCAL_E->m_vecOrigin(); });
|
||||||
|
CatCommand navprint("nav_print", "Debug nav print",
|
||||||
|
[](const CCommand &args) { logging::Info(format(findClosestNavSquare(g_pLocalPlayer->v_Origin)).c_str()); });
|
||||||
|
|
||||||
CatCommand navfind("nav_find", "Debug nav find", [](const CCommand &args) {
|
CatCommand navfind("nav_find", "Debug nav find", [](const CCommand &args) {
|
||||||
std::vector<Vector> path = findPath(g_pLocalPlayer->v_Origin, loc);
|
std::vector<Vector> path = findPath(g_pLocalPlayer->v_Origin, loc);
|
||||||
|
Reference in New Issue
Block a user