mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-27 06:07:56 +03:00
Added misc. speech/choreo utilities
This commit is contained in:
parent
264ee2b04f
commit
f448be8c2b
@ -1153,6 +1153,32 @@ void CAI_Expresser::ClearSpokeConcept( AIConcept_t 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()
|
||||
|
@ -192,6 +192,10 @@ public:
|
||||
float GetTimeSpokeConcept( AIConcept_t concept ); // returns -1 if never
|
||||
void SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback = true );
|
||||
void ClearSpokeConcept( AIConcept_t concept );
|
||||
|
||||
#ifdef MAPBASE
|
||||
AIConcept_t GetLastSpokeConcept( AIConcept_t excludeConcept = NULL );
|
||||
#endif
|
||||
|
||||
// --------------------------------
|
||||
|
||||
|
@ -159,6 +159,7 @@ public:
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes, const char *pszNotThisScene = NULL );
|
||||
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
|
||||
|
||||
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList();
|
||||
#endif
|
||||
@ -485,6 +486,9 @@ public:
|
||||
|
||||
bool HasUnplayedSpeech( void );
|
||||
bool HasFlexAnimation( void );
|
||||
#ifdef MAPBASE
|
||||
bool IsPlayingSpeech( void );
|
||||
#endif
|
||||
|
||||
void SetCurrentTime( float t, bool forceClientSync );
|
||||
|
||||
@ -1157,6 +1161,31 @@ bool CSceneEntity::HasFlexAnimation( void )
|
||||
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:
|
||||
@ -2576,6 +2605,30 @@ bool CSceneEntity::CheckActors()
|
||||
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 )
|
||||
{
|
||||
@ -5937,6 +5990,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()
|
||||
{
|
||||
return &m_ActiveScenes;
|
||||
@ -6035,6 +6113,11 @@ bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnore
|
||||
return GetSceneManager()->IsRunningScriptedSceneWithFlexAndNotPaused( pActor, bIgnoreInstancedScenes, pszNotThisScene );
|
||||
}
|
||||
|
||||
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes )
|
||||
{
|
||||
return GetSceneManager()->IsTalkingInAScriptedScene( pActor, bIgnoreInstancedScenes );
|
||||
}
|
||||
|
||||
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList()
|
||||
{
|
||||
return GetSceneManager()->GetActiveSceneList();
|
||||
|
@ -41,6 +41,7 @@ bool IsRunningScriptedSceneWithSpeech( CBaseFlex *pActor, bool bIgnoreInstancedS
|
||||
bool IsRunningScriptedSceneWithSpeechAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
|
||||
#ifdef MAPBASE
|
||||
bool IsRunningScriptedSceneWithFlexAndNotPaused( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false, const char *pszNotThisScene = NULL );
|
||||
bool IsTalkingInAScriptedScene( CBaseFlex *pActor, bool bIgnoreInstancedScenes = false );
|
||||
CUtlVector< CHandle< CSceneEntity > > *GetActiveSceneList();
|
||||
#endif
|
||||
float GetSceneDuration( char const *pszScene );
|
||||
|
Loading…
x
Reference in New Issue
Block a user