Skip to content

Add is/setPedBleeding functions #2308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2021
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
10 changes: 10 additions & 0 deletions Client/game_sa/CPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,16 @@ unsigned int CPedSA::GetFootBlood()
return 0;
}

bool CPedSA::IsBleeding()
{
return GetPedInterface()->pedFlags.bPedIsBleeding;
}

void CPedSA::SetBleeding(bool bBleeding)
{
GetPedInterface()->pedFlags.bPedIsBleeding = bBleeding;
}

bool CPedSA::IsOnFire()
{
if (GetPedInterface()->pFireOnPed != NULL)
Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
void SetFootBlood(unsigned int uiFootBlood);
unsigned int GetFootBlood();

bool IsBleeding();
void SetBleeding(bool bBleeding);

bool IsOnFire();
void SetOnFire(bool bOnFire);

Expand Down
10 changes: 10 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
m_fCurrentRotation = 0.0f;
m_fMoveSpeed = 0.0f;
m_bCanBeKnockedOffBike = true;
m_bBleeding = false;
RemoveAllWeapons(); // Set all our weapon values to unarmed
m_bHasJetPack = false;
m_FightingStyle = STYLE_GRAB_KICK;
Expand Down Expand Up @@ -5925,6 +5926,15 @@ bool CClientPed::IsFootBloodEnabled()
return false;
}

void CClientPed::SetBleeding(bool bBleeding)
{
if (m_pPlayerPed)
{
m_pPlayerPed->SetBleeding(bBleeding);
}
m_bBleeding = bBleeding;
}

bool CClientPed::IsOnFire()
{
if (m_pPlayerPed)
Expand Down
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule

bool IsFootBloodEnabled();
void SetFootBloodEnabled(bool bHasFootBlood);

bool IsBleeding() const { return m_bBleeding; };
void SetBleeding(bool bBleeding);

bool IsOnFire();
void SetOnFire(bool bOnFire);
Expand Down Expand Up @@ -658,6 +661,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
float m_fCurrentRotation;
float m_fMoveSpeed;
bool m_bCanBeKnockedOffBike;
bool m_bBleeding;
CMatrix m_Matrix;
CVector m_vecMoveSpeed;
CVector m_vecTurnSpeed;
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 @@ -72,6 +72,7 @@ void CLuaPedDefs::LoadFunctions()
{"isPedFootBloodEnabled", IsPedFootBloodEnabled},
{"getPedCameraRotation", GetPedCameraRotation},
{"getPedOxygenLevel", GetPedOxygenLevel},
{"isPedBleeding", ArgumentParser<IsPedBleeding>},

{"setPedWeaponSlot", SetPedWeaponSlot},
{"setPedRotation", SetPedRotation},
Expand Down Expand Up @@ -101,6 +102,7 @@ void CLuaPedDefs::LoadFunctions()
{"isPedReloadingWeapon", IsPedReloadingWeapon},
{"setPedEnterVehicle", ArgumentParser<SetPedEnterVehicle>},
{"setPedExitVehicle", ArgumentParser<SetPedExitVehicle>},
{"setPedBleeding", ArgumentParser<SetPedBleeding>},
};

// Add functions
Expand Down Expand Up @@ -165,6 +167,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getCameraRotation", "getPedCameraRotation");
lua_classfunction(luaVM, "getWeaponSlot", "getPedWeaponSlot");
lua_classfunction(luaVM, "getWalkingStyle", "getPedWalkingStyle");
lua_classfunction(luaVM, "isBleeding", "isPedBleeding");

lua_classfunction(luaVM, "setCanBeKnockedOffBike", "setPedCanBeKnockedOffBike");
lua_classfunction(luaVM, "setAnalogControlState", "setPedAnalogControlState");
Expand Down Expand Up @@ -192,6 +195,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon");
lua_classfunction(luaVM, "setEnterVehicle", "setPedEnterVehicle");
lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle");
lua_classfunction(luaVM, "setBleeding", "setPedBleeding");

lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat");
Expand All @@ -216,6 +220,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "dead", NULL, "isPedDead");
lua_classvariable(luaVM, "targetingMarker", "setPedTargetingMarkerEnabled", "isPedTargetingMarkerEnabled");
lua_classvariable(luaVM, "footBlood", "setPedFootBloodEnabled", NULL);
lua_classvariable(luaVM, "bleeding", "setPedBleeding", "isPedBleeding");
lua_classvariable(luaVM, "targetCollision", nullptr, OOP_GetPedTargetCollision);
lua_classvariable(luaVM, "targetEnd", nullptr, OOP_GetPedTargetEnd);
lua_classvariable(luaVM, "targetStart", nullptr, OOP_GetPedTargetStart);
Expand Down Expand Up @@ -1498,6 +1503,11 @@ int CLuaPedDefs::IsPedFootBloodEnabled(lua_State* luaVM)
return 1;
}

bool CLuaPedDefs::IsPedBleeding(CClientPed* pPed)
{
return pPed->IsBleeding();
}

int CLuaPedDefs::GetPedCameraRotation(lua_State* luaVM)
{
// Verify the argument
Expand Down Expand Up @@ -1959,6 +1969,12 @@ int CLuaPedDefs::SetPedFootBloodEnabled(lua_State* luaVM)
return 1;
}

bool CLuaPedDefs::SetPedBleeding(CClientPed* ped, bool bleeding)
{
ped->SetBleeding(bleeding);
return true;
}

int CLuaPedDefs::SetPedCameraRotation(lua_State* luaVM)
{
// bool setPedCameraRotation ( ped thePed, float cameraRotation )
Expand Down
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 @@ -111,4 +111,6 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(SetPedStat);
static bool SetPedEnterVehicle(CClientPed* pPed, std::optional<CClientVehicle*> pOptVehicle, std::optional<bool> bOptPassenger);
static bool SetPedExitVehicle(CClientPed* pPed);
static bool IsPedBleeding(CClientPed* ped);
static bool SetPedBleeding(CClientPed* ped, bool bleeding);
};
2 changes: 2 additions & 0 deletions Client/sdk/game/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class CPed : public virtual CPhysical
virtual void SetCantBeKnockedOffBike(int iCantBeKnockedOffBike) = 0;
virtual void QuitEnteringCar(CVehicle* vehicle, int iSeat, bool bUnknown) = 0;

virtual void SetBleeding(bool bBleeding) = 0;

virtual bool IsWearingGoggles() = 0;
virtual void SetGogglesState(bool bIsWearingThem) = 0;

Expand Down