aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/ai_playerally.cpp
diff options
context:
space:
mode:
authorMichael Sartain <[email protected]>2014-10-02 08:25:55 -0700
committerMichael Sartain <[email protected]>2014-10-02 08:25:55 -0700
commit55ed12f8d1eb6887d348be03aee5573d44177ffb (patch)
tree3686f7ca78c780cd9a3d367b79a9d9250c1be7c0 /mp/src/game/server/ai_playerally.cpp
parent* Added support for Visual C++ 2013 Express to VPC (diff)
downloadsource-sdk-2013-55ed12f8d1eb6887d348be03aee5573d44177ffb.tar.xz
source-sdk-2013-55ed12f8d1eb6887d348be03aee5573d44177ffb.zip
Updated the SDK with the latest code from the TF and HL2 branches.
Diffstat (limited to 'mp/src/game/server/ai_playerally.cpp')
-rw-r--r--mp/src/game/server/ai_playerally.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/mp/src/game/server/ai_playerally.cpp b/mp/src/game/server/ai_playerally.cpp
index 1f371fc9..1ce4da31 100644
--- a/mp/src/game/server/ai_playerally.cpp
+++ b/mp/src/game/server/ai_playerally.cpp
@@ -548,10 +548,11 @@ void CAI_PlayerAlly::PrescheduleThink( void )
if ( m_flNextIdleSpeechTime && m_flNextIdleSpeechTime < gpGlobals->curtime )
{
AISpeechSelection_t selection;
+
if ( SelectNonCombatSpeech( &selection ) )
{
SetSpeechTarget( selection.hSpeechTarget );
- SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
+ SpeakDispatchResponse( selection.concept.c_str(), selection.Response );
m_flNextIdleSpeechTime = gpGlobals->curtime + RandomFloat( 20,30 );
}
else
@@ -593,22 +594,23 @@ bool CAI_PlayerAlly::SelectSpeechResponse( AIConcept_t concept, const char *pszM
{
if ( IsAllowedToSpeak( concept ) )
{
- AI_Response *pResponse = SpeakFindResponse( concept, pszModifiers );
- if ( pResponse )
+ bool result = SpeakFindResponse( pSelection->Response, concept, pszModifiers );
+ if ( result )
{
- pSelection->Set( concept, pResponse, pTarget );
+ pSelection->concept = concept;
+ pSelection->hSpeechTarget = pTarget;
return true;
}
}
+
return false;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void CAI_PlayerAlly::SetPendingSpeech( AIConcept_t concept, AI_Response *pResponse )
+void CAI_PlayerAlly::SetPendingSpeech( AIConcept_t concept, AI_Response &Response )
{
- m_PendingResponse = *pResponse;
- pResponse->Release();
+ m_PendingResponse = Response;
m_PendingConcept = concept;
m_TimePendingSet = gpGlobals->curtime;
}
@@ -690,7 +692,7 @@ bool CAI_PlayerAlly::SelectInterjection()
if ( SelectIdleSpeech( &selection ) )
{
SetSpeechTarget( selection.hSpeechTarget );
- SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
+ SpeakDispatchResponse( selection.concept.c_str(), selection.Response );
return true;
}
}
@@ -889,9 +891,8 @@ void CAI_PlayerAlly::AnswerQuestion( CAI_PlayerAlly *pQuestioner, int iQARandomN
}
}
- Assert( selection.pResponse );
SetSpeechTarget( selection.hSpeechTarget );
- SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
+ SpeakDispatchResponse( selection.concept.c_str(), selection.Response );
// Prevent idle speech for a while
DeferAllIdleSpeech( random->RandomFloat( TALKER_DEFER_IDLE_SPEAK_MIN, TALKER_DEFER_IDLE_SPEAK_MAX ), GetSpeechTarget()->MyNPCPointer() );
@@ -939,11 +940,11 @@ int CAI_PlayerAlly::SelectNonCombatSpeechSchedule()
if ( !HasPendingSpeech() )
{
AISpeechSelection_t selection;
+
if ( SelectNonCombatSpeech( &selection ) )
{
- Assert( selection.pResponse );
SetSpeechTarget( selection.hSpeechTarget );
- SetPendingSpeech( selection.concept.c_str(), selection.pResponse );
+ SetPendingSpeech( selection.concept.c_str(), selection.Response );
}
}
@@ -1018,14 +1019,14 @@ void CAI_PlayerAlly::StartTask( const Task_t *pTask )
case TASK_TALKER_SPEAK_PENDING:
if ( !m_PendingConcept.empty() )
{
- AI_Response *pResponse = new AI_Response;
- *pResponse = m_PendingResponse;
- SpeakDispatchResponse( m_PendingConcept.c_str(), pResponse );
+ SpeakDispatchResponse( m_PendingConcept.c_str(), m_PendingResponse );
m_PendingConcept.erase();
TaskComplete();
}
else
+ {
TaskFail( FAIL_NO_SOUND );
+ }
break;
default:
@@ -1692,15 +1693,15 @@ bool CAI_PlayerAlly::RespondedTo( const char *ResponseConcept, bool bForce, bool
{
// We're being forced to respond to the event, probably because it's the
// player dying or something equally important.
- AI_Response *result = SpeakFindResponse( ResponseConcept, NULL );
+ AI_Response response;
+ bool result = SpeakFindResponse( response, ResponseConcept, NULL );
if ( result )
{
// We've got something to say. Stop any scenes we're in, and speak the response.
if ( bCancelScene )
RemoveActorFromScriptedScenes( this, false );
- bool spoke = SpeakDispatchResponse( ResponseConcept, result );
- return spoke;
+ return SpeakDispatchResponse( ResponseConcept, response );
}
return false;