-
Автор темы
- #1
C++:
vec2_t Aimbot::calc_spread_angle( const int bullets, const float recoil_index, const std::size_t i ) const {
if ( !g_cl.m_weapon ) // sanity
return vec2_t( 0.f, 0.f ); // or any other default value that makes sense in your context -- dutu
g_csgo.RandomSeed( i + 1u );
auto v1 = g_csgo.RandomFloat( 0.f, 1.f );
auto v2 = g_csgo.RandomFloat( 0.f, math::k_pi2 );
float v3{}, v4{};
using fn_t = void( __stdcall* )( Weapons_t, int, int, float*, float* );
if ( g_csgo.m_weapon_accuracy_shotgun_spread_patterns->GetInt( ) > 0 ) {
// we are supposed to calc shotgun spread so fuck it i dont need it
}
else {
v3 = g_csgo.RandomFloat( 0.f, 1.f );
v4 = g_csgo.RandomFloat( 0.f, math::k_pi2 );
}
// we dont play negev and dont use it
// so we don't set it up
//dutu--
const auto inaccuracy = v1 * g_cl.m_weapon->GetInaccuracy( );// g_eng_pred->inaccuracy( );
const auto spread = v3 * g_cl.m_weapon->GetSpread( );
return {
std::cos( v2 ) * inaccuracy + std::cos( v4 ) * spread,
std::sin( v2 ) * inaccuracy + std::sin( v4 ) * spread
};
}
int Aimbot::calc_hit_chance( Player* player, const ang_t& angle ) { // nemesis hc
if ( g_csgo.m_weapon_accuracy_nospread->GetBool( ) )
return 100;
auto min_dmg = settings.minimal_damage + 1;
min_dmg = std::clamp( static_cast< int >( min_dmg * ( settings.acuracy_bost / 100.f ) ), 1, 100 );
vec3_t fwd{}, right{}, up{};
math::angle_vectors( angle, &fwd, &right, &up );
const auto item_index = g_cl.m_weapon->m_iItemDefinitionIndex( );// g_context->weapon( )->item_index( );
const auto recoil_index = g_cl.m_weapon->m_flRecoilIndex( ); //g_context->weapon( )->recoil_index( );
int hits{};
const auto trace_spread = [ ]( const vec3_t& fwd, const vec3_t& right, const vec3_t& up,
const Player* const target, const int accuracy_boost, const float recoil_index,
const int min_dmg, const std::size_t i, bool& hit ) {
const auto spread_angle = g_aimbot.calc_spread_angle( g_cl.m_weapon_info->m_bullets, recoil_index, i );
auto dir = fwd + ( right * spread_angle.x ) + ( up * spread_angle.y );
dir. normalize( );
// gheto -- dutu
hit = settings.penetrate_minimal_damage > 0 && ( accuracy_boost <= 0 || settings.penetrate_minimal_damage >= min_dmg );
};
constexpr auto k_max_seeds = 128u;
std::array< bool, k_max_seeds > seeds{};
for ( std::size_t i{}; i < k_max_seeds; ++i )
trace_spread( fwd, right, up, player, settings.acuracy_bost, recoil_index, min_dmg, i, seeds.at( i ) );
for ( auto& hit : seeds )
if (hit)
++hits;
return static_cast< int >( ( hits / 128.f ) * 100.f );
}