mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-04 09:40:34 +03:00
commit
0f6fd0a5a4
@ -225,7 +225,7 @@ static CResponseQueue::CFollowupTargetSpec_t ResolveFollowupTargetToEntity( AICo
|
|||||||
|
|
||||||
ConVar chet_debug_idle( "chet_debug_idle", "0", FCVAR_ARCHIVE, "If set one, many debug prints to help track down the TLK_IDLE issue. Set two for super verbose info" );
|
ConVar chet_debug_idle( "chet_debug_idle", "0", FCVAR_ARCHIVE, "If set one, many debug prints to help track down the TLK_IDLE issue. Set two for super verbose info" );
|
||||||
// extern ConVar chet_debug_idle;
|
// extern ConVar chet_debug_idle;
|
||||||
bool CAI_ExpresserWithFollowup::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
|
bool CAI_ExpresserWithFollowup::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
|
||||||
{
|
{
|
||||||
VPROF("CAI_Expresser::Speak");
|
VPROF("CAI_Expresser::Speak");
|
||||||
if ( IsSpeechGloballySuppressed() )
|
if ( IsSpeechGloballySuppressed() )
|
||||||
@ -261,7 +261,7 @@ bool CAI_ExpresserWithFollowup::Speak( AIConcept_t &concept, const char *modifie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
|
SpeechMsg( GetOuter(), "%s (%p) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
|
||||||
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );
|
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );
|
||||||
|
|
||||||
bool spoke = SpeakDispatchResponse( concept, &result, &criteria, filter );
|
bool spoke = SpeakDispatchResponse( concept, &result, &criteria, filter );
|
||||||
@ -297,7 +297,7 @@ static float GetSpeechDurationForResponse( const AI_Response * RESTRICT response
|
|||||||
// Purpose: Dispatches the result
|
// Purpose: Dispatches the result
|
||||||
// Input : *response -
|
// Input : *response -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CAI_ExpresserWithFollowup::SpeakDispatchResponse( AIConcept_t &concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter )
|
bool CAI_ExpresserWithFollowup::SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter )
|
||||||
{
|
{
|
||||||
// This gives the chance for the other bot to respond.
|
// This gives the chance for the other bot to respond.
|
||||||
if ( !concept.GetSpeaker().IsValid() )
|
if ( !concept.GetSpeaker().IsValid() )
|
||||||
|
@ -792,11 +792,11 @@ void CAI_PlayerAlly::PostSpeakDispatchResponse( AIConcept_t concept, AI_Response
|
|||||||
{
|
{
|
||||||
if ( bSaidHelloToNPC )
|
if ( bSaidHelloToNPC )
|
||||||
{
|
{
|
||||||
Warning("Q&A: '%s' said Hello to '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), concept );
|
Warning("Q&A: '%s' said Hello to '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), (const char*)concept );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Warning("Q&A: '%s' questioned '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), concept );
|
Warning("Q&A: '%s' questioned '%s' (concept %s)\n", GetDebugName(), GetSpeechTarget()->GetDebugName(), (const char*)concept );
|
||||||
}
|
}
|
||||||
NDebugOverlay::HorzArrow( GetAbsOrigin(), GetSpeechTarget()->GetAbsOrigin(), 8, 0, 255, 0, 64, true, duration );
|
NDebugOverlay::HorzArrow( GetAbsOrigin(), GetSpeechTarget()->GetAbsOrigin(), 8, 0, 255, 0, 64, true, duration );
|
||||||
}
|
}
|
||||||
@ -1022,11 +1022,11 @@ void CAI_PlayerAlly::AnswerQuestion( CAI_PlayerAlly *pQuestioner, int iQARandomN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert( selection.pResponse );
|
|
||||||
SetSpeechTarget( selection.hSpeechTarget );
|
SetSpeechTarget( selection.hSpeechTarget );
|
||||||
#ifdef NEW_RESPONSE_SYSTEM
|
#ifdef NEW_RESPONSE_SYSTEM
|
||||||
SpeakDispatchResponse( selection.concept.c_str(), &selection.Response );
|
SpeakDispatchResponse( selection.concept.c_str(), &selection.Response );
|
||||||
#else
|
#else
|
||||||
|
Assert( selection.pResponse );
|
||||||
SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
|
SpeakDispatchResponse( selection.concept.c_str(), selection.pResponse );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1078,11 +1078,11 @@ int CAI_PlayerAlly::SelectNonCombatSpeechSchedule()
|
|||||||
AISpeechSelection_t selection;
|
AISpeechSelection_t selection;
|
||||||
if ( SelectNonCombatSpeech( &selection ) )
|
if ( SelectNonCombatSpeech( &selection ) )
|
||||||
{
|
{
|
||||||
Assert( selection.pResponse );
|
|
||||||
SetSpeechTarget( selection.hSpeechTarget );
|
SetSpeechTarget( selection.hSpeechTarget );
|
||||||
#ifdef NEW_RESPONSE_SYSTEM
|
#ifdef NEW_RESPONSE_SYSTEM
|
||||||
SetPendingSpeech( selection.concept.c_str(), &selection.Response );
|
SetPendingSpeech( selection.concept.c_str(), &selection.Response );
|
||||||
#else
|
#else
|
||||||
|
Assert( selection.pResponse );
|
||||||
SetPendingSpeech( selection.concept.c_str(), selection.pResponse );
|
SetPendingSpeech( selection.concept.c_str(), selection.pResponse );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1240,7 @@ char *CAI_Expresser::ParseApplyContext( const char *szContext )
|
|||||||
{
|
{
|
||||||
// If it's really 0, then this is a waste of time
|
// If it's really 0, then this is a waste of time
|
||||||
Warning("\"%s\" was detected by applyContext operators as an operable number, but it's not.\n", szValue);
|
Warning("\"%s\" was detected by applyContext operators as an operable number, but it's not.\n", szValue);
|
||||||
return strdup(szContext);
|
return szContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the existing value; will be operated upon and become the final assignment
|
// This is the existing value; will be operated upon and become the final assignment
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include "ai_speech.h"
|
#include "ai_speech.h"
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "engine/ienginesound.h"
|
#include "engine/IEngineSound.h"
|
||||||
#include "keyvalues.h"
|
#include "KeyValues.h"
|
||||||
#include "ai_basenpc.h"
|
#include "ai_basenpc.h"
|
||||||
#include "ai_criteria.h"
|
#include "AI_Criteria.h"
|
||||||
#include "isaverestore.h"
|
#include "isaverestore.h"
|
||||||
#include "sceneentity.h"
|
#include "sceneentity.h"
|
||||||
#include "ai_speechqueue.h"
|
#include "ai_speechqueue.h"
|
||||||
@ -575,7 +575,7 @@ void CAI_Expresser::GatherCriteria( AI_CriteriaSet * RESTRICT outputSet, const A
|
|||||||
// Output : AI_Response
|
// Output : AI_Response
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char *modifiers /*= NULL*/ )
|
// AI_Response *CAI_Expresser::SpeakFindResponse( AIConcept_t concept, const char *modifiers /*= NULL*/ )
|
||||||
bool CAI_Expresser::FindResponse( AI_Response &outResponse, AIConcept_t &concept, AI_CriteriaSet *criteria )
|
bool CAI_Expresser::FindResponse( AI_Response &outResponse, const AIConcept_t &concept, AI_CriteriaSet *criteria )
|
||||||
{
|
{
|
||||||
VPROF("CAI_Expresser::FindResponse");
|
VPROF("CAI_Expresser::FindResponse");
|
||||||
IResponseSystem *rs = GetOuter()->GetResponseSystem();
|
IResponseSystem *rs = GetOuter()->GetResponseSystem();
|
||||||
@ -703,7 +703,7 @@ bool CAI_Expresser::FindResponse( AI_Response &outResponse, AIConcept_t &concept
|
|||||||
// NULL -
|
// NULL -
|
||||||
// Output : bool : true on success, false on fail
|
// Output : bool : true on success, false on fail
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, AIConcept_t &concept, AI_CriteriaSet *criteria )
|
AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, const AIConcept_t &concept, AI_CriteriaSet *criteria )
|
||||||
{
|
{
|
||||||
Assert(response);
|
Assert(response);
|
||||||
|
|
||||||
@ -808,7 +808,7 @@ AI_Response *CAI_Expresser::SpeakFindResponse( AI_Response *result, AIConcept_t
|
|||||||
// Purpose: Dispatches the result
|
// Purpose: Dispatches the result
|
||||||
// Input : *response -
|
// Input : *response -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t &concept, AI_Response *result, AI_CriteriaSet *criteria, IRecipientFilter *filter /* = NULL */ )
|
bool CAI_Expresser::SpeakDispatchResponse( AIConcept_t concept, AI_Response *result, AI_CriteriaSet *criteria, IRecipientFilter *filter /* = NULL */ )
|
||||||
{
|
{
|
||||||
char response[ 256 ];
|
char response[ 256 ];
|
||||||
result->GetResponse( response, sizeof( response ) );
|
result->GetResponse( response, sizeof( response ) );
|
||||||
@ -1068,21 +1068,21 @@ bool CAI_Expresser::FireEntIOFromResponse( char *response, CBaseEntity *pInitiat
|
|||||||
char *pszParam;
|
char *pszParam;
|
||||||
char *strtokContext;
|
char *strtokContext;
|
||||||
|
|
||||||
pszEntname = strtok_s( response, " ", &strtokContext );
|
pszEntname = V_strtok_s( response, " ", &strtokContext );
|
||||||
if ( !pszEntname )
|
if ( !pszEntname )
|
||||||
{
|
{
|
||||||
Warning( "Response was entityio but had bad value %s\n", response );
|
Warning( "Response was entityio but had bad value %s\n", response );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pszInput = strtok_s( NULL, " ", &strtokContext );
|
pszInput = V_strtok_s( NULL, " ", &strtokContext );
|
||||||
if ( !pszInput )
|
if ( !pszInput )
|
||||||
{
|
{
|
||||||
Warning( "Response was entityio but had bad value %s\n", response );
|
Warning( "Response was entityio but had bad value %s\n", response );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pszParam = strtok_s( NULL, " ", &strtokContext );
|
pszParam = V_strtok_s( NULL, " ", &strtokContext );
|
||||||
|
|
||||||
// poke entity io
|
// poke entity io
|
||||||
CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, pszEntname, pInitiator );
|
CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, pszEntname, pInitiator );
|
||||||
@ -1231,7 +1231,7 @@ void CAI_Expresser::MarkResponseAsUsed( AI_Response *response )
|
|||||||
// Input : concept -
|
// Input : concept -
|
||||||
// Output : Returns true on success, false on failure.
|
// Output : Returns true on success, false on failure.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CAI_Expresser::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
|
bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/, char *pszOutResponseChosen /* = NULL*/, size_t bufsize /* = 0 */, IRecipientFilter *filter /* = NULL */ )
|
||||||
{
|
{
|
||||||
concept.SetSpeaker(GetOuter());
|
concept.SetSpeaker(GetOuter());
|
||||||
AI_CriteriaSet criteria;
|
AI_CriteriaSet criteria;
|
||||||
@ -1245,7 +1245,7 @@ bool CAI_Expresser::Speak( AIConcept_t &concept, const char *modifiers /*= NULL*
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CAI_Expresser::Speak( AIConcept_t &concept, AI_CriteriaSet * RESTRICT criteria, char *pszOutResponseChosen , size_t bufsize , IRecipientFilter *filter )
|
bool CAI_Expresser::Speak( const AIConcept_t &concept, AI_CriteriaSet * RESTRICT criteria, char *pszOutResponseChosen , size_t bufsize , IRecipientFilter *filter )
|
||||||
{
|
{
|
||||||
VPROF("CAI_Expresser::Speak");
|
VPROF("CAI_Expresser::Speak");
|
||||||
if ( IsSpeechGloballySuppressed() )
|
if ( IsSpeechGloballySuppressed() )
|
||||||
@ -1260,7 +1260,7 @@ bool CAI_Expresser::Speak( AIConcept_t &concept, AI_CriteriaSet * RESTRICT crite
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
|
SpeechMsg( GetOuter(), "%s (%p) spoke %s (%f)", STRING(GetOuter()->GetEntityName()), GetOuter(), (const char*)concept, gpGlobals->curtime );
|
||||||
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );
|
// Msg( "%s:%s to %s:%s\n", GetOuter()->GetDebugName(), concept.GetStringConcept(), criteria.GetValue(criteria.FindCriterionIndex("Subject")), pTarget ? pTarget->GetDebugName() : "none" );
|
||||||
|
|
||||||
bool spoke = SpeakDispatchResponse( concept, &result, criteria, filter );
|
bool spoke = SpeakDispatchResponse( concept, &result, criteria, filter );
|
||||||
@ -1447,7 +1447,7 @@ bool CAI_Expresser::CanSpeakAfterMyself()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
bool CAI_Expresser::CanSpeakConcept( AIConcept_t concept )
|
bool CAI_Expresser::CanSpeakConcept( const AIConcept_t &concept )
|
||||||
{
|
{
|
||||||
// Not in history?
|
// Not in history?
|
||||||
int iter = m_ConceptHistories.Find( concept );
|
int iter = m_ConceptHistories.Find( concept );
|
||||||
@ -1479,14 +1479,14 @@ bool CAI_Expresser::CanSpeakConcept( AIConcept_t concept )
|
|||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
bool CAI_Expresser::SpokeConcept( AIConcept_t concept )
|
bool CAI_Expresser::SpokeConcept( const AIConcept_t &concept )
|
||||||
{
|
{
|
||||||
return GetTimeSpokeConcept( concept ) != -1.f;
|
return GetTimeSpokeConcept( concept ) != -1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
float CAI_Expresser::GetTimeSpokeConcept( AIConcept_t concept )
|
float CAI_Expresser::GetTimeSpokeConcept( const AIConcept_t &concept )
|
||||||
{
|
{
|
||||||
int iter = m_ConceptHistories.Find( concept );
|
int iter = m_ConceptHistories.Find( concept );
|
||||||
if ( iter == m_ConceptHistories.InvalidIndex() )
|
if ( iter == m_ConceptHistories.InvalidIndex() )
|
||||||
@ -1498,7 +1498,7 @@ float CAI_Expresser::GetTimeSpokeConcept( AIConcept_t concept )
|
|||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
void CAI_Expresser::SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback )
|
void CAI_Expresser::SetSpokeConcept( const AIConcept_t &concept, AI_Response *response, bool bCallback )
|
||||||
{
|
{
|
||||||
int idx = m_ConceptHistories.Find( concept );
|
int idx = m_ConceptHistories.Find( concept );
|
||||||
if ( idx == m_ConceptHistories.InvalidIndex() )
|
if ( idx == m_ConceptHistories.InvalidIndex() )
|
||||||
@ -1523,7 +1523,7 @@ void CAI_Expresser::SetSpokeConcept( AIConcept_t concept, AI_Response *response,
|
|||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
void CAI_Expresser::ClearSpokeConcept( AIConcept_t concept )
|
void CAI_Expresser::ClearSpokeConcept( const AIConcept_t &concept )
|
||||||
{
|
{
|
||||||
m_ConceptHistories.Remove( concept );
|
m_ConceptHistories.Remove( concept );
|
||||||
}
|
}
|
||||||
@ -1560,7 +1560,7 @@ bool CAI_Expresser::IsValidResponse( ResponseType_t type, const char *pszValue )
|
|||||||
CAI_TimedSemaphore *CAI_Expresser::GetMySpeechSemaphore( CBaseEntity *pNpc )
|
CAI_TimedSemaphore *CAI_Expresser::GetMySpeechSemaphore( CBaseEntity *pNpc )
|
||||||
{
|
{
|
||||||
if ( !pNpc->MyNPCPointer() )
|
if ( !pNpc->MyNPCPointer() )
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
return (pNpc->MyNPCPointer()->IsPlayerAlly() ? &g_AIFriendliesTalkSemaphore : &g_AIFoesTalkSemaphore );
|
return (pNpc->MyNPCPointer()->IsPlayerAlly() ? &g_AIFriendliesTalkSemaphore : &g_AIFoesTalkSemaphore );
|
||||||
}
|
}
|
||||||
@ -1573,16 +1573,23 @@ void CAI_Expresser::SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... )
|
|||||||
if ( !DebuggingSpeech() )
|
if ( !DebuggingSpeech() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
va_list arg_ptr;
|
||||||
|
|
||||||
|
va_start(arg_ptr, pszFormat);
|
||||||
|
CFmtStr formatted;
|
||||||
|
formatted.sprintf_argv(pszFormat, arg_ptr);
|
||||||
|
va_end(arg_ptr);
|
||||||
|
|
||||||
if ( pFlex->MyNPCPointer() )
|
if ( pFlex->MyNPCPointer() )
|
||||||
{
|
{
|
||||||
|
|
||||||
DevMsg( pFlex->MyNPCPointer(), CFmtStr( &pszFormat ) );
|
DevMsg( pFlex->MyNPCPointer(), "%s", formatted.Get() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CGMsg( 1, CON_GROUP_SPEECH_AI, CFmtStr( &pszFormat ) );
|
CGMsg( 1, CON_GROUP_SPEECH_AI, "%s", formatted.Get() );
|
||||||
}
|
}
|
||||||
UTIL_LogPrintf( (char *) ( (const char *) CFmtStr( &pszFormat ) ) );
|
UTIL_LogPrintf( "%s", formatted.Get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "soundflags.h"
|
#include "soundflags.h"
|
||||||
#include "AI_Criteria.h"
|
#include "AI_Criteria.h"
|
||||||
#include "ai_responsesystem.h"
|
#include "AI_ResponseSystem.h"
|
||||||
#include "utldict.h"
|
#include "utldict.h"
|
||||||
#include "ai_speechconcept.h"
|
#include "ai_speechconcept.h"
|
||||||
|
|
||||||
@ -162,8 +162,8 @@ public:
|
|||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
bool Speak( AIConcept_t &concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
bool Speak( AIConcept_t concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
||||||
bool Speak( AIConcept_t &concept, AI_CriteriaSet *criteria, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
bool Speak( const AIConcept_t &concept, AI_CriteriaSet *criteria, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
||||||
|
|
||||||
// Given modifiers (which are colon-delimited strings), fill out a criteria set including this
|
// Given modifiers (which are colon-delimited strings), fill out a criteria set including this
|
||||||
// character's contexts and the ones in the modifier. This lets us hang on to them after a call
|
// character's contexts and the ones in the modifier. This lets us hang on to them after a call
|
||||||
@ -174,8 +174,8 @@ public:
|
|||||||
// AI_Response *SpeakFindResponse( AIConcept_t &concept, AI_CriteriaSet *criteria );
|
// AI_Response *SpeakFindResponse( AIConcept_t &concept, AI_CriteriaSet *criteria );
|
||||||
// Find the appropriate response for the given concept. Return false if none found.
|
// Find the appropriate response for the given concept. Return false if none found.
|
||||||
// Fills out the response object that you provide.
|
// Fills out the response object that you provide.
|
||||||
bool FindResponse( AI_Response &outResponse, AIConcept_t &concept, AI_CriteriaSet *modifiers = NULL );
|
bool FindResponse( AI_Response &outResponse, const AIConcept_t &concept, AI_CriteriaSet *modifiers = NULL );
|
||||||
virtual bool SpeakDispatchResponse( AIConcept_t &concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter = NULL );
|
virtual bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter = NULL );
|
||||||
float GetResponseDuration( AI_Response *response );
|
float GetResponseDuration( AI_Response *response );
|
||||||
|
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
@ -206,11 +206,11 @@ public:
|
|||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
bool CanSpeakConcept( AIConcept_t concept );
|
bool CanSpeakConcept( const AIConcept_t &concept );
|
||||||
bool SpokeConcept( AIConcept_t concept );
|
bool SpokeConcept( const AIConcept_t &concept );
|
||||||
float GetTimeSpokeConcept( AIConcept_t concept ); // returns -1 if never
|
float GetTimeSpokeConcept( const AIConcept_t &concept ); // returns -1 if never
|
||||||
void SetSpokeConcept( AIConcept_t concept, AI_Response *response, bool bCallback = true );
|
void SetSpokeConcept( const AIConcept_t &concept, AI_Response *response, bool bCallback = true );
|
||||||
void ClearSpokeConcept( AIConcept_t concept );
|
void ClearSpokeConcept( const AIConcept_t &concept );
|
||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public:
|
|||||||
bool ScriptSpeakRawScene( char const *soundname, float delay ) { return SpeakRawScene( soundname, delay, NULL ); }
|
bool ScriptSpeakRawScene( char const *soundname, float delay ) { return SpeakRawScene( soundname, delay, NULL ); }
|
||||||
bool ScriptSpeakAutoGeneratedScene( char const *soundname, float delay ) { return SpeakAutoGeneratedScene( soundname, delay ); }
|
bool ScriptSpeakAutoGeneratedScene( char const *soundname, float delay ) { return SpeakAutoGeneratedScene( soundname, delay ); }
|
||||||
int ScriptSpeakRawSentence( char const *pszSentence, float delay ) { return SpeakRawSentence( pszSentence, delay ); }
|
int ScriptSpeakRawSentence( char const *pszSentence, float delay ) { return SpeakRawSentence( pszSentence, delay ); }
|
||||||
bool ScriptSpeak( char const *concept, const char *modifiers ) { return Speak( CAI_Concept( concept ), modifiers[0] != '\0' ? modifiers : NULL ); }
|
bool ScriptSpeak( char const *concept, const char *modifiers ) { return Speak( concept, modifiers[0] != '\0' ? modifiers : NULL ); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// helper used in dealing with RESPONSE_ENTITYIO
|
// helper used in dealing with RESPONSE_ENTITYIO
|
||||||
@ -249,7 +249,7 @@ protected:
|
|||||||
|
|
||||||
void DumpHistories();
|
void DumpHistories();
|
||||||
|
|
||||||
void SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... );
|
void SpeechMsg( CBaseEntity *pFlex, PRINTF_FORMAT_STRING const char *pszFormat, ... ) FMTFUNCTION(3, 4);
|
||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
@ -321,15 +321,15 @@ public:
|
|||||||
// These two methods allow looking up a response and dispatching it to be two different steps
|
// These two methods allow looking up a response and dispatching it to be two different steps
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
//AI_Response *SpeakFindResponse( AIConcept_t concept, const AI_CriteriaSet& modifiers );
|
//AI_Response *SpeakFindResponse( AIConcept_t concept, const AI_CriteriaSet& modifiers );
|
||||||
inline bool SpeakDispatchResponse( AIConcept_t concept, AI_Response &response, AI_CriteriaSet *criteria = NULL ) { return SpeakDispatchResponse( concept, &response, criteria ); }
|
inline bool SpeakDispatchResponse( const AIConcept_t &concept, AI_Response &response, AI_CriteriaSet *criteria = NULL ) { return SpeakDispatchResponse( concept, &response, criteria ); }
|
||||||
#endif
|
#endif
|
||||||
bool SpeakFindResponse( AI_Response& outResponse, AIConcept_t concept, const char *modifiers = NULL );
|
bool SpeakFindResponse( AI_Response& outResponse, const AIConcept_t &concept, const char *modifiers = NULL );
|
||||||
// AI_Response * SpeakFindResponse( AIConcept_t concept, const char *modifiers = NULL );
|
// AI_Response * SpeakFindResponse( AIConcept_t concept, const char *modifiers = NULL );
|
||||||
// AI_Response *SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet *criteria );
|
// AI_Response *SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet *criteria );
|
||||||
// AI_Response *SpeakFindResponse( AIConcept_t concept );
|
// AI_Response *SpeakFindResponse( AIConcept_t concept );
|
||||||
// Find the appropriate response for the given concept. Return false if none found.
|
// Find the appropriate response for the given concept. Return false if none found.
|
||||||
// Fills out the response object that you provide.
|
// Fills out the response object that you provide.
|
||||||
bool FindResponse( AI_Response &outResponse, AIConcept_t &concept, AI_CriteriaSet *criteria = NULL );
|
bool FindResponse( AI_Response &outResponse, const AIConcept_t &concept, AI_CriteriaSet *criteria = NULL );
|
||||||
|
|
||||||
bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria = NULL );
|
bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria = NULL );
|
||||||
virtual void PostSpeakDispatchResponse( AIConcept_t concept, AI_Response *response ) { return; }
|
virtual void PostSpeakDispatchResponse( AIConcept_t concept, AI_Response *response ) { return; }
|
||||||
@ -436,7 +436,7 @@ inline void CAI_ExpresserHost<BASE_NPC>::GatherCriteria( AI_CriteriaSet *outputC
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline bool CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse(AI_Response& outResponse, AIConcept_t concept, const char *modifiers /*= NULL*/ )
|
inline bool CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse(AI_Response& outResponse, const AIConcept_t &concept, const char *modifiers /*= NULL*/ )
|
||||||
{
|
{
|
||||||
AI_CriteriaSet criteria;
|
AI_CriteriaSet criteria;
|
||||||
GatherCriteria(&criteria, concept, modifiers);
|
GatherCriteria(&criteria, concept, modifiers);
|
||||||
@ -446,7 +446,7 @@ inline bool CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse(AI_Response& outRespo
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t concept, const char *modifiers /*= NULL*/ )
|
inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( const AIConcept_t &concept, const char *modifiers /*= NULL*/ )
|
||||||
{
|
{
|
||||||
return this->GetExpresser()->SpeakFindResponse( concept, modifiers );
|
return this->GetExpresser()->SpeakFindResponse( concept, modifiers );
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t concept, AI_CriteriaSet *criteria /*= NULL*/ )
|
inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( const AIConcept_t &concept, AI_CriteriaSet *criteria /*= NULL*/ )
|
||||||
{
|
{
|
||||||
return this->GetExpresser()->SpeakFindResponse( concept, criteria );
|
return this->GetExpresser()->SpeakFindResponse( concept, criteria );
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ inline AI_Response *CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t
|
|||||||
// class that generates a one off.
|
// class that generates a one off.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline AI_Response * CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t concept )
|
inline AI_Response * CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( const AIConcept_t &concept )
|
||||||
{
|
{
|
||||||
AI_CriteriaSet criteria;
|
AI_CriteriaSet criteria;
|
||||||
GatherCriteria( &criteria, concept, NULL );
|
GatherCriteria( &criteria, concept, NULL );
|
||||||
@ -479,7 +479,7 @@ inline AI_Response * CAI_ExpresserHost<BASE_NPC>::SpeakFindResponse( AIConcept_t
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline bool CAI_ExpresserHost<BASE_NPC>::FindResponse( AI_Response &outResponse, AIConcept_t &concept, AI_CriteriaSet *criteria )
|
inline bool CAI_ExpresserHost<BASE_NPC>::FindResponse( AI_Response &outResponse, const AIConcept_t &concept, AI_CriteriaSet *criteria )
|
||||||
{
|
{
|
||||||
return this->GetExpresser()->FindResponse( outResponse, concept, criteria );
|
return this->GetExpresser()->FindResponse( outResponse, concept, criteria );
|
||||||
}
|
}
|
||||||
@ -512,9 +512,9 @@ inline float CAI_ExpresserHost<BASE_NPC>::GetResponseDuration( AI_Response *resp
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <class BASE_NPC>
|
template <class BASE_NPC>
|
||||||
inline void CAI_ExpresserHost<BASE_NPC>::DispatchResponse( const char *conceptName )
|
inline void CAI_ExpresserHost<BASE_NPC>::DispatchResponse( const char *conceptName )
|
||||||
{
|
{
|
||||||
Speak( (AIConcept_t)conceptName );
|
Speak( AIConcept_t( conceptName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -529,7 +529,7 @@ inline void CAI_ExpresserHost<BASE_NPC>::DispatchResponse( const char *conceptNa
|
|||||||
template <class BASE_NPC, class EXPRESSER_TYPE>
|
template <class BASE_NPC, class EXPRESSER_TYPE>
|
||||||
class CAI_ExpresserHostWithData : public CAI_ExpresserHost<BASE_NPC>
|
class CAI_ExpresserHostWithData : public CAI_ExpresserHost<BASE_NPC>
|
||||||
{
|
{
|
||||||
DECLARE_CLASS_NOFRIEND( CAI_ExpresserHostWithData, CAI_ExpresserHost );
|
DECLARE_CLASS_NOFRIEND( CAI_ExpresserHostWithData, CAI_ExpresserHost<BASE_NPC> );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAI_ExpresserHostWithData( ) : m_pExpresser(NULL) {};
|
CAI_ExpresserHostWithData( ) : m_pExpresser(NULL) {};
|
||||||
@ -545,11 +545,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
EXPRESSER_TYPE *CreateExpresser( void )
|
EXPRESSER_TYPE *CreateExpresser( void )
|
||||||
{
|
{
|
||||||
AssertMsg1( m_pExpresser == NULL, "Tried to double-initialize expresser in %s\n", GetDebugName() );
|
AssertMsg1( m_pExpresser == NULL, "Tried to double-initialize expresser in %s\n", this->GetDebugName() );
|
||||||
m_pExpresser = new EXPRESSER_TYPE(this);
|
m_pExpresser = new EXPRESSER_TYPE(this);
|
||||||
if ( !m_pExpresser)
|
if ( !m_pExpresser)
|
||||||
{
|
{
|
||||||
AssertMsg1( false, "Creating an expresser failed in %s\n", GetDebugName() );
|
AssertMsg1( false, "Creating an expresser failed in %s\n", this->GetDebugName() );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,8 +667,8 @@ public:
|
|||||||
CAI_ExpresserWithFollowup( CBaseFlex *pOuter = NULL ) : CAI_Expresser(pOuter),
|
CAI_ExpresserWithFollowup( CBaseFlex *pOuter = NULL ) : CAI_Expresser(pOuter),
|
||||||
m_pPostponedFollowup(NULL)
|
m_pPostponedFollowup(NULL)
|
||||||
{};
|
{};
|
||||||
virtual bool Speak( AIConcept_t &concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
virtual bool Speak( AIConcept_t concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
|
||||||
virtual bool SpeakDispatchResponse( AIConcept_t &concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter = NULL );
|
virtual bool SpeakDispatchResponse( AIConcept_t concept, AI_Response *response, AI_CriteriaSet *criteria, IRecipientFilter *filter = NULL );
|
||||||
virtual void SpeakDispatchFollowup( AI_ResponseFollowup &followup );
|
virtual void SpeakDispatchFollowup( AI_ResponseFollowup &followup );
|
||||||
|
|
||||||
virtual void OnSpeechFinished();
|
virtual void OnSpeechFinished();
|
||||||
|
@ -2511,7 +2511,7 @@ class CBreakableGibShooter : public CBaseEntity
|
|||||||
DECLARE_DATADESC();
|
DECLARE_DATADESC();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const char *GetRandomTemplateModel( CPointTemplate *pTemplate );
|
int GetRandomTemplateModelIndex( CPointTemplate *pTemplate );
|
||||||
|
|
||||||
void Precache( void );
|
void Precache( void );
|
||||||
|
|
||||||
@ -2560,19 +2560,16 @@ END_DATADESC()
|
|||||||
LINK_ENTITY_TO_CLASS( env_break_shooter, CBreakableGibShooter );
|
LINK_ENTITY_TO_CLASS( env_break_shooter, CBreakableGibShooter );
|
||||||
|
|
||||||
|
|
||||||
const char *CBreakableGibShooter::GetRandomTemplateModel( CPointTemplate *pTemplate )
|
int CBreakableGibShooter::GetRandomTemplateModelIndex( CPointTemplate *pTemplate )
|
||||||
{
|
{
|
||||||
int iIndex = RandomInt( 0, pTemplate->GetNumTemplates() );
|
int iIndex = RandomInt( 0, pTemplate->GetNumTemplates() );
|
||||||
char *iszTemplate = (char*)(STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex))));
|
const char *szTemplate = STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex)));
|
||||||
|
|
||||||
CEntityMapData entData( iszTemplate );
|
|
||||||
|
|
||||||
// This might seem a little messy, but I think it's cheaper than creating the entity.
|
// This might seem a little messy, but I think it's cheaper than creating the entity.
|
||||||
char szModel[MAPKEY_MAXLENGTH];
|
char szModel[MAPKEY_MAXLENGTH];
|
||||||
if (!entData.ExtractValue("model", szModel))
|
bool modelExtracted = MapEntity_ExtractValue(szTemplate, "model", szModel);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return strdup(szModel);
|
return modelinfo->GetModelIndex( modelExtracted ? szModel : NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBreakableGibShooter::Precache( void )
|
void CBreakableGibShooter::Precache( void )
|
||||||
@ -2604,7 +2601,7 @@ void CBreakableGibShooter::Shoot( void )
|
|||||||
if (m_iModelType == MODELTYPE_BREAKABLECHUNKS)
|
if (m_iModelType == MODELTYPE_BREAKABLECHUNKS)
|
||||||
iModelIndex = modelinfo->GetModelIndex( g_PropDataSystem.GetRandomChunkModel( STRING( GetModelName() ) ) );
|
iModelIndex = modelinfo->GetModelIndex( g_PropDataSystem.GetRandomChunkModel( STRING( GetModelName() ) ) );
|
||||||
else if (m_iModelType == MODELTYPE_TEMPLATE)
|
else if (m_iModelType == MODELTYPE_TEMPLATE)
|
||||||
iModelIndex = modelinfo->GetModelIndex( GetRandomTemplateModel(pTemplate) );
|
iModelIndex = GetRandomTemplateModelIndex( pTemplate );
|
||||||
|
|
||||||
// All objects except the first one in this run are marked as slaves...
|
// All objects except the first one in this run are marked as slaves...
|
||||||
int slaveFlag = 0;
|
int slaveFlag = 0;
|
||||||
|
@ -277,7 +277,8 @@ bool CGenericActorCustom::KeyValue( const char *szKeyName, const char *szValue )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CGenericActorCustom::SpeakIfAllowed( const char *concept, AI_CriteriaSet *modifiers )
|
void CGenericActorCustom::SpeakIfAllowed( const char *concept, AI_CriteriaSet *modifiers )
|
||||||
{
|
{
|
||||||
Speak( concept, modifiers ? *modifiers : AI_CriteriaSet() );
|
AI_CriteriaSet empty;
|
||||||
|
Speak( concept, modifiers ? *modifiers : empty );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1263,7 +1263,8 @@ void CZombieCustom::AttackSound( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CZombieCustom::SpeakIfAllowed(const char *concept, AI_CriteriaSet *modifiers)
|
void CZombieCustom::SpeakIfAllowed(const char *concept, AI_CriteriaSet *modifiers)
|
||||||
{
|
{
|
||||||
Speak( concept, modifiers ? *modifiers : AI_CriteriaSet() );
|
AI_CriteriaSet empty;
|
||||||
|
Speak( concept, modifiers ? *modifiers : empty );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -672,6 +672,33 @@ int CAI_Monitor::TranslateScheduleString(const char *schedName)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Translator>
|
||||||
|
static void SetForEachDelimited( CAI_Monitor &monitor, const char *szValue, const char *delimiters, void (CAI_Monitor::*setter)(int), Translator translator)
|
||||||
|
{
|
||||||
|
char *value = strdup(szValue);
|
||||||
|
char *token = strtok(value, ":");
|
||||||
|
while (token)
|
||||||
|
{
|
||||||
|
(monitor.*setter)(translator(token));
|
||||||
|
|
||||||
|
token = strtok(NULL, ":");
|
||||||
|
}
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int (CAI_Monitor::*translator)(const char*)>
|
||||||
|
struct CAI_MonitorTranslator
|
||||||
|
{
|
||||||
|
CAI_Monitor &monitor;
|
||||||
|
|
||||||
|
CAI_MonitorTranslator(CAI_Monitor &monitor) : monitor(monitor) {}
|
||||||
|
|
||||||
|
int operator()(const char *value)
|
||||||
|
{
|
||||||
|
return (monitor.*translator)(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Cache user entity field values until spawn is called.
|
// Purpose: Cache user entity field values until spawn is called.
|
||||||
// Input : szKeyName - Key to handle.
|
// Input : szKeyName - Key to handle.
|
||||||
@ -688,13 +715,7 @@ bool CAI_Monitor::KeyValue( const char *szKeyName, const char *szValue )
|
|||||||
}
|
}
|
||||||
else if (FStrEq(szKeyName, "Conditions"))
|
else if (FStrEq(szKeyName, "Conditions"))
|
||||||
{
|
{
|
||||||
char *token = strtok(strdup(szValue), ":");
|
SetForEachDelimited(*this, szValue, ":", &CAI_Monitor::SetCondition, CAI_MonitorTranslator<&CAI_Monitor::TranslateConditionString>(*this));
|
||||||
while (token)
|
|
||||||
{
|
|
||||||
SetCondition(TranslateConditionString(token));
|
|
||||||
|
|
||||||
token = strtok(NULL, ":");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (FStrEq(szKeyName, "SchedulesSimple"))
|
else if (FStrEq(szKeyName, "SchedulesSimple"))
|
||||||
{
|
{
|
||||||
@ -703,13 +724,7 @@ bool CAI_Monitor::KeyValue( const char *szKeyName, const char *szValue )
|
|||||||
}
|
}
|
||||||
else if (FStrEq(szKeyName, "Schedules"))
|
else if (FStrEq(szKeyName, "Schedules"))
|
||||||
{
|
{
|
||||||
char *token = strtok(strdup(szValue), ":");
|
SetForEachDelimited(*this, szValue, ":", &CAI_Monitor::SetSchedule, CAI_MonitorTranslator<&CAI_Monitor::TranslateScheduleString>(*this));
|
||||||
while (token)
|
|
||||||
{
|
|
||||||
SetSchedule(TranslateScheduleString(token));
|
|
||||||
|
|
||||||
token = strtok(NULL, ":");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (FStrEq(szKeyName, "HintsSimple"))
|
else if (FStrEq(szKeyName, "HintsSimple"))
|
||||||
{
|
{
|
||||||
@ -718,13 +733,7 @@ bool CAI_Monitor::KeyValue( const char *szKeyName, const char *szValue )
|
|||||||
}
|
}
|
||||||
else if (FStrEq(szKeyName, "Hints"))
|
else if (FStrEq(szKeyName, "Hints"))
|
||||||
{
|
{
|
||||||
char *token = strtok(strdup(szValue), ":");
|
SetForEachDelimited(*this, szValue, ":", &CAI_Monitor::SetHint, atoi);
|
||||||
while (token)
|
|
||||||
{
|
|
||||||
SetHint(atoi(szValue));
|
|
||||||
|
|
||||||
token = strtok(NULL, ":");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return CBaseEntity::KeyValue( szKeyName, szValue );
|
return CBaseEntity::KeyValue( szKeyName, szValue );
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
//
|
//
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#include "ai_criteria.h"
|
#include "AI_Criteria.h"
|
||||||
|
|
||||||
#ifdef GAME_DLL
|
#ifdef GAME_DLL
|
||||||
#include "ai_speech.h"
|
#include "ai_speech.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <keyvalues.h>
|
#include <KeyValues.h>
|
||||||
#include "engine/ienginesound.h"
|
#include "engine/IEngineSound.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include <tier0/memdbgon.h>
|
#include <tier0/memdbgon.h>
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#include "soundemittersystem/isoundemittersystembase.h"
|
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||||
#include "ai_responsesystem.h"
|
#include "AI_ResponseSystem.h"
|
||||||
#include "igamesystem.h"
|
#include "igamesystem.h"
|
||||||
#include "ai_criteria.h"
|
#include "AI_Criteria.h"
|
||||||
#include <keyvalues.h>
|
#include <KeyValues.h>
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "utldict.h"
|
#include "utldict.h"
|
||||||
#ifdef GAME_DLL
|
#ifdef GAME_DLL
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ai_criteria.h"
|
#include "AI_Criteria.h"
|
||||||
#include "../../public/responserules/response_types.h"
|
#include "../../public/responserules/response_types.h"
|
||||||
|
|
||||||
// using ResponseRules::IResponseFilter;
|
// using ResponseRules::IResponseFilter;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../public/responserules/response_types.h"
|
#include "responserules/response_types.h"
|
||||||
|
|
||||||
class CAI_Concept : public ResponseRules::CRR_Concept
|
class CAI_Concept : public ResponseRules::CRR_Concept
|
||||||
{
|
{
|
||||||
|
@ -464,7 +464,7 @@ public:
|
|||||||
{
|
{
|
||||||
pNodeName = pName->GetName();
|
pNodeName = pName->GetName();
|
||||||
|
|
||||||
const char *pInputName = NULL;
|
string_t pInputName = NULL_STRING;
|
||||||
variant_t varInputParam;
|
variant_t varInputParam;
|
||||||
float flInputDelay = 0.0f;
|
float flInputDelay = 0.0f;
|
||||||
CBaseEntity *pActivator = NULL;
|
CBaseEntity *pActivator = NULL;
|
||||||
@ -480,7 +480,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Input name
|
// Input name
|
||||||
case 0:
|
case 0:
|
||||||
pInputName = inputparams; break;
|
pInputName = AllocPooledString(inputparams); break;
|
||||||
// Input parameter
|
// Input parameter
|
||||||
case 1:
|
case 1:
|
||||||
varInputParam.SetString(AllocPooledString(inputparams)); break;
|
varInputParam.SetString(AllocPooledString(inputparams)); break;
|
||||||
@ -500,9 +500,10 @@ public:
|
|||||||
iter++;
|
iter++;
|
||||||
inputparams = strtok(NULL, ",");
|
inputparams = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
free(pszValue);
|
||||||
|
|
||||||
DebugMsg("MapEdit Debug: Firing input %s on %s\n", pInputName, pNodeName);
|
DebugMsg("MapEdit Debug: Firing input %s on %s\n", pInputName, pNodeName);
|
||||||
g_EventQueue.AddEvent(pNodeName, pInputName, varInputParam, flInputDelay, pActivator, pCaller, iOutputID);
|
g_EventQueue.AddEvent(pNodeName, STRING(pInputName), varInputParam, flInputDelay, pActivator, pCaller, iOutputID);
|
||||||
|
|
||||||
pName = pName->GetNextKey();
|
pName = pName->GetNextKey();
|
||||||
}
|
}
|
||||||
|
@ -65,16 +65,16 @@ namespace ResponseRules
|
|||||||
float followup_delay; // 20
|
float followup_delay; // 20
|
||||||
const char *followup_target; // 24 -- to whom is this despatched?
|
const char *followup_target; // 24 -- to whom is this despatched?
|
||||||
// AIConceptHandle_t hConcept;
|
// AIConceptHandle_t hConcept;
|
||||||
const char *followup_entityiotarget; //< if this rule involves firing entity io
|
const char *followup_entityiotarget; //< if this rule involves firing entity io
|
||||||
const char *followup_entityioinput; //< if this rule involves firing entity io
|
const char *followup_entityioinput; //< if this rule involves firing entity io
|
||||||
float followup_entityiodelay;
|
float followup_entityiodelay;
|
||||||
bool bFired;
|
bool bFired;
|
||||||
|
|
||||||
inline bool IsValid( void ) const { return (followup_concept && followup_contexts); }
|
inline bool IsValid( void ) const { return (followup_concept && followup_contexts); }
|
||||||
inline void Invalidate() { followup_concept = NULL; followup_contexts = NULL; }
|
inline void Invalidate() { followup_concept = NULL; followup_contexts = NULL; }
|
||||||
inline void SetFired( bool fired ) { bFired = fired; }
|
inline void SetFired( bool fired ) { bFired = fired; }
|
||||||
inline bool HasBeenFired() { return bFired; }
|
inline bool HasBeenFired() { return bFired; }
|
||||||
|
|
||||||
AI_ResponseFollowup( void ) : followup_concept(NULL), followup_contexts(NULL), followup_delay(0), followup_target(NULL), followup_entityiotarget(NULL), followup_entityioinput(NULL), followup_entityiodelay(0), bFired(false)
|
AI_ResponseFollowup( void ) : followup_concept(NULL), followup_contexts(NULL), followup_delay(0), followup_target(NULL), followup_entityiotarget(NULL), followup_entityioinput(NULL), followup_entityiodelay(0), bFired(false)
|
||||||
{};
|
{};
|
||||||
AI_ResponseFollowup( char *_followup_concept, char *_followup_contexts, float _followup_delay, char *_followup_target,
|
AI_ResponseFollowup( char *_followup_concept, char *_followup_contexts, float _followup_delay, char *_followup_target,
|
||||||
@ -235,67 +235,67 @@ namespace ResponseRules
|
|||||||
/// entity, subsequent to the match but BEFORE the dispatch.
|
/// entity, subsequent to the match but BEFORE the dispatch.
|
||||||
/// Returns the number of contexts modified. If it returns 0, then
|
/// Returns the number of contexts modified. If it returns 0, then
|
||||||
/// pSetOnWorld is empty.
|
/// pSetOnWorld is empty.
|
||||||
static int InterceptWorldSetContexts( CriteriaSet * RESTRICT pFrom,
|
static int InterceptWorldSetContexts( CriteriaSet * RESTRICT pFrom,
|
||||||
CriteriaSet * RESTRICT pSetOnWorld );
|
CriteriaSet * RESTRICT pSetOnWorld );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RemoveCriteria( int idx, bool bTestForPrefix );
|
void RemoveCriteria( int idx, bool bTestForPrefix );
|
||||||
|
|
||||||
struct CritEntry_t
|
struct CritEntry_t
|
||||||
{
|
{
|
||||||
CritEntry_t() :
|
CritEntry_t() :
|
||||||
criterianame( UTL_INVAL_SYMBOL ),
|
criterianame( UTL_INVAL_SYMBOL ),
|
||||||
weight( 0.0f )
|
weight( 0.0f )
|
||||||
{
|
|
||||||
value[ 0 ] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CritEntry_t( const CritEntry_t& src )
|
|
||||||
{
|
|
||||||
criterianame = src.criterianame;
|
|
||||||
value[ 0 ] = 0;
|
|
||||||
weight = src.weight;
|
|
||||||
SetValue( src.value );
|
|
||||||
}
|
|
||||||
|
|
||||||
CritEntry_t& operator=( const CritEntry_t& src )
|
|
||||||
{
|
|
||||||
if ( this == &src )
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
criterianame = src.criterianame;
|
|
||||||
weight = src.weight;
|
|
||||||
SetValue( src.value );
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool LessFunc( const CritEntry_t& lhs, const CritEntry_t& rhs )
|
|
||||||
{
|
|
||||||
return lhs.criterianame < rhs.criterianame;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetValue( char const *str )
|
|
||||||
{
|
|
||||||
if ( !str )
|
|
||||||
{
|
{
|
||||||
value[ 0 ] = 0;
|
value[ 0 ] = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Q_strncpy( value, str, sizeof( value ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CritSymbol_t criterianame;
|
CritEntry_t( const CritEntry_t& src )
|
||||||
char value[ 64 ];
|
{
|
||||||
float weight;
|
criterianame = src.criterianame;
|
||||||
|
value[ 0 ] = 0;
|
||||||
|
weight = src.weight;
|
||||||
|
SetValue( src.value );
|
||||||
|
}
|
||||||
|
|
||||||
|
CritEntry_t& operator=( const CritEntry_t& src )
|
||||||
|
{
|
||||||
|
if ( this == &src )
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
criterianame = src.criterianame;
|
||||||
|
weight = src.weight;
|
||||||
|
SetValue( src.value );
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool LessFunc( const CritEntry_t& lhs, const CritEntry_t& rhs )
|
||||||
|
{
|
||||||
|
return lhs.criterianame < rhs.criterianame;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetValue( char const *str )
|
||||||
|
{
|
||||||
|
if ( !str )
|
||||||
|
{
|
||||||
|
value[ 0 ] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q_strncpy( value, str, sizeof( value ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CritSymbol_t criterianame;
|
||||||
|
char value[ 64 ];
|
||||||
|
float weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
static CUtlSymbolTable sm_CriteriaSymbols;
|
static CUtlSymbolTable sm_CriteriaSymbols;
|
||||||
typedef CUtlRBTree< CritEntry_t, short > Dict_t;
|
typedef CUtlRBTree< CritEntry_t, short > Dict_t;
|
||||||
Dict_t m_Lookup;
|
Dict_t m_Lookup;
|
||||||
int m_nNumPrefixedContexts; // number of contexts prefixed with kAPPLYTOWORLDPREFIX
|
int m_nNumPrefixedContexts; // number of contexts prefixed with kAPPLYTOWORLDPREFIX
|
||||||
bool m_bOverrideOnAppend;
|
bool m_bOverrideOnAppend;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -457,20 +457,20 @@ namespace ResponseRules
|
|||||||
return ( index >= 0 && index < ((int)(m_Lookup.Count())) );
|
return ( index >= 0 && index < ((int)(m_Lookup.Count())) );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int CriteriaSet::Head() const
|
inline int CriteriaSet::Head() const
|
||||||
{
|
{
|
||||||
return m_Lookup.FirstInorder();
|
return m_Lookup.FirstInorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int CriteriaSet::Next( int i ) const
|
inline int CriteriaSet::Next( int i ) const
|
||||||
{
|
{
|
||||||
return m_Lookup.NextInorder(i);
|
return m_Lookup.NextInorder(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *CriteriaSet::SymbolToStr( const CritSymbol_t &symbol )
|
inline const char *CriteriaSet::SymbolToStr( const CritSymbol_t &symbol )
|
||||||
{
|
{
|
||||||
return sm_CriteriaSymbols.String(symbol);
|
return sm_CriteriaSymbols.String(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,6 +470,16 @@ inline void V_wcscat( INOUT_Z_CAP(cchDest) wchar_t *dest, const wchar_t *src, in
|
|||||||
V_wcsncat( dest, src, cchDest, COPY_ALL_CHARACTERS );
|
V_wcsncat( dest, src, cchDest, COPY_ALL_CHARACTERS );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reentrant strtok
|
||||||
|
inline static char* V_strtok_s( char *str, const char *delimiters, char **context )
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
return strtok_s( str, delimiters, context );
|
||||||
|
#elif POSIX
|
||||||
|
return strtok_r( str, delimiters, context );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// generic unique name helper functions
|
// generic unique name helper functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -366,6 +366,7 @@ namespace ResponseRules
|
|||||||
|
|
||||||
I Insert( const char *pName, const T &element )
|
I Insert( const char *pName, const T &element )
|
||||||
{
|
{
|
||||||
|
extern const char *ResponseCopyString( const char *in );
|
||||||
char const *pString = ResponseCopyString( pName );
|
char const *pString = ResponseCopyString( pName );
|
||||||
unsigned int hash = RR_HASH( pString );
|
unsigned int hash = RR_HASH( pString );
|
||||||
m_ReverseMap.Insert( hash, pString );
|
m_ReverseMap.Insert( hash, pString );
|
||||||
@ -374,6 +375,7 @@ namespace ResponseRules
|
|||||||
|
|
||||||
I Insert( const char *pName )
|
I Insert( const char *pName )
|
||||||
{
|
{
|
||||||
|
extern const char *ResponseCopyString( const char *in );
|
||||||
char const *pString = ResponseCopyString( pName );
|
char const *pString = ResponseCopyString( pName );
|
||||||
unsigned int hash = RR_HASH( pString );
|
unsigned int hash = RR_HASH( pString );
|
||||||
m_ReverseMap.Insert( hash, pString );
|
m_ReverseMap.Insert( hash, pString );
|
||||||
@ -388,7 +390,7 @@ namespace ResponseRules
|
|||||||
|
|
||||||
const char *GetElementName( I i )
|
const char *GetElementName( I i )
|
||||||
{
|
{
|
||||||
int k = Key( i );
|
int k = this->Key( i );
|
||||||
int slot = m_ReverseMap.Find( k );
|
int slot = m_ReverseMap.Find( k );
|
||||||
if ( slot == m_ReverseMap.InvalidIndex() )
|
if ( slot == m_ReverseMap.InvalidIndex() )
|
||||||
return "";
|
return "";
|
||||||
@ -397,7 +399,7 @@ namespace ResponseRules
|
|||||||
|
|
||||||
const char *GetElementName( I i ) const
|
const char *GetElementName( I i ) const
|
||||||
{
|
{
|
||||||
int k = Key( i );
|
int k = this->Key( i );
|
||||||
int slot = m_ReverseMap.Find( k );
|
int slot = m_ReverseMap.Find( k );
|
||||||
if ( slot == m_ReverseMap.InvalidIndex() )
|
if ( slot == m_ReverseMap.InvalidIndex() )
|
||||||
return "";
|
return "";
|
||||||
|
@ -594,7 +594,7 @@ void ConCommand::Dispatch( const CCommand &command )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command without callback!!!
|
// Command without callback!!!
|
||||||
AssertMsg( 0, ( "Encountered ConCommand '%s' without a callback!\n", GetName() ) );
|
AssertMsg( 0, "Encountered ConCommand '%s' without a callback!\n", GetName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user