Я у мамы даун
-
Автор темы
- #1
cpp
#include "legitbot.h"
int besthitbox(player_t* e, Vector& ang)
{
return HITBOX_HEAD;
}
void legitbot::create_move()
{
sync();
Aim();
}
void legitbot::sync()
{
auto weapon = g_ctx.m_local->m_hActiveWeapon().Get();
if (weapon->is_pistol())
{
fov = SETTINGS::settings.fov_pistol;
smooth = SETTINGS::settings.smooth_pistol;
rcs_enable = SETTINGS::settings.rcs_pistol;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_pistol;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_pistol;
smoke_check = SETTINGS::settings.smoke_check_pistol;
jump_check = SETTINGS::settings.jump_check_pistol;
}
else if (weapon->is_smg())
{
fov = SETTINGS::settings.fov_smg;
smooth = SETTINGS::settings.smooth_smg;
rcs_enable = SETTINGS::settings.rcs_smg;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_smg;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_smg;
smoke_check = SETTINGS::settings.smoke_check_smg;
jump_check = SETTINGS::settings.jump_check_smg;
}
else if (weapon->is_shotgun())
{
fov = SETTINGS::settings.fov_shotgun;
smooth = SETTINGS::settings.smooth_shotgun;
rcs_enable = SETTINGS::settings.rcs_shotgun;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_shotgun;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_shotgun;
smoke_check = SETTINGS::settings.smoke_check_shotgun;
jump_check = SETTINGS::settings.jump_check_shotgun;
}
else if (weapon->is_mashinegun())
{
fov = SETTINGS::settings.fov_mashinegun;
smooth = SETTINGS::settings.smooth_mashinegun;
rcs_enable = SETTINGS::settings.rcs_mashinegun;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_mashinegun;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_mashinegun;
smoke_check = SETTINGS::settings.smoke_check_mashinegun;
jump_check = SETTINGS::settings.jump_check_mashinegun;
}
else if (weapon->is_rifle())
{
fov = SETTINGS::settings.fov_rifle;
smooth = SETTINGS::settings.smooth_rifle;
rcs_enable = SETTINGS::settings.rcs_rifle;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_pistol;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_rifle;
smoke_check = SETTINGS::settings.smoke_check_rifle;
jump_check = SETTINGS::settings.jump_check_rifle;
}
else if (weapon->is_sniper())
{
fov = SETTINGS::settings.fov_sniper;
smooth = SETTINGS::settings.smooth_sniper;
rcs_enable = SETTINGS::settings.rcs_sniper;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_sniper;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_sniper;
smoke_check = SETTINGS::settings.smoke_check_sniper;
jump_check = SETTINGS::settings.jump_check_sniper;
scope_check = SETTINGS::settings.scope_check;
}
}
player_t* legitbot::GetEnemyToCrosshair(Vector & viewAngles)
{
g_csgo.m_engine()->GetViewAngles(viewAngles);
float bestdelta = FLT_MAX;
player_t* bestEntity = nullptr;
for (size_t i = 1; i <= 64; i++)
{
auto m_local = g_ctx.m_local;
auto e = static_cast<player_t*>(g_csgo.m_entitylist()->GetClientEntity(i));
if (e && !e->IsDormant() && e->m_iHealth() > 0 && e->m_iTeamNum() != g_ctx.m_local->m_iTeamNum())
{
float delta = math::get_fov(g_ctx.m_local->m_vecOrigin() + g_ctx.m_local->m_vecViewOffset(), viewAngles, e, besthitbox(e, viewAngles));
if (delta < bestdelta && delta < fov)
{
bestdelta = delta;
bestEntity = e;
}
}
}
return bestEntity;
}
bool legitbot::Aim()
{
auto weapon = g_ctx.m_local->m_hActiveWeapon().Get();
if (SETTINGS::settings.enable_legit && GetAsyncKeyState(VK_LBUTTON) && !weapon->is_non_aim())
{
Vector viewAngles;
g_csgo.m_engine()->GetViewAngles(viewAngles);
player_t* e = legitbot::get().GetEnemyToCrosshair(viewAngles);
if (!flash_check && g_ctx.m_local->m_flFlashDuration() <= 0.f)
return false;
if (!smoke_check && util::LineGoesThroughSmoke(g_ctx.m_local->get_eye_pos(), e->hitbox_position(besthitbox(e, viewAngles))))
return false;
if (!jump_check && g_ctx.m_local->m_fFlags() & FL_ONGROUND)
return false;
if (e && e != nullptr && e->IsVisible(besthitbox(e, viewAngles), e))
{
Vector angle = math::calculate_angle(g_ctx.m_local->get_eye_pos(), e->get_eye_pos());
Vector aim_angle = (angle - g_ctx.m_local->m_aimPunchAngle() * (rcs_ammount / 50)).Clamp();
legitbot::get().Smooth(viewAngles, aim_angle, smooth / 4);
if (!SETTINGS::settings.legit_silient)
g_csgo.m_engine()->SetViewAngles(aim_angle);
else
g_ctx.get_command()->m_viewangles = aim_angle;
return true;
}
}
return false;
}
void legitbot::Smooth(Vector & viewAngles, Vector & angle, float smoothvalue)
{
if (smoothvalue != 0)
{
angle = (viewAngles + (angle - viewAngles).Clamp() / smoothvalue).Clamp();
}
}
hpp
class legitbot : public singleton< legitbot >
{
public:
void create_move();
private:
bool Aim();
player_t * GetEnemyToCrosshair(Vector & viewAngles);
void Smooth(Vector & viewAngles, Vector & angle, float smoothvalue);
void sync();
float fov;
float smooth;
bool rcs_enable;
float rcs_ammount;
bool smoke_check;
bool flash_check;
bool jump_check;
bool scope_check;
bool silient;
float silient_fov;
};
#include "legitbot.h"
int besthitbox(player_t* e, Vector& ang)
{
return HITBOX_HEAD;
}
void legitbot::create_move()
{
sync();
Aim();
}
void legitbot::sync()
{
auto weapon = g_ctx.m_local->m_hActiveWeapon().Get();
if (weapon->is_pistol())
{
fov = SETTINGS::settings.fov_pistol;
smooth = SETTINGS::settings.smooth_pistol;
rcs_enable = SETTINGS::settings.rcs_pistol;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_pistol;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_pistol;
smoke_check = SETTINGS::settings.smoke_check_pistol;
jump_check = SETTINGS::settings.jump_check_pistol;
}
else if (weapon->is_smg())
{
fov = SETTINGS::settings.fov_smg;
smooth = SETTINGS::settings.smooth_smg;
rcs_enable = SETTINGS::settings.rcs_smg;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_smg;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_smg;
smoke_check = SETTINGS::settings.smoke_check_smg;
jump_check = SETTINGS::settings.jump_check_smg;
}
else if (weapon->is_shotgun())
{
fov = SETTINGS::settings.fov_shotgun;
smooth = SETTINGS::settings.smooth_shotgun;
rcs_enable = SETTINGS::settings.rcs_shotgun;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_shotgun;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_shotgun;
smoke_check = SETTINGS::settings.smoke_check_shotgun;
jump_check = SETTINGS::settings.jump_check_shotgun;
}
else if (weapon->is_mashinegun())
{
fov = SETTINGS::settings.fov_mashinegun;
smooth = SETTINGS::settings.smooth_mashinegun;
rcs_enable = SETTINGS::settings.rcs_mashinegun;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_mashinegun;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_mashinegun;
smoke_check = SETTINGS::settings.smoke_check_mashinegun;
jump_check = SETTINGS::settings.jump_check_mashinegun;
}
else if (weapon->is_rifle())
{
fov = SETTINGS::settings.fov_rifle;
smooth = SETTINGS::settings.smooth_rifle;
rcs_enable = SETTINGS::settings.rcs_rifle;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_pistol;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_rifle;
smoke_check = SETTINGS::settings.smoke_check_rifle;
jump_check = SETTINGS::settings.jump_check_rifle;
}
else if (weapon->is_sniper())
{
fov = SETTINGS::settings.fov_sniper;
smooth = SETTINGS::settings.smooth_sniper;
rcs_enable = SETTINGS::settings.rcs_sniper;
if (rcs_enable) rcs_ammount = SETTINGS::settings.rcs_ammount_sniper;
else rcs_ammount = 0;
flash_check = SETTINGS::settings.flash_check_sniper;
smoke_check = SETTINGS::settings.smoke_check_sniper;
jump_check = SETTINGS::settings.jump_check_sniper;
scope_check = SETTINGS::settings.scope_check;
}
}
player_t* legitbot::GetEnemyToCrosshair(Vector & viewAngles)
{
g_csgo.m_engine()->GetViewAngles(viewAngles);
float bestdelta = FLT_MAX;
player_t* bestEntity = nullptr;
for (size_t i = 1; i <= 64; i++)
{
auto m_local = g_ctx.m_local;
auto e = static_cast<player_t*>(g_csgo.m_entitylist()->GetClientEntity(i));
if (e && !e->IsDormant() && e->m_iHealth() > 0 && e->m_iTeamNum() != g_ctx.m_local->m_iTeamNum())
{
float delta = math::get_fov(g_ctx.m_local->m_vecOrigin() + g_ctx.m_local->m_vecViewOffset(), viewAngles, e, besthitbox(e, viewAngles));
if (delta < bestdelta && delta < fov)
{
bestdelta = delta;
bestEntity = e;
}
}
}
return bestEntity;
}
bool legitbot::Aim()
{
auto weapon = g_ctx.m_local->m_hActiveWeapon().Get();
if (SETTINGS::settings.enable_legit && GetAsyncKeyState(VK_LBUTTON) && !weapon->is_non_aim())
{
Vector viewAngles;
g_csgo.m_engine()->GetViewAngles(viewAngles);
player_t* e = legitbot::get().GetEnemyToCrosshair(viewAngles);
if (!flash_check && g_ctx.m_local->m_flFlashDuration() <= 0.f)
return false;
if (!smoke_check && util::LineGoesThroughSmoke(g_ctx.m_local->get_eye_pos(), e->hitbox_position(besthitbox(e, viewAngles))))
return false;
if (!jump_check && g_ctx.m_local->m_fFlags() & FL_ONGROUND)
return false;
if (e && e != nullptr && e->IsVisible(besthitbox(e, viewAngles), e))
{
Vector angle = math::calculate_angle(g_ctx.m_local->get_eye_pos(), e->get_eye_pos());
Vector aim_angle = (angle - g_ctx.m_local->m_aimPunchAngle() * (rcs_ammount / 50)).Clamp();
legitbot::get().Smooth(viewAngles, aim_angle, smooth / 4);
if (!SETTINGS::settings.legit_silient)
g_csgo.m_engine()->SetViewAngles(aim_angle);
else
g_ctx.get_command()->m_viewangles = aim_angle;
return true;
}
}
return false;
}
void legitbot::Smooth(Vector & viewAngles, Vector & angle, float smoothvalue)
{
if (smoothvalue != 0)
{
angle = (viewAngles + (angle - viewAngles).Clamp() / smoothvalue).Clamp();
}
}
hpp
class legitbot : public singleton< legitbot >
{
public:
void create_move();
private:
bool Aim();
player_t * GetEnemyToCrosshair(Vector & viewAngles);
void Smooth(Vector & viewAngles, Vector & angle, float smoothvalue);
void sync();
float fov;
float smooth;
bool rcs_enable;
float rcs_ammount;
bool smoke_check;
bool flash_check;
bool jump_check;
bool scope_check;
bool silient;
float silient_fov;
};