Mini-mod tutorial

From Valve Developer Community
(Redirected from Mini-mod tute)
Jump to: navigation, search
English (en)Français (fr)Русский (ru)中文 (zh)Translate (Translate)

Introduction

Modifying the gameplay of a Source game such as Half-Life 2 does not have to require knowledge of programming or Source-modding. This short tutorial is going to teach you how to use configuration files to modify gameplay. Configuration files are simply files which contain a list of instructions for the Source engine to perform. The instructions are developer console commands, so therefore anything that can be typed in the console can be placed in a configuration file.

With console commands, you can change anything from the maximum ammunition capacity of a weapon to the damage that an antlion-guard deals when it charges into you. A full list of console commands is available here, but remember that some listed there are only applicable to Half-Life 2 and its episodic sequels. If a command in the list has Yes written in the Cheat column, then you must add sv_cheats 1 to the beginning of your config file before you can use it.

Creating the config

Open Notepad or a text editor of your choice, and write some console commands of your choice, separated by new lines. To perform the aforementioned tasks involving ammunition and antlion-guards, you would enter these two commands:

sk_max_crossbow 30
sk_antlionguard_dmg_charge 60

There are obviously many more console variables to choose from, but this serves as an example.

Using config files, you can also bind keys to actions. For example, if you wanted to create a key to toggle a 'bullet-time' mode, you would enter this (it requires cheats to be enabled at the beginning of the config file):

sv_cheats 1
alias "BulletTimeOn" "host_timescale 0.5; mat_yuv 1; switchToOff"
alias "BulletTimeOff" "host_timescale 1; mat_yuv 0; switchToOn"
alias "switchToOff" "bind tab BulletTimeOff"
alias "switchToOn" "bind tab BulletTimeOn"
switchToOn

With this config executed, you could press the Tab key to slow down the game and create a monochrome effect on the screen, and press it again to revert the game to normal. To find out more about how that toggle works (it seems quite complicated but it isn't), see alias and bind.


Saving the config

When saving your configuration file, remember to always have the 'Save as type' drop-down box set to 'All file types'. Save your config as anything you want, but remember the .cfg extension. If you were creating a config for Half-Life 2, you would save it here:

WhereSteamIs\steamapps\YourUsername\half-life 2\hl2\cfg


Running the config in-game

To execute this configuration in-game, you would open the developer console and type this:

exec CONFIGNAME.cfg

This will only work if you have saved your configuration in the correct directory (see the above section). With any luck, the changes made in your config file will have taken place.


Removing the config

There is one problem, however. After running the config, your commands will still be loaded the next time you play the game, on any map. To work around this, create another config file called uninstall.cfg (or whatever you want) and in that file, unbind all the keys that you bound in your config. To do this, use this command for each key:

unbind KEY

So, for example, if you bound the arrow keys and Tab, you would put this in the uninstall config:

unbind tab
unbind uparrow
unbind downarrow
unbind leftarrow
unbind rightarrow


Configuration for a particular map

If you want your config to automatically run with a map of your creation, simply place a logic_auto and a point_clientcommand (or point_servercommand for a multiplayer game) in the map. Name the point_clientcommand/point_servercommmand 'console'. Add this output to the logic_auto:

Output: OnMapSpawn
Target entity: console
Input: Command
Parameter: exec YOURCONFIG

When distributing your map, remember to include the cfg files with it. Also include instructions on how to install the configs, and how to use the uninstaller.

Alternative (for per-map configs)

If you wanted to adjust settings for your map like you can in a config file, but you didn't want to have to bother with installing/uninstalling config files, you could use logic_auto and point_clientcommand/point_servercommand alone. Simply use the output shown in the previous section, but change the parameter to the command of your choice.