Response: Difference between revisions
Jump to navigation
Jump to search

No edit summary |
(Added weapondelay - rarely used but functional response option) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
Response specifies a | {{lang|Response}} | ||
A '''response''' specifies how to act based on a rule. A response consists of a weighted set of options and can recursively reference. | |||
==Example== | |||
For example, this is a response "AlyxShot" from <code>scripts/talker/npc_alyx.txt</code>. | For example, this is a response "AlyxShot" from <code>scripts/talker/npc_alyx.txt</code>. | ||
Line 18: | Line 18: | ||
When this response is chosen by a rule AlyxShot, one of these .vcd will be played. | When this response is chosen by a rule AlyxShot, one of these .vcd will be played. | ||
==Types== | |||
Scene is not the only response type. There are also four other types. | Scene is not the only response type. There are also four other types. | ||
*speak: play an entry in sounds.txt. See [[Soundscripts]] | *speak: play an entry in sounds.txt. See [[Soundscripts]] | ||
Line 26: | Line 25: | ||
*response: reference to another response group by name | *response: reference to another response group by name | ||
*print: print the text in developer 2 (for placeholder responses) | *print: print the text in developer 2 (for placeholder responses) | ||
==Definition== | |||
===Single Line=== | |||
Single | |||
<pre> | <pre> | ||
response <responsegroupname> [nodelay | defaultdelay | delay interval ] [speakonce] [noscene] [odds nnn] [respeakdelay interval] [soundelvel "SNDLVL_xxx"] responsetype parameters | response <responsegroupname> [nodelay | defaultdelay | delay interval ] [speakonce] [noscene] [odds nnn] [respeakdelay interval] [soundelvel "SNDLVL_xxx"] responsetype parameters | ||
</pre> | </pre> | ||
===Multiple Lines=== | |||
<pre> | <pre> | ||
response <responsegroupname> | response <responsegroupname> | ||
Line 46: | Line 44: | ||
</pre> | </pre> | ||
==Options== | ===Options=== | ||
*nodelay = an additional delay of 0 after speaking | *nodelay = an additional delay of 0 after speaking | ||
*defaultdelay = an additional delay of 2.8 to 3.2 seconds after speaking | *defaultdelay = an additional delay of 2.8 to 3.2 seconds after speaking | ||
Line 57: | Line 55: | ||
*weight = if there are multiple responses, this is a selection weighting so that certain responses are favored over others in the group (default 1) | *weight = if there are multiple responses, this is a selection weighting so that certain responses are favored over others in the group (default 1) | ||
*displayfirst/displaylast : this should be the first/last item selected (ignores weight) | *displayfirst/displaylast : this should be the first/last item selected (ignores weight) | ||
*weapondelay = pause shooting for the specified duration so the response can be clearly heard. Only works on actors descending from the <code>CAI_PlayerAlly</code> and/or <code>CNPC_PlayerCompanion</code> class(es), such as [[Npc_citizen|citizens]], [[Alyx]], [[Barney]], [[Grigori]]. | |||
:{{tip|Alyx uses it in {{hl2ep1|1}}, such as in the <code>AlyxStartCombat</code> response.}} | |||
[[category:AI]] | ==See also== | ||
*[[Response System]] | |||
[[category:AI Programming]] |
Latest revision as of 05:59, 15 September 2024


A response specifies how to act based on a rule. A response consists of a weighted set of options and can recursively reference.
Example
For example, this is a response "AlyxShot" from scripts/talker/npc_alyx.txt
.
response AlyxShot { scene "scenes/npc/Alyx/gasp02.vcd" scene "scenes/npc/Alyx/gasp03.vcd" scene "scenes/npc/Alyx/hurt04.vcd" scene "scenes/npc/Alyx/hurt05.vcd" scene "scenes/npc/Alyx/hurt06.vcd" scene "scenes/npc/Alyx/hurt08.vcd" scene "scenes/npc/Alyx/uggh01.vcd" }
When this response is chosen by a rule AlyxShot, one of these .vcd will be played.
Types
Scene is not the only response type. There are also four other types.
- speak: play an entry in sounds.txt. See Soundscripts
- sentence: play a sentence from sentences.txt
- scene: play a .vcd file. See Choreography Implementation for more information.
- response: reference to another response group by name
- print: print the text in developer 2 (for placeholder responses)
Definition
Single Line
response <responsegroupname> [nodelay | defaultdelay | delay interval ] [speakonce] [noscene] [odds nnn] [respeakdelay interval] [soundelvel "SNDLVL_xxx"] responsetype parameters
Multiple Lines
response <responsegroupname> { [permitrepeats] ; optional parameter, by default we visit all responses in group before repeating any [sequential] ; optional parameter, by default we randomly choose responses, but with this we walk through the list starting at the first and going to the last [norepeat] ; Once we've run through all of the entries, disable the response group responsetype1 parameters1 [nodelay | defaultdelay | delay interval ] [speakonce] [odds nnn] [respeakdelay interval] [soundelvel "SNDLVL_xxx"] [displayfirst] [ displaylast ] weight nnn responsetype2 parameters2 [nodelay | defaultdelay | delay interval ] [speakonce] [odds nnn] [respeakdelay interval] [soundelvel "SNDLVL_xxx"] [displayfirst] [ displaylast ] weight nnn etc. }
Options
- nodelay = an additional delay of 0 after speaking
- defaultdelay = an additional delay of 2.8 to 3.2 seconds after speaking
- delay interval = an additional delay based on a random sample from the interval after speaking
- speakonce = don't use this response more than one time (default off)
- noscene = For an NPC, play the sound immediately using EmitSound, don't play it through the scene system. Good for playing sounds on dying or dead NPCs.
- odds = if this response is selected, if odds < 100, then there is a chance that nothing will be said (default 100)
- respeakdelay = don't use this response again for at least this long (default 0)
- soundlevel = use this soundlevel for the speak/sentence (default SNDLVL_TALKING)
- weight = if there are multiple responses, this is a selection weighting so that certain responses are favored over others in the group (default 1)
- displayfirst/displaylast : this should be the first/last item selected (ignores weight)
- weapondelay = pause shooting for the specified duration so the response can be clearly heard. Only works on actors descending from the
CAI_PlayerAlly
and/orCNPC_PlayerCompanion
class(es), such as citizens, Alyx, Barney, Grigori.
Tip:Alyx uses it in Half-Life 2: Episode One, such as in the
AlyxStartCombat
response.