@@ -150,7 +150,8 @@ void CClientPed::Init ( CClientManager* pManager, unsigned long ulModelID, bool
150
150
m_fTargetRotation = 0 .0f ;
151
151
m_bTargetAkimboUp = false ;
152
152
m_bIsChoking = false ;
153
- m_ulLastTimeAimed = 0 ;
153
+ m_ulLastTimeBeganAiming = 0 ;
154
+ m_ulLastTimeEndedAiming = 0 ;
154
155
m_ulLastTimeBeganCrouch = 0 ;
155
156
m_ulLastTimeBeganStand = 0 ; // Standing after crouching
156
157
m_ulLastTimeMovedWhileCrouched = 0 ; // Moved while crouching
@@ -2957,10 +2958,9 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
2957
2958
CTask* pTask = m_pTaskManager->GetTaskSecondary ( TASK_SECONDARY_ATTACK );
2958
2959
if ( pTask && pTask->GetTaskType () == TASK_SIMPLE_USE_GUN )
2959
2960
{
2960
- if ( m_ulLastTimeAimed == 0 )
2961
- {
2962
- m_ulLastTimeAimed = ulNow;
2963
- }
2961
+ if ( m_ulLastTimeBeganAiming == 0 )
2962
+ m_ulLastTimeBeganAiming = ulNow;
2963
+
2964
2964
if ( m_ulLastTimeBeganStand >= ulNow - 200 .0f *fSpeedRatio )
2965
2965
{
2966
2966
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_FASTMOVE ) )
@@ -2979,12 +2979,21 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
2979
2979
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_CROUCHBUG ) )
2980
2980
{
2981
2981
if ( Current.RightShoulder1 == 0 && Current.LeftShoulder1 == 0 && Current.ButtonCircle == 0 )
2982
+ {
2982
2983
Current.ShockButtonL = 0 ;
2984
+ // The above checks can be dodged by pressing one of the keys quickly enough, so use a hard
2985
+ // timer as well.
2986
+ m_ulLastTimeEndedAiming = ulNow;
2987
+ }
2988
+ // We carry on blocking the crouch key for 600ms after someone has ended aiming
2989
+ else if ( m_ulLastTimeEndedAiming != 0 && m_ulLastTimeEndedAiming >= ulNow - 600 .0f *fSpeedRatio ) {
2990
+ Current.ShockButtonL = 0 ;
2991
+ }
2983
2992
}
2984
2993
}
2985
2994
else
2986
2995
{
2987
- m_ulLastTimeAimed = 0 ;
2996
+ m_ulLastTimeBeganAiming = 0 ;
2988
2997
// If we have the aim button pressed but aren't aiming, we're probably sprinting
2989
2998
// If we're sprinting with an MP5,Deagle,Fire Extinguisher,Spray can, we shouldnt be able to shoot
2990
2999
// These weapons are weapons you can run with, but can't run with while aiming
@@ -3006,7 +3015,7 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
3006
3015
if ( m_ulLastTimeBeganCrouch == 0 )
3007
3016
m_ulLastTimeBeganCrouch = ulNow;
3008
3017
// No longer aiming if we're in the process of crouching
3009
- m_ulLastTimeAimed = 0 ;
3018
+ m_ulLastTimeBeganAiming = 0 ;
3010
3019
}
3011
3020
else
3012
3021
{
@@ -3042,8 +3051,8 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
3042
3051
}
3043
3052
}
3044
3053
// If we just started aiming, make sure they dont try and crouch
3045
- else if ( (m_ulLastTimeAimed != 0 &&
3046
- m_ulLastTimeAimed >= ulNow - 300 .0f *fSpeedRatio ) ||
3054
+ else if ( (m_ulLastTimeBeganAiming != 0 &&
3055
+ m_ulLastTimeBeganAiming >= ulNow - 300 .0f *fSpeedRatio ) ||
3047
3056
(ulNow - m_ulLastTimeFired) <= 300 .0f *fSpeedRatio )
3048
3057
{
3049
3058
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_FASTFIRE ) )
0 commit comments