Skip to content
Merged
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
102 changes: 102 additions & 0 deletions sp/src/game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4042,6 +4042,92 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
}
break;

#ifdef MAPBASE // From Alien Swarm SDK
case AE_CL_STOP_PARTICLE_EFFECT:
{
char token[256];
char szParticleEffect[256];

// Get the particle effect name
const char *p = options;
p = nexttoken(token, p, ' ', sizeof(token));
if ( token )
{
Q_strncpy( szParticleEffect, token, sizeof(szParticleEffect) );
}

// Get the attachment point index
p = nexttoken(token, p, ' ', sizeof(token));
bool bStopInstantly = ( token && !Q_stricmp( token, "instantly" ) );

ParticleProp()->StopParticlesNamed( szParticleEffect, bStopInstantly );
}
break;

case AE_CL_ADD_PARTICLE_EFFECT_CP:
{
int iControlPoint = 1;
int iAttachment = -1;
int iAttachType = PATTACH_ABSORIGIN_FOLLOW;
int iEffectIndex = -1;
char token[256];
char szParticleEffect[256];

// Get the particle effect name
const char *p = options;
p = nexttoken(token, p, ' ', sizeof(token));
if ( token )
{
Q_strncpy( szParticleEffect, token, sizeof(szParticleEffect) );
}

// Get the control point number
p = nexttoken(token, p, ' ', sizeof(token));
if ( token )
{
iControlPoint = atoi( token );
}

// Get the attachment type
p = nexttoken(token, p, ' ', sizeof(token));
if ( token )
{
iAttachType = GetAttachTypeFromString( token );
if ( iAttachType == -1 )
{
Warning("Invalid attach type specified for particle effect anim event. Trying to spawn effect '%s' with attach type of '%s'\n", szParticleEffect, token );
return;
}
}

// Get the attachment point index
p = nexttoken(token, p, ' ', sizeof(token));
if ( token )
{
iAttachment = atoi(token);

// See if we can find any attachment points matching the name
if ( token[0] != '0' && iAttachment == 0 )
{
iAttachment = LookupAttachment( token );
if ( iAttachment == -1 )
{
Warning("Failed to find attachment point specified for particle effect anim event. Trying to spawn effect '%s' on attachment named '%s'\n", szParticleEffect, token );
return;
}
}
}
iEffectIndex = ParticleProp()->FindEffect( szParticleEffect );
if ( iEffectIndex == -1 )
{
Warning("Failed to find specified particle effect. Trying to add CP to '%s' on attachment named '%s'\n", szParticleEffect, token );
return;
}
ParticleProp()->AddControlPoint( iEffectIndex, iControlPoint, this, (ParticleAttachment_t)iAttachType, iAttachment );
}
break;
#endif

case AE_CL_PLAYSOUND:
{
CLocalPlayerFilter filter;
Expand Down Expand Up @@ -4291,6 +4377,22 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
}
break;

#ifdef MAPBASE
case AE_VSCRIPT_RUN:
{
if (!RunScript( options ))
Warning( "%s failed to run AE_VSCRIPT_RUN on client with \"%s\"\n", GetDebugName(), options );
}
break;

case AE_VSCRIPT_RUN_FILE:
{
if (!RunScriptFile( options ))
Warning( "%s failed to run AE_VSCRIPT_RUN_FILE on client with \"%s\"\n", GetDebugName(), options );
}
break;
#endif

default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions sp/src/game/server/ai_basenpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9526,6 +9526,12 @@ void CAI_BaseNPC::HandleAnimEvent( animevent_t *pEvent )
{
m_hCine->FireScriptEvent( atoi( pEvent->options ) );
}
#ifdef MAPBASE
else if ( GetHintNode() )
{
GetHintNode()->FireScriptEvent( atoi( pEvent->options ) );
}
#endif
else
{
// FIXME: look so see if it's playing a vcd and fire those instead
Expand Down
24 changes: 24 additions & 0 deletions sp/src/game/server/ai_hint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,17 @@ BEGIN_DATADESC( CAI_Hint )
DEFINE_OUTPUT( m_OnNPCStartedUsing, "OnNPCStartedUsing" ),
DEFINE_OUTPUT( m_OnNPCStoppedUsing, "OnNPCStoppedUsing" ),

#ifdef MAPBASE
DEFINE_OUTPUT( m_OnScriptEvent[0], "OnScriptEvent01" ),
DEFINE_OUTPUT( m_OnScriptEvent[1], "OnScriptEvent02" ),
DEFINE_OUTPUT( m_OnScriptEvent[2], "OnScriptEvent03" ),
DEFINE_OUTPUT( m_OnScriptEvent[3], "OnScriptEvent04" ),
DEFINE_OUTPUT( m_OnScriptEvent[4], "OnScriptEvent05" ),
DEFINE_OUTPUT( m_OnScriptEvent[5], "OnScriptEvent06" ),
DEFINE_OUTPUT( m_OnScriptEvent[6], "OnScriptEvent07" ),
DEFINE_OUTPUT( m_OnScriptEvent[7], "OnScriptEvent08" ),
#endif

END_DATADESC( );

#ifdef MAPBASE_VSCRIPT
Expand Down Expand Up @@ -1705,6 +1716,19 @@ void CAI_Hint::NPCStoppedUsing( CAI_BaseNPC *pNPC )
m_OnNPCStoppedUsing.Set( pNPC, pNPC, this );
}

