Concept: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Le Glaconus (talk | contribs) (formatting) |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LanguageBar|title = Concept}} | ||
{{stub}} | |||
A '''concept''' is high-level statement that the code is trying to convey, such as say hello ({{mono|TLK_HELLO}}), answer some question ({{mono|TLK_ANSWER}}), call for help ({{mono|TLK_HELP_ME}}), etc. | |||
You can command a NPC to speak based on a concept by using <code>Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )</code> method. This is defined in <code>AI_Speech.cpp</code>. | You can command a NPC to speak based on a concept by using <code>Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )</code> method. This is defined in <code>AI_Speech.cpp</code>. | ||
<source lang=cpp> | |||
< | bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ ) | ||
{ | { | ||
AI_Response *result = SpeakFindResponse( concept, modifiers ); | AI_Response *result = SpeakFindResponse( concept, modifiers ); | ||
Line 15: | Line 15: | ||
} | } | ||
SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)\n", STRING(GetOuter()->GetEntityName()), GetOuter(), concept, gpGlobals->curtime ); | SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)\n", STRING(GetOuter()->GetEntityName()), | ||
GetOuter(), concept, gpGlobals->curtime ); | |||
bool spoke = SpeakDispatchResponse( concept, result ); | bool spoke = SpeakDispatchResponse( concept, result ); | ||
return spoke; | return spoke; | ||
} | } | ||
</ | </source> | ||
It tries to find a response for the concept from [[Response System]] scripts. Then if it finds one, tries to dispatch it. | It tries to find a response for the concept from [[Response System]] scripts. Then if it finds one, tries to dispatch it. | ||
<code>NPC_talker.cpp</code> is a good example integrating concept speaks within [[tasks]] and [[schedules]]. If you want to make a custom NPC that talks, this would be the best place to start. | <code>NPC_talker.cpp</code> is a good example integrating concept speaks within [[tasks]] and [[schedules]]. If you want to make a custom NPC that talks, this would be the best place to start. | ||
You can also make a NPC choose a response via "DispatchResponse" entity input. | You can also make a NPC choose a response via "DispatchResponse" entity input. | ||
==See also== | |||
== | * [[Concept list]] | ||
[[Category:AI Programming]] | |||
Latest revision as of 02:09, 5 June 2025
A concept is high-level statement that the code is trying to convey, such as say hello (TLK_HELLO), answer some question (TLK_ANSWER), call for help (TLK_HELP_ME), etc.
You can command a NPC to speak based on a concept by using Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )
method. This is defined in AI_Speech.cpp
.
bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )
{
AI_Response *result = SpeakFindResponse( concept, modifiers );
if ( !result )
{
return false;
}
SpeechMsg( GetOuter(), "%s (%x) spoke %s (%f)\n", STRING(GetOuter()->GetEntityName()),
GetOuter(), concept, gpGlobals->curtime );
bool spoke = SpeakDispatchResponse( concept, result );
return spoke;
}
It tries to find a response for the concept from Response System scripts. Then if it finds one, tries to dispatch it.
NPC_talker.cpp
is a good example integrating concept speaks within tasks and schedules. If you want to make a custom NPC that talks, this would be the best place to start.
You can also make a NPC choose a response via "DispatchResponse" entity input.