1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 03:56:10 +08:00

Sync with latest source-sdk-2013.

This commit is contained in:
Nicholas Hastings
2014-10-30 12:30:57 -04:00
parent 6abc7fddca
commit aa5841f220
407 changed files with 6784 additions and 10498 deletions

View File

@ -2163,11 +2163,6 @@ void CSceneEntity::InputTriggerEvent( inputdata_t &inputdata )
}
}
struct NPCInterjection
{
AI_Response *response;
CAI_BaseActor *npc;
};
//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
@ -2176,93 +2171,62 @@ void CSceneEntity::InputInterjectResponse( inputdata_t &inputdata )
{
// Not currently playing a scene
if ( !m_pScene )
{
return;
}
CUtlVector< CAI_BaseActor * > candidates;
int i;
for ( i = 0 ; i < m_pScene->GetNumActors(); i++ )
CUtlVector<CAI_BaseActor *> candidates;
for ( int i = 0 ; i < m_pScene->GetNumActors(); i++ )
{
CBaseFlex *pTestActor = FindNamedActor( i );
if ( !pTestActor )
continue;
CAI_BaseActor *pBaseActor = dynamic_cast<CAI_BaseActor*>(pTestActor);
if ( !pBaseActor )
continue;
if ( !pBaseActor->IsAlive() )
CAI_BaseActor *pBaseActor = dynamic_cast<CAI_BaseActor *>(pTestActor);
if ( !pBaseActor || !pBaseActor->IsAlive() )
continue;
candidates.AddToTail( pBaseActor );
}
int c = candidates.Count();
if ( !c )
{
return;
}
int useIndex = 0;
if ( !m_bIsPlayingBack )
{
// Use any actor if not playing a scene
useIndex = RandomInt( 0, c - 1 );
// int useIndex = RandomInt( 0, c - 1 );
Assert( !"m_bIsPlayBack is false and this code does nothing. Should it?");
}
else
{
CUtlVector< NPCInterjection > validResponses;
CUtlString modifiers("scene:");
modifiers += STRING( GetEntityName() );
char modifiers[ 512 ];
Q_snprintf( modifiers, sizeof( modifiers ), "scene:%s", STRING( GetEntityName() ) );
for ( int i = 0; i < c; i++ )
while (candidates.Count() > 0)
{
CAI_BaseActor *npc = candidates[ i ];
Assert( npc );
// Pick a random slot in the candidates array.
int slot = RandomInt( 0, candidates.Count() - 1 );
AI_Response *response = npc->SpeakFindResponse( inputdata.value.String(), modifiers );
if ( !response )
continue;
CAI_BaseActor *npc = candidates[ slot ];
float duration = npc->GetResponseDuration( response );
// Couldn't look it up
if ( duration <= 0.0f )
continue;
if ( !npc->PermitResponse( duration ) )
// Try to find the response for this slot.
AI_Response response;
bool result = npc->SpeakFindResponse( response, inputdata.value.String(), modifiers.Get() );
if ( result )
{
delete response;
continue;
}
float duration = npc->GetResponseDuration( response );
//
NPCInterjection inter;
inter.response = response;
inter.npc = npc;
validResponses.AddToTail( inter );
}
int rcount = validResponses.Count();
if ( rcount >= 1 )
{
int slot = RandomInt( 0, rcount - 1 );
for ( int i = 0; i < rcount; i++ )
{
NPCInterjection *pInterjection = &validResponses[ i ];
if ( i == slot )
if ( ( duration > 0.0f ) && npc->PermitResponse( duration ) )
{
pInterjection->npc->SpeakDispatchResponse( inputdata.value.String(), pInterjection->response );
}
else
{
delete pInterjection->response;
// If we could look it up, dispatch it and bail.
npc->SpeakDispatchResponse( inputdata.value.String(), response );
return;
}
}
// Remove this entry and look for another one.
candidates.FastRemove(slot);
}
}
}
@ -2783,12 +2747,12 @@ void CSceneEntity::QueueResumePlayback( void )
CAI_BaseActor *pBaseActor = dynamic_cast<CAI_BaseActor*>(pActor);
if ( pBaseActor )
{
AI_Response *result = pBaseActor->SpeakFindResponse( STRING(m_iszResumeSceneFile), NULL );
AI_Response response;
bool result = pBaseActor->SpeakFindResponse( response, STRING(m_iszResumeSceneFile), NULL );
if ( result )
{
char response[ 256 ];
result->GetResponse( response, sizeof( response ) );
bStartedScene = InstancedScriptedScene( NULL, response, &m_hWaitingForThisResumeScene, 0, false ) != 0;
const char *szResponse = response.GetResponsePtr();
bStartedScene = InstancedScriptedScene( NULL, szResponse, &m_hWaitingForThisResumeScene, 0, false ) != 0;
}
}
}