User:GrampaSwood/ResponseRules

From Team Fortress Wiki
Jump to: navigation, search
For Half-Life 2 we developed something called Response Rules, a system that lets us fine-tune the way characters speak lines of dialog in response to game events that are not completely predictable. In Team Fortress 2, we extended Response Rules to the multiplayer environment for the first time. The Response Rule system works by listing speech concepts in a simple text file; the game code then makes characters attempt to speak when the rules or conditions defined in the text file are met in the game. For instance, when a player reloads his weapon, this signals the Response Rule system that now would be an appropriate time to speak a line about reloading. The Response Rule system checks the state of the world, and matches it to a set of rules that determine the best line of dialog to use for that speech concept. If the player's health is low, he may speak a different reloading line than if he is completely healthy. He could play a special line if he has killed more than two enemies in the last 20 seconds, another set of lines if he's underwater, and so on. Keeping dialog and rules in script files gives the game's writers the ability to add speech to the game without needing any code support.
Eric Smith, Hydro developer commentary

Response rules, also known as the Response System, is a feature in Team Fortress 2 which is responsible for triggering voice lines based on a specific situation in the game world. Response rules consist, as the name suggests, of a Response and a Rule. The "Rule" consists of a criteria, and the accompanying "response". The "Response" consists of one or more scenes, which contain the facial expressions and voice lines. In addition to the situationally-triggered responses, the response system is also responsible for voice commands.

The response rules criteria, as well as the class-specific files, are in tf2_misc_dir.vpk in scripts/talker.

Rule

Main article: Rule

Rules consist of one or more criteria and a response. An example of a rule:

rule PyroTauntPlayerPrimary
{
	criteria ConceptPlayerTaunt IsPyro WeaponIsFlamethrower
	response PyroTauntPrimary
}

This rule is used for the Flame Thrower taunt for the Pyro. It checks if the player is taunting, if the player is a Pyro, and if the weapon is of the tf_weapon_flamethrower type. If all of these are true, then the response PyroTauntPrimary is triggered.

Criteria

Main article: Criteria

Criteria are stored in response_rules.txt and each individual class file. Criteria exist for a wide variety of situations, such as:

  • Playing/not playing as a certain class
  • Aiming at a certain class
  • Aiming at an enemy or aiming at a teammate
  • Killing a certain class
  • Killing any class except a specific one
  • Killing a certain amount of players in a short time
  • Holding/not holding a specific weapon or weapon type (e.g. holding the Eyelander or holding a weapon of the tf_weapon_sword type)
  • Wearing specific cosmetic items (such as the bird heads)
  • Accepting or rejecting a duel
  • Dueling a specific class
  • Various Mann vs. Machine events:
    • Killing a Giant or the bomb carrier
    • Losing or winning a wave
    • Giant picks up a bomb
    • Teammate dying
    • The bomb carrier upgrades its level

Response

Main article: Response

Scene