Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions Client/game_sa/CPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,9 @@ void CPedSA::GetAttachedSatchels(std::vector<SSatchelsData>& satchelsList) const
satchelsList.push_back({pProjectileInterface, &pProjectileInterface->m_vecAttachedOffset, &pProjectileInterface->m_vecAttachedRotation});
}
}

void CPedSA::Say(const ePedSpeechContext& speechId, float probability)
{
// Call CPed::Say
((void(__thiscall*)(CPedSAInterface*, ePedSpeechContext, int, float, bool, bool, bool))FUNC_CPed_Say)(GetPedInterface(), speechId, 0, probability, false, false, false);
}
3 changes: 3 additions & 0 deletions Client/game_sa/CPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CPedIntelligenceSAInterface;
#define FUNC_DetachPedFromEntity 0x5E7EC0
#define FUNC_CPed_RemoveBodyPart 0x5f0140
#define FUNC_PreRenderAfterTest 0x5E65A0
#define FUNC_CPed_Say 0x5EFFE0

#define VAR_LocalPlayer 0x94AD28

Expand Down Expand Up @@ -419,4 +420,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
ePedState GetPedState() { return GetPedInterface()->pedState; }

void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;

void Say(const ePedSpeechContext& speechId, float probability) override;
};
8 changes: 8 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5272,6 +5272,14 @@ void CClientPed::Respawn(CVector* pvecPosition, bool bRestoreState, bool bCamera
}
}

void CClientPed::Say(const ePedSpeechContext& speechId, float probability)
{
if (!m_pPlayerPed)
return;

m_pPlayerPed->Say(speechId, probability);
}

const char* CClientPed::GetBodyPartName(unsigned char ucID)
{
if (ucID <= 10)
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule

void Respawn(CVector* pvecPosition = NULL, bool bRestoreState = false, bool bCameraCut = false);

void Say(const ePedSpeechContext& speechId, float probability = 1.0f);

void SetTaskToBeRestoredOnAnimEnd(bool bSetOnEnd) noexcept { m_bTaskToBeRestoredOnAnimEnd = bSetOnEnd; }
bool IsTaskToBeRestoredOnAnimEnd() const noexcept { return m_bTaskToBeRestoredOnAnimEnd; }
void SetTaskTypeToBeRestoredOnAnimEnd(eTaskType taskType) noexcept { m_eTaskTypeToBeRestoredOnAnimEnd = taskType; }
Expand Down
16 changes: 16 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <game/CTasks.h>
#include <game/TaskBasic.h>
#include <game/CAnimManager.h>
#include "CLuaPedDefs.h"

#define MIN_CLIENT_REQ_REMOVEPEDFROMVEHICLE_CLIENTSIDE "1.3.0-9.04482"
#define MIN_CLIENT_REQ_WARPPEDINTOVEHICLE_CLIENTSIDE "1.3.0-9.04482"
Expand Down Expand Up @@ -61,6 +62,7 @@ void CLuaPedDefs::LoadFunctions()
{"setPedEnterVehicle", ArgumentParser<SetPedEnterVehicle>},
{"setPedExitVehicle", ArgumentParser<SetPedExitVehicle>},
{"setPedBleeding", ArgumentParser<SetPedBleeding>},
{"playPedVoiceLine", ArgumentParser<PlayPedVoiceLine>},

{"getPedVoice", GetPedVoice},
{"getElementBonePosition", ArgumentParser<GetElementBonePosition>},
Expand Down Expand Up @@ -210,6 +212,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setEnterVehicle", "setPedEnterVehicle");
lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle");
lua_classfunction(luaVM, "setBleeding", "setPedBleeding");
lua_classfunction(luaVM, "playPedVoiceLine", "playVoiceLine");

lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat");
Expand Down Expand Up @@ -2497,3 +2500,16 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t
return false;
}
}

bool CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probabilty)
{
auto speechContextId = static_cast<ePedSpeechContext>(speechId);
if (speechContextId < ePedSpeechContext::NOTHING || speechContextId >= ePedSpeechContext::NUM_PED_CONTEXT)
throw LuaFunctionError("The argument speechId is invalid. The valid range is 0-359.");

if (probabilty.has_value() && probabilty < 0.0f)
return false;

ped->Say(speechContextId, probabilty.value_or(1.0f));
return true;
}
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,6 @@ class CLuaPedDefs : public CLuaDefs
static bool SetPedBleeding(CClientPed* ped, bool bleeding);

static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept;

static bool PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probabilty);
};
3 changes: 3 additions & 0 deletions Client/sdk/game/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Common.h"
#include "CPhysical.h"
#include "CWeaponInfo.h"
#include "CPedSound.h"

class CObject;
class CPedIK;
Expand Down Expand Up @@ -286,4 +287,6 @@ class CPed : public virtual CPhysical
virtual ePedState GetPedState() = 0;

virtual void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const = 0;

virtual void Say(const ePedSpeechContext& speechId, float probability) = 0;
};
Loading
Loading