diff --git a/MTA10/game_sa/CPedSA.cpp b/MTA10/game_sa/CPedSA.cpp index 8065085df9..352f93bd97 100644 --- a/MTA10/game_sa/CPedSA.cpp +++ b/MTA10/game_sa/CPedSA.cpp @@ -817,6 +817,37 @@ void CPedSA::RemoveBodyPart ( int i, char c ) } } +void CPedSA::SetFootBlood ( unsigned int uiFootBlood ) +{ + DWORD dwThis = (DWORD)this->GetInterface(); + // Check if the ped is to have foot blood + if (uiFootBlood > 0) + { + // Make sure the foot blood flag is activated + *(unsigned short*)(dwThis + 0x46F) |= 16; + } + else if (*(unsigned short*)(dwThis + 0x46F) & 16) + { + // If the foot blood flag is activated, deactivate it + *(unsigned short*)(dwThis + 0x46F) -= 16; + } + // Set the amount of foot blood + *(unsigned int*)(dwThis + 0x750) = uiFootBlood; +} + +unsigned int CPedSA::GetFootBlood ( void ) +{ + DWORD dwThis = (DWORD)this->GetInterface(); + // Check if the ped has the foot blood flag + if (*(unsigned short*)(dwThis + 0x46F) & 16) + { + // If the foot blood flag is activated, return the amount of foot blood + return *(unsigned int*)(dwThis + 0x750); + } + // Otherwise, return zero as there is no foot blood + return 0; +} + bool CPedSA::IsOnFire ( void ) { if ( GetPedInterface()->pFireOnPed != NULL ) diff --git a/MTA10/game_sa/CPedSA.h b/MTA10/game_sa/CPedSA.h index 1fda32c7b7..390f9659b9 100644 --- a/MTA10/game_sa/CPedSA.h +++ b/MTA10/game_sa/CPedSA.h @@ -410,6 +410,9 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA void RemoveBodyPart ( int i, char c ); + void SetFootBlood ( unsigned int uiFootBlood ); + unsigned int GetFootBlood ( void ); + bool IsOnFire ( void ); void SetOnFire ( bool bOnFire ); diff --git a/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 8c888a20e8..b511b95c9a 100644 --- a/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1315,6 +1315,13 @@ bool CStaticFunctionDefinitions::IsPedFrozen ( CClientPed & Ped, bool & bFrozen } +bool CStaticFunctionDefinitions::GetPedFootBlood ( CClientPed & Ped, unsigned int & uiFootBlood ) +{ + uiFootBlood = Ped.GetFootBlood (); + return true; +} + + bool CStaticFunctionDefinitions::GetPedCameraRotation ( CClientPed & Ped, float & fRotation ) { fRotation = ConvertRadiansToDegrees ( Ped.GetCameraRotation() ); @@ -1778,6 +1785,19 @@ bool CStaticFunctionDefinitions::SetPedFrozen ( CClientEntity & Entity, bool bFr } +bool CStaticFunctionDefinitions::SetPedFootBlood ( CClientEntity & Entity, unsigned int uiFootBlood ) +{ + RUN_CHILDREN SetPedFootBlood ( **iter, uiFootBlood ); + if ( IS_PED ( &Entity ) ) + { + CClientPed& Ped = static_cast < CClientPed& > ( Entity ); + Ped.SetFootBlood ( uiFootBlood ); + return true; + } + return false; +} + + bool CStaticFunctionDefinitions::SetPedCameraRotation ( CClientEntity & Entity, float fRotation ) { RUN_CHILDREN SetPedCameraRotation ( **iter, fRotation ); diff --git a/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h index 0fe07778fd..a79e3e1eba 100644 --- a/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -128,6 +128,7 @@ class CStaticFunctionDefinitions static bool GetPedMoveAnim ( CClientPed& Ped, unsigned int& iMoveAnim ); static bool IsPedHeadless ( CClientPed& Ped, bool & bHeadless ); static bool IsPedFrozen ( CClientPed& Ped, bool & bFrozen ); + static bool GetPedFootBlood ( CClientPed& Ped, unsigned int & uiFootBlood ); static bool GetPedCameraRotation ( CClientPed& Ped, float & fRotation ); static bool GetPedWeaponMuzzlePosition ( CClientPed& Ped, CVector& vecPosition ); static bool IsPedOnFire ( CClientPed& Ped, bool & bOnFire ); @@ -145,6 +146,7 @@ class CStaticFunctionDefinitions static bool SetPedLookAt ( CClientEntity& Entity, CVector & vecPosition, int iTime, CClientEntity * pTarget ); static bool SetPedHeadless ( CClientEntity& Entity, bool bHeadless ); static bool SetPedFrozen ( CClientEntity& Entity, bool bFrozen ); + static bool SetPedFootBlood ( CClientEntity& Entity, unsigned int uiFootBlood ); static bool SetPedCameraRotation ( CClientEntity& Entity, float fRotation ); static bool SetPedAimTarget ( CClientEntity& Entity, CVector & vecTarget ); static bool SetPedOnFire ( CClientEntity& Entity, bool bOnFire ); diff --git a/MTA10/mods/shared_logic/CClientPed.cpp b/MTA10/mods/shared_logic/CClientPed.cpp index 872b911928..6870171c46 100644 --- a/MTA10/mods/shared_logic/CClientPed.cpp +++ b/MTA10/mods/shared_logic/CClientPed.cpp @@ -611,6 +611,7 @@ void CClientPed::Spawn ( const CVector& vecPosition, SetHasJetPack ( false ); SetMoveSpeed ( CVector () ); SetInterior ( ucInterior ); + SetFootBlood ( 0 ); } void CClientPed::ResetInterpolation ( void ) @@ -4782,6 +4783,25 @@ void CClientPed::SetHeadless ( bool bHeadless ) m_bHeadless = bHeadless; } + +void CClientPed::SetFootBlood ( unsigned int uiFootBlood ) +{ + if ( m_pPlayerPed ) + { + m_pPlayerPed->SetFootBlood(uiFootBlood); + } +} + +unsigned int CClientPed::GetFootBlood ( void ) +{ + if ( m_pPlayerPed ) + { + return m_pPlayerPed->GetFootBlood(); + } + return 0; +} + + void CClientPed::SetOnFire ( bool bIsOnFire ) { if ( m_pPlayerPed ) diff --git a/MTA10/mods/shared_logic/CClientPed.h b/MTA10/mods/shared_logic/CClientPed.h index 6316571f97..aac7ce16be 100644 --- a/MTA10/mods/shared_logic/CClientPed.h +++ b/MTA10/mods/shared_logic/CClientPed.h @@ -369,6 +369,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule inline bool IsFrozen ( void ) const { return m_bFrozen; } void SetFrozen ( bool bFrozen ); + void SetFootBlood ( unsigned int uiFootBlood ); + unsigned int GetFootBlood ( void ); + inline bool IsOnFire ( void ) { return m_bIsOnFire; } void SetOnFire ( bool bOnFire ); diff --git a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp index aaabb72750..1a90338b00 100644 --- a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp +++ b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp @@ -1067,6 +1067,31 @@ int CLuaFunctionDefs::IsPedFrozen ( lua_State* luaVM ) } +int CLuaFunctionDefs::GetPedFootBlood ( lua_State* luaVM ) +{ + if ( ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA ) ) + { + CClientPed * pPed = lua_toped ( luaVM, 1 ); + if ( pPed ) + { + unsigned int uiFootBlood = 0; + if ( CStaticFunctionDefinitions::GetPedFootBlood ( *pPed, uiFootBlood ) ) + { + lua_pushnumber ( luaVM, uiFootBlood ); + return 1; + } + } + else + m_pScriptDebugging->LogBadPointer ( luaVM, "getPedFootBlood", "ped", 1 ); + } + else + m_pScriptDebugging->LogBadType ( luaVM, "getPedFootBlood" ); + + lua_pushboolean ( luaVM, false ); + return 1; +} + + int CLuaFunctionDefs::GetPedCameraRotation ( lua_State* luaVM ) { if ( ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA ) ) @@ -1352,6 +1377,34 @@ int CLuaFunctionDefs::SetPedFrozen ( lua_State* luaVM ) return 1; } + +int CLuaFunctionDefs::SetPedFootBlood ( lua_State* luaVM ) +{ + int iArgument2 = lua_type ( luaVM, 2 ); + if ( ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA ) && + ( iArgument2 == LUA_TNUMBER || iArgument2 == LUA_TSTRING ) ) + { + CClientEntity* pEntity = lua_toelement ( luaVM, 1 ); + unsigned int uiFootBlood = static_cast < unsigned int > ( lua_tonumber ( luaVM, 2 ) ); + if ( pEntity ) + { + if ( CStaticFunctionDefinitions::SetPedFootBlood ( *pEntity, uiFootBlood ) ) + { + lua_pushboolean ( luaVM, true ); + return 1; + } + } + else + m_pScriptDebugging->LogBadPointer ( luaVM, "setPedFootBlood", "ped", 1 ); + } + else + m_pScriptDebugging->LogBadType ( luaVM, "setPedFootBlood" ); + + lua_pushboolean ( luaVM, false ); + return 1; +} + + int CLuaFunctionDefs::SetPedCameraRotation ( lua_State* luaVM ) { int iArgument2 = lua_type ( luaVM, 2 ); diff --git a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h index 95c57b03b0..ea6425f5d2 100644 --- a/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h +++ b/MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h @@ -211,6 +211,7 @@ class CLuaFunctionDefs LUA_DECLARE ( GetPedMoveAnim ); LUA_DECLARE ( IsPedHeadless ); LUA_DECLARE ( IsPedFrozen ); + LUA_DECLARE ( GetPedFootBlood ); LUA_DECLARE ( GetPedCameraRotation ); LUA_DECLARE ( IsPedOnFire ); @@ -227,6 +228,7 @@ class CLuaFunctionDefs LUA_DECLARE ( SetPedLookAt ); LUA_DECLARE ( SetPedHeadless ); LUA_DECLARE ( SetPedFrozen ); + LUA_DECLARE ( SetPedFootBlood ); LUA_DECLARE ( SetPedCameraRotation ); LUA_DECLARE ( SetPedAimTarget ); LUA_DECLARE ( SetPedOnFire ); diff --git a/MTA10/mods/shared_logic/lua/CLuaManager.cpp b/MTA10/mods/shared_logic/lua/CLuaManager.cpp index b935b91427..bc1fdbc7ee 100644 --- a/MTA10/mods/shared_logic/lua/CLuaManager.cpp +++ b/MTA10/mods/shared_logic/lua/CLuaManager.cpp @@ -406,6 +406,7 @@ void CLuaManager::LoadCFunctions ( void ) //CLuaCFunctions::AddFunction ( "getPedWalkingStyle", CLuaFunctionDefs::GetPedMoveAnim ); CLuaCFunctions::AddFunction ( "isPedHeadless", CLuaFunctionDefs::IsPedHeadless ); CLuaCFunctions::AddFunction ( "isPedFrozen", CLuaFunctionDefs::IsPedFrozen ); + CLuaCFunctions::AddFunction ( "getPedFootBlood", CLuaFunctionDefs::GetPedFootBlood ); CLuaCFunctions::AddFunction ( "getPedCameraRotation", CLuaFunctionDefs::GetPedCameraRotation ); CLuaCFunctions::AddFunction ( "setPedWeaponSlot", CLuaFunctionDefs::SetPedWeaponSlot ); @@ -420,6 +421,7 @@ void CLuaManager::LoadCFunctions ( void ) CLuaCFunctions::AddFunction ( "setPedLookAt", CLuaFunctionDefs::SetPedLookAt ); CLuaCFunctions::AddFunction ( "setPedHeadless", CLuaFunctionDefs::SetPedHeadless ); CLuaCFunctions::AddFunction ( "setPedFrozen", CLuaFunctionDefs::SetPedFrozen ); + CLuaCFunctions::AddFunction ( "setPedFootBlood", CLuaFunctionDefs::SetPedFootBlood ); CLuaCFunctions::AddFunction ( "setPedCameraRotation", CLuaFunctionDefs::SetPedCameraRotation ); CLuaCFunctions::AddFunction ( "setPedAimTarget", CLuaFunctionDefs::SetPedAimTarget ); diff --git a/MTA10/sdk/game/CPed.h b/MTA10/sdk/game/CPed.h index e31404927f..d746e8c898 100644 --- a/MTA10/sdk/game/CPed.h +++ b/MTA10/sdk/game/CPed.h @@ -218,6 +218,9 @@ class CPed : public virtual CPhysical virtual void RemoveBodyPart ( int i, char c ) = 0; + virtual void SetFootBlood ( unsigned int uiFootBlood ) = 0; + virtual unsigned int GetFootBlood ( void ) = 0; + virtual bool IsOnFire ( void ) = 0; virtual void SetOnFire ( bool bOnFire ) = 0;