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, bool VisCheckEntFromEntVector(Vector startVector, CachedEntity *startEnt,
CachedEntity *endEnt); CachedEntity *endEnt);
Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist, Vector VischeckWall(CachedEntity *player, CachedEntity *target, float maxdist,
bool checkWalkable = false); bool checkWalkable);
float vectorMax(Vector i); float vectorMax(Vector i);
Vector vectorAbs(Vector i); Vector vectorABS(Vector i);
bool canReachVector(Vector loc); bool canReachVector(Vector loc);
bool LineIntersectsBox(Vector &bmin, Vector &bmax, Vector &lmin, Vector &lmax); 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; int maxiterations = floor(corner.DistTo(g_pLocalPlayer->v_Origin)) / 40;
for (int i = 0; i < maxiterations; i++) 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)) if (!canReachVector(result))
return false; return false;
breadcrumbs.push_back(result); 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; int maxiterations = floor(corner.DistTo(target->m_vecOrigin())) / 40;
for (int i = 0; i < maxiterations; i++) 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)) if (!canReachVector(result))
return false; return false;
breadcrumbs.push_back(result); breadcrumbs.push_back(result);
@ -188,7 +188,7 @@ void WorldTick()
continue; continue;
if (corneractivate) 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 if (!indirectOrigin.z) //if we couldn't find it, exit
continue; continue;
breadcrumbs.clear(); //we need to ensure that the breadcrumbs std::vector is empty breadcrumbs.clear(); //we need to ensure that the breadcrumbs std::vector is empty
@ -248,7 +248,7 @@ void WorldTick()
continue; continue;
if (corneractivate) 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 if (!indirectOrigin.z) //if we couldn't find it, exit
continue; continue;
//breadcrumbs.clear(); //we need to ensure that the breadcrumbs std::vector is empty //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 vectorABS(Vector i)
{ {
Vector result = i; Vector result = i;
result.x = fabsf(i.x); result.x = fabsf(result.x);
result.y = fabsf(i.y); result.y = fabsf(result.y);
result.z = fabsf(i.z); result.z = fabsf(result.z);
return result; return result;
} }
@ -177,7 +177,6 @@ Vector vectorABS(Vector i)
bool canReachVector(Vector loc) bool canReachVector(Vector loc)
{ {
// check if the vector is too high above ground // check if the vector is too high above ground
{
trace_t trace; trace_t trace;
Ray_t ray; Ray_t ray;
Vector down = loc; Vector down = loc;
@ -188,7 +187,7 @@ bool canReachVector(Vector loc)
75)) // higher as to avoid small false positives, player can jump 75)) // higher as to avoid small false positives, player can jump
// 72 hu // 72 hu
return false; return false;
}
for (int i = 0; i < 4; i++) // for loop for all 4 directions for (int i = 0; i < 4; i++) // for loop for all 4 directions
{ {
Vector directionalLoc = loc; Vector directionalLoc = loc;
@ -207,10 +206,11 @@ bool canReachVector(Vector loc)
directionalLoc.y = directionalLoc.y - 40; directionalLoc.y = directionalLoc.y - 40;
break; break;
} }
trace_t trace; trace_t trace2;
Ray_t ray; Ray_t ray2;
g_ITrace->TraceRay(ray, 0x4200400B, &trace::filter_no_player, &trace); ray2.Init(loc, directionalLoc);
if (trace.startpos.DistTo(trace.endpos) < 26.0f) g_ITrace->TraceRay(ray2, 0x4200400B, &trace::filter_no_player, &trace);
if (trace2.startpos.DistTo(trace2.endpos) < 26.0f)
return false; return false;
} }
return true; return true;