Crosshair "blockbot"

Олдфаг
Статус
Оффлайн
Регистрация
5 Июл 2017
Сообщения
2,108
Реакции[?]
1,189
Поинты[?]
0
worldgamer123:
Hey,

decided to make a "blockbot" (if you can call it that) which will try to get your head into your teammates crosshair.
Great for banning people.

It's not perfect and could be improved a bit, however this is good enough for me. I probably also overcomplicated the position calculation but whatever. Enjoy.

C++:
void blockbot_crosshair( sdk::user_cmd* cmd ) {
    //Return if we are moving
    if ( cmd->sidemove != 0 || cmd->forwardmove != 0 )
        return;
 
    sdk::base_entity* local = interfaces::client_entity_list->get_client_entity( intefaces::engine->get_local_player( ) );
    sdk::base_entity* closest_teammate = nullptr;
 
    if ( !local || !local->alive( ) )
        return;
 
    //Only target teammates within 245 units
    float dist = 245.f;
    for ( int i = 0; i < interfaces::engine->max_clients( ); i++ ) {
        sdk::base_entity* current_ent = interfaces::client_entity_list->get_client_entity( i );
 
        if ( !current_ent || current_ent == local )
            continue;
 
        if ( !current_ent->alive( ) || current_ent->dormant( ) || current_ent->team( ) != local->team( ) )
            continue;
 
        float current_dist = local->abs_origin( ).dist( current_ent->abs_origin( ) );
        if ( current_dist < dist ) {
            dist = current_dist;
            closest_teammate = current_ent;
        }
    }
 
    //Do we have a teammate we can block?
    if ( !closest_teammate )
        return;
 
    //Distance we want to keep from the player
    float radius = 45.f;
 
    static auto pi = std::atan( 1 ) * 4;
    auto target_origin = closest_teammate->abs_origin( );
    auto target_view = closest_teammate->view_angles( ).normalized( ).y;
 
    //Normalize the view to 0-360°
    if ( target_view < 0.f )
        target_view += 360.f;
 
    //Get the sin of our view in radians (used for y position)
    auto sin_view = sin( target_view / 180.f * pi );
 
    //Get the lenght of the adjacent side
    auto delta_x = sqrt( 1 - sin_view * sin_view ) * radius;
 
    /*
        Because a square root can be +- something, we need to account for negative values
        Don't know why but we need to negate the distance between 90° and 270°
    */
    if ( target_view > 90.f && target_view < 270.f )
        delta_x = -delta_x;
 
    //This is our target position now
    target_origin.x += delta_x;
    target_origin.y += sin_view * radius;
 
    //"InTeRpOlAtE"
    target_origin += closest_teammate->velocity( ).length_2d( ) * interfaces::global_vars->interval_per_tick;
 
    //Get our head position
    auto head_pos = local->hitbox_position( sdk::hitbox::head );
 
    //Null z pos
    auto teammate_origin = closest_teammate->abs_origin( );
    head_pos.z = teammate_origin.z = 0.f;
 
    //Return if we aren't close enough
    if ( teammate_origin.dist( head_pos ) > 245.f )
        return;
 
    //Move towards our point
    auto dist_x = head_pos.x - target_origin.x;
    auto dist_y = head_pos.y - target_origin.y;
 
    cmd->sidemove = dist_x > 0 ? 450.f : -450.f;
    cmd->forwardmove = dist_y > 0 ? 450.f : -450.f;
 
    //Fix our movement (we applied it from a y = -90 perspective
    //                   Old angles, Current cmd
    util.movement_fix( sdk::vector( 0, -90, 0 ), cmd );
}

Credits: worldgamer123
From UC


По своему опыту скажу, не лучшая идея выбор максимальной скорости для блокбота, нужно подстраиваться под скорость другого игрока
C++:
cmd->sidemove = dist_x > 0 ? 450.f : -450.f;
cmd->forwardmove = dist_y > 0 ? 450.f : -450.f;
 
Забаненный
Статус
Оффлайн
Регистрация
27 Сен 2018
Сообщения
1,312
Реакции[?]
456
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Найсел, where ss bro?)
 
Олдфаг
Статус
Оффлайн
Регистрация
5 Июл 2017
Сообщения
2,108
Реакции[?]
1,189
Поинты[?]
0
В каких уже готовых продуктах имеется данная функция?
Именно с данной реализацией, думаю, ни один. Если ищешь просто с blockbot'ом, то, наверное, каждый 2-ой чит
 
Сверху Снизу