Skip to content

Commit 1b14af5

Browse files
Zangomanguqaisjp
authored andcommitted
Fix #1440 driveby pitch inverted sometimes
1 parent 0ee554b commit 1b14af5

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

Client/game_sa/CPedSA.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,18 @@ int CPedSA::GetCustomMoveAnim()
10271027
return m_iCustomMoveAnim;
10281028
}
10291029

1030+
bool CPedSA::IsDoingGangDriveby()
1031+
{
1032+
auto pTaskManager = m_pPedIntelligence->GetTaskManager();
1033+
CTask* pTask = pTaskManager->GetTask(TASK_PRIORITY_PRIMARY);
1034+
if (pTask && pTask->GetTaskType() == TASK_SIMPLE_GANG_DRIVEBY)
1035+
{
1036+
return true;
1037+
}
1038+
1039+
return false;
1040+
}
1041+
10301042
/*
10311043
bool CPedSA::CanPedReturnToState ( )
10321044
{

Client/game_sa/CPedSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
447447
void AddWeaponAudioEvent(EPedWeaponAudioEventType audioEventType);
448448

449449
virtual int GetCustomMoveAnim();
450+
bool IsDoingGangDriveby();
450451

451452
static void StaticSetHooks();
452453
};

Client/multiplayer_sa/multiplayer_shotsync.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ bool IsLocalPlayer(CPedSAInterface* pPedInterface)
140140

141141
VOID WriteGunDirectionDataForPed(CPedSAInterface* pPedInterface, float* fGunDirectionX, float* fGunDirectionY, char* cGunDirection)
142142
{
143-
if (!IsLocalPlayer(pPedInterface))
143+
SClientEntity<CPedSA>* pPedClientEntity = m_pools->GetPed((DWORD*)pPedInterface);
144+
CPed* pAimingPed = pPedClientEntity ? pPedClientEntity->pEntity : nullptr;
145+
146+
if (!pAimingPed)
147+
return;
148+
149+
if (!IsLocalPlayer(pAimingPed))
144150
{
145151
CRemoteDataStorageSA* data = CRemoteDataSA::GetRemoteDataStorage(pPedInterface);
146152
if (data)
@@ -168,6 +174,16 @@ VOID WriteGunDirectionDataForPed(CPedSAInterface* pPedInterface, float* fGunDire
168174
// Make sure our pitch is updated (fixes first-person weapons not moving)
169175
*fGunDirectionY = pGameInterface->GetCamera()->Find3rdPersonQuickAimPitch();
170176

177+
// Are we doing driveby?
178+
if (pAimingPed->IsDoingGangDriveby())
179+
{
180+
// Fix pitch in driveby when facing left or backwards
181+
if (LocalShotSyncData.m_cInVehicleAimDirection == 1 || LocalShotSyncData.m_cInVehicleAimDirection == 2)
182+
{
183+
*fGunDirectionY = -*fGunDirectionY;
184+
}
185+
}
186+
171187
LocalShotSyncData.m_fArmDirectionX = *fGunDirectionX;
172188
LocalShotSyncData.m_fArmDirectionY = *fGunDirectionY;
173189
}

Client/sdk/game/CPed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,5 @@ class CPed : public virtual CPhysical
269269
virtual void AddWeaponAudioEvent(EPedWeaponAudioEventType audioEventType) = 0;
270270

271271
virtual int GetCustomMoveAnim() = 0;
272+
virtual bool IsDoingGangDriveby() = 0;
272273
};

0 commit comments

Comments
 (0)