Исходник Педали и полезное

Начинающий
Статус
Оффлайн
Регистрация
22 Мар 2022
Сообщения
147
Реакции[?]
6
Поинты[?]
6K
ну вот вам педали. В коде ещё очень много чего полезного сразу скажу что это не моё я просто перезалил сюда

и да хватит мне задавать вопросы это не я писал я просто перезалил сюда, так что вопросы по коду точно не мне

и писал этот код schw4nzlutsch3n и shialex так что вопросы по коды к ним

movement.hpp:
#pragma once

#include "../protobufs/protobufs.hpp"

struct qucik_peek_data_t {
    void reset( vec3_t vecOrigin = vec3_t( 0.f, 0.f, 0.f ) ) {
        m_old_origin = vecOrigin;
        m_should_retrack = false;
        m_autopeeking = false;
        m_fired = false;
        m_retracking_time = 0;
    }

    bool m_autopeeking = false;
    bool m_fired = false;
    bool m_should_retrack = false;
    int m_retracking_time = 0;
    vec3_t m_old_origin = vec3_t( 0, 0, 0 );
};

class c_movement {
    bool m_in_bhop{};
    bool m_turned_on{};
    bool m_retreat{};
    bool m_negative_side{};

    vec3_t m_vec_start_position{};

    qucik_peek_data_t m_quick_peek_data{};

    bool m_stopped{};
    void auto_strafe( c_user_cmd* user_cmd, float scop );
    void rotate_penis(c_user_cmd* current_cmd, float yaw);
    void limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
    void stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
public:
    float get_max_player_speed( );
    void bunnyhop(c_user_cmd* user_cmd);
    void auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread );
    void subtick_airstrafe(c_user_cmd* user_cmd);
    void quick_peek_assistant( c_user_cmd* pCmd, CBaseUserCmdPB* pBaseCmd );
    void reset_quick_peek_data( );
    void movement_fix( c_user_cmd* user_cmd, vec3_t angle );
    void on_create_move( c_user_cmd* user_cmd, float old_yaw );
    void quick_stop( c_user_cmd* user_cmd );
    void draw_autopeek( );
};

inline const auto g_movement = std::make_unique<c_movement>( );

movement.cpp:
#include "movement.hpp"
#include "../rage_bot/rage_bot.hpp"

#include "../../render/render.hpp"
#include "../rage_bot/rage_bot.hpp"
#include "../anti_hit/anti_hit.hpp"

void c_movement::bunnyhop( c_user_cmd* user_cmd ) {
    m_in_bhop = false;

    if ( !g_cfg->misc.m_bunny_hop )
        return;

    const auto is_jumping = user_cmd->m_button_state.m_button_state & IN_JUMP;
    if (is_jumping)
        return;

    user_cmd->m_button_state.m_button_state &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state2 &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state3 &= ~IN_JUMP;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
    {
        user_cmd->m_button_state.m_button_state |= IN_JUMP;
        user_cmd->m_button_state.m_button_state3 |= IN_JUMP;

        auto poopl = g_protobuf->add_subtick_move_step(user_cmd);
        poopl->set_button(IN_JUMP);
        poopl->set_pressed(true);
        poopl->set_when(0.999f);

        auto poopl1 = g_protobuf->add_subtick_move_step(user_cmd);
        poopl1->set_button(IN_JUMP);
        poopl1->set_pressed(false);
        poopl1->set_when(0.999f);
    }
}

float calculate_delta(float m_speed) {
    const static float max_speed = 300.f;
    const static auto sv_airaccelerate = g_interfaces->m_var->get_by_name("sv_airaccelerate")->get_float();
    const float term = g_cfg->misc.m_strafe_smooth / sv_airaccelerate / max_speed * 100.0f / m_speed;

    if (term < 1.0f && term > -1.0f)
        return std::acos(term);

    return 0.0f;
};

void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };


    auto local = g_ctx->m_local_pawn;

    bool on_ground = local->m_flags() & FL_ONGROUND;

    if (on_ground)
        return;

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t viewangles, strafe, velocity = local->m_vec_velocity();

    velocity.z = 0.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);

    float fl_velocity = velocity.length_2d();
    float strafe_angles = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

    if (strafe_angles > 90.0f)
        strafe_angles = 90.0f;
    else if (strafe_angles < 0.0f)
        strafe_angles = 0.0f;

    static float flOldYaw = 0.f;

    viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const vec3_t viewangles_backup = viewangles;

    float delta_yaw = viewangles.y - flOldYaw;

    static bool direction = false;

    if (std::abs(delta_yaw) < strafe_angles)
    {
        strafe = viewangles;

        if (direction)
        {
            strafe.y += strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            strafe.y -= strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        direction = !direction;
    }
    else
    {
        if (delta_yaw < 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        else if (delta_yaw > 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
    }

    rotate_penis(user_cmd, strafe.y);

    flOldYaw = viewangles.y;


    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }
}

/*
void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t& velocity = g_ctx->m_local_pawn->m_vec_velocity();

    float velocity_length = velocity.length_2d();

    if (velocity_length < 5.f)
        return;

    vec3_t viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const int buttons = user_cmd->m_button_state.m_button_state;

    float offset = 0.f;

    if (buttons & IN_MOVELEFT)
        offset += 90.f;
    if (buttons & IN_MOVERIGHT)
        offset -= 90.f;

    if (buttons & IN_FORWARD)
        offset *= 1.5f;
    else if (buttons & IN_BACK)
        offset = (-offset * 1.5f) + 180.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);
    user_cmd->pb.mutable_base()->set_leftmove(0.f);

    viewangles.y -= offset;

    const float delta_yaw = remainderf(viewangles.y - previous_yaw, 360.f);
    const float abs_delta_yaw = std::fabsf(delta_yaw);

    store_previous_yaw();

    static bool direction = false;

    if (true || abs_delta_yaw < rad2deg(atan2f(30, hypotf(velocity.x, velocity.y))))
    {
        const float strafe_angle = remainderf(viewangles.y - rad2deg(atan2f(velocity.y, velocity.x)), 360.f);

        if (std::signbit(strafe_angle) == 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        viewangles.y += strafe_angle;
    }
    else
    {
        if (std::signbit(delta_yaw) != 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
    }

    rotate_penis(user_cmd, viewangles.y);

    direction = !direction;

    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    /*bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }*/

void c_movement::rotate_penis(c_user_cmd* current_cmd, float yaw) {
    const float rotation_angle_rad = deg2rad(current_cmd->pb.base().viewangles().y() - yaw);
    const float forward_move = current_cmd->pb.base().forwardmove();
    const float side_move = current_cmd->pb.base().leftmove();

    float rotated_forward_move = forward_move * std::cos(rotation_angle_rad) - side_move * std::sin(rotation_angle_rad);
    float rotaded_side_move = forward_move * std::sin(rotation_angle_rad) + side_move * std::cos(rotation_angle_rad);

    current_cmd->pb.mutable_base()->set_forwardmove(rotated_forward_move);
    current_cmd->pb.mutable_base()->set_leftmove(rotaded_side_move);
}

float c_movement::get_max_player_speed( )  {
    if ( !g_ctx->m_local_pawn->get_active_weapon( ) || !g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( ) )
        return 260.f;

    return  g_ctx->m_local_pawn->m_scoped( ) ? g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 1 ] : g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 0 ];
}

