Исходник Calculate velocity length via aliveloop layer (11)

Начинающий
Статус
Оффлайн
Регистрация
20 Янв 2018
Сообщения
574
Реакции[?]
397
Поинты[?]
62K
Вобщем, фактически, фикс произведен следующим образом:
В методе SetUpAliveLoop для просчета Weight, используется следующая формула:
1688138051684.png
Чтобы получить m_flSpeedAsPortionOfRunTopSpeed, нужно произвести обратные просчеты, т.е через уравнение

Как пруф предоставляю код с server.dll:
1688138132823.png

После чего с помощью, опять же, обратных формул, можно получить длину Velocity:
1688138160515.png

Сам код:
Код:
auto max_speed = weapon && weapon_info ?
        std::max<float>((player->is_scoped() ? weapon_info->max_speed_alt : weapon_info->max_speed), 0.001f)
        : CS_PLAYER_SPEED_RUN;

    if (player->is_walking())
        max_speed *= CS_PLAYER_SPEED_WALK_MODIFIER;

    if (player->duck_amount() >= 1.f)
        max_speed *= CS_PLAYER_SPEED_DUCK_MODIFIER;

    if (prev_record) {

        if (record->flags.has(FL_ONGROUND) && prev_record->flags.has(FL_ONGROUND)) {
            auto& layer_aliveloop = prev_record->layers[ANIMATION_LAYER_ALIVELOOP];

            // calculate server value of m_flSpeedAsPortionOfRunTopSpeed via layer from SetupAliveLoop:
            /*
                code from server.dll:
                v27 = 0.0;
                v28 = (*(this + 228) - 0.55000001) * 2.8571432;
                if ( v28 >= 0.0 )
                    v27 = fminf(v28, 1.0);
                sub_104B02A0(this, 1.0 - v27, 11);
            */

            auto base_value = 1.f - layer_aliveloop.weight;
            auto fake_speed_portion = base_value / 2.85f;
            if (fake_speed_portion > 0.f)
                fake_speed_portion += 0.55f;

            // adjust the velocity by server m_flSpeedAsPortionOfRunTopSpeed by inverting in-game formulas
            // code from game:
            /*
                m_flSpeedAsPortionOfRunTopSpeed = clamp( m_flVelocityLengthXY / flMaxSpeedRun, 0, 1 );
                m_flSpeedAsPortionOfWalkTopSpeed = m_flVelocityLengthXY / (flMaxSpeedRun * CS_PLAYER_SPEED_WALK_MODIFIER);
                m_flSpeedAsPortionOfCrouchTopSpeed = m_flVelocityLengthXY / (flMaxSpeedRun * CS_PLAYER_SPEED_DUCK_MODIFIER);
            */

            auto anim_velocity_length = std::min<float>(record->velocity.length(), CS_PLAYER_SPEED_RUN);
            if (fake_speed_portion > 0.f)
                record->velocity *= ((fake_speed_portion * max_speed) / anim_velocity_length);
        }
    }
P.S Эта паста уже в паблике лежит, мне кажется, несколько лет, поэтому нет смысла это держать в секрете
Думаю хотя бы объяснил ее суть
А еще, я видел очень много паблик сурсов, которые пастят логику просчета Velocity, которая нужна для экстраполяции, мб хватит это делать....
 
sapphire dev
Пользователь
Статус
Оффлайн
Регистрация
15 Мар 2018
Сообщения
188
Реакции[?]
124
Поинты[?]
36K
Молодец попай! Разобрался сам и остальным показал
 
