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
4 changes: 3 additions & 1 deletion Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "MemSA.h"
#include "CVehicleSA.h"
#include "CBuildingRemovalSA.h"
#include "CPlayerPedSA.h"

extern CGameSA* pGame;

Expand Down Expand Up @@ -372,7 +373,8 @@ void CBuildingsPoolSA::RemovePedsContactEnityLinks()
ped->pLastContactedEntity[2] = nullptr;
ped->pLastContactedEntity[3] = nullptr;
ped->m_ucCollisionState = 0;
ped->pTargetedEntity = nullptr;

reinterpret_cast<CPlayerPedSA*>(pedLinks->pEntity)->SetTargetedEntity(nullptr);
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions Client/game_sa/CPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,6 @@ CEntity* CPedSA::GetContactEntity() const
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(contactInterface));
}

CEntity* CPedSA::GetTargetedEntity() const
{
CEntitySAInterface* targetInterface = GetPedInterface()->pTargetedEntity;
if (!targetInterface)
return nullptr;

return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(targetInterface));
}

void CPedSA::SetTargetedEntity(CEntity* targetEntity)
{
GetPedInterface()->pTargetedEntity = targetEntity ? targetEntity->GetInterface() : nullptr;
}

void CPedSA::RemoveBodyPart(std::uint8_t boneID, std::uint8_t direction)
{
// char __thiscall CPed::RemoveBodyPart(CPed *this, int boneID, int localDir)
Expand Down
5 changes: 1 addition & 4 deletions Client/game_sa/CPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class CPedSAInterface : public CPhysicalSAInterface
int unk_75C;
std::uint8_t lastWeaponDamage;
std::uint8_t unk_761[3];
CEntitySAInterface* pTargetedEntity;
CEntitySAInterface* lastDamagedEntity;
std::int16_t unk_768;

CVector vecTurretOffset;
Expand Down Expand Up @@ -424,9 +424,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA

int GetRunState() const override { return GetPedInterface()->moveState; }

CEntity* GetTargetedEntity() const override;
void SetTargetedEntity(CEntity* targetEntity) override;

bool GetCanBeShotInVehicle() const override{ return GetPedInterface()->pedFlags.bCanBeShotInVehicle; }
bool GetTestForShotInVehicle() const override { return GetPedInterface()->pedFlags.bTestForShotInVehicle; }

Expand Down
14 changes: 14 additions & 0 deletions Client/game_sa/CPlayerPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ void CPlayerPedSA::SetMoveAnim(eMoveAnim iAnimGroup)
}
}

CEntity* CPlayerPedSA::GetTargetedEntity() const
{
CEntitySAInterface* targetInterface = GetPlayerPedInterface()->mouseTargetEntity;
if (!targetInterface)
return nullptr;

return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(targetInterface));
}

void CPlayerPedSA::SetTargetedEntity(CEntity* targetEntity)
{
GetPlayerPedInterface()->mouseTargetEntity = targetEntity ? targetEntity->GetInterface() : nullptr;
}

////////////////////////////////////////////////////////////////
//
// Hooks for CPlayerPedSA
Expand Down
10 changes: 8 additions & 2 deletions Client/game_sa/CPlayerPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@

#define SIZEOF_CPLAYERPED 1956

class CPlayerPedSAInterface : public CPedSAInterface // CPlayerPed 1956 bytes in SA
class CPlayerPedSAInterface : public CPedSAInterface
{
public:
CEntitySAInterface* mouseTargetEntity;
std::uint8_t field_7A0[4];
};
static_assert(sizeof(CPlayerPedSAInterface) == 0x7A4, "Invalid size for CPlayerPedSAInterface");

class CPlayerPedSA : public virtual CPlayerPed, public virtual CPedSA
{
Expand All @@ -52,7 +55,10 @@ class CPlayerPedSA : public virtual CPlayerPed, public virtual CPedSA
eMoveAnim GetMoveAnim();
void SetMoveAnim(eMoveAnim iAnimGroup);

CPlayerPedSAInterface* GetPlayerPedInterface() { return static_cast<CPlayerPedSAInterface*>(m_pInterface); };
CEntity* GetTargetedEntity() const override;
void SetTargetedEntity(CEntity* targetEntity) override;

CPlayerPedSAInterface* GetPlayerPedInterface() const noexcept { return static_cast<CPlayerPedSAInterface*>(m_pInterface); };

static void StaticSetHooks();
};
3 changes: 0 additions & 3 deletions Client/sdk/game/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ class CPed : public virtual CPhysical

virtual int GetRunState() const = 0;

virtual CEntity* GetTargetedEntity() const = 0;
virtual void SetTargetedEntity(CEntity* targetEntity) = 0;

virtual bool GetCanBeShotInVehicle() const = 0;
virtual bool GetTestForShotInVehicle() const = 0;

Expand Down
3 changes: 3 additions & 0 deletions Client/sdk/game/CPlayerPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ class CPlayerPed : public virtual CPed

virtual eMoveAnim GetMoveAnim() = 0;
virtual void SetMoveAnim(eMoveAnim iAnimGroup) = 0;

virtual CEntity* GetTargetedEntity() const = 0;
virtual void SetTargetedEntity(CEntity* entity) = 0;
};
Loading