void c_movement::limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    float max_speed = get_max_player_speed( );
    max_speed *= 0.033999f;

    const float distance_to_minimal_speed = g_ctx->m_local_pawn->m_vec_velocity( ).length_2d( ) / max_speed;
    if ( distance_to_minimal_speed <= 0.0f )
        return;

    const float forward_move = user_cmd->pb.mutable_base( )->forwardmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_forwardmove( forward_move );

    const float side_move = user_cmd->pb.mutable_base( )->leftmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_leftmove( side_move );
}

void c_movement::stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    vec3_t velocity = g_ctx->m_local_pawn->m_vec_velocity( );
    float speed = velocity.length_2d( );
    if ( speed < 1.f ) {
        user_cmd->pb.mutable_base( )->set_forwardmove( 0.f );
        user_cmd->pb.mutable_base( )->set_leftmove( 0.f );
        return;
    }

    const auto max_accelspeed = g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * g_interfaces->m_var->get_by_name( "sv_maxspeed" )->get_float( ) * movement_services->m_surface_friction( ) * INTERVAL_PER_TICK;

    auto get_maximum_accelerate_speed = [&]
    {
        const auto speed_ratio = speed / ( g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * INTERVAL_PER_TICK );
        return speed - max_accelspeed <= -1.f ? max_accelspeed / speed_ratio : max_accelspeed;
    };

    vec3_t view_angles{};
    g_interfaces->m_client->get_view_angles( view_angles );

    vec3_t velocity_angle{ };
    g_math->vector_angles( velocity * -1.f, velocity_angle );
    velocity_angle.y = view_angles.y - velocity_angle.y;

    vec3_t forward{ };
    g_math->angle_vectors( velocity_angle, forward );

    const auto total_speed = get_maximum_accelerate_speed( );
    const auto max_weapon_speed = get_max_player_speed( );

    user_cmd->pb.mutable_base( )->set_forwardmove( ( forward.x * total_speed ) / max_weapon_speed );
    user_cmd->pb.mutable_base( )->set_leftmove( ( forward.y * -total_speed ) / max_weapon_speed );
}

void c_movement::auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread ) {
    if ( !g_cfg->rage_bot.m_auto_stop )
        return;

    if ( no_spread )
        return;

    if ( !( local_player->m_flags( ) & FL_ONGROUND ) )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    float max_accurate_speed = get_max_player_speed( ) * 0.25f;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= max_accurate_speed )
        return limit_speed( user_cmd, local_player );

    stop_movement( user_cmd, local_player );
}

void c_movement::subtick_airstrafe(c_user_cmd* user_cmd) {
    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (!g_cfg->misc.m_auto_strafe)
        return;

    for (auto i = 0; i < 12; i++) {
        auto subtick = g_protobuf->add_subtick_move_step(user_cmd);
    }

    for (auto i = 0; i < user_cmd->pb.base().subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);
        if (i == 0) {
            subtick->set_when(FLT_TRUE_MIN);
            continue;
        }
        subtick->set_button(0);

        subtick->set_when((1.f / 12.f) * (i));
    }
}

