Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -------------------------------------------------------------------------------- //
- // CAimbot/ESP by Capt. Micro
- // -------------------------------------------------------------------------------- //
- class CAimbot
- {
- public:
- CAimbot();
- ~CAimbot();
- bool bShowRays;
- bool bAimbot;
- bool bFindHits;
- bool bEsp;
- float fMaxDist;
- IVDebugOverlay *debugoverlay;
- bool ReadyForUse(void);
- void ModifyUserCmd(CUserCmd *cmd);
- void DrawEspOverlay(void);
- //private:
- C_BaseEntity *target;
- C_BaseEntity *local;
- bool AimbotTraceRay(C_BaseEntity *ent, Vector &start, Vector &end);
- void AimbotGetAimPos(C_BaseEntity *ent, Vector &out);
- void AimbotGetAimAngle(C_BaseEntity *ent, QAngle &out);
- bool IsVisibleToLocalPlayer(C_BaseEntity *ent);
- void AimbotGetTarget(void);
- };
- CAimbot::CAimbot()
- {
- bShowRays = true;
- bAimbot = false;
- bFindHits = false;
- bEsp = true;
- fMaxDist = 4096.0f;
- debugoverlay = 0;
- target = 0;
- local = 0;
- }
- CAimbot::~CAimbot()
- {
- bShowRays = false;
- bAimbot = false;
- bFindHits = false;
- bEsp = false;
- fMaxDist = 0.0f;
- debugoverlay = 0;
- target = 0;
- local = 0;
- }
- bool CAimbot::ReadyForUse(void)
- {
- return (local != 0) || (debugoverlay != 0);
- }
- void CAimbot::ModifyUserCmd(CUserCmd *cmd)
- {
- if ((!bAimbot) || (target == 0) || (local == 0)) return;
- QAngle aimang;
- AimbotGetAimAngle(target, aimang);
- cmd->viewangles = aimang;
- }
- bool CAimbot::AimbotTraceRay(C_BaseEntity *ent, Vector &start, Vector &end)
- {
- Ray_t ray;
- trace_t trace;
- Vector scr;
- ray.Init(start, end);
- UTIL_TraceRay(ray, MASK_SHOT, local->GetBaseEntity(),
- COLLISION_GROUP_NONE, &trace);
- bool valid = (trace.m_pEnt == ent) && (ScreenTransform(end, scr) == 0);
- if (bShowRays && (debugoverlay != 0))
- debugoverlay->AddLineOverlay(start, end, (valid?0:255), (valid?255:0), 0, true, 0.1f);
- return valid;
- }
- void CAimbot::AimbotGetAimPos(C_BaseEntity *ent, Vector &out)
- {
- ent->EntityToWorldSpace(ent->CollisionProp()->OBBCenter(), &out);
- if (ent == local->GetBaseEntity())
- {
- out = local->EyePosition();
- }
- else
- {
- if (bFindHits)
- {
- Vector lbottom, wbottom;
- lbottom = ent->CollisionProp()->OBBMins();
- lbottom.x = abs(lbottom.x) / 2;
- lbottom.y = abs(lbottom.y) / 2;
- ent->EntityToWorldSpace(lbottom, &wbottom);
- Vector ltop, wtop;
- ltop = ent->CollisionProp()->OBBMaxs();
- ltop.x = abs(ltop.x) / 2;
- ltop.y = abs(ltop.y) / 2;
- ent->EntityToWorldSpace(ltop, &wtop);
- Vector wscan = wtop;
- Vector lpAimPos;
- AimbotGetAimPos(local, lpAimPos);
- for (; wscan.z <= wtop.z && wscan.z >= wbottom.z; wscan.z -= 1.0f)
- {
- if (AimbotTraceRay(ent, lpAimPos, wscan)) {
- if (bShowRays && (debugoverlay != 0))
- debugoverlay->AddLineOverlay(lpAimPos, wscan, 0, 255, 0, true, 0.1f);
- out = wscan;
- return;
- }
- }
- return;
- }
- out = ent->EyePosition();
- if (ent->BoundingRadius() >= 16) out.z -= 8;
- }
- }
- bool CAimbot::IsVisibleToLocalPlayer(C_BaseEntity *ent)
- {
- Vector start, end;
- AimbotGetAimPos(local, start);
- AimbotGetAimPos(ent, end);
- return AimbotTraceRay(ent, start, end);
- }
- void CAimbot::AimbotGetAimAngle(C_BaseEntity *ent, QAngle &out)
- {
- Vector epos, lpos;
- AimbotGetAimPos(ent, epos);
- AimbotGetAimPos(local, lpos);
- VectorAngles((epos - lpos), out);
- }
- void CAimbot::AimbotGetTarget(void)
- {
- if (!bAimbot || (local == 0)) return;
- C_BaseEntity *scanner[256];
- int ent_count = UTIL_EntitiesInSphere(scanner, 256,
- local->GetAbsOrigin(), fMaxDist, 0);
- float closest = fMaxDist;
- for (int i = 0; i < ent_count; i++)
- {
- if (target == 0 && (scanner[i] != NULL)
- && scanner[i]->IsAlive() && scanner[i]->IsNPC()
- && (scanner[i]->GetMoveType() != MOVETYPE_NONE)
- && (scanner[i]->GetMoveType() != MOVETYPE_OBSERVER)
- && IsVisibleToLocalPlayer(scanner[i]))
- {
- float dist = local->GetAbsOrigin().DistTo(scanner[i]->GetAbsOrigin());
- if (dist < closest) { closest = dist; target = scanner[i]; }
- break;
- }
- else if (target != 0)
- {
- if ((scanner[i] == target) &&
- (!scanner[i]->IsAlive() || !scanner[i]->IsNPC()
- || (scanner[i]->GetMoveType() == MOVETYPE_NONE)
- || (scanner[i]->GetMoveType() == MOVETYPE_OBSERVER)
- || !IsVisibleToLocalPlayer(scanner[i])))
- {
- target = 0;
- break;
- }
- }
- }
- }
- void CAimbot::DrawEspOverlay(void)
- {
- if (debugoverlay != 0)
- {
- debugoverlay->AddScreenTextOverlay(0.005f, 0.005f, 0.1f,
- 0, 0, 255, 200, "CAimbot/ESP");
- debugoverlay->AddScreenTextOverlay(0.005f, 0.020f, 0.1f,
- bAimbot?0:255, bAimbot?255:0, 0, 200, "bAimbot");
- debugoverlay->AddScreenTextOverlay(0.005f, 0.030f, 0.1f,
- bEsp?0:255, bEsp?255:0, 0, 200, "bEsp");
- debugoverlay->AddScreenTextOverlay(0.005f, 0.040f, 0.1f,
- bFindHits?0:255, bFindHits?255:0, 0, 200, "bFindHits");
- debugoverlay->AddScreenTextOverlay(0.005f, 0.050f, 0.1f,
- bShowRays?0:255, bShowRays?255:0, 0, 200, "bShowRays");
- }
- if (!bEsp || (debugoverlay == 0) || (local == 0)) return;
- C_BaseEntity *scanner[256];
- int ent_count = UTIL_EntitiesInSphere(scanner, 256,
- local->GetAbsOrigin(), fMaxDist, 0);
- for (int i = 0; i < ent_count; i++)
- {
- if ((scanner[i] != NULL)
- && scanner[i]->IsAlive() && scanner[i]->IsNPC())
- {
- /*Vector vec;
- AimbotGetAimPos(scanner[i], vec);
- debugoverlay->AddTextOverlayRGB(vec, 0, 0.05f, 0, 0, 255, 200, "^");*/
- CCollisionProperty *pCollide = scanner[i]->CollisionProp();
- if (pCollide == 0) continue;
- debugoverlay->AddBoxOverlay(scanner[i]->GetAbsOrigin(),
- pCollide->OBBMins(), pCollide->OBBMaxs(),
- scanner[i]->GetAbsAngles(), 255, 0, 0, 5, 0.1f);
- }
- }
- if (target != 0)
- {
- CCollisionProperty *pCollide = target->CollisionProp();
- debugoverlay->AddBoxOverlay(target->GetAbsOrigin(),
- pCollide->OBBMins(), pCollide->OBBMaxs(),
- target->GetAbsAngles(), 0, 0, 255, 10, 0.1f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement