Skip to content

Commit 24de732

Browse files
authored
Fix remote player fist/melee strafing sync (#4431)
1 parent 8f85924 commit 24de732

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Client/game_sa/CPedIntelligenceSA.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

Client/game_sa/CPedIntelligenceSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
};

Client/multiplayer_sa/multiplayer_keysync.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

Client/sdk/game/CPedIntelligence.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class CPed;
1515
class CTaskSAInterface;
1616
class CTaskManager;
1717
class CTaskSimpleUseGun;
18+
class CTaskSimpleFight;
1819

1920
class 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
};

0 commit comments

Comments
 (0)