Response System

From Valve Developer Community
Jump to navigation Jump to search

Stub

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

Introduction

Response System controls what a NPC talks on a certain situation. e.g. It makes Alyx say "Excuse me" when the player pushes her, Citizens greet when they see the player, Vortigaunts tell stories on USE button, etc.

/scripts/talker/response_rules.txt is the base script file for the global Response System that controls Expressive NPCs.

Also an env_speaker entity can specify its own Context rule script. See scripts/talker/terminal_pa.txt for terminal announcement example.

These scripts contain criterion/rule/response definitions. The Response system checks each rule against the set, give it a numeric score based on the rule's set of criteria. Then the system picks one rule with the highest score, dispatch a response that the rule points.

Add your new custom NPC to the Response System

  • Make your NPC derived from NPC_talker
  • Write a new rule script for your NPC
    • See npc_xxx.txt for examples
  • Include the new script in /scripts/talker/response_rules.txt