Entropy : Zero 2

Entropy : Zero 2

Not enough ratings
Custom NPC Responses
By 1upD
This guide is intended to provide references and information for using the response system in Entropy : Zero 2 addons.
   
Award
Favorite
Favorited
Unfavorite
About this guide
This guide is intended to provide references and information for using the response system in Entropy : Zero 2 (EZ2) addons. It is not a step by step guide, but rather a collection of information to help direct modders towards examples of the NPC response system.

Some of the information in this guide may be applicable to Source engine games and mods outside of Entropy : Zero 2. If you are referring to this guide while working outside of EZ2, please take it with a grain of salt. Certain parts of the guide may refer to features only available in Mapbase mods or in EZ2.

It is assumed that you already know how to make maps using Hammer editor and that you understand the basics of file storage systems and editing text files in a text editor.

Requirements
  • Hammer configured to map for Entropy : Zero 2
  • Knowledge of how to make maps with Hammer
  • GCFScape (or another tool which can open VPK files)
Understanding the Response System
The best resource for information about the response system is the Valve Developer Community (VDC) wiki. Please refer to the VDC page for the Response System to get a detailed breakdown.
https://developer.valvesoftware.com/wiki/Response_System

The response system is a feature of the Source engine used by NPCs to select lines of dialogue dynamically during gameplay.

The wiki breaks down the response system into four core pillars:


  • Criteria Set
    • The criteria set is a set of keys and values for a given speech attempt that are matched on by rules.
    • Response scripts define their own criteria rules which match on criteria in the criteria set.
    • "Contexts" are a type of criteria saved on an NPC that are added to any speech attempt's criteria set.
    • Read more about "Contexts" on the VDC page: https://developer.valvesoftware.com/wiki/Context
    • "Criterion" is the singular form of criteria. Named criteria rules are defined in the scripts with the keyword "criterion"
    • Read more on the VDC page for "Criterion" to learn more about criteria rules:
      https://developer.valvesoftware.com/wiki/Criterion
  • Concepts
    • VDC defines a concept as "a string that represents the high-level reason for the character's speech attempt."
    • A concept is a special criteria in the game's code that is dispatched when a character tries to speak with the response system.
    • It is matched in response rules the same as any other criteria.
    • You can also dispatch custom concepts from a map using the "DispatchResponse" input on an NPC.
    • Read more here:
      https://developer.valvesoftware.com/wiki/Concept
    • The VDC also has an incomplete list of contexts to use as reference:
      https://developer.valvesoftware.com/wiki/Concept_list
  • Responses
    • Responses are a line of dialogue, a scene, or another action for the NPC to play if a rule is matched for it.
    • Responses can be grouped with response groups.
  • Rules
    • Rules have a list of criteria to match against and a response to use if they match.
    • Rules can also have a few other parameters that control when they match
    • In the visualization below, you can imagine the response rules as a table with columns for concept, criteria rule and response.
      • In reality there will be many criteria rules, not just the one criterion rule pictured.


    The wiki goes into more detail about each of these pillars.

    For further reading, the GDC 2012 slides from Elan Ruskin's presentation about the response system give a good visual representation.
    https://steamhost.cn/cdn_akamai_steamstatic_com/apps/valve/2012/GDC2012_Ruskin_Elan_DynamicDialog.pdf
Response System Inputs
There are a few inputs defined on NPCs that allow you to control the response system.

DispatchResponse - The DispatchResponse input will force an NPC to try to speak a concept supplied in the parameter. You can use DispatchResponse to dispatch custom concepts that do not exist in the code, or to force an NPC to use a concept as though they are responding.


Read more here:
https://developer.valvesoftware.com/wiki/Concept

AddContext - If you call the "AddContext" input and pass a paramter with a string in the format "<key>:<value>", it will add that context key and value to the NPC's contexts. Contexts are special criteria saved on a particular NPC that will be added to the criteria set for every concept they speak.


