Technical information on manipulating the TF2 Response System.
This plugin uses TF2's own Response system to work.
Inside tf2_misc_dir.vpk is the directory scripts/talker/ with has a number of .txt files.
These text files control the Valve response system.
To get characters to say their in-game lines, you can look up the response concept you want it to play and figure out what contexts have to be in place before it will work.
This plugin uses the SpeakResponseConcept input instead of DispatchResponse. This is because DispatchResponse does not appear to work correctly in TF2.
Here's an example of how to get a specific response working:
For this, I chose to play the Medic's Melee Dare. The first step is to open up scripts/talker/medic.txt
and search for the word Dare. Ignore the first one you find, as it's the Duel version. Eventually, you'll find this:
criteria ConceptPlayerBattleCry IsWeaponMelee IsMedic IsCrosshairEnemy
The Rule is the important one. See the "criteria" line there? Everything after criteria is a space separate list of contexts defined in response_rules.txt
So, open up scripts/talker/response_rules.txt and look for ConceptPlayerBattleCry
criterion "ConceptPlayerBattleCry" "Concept" "TLK_PLAYER_BATTLECRY" required
The second argument (Concept
) is the rule type. Concepts are special and we'll be sending it to SpeakResponseConcept later. The third ("TLK_PLAYER_BATTLECRY") is its value. The last argument tells us this is required (but pretty much all criteria are).
Now, unfortunately IsMedic isn't really overridable, as the game resets it too quickly for us to override it.
The above may not be true. However, when you define two contexts of the same type, only the first one applies. However, you can remove a context like this:
You can remove all existing contexts like this:
Lets take a look at it anyway. Here's the definitions for this context:
criterion "IsMedic" "playerclass" "Medic" "required"
This context isn't a Concept, meaning that it could (in theory) be set using AddContext. We'll talk more about AddContext in a moment.
Lets look at the last two contexts: IsWeaponMelee and IsCrosshairEnemy
criterion "IsWeaponMelee" "weaponmode" "melee" required
criterion "IsCrossHairEnemy" "crosshair_enemy" "Yes" "required"
Remember what I said about AddContext? This is where you want it. It takes a single string argument, which is in format key:value. You can set these contexts by doing this:
Once you have the contexts set, it's time to call our Concept whose name we saw earlier... and remember to clear the contexts again afterwards.
I haven't tested this code, so the melee weapon context may be reset too quickly for us to fake it using this method... YMMV.
Edit: My tf2-data respository contains the talker files
, which did not change in the Gun Mettle Update.