Вопрос Hitchance for lw from rifk

ЧВК EB_LAN
Эксперт
Статус
Оффлайн
Регистрация
26 Янв 2021
Сообщения
1,547
Реакции[?]
517
Поинты[?]
191K
Я тут начал его пастить и короче, я не знаю правильно или нет оно работает. Кто сможет подсказать плохие моменты которые лучше рекоднуть?
C++:
bool aim::calculate_hitchance(int& final_hitchance)
{
    // generate look-up-table to enhance performance.
    build_seed_table();

    const auto info = g_ctx.globals.weapon->get_csweapon_info();

    if (!info)
        return false;

    auto player = (player_t*)m_entitylist()->GetClientEntity(aim::get().last_target_index);

    auto model = player->GetModel();

    const auto studio_model = m_modelinfo()->GetStudioModel(model);

    if (!studio_model)
        return false;

    const auto hitchance_cfg = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].hitchance_amount;

    auto position = ZERO;

    // performance optimization.
    if ((g_ctx.local()->get_shoot_position() - position).Length() > info->flRange)
        return false;

    // setup calculation parameters.
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };
    const auto sniper = g_ctx.globals.weapon->is_sniper();
    const auto crouched = g_ctx.local()->m_fFlags() & FLAGS_FAKEDUCKING;

    // calculate inaccuracy.
    const auto weapon_inaccuracy = g_ctx.globals.weapon->get_inaccuracy();

    // no need for hitchance, if we can't increase it anyway.
    if (crouched)
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyCrouchAlt : info->flInaccuracyCrouch))
            return true;
    }
    else
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyStandAlt : info->flInaccuracyStand))
            return true;
    }

    // calculate start and angle.
    const auto start = g_ctx.local()->get_shoot_position();

    const auto aim_angle = math::calculate_angle(start, position);
    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);

    // keep track of all traces that hit the enemy.
    auto current = 0;

    // setup calculation parameters.
    Vector total_spread, spread_angle, end;
    float inaccuracy, spread_x, spread_y;
    std::tuple<float, float, float>* seed;

    // use look-up-table to find average hit probability.
    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 = start + end.Normalize() * 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++;

        // abort if hitchance is already sufficent.
        if (static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg)
            return true;

        // abort if we can no longer reach hitchance.
        if (static_cast<float>(current + 255 - i) / static_cast<float>(255) < hitchance_cfg)
            return false;
    }

    return static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg;
}
Пожалуйста, авторизуйтесь для просмотра ссылки.

Знаю что can_hit_hitbox нужен итд, мне пока лень пастить но я мб сегодня уже всё сделаю нормально и как надо.
И вектор 3д надо было бы спастить, но опять же мне легче закостылить...


Хитшанс крашит, и я не знаю как фикс тк лень дебажить. Помогите это зафиксеть:(
 
Последнее редактирование:
Трахов
Пользователь
Статус
Оффлайн
Регистрация
6 Фев 2020
Сообщения
490
Реакции[?]
87
Поинты[?]
2K
Я тут начал его пастить и короче, я не знаю правильно или нет оно работает. Кто сможет подсказать плохие моменты которые лучше рекоднуть?
C++:
bool aim::calculate_hitchance(int& final_hitchance)
{
    // generate look-up-table to enhance performance.
    build_seed_table();

    const auto info = g_ctx.globals.weapon->get_csweapon_info();

    if (!info)
        return false;

    auto player = (player_t*)m_entitylist()->GetClientEntity(aim::get().last_target_index);

    auto model = player->GetModel();

    const auto studio_model = m_modelinfo()->GetStudioModel(model);

    if (!studio_model)
        return false;

    const auto hitchance_cfg = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].hitchance_amount;

    auto position = ZERO;

    // performance optimization.
    if ((g_ctx.local()->get_shoot_position() - position).Length() > info->flRange)
        return false;

    // setup calculation parameters.
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };
    const auto sniper = g_ctx.globals.weapon->is_sniper();
    const auto crouched = g_ctx.local()->m_fFlags() & FLAGS_FAKEDUCKING;

    // calculate inaccuracy.
    const auto weapon_inaccuracy = g_ctx.globals.weapon->get_inaccuracy();

    // no need for hitchance, if we can't increase it anyway.
    if (crouched)
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyCrouchAlt : info->flInaccuracyCrouch))
            return true;
    }
    else
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyStandAlt : info->flInaccuracyStand))
            return true;
    }

    // calculate start and angle.
    const auto start = g_ctx.local()->get_shoot_position();

    const auto aim_angle = math::calculate_angle(start, position);
    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);

    // keep track of all traces that hit the enemy.
    auto current = 0;

    // setup calculation parameters.
    Vector total_spread, spread_angle, end;
    float inaccuracy, spread_x, spread_y;
    std::tuple<float, float, float>* seed;

    // use look-up-table to find average hit probability.
    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 = start + end.Normalize() * 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++;

        // abort if hitchance is already sufficent.
        if (static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg)
            return true;

        // abort if we can no longer reach hitchance.
        if (static_cast<float>(current + 255 - i) / static_cast<float>(255) < hitchance_cfg)
            return false;
    }

    return static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg;
}
Пожалуйста, авторизуйтесь для просмотра ссылки.

