This commit is contained in:
TotallyNotElite 2018-07-01 14:29:26 +02:00
parent aff77d2d2c
commit 97410d3899
3 changed files with 25 additions and 25 deletions

View File

@ -78,9 +78,9 @@ bool VisCheckEntFromEnt(CachedEntity *startEnt, CachedEntity *endEnt);
bool VisCheckEntFromEntVector(Vector startVector, CachedEntity *startEnt,
CachedEntity *endEnt);
Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
bool checkWalkable = false);
bool checkWalkable);
float vectorMax(Vector i);
Vector vectorAbs(Vector i);
Vector vectorABS(Vector i);
bool canReachVector(Vector loc);
bool LineIntersectsBox(Vector &bmin, Vector &bmax, Vector &lmin, Vector &lmax);

View File

@ -116,7 +116,7 @@ bool addCrumbs(CachedEntity *target, Vector corner = g_pLocalPlayer->v_Origin)
int maxiterations = floor(corner.DistTo(g_pLocalPlayer->v_Origin)) / 40;
for (int i = 0; i < maxiterations; i++)
{
Vector result = g_pLocalPlayer->v_Origin + dist / vectorMax(vectorAbs(dist)) * 40.0f * (i + 1);
Vector result = g_pLocalPlayer->v_Origin + dist / vectorMax(vectorABS(dist)) * 40.0f * (i + 1);
if (!canReachVector(result))
return false;
breadcrumbs.push_back(result);
@ -127,7 +127,7 @@ bool addCrumbs(CachedEntity *target, Vector corner = g_pLocalPlayer->v_Origin)
int maxiterations = floor(corner.DistTo(target->m_vecOrigin())) / 40;
for (int i = 0; i < maxiterations; i++)
{
Vector result = corner + dist / vectorMax(vectorAbs(dist)) * 40.0f * (i + 1);
Vector result = corner + dist / vectorMax(vectorABS(dist)) * 40.0f * (i + 1);
if (!canReachVector(result))
return false;
breadcrumbs.push_back(result);
@ -188,7 +188,7 @@ void WorldTick()
continue;
if (corneractivate)
{
Vector indirectOrigin = VischeckWall(LOCAL_E, entity, 250); //get the corner location that the future target is visible from
Vector indirectOrigin = VischeckWall(LOCAL_E, entity, 250, true); //get the corner location that the future target is visible from
if (!indirectOrigin.z) //if we couldn't find it, exit
continue;
breadcrumbs.clear(); //we need to ensure that the breadcrumbs std::vector is empty
@ -248,7 +248,7 @@ void WorldTick()
continue;
if (corneractivate)
{
Vector indirectOrigin = VischeckWall(LOCAL_E, entity, 250); //get the corner location that the future target is visible from
Vector indirectOrigin = VischeckWall(LOCAL_E, entity, 250, true); //get the corner location that the future target is visible from
if (!indirectOrigin.z) //if we couldn't find it, exit
continue;
//breadcrumbs.clear(); //we need to ensure that the breadcrumbs std::vector is empty

View File

@ -166,9 +166,9 @@ float vectorMax(Vector i) // Returns a vectors max value. For example: {123,
Vector vectorABS(Vector i)
{
Vector result = i;
result.x = fabsf(i.x);
result.y = fabsf(i.y);
result.z = fabsf(i.z);
result.x = fabsf(result.x);
result.y = fabsf(result.y);
result.z = fabsf(result.z);
return result;
}
@ -177,18 +177,17 @@ Vector vectorABS(Vector i)
bool canReachVector(Vector loc)
{
// check if the vector is too high above ground
{
trace_t trace;
Ray_t ray;
Vector down = loc;
down.z = down.z - 5;
ray.Init(loc, down);
g_ITrace->TraceRay(ray, 0x4200400B, &trace::filter_no_player, &trace);
if (!(trace.startpos.z - trace.endpos.z <=
75)) // higher as to avoid small false positives, player can jump
// 72 hu
return false;
}
trace_t trace;
Ray_t ray;
Vector down = loc;
down.z = down.z - 5;
ray.Init(loc, down);
g_ITrace->TraceRay(ray, 0x4200400B, &trace::filter_no_player, &trace);
if (!(trace.startpos.z - trace.endpos.z <=
75)) // higher as to avoid small false positives, player can jump
// 72 hu
return false;
for (int i = 0; i < 4; i++) // for loop for all 4 directions
{
Vector directionalLoc = loc;
@ -207,10 +206,11 @@ bool canReachVector(Vector loc)
directionalLoc.y = directionalLoc.y - 40;
break;
}
trace_t trace;
Ray_t ray;
g_ITrace->TraceRay(ray, 0x4200400B, &trace::filter_no_player, &trace);
if (trace.startpos.DistTo(trace.endpos) < 26.0f)
trace_t trace2;
Ray_t ray2;
ray2.Init(loc, directionalLoc);
g_ITrace->TraceRay(ray2, 0x4200400B, &trace::filter_no_player, &trace);
if (trace2.startpos.DistTo(trace2.endpos) < 26.0f)
return false;
}
return true;