Skip to content

Commit

Permalink
Lua: Add player_onuse callback
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Mar 23, 2015
1 parent c692ca8 commit 80c8570
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions cl_dll/ff/c_ff_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class C_FFPlayer : public C_BasePlayer, public IFFPlayerAnimStateHelpers
virtual bool IsOverridingViewmodel( void ) { return IsCloaked(); };
virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags ) { return pViewmodel ? pViewmodel->DrawOverriddenViewmodel( flags ) : 0; }
virtual const QAngle& GetRenderAngles( void );
virtual void PlayerUse( void );

virtual RenderGroup_t GetRenderGroup();

Expand Down
1 change: 1 addition & 0 deletions dlls/ff/ff_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class CFFPlayer : public CBasePlayer, public IFFPlayerAnimStateHelpers
virtual void Event_Killed(const CTakeDamageInfo &info);
virtual bool Event_Gibbed(const CTakeDamageInfo &info);
virtual bool BecomeRagdollOnClient(const Vector &force);
virtual void PlayerUse( void );

virtual void LeaveVehicle( const Vector &vecExitPoint, const QAngle &vecExitAngles );
virtual void UpdateOnRemove( void );
Expand Down
19 changes: 19 additions & 0 deletions game_shared/ff/ff_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,25 @@ void CFFPlayer::PlayStepSound(Vector &vecOrigin, surfacedata_t *psurface, float
}
// <-- Mirv: Proper sounds

/** Allow Lua to react to and/or deny +use
*/
void CFFPlayer::PlayerUse()
{
#ifdef GAME_DLL
if (m_afButtonPressed & IN_USE)
{
CFFLuaSC hContext( 0 );
hContext.Push( this );
if( _scriptman.RunPredicates_LUA( NULL, &hContext, "player_onuse" ) && !hContext.DidReturnNil() && !hContext.GetBool() )
{
return;
}
}
#endif

BaseClass::PlayerUse();
}

//-----------------------------------------------------------------------------
// Purpose: Handle all class specific skills
//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 80c8570

Please sign in to comment.