Вопрос Can't get backtrack working

Статус
В этой теме нельзя размещать новые ответы.
Начинающий
Статус
Оффлайн
Регистрация
17 Дек 2018
Сообщения
116
Реакции[?]
5
Поинты[?]
0
So I recently started getting into basic selfcoding. I'm happy with my legitbot and figured I'd try to do backtrack. I did some research but I'm lost as to why my code isn't working. Here is my code:

I'm kind of new to this, but I can't figure out what I am doing wrong.

Код:
void lagcomp::update_player_records( ) {

    // validation checks.
    if ( !csgo::local_player || !csgo::local_player->is_alive( ) || !interfaces::engine->is_in_game( ) )
    {
        return;
    }

    // setup cvar values.
    setup_vars( );

    // loop all entities starting at 1 so we dont scan world which is 0.
    for ( int i = 1; i <= interfaces::globals->max_clients; i++ )
    {
        // cast to player from entity list.
        player_t * ent = (player_t*)interfaces::entity_list->get_client_entity( i );

        // validation checks.
        if ( !ent || !ent->is_alive( ) || ent->dormant( ) || ent == csgo::local_player )
            continue;

        // declare this to access the data within the struct without having to push_back etc.
        tick_records test;

        // determine weather or not we should update the record. If their simulation time is bigger than what we have stored, than we know we have recieved an update about the player. 
        bool should_update_player_record = tick_record [i].empty( ) || ( !tick_record [i].empty( ) && ent->simulation_time( ) > tick_record [i].front( ).sim_time );

        if ( should_update_player_record )
        {
            // setup a bone matrix for the newest element in our list container.
            ent->setup_bones(test.bone_matrix, 128, bone_used_by_anything, ent->simulation_time());

            // create a new record for the player and make sure to push it to the front as the newest record.
            tick_record [i].push_front(tick_records(ent));

            // reset player records and remove old records stored in our list container.
            while ( tick_record [i].size( ) > 32 )
            {
                tick_record [i].pop_back( );
            }
        }

        // calculate server time, credits to my boy trollero lol.
        auto server_time = ( csgo::local_player->get_tick_base() * interfaces::globals->interval_per_tick );

        // clear invalid records.
        for ( auto & tick : tick_record [i] )
        {
            if ( !std::fabs(tick_count - ( server_time - tick.sim_time ) <= ( variables::backtrack_amount / 1000 )))
            {
                tick_record [i].pop_back( );
            }
        }
    }
}

void lagcomp::run( c_usercmd * cmd ) {

    if ( !interfaces::engine->is_in_game( ) || !csgo::local_player || !csgo::local_player->is_alive( ) || !variables::backtrack || !cmd || !(cmd->buttons & in_attack))
    {
        return;
    }

    // declare stuff.
    int player_index = -1;
    player_t * closest_player{};
    vec3_t closest_absd_origin{};
    vec3_t eye_pos = csgo::local_player->get_eye_pos( );

    // fov variable used for sorting. Could be anythhing over 180, doesn't matter. However, since the fov from a player ingame can't be over 180, I'll set it to 180.
    float player_fov = 180.f;
    float backtrack_fov = 180.f;

    // loop through all players ingame
    for ( int i = 1; i <= interfaces::globals->max_clients; i++ )
    {
        // assign player with an entity we grabbed from ingame.
        player_t * player = ( player_t * ) interfaces::entity_list->get_client_entity(i);

        // sanity checks.
        if ( !player || !player->is_alive( ) || !csgo::local_player || player == csgo::local_player )
            continue;

        // read abs origin is better for fov sorting.
        vec3_t abs_origin = player->abs_origin( );

        // crazy math, essentially rotating vectors etc. To understand this, you'll need to have a basic understanding of how csgo's view matrix is caluclated.
        auto player_pos = math::calculate_angle2(eye_pos, abs_origin, cmd->viewangles);

        // std::hypotf, used to calculate shit in a 3D space
        auto distance = std::hypotf(player_pos.x, player_pos.y);

        // time for our sorting logic. 
        // this works really well for finding the closest player, other sorting methods could be implemented later on.
        if ( distance < player_fov )
        {
            player_fov=distance;
            player_index = i;
            closest_player = player;
            closest_absd_origin = abs_origin;
        }
    }

    // if we don't have a valid closest player or player_index return.
    if ( player_index == -1 || !closest_player )
        return;

    // loop through player records.
    for ( auto & tick : tick_record [player_index] )
    {
        // calculate server time, credits to my boy trollero lol.
        auto server_time = ( csgo::local_player->get_tick_base( ) * interfaces::globals->interval_per_tick );

        // used to determine how old the record is. 
        float delta_time = std::fabs(tick_count - ( server_time - tick.sim_time ));

        // we can only backtrack 200ms without fakeping.
        if ( delta_time > ( variables::backtrack_amount / 1000 ) )
            continue;

        // crazy math, essentially rotating vectors etc. To understand this, you'll need to have a basic understanding of how csgo's view matrix is caluclated.
        auto player_pos = math::calculate_angle2(eye_pos, closest_absd_origin, cmd->viewangles);
        auto distance = std::hypotf(player_pos.x, player_pos.y);

        // time for our sorting logic.
        if (distance < backtrack_fov )
        {
            backtrack_fov = distance;
            tick_count = utilities::TIME_TO_TICKS(tick.sim_time + lerp_time);
        }
    }

    // finally set the tickcount and trick the game into thinking we have a higher ping than we actually have.
    cmd->tick_count = tick_count;
}
 
Последнее редактирование:
life is cheap, death is free!
Эксперт
Статус
Оффлайн
Регистрация
9 Дек 2019
Сообщения
1,603
Реакции[?]
517
Поинты[?]
2K
Говорят, что в аду есть специальный котёл для тех кто кидает код скринами

ну скинь ты его нормально боже
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу