Untested navbot changes + gui free mouse
This commit is contained in:
parent
ebd074235e
commit
618f6961a8
@ -46,7 +46,7 @@ class inactivityTracker
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, int> VectorToId(std::pair<Vector, Vector> &connection)
|
std::pair<int, int> VectorsToId(std::pair<Vector, Vector> &connection)
|
||||||
{
|
{
|
||||||
CNavArea *currnode = nullptr;
|
CNavArea *currnode = nullptr;
|
||||||
for (size_t i = 0; i < areas.size(); i++)
|
for (size_t i = 0; i < areas.size(); i++)
|
||||||
@ -81,6 +81,22 @@ class inactivityTracker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VectorToID(Vector vec)
|
||||||
|
{
|
||||||
|
CNavArea *currnode = nullptr;
|
||||||
|
for (size_t i = 0; i < areas.size(); i++)
|
||||||
|
{
|
||||||
|
if (areas.at(i).m_center == vec)
|
||||||
|
{
|
||||||
|
currnode = &areas.at(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!currnode)
|
||||||
|
return -1;
|
||||||
|
return currnode->m_id;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
@ -92,16 +108,15 @@ public:
|
|||||||
}
|
}
|
||||||
bool ShouldCancelPath(std::vector<Vector> crumbs)
|
bool ShouldCancelPath(std::vector<Vector> crumbs)
|
||||||
{
|
{
|
||||||
for (auto sentry : sentries)
|
for (auto crumb : crumbs)
|
||||||
for (auto crumb : crumbs)
|
{
|
||||||
{
|
int id = VectorToID(crumb);
|
||||||
if (crumb.DistTo(sentry) > 1100)
|
if (id == -1)
|
||||||
continue;
|
continue;
|
||||||
if (!IsVectorVisible(crumb, sentry, true))
|
if (sentryAreas[id])
|
||||||
continue;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void updateSentries()
|
void updateSentries()
|
||||||
{
|
{
|
||||||
@ -110,7 +125,9 @@ public:
|
|||||||
for (int i = 0; i < HIGHEST_ENTITY; i++)
|
for (int i = 0; i < HIGHEST_ENTITY; i++)
|
||||||
{
|
{
|
||||||
CachedEntity *ent = ENTITY(i);
|
CachedEntity *ent = ENTITY(i);
|
||||||
if (CE_BAD(ent) || ent->m_iClassID() != CL_CLASS(CObjectSentrygun) || ent->m_iTeam() == LOCAL_E->m_iTeam())
|
if (CE_BAD(ent) ||
|
||||||
|
ent->m_iClassID() != CL_CLASS(CObjectSentrygun) /*||
|
||||||
|
ent->m_iTeam() == LOCAL_E->m_iTeam()*/)
|
||||||
continue;
|
continue;
|
||||||
Vector sentryloc = GetBuildingPosition(ent);
|
Vector sentryloc = GetBuildingPosition(ent);
|
||||||
sentries.push_back(sentryloc);
|
sentries.push_back(sentryloc);
|
||||||
@ -128,8 +145,7 @@ public:
|
|||||||
}
|
}
|
||||||
bool IsIgnored(std::pair<int, int> connection)
|
bool IsIgnored(std::pair<int, int> connection)
|
||||||
{
|
{
|
||||||
if (sentryAreas[connection.first] ||
|
if (sentryAreas[connection.first] || sentryAreas[connection.second])
|
||||||
sentryAreas[connection.second])
|
|
||||||
{
|
{
|
||||||
logging::Info("Ignored a connection due to sentry gun coverage");
|
logging::Info("Ignored a connection due to sentry gun coverage");
|
||||||
return true;
|
return true;
|
||||||
@ -173,7 +189,7 @@ public:
|
|||||||
void AddTime(std::pair<Vector, Vector> connection, Timer &timer,
|
void AddTime(std::pair<Vector, Vector> connection, Timer &timer,
|
||||||
bool &resetPather)
|
bool &resetPather)
|
||||||
{
|
{
|
||||||
auto pair = VectorToId(connection);
|
auto pair = VectorsToId(connection);
|
||||||
if (pair.first == -1 || pair.second == -1)
|
if (pair.first == -1 || pair.second == -1)
|
||||||
return;
|
return;
|
||||||
AddTime(pair, timer, resetPather);
|
AddTime(pair, timer, resetPather);
|
||||||
@ -201,7 +217,7 @@ public:
|
|||||||
}
|
}
|
||||||
bool CheckType2(std::pair<Vector, Vector> connection)
|
bool CheckType2(std::pair<Vector, Vector> connection)
|
||||||
{
|
{
|
||||||
auto pair = VectorToId(connection);
|
auto pair = VectorsToId(connection);
|
||||||
if (pair.first == -1 || pair.second == -1)
|
if (pair.first == -1 || pair.second == -1)
|
||||||
return false;
|
return false;
|
||||||
return CheckType2(pair);
|
return CheckType2(pair);
|
||||||
|
@ -211,7 +211,7 @@ bool NavTo(Vector dest, bool navToLocalCenter, bool persistent,
|
|||||||
// Only allow instructions to overwrite others if their priority is higher
|
// Only allow instructions to overwrite others if their priority is higher
|
||||||
if (instructionPriority < priority)
|
if (instructionPriority < priority)
|
||||||
return false;
|
return false;
|
||||||
int locNav, tarNav;
|
int locNav = 0, tarNav = 0;
|
||||||
auto path = findPath(g_pLocalPlayer->v_Origin, dest, locNav, tarNav);
|
auto path = findPath(g_pLocalPlayer->v_Origin, dest, locNav, tarNav);
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
return false;
|
return false;
|
||||||
@ -266,7 +266,7 @@ void Repath()
|
|||||||
logging::Info("Pathing: NavBot inactive for too long. Ignoring "
|
logging::Info("Pathing: NavBot inactive for too long. Ignoring "
|
||||||
"connection and finding another path...");
|
"connection and finding another path...");
|
||||||
// Throwaway int
|
// Throwaway int
|
||||||
int i1, i2;
|
int i1 = 0, i2 = 0;
|
||||||
// Find a new path
|
// Find a new path
|
||||||
TF2MAP->pather->Reset();
|
TF2MAP->pather->Reset();
|
||||||
crumbs = findPath(g_pLocalPlayer->v_Origin, crumbs.back(), i1, i2);
|
crumbs = findPath(g_pLocalPlayer->v_Origin, crumbs.back(), i1, i2);
|
||||||
@ -402,7 +402,7 @@ CatCommand navprint("nav_print", "Debug nav print", [](const CCommand &args) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
CatCommand navfind("nav_find", "Debug nav find", [](const CCommand &args) {
|
CatCommand navfind("nav_find", "Debug nav find", [](const CCommand &args) {
|
||||||
int i1, i2;
|
int i1 = 0, i2 = 0;
|
||||||
std::vector<Vector> path = findPath(g_pLocalPlayer->v_Origin, loc, i1, i2);
|
std::vector<Vector> path = findPath(g_pLocalPlayer->v_Origin, loc, i1, i2);
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
|
@ -156,6 +156,16 @@ bool gui::handleSdlEvent(SDL_Event *event)
|
|||||||
logging::Info("GUI open button pressed");
|
logging::Info("GUI open button pressed");
|
||||||
zerokernel::Menu::instance->setInGame(
|
zerokernel::Menu::instance->setInGame(
|
||||||
!zerokernel::Menu::instance->isInGame());
|
!zerokernel::Menu::instance->isInGame());
|
||||||
|
if (!zerokernel::Menu::instance->isInGame())
|
||||||
|
{
|
||||||
|
g_ISurface->UnlockCursor();
|
||||||
|
g_ISurface->SetCursorAlwaysVisible(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_ISurface->LockCursor();
|
||||||
|
g_ISurface->SetCursorAlwaysVisible(false);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user