Merge branch 'temp/speech-utilities' of https://github.com/Blixibon/source-sdk-2013 into develop

This commit is contained in:
Blixibon 2022-01-17 17:11:00 -06:00
commit abdd78e5e0
4 changed files with 118 additions and 0 deletions

View File

@ -1153,6 +1153,32 @@ void CAI_Expresser::ClearSpokeConcept( AIConcept_t concept )
m_ConceptHistories.Remove( concept ); m_ConceptHistories.Remove( concept );
} }
#ifdef MAPBASE
//-------------------------------------
AIConcept_t CAI_Expresser::GetLastSpokeConcept( AIConcept_t excludeConcept /* = NULL */ )
{
int iLastSpokenIndex = m_ConceptHistories.InvalidIndex();
float flLast = 0.0f;
for ( int i = m_ConceptHistories.First(); i != m_ConceptHistories.InvalidIndex(); i = m_ConceptHistories.Next(i ) )
{
ConceptHistory_t *h = &m_ConceptHistories[ i ];
// If an 'exclude concept' was provided, skip over this entry in the history if it matches the exclude concept
if ( excludeConcept != NULL && FStrEq( m_ConceptHistories.GetElementName( i ), excludeConcept ) )
continue;
if ( h->timeSpoken >= flLast )
{
iLastSpokenIndex = i;
flLast = h->timeSpoken;
}
}
return iLastSpokenIndex != m_ConceptHistories.InvalidIndex() ? m_ConceptHistories.GetElementName( iLastSpokenIndex ) : NULL;
}
#endif
//------------------------------------- //-------------------------------------
void CAI_Expresser::DumpHistories() void CAI_Expresser::DumpHistories()

View File

@ -187,6 +187,10 @@ public:
bool CanSpeakAfterMyself(); bool CanSpeakAfterMyself();
float GetTimeSpeechComplete() const { return m_flStopTalkTime; } float GetTimeSpeechComplete() const { return m_flStopTalkTime; }
void BlockSpeechUntil( float time ); void BlockSpeechUntil( float time );
#ifdef EZ2
float GetRealTimeSpeechComplete() const { return m_flStopTalkTimeWithoutDelay; }
#endif
// -------------------------------- // --------------------------------
@ -195,6 +199,10 @@ public:
float GetTimeSpokeConcept( AIConcept_t concept ); // returns -1 if never float GetTimeSpokeConcept( AIConcept_t concept ); // returns -1 if never
void SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback = true ); void SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback = true );
void ClearSpokeConcept( AIConcept_t concept ); void ClearSpokeConcept( AIConcept_t concept );
#ifdef MAPBASE
AIConcept_t GetLastSpokeConcept( AIConcept_t excludeConcept = NULL );
#endif
// -------------------------------- // --------------------------------

View File

@ -160,6 +160,7 @@ public:
#ifdef MAPBASE #ifdef MAPBASE
bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes, const char *pszNotThisScene = NULL ); bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes, const char *pszNotThisScene = NULL );
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList(); CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList();
#endif #endif
@ -486,6 +487,9 @@ public:
bool HasUnplayedSpeech( void ); bool HasUnplayedSpeech( void );
bool HasFlexAnimation( void ); bool HasFlexAnimation( void );
#ifdef MAPBASE
bool IsPlayingSpeech( void );
#endif
void SetCurrentTime( float t, bool forceClientSync ); void SetCurrentTime( float t, bool forceClientSync );
@ -1158,6 +1162,31 @@ bool CSceneEntity::HasFlexAnimation( void )
return false; return false;
} }
#ifdef MAPBASE
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CSceneEntity::IsPlayingSpeech( void )
{
if ( m_pScene )
{
float flTime = m_pScene->GetTime();
for ( int i = 0; i < m_pScene->GetNumEvents(); i++ )
{
CChoreoEvent *e = m_pScene->GetEvent( i );
if ( e->GetType() == CChoreoEvent::SPEAK )
{
if ( /*flTime >= e->GetStartTime() &&*/ flTime <= e->GetEndTime() )
return true;
}
}
}
return false;
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
@ -2612,6 +2641,30 @@ bool CSceneEntity::CheckActors()
return false; return false;
} }
} }
#ifdef MAPBASE
else if ( pTestActor->IsPlayer() )
{
// Blixibon - Player speech handling
CBasePlayer *pPlayer = static_cast<CBasePlayer*>(pTestActor);
bool bShouldWait = false;
if ( pPlayer->GetExpresser() && pPlayer->GetExpresser()->IsSpeaking() )
{
bShouldWait = true;
}
else if ( IsTalkingInAScriptedScene( pPlayer ) )
{
bShouldWait = true;
}
if ( bShouldWait )
{
// One of the actors for this scene is talking already.
// Try again next think.
m_bWaitingForActor = true;
return false;
}
}
#endif
} }
else if ( m_BusyActor == SCENE_BUSYACTOR_INTERRUPT || m_BusyActor == SCENE_BUSYACTOR_INTERRUPT_CANCEL ) else if ( m_BusyActor == SCENE_BUSYACTOR_INTERRUPT || m_BusyActor == SCENE_BUSYACTOR_INTERRUPT_CANCEL )
{ {
@ -6052,6 +6105,31 @@ bool CSceneManager::IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActo
} }
bool CSceneManager::IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes )
{
int c = m_ActiveScenes.Count();
for ( int i = 0; i < c; i++ )
{
CSceneEntity *pScene = m_ActiveScenes[ i ].Get();
if ( !pScene ||
!pScene->IsPlayingBack() ||
pScene->IsPaused() ||
( bIgnoreInstancedScenes && dynamic_cast<CInstancedSceneEntity *>(pScene) != NULL )
)
{
continue;
}
if ( pScene->InvolvesActor( pActor ) )
{
if ( pScene->IsPlayingSpeech() )
return true;
}
}
return false;
}
CUtlVector< CHandle< CSceneEntity > > *CSceneManager::GetActiveSceneList() CUtlVector< CHandle< CSceneEntity > > *CSceneManager::GetActiveSceneList()
{ {
return &m_ActiveScenes; return &m_ActiveScenes;
@ -6150,6 +6228,11 @@ bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnore
return GetSceneManager()->IsRunningScriptedSceneWithFlexAndNotPaused( pActor, bIgnoreInstancedScenes, pszNotThisScene ); return GetSceneManager()->IsRunningScriptedSceneWithFlexAndNotPaused( pActor, bIgnoreInstancedScenes, pszNotThisScene );
} }
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes )
{
return GetSceneManager()->IsTalkingInAScriptedScene( pActor, bIgnoreInstancedScenes );
}
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList() CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList()
{ {
return GetSceneManager()->GetActiveSceneList(); return GetSceneManager()->GetActiveSceneList();

View File

@ -43,6 +43,7 @@ bool IsRunningScriptedSceneWithSpeech( CBaseFlex *pActor, bool bIgnoreInstancedS
bool IsRunningScriptedSceneWithSpeechAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false ); bool IsRunningScriptedSceneWithSpeechAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
#ifdef MAPBASE #ifdef MAPBASE
bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false, const char *pszNotThisScene = NULL ); bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false, const char *pszNotThisScene = NULL );
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList(); CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList();
#endif #endif
float GetSceneDuration( char const *pszScene ); float GetSceneDuration( char const *pszScene );