void c_movement::quick_peek_assistant( c_user_cmd* user_cmd, CBaseUserCmdPB* base_cmd ) {
    static vec3_t vec_origin = vec3_t( 0.0f, 0.0f, 0.0f );

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) ) {
        m_quick_peek_data.reset( );
        return;
    }

    if ( m_quick_peek_data.m_old_origin.is_zero( ) ) {
        vec_origin = g_ctx->m_local_pawn->m_scene_node( )->m_origin( );

        game_trace_t trace;
        trace_filter_t filter( 0x3001, nullptr, nullptr, 3 );
        filter.m_arr_collisions.at( 1 ) = 0x10000;

        ray_t ray = ray_t( );
        g_interfaces->m_trace->trace_shape( &ray, g_prediction->get_local_data( )->m_eye_pos, g_prediction->get_local_data( )->m_eye_pos - vec3_t( 0.0f, 0.0f, 1000.f ), &filter, &trace );

        if ( trace.m_fraction < 1.0f )
            vec_origin = trace.m_end + vec3_t( 0.0f, 0.0f, 2.0f );

        m_quick_peek_data.reset( vec_origin );
    }
    else {
        if ( g_ctx->m_local_pawn->m_scene_node( )->m_origin( ).dist( m_quick_peek_data.m_old_origin ) > 5.0f ) {
            if ( m_quick_peek_data.m_should_retrack ) {
                ++m_quick_peek_data.m_retracking_time;

                vec3_t ang_angles_to_pos = vec3_t( 0, 0, 0 );
                g_math->vector_angles( m_quick_peek_data.m_old_origin - g_ctx->m_local_pawn->m_scene_node( )->m_origin( ), ang_angles_to_pos );

                base_cmd->set_forwardmove( std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::cos( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
                base_cmd->set_leftmove( -std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::sin( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
            }
        }
        else {
            m_quick_peek_data.m_should_retrack = false;
            m_quick_peek_data.m_fired = false;
            m_quick_peek_data.m_retracking_time = 0;
        }
    }

    if ( user_cmd->m_button_state.m_button_state & IN_ATTACK || !processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 0 ) {
        m_quick_peek_data.m_should_retrack = true;
        m_quick_peek_data.m_autopeeking = true;

        if ( user_cmd->m_button_state.m_button_state & IN_ATTACK )
            m_quick_peek_data.m_fired = true;
    }
    else if ( !user_cmd->m_button_state.m_button_state & IN_ATTACK && ( processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 1 ) && m_quick_peek_data.m_should_retrack && !m_quick_peek_data.m_fired )
        m_quick_peek_data.m_should_retrack = false;
}

void c_movement::reset_quick_peek_data( ) {
    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        m_quick_peek_data.reset( vec3_t( 0.f, 0.f, 0.f ) );
}

void c_movement::movement_fix( c_user_cmd* user_cmd, vec3_t angle ) {
    vec3_t wish_angle{ user_cmd->pb.mutable_base( )->viewangles( ).x( ), user_cmd->pb.mutable_base( )->viewangles( ).y( ), user_cmd->pb.mutable_base( )->viewangles( ).z( ) };
    int sign = wish_angle.x > 89.f ? -1.f : 1.f;
    wish_angle.clamp( );

    vec3_t forward, right, up, old_forward, old_right, old_up;
    vec3_t view_angles = angle;

    g_math->angle_vectors( wish_angle, forward, right, up );

    forward.z = right.z = up.x = up.y = 0.f;

    forward.normalize_in_place( );
    right.normalize_in_place( );
    up.normalize_in_place( );

    g_math->angle_vectors( view_angles, old_forward, old_right, old_up );

    old_forward.z = old_right.z = old_up.x = old_up.y = 0.f;

    old_forward.normalize_in_place( );
    old_right.normalize_in_place( );
    old_up.normalize_in_place( );

    forward *= user_cmd->pb.mutable_base( )->forwardmove( );
    right *= user_cmd->pb.mutable_base( )->leftmove( );
    up *= user_cmd->pb.mutable_base( )->upmove( );

    float fixed_forward_move = old_forward.dot( right ) + old_forward.dot( forward ) + old_forward.dot( up, true );

    float fixed_side_move = old_right.dot( right ) + old_right.dot( forward ) + old_right.dot( up, true );

    float fixed_up_move = old_up.dot( right, true ) + old_up.dot( forward, true ) + old_up.dot( up );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
    user_cmd->pb.mutable_base( )->set_upmove( fixed_up_move );

    fixed_forward_move = sign * ( old_forward.dot( right ) + old_forward.dot( forward ) );
    fixed_side_move = old_right.dot( right ) + old_right.dot( forward );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
}

void c_movement::on_create_move( c_user_cmd* user_cmd, float old_yaw ) {
    if ( g_ctx->m_local_pawn->m_move_type( ) == movetype_ladder || g_ctx->m_local_pawn->m_move_type( ) == movetype_noclip )
        return;

    subtick_airstrafe(user_cmd);

    auto_strafe( user_cmd, old_yaw );
    quick_stop( user_cmd );
}

void c_movement::quick_stop( c_user_cmd* user_cmd ) {
    if ( !g_cfg->misc.m_quick_stop )
        return;

    c_cs_player_pawn* local_player = g_ctx->m_local_pawn;

    if ( !local_player || !local_player->is_alive( ) || !( local_player->m_flags( ) & FL_ONGROUND ) || m_in_bhop )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    if ( m_quick_peek_data.m_should_retrack )
        return;

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if ( !processing_movement_keys )
        stop_movement( user_cmd, local_player );
}

void c_movement::draw_autopeek( ) {
    if ( !g_interfaces->m_engine->is_connected( ) || !g_interfaces->m_engine->is_in_game( ) || !g_ctx->m_local_pawn )
        return;

    vec3_t position = vec3_t( );

    if ( !m_quick_peek_data.m_old_origin.is_zero( ) )
        position = m_quick_peek_data.m_old_origin;

    if ( position.is_zero( ) )
        return;

    if ( g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        g_render->radial_gradient_3d( m_quick_peek_data.m_old_origin, 20.f, ( g_cfg->misc.m_quick_peek_color ).set_alpha( 15.f ), ( g_cfg->misc.m_quick_peek_color ).set_alpha( 0.f ) );
}
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
24 Сен 2024
Сообщения
5
Реакции[?]
6
Поинты[?]
6K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
где кредитсы???
 
Начинающий
Статус
Оффлайн
Регистрация
9 Май 2024
Сообщения
130
Реакции[?]
3
Поинты[?]
3K
HvH Legend
Пользователь
Статус
Онлайн
Регистрация
23 Окт 2022
Сообщения
367
Реакции[?]
95
Поинты[?]
25K
ну вот вам педали. В коде ещё очень много чего полезного сразу скажу что это не моё я просто перезалил сюда
movement.hpp:
#pragma once

#include "../protobufs/protobufs.hpp"

struct qucik_peek_data_t {
    void reset( vec3_t vecOrigin = vec3_t( 0.f, 0.f, 0.f ) ) {
        m_old_origin = vecOrigin;
        m_should_retrack = false;
        m_autopeeking = false;
        m_fired = false;
        m_retracking_time = 0;
    }

    bool m_autopeeking = false;
    bool m_fired = false;
    bool m_should_retrack = false;
    int m_retracking_time = 0;
    vec3_t m_old_origin = vec3_t( 0, 0, 0 );
};

class c_movement {
    bool m_in_bhop{};
    bool m_turned_on{};
    bool m_retreat{};
    bool m_negative_side{};

    vec3_t m_vec_start_position{};

    qucik_peek_data_t m_quick_peek_data{};

    bool m_stopped{};
    void auto_strafe( c_user_cmd* user_cmd, float scop );
    void rotate_penis(c_user_cmd* current_cmd, float yaw);
    void limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
    void stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
public:
    float get_max_player_speed( );
    void bunnyhop(c_user_cmd* user_cmd);
    void auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread );
    void subtick_airstrafe(c_user_cmd* user_cmd);
    void quick_peek_assistant( c_user_cmd* pCmd, CBaseUserCmdPB* pBaseCmd );
    void reset_quick_peek_data( );
    void movement_fix( c_user_cmd* user_cmd, vec3_t angle );
    void on_create_move( c_user_cmd* user_cmd, float old_yaw );
    void quick_stop( c_user_cmd* user_cmd );
    void draw_autopeek( );
};

inline const auto g_movement = std::make_unique<c_movement>( );

movement.cpp:
#include "movement.hpp"
#include "../rage_bot/rage_bot.hpp"

#include "../../render/render.hpp"
#include "../rage_bot/rage_bot.hpp"
#include "../anti_hit/anti_hit.hpp"

void c_movement::bunnyhop( c_user_cmd* user_cmd ) {
    m_in_bhop = false;

    if ( !g_cfg->misc.m_bunny_hop )
        return;

    const auto is_jumping = user_cmd->m_button_state.m_button_state & IN_JUMP;
    if (is_jumping)
        return;

    user_cmd->m_button_state.m_button_state &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state2 &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state3 &= ~IN_JUMP;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
    {
        user_cmd->m_button_state.m_button_state |= IN_JUMP;
        user_cmd->m_button_state.m_button_state3 |= IN_JUMP;

        auto poopl = g_protobuf->add_subtick_move_step(user_cmd);
        poopl->set_button(IN_JUMP);
        poopl->set_pressed(true);
        poopl->set_when(0.999f);

        auto poopl1 = g_protobuf->add_subtick_move_step(user_cmd);
        poopl1->set_button(IN_JUMP);
        poopl1->set_pressed(false);
        poopl1->set_when(0.999f);
    }
}

float calculate_delta(float m_speed) {
    const static float max_speed = 300.f;
    const static auto sv_airaccelerate = g_interfaces->m_var->get_by_name("sv_airaccelerate")->get_float();
    const float term = g_cfg->misc.m_strafe_smooth / sv_airaccelerate / max_speed * 100.0f / m_speed;

    if (term < 1.0f && term > -1.0f)
        return std::acos(term);

    return 0.0f;
};

void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };


    auto local = g_ctx->m_local_pawn;

    bool on_ground = local->m_flags() & FL_ONGROUND;

    if (on_ground)
        return;

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t viewangles, strafe, velocity = local->m_vec_velocity();

    velocity.z = 0.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);

    float fl_velocity = velocity.length_2d();
    float strafe_angles = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

    if (strafe_angles > 90.0f)
        strafe_angles = 90.0f;
    else if (strafe_angles < 0.0f)
        strafe_angles = 0.0f;

    static float flOldYaw = 0.f;

    viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const vec3_t viewangles_backup = viewangles;

    float delta_yaw = viewangles.y - flOldYaw;

    static bool direction = false;

    if (std::abs(delta_yaw) < strafe_angles)
    {
        strafe = viewangles;

        if (direction)
        {
            strafe.y += strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            strafe.y -= strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        direction = !direction;
    }
    else
    {
        if (delta_yaw < 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        else if (delta_yaw > 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
    }

    rotate_penis(user_cmd, strafe.y);

    flOldYaw = viewangles.y;


    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }
}

/*
void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t& velocity = g_ctx->m_local_pawn->m_vec_velocity();

    float velocity_length = velocity.length_2d();

    if (velocity_length < 5.f)
        return;

    vec3_t viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const int buttons = user_cmd->m_button_state.m_button_state;

    float offset = 0.f;

    if (buttons & IN_MOVELEFT)
        offset += 90.f;
    if (buttons & IN_MOVERIGHT)
        offset -= 90.f;

    if (buttons & IN_FORWARD)
        offset *= 1.5f;
    else if (buttons & IN_BACK)
        offset = (-offset * 1.5f) + 180.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);
    user_cmd->pb.mutable_base()->set_leftmove(0.f);

    viewangles.y -= offset;

    const float delta_yaw = remainderf(viewangles.y - previous_yaw, 360.f);
    const float abs_delta_yaw = std::fabsf(delta_yaw);

    store_previous_yaw();

    static bool direction = false;

    if (true || abs_delta_yaw < rad2deg(atan2f(30, hypotf(velocity.x, velocity.y))))
    {
        const float strafe_angle = remainderf(viewangles.y - rad2deg(atan2f(velocity.y, velocity.x)), 360.f);

        if (std::signbit(strafe_angle) == 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        viewangles.y += strafe_angle;
    }
    else
    {
        if (std::signbit(delta_yaw) != 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
    }

    rotate_penis(user_cmd, viewangles.y);

    direction = !direction;

    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    /*bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }*/

void c_movement::rotate_penis(c_user_cmd* current_cmd, float yaw) {
    const float rotation_angle_rad = deg2rad(current_cmd->pb.base().viewangles().y() - yaw);
    const float forward_move = current_cmd->pb.base().forwardmove();
    const float side_move = current_cmd->pb.base().leftmove();

    float rotated_forward_move = forward_move * std::cos(rotation_angle_rad) - side_move * std::sin(rotation_angle_rad);
    float rotaded_side_move = forward_move * std::sin(rotation_angle_rad) + side_move * std::cos(rotation_angle_rad);

    current_cmd->pb.mutable_base()->set_forwardmove(rotated_forward_move);
    current_cmd->pb.mutable_base()->set_leftmove(rotaded_side_move);
}

float c_movement::get_max_player_speed( )  {
    if ( !g_ctx->m_local_pawn->get_active_weapon( ) || !g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( ) )
        return 260.f;

    return  g_ctx->m_local_pawn->m_scoped( ) ? g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 1 ] : g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 0 ];
}