Знаю что can_hit_hitbox нужен итд, мне пока лень пастить но я мб сегодня уже всё сделаю нормально и как надо.
И вектор 3д надо было бы спастить, но опять же мне легче закостылить...


Хитшанс крашит, и я не знаю как фикс тк лень дебажить. Помогите это зафиксеть:(
can_hitbox не нужен, у тебя есть hitbox_intersection для этого (одна и таже херня)
а по факту рифк хитшанс не лучший выбор потому что в буле(
 
Начинающий
Статус
Оффлайн
Регистрация
11 Сен 2017
Сообщения
33
Реакции[?]
1
Поинты[?]
0
Код:
int aim::hitchance(const Vector& aim_angle)
{
    auto final_hitchance = 0;
    auto weapon_info = g_ctx.globals.weapon->get_csweapon_info();

    if (!weapon_info)
        return final_hitchance;

    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 is_special_weapon = g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_AWP || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_G3SG1 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SCAR20 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SSG08;
    auto inaccuracy = weapon_info->flInaccuracyStand;

    if (g_ctx.local()->m_fFlags() & FL_DUCKING)
    {
        if (is_special_weapon)
            inaccuracy = weapon_info->flInaccuracyCrouchAlt;
        else
            inaccuracy = weapon_info->flInaccuracyCrouch;
    }
    else if (is_special_weapon)
        inaccuracy = weapon_info->flInaccuracyStandAlt;

    if (g_ctx.globals.inaccuracy - 0.000001f < inaccuracy)
        final_hitchance = 100;
    else
    {
        static auto setup_spread_values = true;
        static float spread_values[256][6];

        if (setup_spread_values)
        {
            setup_spread_values = false;

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

                auto a = math::random_float(0.0f, 1.0f);
                auto b = math::random_float(0.0f, DirectX::XM_2PI);
                auto c = math::random_float(0.0f, 1.0f);
                auto d = math::random_float(0.0f, DirectX::XM_2PI);

                spread_values[i][0] = a;
                spread_values[i][1] = c;

                auto sin_b = 0.0f, cos_b = 0.0f;
                DirectX::XMScalarSinCos(&sin_b, &cos_b, b);

                auto sin_d = 0.0f, cos_d = 0.0f;
                DirectX::XMScalarSinCos(&sin_d, &cos_d, d);

                spread_values[i][2] = sin_b;
                spread_values[i][3] = cos_b;
                spread_values[i][4] = sin_d;
                spread_values[i][5] = cos_d;
            }
        }

        auto hits = 0;
        for (auto i = 0; i < 256; ++i)
        {
            auto inaccuracy = spread_values[i][0] * g_ctx.globals.inaccuracy;
            auto spread = spread_values[i][1] * g_ctx.globals.spread;

            auto spread_x = spread_values[i][3] * inaccuracy + spread_values[i][5] * spread;
            auto spread_y = spread_values[i][2] * inaccuracy + spread_values[i][4] * spread;

            auto direction = ZERO;

            direction.x = forward.x + right.x * spread_x + up.x * spread_y;
            direction.y = forward.y + right.y * spread_x + up.y * spread_y;
            direction.z = forward.z + right.z * spread_x + up.z * spread_y;

            auto end = g_ctx.globals.eye_pos + direction * weapon_info->flRange;
            
            CGameTrace tr;
            Ray_t ray;
            ray.Init(g_ctx.globals.eye_pos, end);
            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)
                hits++;

            //if (hitbox_intersection(final_target.record->player, final_target.record->matrixes_data.main, final_target.data.hitbox, g_ctx.globals.eye_pos, end))
                //++hits;
        }
        final_hitchance = (int)((float)hits / 2.56f);
    }
}
 
