Исходник Адекватный хитшанс

Эксперт
Статус
Оффлайн
Регистрация
30 Дек 2019
Сообщения
1,970
Реакции[?]
958
Поинты[?]
19K
Увидел тему про хитшанс, посмеялся, решил дропнуть наиболее правильный, в нём не хватает провеки на валид рекод и кое что ещё

Код:
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;
}
 
Последнее редактирование:
Keep Ev0lving, Stay Fatal
Эксперт
Статус
Оффлайн
Регистрация
6 Фев 2018
Сообщения
1,543
Реакции[?]
583
Поинты[?]
99K
Увидел тему про хитшанс, посмеялся, решил дропнуть наиболее правильный, в нём не хватает провеки на валид рекод и кое что ещё

Код:
static std::vector<std::tuple<float, float, float>> pre_computed_seeds = {};
void c_ragebot::bulid_seed_table() {

    if (!pre_computed_seeds.empty()) return;

    for (auto i = 0; i < max_seeds; i++) {
        math::random_seed(i + 1);

        const auto pi_seed = math::random_float(0.f, M_PI * 2);

        pre_computed_seeds.emplace_back(math::random_float(0.f, 1.f), sin(pi_seed), cos(pi_seed));
    }
}

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;
}
Что за клоунаду ты скинул... Зачем тебе bulid_seed_table ЕСТЬ ТЫ НЕ ЮЗАЕШЬ ЕБАНЫЕ pre_computed_seeds.
Ещё, в 2021 году юзать трейсеры? Серьёзно нахуй?
 
Забаненный
Статус
Оффлайн
Регистрация
17 Апр 2021
Сообщения
22
Реакции[?]
11
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
какие же вы все сочные это треш что аж блювать хочется
 
Забаненный
Статус
Оффлайн
Регистрация
2 Окт 2021
Сообщения
3
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Увидел тему про хитшанс, посмеялся, решил дропнуть наиболее правильный, в нём не хватает провеки на валид рекод и кое что ещё

Код:
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;
}
фаталити здравствуйте..
зачем использовать трейсы.. если будет p100 optimization проще использовать хитбокс интерсекшен
 
Начинающий
Статус
Оффлайн
Регистрация
1 Мар 2020
Сообщения
16
Реакции[?]
5
Поинты[?]
0
Увидел тему про хитшанс, посмеялся, решил дропнуть наиболее правильный, в нём не хватает провеки на валид рекод и кое что ещё

Код:
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;
}
Хотяб дропнул что-ле дитяткам сам билд сид тэйбл...
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));
    }
}
 
Последнее редактирование:
Нефор
Забаненный
Статус
Оффлайн
Регистрация
9 Ноя 2018
Сообщения
1,042
Реакции[?]
663
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
дефолт паблик параша
 
Похожие темы
Сверху Снизу