void c_movement::limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    float max_speed = get_max_player_speed( );
    max_speed *= 0.033999f;

    const float distance_to_minimal_speed = g_ctx->m_local_pawn->m_vec_velocity( ).length_2d( ) / max_speed;
    if ( distance_to_minimal_speed <= 0.0f )
        return;

    const float forward_move = user_cmd->pb.mutable_base( )->forwardmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_forwardmove( forward_move );

    const float side_move = user_cmd->pb.mutable_base( )->leftmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_leftmove( side_move );
}

void c_movement::stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    vec3_t velocity = g_ctx->m_local_pawn->m_vec_velocity( );
    float speed = velocity.length_2d( );
    if ( speed < 1.f ) {
        user_cmd->pb.mutable_base( )->set_forwardmove( 0.f );
        user_cmd->pb.mutable_base( )->set_leftmove( 0.f );
        return;
    }

    const auto max_accelspeed = g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * g_interfaces->m_var->get_by_name( "sv_maxspeed" )->get_float( ) * movement_services->m_surface_friction( ) * INTERVAL_PER_TICK;

    auto get_maximum_accelerate_speed = [&]
    {
        const auto speed_ratio = speed / ( g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * INTERVAL_PER_TICK );
        return speed - max_accelspeed <= -1.f ? max_accelspeed / speed_ratio : max_accelspeed;
    };

    vec3_t view_angles{};
    g_interfaces->m_client->get_view_angles( view_angles );

    vec3_t velocity_angle{ };
    g_math->vector_angles( velocity * -1.f, velocity_angle );
    velocity_angle.y = view_angles.y - velocity_angle.y;

    vec3_t forward{ };
    g_math->angle_vectors( velocity_angle, forward );

    const auto total_speed = get_maximum_accelerate_speed( );
    const auto max_weapon_speed = get_max_player_speed( );

    user_cmd->pb.mutable_base( )->set_forwardmove( ( forward.x * total_speed ) / max_weapon_speed );
    user_cmd->pb.mutable_base( )->set_leftmove( ( forward.y * -total_speed ) / max_weapon_speed );
}

void c_movement::auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread ) {
    if ( !g_cfg->rage_bot.m_auto_stop )
        return;

    if ( no_spread )
        return;

    if ( !( local_player->m_flags( ) & FL_ONGROUND ) )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    float max_accurate_speed = get_max_player_speed( ) * 0.25f;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= max_accurate_speed )
        return limit_speed( user_cmd, local_player );

    stop_movement( user_cmd, local_player );
}

void c_movement::subtick_airstrafe(c_user_cmd* user_cmd) {
    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (!g_cfg->misc.m_auto_strafe)
        return;

    for (auto i = 0; i < 12; i++) {
        auto subtick = g_protobuf->add_subtick_move_step(user_cmd);
    }

    for (auto i = 0; i < user_cmd->pb.base().subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);
        if (i == 0) {
            subtick->set_when(FLT_TRUE_MIN);
            continue;
        }
        subtick->set_button(0);

        subtick->set_when((1.f / 12.f) * (i));
    }
}

void c_movement::quick_peek_assistant( c_user_cmd* user_cmd, CBaseUserCmdPB* base_cmd ) {
    static vec3_t vec_origin = vec3_t( 0.0f, 0.0f, 0.0f );

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) ) {
        m_quick_peek_data.reset( );
        return;
    }

    if ( m_quick_peek_data.m_old_origin.is_zero( ) ) {
        vec_origin = g_ctx->m_local_pawn->m_scene_node( )->m_origin( );

        game_trace_t trace;
        trace_filter_t filter( 0x3001, nullptr, nullptr, 3 );
        filter.m_arr_collisions.at( 1 ) = 0x10000;

        ray_t ray = ray_t( );
        g_interfaces->m_trace->trace_shape( &ray, g_prediction->get_local_data( )->m_eye_pos, g_prediction->get_local_data( )->m_eye_pos - vec3_t( 0.0f, 0.0f, 1000.f ), &filter, &trace );

        if ( trace.m_fraction < 1.0f )
            vec_origin = trace.m_end + vec3_t( 0.0f, 0.0f, 2.0f );

        m_quick_peek_data.reset( vec_origin );
    }
    else {
        if ( g_ctx->m_local_pawn->m_scene_node( )->m_origin( ).dist( m_quick_peek_data.m_old_origin ) > 5.0f ) {
            if ( m_quick_peek_data.m_should_retrack ) {
                ++m_quick_peek_data.m_retracking_time;

                vec3_t ang_angles_to_pos = vec3_t( 0, 0, 0 );
                g_math->vector_angles( m_quick_peek_data.m_old_origin - g_ctx->m_local_pawn->m_scene_node( )->m_origin( ), ang_angles_to_pos );

                base_cmd->set_forwardmove( std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::cos( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
                base_cmd->set_leftmove( -std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::sin( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
            }
        }
        else {
            m_quick_peek_data.m_should_retrack = false;
            m_quick_peek_data.m_fired = false;
            m_quick_peek_data.m_retracking_time = 0;
        }
    }

    if ( user_cmd->m_button_state.m_button_state & IN_ATTACK || !processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 0 ) {
        m_quick_peek_data.m_should_retrack = true;
        m_quick_peek_data.m_autopeeking = true;

        if ( user_cmd->m_button_state.m_button_state & IN_ATTACK )
            m_quick_peek_data.m_fired = true;
    }
    else if ( !user_cmd->m_button_state.m_button_state & IN_ATTACK && ( processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 1 ) && m_quick_peek_data.m_should_retrack && !m_quick_peek_data.m_fired )
        m_quick_peek_data.m_should_retrack = false;
}

void c_movement::reset_quick_peek_data( ) {
    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        m_quick_peek_data.reset( vec3_t( 0.f, 0.f, 0.f ) );
}

void c_movement::movement_fix( c_user_cmd* user_cmd, vec3_t angle ) {
    vec3_t wish_angle{ user_cmd->pb.mutable_base( )->viewangles( ).x( ), user_cmd->pb.mutable_base( )->viewangles( ).y( ), user_cmd->pb.mutable_base( )->viewangles( ).z( ) };
    int sign = wish_angle.x > 89.f ? -1.f : 1.f;
    wish_angle.clamp( );

    vec3_t forward, right, up, old_forward, old_right, old_up;
    vec3_t view_angles = angle;

    g_math->angle_vectors( wish_angle, forward, right, up );

    forward.z = right.z = up.x = up.y = 0.f;

    forward.normalize_in_place( );
    right.normalize_in_place( );
    up.normalize_in_place( );

    g_math->angle_vectors( view_angles, old_forward, old_right, old_up );

    old_forward.z = old_right.z = old_up.x = old_up.y = 0.f;

    old_forward.normalize_in_place( );
    old_right.normalize_in_place( );
    old_up.normalize_in_place( );

    forward *= user_cmd->pb.mutable_base( )->forwardmove( );
    right *= user_cmd->pb.mutable_base( )->leftmove( );
    up *= user_cmd->pb.mutable_base( )->upmove( );

    float fixed_forward_move = old_forward.dot( right ) + old_forward.dot( forward ) + old_forward.dot( up, true );

    float fixed_side_move = old_right.dot( right ) + old_right.dot( forward ) + old_right.dot( up, true );

    float fixed_up_move = old_up.dot( right, true ) + old_up.dot( forward, true ) + old_up.dot( up );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
    user_cmd->pb.mutable_base( )->set_upmove( fixed_up_move );

    fixed_forward_move = sign * ( old_forward.dot( right ) + old_forward.dot( forward ) );
    fixed_side_move = old_right.dot( right ) + old_right.dot( forward );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
}

void c_movement::on_create_move( c_user_cmd* user_cmd, float old_yaw ) {
    if ( g_ctx->m_local_pawn->m_move_type( ) == movetype_ladder || g_ctx->m_local_pawn->m_move_type( ) == movetype_noclip )
        return;

    subtick_airstrafe(user_cmd);

    auto_strafe( user_cmd, old_yaw );
    quick_stop( user_cmd );
}

void c_movement::quick_stop( c_user_cmd* user_cmd ) {
    if ( !g_cfg->misc.m_quick_stop )
        return;

    c_cs_player_pawn* local_player = g_ctx->m_local_pawn;

    if ( !local_player || !local_player->is_alive( ) || !( local_player->m_flags( ) & FL_ONGROUND ) || m_in_bhop )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    if ( m_quick_peek_data.m_should_retrack )
        return;

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if ( !processing_movement_keys )
        stop_movement( user_cmd, local_player );
}

void c_movement::draw_autopeek( ) {
    if ( !g_interfaces->m_engine->is_connected( ) || !g_interfaces->m_engine->is_in_game( ) || !g_ctx->m_local_pawn )
        return;

    vec3_t position = vec3_t( );

    if ( !m_quick_peek_data.m_old_origin.is_zero( ) )
        position = m_quick_peek_data.m_old_origin;

    if ( position.is_zero( ) )
        return;

    if ( g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        g_render->radial_gradient_3d( m_quick_peek_data.m_old_origin, 20.f, ( g_cfg->misc.m_quick_peek_color ).set_alpha( 15.f ), ( g_cfg->misc.m_quick_peek_color ).set_alpha( 0.f ) );
}
а кудда эта вставить, в рендер менюшки ?
1727288073235.png
Просто у меня что-то тут красное, это типо моя тянка следы оставила исходящие из своей вагины или че ?
 
Начинающий
Статус
Оффлайн
Регистрация
22 Мар 2022
Сообщения
147
Реакции[?]
6
Поинты[?]
6K
где кредитсы???
но ведь это не ты слил ты писал что это не ласт и хуй вам а не педали и тд
а кудда эта вставить, в рендер менюшки ?
Посмотреть вложение 286493
Просто у меня что-то тут красное, это типо моя тянка следы оставила исходящие из своей вагины или че ?
сколько лет твоей тянке...?
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
13 Авг 2022
Сообщения
132
Реакции[?]
12
Поинты[?]
5K
ну вот вам педали. В коде ещё очень много чего полезного сразу скажу что это не моё я просто перезалил сюда

и да хватит мне задавать вопросы это не я писал я просто перезалил сюда, так что вопросы по коду точно не мне

и писал этот код schw4nzlutsch3n и shialex так что вопросы по коды к ним

movement.hpp:
#pragma once

#include "../protobufs/protobufs.hpp"

struct qucik_peek_data_t {
    void reset( vec3_t vecOrigin = vec3_t( 0.f, 0.f, 0.f ) ) {
        m_old_origin = vecOrigin;
        m_should_retrack = false;
        m_autopeeking = false;
        m_fired = false;
        m_retracking_time = 0;
    }

    bool m_autopeeking = false;
    bool m_fired = false;
    bool m_should_retrack = false;
    int m_retracking_time = 0;
    vec3_t m_old_origin = vec3_t( 0, 0, 0 );
};

class c_movement {
    bool m_in_bhop{};
    bool m_turned_on{};
    bool m_retreat{};
    bool m_negative_side{};

    vec3_t m_vec_start_position{};

    qucik_peek_data_t m_quick_peek_data{};

    bool m_stopped{};
    void auto_strafe( c_user_cmd* user_cmd, float scop );
    void rotate_penis(c_user_cmd* current_cmd, float yaw);
    void limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
    void stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player );
public:
    float get_max_player_speed( );
    void bunnyhop(c_user_cmd* user_cmd);
    void auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread );
    void subtick_airstrafe(c_user_cmd* user_cmd);
    void quick_peek_assistant( c_user_cmd* pCmd, CBaseUserCmdPB* pBaseCmd );
    void reset_quick_peek_data( );
    void movement_fix( c_user_cmd* user_cmd, vec3_t angle );
    void on_create_move( c_user_cmd* user_cmd, float old_yaw );
    void quick_stop( c_user_cmd* user_cmd );
    void draw_autopeek( );
};

inline const auto g_movement = std::make_unique<c_movement>( );

movement.cpp:
#include "movement.hpp"
#include "../rage_bot/rage_bot.hpp"

#include "../../render/render.hpp"
#include "../rage_bot/rage_bot.hpp"
#include "../anti_hit/anti_hit.hpp"

void c_movement::bunnyhop( c_user_cmd* user_cmd ) {
    m_in_bhop = false;

    if ( !g_cfg->misc.m_bunny_hop )
        return;

    const auto is_jumping = user_cmd->m_button_state.m_button_state & IN_JUMP;
    if (is_jumping)
        return;

    user_cmd->m_button_state.m_button_state &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state2 &= ~IN_JUMP;
    user_cmd->m_button_state.m_button_state3 &= ~IN_JUMP;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
    {
        user_cmd->m_button_state.m_button_state |= IN_JUMP;
        user_cmd->m_button_state.m_button_state3 |= IN_JUMP;

        auto poopl = g_protobuf->add_subtick_move_step(user_cmd);
        poopl->set_button(IN_JUMP);
        poopl->set_pressed(true);
        poopl->set_when(0.999f);

        auto poopl1 = g_protobuf->add_subtick_move_step(user_cmd);
        poopl1->set_button(IN_JUMP);
        poopl1->set_pressed(false);
        poopl1->set_when(0.999f);
    }
}

float calculate_delta(float m_speed) {
    const static float max_speed = 300.f;
    const static auto sv_airaccelerate = g_interfaces->m_var->get_by_name("sv_airaccelerate")->get_float();
    const float term = g_cfg->misc.m_strafe_smooth / sv_airaccelerate / max_speed * 100.0f / m_speed;

    if (term < 1.0f && term > -1.0f)
        return std::acos(term);

    return 0.0f;
};

void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };


    auto local = g_ctx->m_local_pawn;

    bool on_ground = local->m_flags() & FL_ONGROUND;

    if (on_ground)
        return;

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t viewangles, strafe, velocity = local->m_vec_velocity();

    velocity.z = 0.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);

    float fl_velocity = velocity.length_2d();
    float strafe_angles = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

    if (strafe_angles > 90.0f)
        strafe_angles = 90.0f;
    else if (strafe_angles < 0.0f)
        strafe_angles = 0.0f;

    static float flOldYaw = 0.f;

    viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const vec3_t viewangles_backup = viewangles;

    float delta_yaw = viewangles.y - flOldYaw;

    static bool direction = false;

    if (std::abs(delta_yaw) < strafe_angles)
    {
        strafe = viewangles;

        if (direction)
        {
            strafe.y += strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            strafe.y -= strafe_angles;
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        direction = !direction;
    }
    else
    {
        if (delta_yaw < 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        else if (delta_yaw > 0.0f)
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
    }

    rotate_penis(user_cmd, strafe.y);

    flOldYaw = viewangles.y;


    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }
}