Последнее редактирование:
шатап книга
Забаненный
Статус
Оффлайн
Регистрация
7 Мар 2020
Сообщения
485
Реакции[?]
119
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Я тут начал его пастить и короче, я не знаю правильно или нет оно работает. Кто сможет подсказать плохие моменты которые лучше рекоднуть?
C++:
bool aim::calculate_hitchance(int& final_hitchance)
{
    // generate look-up-table to enhance performance.
    build_seed_table();

    const auto info = g_ctx.globals.weapon->get_csweapon_info();

    if (!info)
        return false;

    auto player = (player_t*)m_entitylist()->GetClientEntity(aim::get().last_target_index);

    auto model = player->GetModel();

    const auto studio_model = m_modelinfo()->GetStudioModel(model);

    if (!studio_model)
        return false;

    const auto hitchance_cfg = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].hitchance_amount;

    auto position = ZERO;

    // performance optimization.
    if ((g_ctx.local()->get_shoot_position() - position).Length() > info->flRange)
        return false;

    // setup calculation parameters.
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };
    const auto sniper = g_ctx.globals.weapon->is_sniper();
    const auto crouched = g_ctx.local()->m_fFlags() & FLAGS_FAKEDUCKING;

    // calculate inaccuracy.
    const auto weapon_inaccuracy = g_ctx.globals.weapon->get_inaccuracy();

    // no need for hitchance, if we can't increase it anyway.
    if (crouched)
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyCrouchAlt : info->flInaccuracyCrouch))
            return true;
    }
    else
    {
        if (round_acc(weapon_inaccuracy) == round_acc(sniper ? info->flInaccuracyStandAlt : info->flInaccuracyStand))
            return true;
    }

    // calculate start and angle.
    const auto start = g_ctx.local()->get_shoot_position();

    const auto aim_angle = math::calculate_angle(start, position);
    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);

    // keep track of all traces that hit the enemy.
    auto current = 0;

    // setup calculation parameters.
    Vector total_spread, spread_angle, end;
    float inaccuracy, spread_x, spread_y;
    std::tuple<float, float, float>* seed;

    // use look-up-table to find average hit probability.
    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 = start + end.Normalize() * 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++;

        // abort if hitchance is already sufficent.
        if (static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg)
            return true;

        // abort if we can no longer reach hitchance.
        if (static_cast<float>(current + 255 - i) / static_cast<float>(255) < hitchance_cfg)
            return false;
    }

    return static_cast<float>(current) / static_cast<float>(255) >= hitchance_cfg;
}
Пожалуйста, авторизуйтесь для просмотра ссылки.

Знаю что can_hit_hitbox нужен итд, мне пока лень пастить но я мб сегодня уже всё сделаю нормально и как надо.
И вектор 3д надо было бы спастить, но опять же мне легче закостылить...


