File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,16 @@ CTaskSimpleUseGun* CPedIntelligenceSA::GetTaskUseGun()
6969
7070 return nullptr ;
7171}
72+
73+ CTaskSimpleFight* CPedIntelligenceSA::GetFightTask ()
74+ {
75+ CTaskManager* taskMgr = GetTaskManager ();
76+ if (!taskMgr)
77+ return nullptr ;
78+
79+ CTask* secondaryTask = taskMgr->GetTaskSecondary (TASK_SECONDARY_ATTACK);
80+ if (secondaryTask && secondaryTask->GetTaskType () == TASK_SIMPLE_FIGHT)
81+ return dynamic_cast <CTaskSimpleFight*>(secondaryTask);
82+
83+ return nullptr ;
84+ }
Original file line number Diff line number Diff line change @@ -55,4 +55,5 @@ class CPedIntelligenceSA : public CPedIntelligence
5555 bool TestForStealthKill (CPed* pPed, bool bUnk);
5656 CTaskSAInterface* SetTaskDuckSecondary (unsigned short nLengthOfDuck);
5757 CTaskSimpleUseGun* GetTaskUseGun ();
58+ CTaskSimpleFight* GetFightTask ();
5859};
Original file line number Diff line number Diff line change @@ -301,8 +301,7 @@ void SwitchContext(CPed* thePed)
301301 pGameInterface->SetGravity (data->m_fGravity );
302302
303303 // Disable mouselook for remote players (so the mouse doesn't affect them)
304- // Only disable mouselook if they're not holding a 1st-person weapon
305- // And if they're not under-water
304+ // Disable mouselook if they're not holding a 1st-person weapon
306305 bool bDisableMouseLook = true ;
307306 if (pWeapon)
308307 {
@@ -312,6 +311,15 @@ void SwitchContext(CPed* thePed)
312311 bDisableMouseLook = false ;
313312 }
314313 }
314+
315+ // Disable mouse look if they're not in a fight task and not aiming (strafing)
316+ // Fix GitHub Issue #395
317+ if (thePed->GetCurrentWeaponSlot () == eWeaponSlot::WEAPONSLOT_TYPE_UNARMED && data->m_pad .NewState .RightShoulder1 != 0 && thePed->GetPedIntelligence ()->GetFightTask ())
318+ bDisableMouseLook = false ;
319+
320+ // Disable mouse look if they're not underwater (Ped vertical rotation when diving)
321+ // TODO - After merge PR #4401
322+
315323 bMouseLookEnabled = *(bool *)0xB6EC2E ;
316324 if (bDisableMouseLook)
317325 *(bool *)0xB6EC2E = false ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class CPed;
1515class CTaskSAInterface ;
1616class CTaskManager ;
1717class CTaskSimpleUseGun ;
18+ class CTaskSimpleFight ;
1819
1920class CPedIntelligence
2021{
@@ -23,4 +24,5 @@ class CPedIntelligence
2324 virtual bool TestForStealthKill (CPed* pPed, bool bUnk) = 0;
2425 virtual CTaskSAInterface* SetTaskDuckSecondary (unsigned short nLengthOfDuck) = 0;
2526 virtual CTaskSimpleUseGun* GetTaskUseGun () = 0;
27+ virtual CTaskSimpleFight* GetFightTask () = 0;
2628};
You can’t perform that action at this time.
0 commit comments