Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/game/server/swarm/asw_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ bool CASW_Player::ClientCommand( const CCommand &args )
int iValue = V_atoi( args[4] );

CRD_VGui_VScript *pEnt = dynamic_cast< CRD_VGui_VScript * >( CBaseEntity::Instance( iEntity ) );
if ( !pEnt || pEnt->m_iRandomCheck != iCheck || !pEnt->m_hInteracter || GetNPC() != pEnt->m_hInteracter )
if ( !pEnt || pEnt->m_iRandomCheck != iCheck || ( !pEnt->m_bAnyoneCanInteract && ( !pEnt->m_hInteracter || GetNPC() != pEnt->m_hInteracter ) ) )
{
Warning( "Player %s sent a bad cl_vgui_vscript_input command\n", GetASWNetworkID() );
return false;
Expand Down
12 changes: 12 additions & 0 deletions src/game/shared/swarm/rd_vgui_vscript_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ BEGIN_NETWORK_TABLE( CRD_VGui_VScript, DT_RD_VGui_VScript )
RecvPropInt( RECVINFO( m_iRandomCheck ) ),
RecvPropEHandle( RECVINFO( m_hInteracter ) ),
RecvPropInt( RECVINFO( m_iSequenceAck ) ),
RecvPropBool( RECVINFO( m_bAnyoneCanInteract ) ),
#else
SendPropInt( SENDINFO( m_iRandomCheck ) ),
SendPropEHandle( SENDINFO( m_hInteracter ) ),
SendPropInt( SENDINFO( m_iSequenceAck ) ),
SendPropBool( SENDINFO( m_bAnyoneCanInteract ) ),
#endif
END_NETWORK_TABLE();

Expand All @@ -68,6 +70,7 @@ BEGIN_ENT_SCRIPTDESC( CRD_VGui_VScript, CRD_HUD_VScript, "Alien Swarm: Reactive
DEFINE_SCRIPTFUNC( CreateButton, "Creates a button that can be targeted by both the mouse and the controller." )
#else
DEFINE_SCRIPTFUNC( SetInteracter, "Sets the character who is allowed to interact with this screen." )
DEFINE_SCRIPTFUNC( SetAnyoneCanInteract, "If set to true, Control function runs for spectators and they can send inputs." )
#endif
DEFINE_SCRIPTFUNC( GetInteracter, "Gets the character who is allowed to interact with this screen." )
END_SCRIPTDESC();
Expand Down Expand Up @@ -204,6 +207,7 @@ CRD_VGui_VScript::CRD_VGui_VScript()
{
m_hInteracter = NULL;
m_iSequenceAck = 0;
m_bAnyoneCanInteract = false;

#ifdef CLIENT_DLL
s_InteractiveHUDEntities.AddToTail( this );
Expand Down Expand Up @@ -495,6 +499,9 @@ void CRD_VGui_VScript::ResetPrediction()

bool CRD_VGui_VScript::AllowedToInteract()
{
if ( m_bAnyoneCanInteract )
return true;

ASSERT_LOCAL_PLAYER_RESOLVABLE();

C_BaseEntity *pOwner = GetPredictionOwner();
Expand Down Expand Up @@ -676,6 +683,11 @@ void CRD_VGui_VScript::SetInteracter( HSCRIPT interacter )
m_hInteracter = assert_cast< CASW_Inhabitable_NPC * >( pInteracter );
}

void CRD_VGui_VScript::SetAnyoneCanInteract( bool bAnyone )
{
m_bAnyoneCanInteract = bAnyone;
}

void CRD_VGui_VScript::RunVScripts()
{
BaseClass::RunVScripts();
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/swarm/rd_vgui_vscript_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CRD_VGui_VScript : public CRD_HUD_VScript
virtual void OnInput( int sequence, int value );
void SetInteracter( HSCRIPT interacter );
virtual bool AllowSetInteracter() { return true; }
void SetAnyoneCanInteract( bool bEveryone );

void RunVScripts() override;
#endif
Expand All @@ -89,6 +90,7 @@ class CRD_VGui_VScript : public CRD_HUD_VScript
CNetworkVar( int, m_iRandomCheck );
CNetworkHandle( CASW_Inhabitable_NPC, m_hInteracter );
CNetworkVar( int, m_iSequenceAck );
CNetworkVar( bool, m_bAnyoneCanInteract );

bool m_bIsInput{ false };

Expand Down