Difference between revisions of "User:Zoolooman/Scripting"

From Team Fortress Wiki
Jump to: navigation, search
(Script page idea.)
 
m (Resources)
Line 87: Line 87:
 
*http://forums.steampowered.com/forums/showthread.php?t=709568 - AciD's guide.  Covers basics.
 
*http://forums.steampowered.com/forums/showthread.php?t=709568 - AciD's guide.  Covers basics.
 
*http://warriornation.net/Forum/showthread.php?t=568008 - shatteredsword's guide.  Covers some of the more advanced scripting tricks.
 
*http://warriornation.net/Forum/showthread.php?t=568008 - shatteredsword's guide.  Covers some of the more advanced scripting tricks.
*http://www.fpsbanana.com/scripts/games/297 - The scripting section with hundreds of script examples, some simple, some incredibly complex.
+
*http://www.fpsbanana.com/scripts/games/297 - The scripting section with hundreds of TF2 script examples.
 
*[[Bindable keys]] - A List of the keys that are bindable and their scripting names.
 
*[[Bindable keys]] - A List of the keys that are bindable and their scripting names.
  
 
[[Category:Scripts]]
 
[[Category:Scripts]]

Revision as of 01:20, 21 October 2010

Scripting is the use of configuration files to create new keybinds and aliases automating complex behaviors and console commands.

  • Keybinds connect a key to a certain console command, such as choosing a weapon slot or saying prewritten text in chat.
  • Aliases build new commands by executing a series of console commands whenever they are used. An alias might define jumping and crouching as a single jump-crouch command, which can then be bound to a key.

Basic Scripting Files

Team Fortress 2 automatically reads several game files and executes whatever keybinds and aliases are present. Here is the list of those files:

  • config.cfg - This is the default config file, which the game edits whenever you use the in-game menus to bind keys or change video settings. While editing the file is safe, it's simpler to leave it alone.
  • autoexec.cfg - This is the default config file for executing custom keybinds and aliases. You may put your keybinds directly into this file, but it is often easier to create separate .cfg files for different scripts, which you then execute inside this file.
  • <class>.cfg - Each class has a config file which automatically runs whenever you switch to that class. You may put your keybinds directly into this file, but it is often easier to create separate .cfg files for different scripts, which you then execute inside these files.

Syntax

Here is a list of syntactic rules:

  • For any keybind or alias to work, you need to follow this format:
command <argument1> <argument2>
  • command is the type of script you're making. You have two choices:
  • bind - Used to bind commands to a particular key.
  • alias - Used to execute commands when the alias is executed.
  • <argument1> is either the key being bound or the name of the alias being created.
  • <argument2> is either the command being bound or the commands executed by the alias.
  • To run multiple commands, you must put the entire argument in quotation marks and separate the commands with semicolons, like so:
alias "spraynpray" "+attack; wait 500; -attack"
bind "mouse3" "spraynpray"
  • When executed, the alias starts firing the player's weapon, continues for 500 physics frames or roughly five seconds, and then stops firing. The alias is keybound to execute when you press the middle mouse button.
  • If you want a command to be continuously applied, you place a + in front of it, such as +duck. If you want it to end, you place a - in front of it, such as -duck.
  • If a command or alias is bound to a key, a + tells the game to run the command as long as the key is held. Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.
  • If you want the game to delay for a period of time during an alias, or if you want avoid client crashes by executing commands too quickly, use the wait command. It tells the game to wait one physics frame, something like a full turn in the TF2 rules, before continuing to execute an alias or command. It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues. "wait 100" is roughly a second on a 100 FPS server.
  • Some servers disable the wait command. Many scripts will not function under these conditions.
  • Other commands accept values as well. For example, if you want to turn alltalk on and off, the sv_alltalk command accepts 1 or 0 respectively.

Common scripts

There are several notable scripts that have affected gameplay. Some of these are patched out. Others remain functional.

Pistol Script

Originally, the Pistol could be fired almost as fast as the human hand could press a key. Realizing this, some people created script sthat made the Pistol fire as rapidly as possible as long as you held down the fire button. This not only allowed the Scout and Engineer to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.

Valve eventually leveled the playing field. They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key. The Pistol script was no longer necessary.

Targe Turn Script

Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands. The Chargin' Targe was the first weapon to create a restriction on how fast you could turn your viewpoint, so Valve put limits on mouse turnspeed but forgot to apply the same restrictions to the rarely used keyboard turns.

Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.

Valve eventually capped the keyboard turn commands like the mouse commands. The Turn scripts were made useless.

Weapon Hiding Scripts

There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class. Players often make their guns invisible to clear up the screen, but make items like melee weapons, PDAs, watches and so forth visible because these models indicate important information. For example, the Spy relies heavily on his visible model to determine when he is cloaked, when his cloak is disturbed, and when the Dead Ringer activates. Other classes use the melee animations to judge when their attacks will hit.

Sentry Jumping Scripts

Since the Engineer update, Engineers have been able to pack up and carry their Sentry Guns. Simultaneously, the Wrangler allowed Engineers to Sentry jump with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.

While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.

Sensitivity and Control Scripts

Some players prefer different mouse sensitivities and control schemes for some classes. These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.

Resources

Here are some links that review Team Fortress 2 scripting in greater detail: