| TFC .cfg files |
| Gee, seeing as Kntajus did all the work so far, I thought it might be appropriate if I (Brandano) put hand to the keyboard and did some typing myself. The problem was what should I talk about? We don't have custom maps, and the TFC manual already explains almost everything... But there's still the question of the console and how to build CFG files. |
| Now, I am sure that Reaper would be a better candidate to speak about this sort of stuff. What with him being a programmer and everything... I am sure he already has quite a few tips about how to make a perfect config file for your favoured character. On the other hand, he used a strangely perverse keyboard setup, that doesn't really resemble the default TFC settings. I do have my own defects, from this point of view. I jump with my right mouse button, and crouch with the spacebar. (Horror!! Q2 purists will already have a price on my head!) But I am not going to discuss in detail my CFG file, I am just going to give a quick outline of how you go about creating your own (getting it wrong, and making your life miserable). |
| Overview |
| The CFG file is a script that defines which commands are run by which keys (and what your name is, what graphic and sound settings you are running, but this is already another story). These files can be found in your Half-Life\TFC folder, and as you will notice, one CFG file is available for each character. There is also an autoexec.cfg and a config.cfg. These files are "loaded", or better, exec'ed (will explain later) in sequence. That is, first the config.cfg (this is your default HL generated config file), then the autoexec.cfg (which stores the key setup common to all characters), and then the character.cfg (which on a clean installation of TFC is usually empty, apart from an echo command that prompts on the screen "xxxx cfg loaded", where xxxx is the character). There are also CFG files for the default maps, and these are loaded after the autoexec.cfg, so that you might have a custom configuration for a particular map. Very flexible, but better keep it simple for the moment. |
| Usually you just link a key to a command using the command "bind", for example: |
| bind "a" "+moveleft" |
| The command +moveleft moves the character left, strafes left, if you like. The plus sign means that it is a momentary command, and will be executed as long as you keep the "a" key pressed, and that it will stop when you release the "a" key. It isn't quite that straightforward though, and you should be aware that there is a second command, -moveleft, to stop the movement. This will be executed when you release the key, even though you haven't bound it to anything. As a matter of fact, if you bind the -moveleft command to another key, your character will keep on moving left until you press this other key, regardless of the fact that "a" might have been released. Go and have a cup of tea, and read this again afterwards. It makes sense, but it's not very immediate :-) |
| A simpler example would be: bind "F5" "snapshot", and the reason why this is not a momentary command should be obvious. The nice thing about CFG files is that a command doesn't need to be linked to the same key for the length of the game. This is thanks to the command "alias" , which is the most important of them all. An alias command allows you to define a new command made up of several other commands. So, if I wanted to automatically take a snapshot every time I move left (why, oh WHY should I want to do that.... oh, never mind) I only have to define a new command as: |
|
alias +snapmvleft "snapshot;+moveleft" alias -snapmvleft "-moveleft" |
| As you can see, I had to define 2 commands, the 2 halves of a momentary command. That is because the +moveleft command is a momentary one, and if I had only included +moveleft in the snapmvleft command, I would have ended up with my character continually drifting to the left from the first time I use the command, while I will have a snapshot every time I use the command again. As it is, it will take a snapshot every time I execute the command, and it will move left WHILE I am executing the command. Just to ram it home: If I bind +snapmvleft to the "a" key, and press "a" in the game, I will get a SINGLE snapshot, and I will keep moving left as long as I keep the "a" key pressed. As I release it -snapmvleft will be executed, and consequently -moveleft, and this will stop the motion. Another cup of tea please.... |
| "Dynamic" Configuration |
| So, what if I want to change a command while the game is running? Say you want a key to do 2 things in sequence, like sending 2 parts of a message. To do this you can use the alias command to define a new macro sequence like this: |
|
alias wddch1 "say Why did the chicken cross the road?;bind w wddch2" alias wddch2 "say To get to the other side!;bind w wddch1" bind "w" wddch1 |
| When you press "w" for the first time, it's bound to the command wddch1, which will send a message with the first part of the dumbest joke on earth, and will bind "w" to wddch2. As you press "w" for the second time you will execute the command wddch2, which will say the second part, and make everyone very depressed. Finally, it will also bind "w" to wddch1, restarting the cycle. Note that I had to bind "w" to wddch1 to start with, otherwise I can press W as much as I like, but it won't do anything. Also note that the bind statement in wddch2 could perfectly well be to a command wddch3, and so on, so you can have a single key selecting a whole series of commands in sequence. But you have to remember to bind the "w" key back to the first command in the list, otherwise once you reach the end of the sequence you are stuck, you will only execute that last command with that button thereafter. |
| Setting a "modifier" |
| Another macro you might want to set up is to have a key as a modifier, so that the same button might execute 2 different commands depending on the state of another button. This is easily done by linking a momentary aliased command to that button, like this: |
|
alias +state1 "bind a +moveleft;bind w +forward..." alias -state1 "bind a invprev;bind w +moveup..." |
| and then assigning the +state1 command to the modifier button, like this: |
| bind "ALT" "+state1" |
| While "ALT" is pressed the first list of binds holds true, while it's released, the second list does. This might not be what you really need, though. You might actually want to use a single button to cycle between completely different settings. This is a combination of the last 2 examples. You just need to create a series of non-momentary commands, and cycle through them by binding each time the modifier key with the next command, like this: |
|
alias state1 "bind a +moveleft; bind w +forward...;bind ALT state2" alias state2 "bind a invprev; bind w +moveup...;bind ALT state3" alias state3 "bind a invnext;.......;bind ALT state1" bind "ALT" "state1" |
| Which by now, even considering your headache, should pretty much explain itself. You shouldn't drink so much tea, m8. |
| "exec"ing a file |
| There's yet another way... Remember when at the start I said that exec'ed was a more appropriate way of describing the loading of a CFG file? There's a wonderful command called "exec". If you type in the console exec whatevernameulike.cfg, that CFG file will be loaded, or better exec'ed. Naturally, you can bind a key to a custom exec file, that you might want to use across a few characters without having to copy the entire thing in every character.cfg, and that doesn't necessarily run for ALL of the characters, as would happen if you were to put that script in your autoexec.cfg. So you can either include a line in your character.cfg reading: |
| exec whatevernameulike.cfg |
|
Or bind a key to this command, and naturally you can include this sort of binding in any of the macro
demonstrated above. A use for this might be to cycle between different sound and graphic settings (once we
figure out what all the commands do). So far I haven't mentioned what each command does. I just don't have
enough time, so I'll just point to a page that holds a pretty comprehensive list:
Console Commands. There's also a download available, HLDS Toolz, from www.planethalflife.com. Among other things, this has a CFG file editor within it. You can find it here. |
| TDO_Brandano |