Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Client/game_sa/CTasksSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ CTaskSimpleChoking* CTasksSA::CreateTaskSimpleChoking(CPed* pAttacker, bool bIsT
return pTask;
}

CTaskSimpleClimb* CTasksSA::CreateTaskSimpleClimb(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, char nHeight,
CTaskSimpleClimb* CTasksSA::CreateTaskSimpleClimb(CEntitySAInterface* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, eClimbHeights nHeight,
const bool bForceClimb)
{
CTaskSimpleClimbSA* pTask = NewTask<CTaskSimpleClimbSA>(pClimbEnt, vecTarget, fHeading, nSurfaceType, nHeight, bForceClimb);
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CTasksSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CTasksSA : public CTasks
CTaskSimpleDuck* CreateTaskSimpleDuck(eDuckControlTypes nDuckControl, unsigned short nLengthOfDuck = 0, unsigned short nUseShotsWhizzingEvents = -1);
CTaskSimpleChoking* CreateTaskSimpleChoking(CPed* pAttacker, bool bIsTearGas);

CTaskSimpleClimb* CreateTaskSimpleClimb(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, char nHeight = CLIMB_GRAB,
CTaskSimpleClimb* CreateTaskSimpleClimb(CEntitySAInterface* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, eClimbHeights nHeight = CLIMB_GRAB,
const bool bForceClimb = false);
CTaskSimpleJetPack* CreateTaskSimpleJetpack(const CVector* pVecTargetPos = NULL, float fCruiseHeight = 10.0f, int nHoverTime = 0);

Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/TaskJumpFallSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "StdInc.h"
#include "TaskJumpFallSA.h"

CTaskSimpleClimbSA::CTaskSimpleClimbSA(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, char nHeight,
CTaskSimpleClimbSA::CTaskSimpleClimbSA(CEntitySAInterface* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, eClimbHeights nHeight,
const bool bForceClimb)
{
CreateTaskInterface(sizeof(CTaskSimpleClimbSAInterface));
Expand Down
4 changes: 2 additions & 2 deletions Client/game_sa/TaskJumpFallSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CTaskSimpleClimbSAInterface : public CTaskSimpleSAInterface
char m_nFallAfterVault;
float m_fHandholdHeading;
CVector m_vecHandholdPos;
CEntity* m_pClimbEnt;
CEntitySAInterface* m_pClimbEnt;

short m_nGetToPosCounter;
CAnimBlendAssociation* m_pAnim;
Expand All @@ -47,7 +47,7 @@ class CTaskSimpleClimbSA : public virtual CTaskSimpleSA, public virtual CTaskSim
{
public:
CTaskSimpleClimbSA(){};
CTaskSimpleClimbSA(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, char nHeight = CLIMB_GRAB,
CTaskSimpleClimbSA(CEntitySAInterface* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, eClimbHeights nHeight = CLIMB_GRAB,
const bool bForceClimb = false);

eClimbHeights GetHeightForPos() const override { return static_cast<const CTaskSimpleClimbSAInterface*>(GetInterface())->m_nHeightForPos; }
Expand Down
33 changes: 33 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7216,3 +7216,36 @@ void CClientPed::SetSyncing(bool bIsSyncing)
ResetVehicleInOut();
}
}

void CClientPed::RunClimbingTask()
{
if (!m_pPlayerPed)
return;

CVector climbPos;
float climbAngle;
int surfaceType;

CEntitySAInterface* climbEntity = CTaskSimpleClimb::TestForClimb(m_pPlayerPed, climbPos, climbAngle, surfaceType, true);

// If a ped is in the air, its rotation is inverted (see GetRotationDegressNew, GetRotationRadiansNew)
if (!IsOnGround() && !climbEntity)
{
CVector rot;
GetRotationDegrees(rot);

rot.fZ += 180.0f;
SetRotationDegrees(rot);

climbEntity = CTaskSimpleClimb::TestForClimb(m_pPlayerPed, climbPos, climbAngle, surfaceType, true);
}

if (!climbEntity)
return;

CTaskSimpleClimb* climbTask = g_pGame->GetTasks()->CreateTaskSimpleClimb(climbEntity, climbPos, climbAngle, surfaceType, eClimbHeights::CLIMB_GRAB, false);
if (!climbTask)
return;

climbTask->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_PRIMARY, true);
}
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
void SetHasSyncedAnim(bool synced) noexcept { m_hasSyncedAnim = synced; }
bool HasSyncedAnim() const noexcept { return m_hasSyncedAnim; }

void RunClimbingTask();

protected:
// This constructor is for peds managed by a player. These are unknown to the ped manager.
CClientPed(CClientManager* pManager, unsigned long ulModelID, ElementID ID, bool bIsLocalPlayer);
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ CTask* CClientTask::CreateTask(bool& bTaskPrimary, int& iTaskPriority)
iTaskPriority = TASK_PRIORITY_PRIMARY;

// Create the task
return g_pGame->GetTasks()->CreateTaskSimpleClimb(NULL, vecTarget, fHeading, static_cast<unsigned char>(fSurfaceType), static_cast<char>(fClimbStage),
return g_pGame->GetTasks()->CreateTaskSimpleClimb(NULL, vecTarget, fHeading, static_cast<unsigned char>(fSurfaceType), static_cast<eClimbHeights>(fClimbStage),
bForceClimb);
}

Expand Down
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CNetAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,9 @@ void CNetAPI::ReadPlayerPuresync(CClientPlayer* pPlayer, NetBitStreamInterface&
pPlayer->SetOnFire(flags.data.bIsOnFire);
pPlayer->SetStealthAiming(flags.data.bStealthAiming);

if (flags.data.hangingDuringClimb && pPlayer->GetMovementState() != eMovementState::MOVEMENTSTATE_HANGING && pPlayer->GetMovementState() != eMovementState::MOVEMENTSTATE_CLIMB)
pPlayer->RunClimbingTask();

// Remember now as the last puresync time
pPlayer->SetLastPuresyncTime(CClientTime::GetTime());
pPlayer->SetLastPuresyncPosition(position.data.vecPosition);
Expand Down Expand Up @@ -1112,6 +1115,7 @@ void CNetAPI::WritePlayerPuresync(CClientPlayer* pPlayerModel, NetBitStreamInter
flags.data.bStealthAiming = (pPlayerModel->IsStealthAiming() == true);
flags.data.isReloadingWeapon = (pPlayerModel->IsReloadingWeapon() == true);
flags.data.animInterrupted = pPlayerModel->HasSyncedAnim() && (!pPlayerModel->IsRunningAnimation() || pPlayerModel->m_animationOverridedByClient);
flags.data.hangingDuringClimb = pPlayerModel->GetMovementState() == eMovementState::MOVEMENTSTATE_HANGING;

// The animation has been overwritten or interrupted by the client
if (flags.data.animInterrupted)
Expand Down
4 changes: 2 additions & 2 deletions Client/sdk/game/CTasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class CTasks
unsigned short nUseShotsWhizzingEvents = -1) = 0;
virtual CTaskSimpleChoking* CreateTaskSimpleChoking(CPed* pAttacker, bool bIsTearGas) = 0;

virtual CTaskSimpleClimb* CreateTaskSimpleClimb(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType,
char nHeight = CLIMB_GRAB, const bool bForceClimb = false) = 0;
virtual CTaskSimpleClimb* CreateTaskSimpleClimb(CEntitySAInterface* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType,
eClimbHeights nHeight = CLIMB_GRAB, const bool bForceClimb = false) = 0;
virtual CTaskSimpleJetPack* CreateTaskSimpleJetpack(const CVector* pVecTargetPos = NULL, float fCruiseHeight = 10.0f, int nHoverTime = 0) = 0;

virtual CTaskSimpleRunAnim* CreateTaskSimpleRunAnim(const AssocGroupId animGroup, const AnimationId animID, const float fBlendDelta, const int iTaskType,
Expand Down
10 changes: 10 additions & 0 deletions Client/sdk/game/TaskJumpFall.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#pragma once

#include "Task.h"
#include "CPed.h"

enum eClimbHeights : std::int8_t;

Expand All @@ -21,6 +22,15 @@ class CTaskSimpleClimb : public virtual CTaskSimple
virtual ~CTaskSimpleClimb(){};

virtual eClimbHeights GetHeightForPos() const = 0;

static class CEntitySAInterface* TestForClimb(CPed* ped, CVector& climbPos, float& climbAngle, int& surfaceType, bool launch)
{
if (!ped)
return nullptr;

// CTaskSimpleClimb::TestForClimb
return ((class CEntitySAInterface*(__cdecl*)(class CPedSAInterface*, CVector*, float*, int*, bool))0x6803A0)(ped->GetPedInterface(), &climbPos, &climbAngle, &surfaceType, launch);
}
};

class CTaskSimpleJetPack : public virtual CTaskSimple
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ class CPed : public CElement
void SetAnimationProgress(float progress) { m_animData.progress = progress; };
void SetAnimationSpeed(float speed) { m_animData.speed = speed; };

void SetHanging(bool hanging) noexcept { m_hanging = hanging; }
bool IsHanging() const noexcept { return m_hanging; }

protected:
bool ReadSpecialData(const int iLine) override;

Expand Down Expand Up @@ -350,6 +353,7 @@ class CPed : public CElement
CVehicle* m_pJackingVehicle;
SPlayerAnimData m_animData{};
float m_cameraRotation{};
bool m_hanging{false}; // Is the player hanging during a climb task?

CVehicle* m_pVehicle;
unsigned int m_uiVehicleSeat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream)
if (flags.data.animInterrupted)
pSourcePlayer->SetAnimationData({});

pSourcePlayer->SetHanging(flags.data.hangingDuringClimb);

// Contact element
CElement* pContactElement = NULL;
if (flags.data.bHasContact)
Expand Down Expand Up @@ -374,6 +376,7 @@ bool CPlayerPuresyncPacket::Write(NetBitStreamInterface& BitStream) const
flags.data.bSyncingVelocity = (!flags.data.bIsOnGround || pSourcePlayer->IsSyncingVelocity());
flags.data.bStealthAiming = (pSourcePlayer->IsStealthAiming() == true);
flags.data.isReloadingWeapon = pSourcePlayer->IsReloadingWeapon();
flags.data.hangingDuringClimb = pSourcePlayer->IsHanging();

CVector vecPosition = pSourcePlayer->GetPosition();
if (pContactElement)
Expand Down
3 changes: 2 additions & 1 deletion Shared/sdk/net/SyncStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ struct SPlayerPuresyncFlags : public ISyncStructure
{
enum
{
BITCOUNT = 14
BITCOUNT = 15
};

bool Read(NetBitStreamInterface& stream)
Expand Down Expand Up @@ -573,6 +573,7 @@ struct SPlayerPuresyncFlags : public ISyncStructure
bool bStealthAiming : 1;
bool isReloadingWeapon : 1;
bool animInterrupted : 1;
bool hangingDuringClimb : 1;
} data;
};

Expand Down
Loading