Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LagComp.cpp
- #include "LagComp.h"
- using namespace SDK;
- void BackTrack::Update(int tick_count)
- {
- latest_tick = tick_count;
- for (int i = 0; i < 64; i++)
- {
- UpdateRecord(i);
- }
- }
- int BackTrack::BacktrackTicks()
- {
- // Gets server tickrate
- float timepertick = Interfaces::GlobalVars()->interval_per_tick;
- if (timepertick == 0) timepertick += 0.001; // prevents game from crashing when unconnected
- float tickrate = 1 / timepertick;
- // actual b1g calculations yay
- int BacktrackTicks = Settings::Aimbot::aim_Backtracktime / 200 * tickrate; // slider from 1-200ms
- if (BacktrackTicks < 1) return 1; //prevents crash, thank me l8r
- else return BacktrackTicks;
- }
- bool BackTrack::IsTickValid(int tick)
- {
- int delta = latest_tick - tick;
- float deltaTime = delta * Interfaces::GlobalVars()->interval_per_tick;
- return (fabs(deltaTime) <= 0.2f); // edited, come back to this overtime.
- }
- void BackTrack::UpdateRecord(int i)
- {
- CBaseEntity* pEntity = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(i);
- if (pEntity && !pEntity->IsDead() && !pEntity->IsDormant())
- {
- float lby = pEntity->GetLowerBodyYaw();
- if (lby != records[i].lby)
- {
- records[i].tick_count = latest_tick;
- records[i].lby = lby;
- records[i].headPosition = pEntity->GetHitboxPosition(0);
- }
- }
- else
- {
- records[i].tick_count = 0;
- }
- }
- bool BackTrack::RunLBYBackTrack(int i, CUserCmd* cmd, Vector& aimPoint)
- {
- if (IsTickValid(records[i].tick_count))
- {
- aimPoint = records[i].headPosition;
- cmd->tick_count = records[i].tick_count;
- return true;
- }
- return false;
- }
- void BackTrack::legitBackTrack(CUserCmd* cmd)
- {
- if (Settings::Aimbot::aim_Backtrack)
- {
- int bestTargetIndex = -1;
- float bestFov = FLT_MAX;
- CBaseEntity* pLocal = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(Interfaces::Engine()->GetLocalPlayer());
- PlayerInfo info;
- if (pLocal->IsDead())
- return;
- for (int i = 0; i < Interfaces::Engine()->GetMaxClients(); i++)
- {
- auto entity = (CBaseEntity*)Interfaces::EntityList()->GetClientEntity(i);
- if (!entity || !pLocal)
- continue;
- if (entity == pLocal)
- continue;
- if (!Interfaces::Engine()->GetPlayerInfo(i, &info))
- continue;
- if (entity->IsDormant())
- continue;
- if (entity->GetTeam() == pLocal->GetTeam())
- continue;
- if (!entity->IsDead())
- {
- float simtime = entity->GetSimTime();
- Vector hitboxPos = entity->GetHitboxPosition(0);
- headPositions[i][cmd->command_number % BacktrackTicks()] = backtrackData{ simtime, hitboxPos };
- Vector ViewDir = angle_vector(cmd->viewangles + (pLocal->GetAimPunchAngle() * 2.f));
- float FOVDistance = distance_point_to_line(hitboxPos, pLocal->GetEyePosition(), ViewDir);
- if (bestFov > FOVDistance)
- {
- bestFov = FOVDistance;
- bestTargetIndex = i;
- }
- }
- }
- float bestTargetSimTime;
- if (bestTargetIndex != -1)
- {
- float tempFloat = FLT_MAX;
- Vector ViewDir = angle_vector(cmd->viewangles + (pLocal->GetAimPunchAngle() * 2.f));
- for (int t = 0; t < BacktrackTicks(); ++t)
- {
- float tempFOVDistance = distance_point_to_line(headPositions[bestTargetIndex][t].hitboxPos, pLocal->GetEyePosition(), ViewDir);
- if (tempFloat > tempFOVDistance && headPositions[bestTargetIndex][t].simtime > pLocal->GetSimTime() - 1)
- {
- tempFloat = tempFOVDistance;
- bestTargetSimTime = headPositions[bestTargetIndex][t].simtime;
- }
- }
- cmd->tick_count = TIME_TO_TICKS(bestTargetSimTime);
- }
- }
- }
- BackTrack* backtracking = new BackTrack();
- backtrackData headPositions[64][25]; //support for 128tick servers
- LagComp.h
- #pragma once
- #include "../../Engine/Engine.h"
- #define PI 3.14159265358979323846f
- #define MAXBACKTRACKTICKS ((int)Settings::Aimbot::aim_Backtracktime)
- #define TICK_INTERVAL (Interfaces::GlobalVars()->interval_per_tick)
- #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
- inline Vector angle_vector(Vector meme)
- {
- auto sy = sin(meme.y / 180.f * static_cast<float>(PI));
- auto cy = cos(meme.y / 180.f * static_cast<float>(PI));
- auto sp = sin(meme.x / 180.f * static_cast<float>(PI));
- auto cp = cos(meme.x / 180.f* static_cast<float>(PI));
- return Vector(cp*cy, cp*sy, -sp);
- }
- 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();
- }
- namespace SDK
- {
- struct lbyRecords
- {
- int tick_count;
- float lby;
- Vector headPosition;
- };
- struct backtrackData
- {
- float simtime;
- Vector hitboxPos;
- };
- class BackTrack
- {
- int latest_tick;
- bool IsTickValid(int tick);
- void UpdateRecord(int i);
- public:
- lbyRecords records[64];
- bool RunLBYBackTrack(int i, CUserCmd* cmd, Vector& aimPoint);
- void legitBackTrack(CUserCmd * cmd);
- void Update(int tick_count);
- int BacktrackTicks();
- };
- }
- extern backtrackData headPositions[64][25]; //same
- extern BackTrack* backtracking;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement