From 0bc63d4dbbfe4fb74b4114f0ae11bfe8c87d5cc9 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 21 Nov 2018 18:45:39 +0100 Subject: d --- internal_rewrite/c_base_player.cpp | 29 +++++++++++++++++++++++------ internal_rewrite/c_base_player.hpp | 1 + internal_rewrite/factory.hpp | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/internal_rewrite/c_base_player.cpp b/internal_rewrite/c_base_player.cpp index 957aa2a..a4cdb7e 100644 --- a/internal_rewrite/c_base_player.cpp +++ b/internal_rewrite/c_base_player.cpp @@ -890,16 +890,33 @@ void c_base_player::fix_animations( bool reset, bool resolver_change ) { float prev_cycle = m_AnimOverlay( ).GetElements( )[ 6 ].m_flPrevCycle; float prev_rate = m_AnimOverlay( ).GetElements( )[ 6 ].m_flPlaybackRate; - /*needs testing but seems to work*/ if( !reset ) { - auto& layer = m_AnimOverlay( ).GetElements( )[ 3 ]; + auto fraction = get_animstate( )->m_flStopToFullRunningFraction; + bool stopping = sm_animdata[ idx ].m_is_stopping; - int sequence = get_seq_activity( layer.m_nSequence ); + if( fraction > 0.1f && fraction < 1.f ) { + float delta_2x = get_animstate( )->m_flLastUpdateDelta * 2.f; - if( sequence == 979 ) { - //if( sm_animdata[ idx ].m_adjust_cycle + sm_animdata[ idx ].m_adjust_rate >= 1.f ) - // eye_angles.y = m_flLowerBodyYawTarget( ); + if( stopping ) + fraction -= delta_2x; + else + fraction += delta_2x; + + fraction = std::clamp( fraction, 0.f, 1.f ); + } + + auto speed = get_anim_velocity( ).length2d( ); + + if( speed > 135.2f && stopping ) { + sm_animdata[ idx ].m_is_stopping = false; + fraction = std::max( fraction, 0.0099999998f ); + } + if( speed < 135.2f && !stopping ) { + sm_animdata[ idx ].m_is_stopping = true; + fraction = std::min( fraction, 0.99000001f ); } + + get_animstate( )->m_flStopToFullRunningFraction = fraction; } get_animstate( )->update( eye_angles.y, eye_angles.x ); diff --git a/internal_rewrite/c_base_player.hpp b/internal_rewrite/c_base_player.hpp index e5455f9..876b65b 100644 --- a/internal_rewrite/c_base_player.hpp +++ b/internal_rewrite/c_base_player.hpp @@ -242,6 +242,7 @@ struct ent_animdata_t { int m_anim_flags; float m_adjust_rate; float m_adjust_cycle; + bool m_is_stopping; }; class c_base_player { diff --git a/internal_rewrite/factory.hpp b/internal_rewrite/factory.hpp index d197951..c81c79b 100644 --- a/internal_rewrite/factory.hpp +++ b/internal_rewrite/factory.hpp @@ -11,7 +11,7 @@ //IFACE_DLLMAIN - interfaces are passed through dllmain and below code doesnt need to be ran #ifndef _DEBUG //#define IFACE_DLLMAIN -//#define HEADER_MODULE +#define HEADER_MODULE #endif #ifdef IFACE_DLLMAIN -- cgit v1.2.3