Вопрос Hitchance

yoo bro, i see a big paster)()
Начинающий
Статус
Оффлайн
Регистрация
29 Июл 2019
Сообщения
257
Реакции[?]
26
Поинты[?]
0
Хитшанс не видит значения которые я ставлю, всегда 1:
C++:
{
    // generate look-up-table to enhance performance.
    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;

    // performance optimization.
    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;
    }

    // setup calculation parameters.
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };
    const auto sniper = 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;
    const auto crouched = g_ctx.local()->m_fFlags() & FL_DUCKING;
    const auto on_ground = g_ctx.local()->m_fFlags() & FL_ONGROUND;

    // 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))
        {
            final_hitchance = INT_MAX;
            return true;
        }
    }

    // calculate start and angle.
    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).Clamp();
    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 (int i = 0; i < 255; i++)  // NOLINT(modernize-loop-convert)
    {
        // get seed.
        seed = &precomputed_seeds[i];

        // calculate spread.
        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();

        // calculate angle with spread applied.
        math::vector_angles(total_spread, spread_angle);

        // calculate end point of trace.
        math::angle_vectors(spread_angle, end);
        end.Normalize();
        end = g_ctx.globals.eye_pos + end * info->flRange;

            trace_t ll;
            Ray_t rr;

            for (auto i = 0; i < 2; i++)
            {
                rr.Init(g_ctx.globals.eye_pos, end);

                m_trace()->ClipRayToEntity(rr, 0x4600400B, final_target.record->player, &ll);

                bool can_damage = (ll.hitgroup >= 0 && ll.hitgroup <= 8);
                bool is_required_player = (ll.hit_entity == final_target.record->player);

                if (can_damage && is_required_player)
                    ++current;

            }

        if (hitbox_intersection(final_target.record->player, final_target.record->matrixes_data.main, final_target.data.hitbox, g_ctx.globals.eye_pos, end))
            ++current;


        // abort if hitchance is already sufficent.
        if ((static_cast<float>(current) / 255.f)  >= hitchance_cfg / 100.f)
        {
            final_hitchance = (static_cast<float>(current) / 255.f) * 100.f;
            return true;
        }

        // abort if we can no longer reach hitchance.
        if ((static_cast<float>(current + 255 - i) / 255.f)  < hitchance_cfg / 100.f)
        {
            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)  >= hitchance_cfg / 100.f;
}
 
Трахов
Пользователь
Статус
Оффлайн
Регистрация
6 Фев 2020
Сообщения
490
Реакции[?]
87
Поинты[?]
2K
Хитшанс не видит значения которые я ставлю, всегда 1:
C++:
{
    // generate look-up-table to enhance performance.
    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;

    // performance optimization.
    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;
    }

    // setup calculation parameters.
    const auto round_acc = [](const float accuracy) { return roundf(accuracy * 1000.f) / 1000.f; };
    const auto sniper = 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;
    const auto crouched = g_ctx.local()->m_fFlags() & FL_DUCKING;
    const auto on_ground = g_ctx.local()->m_fFlags() & FL_ONGROUND;

    // 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))
        {
            final_hitchance = INT_MAX;
            return true;
        }
    }

    // calculate start and angle.
    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).Clamp();
    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 (int i = 0; i < 255; i++)  // NOLINT(modernize-loop-convert)
    {
        // get seed.
        seed = &precomputed_seeds[i];

        // calculate spread.
        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();

        // calculate angle with spread applied.
        math::vector_angles(total_spread, spread_angle);

        // calculate end point of trace.
        math::angle_vectors(spread_angle, end);
        end.Normalize();
        end = g_ctx.globals.eye_pos + end * info->flRange;

            trace_t ll;
            Ray_t rr;

            for (auto i = 0; i < 2; i++)
            {
                rr.Init(g_ctx.globals.eye_pos, end);

                m_trace()->ClipRayToEntity(rr, 0x4600400B, final_target.record->player, &ll);

                bool can_damage = (ll.hitgroup >= 0 && ll.hitgroup <= 8);
                bool is_required_player = (ll.hit_entity == final_target.record->player);

                if (can_damage && is_required_player)
                    ++current;

            }

        if (hitbox_intersection(final_target.record->player, final_target.record->matrixes_data.main, final_target.data.hitbox, g_ctx.globals.eye_pos, end))
            ++current;


        // abort if hitchance is already sufficent.
        if ((static_cast<float>(current) / 255.f)  >= hitchance_cfg / 100.f)
        {
            final_hitchance = (static_cast<float>(current) / 255.f) * 100.f;
            return true;
        }

        // abort if we can no longer reach hitchance.
        if ((static_cast<float>(current + 255 - i) / 255.f)  < hitchance_cfg / 100.f)
        {
            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)  >= hitchance_cfg / 100.f;
}
final_hitchance = vars.ragebot.weapon[csgo.globals.current_weapon].hitchance_amount;

hitchance_cfg удали.
 
yoo bro, i see a big paster)()
Начинающий
Статус
Оффлайн
Регистрация
29 Июл 2019
Сообщения
257
Реакции[?]
26
Поинты[?]
0
final_hitchance = vars.ragebot.weapon[csgo.globals.current_weapon].hitchance_amount;

hitchance_cfg удали.
это в конец или там где вот это:
if ((g_ctx.globals.eye_pos - final_target.data.point.point).Length() > info->flRange)
{
final_hitchance = 0;
return true;
}
 
Забаненный
Статус
Оффлайн
Регистрация
22 Мар 2021
Сообщения
1,019
Реакции[?]
315
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
брейкпоинты расставь и посмотри где и почему возвращает 1
 
Эксперт
Статус
Оффлайн
Регистрация
17 Фев 2017
Сообщения
864
Реакции[?]
420
Поинты[?]
1K
Если ты выводишь результат выполнения функции то не удивительно, почему у тебя 1. Потому что твоя функа возвращает булеановое значение, которое принимает либо 0 либо 1.
false = 0, true = 1.
Поэтому использовать её вот так:
int hitchance = ragebot->get_hitchance();
Нельзя.
 
Сверху Снизу