From 97410d38996cd4d11128cd16b872237a4a1414ab Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 1 Jul 2018 14:29:26 +0200 Subject: [PATCH] Fix --- include/helpers.hpp | 4 ++-- src/hacks/FollowBot.cpp | 8 ++++---- src/helpers.cpp | 38 +++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/helpers.hpp b/include/helpers.hpp index 823fbf14..326aec72 100755 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -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); diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index a0ef78bc..89624bd3 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -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 diff --git a/src/helpers.cpp b/src/helpers.cpp index 9981e824..9cccea43 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -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;