Merge remote-tracking branch 'nullworks/newui'
This commit is contained in:
commit
fe1304ab1e
@ -33,7 +33,8 @@ class inactivityTracker
|
|||||||
std::unordered_map<std::pair<int, int>, std::pair<int, unsigned int>,
|
std::unordered_map<std::pair<int, int>, std::pair<int, unsigned int>,
|
||||||
boost::hash<std::pair<int, int>>>
|
boost::hash<std::pair<int, int>>>
|
||||||
inactives;
|
inactives;
|
||||||
std::vector<int> sentryAreas;
|
std::unordered_map<int, bool> sentryAreas;
|
||||||
|
std::vector<Vector> sentries;
|
||||||
|
|
||||||
bool vischeckConnection(std::pair<int, int> &connection)
|
bool vischeckConnection(std::pair<int, int> &connection)
|
||||||
{
|
{
|
||||||
@ -89,36 +90,52 @@ public:
|
|||||||
i.second.second = 0;
|
i.second.second = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool ShouldCancelPath(std::vector<Vector> crumbs)
|
||||||
|
{
|
||||||
|
for (auto sentry : sentries)
|
||||||
|
for (auto crumb : crumbs)
|
||||||
|
{
|
||||||
|
if (crumb.DistTo(sentry) > 1100)
|
||||||
|
continue;
|
||||||
|
if (!IsVectorVisible(crumb, sentry, true))
|
||||||
|
continue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
void updateSentries()
|
void updateSentries()
|
||||||
{
|
{
|
||||||
logging::Info("1");
|
|
||||||
sentryAreas.clear();
|
sentryAreas.clear();
|
||||||
|
sentries.clear();
|
||||||
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))
|
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);
|
||||||
for (auto i : areas)
|
for (auto i : areas)
|
||||||
{
|
{
|
||||||
Vector area = i.m_center;
|
Vector area = i.m_center;
|
||||||
area.z += 30.0f;
|
area.z += 83.0f;
|
||||||
if (area.DistTo(sentryloc) > 1100.0f)
|
if (area.DistTo(sentryloc) > 1100.0f)
|
||||||
continue;
|
continue;
|
||||||
if (!IsVectorVisible(area, sentryloc, true))
|
if (!IsVectorVisible(area, sentryloc, true))
|
||||||
continue;
|
continue;
|
||||||
logging::Info("5");
|
sentryAreas[i.m_id] = true;
|
||||||
sentryAreas.push_back(i.m_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool IsIgnored(std::pair<int, int> connection)
|
bool IsIgnored(std::pair<int, int> connection)
|
||||||
{
|
{
|
||||||
if (inactives.find(connection) == inactives.end())
|
if (sentryAreas[connection.first] ||
|
||||||
|
sentryAreas[connection.second])
|
||||||
{
|
{
|
||||||
return false;
|
logging::Info("Ignored a connection due to sentry gun coverage");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (inactives.find(connection) == inactives.end())
|
||||||
|
return false;
|
||||||
auto &pair = inactives.at(connection);
|
auto &pair = inactives.at(connection);
|
||||||
if (pair.second >= 5000)
|
if (pair.second >= 5000)
|
||||||
{
|
{
|
||||||
@ -131,14 +148,6 @@ public:
|
|||||||
"Ignored a connection due to type 2 connection type.");
|
"Ignored a connection due to type 2 connection type.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (std::find(sentryAreas.begin(), sentryAreas.end(),
|
|
||||||
connection.first) != sentryAreas.end() ||
|
|
||||||
std::find(sentryAreas.begin(), sentryAreas.end(),
|
|
||||||
connection.second) != sentryAreas.end())
|
|
||||||
{
|
|
||||||
logging::Info("Ignored a connection due to sentry gun coverage");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,19 @@ public:
|
|||||||
virtual TraceType_t GetTraceType() const;
|
virtual TraceType_t GetTraceType() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FilterNoEntity : public ITraceFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IClientEntity *m_pSelf;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~FilterNoEntity();
|
||||||
|
FilterNoEntity();
|
||||||
|
virtual bool ShouldHitEntity(IHandleEntity *entity, int mask);
|
||||||
|
void SetSelf(IClientEntity *self);
|
||||||
|
virtual TraceType_t GetTraceType() const;
|
||||||
|
};
|
||||||
|
|
||||||
class FilterPenetration : public ITraceFilter
|
class FilterPenetration : public ITraceFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -59,5 +72,6 @@ public:
|
|||||||
|
|
||||||
extern FilterDefault filter_default;
|
extern FilterDefault filter_default;
|
||||||
extern FilterNoPlayer filter_no_player;
|
extern FilterNoPlayer filter_no_player;
|
||||||
|
extern FilterNoEntity filter_no_entity;
|
||||||
extern FilterPenetration filter_penetration;
|
extern FilterPenetration filter_penetration;
|
||||||
} // namespace trace
|
} // namespace trace
|
||||||
|
@ -118,7 +118,9 @@ void update_catbot_list()
|
|||||||
strcasestr(info.name, "zCat") ||
|
strcasestr(info.name, "zCat") ||
|
||||||
strcasestr(info.name, "lagger bot") ||
|
strcasestr(info.name, "lagger bot") ||
|
||||||
strcasestr(info.name, "zLag-bot") ||
|
strcasestr(info.name, "zLag-bot") ||
|
||||||
strcasestr(info.name, "crash-bot"))
|
strcasestr(info.name, "crash-bot") ||
|
||||||
|
strcasestr(info.name, "reichstagbot")
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (human_detecting_map.find(info.friendsID) ==
|
if (human_detecting_map.find(info.friendsID) ==
|
||||||
human_detecting_map.end())
|
human_detecting_map.end())
|
||||||
|
@ -185,14 +185,13 @@ void Init()
|
|||||||
sniper_spots.size(), preferred_sniper_spots.size(),
|
sniper_spots.size(), preferred_sniper_spots.size(),
|
||||||
nest_spots.size());
|
nest_spots.size());
|
||||||
}
|
}
|
||||||
// I doubtwe'd use more than 128 Sniper spots
|
|
||||||
std::array<int, 128> priority_spots;
|
std::unordered_map<int, int> priority_spots;
|
||||||
void initonce()
|
void initonce()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < afkTicks.size(); i++)
|
for (int i = 0; i < afkTicks.size(); i++)
|
||||||
afkTicks[i].update();
|
afkTicks[i].update();
|
||||||
for (auto &e :priority_spots)
|
priority_spots.clear();
|
||||||
e = 0;
|
|
||||||
cdr.update();
|
cdr.update();
|
||||||
cd2.update();
|
cd2.update();
|
||||||
cd3.update();
|
cd3.update();
|
||||||
@ -294,11 +293,11 @@ int GetClosestBuilding()
|
|||||||
return BestBuilding;
|
return BestBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavToSniperSpot(int priority)
|
bool NavToSniperSpot(int priority)
|
||||||
{
|
{
|
||||||
Vector random_spot;
|
Vector random_spot;
|
||||||
if (!sniper_spots.size() && !preferred_sniper_spots.size())
|
if (!sniper_spots.size() && !preferred_sniper_spots.size())
|
||||||
return;
|
return false;
|
||||||
auto snip_spot = preferred_sniper_spots.size()
|
auto snip_spot = preferred_sniper_spots.size()
|
||||||
? preferred_sniper_spots
|
? preferred_sniper_spots
|
||||||
: sniper_spots;
|
: sniper_spots;
|
||||||
@ -323,12 +322,13 @@ void NavToSniperSpot(int priority)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (best_spot == -1)
|
if (best_spot == -1)
|
||||||
return;
|
return false;
|
||||||
random_spot = snip_spot.at(best_spot);
|
random_spot = snip_spot.at(best_spot);
|
||||||
|
bool toret = false;
|
||||||
if (random_spot.z)
|
if (random_spot.z)
|
||||||
nav::NavTo(random_spot, false, true, priority);
|
toret = nav::NavTo(random_spot, false, true, priority);
|
||||||
priority_spots[best_spot]++;
|
priority_spots[best_spot]++;
|
||||||
return;
|
return toret;
|
||||||
}
|
}
|
||||||
int follow_target = 0;
|
int follow_target = 0;
|
||||||
void CreateMove()
|
void CreateMove()
|
||||||
@ -360,15 +360,17 @@ void CreateMove()
|
|||||||
cd3.update();
|
cd3.update();
|
||||||
bool isready =
|
bool isready =
|
||||||
(spy_mode || heavy_mode || engi_mode) ? 1 : nav::ReadyForCommands;
|
(spy_mode || heavy_mode || engi_mode) ? 1 : nav::ReadyForCommands;
|
||||||
int waittime = (spy_mode || heavy_mode || engi_mode) ? 100 : 5000;
|
static int waittime = (spy_mode || heavy_mode || engi_mode) ? 100 : 2000;
|
||||||
if (isready && cd3.test_and_set(waittime))
|
if (isready && cd3.test_and_set(waittime))
|
||||||
{
|
{
|
||||||
|
waittime = (spy_mode || heavy_mode || engi_mode) ? 100 : 2000;
|
||||||
if (!spy_mode && !heavy_mode && !engi_mode)
|
if (!spy_mode && !heavy_mode && !engi_mode)
|
||||||
{
|
{
|
||||||
cd3.update();
|
cd3.update();
|
||||||
if (cd2.test_and_set(5000))
|
if (cd2.test_and_set(5000))
|
||||||
Init();
|
Init();
|
||||||
NavToSniperSpot(5);
|
if (!NavToSniperSpot(5))
|
||||||
|
waittime = 1;
|
||||||
}
|
}
|
||||||
else if (!engi_mode)
|
else if (!engi_mode)
|
||||||
{
|
{
|
||||||
@ -377,13 +379,17 @@ void CreateMove()
|
|||||||
{
|
{
|
||||||
if (cd2.test_and_set(5000))
|
if (cd2.test_and_set(5000))
|
||||||
Init();
|
Init();
|
||||||
NavToSniperSpot(5);
|
if (!NavToSniperSpot(5))
|
||||||
|
waittime = 1;
|
||||||
}
|
}
|
||||||
if (CE_GOOD(tar))
|
if (CE_GOOD(tar))
|
||||||
{
|
{
|
||||||
if (!spy_mode ||
|
if (!spy_mode ||
|
||||||
!hacks::shared::backtrack::isBacktrackEnabled)
|
!hacks::shared::backtrack::isBacktrackEnabled)
|
||||||
nav::NavTo(tar->m_vecOrigin(), false);
|
{
|
||||||
|
if (!nav::NavTo(tar->m_vecOrigin(), false))
|
||||||
|
last_tar = -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (auto i : hacks::shared::backtrack::headPositions
|
for (auto i : hacks::shared::backtrack::headPositions
|
||||||
@ -508,7 +514,8 @@ void CreateMove()
|
|||||||
{
|
{
|
||||||
if (cd2.test_and_set(5000))
|
if (cd2.test_and_set(5000))
|
||||||
Init();
|
Init();
|
||||||
NavToSniperSpot(1);
|
if (!NavToSniperSpot(1))
|
||||||
|
waittime = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1107,19 +1107,29 @@ netvar.iHealth));
|
|||||||
|
|
||||||
bool IsVectorVisible(Vector origin, Vector target, bool enviroment_only)
|
bool IsVectorVisible(Vector origin, Vector target, bool enviroment_only)
|
||||||
{
|
{
|
||||||
trace_t trace_visible;
|
|
||||||
Ray_t ray;
|
|
||||||
|
|
||||||
trace::filter_no_player.SetSelf(RAW_ENT(g_pLocalPlayer->entity));
|
|
||||||
ray.Init(origin, target);
|
|
||||||
if (!enviroment_only)
|
if (!enviroment_only)
|
||||||
|
{
|
||||||
|
trace_t trace_visible;
|
||||||
|
Ray_t ray;
|
||||||
|
|
||||||
|
trace::filter_no_player.SetSelf(RAW_ENT(g_pLocalPlayer->entity));
|
||||||
|
ray.Init(origin, target);
|
||||||
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_no_player,
|
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_no_player,
|
||||||
&trace_visible);
|
&trace_visible);
|
||||||
|
return (trace_visible.fraction == 1.0f);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
g_ITrace->TraceRay(ray, 0x4200400B, &trace::filter_no_player,
|
{
|
||||||
&trace_visible);
|
trace_t trace_visible;
|
||||||
|
Ray_t ray;
|
||||||
|
|
||||||
return (trace_visible.fraction == 1.0f);
|
trace::filter_no_entity.SetSelf(RAW_ENT(g_pLocalPlayer->entity));
|
||||||
|
ray.Init(origin, target);
|
||||||
|
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_no_entity,
|
||||||
|
&trace_visible);
|
||||||
|
return (trace_visible.fraction == 1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WhatIAmLookingAt(int *result_eindex, Vector *result_pos)
|
void WhatIAmLookingAt(int *result_eindex, Vector *result_pos)
|
||||||
|
@ -243,6 +243,7 @@ void clearInstructions()
|
|||||||
static Timer ignoreReset{};
|
static Timer ignoreReset{};
|
||||||
static Timer patherReset{};
|
static Timer patherReset{};
|
||||||
static Timer sentryUpdate{};
|
static Timer sentryUpdate{};
|
||||||
|
static Timer sentryCheck{};
|
||||||
// Function for removing ignores
|
// Function for removing ignores
|
||||||
void ignoreManagerCM()
|
void ignoreManagerCM()
|
||||||
{
|
{
|
||||||
@ -252,8 +253,8 @@ void ignoreManagerCM()
|
|||||||
TF2MAP->inactiveTracker.reset();
|
TF2MAP->inactiveTracker.reset();
|
||||||
if (patherReset.test_and_set(30000))
|
if (patherReset.test_and_set(30000))
|
||||||
TF2MAP->pather->Reset();
|
TF2MAP->pather->Reset();
|
||||||
if(sentryUpdate.test_and_set(2000))
|
if(sentryUpdate.test_and_set(1000))
|
||||||
TF2MAP->inactiveTracker.updateSentries();
|
TF2MAP->inactiveTracker.updateSentries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Repath()
|
void Repath()
|
||||||
@ -265,6 +266,7 @@ void Repath()
|
|||||||
// Throwaway int
|
// Throwaway int
|
||||||
int i1, i2;
|
int i1, i2;
|
||||||
// Find a new path
|
// Find a new path
|
||||||
|
TF2MAP->pather->Reset();
|
||||||
crumbs = findPath(g_pLocalPlayer->v_Origin, crumbs.back(), i1, i2);
|
crumbs = findPath(g_pLocalPlayer->v_Origin, crumbs.back(), i1, i2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -273,6 +275,7 @@ void Repath()
|
|||||||
"Pathing: NavBot inactive for too long. Canceling tasks and "
|
"Pathing: NavBot inactive for too long. Canceling tasks and "
|
||||||
"ignoring connection...");
|
"ignoring connection...");
|
||||||
// Wait for new instructions
|
// Wait for new instructions
|
||||||
|
TF2MAP->pather->Reset();
|
||||||
crumbs.clear();
|
crumbs.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,6 +328,13 @@ void CreateMove()
|
|||||||
inactivity.update();
|
inactivity.update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Check for new sentries
|
||||||
|
if (sentryCheck.test_and_set(1000) && TF2MAP->inactiveTracker.ShouldCancelPath(crumbs))
|
||||||
|
{
|
||||||
|
logging::Info("Pathing: New Sentry found!");
|
||||||
|
TF2MAP->pather->Reset();
|
||||||
|
Repath();
|
||||||
|
}
|
||||||
// If inactive for too long
|
// If inactive for too long
|
||||||
if (inactivity.check(5000))
|
if (inactivity.check(5000))
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,34 @@ TraceType_t trace::FilterNoPlayer::GetTraceType() const
|
|||||||
{
|
{
|
||||||
return TRACE_EVERYTHING;
|
return TRACE_EVERYTHING;
|
||||||
}
|
}
|
||||||
|
/* No-Entity filter */
|
||||||
|
|
||||||
|
trace::FilterNoEntity::FilterNoEntity()
|
||||||
|
{
|
||||||
|
m_pSelf = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace::FilterNoEntity::~FilterNoEntity(){};
|
||||||
|
|
||||||
|
void trace::FilterNoEntity::SetSelf(IClientEntity *self)
|
||||||
|
{
|
||||||
|
if (self == nullptr)
|
||||||
|
{
|
||||||
|
logging::Info("nullptr in FilterNoPlayer::SetSelf");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_pSelf = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool trace::FilterNoEntity::ShouldHitEntity(IHandleEntity *handle, int mask)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceType_t trace::FilterNoEntity::GetTraceType() const
|
||||||
|
{
|
||||||
|
return TRACE_EVERYTHING;
|
||||||
|
}
|
||||||
/* Penetration Filter */
|
/* Penetration Filter */
|
||||||
|
|
||||||
trace::FilterPenetration::FilterPenetration()
|
trace::FilterPenetration::FilterPenetration()
|
||||||
@ -172,4 +199,5 @@ void trace::FilterPenetration::Reset()
|
|||||||
|
|
||||||
trace::FilterDefault trace::filter_default{};
|
trace::FilterDefault trace::filter_default{};
|
||||||
trace::FilterNoPlayer trace::filter_no_player{};
|
trace::FilterNoPlayer trace::filter_no_player{};
|
||||||
|
trace::FilterNoEntity trace::filter_no_entity{};
|
||||||
trace::FilterPenetration trace::filter_penetration{};
|
trace::FilterPenetration trace::filter_penetration{};
|
||||||
|
Reference in New Issue
Block a user