Skip to content

Commit

Permalink
Handle target camera rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
tederis committed Jan 29, 2025
1 parent b3d44c7 commit d318adf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3333,14 +3333,20 @@ void CClientPed::SetTargetRotation(float fRotation)
SetCurrentRotation(fRotation);
}

void CClientPed::SetTargetRotation(unsigned long ulDelay, float fRotation, float fCameraRotation)
void CClientPed::SetTargetRotation(unsigned long ulDelay, std::optional<float> rotation, std::optional<float> cameraRotation)
{
m_ulBeginRotationTime = CClientTime::GetTime();
m_ulEndRotationTime = m_ulBeginRotationTime + ulDelay;
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
m_fTargetRotationA = fRotation;
m_fBeginCameraRotation = GetCameraRotation();
m_fTargetCameraRotation = fCameraRotation;
if (rotation.has_value())
{
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
m_fTargetRotationA = rotation.value();
}
if (cameraRotation.has_value())
{
m_fBeginCameraRotation = GetCameraRotation();
m_fTargetCameraRotation = cameraRotation.value();
}
}

// Temporary
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
float GetCurrentRotation();
void SetCurrentRotation(float fRotation, bool bIncludeTarget = true);
void SetTargetRotation(float fRotation);
void SetTargetRotation(unsigned long ulDelay, float fRotation, float fCameraRotation);
void SetTargetRotation(unsigned long ulDelay, std::optional<float> rotation, std::optional<float> cameraRotation);

float GetCameraRotation();
void SetCameraRotation(float fRotation);
Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/CPedSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
if (ucFlags & 0x01)
pPed->SetTargetPosition(vecPosition, PED_SYNC_RATE);
if (ucFlags & 0x02)
pPed->SetTargetRotation(PED_SYNC_RATE, fRotation, 0.0f);
pPed->SetTargetRotation(PED_SYNC_RATE, fRotation, std::nullopt);
if (ucFlags & 0x04)
pPed->SetMoveSpeed(vecMoveSpeed);
if (ucFlags & 0x08)
pPed->LockHealth(fHealth);
if (ucFlags & 0x10)
pPed->LockArmor(fArmor);
if (flags2 & 0x01)
pPed->SetCameraRotation(cameraRotation);
pPed->SetTargetRotation(PED_SYNC_RATE, std::nullopt, cameraRotation);
if (BitStream.Version() >= 0x04E && ucFlags & 0x20)
pPed->SetOnFire(bOnFire);
if (BitStream.Version() >= 0x55 && ucFlags & 0x40)
Expand Down

0 comments on commit d318adf

Please sign in to comment.