Skip to content

Commit 6ba5990

Browse files
authored
Merge branch 'master' into fix-bind
2 parents e916617 + 7067ac1 commit 6ba5990

File tree

8 files changed

+418
-4
lines changed

8 files changed

+418
-4
lines changed

Client/game_sa/CPedSA.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,3 +1120,9 @@ void CPedSA::GetAttachedSatchels(std::vector<SSatchelsData>& satchelsList) const
11201120
satchelsList.push_back({pProjectileInterface, &pProjectileInterface->m_vecAttachedOffset, &pProjectileInterface->m_vecAttachedRotation});
11211121
}
11221122
}
1123+
1124+
void CPedSA::Say(const ePedSpeechContext& speechId, float probability)
1125+
{
1126+
// Call CPed::Say
1127+
((void(__thiscall*)(CPedSAInterface*, ePedSpeechContext, int, float, bool, bool, bool))FUNC_CPed_Say)(GetPedInterface(), speechId, 0, probability, false, false, false);
1128+
}

Client/game_sa/CPedSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CPedIntelligenceSAInterface;
5959
#define FUNC_DetachPedFromEntity 0x5E7EC0
6060
#define FUNC_CPed_RemoveBodyPart 0x5f0140
6161
#define FUNC_PreRenderAfterTest 0x5E65A0
62+
#define FUNC_CPed_Say 0x5EFFE0
6263

6364
#define VAR_LocalPlayer 0x94AD28
6465

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

421422
void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;
423+
424+
void Say(const ePedSpeechContext& speechId, float probability) override;
422425
};

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5272,6 +5272,14 @@ void CClientPed::Respawn(CVector* pvecPosition, bool bRestoreState, bool bCamera
52725272
}
52735273
}
52745274

5275+
void CClientPed::Say(const ePedSpeechContext& speechId, float probability)
5276+
{
5277+
if (!m_pPlayerPed)
5278+
return;
5279+
5280+
m_pPlayerPed->Say(speechId, probability);
5281+
}
5282+
52755283
const char* CClientPed::GetBodyPartName(unsigned char ucID)
52765284
{
52775285
if (ucID <= 10)

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
598598

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

601+
void Say(const ePedSpeechContext& speechId, float probability = 1.0f);
602+
601603
void SetTaskToBeRestoredOnAnimEnd(bool bSetOnEnd) noexcept { m_bTaskToBeRestoredOnAnimEnd = bSetOnEnd; }
602604
bool IsTaskToBeRestoredOnAnimEnd() const noexcept { return m_bTaskToBeRestoredOnAnimEnd; }
603605
void SetTaskTypeToBeRestoredOnAnimEnd(eTaskType taskType) noexcept { m_eTaskTypeToBeRestoredOnAnimEnd = taskType; }

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <game/CTasks.h>
1616
#include <game/TaskBasic.h>
1717
#include <game/CAnimManager.h>
18+
#include "CLuaPedDefs.h"
1819

1920
#define MIN_CLIENT_REQ_REMOVEPEDFROMVEHICLE_CLIENTSIDE "1.3.0-9.04482"
2021
#define MIN_CLIENT_REQ_WARPPEDINTOVEHICLE_CLIENTSIDE "1.3.0-9.04482"
@@ -61,6 +62,7 @@ void CLuaPedDefs::LoadFunctions()
6162
{"setPedEnterVehicle", ArgumentParser<SetPedEnterVehicle>},
6263
{"setPedExitVehicle", ArgumentParser<SetPedExitVehicle>},
6364
{"setPedBleeding", ArgumentParser<SetPedBleeding>},
65+
{"playPedVoiceLine", ArgumentParser<PlayPedVoiceLine>},
6466

6567
{"getPedVoice", GetPedVoice},
6668
{"getElementBonePosition", ArgumentParser<GetElementBonePosition>},
@@ -210,6 +212,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
210212
lua_classfunction(luaVM, "setEnterVehicle", "setPedEnterVehicle");
211213
lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle");
212214
lua_classfunction(luaVM, "setBleeding", "setPedBleeding");
215+
lua_classfunction(luaVM, "playPedVoiceLine", "playVoiceLine");
213216

214217
lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
215218
lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat");
@@ -2506,3 +2509,15 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t
25062509
return false;
25072510
}
25082511
}
2512+
2513+
void CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probabilty)
2514+
{
2515+
auto speechContextId = static_cast<ePedSpeechContext>(speechId);
2516+
if (speechContextId < ePedSpeechContext::NOTHING || speechContextId >= ePedSpeechContext::NUM_PED_CONTEXT)
2517+
throw LuaFunctionError("The argument speechId is invalid. The valid range is 0-359.");
2518+
2519+
if (probabilty.has_value() && probabilty < 0.0f)
2520+
throw LuaFunctionError("The argument probabilty cannot have a negative value.");
2521+
2522+
ped->Say(speechContextId, probabilty.value_or(1.0f));
2523+
}

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class CLuaPedDefs : public CLuaDefs
116116
static bool SetPedExitVehicle(CClientPed* pPed);
117117
static bool IsPedBleeding(CClientPed* ped);
118118
static bool SetPedBleeding(CClientPed* ped, bool bleeding);
119-
119+
120120
static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully);
121+
122+
static void PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probabilty);
121123
};

Client/sdk/game/CPed.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Common.h"
1616
#include "CPhysical.h"
1717
#include "CWeaponInfo.h"
18+
#include "CPedSound.h"
1819

1920
class CObject;
2021
class CPedIK;
@@ -286,4 +287,6 @@ class CPed : public virtual CPhysical
286287
virtual ePedState GetPedState() = 0;
287288

288289
virtual void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const = 0;
290+
291+
virtual void Say(const ePedSpeechContext& speechId, float probability) = 0;
289292
};

0 commit comments

Comments
 (0)