WIP
This commit is contained in:
parent
c35e31e152
commit
6c27273f98
@ -77,7 +77,9 @@ bool IsEntityVectorVisible(CachedEntity *entity, Vector endpos);
|
|||||||
bool VisCheckEntFromEnt(CachedEntity *startEnt, CachedEntity *endEnt);
|
bool VisCheckEntFromEnt(CachedEntity *startEnt, CachedEntity *endEnt);
|
||||||
bool VisCheckEntFromEntVector(Vector startVector, CachedEntity *startEnt,
|
bool VisCheckEntFromEntVector(Vector startVector, CachedEntity *startEnt,
|
||||||
CachedEntity *endEnt);
|
CachedEntity *endEnt);
|
||||||
Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
|
Vector VischeckCorner(CachedEntity *player, CachedEntity *target, float maxdist,
|
||||||
|
bool checkWalkable);
|
||||||
|
std::pair<Vector,Vector> VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
|
||||||
bool checkWalkable);
|
bool checkWalkable);
|
||||||
float vectorMax(Vector i);
|
float vectorMax(Vector i);
|
||||||
Vector vectorAbs(Vector i);
|
Vector vectorAbs(Vector i);
|
||||||
|
@ -221,7 +221,7 @@ void smart_crouch()
|
|||||||
{
|
{
|
||||||
bool foundtar = false;
|
bool foundtar = false;
|
||||||
static bool crouch = false;
|
static bool crouch = false;
|
||||||
if (crouchcdr.test_and_set(1000))
|
if (crouchcdr.test_and_set(2000))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g_IEngine->GetMaxClients(); i++)
|
for (int i = 0; i < g_IEngine->GetMaxClients(); i++)
|
||||||
{
|
{
|
||||||
@ -246,13 +246,10 @@ void smart_crouch()
|
|||||||
continue;
|
continue;
|
||||||
if (!IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->center) && !IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->min) && !IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->max))
|
if (!IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->center) && !IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->min) && !IsVectorVisible(ent->hitboxes.GetHitbox(0)->center, LOCAL_E->hitboxes.GetHitbox(j)->max))
|
||||||
continue;
|
continue;
|
||||||
else
|
|
||||||
{
|
|
||||||
foundtar = true;
|
foundtar = true;
|
||||||
crouch = true;
|
crouch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!foundtar && crouch)
|
if (!foundtar && crouch)
|
||||||
crouch = false;
|
crouch = false;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ static CatVar afktime(
|
|||||||
CV_INT, "fb_afk_time", "15000", "Max AFK Time",
|
CV_INT, "fb_afk_time", "15000", "Max AFK Time",
|
||||||
"Max time in ms spent standing still before player gets declared afk");
|
"Max time in ms spent standing still before player gets declared afk");
|
||||||
static CatVar corneractivate(
|
static CatVar corneractivate(
|
||||||
CV_SWITCH, "fb_activation_corners", "1", "Activate arround corners",
|
CV_SWITCH, "fb_activation_corners", "1", "Activate around corners",
|
||||||
"Try to find an activation path to an entity behind a corner.");
|
"Try to find an activation path to an entity behind a corner.");
|
||||||
|
|
||||||
// Something to store breadcrumbs created by followed players
|
// Something to store breadcrumbs created by followed players
|
||||||
@ -143,6 +143,8 @@ int ClassPriority(CachedEntity *ent)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Timer waittime{};
|
||||||
|
int lastent = 0;
|
||||||
void WorldTick()
|
void WorldTick()
|
||||||
{
|
{
|
||||||
if (!followbot)
|
if (!followbot)
|
||||||
@ -195,15 +197,28 @@ void WorldTick()
|
|||||||
|
|
||||||
if (!entity->m_bAlivePlayer()) // Dont follow dead players
|
if (!entity->m_bAlivePlayer()) // Dont follow dead players
|
||||||
continue;
|
continue;
|
||||||
|
lastent++;
|
||||||
|
if (lastent > g_IEngine->GetMaxClients())
|
||||||
|
lastent = 0;
|
||||||
if (corneractivate)
|
if (corneractivate)
|
||||||
{
|
{
|
||||||
Vector indirectOrigin =
|
Vector indirectOrigin =
|
||||||
VischeckWall(LOCAL_E, entity, 250,
|
VischeckCorner(LOCAL_E, entity, 500,
|
||||||
true); // get the corner location that the
|
true); // get the corner location that the
|
||||||
// future target is visible from
|
// future target is visible from
|
||||||
if (!indirectOrigin.z) // if we couldn't find it, exit
|
std::pair<Vector, Vector> corners;
|
||||||
|
if (!indirectOrigin.z && entity->m_IDX == lastent) // if we couldn't find it, run wallcheck instead
|
||||||
|
{
|
||||||
|
corners = VischeckWall(LOCAL_E, entity, 500, true);
|
||||||
|
if (!corners.first.z || !corners.second.z)
|
||||||
continue;
|
continue;
|
||||||
|
addCrumbs(LOCAL_E, corners.first);
|
||||||
|
addCrumbs(entity, corners.second);
|
||||||
|
}
|
||||||
|
if (indirectOrigin.z)
|
||||||
addCrumbs(entity, indirectOrigin);
|
addCrumbs(entity, indirectOrigin);
|
||||||
|
else if (!indirectOrigin.z && !corners.first.z)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -265,9 +280,7 @@ void WorldTick()
|
|||||||
if (follow_target &&
|
if (follow_target &&
|
||||||
ENTITY(follow_target)->m_flDistance() <
|
ENTITY(follow_target)->m_flDistance() <
|
||||||
entity->m_flDistance()) // favor closer entitys
|
entity->m_flDistance()) // favor closer entitys
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
// check if new target has a higher priority than current target
|
// check if new target has a higher priority than current target
|
||||||
if (ClassPriority(ENTITY(follow_target)) >=
|
if (ClassPriority(ENTITY(follow_target)) >=
|
||||||
ClassPriority(ENTITY(i)))
|
ClassPriority(ENTITY(i)))
|
||||||
@ -276,12 +289,22 @@ void WorldTick()
|
|||||||
if (corneractivate)
|
if (corneractivate)
|
||||||
{
|
{
|
||||||
Vector indirectOrigin =
|
Vector indirectOrigin =
|
||||||
VischeckWall(LOCAL_E, entity, 250,
|
VischeckCorner(LOCAL_E, entity, 500,
|
||||||
true); // get the corner location that the
|
true); // get the corner location that the
|
||||||
// future target is visible from
|
// future target is visible from
|
||||||
if (!indirectOrigin.z) // if we couldn't find it, exit
|
std::pair<Vector, Vector> corners;
|
||||||
|
if (!indirectOrigin.z && entity->m_IDX == lastent) // if we couldn't find it, run wallcheck instead
|
||||||
|
{
|
||||||
|
corners = VischeckWall(LOCAL_E, entity, 500, true);
|
||||||
|
if (!corners.first.z || !corners.second.z)
|
||||||
continue;
|
continue;
|
||||||
|
addCrumbs(LOCAL_E, corners.first);
|
||||||
|
addCrumbs(entity, corners.second);
|
||||||
|
}
|
||||||
|
if (indirectOrigin.z)
|
||||||
addCrumbs(entity, indirectOrigin);
|
addCrumbs(entity, indirectOrigin);
|
||||||
|
else if (!indirectOrigin.z && !corners.first.z)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ void WalkTo(const Vector &vector)
|
|||||||
|
|
||||||
// Function to get the corner location that a vischeck to an entity is possible
|
// Function to get the corner location that a vischeck to an entity is possible
|
||||||
// from
|
// from
|
||||||
Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
|
Vector VischeckCorner(CachedEntity *player, CachedEntity *target, float maxdist,
|
||||||
bool checkWalkable)
|
bool checkWalkable)
|
||||||
{
|
{
|
||||||
int maxiterations = maxdist / 40;
|
int maxiterations = maxdist / 40;
|
||||||
@ -165,6 +165,91 @@ Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
|
|||||||
return { 0, 0, 0 };
|
return { 0, 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return Two Corners that connect perfectly to ent and local player
|
||||||
|
std::pair<Vector,Vector> VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
|
||||||
|
bool checkWalkable)
|
||||||
|
{
|
||||||
|
int maxiterations = maxdist / 40;
|
||||||
|
Vector origin = player->m_vecOrigin();
|
||||||
|
|
||||||
|
// if we can see an entity, we don't need to run calculations
|
||||||
|
if (VisCheckEntFromEnt(player, target))
|
||||||
|
{
|
||||||
|
std::pair<Vector, Vector> orig(origin, origin);
|
||||||
|
if (!checkWalkable)
|
||||||
|
return orig;
|
||||||
|
else if (canReachVector(origin, target->m_vecOrigin()))
|
||||||
|
return orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) // for loop for all 4 directions
|
||||||
|
{
|
||||||
|
// 40 * maxiterations = range in HU
|
||||||
|
for (int j = 0; j < maxiterations; j++)
|
||||||
|
{
|
||||||
|
Vector virtualOrigin = origin;
|
||||||
|
// what direction to go in
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
virtualOrigin.x = virtualOrigin.x + 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
virtualOrigin.x = virtualOrigin.x - 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
virtualOrigin.y = virtualOrigin.y + 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
virtualOrigin.y = virtualOrigin.y - 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// check if player can see the players virtualOrigin
|
||||||
|
if (!IsVectorVisible(origin, virtualOrigin, true))
|
||||||
|
continue;
|
||||||
|
for (int i = 0; i < 4; i++) // for loop for all 4 directions
|
||||||
|
{
|
||||||
|
// 40 * maxiterations = range in HU
|
||||||
|
for (int j = 0; j < maxiterations; j++)
|
||||||
|
{
|
||||||
|
Vector virtualOrigin2 = origin;
|
||||||
|
// what direction to go in
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
virtualOrigin2.x = virtualOrigin2.x + 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
virtualOrigin2.x = virtualOrigin2.x - 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
virtualOrigin2.y = virtualOrigin2.y + 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
virtualOrigin2.y = virtualOrigin2.y - 40 * (j + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// check if the virtualOrigin2 can see the target
|
||||||
|
if (!VisCheckEntFromEntVector(virtualOrigin2, player, target))
|
||||||
|
continue;
|
||||||
|
if (!IsVectorVisible(virtualOrigin, virtualOrigin2, true))
|
||||||
|
continue;
|
||||||
|
std::pair<Vector, Vector> toret(virtualOrigin, virtualOrigin2);
|
||||||
|
if (!checkWalkable)
|
||||||
|
return toret;
|
||||||
|
// check if the location is accessible
|
||||||
|
if (!canReachVector(origin, virtualOrigin) || !canReachVector(target->m_vecOrigin(), virtualOrigin2))
|
||||||
|
continue;
|
||||||
|
if (canReachVector(virtualOrigin, target->m_vecOrigin()))
|
||||||
|
return toret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we didn't find anything, return an empty Vector
|
||||||
|
return { {0, 0, 0}, {0, 0, 0} };
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a vectors max value. For example: {123,-150, 125} = 125
|
// Returns a vectors max value. For example: {123,-150, 125} = 125
|
||||||
float vectorMax(Vector i)
|
float vectorMax(Vector i)
|
||||||
{
|
{
|
||||||
@ -649,8 +734,7 @@ bool IsEntityVectorVisible(CachedEntity *entity, Vector endpos)
|
|||||||
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default,
|
g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default,
|
||||||
&trace_object);
|
&trace_object);
|
||||||
}
|
}
|
||||||
return (trace_object.fraction >= 0.99f ||
|
return (((IClientEntity *) trace_object.m_pEnt) == RAW_ENT(entity) || trace_object.fraction >= 0.99f);
|
||||||
(((IClientEntity *) trace_object.m_pEnt)) == RAW_ENT(entity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For when you need to vis check something that isnt the local player
|
// For when you need to vis check something that isnt the local player
|
||||||
|
Reference in New Issue
Block a user