Исходник Weave autostop converted for lw

Начинающий
Статус
Оффлайн
Регистрация
15 Фев 2022
Сообщения
299
Реакции[?]
21
Поинты[?]
0
я просто конвертнул, прошу без хейта, отличие от деф лв предиктива не особо заметно. Лишнее сами удаляйте
aim.cpp aim::run():
if (!should_stop && g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].autostop_modifiers[AUTOSTOP_PREDICTIVE])
    {
        auto max_speed = 260.0f;
        auto weapon_info = g_ctx.globals.weapon->get_csweapon_info();

        if (weapon_info)
            max_speed = g_ctx.globals.scoped ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

        //GetTicksToShoot() <= GetTicksToStop()

        auto ticks_to_stop = get_ticks_to_stop();//math::clamp(engineprediction::get().backup_data.velocity.Length2D() / max_speed * 3.0f, 0.0f, 4.0f);
        //auto ticks_to_stop = get_ticks_to_stop();
        auto predicted_eye_pos = g_ctx.globals.eye_pos + engineprediction::get().backup_data.velocity * m_globals()->m_intervalpertick * ticks_to_stop;

        for (auto& target : targets)
        {
            if (!target.last_record->valid())
                continue;

            scan_data last_data;

            target.last_record->adjust_player();
            scan(target.last_record, last_data, predicted_eye_pos, true);

            if (!last_data.valid())
                continue;

            should_stop = GetTicksToShoot() <= get_ticks_to_stop();
            break;
        }

    }
funcs for aim.cpp:
int aim::get_ticks_to_stop() {
    static auto predict_velocity = [](Vector* velocity)
    {
        float speed = velocity->Length2D();
        static auto sv_friction = m_cvar()->FindVar(crypt_str("sv_friction"));
        static auto sv_stopspeed = m_cvar()->FindVar(crypt_str("sv_stopspeed"));

        if (speed >= 1.f)
        {
            float friction = sv_friction->GetFloat();
            float stop_speed = std::max< float >(speed, sv_stopspeed->GetFloat());
            float time = std::max< float >(m_globals()->m_intervalpertick, m_globals()->m_frametime);
            *velocity *= std::max< float >(0.f, speed - friction * stop_speed * time / speed);
        }
    };
    Vector vel = engineprediction::get().backup_data.velocity;
    int ticks_to_stop = 0;
    for (;;)
    {
        if (vel.Length2D() < 1.f)
            break;
        predict_velocity(&vel);
        ticks_to_stop++;
    }
    return ticks_to_stop;
}

//func
int aim::GetTicksToShoot() {
    if (g_ctx.globals.weapon->can_fire(g_ctx.globals.weapon->m_iItemDefinitionIndex() == WEAPON_TASER ? true : false))
        return -1;
    auto flServerTime = TICKS_TO_TIME(g_ctx.globals.fixed_tickbase);
    auto flNextPrimaryAttack = g_ctx.globals.weapon->m_flNextPrimaryAttack();

    return TIME_TO_TICKS(fabsf(flNextPrimaryAttack - flServerTime));
}
 
Последнее редактирование:
Сверху Снизу