arrow_upward
[Request] Block Bot C++
#1
anybody have a working cpp code for a block bot, one i have from yeti is kinda ass

this is the current code i have from yeti for reference
Code:
void Misc_Movement::blockbot( CUserCmd* m_pcmd ) {
    auto m_local = game::localdata.localplayer( );

    float bestdist = 250.f;
    int index = -1;

    if ( GetAsyncKeyState( miscconfig.iBlockbotKey ) ) {
        for ( int i = 0; i < m_pGlobals->maxClients; i++ ) {
            auto entity = m_pEntityList->GetClientEntity( i );

            if ( !entity ) continue;
            if ( !entity->IsAlive( ) || entity->IsDormant( ) || entity == m_local ) continue;

            float dist = ( m_local->GetOrigin( ) - entity->GetOrigin( ) ).Length( );

            if ( dist < bestdist ) {
                bestdist = dist;
                index = i;
            }
        }
    }

    if ( index == -1 ) return;

    auto target = m_pEntityList->GetClientEntity( index );

    if ( !target ) return;

    Vector angles;  game::math.calculate_angle( m_local->GetEyePosition( ), target->GetEyePosition( ), angles );
    angles.Normalized( );

    if ( angles.y < 0.0f ) m_pcmd->sidemove = 450.f;
    else if ( angles.y > 0.0f ) m_pcmd->sidemove = -450.f;
}