Read more here:
https://developer.valvesoftware.com/wiki/Context
Classname Context
Mapbase adds the option to override the "classname" criteria an NPC uses in its criteria sets with a custom context. This is useful because it allows mappers to change which response rules apply to which NPCs. Setting the classname context with "AddContext" allows you to tell a metrocop that they are a Combine soldier, or a citizen that they are a metrocop. This also means that you can change the player's classname from player - which represents Bad Cop in EZ2 - to a new classname that you create.
Talker Files
The response system is configured by scripts in text files called "talker" files. Talker files for the base game are located in scripts/talker/ and can be found in EntropyZero2/entropyzero2/ez2/ez2_dir.vpk.


Talker files have configuration blocks to define criteria rules, responses, and response rules.

For an example, here is a snippet of the player.txt talker file for the rule and response BadCopManyEnemies. (I have also copied all the relevant criteria rule definitions for clarity)

// Criteria defintions criterion "IsBadCop" "classname" "player" required criterion "ConceptManyEnemies" "Concept" "TLK_MANY_ENEMIES" "required" criterion "EnemyVisible" "enemy_visible" "1" required criterion "JustStartedCombat" "combat_length" "<5.0" required criterion "HaventRemarkedDamageRecently" "damage_remarked" "!=1" required //============================================================================================================ // Many enemies/mobbed //============================================================================================================ response "BadCopManyEnemies" { norepeat speak "bc_manyenemies_1" odds 20 respeakdelay 500 speak "bc_manyenemies_2" odds 20 respeakdelay 500 speak "bc_manyenemies_3" odds 20 respeakdelay 500 speak "bc_taunt_gen_6" odds 20 respeakdelay 500 } rule BadCopManyEnemies { criteria IsBadCop ConceptManyEnemies EnemyVisible JustStartedCombat HaventRemarkedDamageRecently healthfrac ">0.7" required response BadCopManyEnemies }

In the above example, several named criteria rules like IsBadCop, ConceptManyEnemies, and EnemyVisible are defined with the "criterion" blocks. Once defined, these named criteria rules can be used in a rule in the "criteria" list. The rule will only match if all of the criteria rules with the "required" argument are true.

The response "BadCopManyEnemies" has the option "norepeat", which means once each of the possible responses in the group have been played, it will not be selected again. After that, it has a few different lines that play with the "speak" option. The first argument to speak is the name of a soundscript to play from the NPC that is responding. Each speak option also has an argument "odds" which is a percentage likelihood for the line to play, and an argument "respeakdelay" that will prevent the same concept from being dispatched for a number of seconds. All the arguments after the soundscript name are optional.

The rule "BadCopManyEnemies" is a list of criteria to match and selects the response group also named "BadCopManyEnemies".
Level Specific Files
If you are trying to add new responses for a custom level to be published in a workshop addon, you will need to use a level specific talker file to load the new responses in your addon without overwriting existing files.

In Mapbase mods, the game will always load an extra talker file at the path maps/<mapname>_talker.txt. You can create a file in your addons' "maps" directory and name it with the name of your map followed by _talker.txt. It must match the BSP name exactly (aside from the extension) with "_talker.txt" appended.

Read more here on Mapbase's GitHub wiki: https://github.com/mapbase-source/source-sdk-2013/wiki/Map-Specific-Scripts

The next section of the guide will demonstrate a map specific talker file for the Uprising Plaza Demo addon on the workshop.
Workshop Map Specific Talker File Example
Here is an example of a talker file from the workshop addon "E:Z - Uprising Demo: PLAZA STANDOFF".

You can play the addon here: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2826357973

The file is located in maps/upr_02_03_talker.txt, so it will be loaded by the game in the map upr_02_03.


Please also note the level specific soundscripts which are used in the talker file.


For a more detailed reference, feel free to subscribe to the addon and find the scripts at: Steam\steamapps\workshop\content\1583720\2826357973\maps

Here is an abridged copy of the talker file:

