From 5378c517066d9b380e48a6b96a91dd98d42d64e1 Mon Sep 17 00:00:00 2001 From: Nikita Obreht Date: Fri, 13 Aug 2021 17:45:47 +0200 Subject: [PATCH] Add is/setPedBleeding --- Client/game_sa/CPedSA.cpp | 10 ++++++++++ Client/game_sa/CPedSA.h | 3 +++ Client/mods/deathmatch/logic/CClientPed.cpp | 10 ++++++++++ Client/mods/deathmatch/logic/CClientPed.h | 4 ++++ .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 16 ++++++++++++++++ .../mods/deathmatch/logic/luadefs/CLuaPedDefs.h | 2 ++ Client/sdk/game/CPed.h | 2 ++ 7 files changed, 47 insertions(+) diff --git a/Client/game_sa/CPedSA.cpp b/Client/game_sa/CPedSA.cpp index 5da8c9f947a..3e25ddf4686 100644 --- a/Client/game_sa/CPedSA.cpp +++ b/Client/game_sa/CPedSA.cpp @@ -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) diff --git a/Client/game_sa/CPedSA.h b/Client/game_sa/CPedSA.h index eed0f739ee6..aafcfc291c9 100644 --- a/Client/game_sa/CPedSA.h +++ b/Client/game_sa/CPedSA.h @@ -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); diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 369af597208..decc32243be 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -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; @@ -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) diff --git a/Client/mods/deathmatch/logic/CClientPed.h b/Client/mods/deathmatch/logic/CClientPed.h index ba1af9fe534..024fda627e6 100644 --- a/Client/mods/deathmatch/logic/CClientPed.h +++ b/Client/mods/deathmatch/logic/CClientPed.h @@ -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); @@ -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; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index dbecbd3f619..f02e78c3109 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -72,6 +72,7 @@ void CLuaPedDefs::LoadFunctions() {"isPedFootBloodEnabled", IsPedFootBloodEnabled}, {"getPedCameraRotation", GetPedCameraRotation}, {"getPedOxygenLevel", GetPedOxygenLevel}, + {"isPedBleeding", ArgumentParser}, {"setPedWeaponSlot", SetPedWeaponSlot}, {"setPedRotation", SetPedRotation}, @@ -101,6 +102,7 @@ void CLuaPedDefs::LoadFunctions() {"isPedReloadingWeapon", IsPedReloadingWeapon}, {"setPedEnterVehicle", ArgumentParser}, {"setPedExitVehicle", ArgumentParser}, + {"setPedBleeding", ArgumentParser}, }; // Add functions @@ -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"); @@ -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"); @@ -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); @@ -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 @@ -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 ) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 06d1ff0c0e7..522ffd8eb03 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -111,4 +111,6 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(SetPedStat); static bool SetPedEnterVehicle(CClientPed* pPed, std::optional pOptVehicle, std::optional bOptPassenger); static bool SetPedExitVehicle(CClientPed* pPed); + static bool IsPedBleeding(CClientPed* ped); + static bool SetPedBleeding(CClientPed* ped, bool bleeding); }; diff --git a/Client/sdk/game/CPed.h b/Client/sdk/game/CPed.h index a795895fd50..d5381feca37 100644 --- a/Client/sdk/game/CPed.h +++ b/Client/sdk/game/CPed.h @@ -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;