Хитшанс крашит, и я не знаю как фикс тк лень дебажить. Помогите это зафиксеть:(
зачем ты гетаешь плеера из плеер индекса, если есть final_target.record->player
 
Начинающий
Статус
Оффлайн
Регистрация
11 Сен 2017
Сообщения
33
Реакции[?]
1
Поинты[?]
0
Best HitChance for LW v3
Код:
bool aim::calculate_hitchance_boost(Vector angles, int& final_hitchance, player_t* player, int hitbox, bool accuracy_boost_amount)
{
    angles.Clamp();
    build_seed_table();
    const auto info = g_ctx.globals.weapon->get_csweapon_info();

    if (!info)
        return false;

    auto model = player->GetModel();
    const auto studio_model = m_modelinfo()->GetStudioModel(model);

    if (!studio_model)
        return false;

    float HITCHANCE_MAX = 100.f;
    constexpr int SEED_MAX = 256;

    float hitchance = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].hitchance_amount;
    if (g_ctx.globals.double_tap_aim && g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].double_tap_hitchance)
        hitchance = g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].double_tap_hitchance_amount;

     // if you play on no spread servers, no delete this //
    //if (m_cvar()->FindVar(crypt_str("weapon_accuracy_nospread"))->GetInt())
    //{
        //final_hitchance = 100;
        //return true;
    //}

    size_t total_hits{ }, needed_hits{ (size_t)std::ceil((SEED_MAX * (hitchance / HITCHANCE_MAX))) };
    Vector start{ g_ctx.globals.eye_pos }, end, fwd, right, up, dir, wep_spread;
    auto allowed_misses = SEED_MAX - needed_hits;

    static auto weapon_recoil_scale = m_cvar()->FindVar(crypt_str("weapon_recoil_scale"));
    const auto cur_aim_angle = math::calculate_angle(g_ctx.globals.eye_pos, final_target.data.point.point) - (g_ctx.local()->m_aimPunchAngle() * weapon_recoil_scale->GetFloat());

    math::angle_vectors(cur_aim_angle, &fwd, &right, &up);

    math::fast_vec_normalize(fwd);
    math::fast_vec_normalize(right);
    math::fast_vec_normalize(up);

    if ((g_ctx.local()->get_shoot_position() - cur_aim_angle).Length2D() > g_ctx.globals.weapon->get_csweapon_info()->flRange)
        return false;

    const auto id = g_ctx.globals.weapon->m_iItemDefinitionIndex();
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };

    auto is_special_weapon = g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_AWP || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_G3SG1 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SCAR20 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SSG08;
    auto inaccuracy = g_ctx.globals.weapon->get_inaccuracy();
    auto spread = g_ctx.globals.weapon->get_spread();

    g_ctx.globals.weapon->update_accuracy_penality();

    auto get_hitgroup = [](const int& hitbox)
    {
        if (hitbox == HITBOX_HEAD)
            return 0;
        else if (hitbox == HITBOX_PELVIS)
            return 1;
        else if (hitbox == HITBOX_STOMACH)
            return 2;
        else if (hitbox >= HITBOX_LOWER_CHEST && hitbox <= HITBOX_UPPER_CHEST)
            return 3;
        else if (hitbox >= HITBOX_RIGHT_THIGH && hitbox <= HITBOX_LEFT_FOOT)
            return 4;
        else if (hitbox >= HITBOX_RIGHT_HAND && hitbox <= HITBOX_LEFT_FOREARM)
            return 5;

        return -1;
    };

    for (int i = 0; i < SEED_MAX; i++)
    {
        wep_spread = CalculateSpread(i, inaccuracy, spread);
        dir = (fwd + (right * wep_spread.x) + (up * wep_spread.y)).Normalized();
        end = start + (dir * g_ctx.globals.weapon->get_csweapon_info()->flRange);

        if (g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].skip_hitchance_if_low_inaccuracy && !g_ctx.globals.double_tap_aim && g_ctx.local()->m_fFlags() & FL_ONGROUND && engineprediction::get().backup_data.flags & FL_ONGROUND) //-V807
        {
            auto weapon_info_inaccuracy = g_ctx.globals.weapon->m_zoomLevel() ? g_ctx.globals.weapon->get_csweapon_info()->flInaccuracyStandAlt : g_ctx.globals.weapon->get_csweapon_info()->flInaccuracyStand;

            if (engineprediction::get().backup_data.flags & FL_DUCKING)
                weapon_info_inaccuracy = g_ctx.globals.weapon->m_zoomLevel() ? g_ctx.globals.weapon->get_csweapon_info()->flInaccuracyCrouchAlt : g_ctx.globals.weapon->get_csweapon_info()->flInaccuracyCrouch;

            if (g_ctx.globals.inaccuracy - weapon_info_inaccuracy < 0.0001f)
                return true;
        }

        if (hitbox_intersection_skeet(final_target.record->player, final_target.record->matrixes_data.main, final_target.data.hitbox, start, end))
        {
            auto fire_data = autowall::get().wall_penetration(start, end, player);
            if (fire_data.damage >= 1 && get_hitgroup(hitbox) == get_hitgroup(fire_data.hitbox))
            {
                auto accuracy_boost = true;
                if (accuracy_boost_amount && (float)fire_data.damage / (float)final_target.data.damage < (float)g_cfg.ragebot.weapon->accuracy_boost_amount / 100.0f)
                    accuracy_boost = false;

                if (accuracy_boost)
                    total_hits++;
            }
        }

        
        if (total_hits >= needed_hits)
        {
            final_hitchance = (size_t)std::ceil(total_hits / 2.56f);
            return true;
        }

        if ((SEED_MAX - i + total_hits) < needed_hits)
            return false;

    }
    return (total_hits / SEED_MAX) >= needed_hits;
}
Код:
auto is_valid_hitchance = calculate_hitchance_boost(aim_angle, final_hitchance, final_target.record->player, final_target.data.point.hitbox, !g_ctx.globals.double_tap_aim);

    if (!is_valid_hitchance)
    {
        auto is_zoomable_weapon = g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SCAR20 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_G3SG1 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SSG08 || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_AWP || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_AUG || g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_SG553;

        if (g_cfg.ragebot.autoscope && is_zoomable_weapon && !g_ctx.globals.weapon->m_zoomLevel())
            cmd->m_buttons |= IN_ATTACK2;

        return;
    }
 
Последнее редактирование:
...
Пользователь
Статус
Оффлайн
Регистрация
25 Май 2020
Сообщения
291
Реакции[?]
41
Поинты[?]
0
Брать хитшанс из рифка не особо хороший вариант. Где-то в паблике видел достойный хитшанс. Если найду, то кину.
 
Забаненный
Статус
Оффлайн
Регистрация
22 Мар 2021
Сообщения
1,019
Реакции[?]
315
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Пользователь
Статус
Оффлайн
Регистрация
4 Дек 2017
Сообщения
150
Реакции[?]
32
Поинты[?]
0
С хитшансом любой дурак сможет, а ты без него попробуй, топ тема
 
Сверху Снизу