//============================================================================================================ //============================================================================================================ // npc_UpCop concepts and criteria //============================================================================================================ // Concepts criterion "ConceptTalkUpCopDie" "Concept" "TLK_DEATH" required criterion "ConceptTalkUpCopPain" "Concept" "TLK_WOUND" required criterion "IsUpCop" "classname" "npc_ezu_UpCop" "required" //============================================================================================================ // npc_metropolice basic sounds //============================================================================================================ response "UpCopPain" { sentence "METROPOLICE_PAIN" noscene } rule UpCopPain { criteria IsUpCop ConceptTalkUpCopPain PainSoundsAllowed response UpCopPain } response "UpCopDie" { speak "NPC_MetroPolice.Die" noscene } rule UpCopDie { criteria IsUpCop ConceptTalkUpCopDie DeathSoundsAllowed response UpCopDie } response "UpCopKill" { speak "player.figures" respeakdelay 7 speak "player.chuckle" respeakdelay 7 speak "player.sentencedelivered" respeakdelay 7 speak "player.suspectexpired" respeakdelay 7 speak "player.finalveredict" respeakdelay 7 speak "player.assaultpointsecured" respeakdelay 7 speak "player.gotohell" respeakdelay 7 speak "player.thatsenough" respeakdelay 7 } rule UpCopKill { criteria IsUpCop ConceptEnemyDead response UpCopKill } response "UpCopUseRebelOrderSurrender" { speak "player.stopwhining" speak "player.moveit2" speak "player.cmon" speak "player.getoutofhere" } rule UpCopUseRebelOrderSurrender { criteria IsUpCop ConceptTalkUse IsOrderSurrender EnemyVisible EnemyIsNotTurret response UpCopUseRebelOrderSurrender } response "UpCopHearDanger" { speak "player.moveit" } rule UpCopHearGrenade { criteria IsUpCop ConceptTalkDanger SoundIsGrenade response UpCopHearDanger }

This is a short snippet of the level sounds file, maps/upr_02_03_level_sounds.txt. These are level sounds loaded in the map upr_02_03. Notice that these sounds are some of the ones referenced in the "speak" command.

player.privacy { channel CHAN_VOICE volume VOL_NORM pitch PITCH_NORM soundlevel SNDLVL_NONE wave upr_02_03/player_taunts/ez2_pt_vocal_figures.wav } player.chuckle { channel CHAN_VOICE volume VOL_NORM pitch PITCH_NORM soundlevel SNDLVL_NONE wave upr_02_03/player_taunts/upr_pt_chuckle.wav } player.sentencedelivered { channel CHAN_VOICE volume VOL_NORM pitch PITCH_NORM soundlevel SNDLVL_NONE wave upr_02_03/player_taunts/upr_pt_sentencedelivered.wav }
Debugging response rules
There are console commands which can be used to troubleshoot whether or not response rules are working as intended.

Please see the complete command table on the VDC here: https://developer.valvesoftware.com/wiki/List_of_Half-Life_2_console_commands_and_variables

Command
Description
rr_debug_qa
Set to 1 to see debug related to the Question & Answer system used to create conversations between allied NPCs.
rr_debugresponses
Show verbose matching output (1 for simple, 2 for rule scoring). If set to 3, it will only show response success/failure for np
rr_debugrule
If set to the name of the rule, that rule's score will be shown whenever a concept is passed into the response rules system.
rr_dumpresponses
Dump all response_rules.txt and rules (requires restart)
rr_reloadresponsesystems
Reload all response system scripts.

Response system logging
Set rr_debugresponses to 1 to see information about all responses logged to the console. It will show the criteria set for each response. This is very useful to see which criteria are available for a particular concept.

Hot reloading talker files

If you make changes to your level specific talker file while in-game, use the command "rr_reloadresponsesystem" to load your changes without restarting the game.
1 Comments
xdxdxd 28 May, 2024 @ 3:42am 
Absolute peak