From 3532acd0bad63f83ebe8ffe47b9d0c83c772825e Mon Sep 17 00:00:00 2001 From: FileEX Date: Mon, 8 Sep 2025 00:16:13 +0200 Subject: [PATCH 1/3] Fix bug --- Client/game_sa/CPedIntelligenceSA.cpp | 13 +++++++++++++ Client/game_sa/CPedIntelligenceSA.h | 1 + Client/multiplayer_sa/multiplayer_keysync.cpp | 12 ++++++++++-- Client/sdk/game/CPedIntelligence.h | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CPedIntelligenceSA.cpp b/Client/game_sa/CPedIntelligenceSA.cpp index cc3d6002593..96168fbdf66 100644 --- a/Client/game_sa/CPedIntelligenceSA.cpp +++ b/Client/game_sa/CPedIntelligenceSA.cpp @@ -69,3 +69,16 @@ CTaskSimpleUseGun* CPedIntelligenceSA::GetTaskUseGun() return nullptr; } + +CTaskSimpleFight* CPedIntelligenceSA::GetFightTask() +{ + CTaskManager* taskMgr = GetTaskManager(); + if (!taskMgr) + return nullptr; + + CTask* secondaryTask = taskMgr->GetTaskSecondary(TASK_SECONDARY_ATTACK); + if (secondaryTask && secondaryTask->GetTaskType() == TASK_SIMPLE_FIGHT) + return dynamic_cast(secondaryTask); + + return nullptr; +} diff --git a/Client/game_sa/CPedIntelligenceSA.h b/Client/game_sa/CPedIntelligenceSA.h index 59870278f26..c6333f13ecd 100644 --- a/Client/game_sa/CPedIntelligenceSA.h +++ b/Client/game_sa/CPedIntelligenceSA.h @@ -55,4 +55,5 @@ class CPedIntelligenceSA : public CPedIntelligence bool TestForStealthKill(CPed* pPed, bool bUnk); CTaskSAInterface* SetTaskDuckSecondary(unsigned short nLengthOfDuck); CTaskSimpleUseGun* GetTaskUseGun(); + CTaskSimpleFight* GetFightTask(); }; diff --git a/Client/multiplayer_sa/multiplayer_keysync.cpp b/Client/multiplayer_sa/multiplayer_keysync.cpp index f277a51c34d..b3801f05a16 100644 --- a/Client/multiplayer_sa/multiplayer_keysync.cpp +++ b/Client/multiplayer_sa/multiplayer_keysync.cpp @@ -301,8 +301,7 @@ void SwitchContext(CPed* thePed) pGameInterface->SetGravity(data->m_fGravity); // Disable mouselook for remote players (so the mouse doesn't affect them) - // Only disable mouselook if they're not holding a 1st-person weapon - // And if they're not under-water + // Disable mouselook if they're not holding a 1st-person weapon bool bDisableMouseLook = true; if (pWeapon) { @@ -312,6 +311,15 @@ void SwitchContext(CPed* thePed) bDisableMouseLook = false; } } + + // Disable mouse look if they are not in a fight task and not aiming (strafing) + // Fix GitHub Issue #395 + if (thePed->GetCurrentWeaponSlot() == eWeaponSlot::WEAPONSLOT_TYPE_UNARMED && thePed->GetPedIntelligence()->GetFightTask() && data->m_pad.NewState.RightShoulder1 != 0) + bDisableMouseLook = false; + + // Disable mouse look if they're underwater (Ped vertical rotation when diving) + // TODO - After merge PR #4401 + bMouseLookEnabled = *(bool*)0xB6EC2E; if (bDisableMouseLook) *(bool*)0xB6EC2E = false; diff --git a/Client/sdk/game/CPedIntelligence.h b/Client/sdk/game/CPedIntelligence.h index 7118b0c639b..ef54c42a53f 100644 --- a/Client/sdk/game/CPedIntelligence.h +++ b/Client/sdk/game/CPedIntelligence.h @@ -15,6 +15,7 @@ class CPed; class CTaskSAInterface; class CTaskManager; class CTaskSimpleUseGun; +class CTaskSimpleFight; class CPedIntelligence { @@ -23,4 +24,5 @@ class CPedIntelligence virtual bool TestForStealthKill(CPed* pPed, bool bUnk) = 0; virtual CTaskSAInterface* SetTaskDuckSecondary(unsigned short nLengthOfDuck) = 0; virtual CTaskSimpleUseGun* GetTaskUseGun() = 0; + virtual CTaskSimpleFight* GetFightTask() = 0; }; From debf856749371c6ddea46fd24fd70a3c28d46307 Mon Sep 17 00:00:00 2001 From: FileEX Date: Mon, 8 Sep 2025 00:22:34 +0200 Subject: [PATCH 2/3] Update multiplayer_keysync.cpp --- Client/multiplayer_sa/multiplayer_keysync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/multiplayer_sa/multiplayer_keysync.cpp b/Client/multiplayer_sa/multiplayer_keysync.cpp index b3801f05a16..caf7672b710 100644 --- a/Client/multiplayer_sa/multiplayer_keysync.cpp +++ b/Client/multiplayer_sa/multiplayer_keysync.cpp @@ -314,7 +314,7 @@ void SwitchContext(CPed* thePed) // Disable mouse look if they are not in a fight task and not aiming (strafing) // Fix GitHub Issue #395 - if (thePed->GetCurrentWeaponSlot() == eWeaponSlot::WEAPONSLOT_TYPE_UNARMED && thePed->GetPedIntelligence()->GetFightTask() && data->m_pad.NewState.RightShoulder1 != 0) + if (thePed->GetCurrentWeaponSlot() == eWeaponSlot::WEAPONSLOT_TYPE_UNARMED && data->m_pad.NewState.RightShoulder1 != 0 && thePed->GetPedIntelligence()->GetFightTask()) bDisableMouseLook = false; // Disable mouse look if they're underwater (Ped vertical rotation when diving) From 6cf23c994af8485a3800d427769989dc748c90a3 Mon Sep 17 00:00:00 2001 From: FileEX Date: Mon, 8 Sep 2025 00:23:59 +0200 Subject: [PATCH 3/3] Comment typo --- Client/multiplayer_sa/multiplayer_keysync.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/multiplayer_sa/multiplayer_keysync.cpp b/Client/multiplayer_sa/multiplayer_keysync.cpp index caf7672b710..ebdf265e3b3 100644 --- a/Client/multiplayer_sa/multiplayer_keysync.cpp +++ b/Client/multiplayer_sa/multiplayer_keysync.cpp @@ -312,12 +312,12 @@ void SwitchContext(CPed* thePed) } } - // Disable mouse look if they are not in a fight task and not aiming (strafing) + // Disable mouse look if they're not in a fight task and not aiming (strafing) // Fix GitHub Issue #395 if (thePed->GetCurrentWeaponSlot() == eWeaponSlot::WEAPONSLOT_TYPE_UNARMED && data->m_pad.NewState.RightShoulder1 != 0 && thePed->GetPedIntelligence()->GetFightTask()) bDisableMouseLook = false; - // Disable mouse look if they're underwater (Ped vertical rotation when diving) + // Disable mouse look if they're not underwater (Ped vertical rotation when diving) // TODO - After merge PR #4401 bMouseLookEnabled = *(bool*)0xB6EC2E;