Skip to content

Commit d54e53a

Browse files
authored
Add is/setPedBleeding (#2308)
1 parent 334af01 commit d54e53a

File tree

7 files changed

+47
-0
lines changed

7 files changed

+47
-0
lines changed

Client/game_sa/CPedSA.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,16 @@ unsigned int CPedSA::GetFootBlood()
892892
return 0;
893893
}
894894

895+
bool CPedSA::IsBleeding()
896+
{
897+
return GetPedInterface()->pedFlags.bPedIsBleeding;
898+
}
899+
900+
void CPedSA::SetBleeding(bool bBleeding)
901+
{
902+
GetPedInterface()->pedFlags.bPedIsBleeding = bBleeding;
903+
}
904+
895905
bool CPedSA::IsOnFire()
896906
{
897907
if (GetPedInterface()->pFireOnPed != NULL)

Client/game_sa/CPedSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
431431
void SetFootBlood(unsigned int uiFootBlood);
432432
unsigned int GetFootBlood();
433433

434+
bool IsBleeding();
435+
void SetBleeding(bool bBleeding);
436+
434437
bool IsOnFire();
435438
void SetOnFire(bool bOnFire);
436439

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
142142
m_fCurrentRotation = 0.0f;
143143
m_fMoveSpeed = 0.0f;
144144
m_bCanBeKnockedOffBike = true;
145+
m_bBleeding = false;
145146
RemoveAllWeapons(); // Set all our weapon values to unarmed
146147
m_bHasJetPack = false;
147148
m_FightingStyle = STYLE_GRAB_KICK;
@@ -5925,6 +5926,15 @@ bool CClientPed::IsFootBloodEnabled()
59255926
return false;
59265927
}
59275928

5929+
void CClientPed::SetBleeding(bool bBleeding)
5930+
{
5931+
if (m_pPlayerPed)
5932+
{
5933+
m_pPlayerPed->SetBleeding(bBleeding);
5934+
}
5935+
m_bBleeding = bBleeding;
5936+
}
5937+
59285938
bool CClientPed::IsOnFire()
59295939
{
59305940
if (m_pPlayerPed)

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
464464

465465
bool IsFootBloodEnabled();
466466
void SetFootBloodEnabled(bool bHasFootBlood);
467+
468+
bool IsBleeding() const { return m_bBleeding; };
469+
void SetBleeding(bool bBleeding);
467470

468471
bool IsOnFire();
469472
void SetOnFire(bool bOnFire);
@@ -658,6 +661,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
658661
float m_fCurrentRotation;
659662
float m_fMoveSpeed;
660663
bool m_bCanBeKnockedOffBike;
664+
bool m_bBleeding;
661665
CMatrix m_Matrix;
662666
CVector m_vecMoveSpeed;
663667
CVector m_vecTurnSpeed;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void CLuaPedDefs::LoadFunctions()
7272
{"isPedFootBloodEnabled", IsPedFootBloodEnabled},
7373
{"getPedCameraRotation", GetPedCameraRotation},
7474
{"getPedOxygenLevel", GetPedOxygenLevel},
75+
{"isPedBleeding", ArgumentParser<IsPedBleeding>},
7576

7677
{"setPedWeaponSlot", SetPedWeaponSlot},
7778
{"setPedRotation", SetPedRotation},
@@ -101,6 +102,7 @@ void CLuaPedDefs::LoadFunctions()
101102
{"isPedReloadingWeapon", IsPedReloadingWeapon},
102103
{"setPedEnterVehicle", ArgumentParser<SetPedEnterVehicle>},
103104
{"setPedExitVehicle", ArgumentParser<SetPedExitVehicle>},
105+
{"setPedBleeding", ArgumentParser<SetPedBleeding>},
104106
};
105107

106108
// Add functions
@@ -165,6 +167,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
165167
lua_classfunction(luaVM, "getCameraRotation", "getPedCameraRotation");
166168
lua_classfunction(luaVM, "getWeaponSlot", "getPedWeaponSlot");
167169
lua_classfunction(luaVM, "getWalkingStyle", "getPedWalkingStyle");
170+
lua_classfunction(luaVM, "isBleeding", "isPedBleeding");
168171

169172
lua_classfunction(luaVM, "setCanBeKnockedOffBike", "setPedCanBeKnockedOffBike");
170173
lua_classfunction(luaVM, "setAnalogControlState", "setPedAnalogControlState");
@@ -192,6 +195,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
192195
lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon");
193196
lua_classfunction(luaVM, "setEnterVehicle", "setPedEnterVehicle");
194197
lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle");
198+
lua_classfunction(luaVM, "setBleeding", "setPedBleeding");
195199

196200
lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
197201
lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat");
@@ -216,6 +220,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
216220
lua_classvariable(luaVM, "dead", NULL, "isPedDead");
217221
lua_classvariable(luaVM, "targetingMarker", "setPedTargetingMarkerEnabled", "isPedTargetingMarkerEnabled");
218222
lua_classvariable(luaVM, "footBlood", "setPedFootBloodEnabled", NULL);
223+
lua_classvariable(luaVM, "bleeding", "setPedBleeding", "isPedBleeding");
219224
lua_classvariable(luaVM, "targetCollision", nullptr, OOP_GetPedTargetCollision);
220225
lua_classvariable(luaVM, "targetEnd", nullptr, OOP_GetPedTargetEnd);
221226
lua_classvariable(luaVM, "targetStart", nullptr, OOP_GetPedTargetStart);
@@ -1498,6 +1503,11 @@ int CLuaPedDefs::IsPedFootBloodEnabled(lua_State* luaVM)
14981503
return 1;
14991504
}
15001505

1506+
bool CLuaPedDefs::IsPedBleeding(CClientPed* pPed)
1507+
{
1508+
return pPed->IsBleeding();
1509+
}
1510+
15011511
int CLuaPedDefs::GetPedCameraRotation(lua_State* luaVM)
15021512
{
15031513
// Verify the argument
@@ -1959,6 +1969,12 @@ int CLuaPedDefs::SetPedFootBloodEnabled(lua_State* luaVM)
19591969
return 1;
19601970
}
19611971

1972+
bool CLuaPedDefs::SetPedBleeding(CClientPed* ped, bool bleeding)
1973+
{
1974+
ped->SetBleeding(bleeding);
1975+
return true;
1976+
}
1977+
19621978
int CLuaPedDefs::SetPedCameraRotation(lua_State* luaVM)
19631979
{
19641980
// bool setPedCameraRotation ( ped thePed, float cameraRotation )

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,6 @@ class CLuaPedDefs : public CLuaDefs
111111
LUA_DECLARE(SetPedStat);
112112
static bool SetPedEnterVehicle(CClientPed* pPed, std::optional<CClientVehicle*> pOptVehicle, std::optional<bool> bOptPassenger);
113113
static bool SetPedExitVehicle(CClientPed* pPed);
114+
static bool IsPedBleeding(CClientPed* ped);
115+
static bool SetPedBleeding(CClientPed* ped, bool bleeding);
114116
};

Client/sdk/game/CPed.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class CPed : public virtual CPhysical
228228
virtual void SetCantBeKnockedOffBike(int iCantBeKnockedOffBike) = 0;
229229
virtual void QuitEnteringCar(CVehicle* vehicle, int iSeat, bool bUnknown) = 0;
230230

231+
virtual void SetBleeding(bool bBleeding) = 0;
232+
231233
virtual bool IsWearingGoggles() = 0;
232234
virtual void SetGogglesState(bool bIsWearingThem) = 0;
233235

0 commit comments

Comments
 (0)