Response

From Valve Developer Community
(Redirected from Responses)
Jump to: navigation, search
English (en)Translate (Translate)

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/or CNPC_PlayerCompanion class(es), such as citizens, Alyx, Barney, Grigori.
Tip.pngTip:Alyx uses it in Half-Life 2: Episode One, such as in the AlyxStartCombat response.

See also