-
Автор темы
- #1
Добрый вечер! Случилась такая проблема. У меня отбрасывает камеру при стрельбе в кс го. Подскажите пожалуйста, как это исправить. Видео с проблемой:
код:
Пожалуйста, авторизуйтесь для просмотра ссылки.
м ПРОСЬБА МОДЕРАМ, НЕ СНОСИТЬ ДАННУЮ ТЕМУ!!!!!!!!!!!!!!!!!!код:
Код:
#include "aimbot.hpp"
#include "../helpers/math.hpp"
#include "../menu.hpp"
#include "../helpers/input.hpp"
#include "autowall.hpp"
#include <chrono>
std::map<const char*, HMODULE> modules;
HMODULE GetModule(const char* name)
{
if (!modules.count(name) || !modules[name])
modules[name] = GetModuleHandleA(name);
return modules[name];
}
std::uint8_t* PatternScan2(const char* module_name, const char* signature)
{
auto module = GetModule(module_name);
static auto pattern_to_byte = [](const char* pattern) {
auto bytes = std::vector<int>{};
auto start = const_cast<char*>(pattern);
auto end = const_cast<char*>(pattern) + strlen(pattern);
for (auto current = start; current < end; ++current) {
if (*current == '?') {
++current;
if (*current == '?')
++current;
bytes.push_back(-1);
}
else {
bytes.push_back(strtoul(current, ¤t, 16));
}
}
return bytes;
};
auto dosHeader = (PIMAGE_DOS_HEADER)module;
auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)module + dosHeader->e_lfanew);
auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
auto patternBytes = pattern_to_byte(signature);
auto scanBytes = reinterpret_cast<std::uint8_t*>(module);
auto s = patternBytes.size();
auto d = patternBytes.data();
for (auto i = 0ul; i < sizeOfImage - s; ++i) {
bool found = true;
for (auto j = 0ul; j < s; ++j) {
if (scanBytes[i + j] != d[j] && d[j] != -1) {
found = false;
break;
}
}
if (found) {
return &scanBytes[i];
}
}
return nullptr;
}
float CLegitbot::GetFovToPlayer(QAngle viewAngle, QAngle aimAngle)
{
QAngle delta = aimAngle - viewAngle;
Math::FixAngles(delta);
return sqrtf(powf(delta.x, 2.0f) + powf(delta.y, 2.0f)); /// (powf(delta.x, 2.0f) + powf(delta.y, 2.0f));
}
bool CLegitbot::IsLineGoesThroughSmoke(Vector startPos, Vector endPos)
{
static auto LineGoesThroughSmokeFn = (bool(*)(Vector, Vector))PatternScan2("client.dll", "55 8B EC 83 EC 08 8B 15 ? ? ? ? 0F 57 C0");
return LineGoesThroughSmokeFn(startPos, endPos);
}
bool CLegitbot::IsRcs()
{
if (!g_LocalPlayer) return false;
return g_LocalPlayer->m_iShotsFired() >= settings.rcs.start + 1;
}
bool CLegitbot::IsEnabled(CUserCmd* cmd)
{
if (!g_EngineClient->IsInGame() || !g_LocalPlayer)
return false;
if (!g_LocalPlayer->IsAlive())
return false;
auto weapon = g_LocalPlayer->m_hActiveWeapon();
if (!weapon || !weapon->IsGun())
return false;
settings = g_Options.aim_settings[weapon->m_iItemDefinitionIndex()].legit;
if (!settings.enabled)
return false;
//if (!settings.enabled || !(cmd->buttons & IN_ATTACK)) {
//return false;
if (!weapon->HasBullets())
return false;
return (cmd->buttons & IN_ATTACK);
return (cmd->buttons & IN_ATTACK) || (settings.autofire.enabled && GetAsyncKeyState(settings.autofire.hotkey));
}
void CLegitbot::Smooth(QAngle currentAngle, QAngle aimAngle, QAngle& angle)
{
auto smooth_value = max(1.0f, settings.smooth);
Vector current, aim;
Math::AngleVectors(currentAngle, current);
Math::AngleVectors(aimAngle, aim);
const Vector delta = aim - current;
const Vector smoothed = current + delta / smooth_value;
Math::VectorAngles(smoothed, angle);
}
void CLegitbot::RCS(QAngle& angle, C_BasePlayer* target, CUserCmd* cmd)
{
if (!settings.rcs.enabled || shotsFired < settings.rcs.start - 30)
return;
if (!settings.rcs.x && !settings.rcs.y)
return;
auto x = settings.rcs.x;
auto y = settings.rcs.y;
static auto weapon_recoil_scale = g_CVar->FindVar("weapon_recoil_scale");
float scale = weapon_recoil_scale->GetFloat();
if (scale != 2.f)
{
x = scale * x / 2.f;
y = scale * y / 2.f;
}
x = scale *= 1.26f;
y = scale;
if (x <= 0 && y <= 0)
return;
QAngle punch = { };
if (target)
punch = { current_punch.x * x, current_punch.y * y, 0 };
else if (settings.rcs.type == 0)
punch = { (current_punch.x - last_punch.x) * x, (current_punch.y - last_punch.y) * y, 0 };
if ((punch.x != 0.f || punch.y != 0.f) && g_LocalPlayer->m_aimPunchAngle().z == 0.f)
{
angle -= punch;
angle.Normalized();
}
last_corrected = punch;
}
/*void CLegitbot::RCS(QAngle& angle, C_BasePlayer* target)
{
if (!settings.rcs.enabled || !IsRcs()) {
return;
}
if (settings.rcs.x == 0 && settings.rcs.y == 0) {
return;
}
if (target) {
QAngle punch = g_LocalPlayer->m_aimPunchAngle();
angle.x -= punch.x * (settings.rcs.x / 50.f);
angle.y -= punch.y * (settings.rcs.y / 50.f);
}
else if (settings.rcs.type == 0) {
QAngle NewPunch = { current_punch.x - last_punch.x, current_punch.y - last_punch.y, 0 };
angle.x -= NewPunch.x * (settings.rcs.x / 50.f);
angle.y -= NewPunch.y* (settings.rcs.y / 50.f);
}
Math::FixAngles(angle);
}*/
/*void CLegitbot::RCS(QAngle& angle, C_BasePlayer* target)
{
if (!g_LocalPlayer)
return;
if (!settings.rcs.enabled || !IsRcs()) {
return;
}
if (settings.rcs.x == 0 && settings.rcs.y == 0) {
return;
}
if (target) {
QAngle punch = g_LocalPlayer->m_aimPunchAngle();
float x = settings.rcs.x * 0.02f;
float y = settings.rcs.y * 0.02f;
angle.x -= punch.x * x;
angle.y -= punch.y * y;
}
Math::Normalize3(angle);
Math::ClampAngles(angle);
}*/
bool CLegitbot::IsSilent()
{
if (settings.silent2 == 2)
return !(shotsFired > 0 || !settings.silent2 || !settings.silent_fov);
if (settings.silent2 == 1)
return !(!settings.silent2 || !settings.silent_fov);
if (settings.silent2 == 0)
return !(shotsFired > 0 || !settings.silent2 || !settings.silent_fov);
}
float CLegitbot::GetFov()
{
if (IsSilent())
return settings.silent_fov;
return settings.fov;
}
bool CLegitbot::autoweapon() {
if (!g_LocalPlayer->m_hActiveWeapon())
return false;
if (!g_LocalPlayer->IsNotTarget())
return false;
if (g_LocalPlayer->m_hActiveWeapon()->IsGrenade())
return false;
if (g_LocalPlayer->m_hActiveWeapon()->IsKnife())
return false;
if (g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_TASER ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_FISTS ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_BREACHCHARGE ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_TABLET ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_MELEE ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_AXE ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_HAMMER ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_KNIFE_GHOST ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_FIREBOMB ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_DIVERSION ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_FRAG_GRENADE ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_C4 ||
g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex() == WEAPON_HEALTHSHOT
)
return false;
Weapon::current_weapon = g_LocalPlayer->m_hActiveWeapon()->m_iItemDefinitionIndex();
return true;
}
C_BasePlayer* CLegitbot::GetClosestPlayer(CUserCmd* cmd, int& bestBone, float& bestFov, QAngle& bestAngles)
{
if (target && !kill_delay && settings.kill_delay > 0 && !target->IsAlive())
{
target = nullptr;
kill_delay = true;
kill_delay_time = int(GetTickCount()) + settings.kill_delay;
}
if (kill_delay)
{
if (kill_delay_time <= int(GetTickCount()))
kill_delay = false;
else
return nullptr;
}
target = nullptr;
std::vector<int> hitboxes;
if (settings.hitboxes.head) {
hitboxes.push_back(HITBOX_HEAD);
}
/////////////////////////////
if (settings.hitboxes.neck)
hitboxes.push_back(HITBOX_NECK);
if (settings.hitboxes.belly)
hitboxes.push_back(HITBOX_STOMACH);
if (settings.hitboxes.chest)
{
hitboxes.push_back(HITBOX_CHEST);
hitboxes.push_back(HITBOX_LOWER_CHEST);
hitboxes.push_back(HITBOX_UPPER_CHEST);
}
/*if (settings.hitboxes.chest)
{
hitboxes.emplace_back(HITBOX_UPPER_CHEST);
hitboxes.emplace_back(HITBOX_CHEST);
hitboxes.emplace_back(HITBOX_LOWER_CHEST);
}*/
if (settings.hitboxes.hands)
{
hitboxes.push_back(HITBOX_RIGHT_UPPER_ARM);
hitboxes.push_back(HITBOX_RIGHT_FOREARM);
hitboxes.push_back(HITBOX_LEFT_UPPER_ARM);
hitboxes.push_back(HITBOX_LEFT_FOREARM);
hitboxes.push_back(HITBOX_RIGHT_HAND);
hitboxes.push_back(HITBOX_LEFT_HAND);
}
/*if (settings.hitboxes.hands)
{
hitboxes.emplace_back(HITBOX_LEFT_FOREARM);
hitboxes.emplace_back(HITBOX_LEFT_HAND);
hitboxes.emplace_back(HITBOX_LEFT_UPPER_ARM);
hitboxes.emplace_back(HITBOX_RIGHT_FOREARM);
hitboxes.emplace_back(HITBOX_RIGHT_HAND);
hitboxes.emplace_back(HITBOX_RIGHT_UPPER_ARM);
}*/
if (settings.hitboxes.legs)
{
hitboxes.push_back(HITBOX_LEFT_FOOT);
hitboxes.push_back(HITBOX_RIGHT_FOOT);
hitboxes.push_back(HITBOX_LEFT_THIGH);
hitboxes.push_back(HITBOX_RIGHT_THIGH);
hitboxes.push_back(HITBOX_LEFT_CALF);
hitboxes.push_back(HITBOX_RIGHT_CALF);
}
/*if (settings.hitboxes.legs)
{
hitboxes.emplace_back(HITBOX_LEFT_FOOT);
hitboxes.emplace_back(HITBOX_LEFT_CALF);
hitboxes.emplace_back(HITBOX_LEFT_THIGH);
hitboxes.emplace_back(HITBOX_RIGHT_FOOT);
hitboxes.emplace_back(HITBOX_LEFT_CALF);
hitboxes.emplace_back(HITBOX_LEFT_THIGH);
}*/
const Vector eyePos = g_LocalPlayer->GetEyePos();
for (auto i = 1; i <= g_GlobalVars->maxClients; i++) //g_GlobalVars->maxClients
{
C_BasePlayer* player = C_BasePlayer::GetPlayerByIndex(i);
if (!player || !player->IsAlive() || !player->IsPlayer() || player->m_bGunGameImmunity())
continue;
//if (!player->IsEnemy())
//continue;
for (const auto hitbox : hitboxes)
{
Vector hitboxPos = player->GetHitboxPos(hitbox);
QAngle ang;
Math::VectorAngles(hitboxPos - eyePos, ang);
const float fov = GetFovToPlayer(cmd->viewangles + last_punch * 2.f, ang);
if (fov > GetFov())
continue;
if (!g_LocalPlayer->CanSeePlayer(player, player->abs_origin()))
continue;
if (settings.smoke_check && IsLineGoesThroughSmoke(eyePos, hitboxPos))
continue;
if (bestFov > fov)
{
bestBone = hitbox;
bestAngles = ang;
bestFov = fov;
target = player;
}
}
}
return target;
}
void CLegitbot::Run(CUserCmd* cmd)
{
if (int(GetTickCount()) > lastShotTick + 50)
shotsFired = 0;
if (!IsEnabled(cmd))
{
last_punch = { 0, 0, 0 };
shot_delay = false;
kill_delay = false;
target = nullptr;
return;
}
auto weapon = g_LocalPlayer->m_hActiveWeapon().Get();
if (!weapon)
return;
auto weapon_data = weapon->GetCSWeaponData();
if (!weapon_data)
return;
if (settings.flash_check && g_LocalPlayer->IsFlashed())
return;
auto angles = cmd->viewangles;
const auto current = angles;
float fov = FLT_MAX;
int bestBone = -1;
if (GetClosestPlayer(cmd, bestBone, fov, angles))
{
if ((!settings.silent2 || settings.silent2 == 2) && !shot_delay && settings.shot_delay > 0 && !shotsFired)
{
shot_delay = true;
shot_delay_time = int(GetTickCount()) + settings.shot_delay;
}
if (fov <= .5)
shot_delay = false;
if (shot_delay && shot_delay_time <= int(GetTickCount()))
shot_delay = false;
if (shot_delay)
cmd->buttons &= ~IN_ATTACK;
if (settings.autofire.enabled && GetAsyncKeyState(settings.autofire.hotkey))
cmd->buttons |= IN_ATTACK;
}
current_punch = g_LocalPlayer->m_aimPunchAngle();
{
if (cmd->buttons & IN_ATTACK)
RCS(angles, target ,cmd);
}
last_punch = current_punch;
if (!IsSilent() && target)
Smooth(current, angles, angles);
Math::FixAngles(angles);
cmd->viewangles = angles;
if (!IsSilent())
g_EngineClient->SetViewAngles(&angles);
if (g_LocalPlayer->m_hActiveWeapon()->IsPistol() && settings.autopistol)
{
const float server_time = g_LocalPlayer->m_nTickBase() * g_GlobalVars->interval_per_tick;
const float next_shot = g_LocalPlayer->m_hActiveWeapon()->m_flNextPrimaryAttack() - server_time;
if (next_shot > 0)
cmd->buttons &= ~IN_ATTACK;
}
if (cmd->buttons & IN_ATTACK)
{
lastShotTick = GetTickCount();
shotsFired + 3;
}
}