Исходник Jump/fall fix

Эксперт
Статус
Оффлайн
Регистрация
30 Дек 2019
Сообщения
1,970
Реакции[?]
958
Поинты[?]
19K
C++:
int last_activity = {}, last_activity_tick = {};

if (record->m_layers[ 0 ][ land_or_climb_layer ].m_weight > 0.0f && prev->m_layers[ 0 ][ land_or_climb_layer ].m_weight <= 0.0f) {
    int act = player->get_seq_act(curr->m_layers[ 0 ][ land_or_climb_layer ].m_sequence);

    if ( act == act_csgo_land_light || act == act_csgo_land_heavy ) {
        float land_time = record->m_layers[ 0 ][ land_or_climb_layer ].m_cycle / record->m_layers[ 0 ][ land_or_climb_layer ].m_playback_rate;

        if (land_time > 0.f) {
            last_activity_tick = TIME_TO_TICKS(record->m_sim_time - land_time) + 1;
            last_activity = act_csgo_land;
        }
    }
}

if (record->m_layers[ 0 ][ jump_or_fall_layer ].m_weight > 0.0f && prev->m_layers[ 0 ][ jump_or_fall_layer ].m_weight <= 0.0f) {
    int act = player->get_seq_act(curr->m_layers[ 0 ][ jump_or_fall_layer ].m_sequence);

    if ( act == act_csgo_jump ) {
        float jump_time = record->m_layers[ 0 ][ jump_or_fall_layer ].m_cycle / record->m_layers[ 0 ][ jump_or_fall_layer ].m_playback_rate;

        if (jump_time > 0.f) {
            last_activity_tick = TIME_TO_TICKS(record->m_sim_time - jump_time) + 1;
            last_activity = act_csgo_jump;
        }
    }
}
C++:
for ( int i = 1; i < record->m_sim_ticks + 1; i++ ) {
    if ( i != record->m_sim_ticks ) {
        if ( last_activity > 0 ) {
            bool on_ground = record->m_flags.has( fl_onground );
            if ( last_activity == act_csgo_jump ) {
                if ( sdk::to_ticks( record->m_sim_time ) == ( last_activity_tick - 1 ) )
                    on_ground = true;
                else if (sdk::to_ticks( record->m_sim_time ) == last_activity_tick ) {
                    auto jump_layer = &player->get_anim_layers( ).at( jump_or_fall_layer );
                    jump_layer->m_cycle = 0.f;
                    jump_layer->m_rate = record->m_layers[ 0 ][ jump_or_fall_layer ].m_rate;
                    jump_layer->m_sequence = record->m_layers[ 0 ][ jump_or_fall_layer ].m_sequence;
                    on_ground = false;
                }
            }
            else if ( last_activity == act_csgo_land ) {
                if ( sdk::to_ticks( record->m_sim_time ) == ( last_activity_tick - 1 ) )
                    on_ground = false;
                else if ( sdk::to_ticks( record->m_sim_time ) == last_activity_tick ) {
                    auto land_layer = &player->get_anim_layers( ).at( land_of_climb_layer );
                    jump_layer->m_cycle = 0.f;
                    jump_layer->m_rate = record->m_layers[ 0 ][ land_of_climb_layer ].m_rate;
                    jump_layer->m_sequence = record->m_layers[ 0 ][ land_of_climb_layer ].m_sequence;
                    on_ground = true;
                }
            }

             if ( on_ground )
                 player->get_flags( ).add( fl_onground );
             else
                 player->get_flags( ).remove( fl_onground );
        }
    }
}
 
Сверху Снизу