Эксперт
-
Автор темы
- #1
Увидел тему про хитшанс, посмеялся, решил дропнуть наиболее правильный, в нём не хватает провеки на валид рекод и кое что ещё
Код:
bool c_ragebot::HitChance(vec3_t angles, c_base_player* ent)
{
bulid_seed_table();
auto weapon = g_local->get_active_weapon();
if (!weapon)
return false;
float weapon_hitchance = g_vars.config.ragebot.aimbot.main.weapon[curGroup].hitchance;
vec3_t fw, rw, uw;
math::angle_vectors(angles, fw, rw, uw);
int hits = 0;
int needed_hits = static_cast<int>(max_seeds * (weapon_hitchance / 100.f));
float weapon_spread = weapon->get_spread();
float weapon_innacuracy = weapon->get_inaccuracy();
vec3_t src = g_local->get_eye_pos();
for (int i = 0; i < max_seeds; i++) {
float a = math::random_float(0.f, 1.f);
float b = math::random_float(0.f, M_PI * 2.f);
float c = math::random_float(0.f, 1.f);
float d = math::random_float(0.f, M_PI * 2.f);
float inaccuracy = a * weapon_innacuracy;
float spread = c * weapon_spread;
if (weapon->m_iItemDefinitionIndex() == 64/*WEAPON_REVOLVER*/) {
if (g::cmd->buttons & in_attack2) {
a = 1.f - a * a;
c = 1.f - c * c;
}
}
vec3_t spread_view((cos(b) * inaccuracy) + (cos(d) * spread), (sin(b) * inaccuracy) + (sin(d) * spread), 0);
vec3_t direction;
direction.x = fw.x + (spread_view.x * rw.x) + (spread_view.y * uw.x);
direction.y = fw.y + (spread_view.x * rw.y) + (spread_view.y * uw.y);
direction.z = fw.z + (spread_view.x * rw.z) + (spread_view.y * uw.z);
direction.normalized();
vec3_t viewangles_spread;
vec3_t view_forward;
math::vector_angles(direction, uw, viewangles_spread);
viewangles_spread.normalize();
math::angle_vectors(viewangles_spread, view_forward);
view_forward.normalize_in_place();
view_forward = src + (direction * weapon->get_cs_weapon_data()->range);
trace_t tr;
ray_t ray;
ray.initialize(src, view_forward);
i::trace->clip_ray_to_entity(ray, mask_shot, ent, &tr);
if (tr.player == ent)
hits++;
if ((max_seeds - i + hits) < needed_hits)
return false;
}
if (static_cast<int>((static_cast<float>(hits) / max_seeds) * 100.f) >= weapon_hitchance)
return true;
final_hitchance = ((float)hits / (float)max_seeds);
return false;
}
Последнее редактирование: