Skip to content

Commit

Permalink
Added 4237: (SetPedFootBlood Patch) from lucasc190
Browse files Browse the repository at this point in the history
bool setPedFootBlood(ped thePed, int amount)
int getPedFootBlood(ped thePed)
  • Loading branch information
Flobu committed Apr 27, 2010
1 parent 3a79f48 commit 4b606d0
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 0 deletions.
31 changes: 31 additions & 0 deletions MTA10/game_sa/CPedSA.cpp
Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions MTA10/game_sa/CPedSA.h
Expand Up @@ -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 );

Expand Down
20 changes: 20 additions & 0 deletions MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down
20 changes: 20 additions & 0 deletions MTA10/mods/shared_logic/CClientPed.cpp
Expand Up @@ -611,6 +611,7 @@ void CClientPed::Spawn ( const CVector& vecPosition,
SetHasJetPack ( false );
SetMoveSpeed ( CVector () );
SetInterior ( ucInterior );
SetFootBlood ( 0 );
}

void CClientPed::ResetInterpolation ( void )
Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions MTA10/mods/shared_logic/CClientPed.h
Expand Up @@ -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 );

Expand Down
53 changes: 53 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp
Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h
Expand Up @@ -211,6 +211,7 @@ class CLuaFunctionDefs
LUA_DECLARE ( GetPedMoveAnim );
LUA_DECLARE ( IsPedHeadless );
LUA_DECLARE ( IsPedFrozen );
LUA_DECLARE ( GetPedFootBlood );
LUA_DECLARE ( GetPedCameraRotation );
LUA_DECLARE ( IsPedOnFire );

Expand All @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions MTA10/mods/shared_logic/lua/CLuaManager.cpp
Expand Up @@ -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 );
Expand All @@ -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 );

Expand Down
3 changes: 3 additions & 0 deletions MTA10/sdk/game/CPed.h
Expand Up @@ -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;

Expand Down

0 comments on commit 4b606d0

Please sign in to comment.