/*
void c_movement::auto_strafe( c_user_cmd* user_cmd, float old_yaw ) {
    if ( !g_cfg->misc.m_auto_strafe )
        return;

    if ( !user_cmd || !user_cmd->pb.mutable_base()->mutable_viewangles( ) )
        return;

    // 1794 - noclip, 2313 - ladder
    if (!g_ctx->m_local_pawn
        || !g_ctx->m_local_pawn->is_alive()
        || g_ctx->m_local_pawn->m_move_type() == 1794
        || g_ctx->m_local_pawn->m_move_type() == 2313)
        return;

    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (user_cmd->m_button_state.m_button_state & IN_SPEED)
        return;

    static float previous_yaw = 0.f;

    auto store_previous_yaw = [&]()
        {
            previous_yaw = g_interfaces->m_csgo_input->m_view_angles.y;
        };

    static auto cl_sidespeed = 1.f;
    static auto cl_forwardspeed = 1.f;

    vec3_t& velocity = g_ctx->m_local_pawn->m_vec_velocity();

    float velocity_length = velocity.length_2d();

    if (velocity_length < 5.f)
        return;

    vec3_t viewangles = g_interfaces->m_csgo_input->m_view_angles;

    const int buttons = user_cmd->m_button_state.m_button_state;

    float offset = 0.f;

    if (buttons & IN_MOVELEFT)
        offset += 90.f;
    if (buttons & IN_MOVERIGHT)
        offset -= 90.f;

    if (buttons & IN_FORWARD)
        offset *= 1.5f;
    else if (buttons & IN_BACK)
        offset = (-offset * 1.5f) + 180.f;

    user_cmd->pb.mutable_base()->set_forwardmove(0.f);
    user_cmd->pb.mutable_base()->set_leftmove(0.f);

    viewangles.y -= offset;

    const float delta_yaw = remainderf(viewangles.y - previous_yaw, 360.f);
    const float abs_delta_yaw = std::fabsf(delta_yaw);

    store_previous_yaw();

    static bool direction = false;

    if (true || abs_delta_yaw < rad2deg(atan2f(30, hypotf(velocity.x, velocity.y))))
    {
        const float strafe_angle = remainderf(viewangles.y - rad2deg(atan2f(velocity.y, velocity.x)), 360.f);

        if (std::signbit(strafe_angle) == 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }

        viewangles.y += strafe_angle;
    }
    else
    {
        if (std::signbit(delta_yaw) != 0)
        {
            user_cmd->pb.mutable_base()->set_leftmove(-cl_sidespeed);
        }
        else
        {
            user_cmd->pb.mutable_base()->set_leftmove(cl_sidespeed);
        }
    }

    rotate_penis(user_cmd, viewangles.y);

    direction = !direction;

    float forward_move = user_cmd->pb.base().forwardmove();
    float side_move = user_cmd->pb.base().leftmove();

    /*bool dir = !direction;

    for (auto i = 0; i < user_cmd->pb.mutable_base()->subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);

        strafe = viewangles;

        float sidemove = 0.f;

        velocity += velocity * 0.015625f;

        float fl_velocity = velocity.length_2d();
        float strafe_angle = fl_velocity == 0.f ? 90.f : min(90.f, rad2deg(std::asin(15.f / fl_velocity)));

        if (strafe_angle > 90.0f)
            strafe_angle = 90.0f;
        else if (strafe_angle < 0.0f)
            strafe_angle = 0.0f;

        if (dir)
        {
            strafe.y += strafe_angle;
            sidemove = cl_sidespeed;
        }
        else
        {
            strafe.y -= strafe_angle;
            sidemove = -cl_sidespeed;
        }

        dir = !dir;

        const float rotation_angle_rad = deg2rad(user_cmd->pb.base().viewangles().y() - strafe.y);

        float rotated_forward_move = 0.f * std::cos(rotation_angle_rad) - sidemove * std::sin(rotation_angle_rad);
        float rotaded_side_move = 0.f * std::sin(rotation_angle_rad) + sidemove * std::cos(rotation_angle_rad);

        subtick->set_analog_forward_delta(rotated_forward_move - forward_move);
        subtick->set_analog_left_delta(rotaded_side_move - side_move);

        forward_move = rotated_forward_move;
        side_move = rotaded_side_move;
    }*/

