Начинающий
-
Автор темы
- #1
По фану закинул хитшанс который будет лучше чем сливали двое недавно...
C++:
static std::vector<std::tuple<float, float, float>> precomputed_seeds = {};
__forceinline void build_seed_table()
{
if (!precomputed_seeds.empty())
return;
for (auto i = 0; i < 255; i++) {
math::random_seed(i + 1);
const auto pi_seed = math::random_float(0.f, twopi);
precomputed_seeds.emplace_back(math::random_float(0.f, 1.f),
sin(pi_seed), cos(pi_seed));
}
}
bool aim::Hitchance(int& final_hitchance)
{
build_seed_table();
const auto info = g_ctx.globals.weapon->get_csweapon_info();
if (!info)
{
final_hitchance = 0;
return true;
}
const auto hitchance_cfg = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].hitchance_amount;
if ((g_ctx.globals.eye_pos - final_target.data.point.point).Length() > info->flRange)
{
final_hitchance = 0;
return true;
}
static auto nospread = m_cvar()->FindVar(crypt_str("weapon_accuracy_nospread"));
if (nospread->GetBool())
{
final_hitchance = INT_MAX;
return true;
}
const auto weapon_inaccuracy = g_ctx.globals.weapon->get_inaccuracy();
static auto weapon_recoil_scale = m_cvar()->FindVar(crypt_str("weapon_recoil_scale"));
const auto aim_angle = math::calculate_angle(g_ctx.globals.eye_pos, final_target.data.point.point) - (g_ctx.local()->m_aimPunchAngle() * weapon_recoil_scale->GetFloat());
auto forward = ZERO;
auto right = ZERO;
auto up = ZERO;
math::angle_vectors(aim_angle, &forward, &right, &up);
math::fast_vec_normalize(forward);
math::fast_vec_normalize(right);
math::fast_vec_normalize(up);
auto current = 0;
Vector total_spread, spread_angle, end;
float inaccuracy, spread_x, spread_y;
std::tuple<float, float, float>* seed;
for (auto i = 0u; i < 255; i++)
{
seed = &precomputed_seeds[i];
inaccuracy = std::get<0>(*seed) * weapon_inaccuracy;
spread_x = std::get<2>(*seed) * inaccuracy;
spread_y = std::get<1>(*seed) * inaccuracy;
total_spread = (forward + right * spread_x + up * spread_y);
total_spread.Normalize();
math::vector_angles(total_spread, spread_angle);
math::angle_vectors(spread_angle, end);
end.Normalize();
end = g_ctx.globals.eye_pos + end * info->flRange;
CGameTrace tr;
m_trace()->ClipRayToEntity(Ray_t(g_ctx.globals.eye_pos, end), MASK_SHOT, final_target.record->player, &tr);
if (tr.hit_entity == final_target.record->player)
current++;
if ((static_cast<float>(current) / 255.f) * 100.f >= hitchance_cfg)
{
final_hitchance = (static_cast<float>(current) / 255.f) * 100.f;
return true;
}
if ((static_cast<float>(current + 255 - i) / 255.f) * 100.f < hitchance_cfg)
{
final_hitchance = (static_cast<float>(current + 255 - i) / 255.f) * 100.f;
return false;
}
}
final_hitchance = (static_cast<float>(current) / 255.f) * 100.f;
return (static_cast<float>(current) / 255.f) * 100.f >= hitchance_cfg;
}