巨集
這頁目前正處於被翻譯至繁體中文的狀態。 如果你會說繁體中文,請在討論頁中留下你的大名,或透過查看歷史紀錄跟有編輯這頁的用戶聯繫。 |
巨集又稱為腳本,是使用配置文件來把控制台的指令碼綁定到鍵位或把數個指令綁定成一個新的別名
巨集所涵蓋的範圍可以從綁定鍵位到使用別名來自動重複指令。甚至可以使用巨集來創建千變萬化的行為。
內容
巨集的文件
絕地要塞2會自動讀取以下幾個遊戲文件來實行巨集:
- config.cfg - 這是默認的配置文件,當你在選項裏面做出更改時,便會將設定儲存在此文件。
- autoexec.cfg - 這是儲存玩家設定的配置文件,你可以把巨集或指令儲存在此文件。當config.cfg和autoexec.cfg都有相同的指令時,遊戲會以autoexec.cfg為准
- <class>.cfg - 每個兵種都有一個配置文件,你可以將綁定鍵位的指令儲存在這些文件。當你選擇了相應的兵種後,相應文件的指令便會執行。
語法
這是一個語法的規則:
- 無論是綁定或別名,你都要按照以下格式來編寫:
- 命令 <argument1> <argument2>
- 目前有三種命令可供選擇:
- bind - 用於將指令綁定到鍵位
- alias - 可以將多個指令綁定成別名來一次性執行
- exec - 可以讓客戶端加載其他配置文件
- <argument1> 可以是鍵位的名稱或創建別名的名稱
- <argument2> 可以是被綁定的指令別名的名稱
- 要一次執行多條指令,你必須將所以指令用引號括住,例如:
- alias "spraynpray" "+attack; wait 500; -attack"
- bind "mouse3" "spraynpray"
- 按mouse3後,開始執行別名spraynpray,然後別名spraynpray會讓你的武器進行攻擊,接著等待500幀,最後停止射擊。
綁定
絕地要塞2可以將指令綁定到鍵盤上的任何一個鍵,在綁定之前,你需要瞭解在絕地要塞2中每個鍵盤的名稱。
絕地要塞2的鍵盤名稱
- 鍵盤按鍵: 鍵盤名稱
- Left Shift: SHIFT
- Left Ctrl: CTRL
- Left Alt: ALT
- Right Shift: RSHIFT
- Right Control: RCTRL
- Right Alt: RALT
- Tab: TAB
- Backspace: BACKSPACE
- ---
- Insert: INS
- Scroll Lock: SCROLLLOCK
- Pause/Break: NUMLOCK
- ---
- Home: HOME
- End: END
- Delete: DEL
- Page Up: PGUP
- Page Down: PGDN
- ---
- Up Arrow: UPARROW
- Down Arrow: DOWNARROW
- Left Arrow: LEFTARROW
- Right Arrow: RIGHTARROW
- Numpad Keys: Names of Keybinds
- 0: KP_INS
- 1: KP_END
- 2: KP_DOWNARROW
- 3: KP_PGDN
- 4: KP_LEFTARROW
- 5: KP_5
- 6: KP_RIGHTARROW
- 7: KP_HOME
- 8: KP_UPARROW
- 9: KP_PGUP
- Enter: KP_ENTER
- ".": KP_DEL
- "+": KP_PLUS
- "-": KP_MINUS
- "*": KP_MULTIPLY
- "/":KP_SLASH
- 鼠標滾輪方向: 名稱
- Mouse Wheel Up: MWHEELUP
- Mouse Wheel Down: MWHEELDOWN
使用上述名稱你可以在下面的示例巨集生成一個配置文件:
- bind KP_ENTER "voicemenu 0 1"
此巨集功用是當你按下小鍵盤的Enter鍵後會觸發『謝謝』的語音指令。
基本指令
大多數指令後可以輸入一個參數,在大部份的指令裏同常參數0代表關閉,1代表開啟。
bind "q" "sv_alltalk 1"
有部分指令可以輸入多個參數,比如:
- disguise X Y - 這是快速偽裝的指令 X是代表兵種的編號;Y是團隊的編號
- voicemenu X Y - 這是快速發出語音的指令,相當於系統預設按E鍵呼叫醫護兵。
假如"voicemenu 1 1"是發現spy的指令,那麼:
bind "t" "voicemenu 1 1"
按t鍵後即會發出spy!的語音。
遞增指令
incrementvar這個命令可以讓指令的參數遞增,比如:
- command "<argument1>" "incrementvar <argument2> X Y Z"
- X和Y可以設定<argument2>的指令參數範圍
- Z是設定每次遞增的數目
如果你想設定指令的參數範圍是1到10,而遞增的數目為2,那麼<argument2>的參數便會實行遞增後的值:2、4、6、8、10等等。
這裡有一個例子:
- bind "n" "incrementvar net_graphpos 1 3 1"
按n鍵後,net_graphpos便會以參數1、3實行。
+和-命令
這些命令有兩種狀態,當綁定的鍵按下時,+命令會一直實行;當鬆開綁定鍵後,-命令會一直實行。
例如:
- bind "c" "+duck"
這是+命令,所以當c鍵按下時,玩家就會一直蹲下。當鬆開後,玩家就會停止蹲下。
一般來說,如果一個指令或別名綁定到一個鍵,+會告訴遊戲開始並一直實行指令。相反,如果一個指令或別名綁定到一個鍵,-會告訴遊戲取消+號的工作。
如果定義一個+別名,將綁定別名的鍵按下時,-命令運行時就是取消
等待命令
如果你想按下鍵位後在等一段時間後才實行,可以使用wait命令。
等待命令是以幀(FPS)為單位,在100FPS的的情況下,每100幀大約為一秒。
有些服務器會禁用等待命令,在你實行巨集時會忽略wait命令,這會使一些巨集崩潰。
別名
別名可以讓玩家按下一個鍵位後實行多個命令,以下是一個簡單例子:
alias "aliasname" "command1; command2; command3"
然後,你可以將該別名綁定到一個鍵位
bind "key" "aliasname"
當按下aliasname後,command1; command2; command3就會按順序執行。
複雜的別名
別名可以執行任何指令,也可以執行其他別名。因此,你可以創建一個循環的巨集。
bind "key" namescroll
alias namescroll "firstname"
alias firstname "setinfo name "First_name"; alias namescroll secondname"
alias secondname "setinfo name "Second_name"; alias namescroll thirdname"
alias thirdname "setinfo name "Third-name"; alias namescroll firstname"
此巨集難以閱讀,在此分開解釋:
- 第一行將別名namescroll綁定到一個鍵位
- 第二行創建別名namescroll和添加指令"firstname"
- 第三行定義名字別名和兩個指令
- 第一條命令設置遊戲中的名字為First_name
- 第二條命令將別名namescroll定義為執行別名secondname
- 第四行類似於第三行,將別名secondname定義為更改遊戲名字為Second_name,然後將namescroll定義為執行別名thirdname
- 第五行將別名thirdname定義為更改遊戲名字為Third-name,然後將namescroll定義為執行別名firstname
這樣就完成一個循環別名,第五行結束後會再次執行第三行的別名。
循環的別名
Aliases can be used in conjunction with the Wait command to create looping aliases.
alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"
Loop
下面解釋以上的巨集:
- 第一行建立別名loop,在控制台顯示Looping every 150 ticks後,等待150幀後再次執行別名loop
- 第二行循環別名loop
您還可以創建循環命令的別名,像這樣的例子:
alias "Loop1" "echo Loop 1;wait 150;Loop2"
alias "Loop2" "echo Loop 2;wait 150;Loop1"
別名Loop1執行別名Loop2,別名Loop2執行別名Loop1,如此循環
這種方法也可用於取消循環,但不清除循環別名:
alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "Loop2" "Loop1"
這將創建一個循環,然後
alias "Loop2"
將打破它,清除Loop2別名。
您可以利用這些按鈕按下(通過 + / - 前綴覆蓋更早)是這樣的:
alias "Loop2" "Loop1"
alias "Loop1" "echo Loop1;wait 150;Loop2"
alias "+Loop" "alias Loop2 Loop1;Loop2"
alias "-Loop" "alias Loop2"
bind "<Key>" "+Loop"
解讀此巨集:
創建別名Loop2執行別名Loop2
別名Loop1在控制台顯示Loop1字樣,150幀後執行Loop2
創建別名-Loop,-Loop執行命令alias Loop2
用-Lopp來清除Loop2,取消了循環。
有用的指令
有很多不同的指令可以編寫巨集,這幾乎可以讓巨集做任何事,一下是部分指令的列表
語音指令
語音指令可以讓你在遊戲內發出特定的語音。
語音指令使用以下語法
voicemenu <menu_number> <phrase_number>
<menu_number>是編號1到3的語音菜單編號,<phrase_number>則是語音菜單1到7的語音編號
語音相關編號
- 0 <phrase_number>
- 0: 醫生!
- 1: 謝謝
- 2: Go
- 3: Move Up
- 4: Flank Left
- 5: Flank Right
- 6: 是
- 7: 否
- 1 <phrase_number>
- 0: Incoming
- 1: spy!
- 2: 前方有步哨
- 3: 這裡需要步哨防禦槍!
- 4: 這裡需要傳送裝置!
- 5: 這裡需要補給器!
- 6: Activate ÜberCharge
- 7: (只有Medic可以使用)ÜberCharge Ready
- 2 <phrase_number>
- 0: Help
- 1: Battlecry
- 2: Cheers
- 3: Jeers
- 4: Positive
- 5: Negative
- 6: Nice Shot
- 7: Good Job
Spy快速偽裝
這些巨集可以讓玩家按下一個鍵後即偽裝而不用開啟偽裝菜單
偽裝命令使用以下語法:
disguise <class_number> <team_number>
<class_number>是代表兵種的編號;<team_number>是代表團隊的編號
偽裝編號參數
- 1 <class_number>
- 1: Scout
- 2: Sniper
- 3: Soldier
- 4: Demoman
- 5: Medic
- 6: Heavy
- 7: Pyro
- 8: Spy
- 9: Engineer
- 2 <team_number>
- 1: BLU team
- 2: RED team
- -1: Opposite team
- -2: Same team
Engineer快速建造
類似Spy的快速偽裝,這可以讓Engineer不必開啟建造菜但即能建造。
建築指令使用以下語法
build <building_number>
destroy <building number>
<building_number>是建築的編號
建築編號參數
- Number: Building/Destroying
- 0: Dispenser
- 1: Teleporter Entrance
- 2: Sentry Gun/Minisentry
- 3: Teleporter Exit
以下是快速建造巨集的例子:
alias sentry "destroy 2; build 2"
alias Dispenser "destroy 0; build 0"
alias entrance "destroy 1; build 1"
alias exit "destroy 3; build 3"
bind f1 sentry
bind f2 dispenser
bind f3 entrance
bind f4 exit
這巨集會在建造前先破壞要建造的建築,使玩家建造前無需開啟破壞菜單。
Medic Radar
This set of aliases and commands will temporarily boost the Medic's autocall threshold to 150% (a fully-overhealed player)for as long as they hold a key down, allowing him to see where all of his teammates are by their Medic autocall speech bubbles in the event he finds himself alone.
alias "autocall_default" "hud_medicautocallersthreshold "75""
alias "autocall_all" "hud_medicautocallersthreshold "150""
alias "+radar" "autocall_all"
alias "-radar" "autocall_default"
bind mouse3 "+radar"
The default autocall value, or the autocall threshold when this command is not in use, can be adjusted to any desired number (in the example it is listed as 75% health) and the keybind to activate it can be changed as well (the example is bound to mouse3).
值得注意的巨集
有些巨集會破壞遊戲的環境和平衡。
補丁巨集
手槍連射巨集
原先遊戲裏的手槍只能單發射擊,後來有人編寫了手槍連射巨集,讓玩家一直按下鍵位即可連續發射手槍。後來Valve為了確保遊戲公平性,讓玩家即使不使用巨集也可以連續發射手槍。
Targe Turn Scripts
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 quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.
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 as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
However, it is still possible to write a script that will toggle Sensitivity between insanely high values when charging and normal value when the player performs an attack. It is also possible to turn easily while using a gamepad's analog sticks.
Air Crouching Scripts
Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.
Valve patched it so you could only crouch twice in a single jump.
Current Scripts
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.
Gunslinger Scripts
Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.
Sensitivity and Control Scripts
Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Scout, which requires high sensitivity for quick turning and maneuverability, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
See Also
- List of useful console commands
- Customizing - config_default.cfg: The default key-binds within TF2.