void c_movement::rotate_penis(c_user_cmd* current_cmd, float yaw) {
    const float rotation_angle_rad = deg2rad(current_cmd->pb.base().viewangles().y() - yaw);
    const float forward_move = current_cmd->pb.base().forwardmove();
    const float side_move = current_cmd->pb.base().leftmove();

    float rotated_forward_move = forward_move * std::cos(rotation_angle_rad) - side_move * std::sin(rotation_angle_rad);
    float rotaded_side_move = forward_move * std::sin(rotation_angle_rad) + side_move * std::cos(rotation_angle_rad);

    current_cmd->pb.mutable_base()->set_forwardmove(rotated_forward_move);
    current_cmd->pb.mutable_base()->set_leftmove(rotaded_side_move);
}

float c_movement::get_max_player_speed( )  {
    if ( !g_ctx->m_local_pawn->get_active_weapon( ) || !g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( ) )
        return 260.f;

    return  g_ctx->m_local_pawn->m_scoped( ) ? g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 1 ] : g_ctx->m_local_pawn->get_active_weapon( )->get_weapon_data( )->m_max_speed( )[ 0 ];
}

void c_movement::limit_speed( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    float max_speed = get_max_player_speed( );
    max_speed *= 0.033999f;

    const float distance_to_minimal_speed = g_ctx->m_local_pawn->m_vec_velocity( ).length_2d( ) / max_speed;
    if ( distance_to_minimal_speed <= 0.0f )
        return;

    const float forward_move = user_cmd->pb.mutable_base( )->forwardmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_forwardmove( forward_move );

    const float side_move = user_cmd->pb.mutable_base( )->leftmove( ) / distance_to_minimal_speed;

    user_cmd->pb.mutable_base( )->set_leftmove( side_move );
}

void c_movement::stop_movement( c_user_cmd* user_cmd, c_cs_player_pawn* local_player ) {
    c_player_movement_service* movement_services = local_player->m_movement_services( );

    if ( !movement_services )
        return;

    vec3_t velocity = g_ctx->m_local_pawn->m_vec_velocity( );
    float speed = velocity.length_2d( );
    if ( speed < 1.f ) {
        user_cmd->pb.mutable_base( )->set_forwardmove( 0.f );
        user_cmd->pb.mutable_base( )->set_leftmove( 0.f );
        return;
    }

    const auto max_accelspeed = g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * g_interfaces->m_var->get_by_name( "sv_maxspeed" )->get_float( ) * movement_services->m_surface_friction( ) * INTERVAL_PER_TICK;

    auto get_maximum_accelerate_speed = [&]
    {
        const auto speed_ratio = speed / ( g_interfaces->m_var->get_by_name( "sv_accelerate" )->get_float( ) * INTERVAL_PER_TICK );
        return speed - max_accelspeed <= -1.f ? max_accelspeed / speed_ratio : max_accelspeed;
    };

    vec3_t view_angles{};
    g_interfaces->m_client->get_view_angles( view_angles );

    vec3_t velocity_angle{ };
    g_math->vector_angles( velocity * -1.f, velocity_angle );
    velocity_angle.y = view_angles.y - velocity_angle.y;

    vec3_t forward{ };
    g_math->angle_vectors( velocity_angle, forward );

    const auto total_speed = get_maximum_accelerate_speed( );
    const auto max_weapon_speed = get_max_player_speed( );

    user_cmd->pb.mutable_base( )->set_forwardmove( ( forward.x * total_speed ) / max_weapon_speed );
    user_cmd->pb.mutable_base( )->set_leftmove( ( forward.y * -total_speed ) / max_weapon_speed );
}

void c_movement::auto_stop( c_user_cmd* user_cmd, c_cs_player_pawn* local_player, c_base_player_weapon* active_weapon, bool no_spread ) {
    if ( !g_cfg->rage_bot.m_auto_stop )
        return;

    if ( no_spread )
        return;

    if ( !( local_player->m_flags( ) & FL_ONGROUND ) )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    float max_accurate_speed = get_max_player_speed( ) * 0.25f;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= max_accurate_speed )
        return limit_speed( user_cmd, local_player );

    stop_movement( user_cmd, local_player );
}

void c_movement::subtick_airstrafe(c_user_cmd* user_cmd) {
    if (g_ctx->m_local_pawn->m_flags() & FL_ONGROUND)
        return;

    if (!g_cfg->misc.m_auto_strafe)
        return;

    for (auto i = 0; i < 12; i++) {
        auto subtick = g_protobuf->add_subtick_move_step(user_cmd);
    }

    for (auto i = 0; i < user_cmd->pb.base().subtick_moves_size(); i++) {
        auto subtick = user_cmd->pb.mutable_base()->mutable_subtick_moves(i);
        if (i == 0) {
            subtick->set_when(FLT_TRUE_MIN);
            continue;
        }
        subtick->set_button(0);

        subtick->set_when((1.f / 12.f) * (i));
    }
}

