From 738599e37bc8a870ece01bdf6d5c94755f46f590 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Tue, 15 May 2018 18:23:29 +0200 Subject: [PATCH 1/2] Some fixes --- include/hacks/Backtrack.hpp | 25 ++++++ libglez | 1 + libxoverlay | 1 + simple-ipc | 1 + src/hacks/Backtrack.cpp | 134 ++++++++++++++++++++++++++++++++ src/hooks/IsPlayingTimeDemo.cpp | 19 +++++ 6 files changed, 181 insertions(+) create mode 100644 include/hacks/Backtrack.hpp create mode 160000 libglez create mode 160000 libxoverlay create mode 160000 simple-ipc create mode 100644 src/hacks/Backtrack.cpp create mode 100644 src/hooks/IsPlayingTimeDemo.cpp diff --git a/include/hacks/Backtrack.hpp b/include/hacks/Backtrack.hpp new file mode 100644 index 00000000..ac1b678e --- /dev/null +++ b/include/hacks/Backtrack.hpp @@ -0,0 +1,25 @@ +/* + * Backtrack.hpp + * + * Created on: May 15, 2018 + * Author: bencat07 + */ + +#pragma once +#include "common.hpp" + +namespace hacks { +namespace shared { +namespace backtrack { +struct BacktrackData +{ + int tickcount; + Vector hitboxpos; +}; +void Init(); +void Run(); +void Draw(); +extern BacktrackData headPositions[24][12]; +} +} +} diff --git a/libglez b/libglez new file mode 160000 index 00000000..a8fc8b75 --- /dev/null +++ b/libglez @@ -0,0 +1 @@ +Subproject commit a8fc8b75b1a8488a7a51e2575cb265b5ed24e36f diff --git a/libxoverlay b/libxoverlay new file mode 160000 index 00000000..de4e4bb2 --- /dev/null +++ b/libxoverlay @@ -0,0 +1 @@ +Subproject commit de4e4bb2787a5c586bd54834f9b09b703b35e59e diff --git a/simple-ipc b/simple-ipc new file mode 160000 index 00000000..60f43c1c --- /dev/null +++ b/simple-ipc @@ -0,0 +1 @@ +Subproject commit 60f43c1c8ebe794345f8ab2ba465984ec445a9c6 diff --git a/src/hacks/Backtrack.cpp b/src/hacks/Backtrack.cpp new file mode 100644 index 00000000..598fd606 --- /dev/null +++ b/src/hacks/Backtrack.cpp @@ -0,0 +1,134 @@ +/* + * Backtrack.cpp + * + * Created on: May 15, 2018 + * Author: bencat07 + */ + +#include "common.hpp" +#include "Backtrack.hpp" +namespace hacks { +namespace shared { +namespace backtrack { +CatVar enable(CV_SWITCH, "backtrack", "1", "Enable backtrack", "For legit play only as of right now."); +BacktrackData headPositions[24][12]; + +//======================================================================= +inline float distance_point_to_line(Vector Point, Vector LineOrigin, Vector Dir) +{ + auto PointDir = Point - LineOrigin; + + auto TempOffset = PointDir.Dot(Dir) / (Dir.x*Dir.x + Dir.y*Dir.y + Dir.z*Dir.z); + if (TempOffset < 0.000001f) + return FLT_MAX; + + auto PerpendicularPoint = LineOrigin + (Dir * TempOffset); + + return (Point - PerpendicularPoint).Length(); +} + +inline Vector angle_vector(Vector meme) +{ + auto sy = sin(meme.y / 180.f * static_cast(PI)); + auto cy = cos(meme.y / 180.f * static_cast(PI)); + + auto sp = sin(meme.x / 180.f * static_cast(PI)); + auto cp = cos(meme.x / 180.f* static_cast(PI)); + + return Vector(cp*cy, cp*sy, -sp); +} +//======================================================================= +void Init() +{ + for (auto a : headPositions) + { + a->hitboxpos = {0,0,0}; + a->tickcount = 0; + } +} +void Run() +{ + if (!enable) + return; + CUserCmd *cmd = g_pUserCmd; + int iBestTarget = -1; + float bestFov = 99999; + + if (CE_BAD(LOCAL_E)) + return; + + for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) + { + CachedEntity* pEntity = ENTITY(i); + + if (CE_BAD(pEntity)) + continue; + if (!pEntity->m_bAlivePlayer) + { + for (int j = 0; j < 13; j++) { + headPositions[i][j].hitboxpos = {0,0,0}; + headPositions[i][j].tickcount = 0; + } + continue; + } + if (pEntity->m_iTeam == LOCAL_E->m_iTeam) + continue; + + Vector hitboxpos = pEntity->hitboxes.GetHitbox(0)->center; + headPositions[i][cmd->command_number % 13] = BacktrackData{ cmd->tick_count, hitboxpos }; + + Vector ViewDir = angle_vector(cmd->viewangles); + float FOVDistance = distance_point_to_line(hitboxpos, g_pLocalPlayer->v_Eye, ViewDir); + + if (bestFov > FOVDistance) + { + bestFov = FOVDistance; + iBestTarget = i; + } + + if (iBestTarget != -1) + { + int bestTick = 0; + float tempFOV = 9999; + float bestFOV = 30; + Vector lowestDistTicks(180, 180, 0); + for (int t = 0; t < 12; ++t) + { + Vector ViewDir = angle_vector(cmd->viewangles); + float tempFOV = distance_point_to_line(headPositions[iBestTarget][t].hitboxpos, g_pLocalPlayer->v_Eye, ViewDir); + if (bestFOV > tempFOV) + bestTick = t, bestFOV = tempFOV; + } + + if (cmd->buttons & IN_ATTACK) + cmd->tick_count = headPositions[i][bestTick].tickcount; + } + + } + +} +void Draw() +{ +#if ENABLE_VISUALS + for (int i = 0; i < 24; i++) + for (int j = 0; j < 12; j++) + { + auto hbpos = headPositions[i][j].hitboxpos; + auto tickount = headPositions[i][j].tickcount; + if (!hbpos.x && !hbpos.y && !hbpos.z) + continue; + Vector out; + rgba_t color = colors::FromHSL(fabs(sin(j / 2.0f)) * 360.0f, + 0.85f, 0.9f); + if (draw::WorldToScreen(hbpos, out)) + { + draw_api::draw_rect(out.x, out.y, 3, 3, color); + } + } +#endif +} +} +} +} + + diff --git a/src/hooks/IsPlayingTimeDemo.cpp b/src/hooks/IsPlayingTimeDemo.cpp new file mode 100644 index 00000000..0d6c6c4b --- /dev/null +++ b/src/hooks/IsPlayingTimeDemo.cpp @@ -0,0 +1,19 @@ +/* + * IsPlayingTimeDemo.cpp + * + * Created on: May 13, 2018 + * Author: bencat07 + */ +#include "HookedMethods.hpp" +#include "MiscTemporary.hpp" + +namespace hooked_methods +{ +DEFINE_HOOKED_METHOD(IsPlayingTimeDemo, bool) +{ + if (nolerp) + return true; + else + return original::IsPlayingTimeDemo(); +} +} From 9b3989225743a67ca8aad1aae1c6aa3d7675121f Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Tue, 15 May 2018 18:23:52 +0200 Subject: [PATCH 2/2] . --- libglez | 1 - 1 file changed, 1 deletion(-) delete mode 160000 libglez diff --git a/libglez b/libglez deleted file mode 160000 index a8fc8b75..00000000 --- a/libglez +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a8fc8b75b1a8488a7a51e2575cb265b5ed24e36f