Skip to content

Commit a982911

Browse files
Potential fix for #9353 (crouchbug workaround)
1 parent f4e72f9 commit a982911

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ void CClientPed::Init ( CClientManager* pManager, unsigned long ulModelID, bool
150150
m_fTargetRotation = 0.0f;
151151
m_bTargetAkimboUp = false;
152152
m_bIsChoking = false;
153-
m_ulLastTimeAimed = 0;
153+
m_ulLastTimeBeganAiming = 0;
154+
m_ulLastTimeEndedAiming = 0;
154155
m_ulLastTimeBeganCrouch = 0;
155156
m_ulLastTimeBeganStand = 0; //Standing after crouching
156157
m_ulLastTimeMovedWhileCrouched = 0; //Moved while crouching
@@ -2957,10 +2958,9 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
29572958
CTask* pTask = m_pTaskManager->GetTaskSecondary ( TASK_SECONDARY_ATTACK );
29582959
if ( pTask && pTask->GetTaskType () == TASK_SIMPLE_USE_GUN )
29592960
{
2960-
if ( m_ulLastTimeAimed == 0 )
2961-
{
2962-
m_ulLastTimeAimed = ulNow;
2963-
}
2961+
if ( m_ulLastTimeBeganAiming == 0 )
2962+
m_ulLastTimeBeganAiming = ulNow;
2963+
29642964
if ( m_ulLastTimeBeganStand >= ulNow - 200.0f*fSpeedRatio )
29652965
{
29662966
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_FASTMOVE ) )
@@ -2979,12 +2979,21 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
29792979
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_CROUCHBUG ) )
29802980
{
29812981
if ( Current.RightShoulder1 == 0 && Current.LeftShoulder1 == 0 && Current.ButtonCircle == 0 )
2982+
{
29822983
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+
}
29832992
}
29842993
}
29852994
else
29862995
{
2987-
m_ulLastTimeAimed = 0;
2996+
m_ulLastTimeBeganAiming = 0;
29882997
// If we have the aim button pressed but aren't aiming, we're probably sprinting
29892998
// If we're sprinting with an MP5,Deagle,Fire Extinguisher,Spray can, we shouldnt be able to shoot
29902999
// These weapons are weapons you can run with, but can't run with while aiming
@@ -3006,7 +3015,7 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
30063015
if ( m_ulLastTimeBeganCrouch == 0 )
30073016
m_ulLastTimeBeganCrouch = ulNow;
30083017
// No longer aiming if we're in the process of crouching
3009-
m_ulLastTimeAimed = 0;
3018+
m_ulLastTimeBeganAiming = 0;
30103019
}
30113020
else
30123021
{
@@ -3042,8 +3051,8 @@ void CClientPed::ApplyControllerStateFixes ( CControllerState& Current )
30423051
}
30433052
}
30443053
// 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) ||
30473056
(ulNow - m_ulLastTimeFired) <= 300.0f*fSpeedRatio )
30483057
{
30493058
if ( !g_pClientGame->IsGlitchEnabled ( CClientGame::GLITCH_FASTFIRE ) )

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
521521
CControllerState* m_lastControllerState;
522522
CRemoteDataStorage* m_remoteDataStorage;
523523
unsigned long m_ulLastTimeFired;
524-
unsigned long m_ulLastTimeAimed;
524+
unsigned long m_ulLastTimeBeganAiming;
525+
unsigned long m_ulLastTimeEndedAiming;
525526
unsigned long m_ulLastTimeBeganCrouch;
526527
unsigned long m_ulLastTimeBeganStand;
527528
unsigned long m_ulLastTimeMovedWhileCrouched;

0 commit comments

Comments
 (0)