void c_movement::quick_peek_assistant( c_user_cmd* user_cmd, CBaseUserCmdPB* base_cmd ) {
    static vec3_t vec_origin = vec3_t( 0.0f, 0.0f, 0.0f );

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) ) {
        m_quick_peek_data.reset( );
        return;
    }

    if ( m_quick_peek_data.m_old_origin.is_zero( ) ) {
        vec_origin = g_ctx->m_local_pawn->m_scene_node( )->m_origin( );

        game_trace_t trace;
        trace_filter_t filter( 0x3001, nullptr, nullptr, 3 );
        filter.m_arr_collisions.at( 1 ) = 0x10000;

        ray_t ray = ray_t( );
        g_interfaces->m_trace->trace_shape( &ray, g_prediction->get_local_data( )->m_eye_pos, g_prediction->get_local_data( )->m_eye_pos - vec3_t( 0.0f, 0.0f, 1000.f ), &filter, &trace );

        if ( trace.m_fraction < 1.0f )
            vec_origin = trace.m_end + vec3_t( 0.0f, 0.0f, 2.0f );

        m_quick_peek_data.reset( vec_origin );
    }
    else {
        if ( g_ctx->m_local_pawn->m_scene_node( )->m_origin( ).dist( m_quick_peek_data.m_old_origin ) > 5.0f ) {
            if ( m_quick_peek_data.m_should_retrack ) {
                ++m_quick_peek_data.m_retracking_time;

                vec3_t ang_angles_to_pos = vec3_t( 0, 0, 0 );
                g_math->vector_angles( m_quick_peek_data.m_old_origin - g_ctx->m_local_pawn->m_scene_node( )->m_origin( ), ang_angles_to_pos );

                base_cmd->set_forwardmove( std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::cos( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
                base_cmd->set_leftmove( -std::fmaxf( std::fminf( 1.0f, static_cast<float>( std::sin( deg2rad( ( base_cmd->viewangles( ).y( ) - ang_angles_to_pos.y ) ) ) * static_cast<float>( std::cos( ang_angles_to_pos.x * 0.017453292 ) ) ) ), -1.0f ) );
            }
        }
        else {
            m_quick_peek_data.m_should_retrack = false;
            m_quick_peek_data.m_fired = false;
            m_quick_peek_data.m_retracking_time = 0;
        }
    }

    if ( user_cmd->m_button_state.m_button_state & IN_ATTACK || !processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 0 ) {
        m_quick_peek_data.m_should_retrack = true;
        m_quick_peek_data.m_autopeeking = true;

        if ( user_cmd->m_button_state.m_button_state & IN_ATTACK )
            m_quick_peek_data.m_fired = true;
    }
    else if ( !user_cmd->m_button_state.m_button_state & IN_ATTACK && ( processing_movement_keys && g_cfg->misc.m_quick_peek_assistant_type == 1 ) && m_quick_peek_data.m_should_retrack && !m_quick_peek_data.m_fired )
        m_quick_peek_data.m_should_retrack = false;
}

void c_movement::reset_quick_peek_data( ) {
    if ( !g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        m_quick_peek_data.reset( vec3_t( 0.f, 0.f, 0.f ) );
}

void c_movement::movement_fix( c_user_cmd* user_cmd, vec3_t angle ) {
    vec3_t wish_angle{ user_cmd->pb.mutable_base( )->viewangles( ).x( ), user_cmd->pb.mutable_base( )->viewangles( ).y( ), user_cmd->pb.mutable_base( )->viewangles( ).z( ) };
    int sign = wish_angle.x > 89.f ? -1.f : 1.f;
    wish_angle.clamp( );

    vec3_t forward, right, up, old_forward, old_right, old_up;
    vec3_t view_angles = angle;

    g_math->angle_vectors( wish_angle, forward, right, up );

    forward.z = right.z = up.x = up.y = 0.f;

    forward.normalize_in_place( );
    right.normalize_in_place( );
    up.normalize_in_place( );

    g_math->angle_vectors( view_angles, old_forward, old_right, old_up );

    old_forward.z = old_right.z = old_up.x = old_up.y = 0.f;

    old_forward.normalize_in_place( );
    old_right.normalize_in_place( );
    old_up.normalize_in_place( );

    forward *= user_cmd->pb.mutable_base( )->forwardmove( );
    right *= user_cmd->pb.mutable_base( )->leftmove( );
    up *= user_cmd->pb.mutable_base( )->upmove( );

    float fixed_forward_move = old_forward.dot( right ) + old_forward.dot( forward ) + old_forward.dot( up, true );

    float fixed_side_move = old_right.dot( right ) + old_right.dot( forward ) + old_right.dot( up, true );

    float fixed_up_move = old_up.dot( right, true ) + old_up.dot( forward, true ) + old_up.dot( up );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
    user_cmd->pb.mutable_base( )->set_upmove( fixed_up_move );

    fixed_forward_move = sign * ( old_forward.dot( right ) + old_forward.dot( forward ) );
    fixed_side_move = old_right.dot( right ) + old_right.dot( forward );

    user_cmd->pb.mutable_base( )->set_forwardmove( fixed_forward_move );
    user_cmd->pb.mutable_base( )->set_leftmove( fixed_side_move );
}

void c_movement::on_create_move( c_user_cmd* user_cmd, float old_yaw ) {
    if ( g_ctx->m_local_pawn->m_move_type( ) == movetype_ladder || g_ctx->m_local_pawn->m_move_type( ) == movetype_noclip )
        return;

    subtick_airstrafe(user_cmd);

    auto_strafe( user_cmd, old_yaw );
    quick_stop( user_cmd );
}

void c_movement::quick_stop( c_user_cmd* user_cmd ) {
    if ( !g_cfg->misc.m_quick_stop )
        return;

    c_cs_player_pawn* local_player = g_ctx->m_local_pawn;

    if ( !local_player || !local_player->is_alive() || !( local_player->m_flags() & FL_ONGROUND ) || m_in_bhop )
        return;

    if ( local_player->m_vec_velocity( ).length_2d( ) <= 0.f )
        return;

    if (m_quick_peek_data.m_should_retrack)
        return;

    bool processing_movement_keys = ( user_cmd->m_button_state.m_button_state & ( IN_TURNLEFT ) || user_cmd->m_button_state.m_button_state & ( IN_FORWARD ) || user_cmd->m_button_state.m_button_state & ( IN_BACK ) ||
        user_cmd->m_button_state.m_button_state & ( IN_TURNRIGHT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVELEFT ) || user_cmd->m_button_state.m_button_state & ( IN_MOVERIGHT ) ||
        user_cmd->m_button_state.m_button_state & ( IN_JUMP ) );

    if (!processing_movement_keys)
        stop_movement( user_cmd, local_player );
}

void c_movement::draw_autopeek() {
    if ( !g_interfaces->m_engine->is_connected() || !g_interfaces->m_engine->is_in_game() || !g_ctx->m_local_pawn )
        return;

    vec3_t position = vec3_t( );

    if ( !m_quick_peek_data.m_old_origin.is_zero() )
        position = m_quick_peek_data.m_old_origin;

    if ( position.is_zero( ) )
        return;

    if ( g_key_handler->is_pressed( g_cfg->misc.m_override_quick_peek_assistant, g_cfg->misc.m_override_quick_peek_assistant_style ) )
        g_render->radial_gradient_3d( m_quick_peek_data.m_old_origin, 20.f, ( g_cfg->misc.m_quick_peek_color ).set_alpha( 15.f), ( g_cfg->misc.m_quick_peek_color).set_alpha( 0.f ) );
}
[/QUOTE ]

/del useless ong
 
Новичок
Статус
Оффлайн
Регистрация
14 Апр 2021
Сообщения
1
Реакции[?]
0
Поинты[?]
0
shit code, doesn't even work, tried everything to fix but it's just so bad that I'm going to commit suicide and spread miss information online from now on.
 
Сверху Снизу