Skip to content

Commit

Permalink
Added Extra Parameter To SetPedLookAt (Will Break Old Syntax)
Browse files Browse the repository at this point in the history
The change basically adds a param that determines how long it will take to turn the Ped's head in milliseconds.

New Format:
bool setPedLookAt ( ped thePed, float x, float y, float z [, int time = 3000, int duration = 1000, element target ] )
  • Loading branch information
fedorms committed Apr 26, 2010
1 parent 9f0153f commit ef96db6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -1738,13 +1738,13 @@ bool CStaticFunctionDefinitions::SetPedDoingGangDriveby ( CClientEntity & Entity
}


bool CStaticFunctionDefinitions::SetPedLookAt ( CClientEntity & Entity, CVector & vecPosition, int iTime, CClientEntity * pTarget )
bool CStaticFunctionDefinitions::SetPedLookAt ( CClientEntity & Entity, CVector & vecPosition, int iTime, int iBlend, CClientEntity * pTarget )
{
RUN_CHILDREN SetPedLookAt ( **iter, vecPosition, iTime, pTarget );
RUN_CHILDREN SetPedLookAt ( **iter, vecPosition, iTime, iBlend, pTarget );
if ( IS_PED ( &Entity ) )
{
CClientPed& Ped = static_cast < CClientPed& > ( Entity );
Ped.LookAt ( vecPosition, iTime, pTarget );
Ped.LookAt ( vecPosition, iTime, iBlend, pTarget );
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Expand Up @@ -142,7 +142,7 @@ class CStaticFunctionDefinitions
static bool RemovePedClothes ( CClientEntity& Entity, unsigned char ucType );
static bool SetPedControlState ( CClientEntity& Entity, const char* szControl, bool bState );
static bool SetPedDoingGangDriveby ( CClientEntity& Entity, bool bGangDriveby );
static bool SetPedLookAt ( CClientEntity& Entity, CVector & vecPosition, int iTime, CClientEntity * pTarget );
static bool SetPedLookAt ( CClientEntity& Entity, CVector & vecPosition, int iTime, int iBlend, CClientEntity * pTarget );
static bool SetPedHeadless ( CClientEntity& Entity, bool bHeadless );
static bool SetPedFrozen ( CClientEntity& Entity, bool bFrozen );
static bool SetPedCameraRotation ( CClientEntity& Entity, float fRotation );
Expand Down
4 changes: 2 additions & 2 deletions MTA10/mods/shared_logic/CClientPed.cpp
Expand Up @@ -4563,13 +4563,13 @@ void CClientPed::SetSunbathing ( bool bSunbathing, bool bStartStanding )
}


bool CClientPed::LookAt ( CVector vecOffset, int iTime, CClientEntity * pEntity )
bool CClientPed::LookAt ( CVector vecOffset, int iTime, int iBlend, CClientEntity * pEntity )
{
if ( m_pPlayerPed )
{
CEntity * pGameEntity = NULL;
if ( pEntity ) pGameEntity = pEntity->GetGameEntity ();
CTaskSimpleTriggerLookAt * pTask = g_pGame->GetTasks ()->CreateTaskSimpleTriggerLookAt ( pGameEntity, iTime, 0, vecOffset );
CTaskSimpleTriggerLookAt * pTask = g_pGame->GetTasks ()->CreateTaskSimpleTriggerLookAt ( pGameEntity, iTime, 0, vecOffset, false, 0.250000, iBlend );
if ( pTask )
{
pTask->SetAsSecondaryPedTask ( m_pPlayerPed, TASK_SECONDARY_PARTIAL_ANIM );
Expand Down
2 changes: 1 addition & 1 deletion MTA10/mods/shared_logic/CClientPed.h
Expand Up @@ -345,7 +345,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
bool IsSunbathing ( void );
void SetSunbathing ( bool bSunbathing, bool bStartStanding = true );

bool LookAt ( CVector vecOffset, int iTime = 1000, CClientEntity * pEntity = NULL );
bool LookAt ( CVector vecOffset, int iTime = 1000, int iBlend = 1000, CClientEntity * pEntity = NULL );
bool UseGun ( CVector vecTarget, CClientEntity * pEntity );

bool IsAttachToable ( void );
Expand Down
11 changes: 7 additions & 4 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp
Expand Up @@ -1271,20 +1271,23 @@ int CLuaFunctionDefs::SetPedLookAt ( lua_State* luaVM )
vecPosition.fY = static_cast < float > ( lua_tonumber ( luaVM, 3 ) );
vecPosition.fZ = static_cast < float > ( lua_tonumber ( luaVM, 4 ) );
int iTime = 3000;
CClientEntity * pTarget = NULL;
int iBlend = 1000;
CClientEntity * pTarget = NULL;

int iArgument5 = lua_type ( luaVM, 5 );
int iArgument6 = lua_type ( luaVM, 6 );
if ( iArgument5 == LUA_TNUMBER || iArgument5 == LUA_TSTRING )
{
iTime = static_cast < int > ( lua_tonumber ( luaVM, 5 ) );
iBlend = static_cast < int > ( lua_tonumber ( luaVM, 6 ) );

if ( lua_type ( luaVM, 6 ) == LUA_TLIGHTUSERDATA )
pTarget = lua_toelement ( luaVM, 6 );
if ( lua_type ( luaVM, 7 ) == LUA_TLIGHTUSERDATA )
pTarget = lua_toelement ( luaVM, 7 );
}

if ( pEntity )
{
if ( CStaticFunctionDefinitions::SetPedLookAt ( *pEntity, vecPosition, iTime, pTarget ) )
if ( CStaticFunctionDefinitions::SetPedLookAt ( *pEntity, vecPosition, iTime, iBlend, pTarget ) )
{
lua_pushboolean ( luaVM, true );
return 1;
Expand Down

0 comments on commit ef96db6

Please sign in to comment.