Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Client/game_sa/CPedIntelligenceSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CTaskSimpleFight*>(secondaryTask);

return nullptr;
}
1 change: 1 addition & 0 deletions Client/game_sa/CPedIntelligenceSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ class CPedIntelligenceSA : public CPedIntelligence
bool TestForStealthKill(CPed* pPed, bool bUnk);
CTaskSAInterface* SetTaskDuckSecondary(unsigned short nLengthOfDuck);
CTaskSimpleUseGun* GetTaskUseGun();
CTaskSimpleFight* GetFightTask();
};
12 changes: 10 additions & 2 deletions Client/multiplayer_sa/multiplayer_keysync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -312,6 +311,15 @@ void SwitchContext(CPed* thePed)
bDisableMouseLook = false;
}
}

// 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 not underwater (Ped vertical rotation when diving)
// TODO - After merge PR #4401

bMouseLookEnabled = *(bool*)0xB6EC2E;
if (bDisableMouseLook)
*(bool*)0xB6EC2E = false;
Expand Down
2 changes: 2 additions & 0 deletions Client/sdk/game/CPedIntelligence.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CPed;
class CTaskSAInterface;
class CTaskManager;
class CTaskSimpleUseGun;
class CTaskSimpleFight;

class CPedIntelligence
{
Expand All @@ -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;
};
Loading