Concept: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (recategorize)
mNo edit summary
Line 1: Line 1:
{{stub}}[[Category:AI Programming]]
{{stub}}[[Category:AI Programming]]
 
A '''concept''' is high level state that the code is trying to convey, such as say hello(TLK_HELLO), answer some question(TLK_ANSWER), or call for help(TLK_HELP_ME), etc.  
Concept is high level state that the code is trying to convey, such as say hello(TLK_HELLO), answer some question(TLK_ANSWER), or call for help(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>.


<pre>bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )
<pre>bool CAI_Expresser::Speak( AIConcept_t concept, const char *modifiers /*= NULL*/ )
Line 21: Line 18:
}
}
</pre>
</pre>


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==
* [[Concept list]]
===ai_behavior_lead.h===
 
ai_behavior_lead.h
 
TLK_LEAD_START
 
TLK_LEAD_ARRIVAL
 
TLK_LEAD_SUCCESS
 
lead_fail
 
TLK_LEAD_COMINGBACK
 
TLK_LEAD_CATCHUP
 
TLK_LEAD_RETRIEVE
 
TLK_LEAD_ATTRACTPLAYER
 
TLK_LEAD_WAITOVER
 
TLK_LEAD_MISSING_WEAPON
 
===ai_playerally.h===
 
TLK_ANSWER
 
TLK_QUESTION
 
TLK_IDLE
 
TLK_STARE
 
TLK_USE
 
TLK_STARTFOLLOW
 
TLK_STOPFOLLOW
 
TLK_JOINPLAYER
 
TLK_STOP
 
TLK_NOSHOOT
 
TLK_HELLO
 
TLK_PHELLO
 
TLK_PIDLE
 
TLK_PQUESTION
 
TLK_PLHURT1
 
TLK_PLHURT2
 
TLK_PLHURT3
 
TLK_PLPUSH
 
TLK_PLRELOAD
 
TLK_SMELL
 
TLK_SHOT
 
TLK_WOUND
 
TLK_MORTAL
 
TLK_DANGER
 
TLK_SEE_COMBINE
 
TLK_ENEMY_DEAD
 
TLK_SELECTED // selected by player in command mode.
 
TLK_COMMANDED // received orders from player in command mode
 
TLK_COMMAND_FAILED
 
TLK_BETRAYED // player killed an ally in front of me.
 
TLK_ALLY_KILLED // witnessed an ally die some other way.
 
TLK_ATTACKING // about to fire my weapon at a target
 
TLK_HEAL // healing someone
 
TLK_GIVEAMMO // giving ammo to someone
 
TLK_DEATH // Death rattle
 
TLK_HELP_ME // call out to the player for help
 
TLK_PLYR_PHYSATK // Player's attacked me with a thrown physics object
 
TLK_ANSWER_VORT
 
TLK_ANSWER_CIT
 
TLK_QUESTION_VORT
 
TLK_QUESTION_CIT
 
TLK_NEWWEAPON
 
TLK_PLDEAD
 
TLK_HIDEANDRELOAD
 
TLK_STARTCOMBAT
 
TLK_WATCHOUT
 
 
TLK_RESUME // resume is as I was saying... or anyhow...
 
 
TLK_TGSTAYPUT// tourguide stuff
 
TLK_TGFIND
 
TLK_TGSEEK
 
TLK_TGLOSTYOU
 
TLK_TGCATCHUP
 
TLK_TGENDTOUR

Revision as of 18:53, 10 June 2006

Stub

This article or section is a stub. You can help by expanding it.

A concept is high level state that the code is trying to convey, such as say hello(TLK_HELLO), answer some question(TLK_ANSWER), or 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.

See Also