#ifdef MAPBASE
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAI_Hint::FireScriptEvent( int nEvent )
{
if ( ( nEvent >= 1 ) && ( nEvent <= 8 ) )
{
m_OnScriptEvent[nEvent - 1].FireOutput( m_hHintOwner, this );
}
}
#endif


CON_COMMAND(ai_dump_hints, "")
{
Expand Down
7 changes: 7 additions & 0 deletions sp/src/game/server/ai_hint.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ class CAI_Hint : public CServerOnlyEntity
void FixupTargetNode();
void NPCStartedUsing( CAI_BaseNPC *pNPC );
void NPCStoppedUsing( CAI_BaseNPC *pNPC );
#ifdef MAPBASE
void FireScriptEvent( int nEvent );
#endif

HintIgnoreFacing_t GetIgnoreFacing() const { return m_NodeData.fIgnoreFacing; }

Expand Down Expand Up @@ -385,6 +388,10 @@ class CAI_Hint : public CServerOnlyEntity
float m_nodeFOV;
Vector m_vecForward;

#ifdef MAPBASE
COutputEvent m_OnScriptEvent[8];
#endif

// The next hint in list of all hints
friend class CAI_HintManager;

Expand Down
14 changes: 13 additions & 1 deletion sp/src/game/server/baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent )
#ifdef MAPBASE
else if ( pEvent->event == AE_NPC_RESPONSE )
{
if (!MyNPCPointer()->GetExpresser()->IsSpeaking())
if (MyNPCPointer() && MyNPCPointer()->GetExpresser() && !MyNPCPointer()->GetExpresser()->IsSpeaking())
{
DispatchResponse( pEvent->options );
}
Expand All @@ -1344,6 +1344,18 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent )
DispatchResponse( pEvent->options );
return;
}
else if ( pEvent->event == AE_VSCRIPT_RUN )
{
if (!RunScript( pEvent->options ))
Warning( "%s failed to run AE_VSCRIPT_RUN on server with \"%s\"\n", GetDebugName(), pEvent->options );
return;
}
else if ( pEvent->event == AE_VSCRIPT_RUN_FILE )
{
if (!RunScriptFile( pEvent->options ))
Warning( "%s failed to run AE_VSCRIPT_RUN_FILE on server with \"%s\"\n", GetDebugName(), pEvent->options );
return;
}
#endif
else if ( pEvent->event == AE_RAGDOLL )
{
Expand Down
8 changes: 8 additions & 0 deletions sp/src/game/shared/eventlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ void EventList_RegisterSharedEvents( void )
REGISTER_SHARED_ANIMEVENT( AE_SV_DUSTTRAIL, AE_TYPE_SERVER );

REGISTER_SHARED_ANIMEVENT( AE_CL_CREATE_PARTICLE_EFFECT, AE_TYPE_CLIENT );
#ifdef MAPBASE // From Alien Swarm SDK
REGISTER_SHARED_ANIMEVENT( AE_CL_STOP_PARTICLE_EFFECT, AE_TYPE_CLIENT );
REGISTER_SHARED_ANIMEVENT( AE_CL_ADD_PARTICLE_EFFECT_CP, AE_TYPE_CLIENT );
//REGISTER_SHARED_ANIMEVENT( AE_CL_CREATE_PARTICLE_BRASS, AE_TYPE_CLIENT );
#endif

REGISTER_SHARED_ANIMEVENT( AE_RAGDOLL, AE_TYPE_SERVER );

Expand All @@ -252,5 +257,8 @@ void EventList_RegisterSharedEvents( void )
#ifdef MAPBASE
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE, AE_TYPE_SERVER );
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE_FORCED, AE_TYPE_SERVER );

REGISTER_SHARED_ANIMEVENT( AE_VSCRIPT_RUN, AE_TYPE_CLIENT | AE_TYPE_SERVER );
REGISTER_SHARED_ANIMEVENT( AE_VSCRIPT_RUN_FILE, AE_TYPE_CLIENT | AE_TYPE_SERVER );
#endif
}
8 changes: 8 additions & 0 deletions sp/src/game/shared/eventlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ typedef enum
AE_SV_DUSTTRAIL,

AE_CL_CREATE_PARTICLE_EFFECT,
#ifdef MAPBASE // From Alien Swarm SDK
AE_CL_STOP_PARTICLE_EFFECT,
AE_CL_ADD_PARTICLE_EFFECT_CP,
//AE_CL_CREATE_PARTICLE_BRASS,
#endif

AE_RAGDOLL,

Expand All @@ -88,6 +93,9 @@ typedef enum
#ifdef MAPBASE
AE_NPC_RESPONSE, // Play a response system concept if we're not speaking
AE_NPC_RESPONSE_FORCED, // Always play a response system concept

AE_VSCRIPT_RUN, // Run vscript code (server + client)
AE_VSCRIPT_RUN_FILE, // Run vscript file (server + client)
#endif

LAST_SHARED_ANIMEVENT,
Expand Down