Add new VScript and particle anim events

This commit is contained in:
ALLEN-PC\acj30 2024-01-03 12:47:29 -06:00
parent e34e0d3b10
commit e44f60e8d8
4 changed files with 131 additions and 1 deletions

View File

@ -4042,6 +4042,92 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
} }
break; 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: case AE_CL_PLAYSOUND:
{ {
CLocalPlayerFilter filter; CLocalPlayerFilter filter;
@ -4291,6 +4377,22 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
} }
break; 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: default:
break; break;
} }

View File

@ -1333,7 +1333,7 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent )
#ifdef MAPBASE #ifdef MAPBASE
else if ( pEvent->event == AE_NPC_RESPONSE ) else if ( pEvent->event == AE_NPC_RESPONSE )
{ {
if (!MyNPCPointer()->GetExpresser()->IsSpeaking()) if (MyNPCPointer() && MyNPCPointer()->GetExpresser() && !MyNPCPointer()->GetExpresser()->IsSpeaking())
{ {
DispatchResponse( pEvent->options ); DispatchResponse( pEvent->options );
} }
@ -1344,6 +1344,18 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent )
DispatchResponse( pEvent->options ); DispatchResponse( pEvent->options );
return; 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 #endif
else if ( pEvent->event == AE_RAGDOLL ) else if ( pEvent->event == AE_RAGDOLL )
{ {

View File

@ -233,6 +233,11 @@ void EventList_RegisterSharedEvents( void )
REGISTER_SHARED_ANIMEVENT( AE_SV_DUSTTRAIL, AE_TYPE_SERVER ); REGISTER_SHARED_ANIMEVENT( AE_SV_DUSTTRAIL, AE_TYPE_SERVER );
REGISTER_SHARED_ANIMEVENT( AE_CL_CREATE_PARTICLE_EFFECT, AE_TYPE_CLIENT ); 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 ); REGISTER_SHARED_ANIMEVENT( AE_RAGDOLL, AE_TYPE_SERVER );
@ -252,5 +257,8 @@ void EventList_RegisterSharedEvents( void )
#ifdef MAPBASE #ifdef MAPBASE
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE, AE_TYPE_SERVER ); REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE, AE_TYPE_SERVER );
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESPONSE_FORCED, 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 #endif
} }

View File

@ -69,6 +69,11 @@ typedef enum
AE_SV_DUSTTRAIL, AE_SV_DUSTTRAIL,
AE_CL_CREATE_PARTICLE_EFFECT, 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, AE_RAGDOLL,
@ -88,6 +93,9 @@ typedef enum
#ifdef MAPBASE #ifdef MAPBASE
AE_NPC_RESPONSE, // Play a response system concept if we're not speaking AE_NPC_RESPONSE, // Play a response system concept if we're not speaking
AE_NPC_RESPONSE_FORCED, // Always play a response system concept 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 #endif
LAST_SHARED_ANIMEVENT, LAST_SHARED_ANIMEVENT,