get good get legendware
Участник
Статус
Оффлайн
Регистрация
22 Сен 2020
Сообщения
437
Реакции[?]
201
Поинты[?]
48K
C++:
Vector lagcompensation::DeterminePlayerVelocity(player_t* pPlayer, adjust_data* m_LagRecord, adjust_data* m_PrevRecord, c_baseplayeranimationstate* m_AnimationState)
{
    float m_flMaxSpeed = 260.0f;
    auto pCombatWeapon = pPlayer->m_hActiveWeapon();
    auto pCombatWeaponData = pCombatWeapon->get_csweapon_info();

    if (!pCombatWeaponData || !pCombatWeapon)
        m_flMaxSpeed = 260.0f;
    else
    {
        if (pCombatWeapon->m_weaponMode() == 0)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeed;
        else if (pCombatWeapon->m_weaponMode() == 1)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeedAlt;
    }

    /* Prepare data once */
    if (!m_PrevRecord)
    {
        const float flVelLength = m_LagRecord->velocity.Length();
        if (flVelLength > m_flMaxSpeed)
            m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

        return m_LagRecord->velocity;
    }

    /* Define const */
    //const float flMaxSpeed = SDK::EngineData::m_ConvarList[CheatConvarList::MaxSpeed]->GetFloat();


    /* Get animation layers */
    const AnimationLayer* m_AliveLoop = &m_LagRecord->layers[ANIMATION_LAYER_ALIVELOOP];
    const AnimationLayer* m_PrevAliveLoop = &m_PrevRecord->layers[ANIMATION_LAYER_ALIVELOOP];

    const AnimationLayer* m_Movement = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_PrevMovement = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_Landing = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];
    const AnimationLayer* m_PrevLanding = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];

    /* Recalculate velocity using origin delta */
    m_LagRecord->velocity = (m_LagRecord->origin - m_PrevRecord->origin) * (1.0f / TICKS_TO_TIME(m_LagRecord->simulation_time));


    /* Check PlaybackRate */
    if (m_Movement->m_flPlaybackRate < 0.00001f)
        m_LagRecord->velocity.x = m_LagRecord->velocity.y = 0.0f;
    else
    {
        /* Compute velocity using m_flSpeedAsPortionOfRunTopSpeed */
        float flWeight = m_AliveLoop->m_flWeight;
        if (flWeight < 1.0f)
        {

            /* Check PlaybackRate */
            if (m_AliveLoop->m_flPlaybackRate == m_PrevAliveLoop->m_flPlaybackRate)
            {
                /* Check Sequence */
                if (m_AliveLoop->m_nSequence == m_PrevAliveLoop->m_nSequence)
                {

                    /* Very important cycle check */
                    if (m_AliveLoop->m_flCycle > m_PrevAliveLoop->m_flCycle)
                    {
                        /* Check weapon */
                        if (m_AnimationState->m_pActiveWeapon == pPlayer->m_hActiveWeapon())
                        {
                            /* Get m_flSpeedAsPortionOfRunTopSpeed */
                            float m_flSpeedAsPortionOfRunTopSpeed = ((1.0f - flWeight) / 2.8571432f) + 0.55f;


                            /* Check m_flSpeedAsPortionOfRunTopSpeed bounds ( from 55% to 90% from the speed ) */
                            if (m_flSpeedAsPortionOfRunTopSpeed > 0.55f && m_flSpeedAsPortionOfRunTopSpeed < 0.9f)
                            {

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_flSpeedAsPortionOfRunTopSpeed * m_flMaxSpeed;
                                m_LagRecord->m_nVelocityMode = EFixedVelocity::AliveLoopLayer;
                            }
                            else if (m_flSpeedAsPortionOfRunTopSpeed > 0.9f)
                            {

                                

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_LagRecord->velocity.Length2D();
                            }
                        }
                    }
                }
            }
        }

        /* Compute velocity using Movement ( 6 ) weight  */
        if (m_LagRecord->m_flAnimationVelocity <= 0.0f)
        {

            

            /* Check Weight bounds from 10% to 90% from the speed */
            float flWeight = m_Movement->m_flWeight;
            if (flWeight > 0.1f && flWeight < 0.9f)
            {
                /* Skip on land */
                if (m_Landing->m_flWeight <= 0.0f)
                {

                    

                    /* Check Accelerate */
                    if (flWeight > m_PrevMovement->m_flWeight)
                    {
                        /* Skip on direction switch */
                        if (m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence)
                        {

                            

                            /* Check move sequence */
                            if (m_Movement->m_nSequence == m_PrevMovement->m_nSequence)
                            {
                                /* Check land sequence */
                                if (m_Landing->m_nSequence == m_PrevLanding->m_nSequence)
                                {

                                    

                                    /* Check stand sequence */
                                    if (m_LagRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence)
                                    {
                                        /* Check Flags */
                                        if (m_LagRecord->flags & FL_ONGROUND)
                                        {

                                            

                                            /* Compute MaxSpeed modifier */
                                            float flSpeedModifier = 1.0f;
                                            if (m_LagRecord->flags & FL_DUCKING)
                                                flSpeedModifier = 0.34f;
                                            else if (pPlayer->m_bIsWalking())
                                                flSpeedModifier = 0.52f;


                                            

                                            /* Compute Velocity ( THIS CODE ONLY WORKS IN DUCK AND WALK ) */
                                            if (flSpeedModifier < 1.0f)
                                            {
                                                m_LagRecord->m_flAnimationVelocity = (flWeight * (m_flMaxSpeed * flSpeedModifier));
                                                m_LagRecord->m_nVelocityMode = EFixedVelocity::MovementLayer;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    

                }
            }
        }
    }

    /* Compute velocity from m_Record->m_flAnimationVelocity floating point */
    if (m_LagRecord->m_flAnimationVelocity > 0.0f)
    {
        const float flModifier = m_LagRecord->m_flAnimationVelocity / m_LagRecord->velocity.Length2D();
        m_LagRecord->velocity.x *= flModifier;

        

        m_LagRecord->velocity.y *= flModifier;
    }

    /* Prepare data once */
    const float flVelLength = m_LagRecord->velocity.Length();


    

    /* Clamp velocity if its out bounds */
    if (flVelLength > m_flMaxSpeed)
        m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

    return m_LagRecord->velocity;
}

Whoops!
 
Забаненный
Статус
Оффлайн
Регистрация
14 Июл 2023
Сообщения
21
Реакции[?]
5
Поинты[?]
5K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
Vector lagcompensation::DeterminePlayerVelocity(player_t* pPlayer, adjust_data* m_LagRecord, adjust_data* m_PrevRecord, c_baseplayeranimationstate* m_AnimationState)
{
    float m_flMaxSpeed = 260.0f;
    auto pCombatWeapon = pPlayer->m_hActiveWeapon();
    auto pCombatWeaponData = pCombatWeapon->get_csweapon_info();

    if (!pCombatWeaponData || !pCombatWeapon)
        m_flMaxSpeed = 260.0f;
    else
    {
        if (pCombatWeapon->m_weaponMode() == 0)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeed;
        else if (pCombatWeapon->m_weaponMode() == 1)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeedAlt;
    }

    /* Prepare data once */
    if (!m_PrevRecord)
    {
        const float flVelLength = m_LagRecord->velocity.Length();
        if (flVelLength > m_flMaxSpeed)
            m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

        return m_LagRecord->velocity;
    }

    /* Define const */
    //const float flMaxSpeed = SDK::EngineData::m_ConvarList[CheatConvarList::MaxSpeed]->GetFloat();


    /* Get animation layers */
    const AnimationLayer* m_AliveLoop = &m_LagRecord->layers[ANIMATION_LAYER_ALIVELOOP];
    const AnimationLayer* m_PrevAliveLoop = &m_PrevRecord->layers[ANIMATION_LAYER_ALIVELOOP];

    const AnimationLayer* m_Movement = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_PrevMovement = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_Landing = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];
    const AnimationLayer* m_PrevLanding = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];

    /* Recalculate velocity using origin delta */
    m_LagRecord->velocity = (m_LagRecord->origin - m_PrevRecord->origin) * (1.0f / TICKS_TO_TIME(m_LagRecord->simulation_time));


    /* Check PlaybackRate */
    if (m_Movement->m_flPlaybackRate < 0.00001f)
        m_LagRecord->velocity.x = m_LagRecord->velocity.y = 0.0f;
    else
    {
        /* Compute velocity using m_flSpeedAsPortionOfRunTopSpeed */
        float flWeight = m_AliveLoop->m_flWeight;
        if (flWeight < 1.0f)
        {

            /* Check PlaybackRate */
            if (m_AliveLoop->m_flPlaybackRate == m_PrevAliveLoop->m_flPlaybackRate)
            {
                /* Check Sequence */
                if (m_AliveLoop->m_nSequence == m_PrevAliveLoop->m_nSequence)
                {

                    /* Very important cycle check */
                    if (m_AliveLoop->m_flCycle > m_PrevAliveLoop->m_flCycle)
                    {
                        /* Check weapon */
                        if (m_AnimationState->m_pActiveWeapon == pPlayer->m_hActiveWeapon())
                        {
                            /* Get m_flSpeedAsPortionOfRunTopSpeed */
                            float m_flSpeedAsPortionOfRunTopSpeed = ((1.0f - flWeight) / 2.8571432f) + 0.55f;


                            /* Check m_flSpeedAsPortionOfRunTopSpeed bounds ( from 55% to 90% from the speed ) */
                            if (m_flSpeedAsPortionOfRunTopSpeed > 0.55f && m_flSpeedAsPortionOfRunTopSpeed < 0.9f)
                            {

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_flSpeedAsPortionOfRunTopSpeed * m_flMaxSpeed;
                                m_LagRecord->m_nVelocityMode = EFixedVelocity::AliveLoopLayer;
                            }
                            else if (m_flSpeedAsPortionOfRunTopSpeed > 0.9f)
                            {

                               

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_LagRecord->velocity.Length2D();
                            }
                        }
                    }
                }
            }
        }

        /* Compute velocity using Movement ( 6 ) weight  */
        if (m_LagRecord->m_flAnimationVelocity <= 0.0f)
        {

           

            /* Check Weight bounds from 10% to 90% from the speed */
            float flWeight = m_Movement->m_flWeight;
            if (flWeight > 0.1f && flWeight < 0.9f)
            {
                /* Skip on land */
                if (m_Landing->m_flWeight <= 0.0f)
                {

                   

                    /* Check Accelerate */
                    if (flWeight > m_PrevMovement->m_flWeight)
                    {
                        /* Skip on direction switch */
                        if (m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence)
                        {

                           

                            /* Check move sequence */
                            if (m_Movement->m_nSequence == m_PrevMovement->m_nSequence)
                            {
                                /* Check land sequence */
                                if (m_Landing->m_nSequence == m_PrevLanding->m_nSequence)
                                {

                                   

                                    /* Check stand sequence */
                                    if (m_LagRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence)
                                    {
                                        /* Check Flags */
                                        if (m_LagRecord->flags & FL_ONGROUND)
                                        {

                                           

                                            /* Compute MaxSpeed modifier */
                                            float flSpeedModifier = 1.0f;
                                            if (m_LagRecord->flags & FL_DUCKING)
                                                flSpeedModifier = 0.34f;
                                            else if (pPlayer->m_bIsWalking())
                                                flSpeedModifier = 0.52f;


                                           

                                            /* Compute Velocity ( THIS CODE ONLY WORKS IN DUCK AND WALK ) */
                                            if (flSpeedModifier < 1.0f)
                                            {
                                                m_LagRecord->m_flAnimationVelocity = (flWeight * (m_flMaxSpeed * flSpeedModifier));
                                                m_LagRecord->m_nVelocityMode = EFixedVelocity::MovementLayer;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                   

                }
            }
        }
    }

    /* Compute velocity from m_Record->m_flAnimationVelocity floating point */
    if (m_LagRecord->m_flAnimationVelocity > 0.0f)
    {
        const float flModifier = m_LagRecord->m_flAnimationVelocity / m_LagRecord->velocity.Length2D();
        m_LagRecord->velocity.x *= flModifier;

       

        m_LagRecord->velocity.y *= flModifier;
    }

    /* Prepare data once */
    const float flVelLength = m_LagRecord->velocity.Length();


   

    /* Clamp velocity if its out bounds */
    if (flVelLength > m_flMaxSpeed)
        m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

    return m_LagRecord->velocity;
}

Whoops!
и зачем ты скинул велосити фикс с оверсии...
 
Модератор форума
Участник
Статус
Оффлайн
Регистрация
26 Янв 2020
Сообщения
378
Реакции[?]
157
Поинты[?]
9K
C++:
Vector lagcompensation::DeterminePlayerVelocity(player_t* pPlayer, adjust_data* m_LagRecord, adjust_data* m_PrevRecord, c_baseplayeranimationstate* m_AnimationState)
{
    float m_flMaxSpeed = 260.0f;
    auto pCombatWeapon = pPlayer->m_hActiveWeapon();
    auto pCombatWeaponData = pCombatWeapon->get_csweapon_info();

    if (!pCombatWeaponData || !pCombatWeapon)
        m_flMaxSpeed = 260.0f;
    else
    {
        if (pCombatWeapon->m_weaponMode() == 0)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeed;
        else if (pCombatWeapon->m_weaponMode() == 1)
            m_flMaxSpeed = pCombatWeaponData->flMaxPlayerSpeedAlt;
    }

    /* Prepare data once */
    if (!m_PrevRecord)
    {
        const float flVelLength = m_LagRecord->velocity.Length();
        if (flVelLength > m_flMaxSpeed)
            m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

        return m_LagRecord->velocity;
    }

    /* Define const */
    //const float flMaxSpeed = SDK::EngineData::m_ConvarList[CheatConvarList::MaxSpeed]->GetFloat();


    /* Get animation layers */
    const AnimationLayer* m_AliveLoop = &m_LagRecord->layers[ANIMATION_LAYER_ALIVELOOP];
    const AnimationLayer* m_PrevAliveLoop = &m_PrevRecord->layers[ANIMATION_LAYER_ALIVELOOP];

    const AnimationLayer* m_Movement = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_PrevMovement = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_MOVE];
    const AnimationLayer* m_Landing = &m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];
    const AnimationLayer* m_PrevLanding = &m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB];

    /* Recalculate velocity using origin delta */
    m_LagRecord->velocity = (m_LagRecord->origin - m_PrevRecord->origin) * (1.0f / TICKS_TO_TIME(m_LagRecord->simulation_time));


    /* Check PlaybackRate */
    if (m_Movement->m_flPlaybackRate < 0.00001f)
        m_LagRecord->velocity.x = m_LagRecord->velocity.y = 0.0f;
    else
    {
        /* Compute velocity using m_flSpeedAsPortionOfRunTopSpeed */
        float flWeight = m_AliveLoop->m_flWeight;
        if (flWeight < 1.0f)
        {

            /* Check PlaybackRate */
            if (m_AliveLoop->m_flPlaybackRate == m_PrevAliveLoop->m_flPlaybackRate)
            {
                /* Check Sequence */
                if (m_AliveLoop->m_nSequence == m_PrevAliveLoop->m_nSequence)
                {

                    /* Very important cycle check */
                    if (m_AliveLoop->m_flCycle > m_PrevAliveLoop->m_flCycle)
                    {
                        /* Check weapon */
                        if (m_AnimationState->m_pActiveWeapon == pPlayer->m_hActiveWeapon())
                        {
                            /* Get m_flSpeedAsPortionOfRunTopSpeed */
                            float m_flSpeedAsPortionOfRunTopSpeed = ((1.0f - flWeight) / 2.8571432f) + 0.55f;


                            /* Check m_flSpeedAsPortionOfRunTopSpeed bounds ( from 55% to 90% from the speed ) */
                            if (m_flSpeedAsPortionOfRunTopSpeed > 0.55f && m_flSpeedAsPortionOfRunTopSpeed < 0.9f)
                            {

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_flSpeedAsPortionOfRunTopSpeed * m_flMaxSpeed;
                                m_LagRecord->m_nVelocityMode = EFixedVelocity::AliveLoopLayer;
                            }
                            else if (m_flSpeedAsPortionOfRunTopSpeed > 0.9f)
                            {

                               

                                /* Compute velocity */
                                m_LagRecord->m_flAnimationVelocity = m_LagRecord->velocity.Length2D();
                            }
                        }
                    }
                }
            }
        }

        /* Compute velocity using Movement ( 6 ) weight  */
        if (m_LagRecord->m_flAnimationVelocity <= 0.0f)
        {

           

            /* Check Weight bounds from 10% to 90% from the speed */
            float flWeight = m_Movement->m_flWeight;
            if (flWeight > 0.1f && flWeight < 0.9f)
            {
                /* Skip on land */
                if (m_Landing->m_flWeight <= 0.0f)
                {

                   

                    /* Check Accelerate */
                    if (flWeight > m_PrevMovement->m_flWeight)
                    {
                        /* Skip on direction switch */
                        if (m_LagRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_MOVEMENT_STRAFECHANGE].m_nSequence)
                        {

                           

                            /* Check move sequence */
                            if (m_Movement->m_nSequence == m_PrevMovement->m_nSequence)
                            {
                                /* Check land sequence */
                                if (m_Landing->m_nSequence == m_PrevLanding->m_nSequence)
                                {

                                   

                                    /* Check stand sequence */
                                    if (m_LagRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence == m_PrevRecord->layers[ANIMATION_LAYER_ADJUST].m_nSequence)
                                    {
                                        /* Check Flags */
                                        if (m_LagRecord->flags & FL_ONGROUND)
                                        {

                                           

                                            /* Compute MaxSpeed modifier */
                                            float flSpeedModifier = 1.0f;
                                            if (m_LagRecord->flags & FL_DUCKING)
                                                flSpeedModifier = 0.34f;
                                            else if (pPlayer->m_bIsWalking())
                                                flSpeedModifier = 0.52f;


                                           

                                            /* Compute Velocity ( THIS CODE ONLY WORKS IN DUCK AND WALK ) */
                                            if (flSpeedModifier < 1.0f)
                                            {
                                                m_LagRecord->m_flAnimationVelocity = (flWeight * (m_flMaxSpeed * flSpeedModifier));
                                                m_LagRecord->m_nVelocityMode = EFixedVelocity::MovementLayer;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                   

                }
            }
        }
    }

    /* Compute velocity from m_Record->m_flAnimationVelocity floating point */
    if (m_LagRecord->m_flAnimationVelocity > 0.0f)
    {
        const float flModifier = m_LagRecord->m_flAnimationVelocity / m_LagRecord->velocity.Length2D();
        m_LagRecord->velocity.x *= flModifier;

       

        m_LagRecord->velocity.y *= flModifier;
    }

    /* Prepare data once */
    const float flVelLength = m_LagRecord->velocity.Length();


   

    /* Clamp velocity if its out bounds */
    if (flVelLength > m_flMaxSpeed)
        m_LagRecord->velocity *= m_flMaxSpeed / flVelLength;

    return m_LagRecord->velocity;
}

Whoops!
Thanks for def porches code:coolface:
 
Сверху Снизу