Difference between revisions of "Scripting/zh-hant"

From Team Fortress Wiki
Jump to: navigation, search
m (等待命令)
m (語法: fix)
 
(17 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:巨集}}
 
{{DISPLAYTITLE:巨集}}
 
{{trans}}
 
{{trans}}
巨集又稱為腳本,是使用配置文件來把[[console|控制台]]的指令碼綁定到鍵位或把數個指令綁定成一個新的別名
+
巨集又稱為腳本,是使用配置文件來把[[console/zh-hant|控制台]]的指令碼綁定到鍵位或把數個指令綁定成一個新的別名
  
 
巨集所涵蓋的範圍可以從綁定鍵位到使用別名來自動重複指令。甚至可以使用巨集來創建千變萬化的行為。
 
巨集所涵蓋的範圍可以從綁定鍵位到使用別名來自動重複指令。甚至可以使用巨集來創建千變萬化的行為。
Line 9: Line 9:
 
絕地要塞2會自動讀取以下幾個遊戲文件來實行巨集:
 
絕地要塞2會自動讀取以下幾個遊戲文件來實行巨集:
  
* config.cfg - 這是默認的配置文件,當你在選項裏面做出更改時,便會將設定儲存在此文件。
+
* config.cfg - 這是默認的配置文件,當你在選項裏面做出更改時,便會將設定儲存在此文件。編輯此文件沒有風險,但在啟動遊戲時會影響到修改過的按鍵配置。每次啟動遊戲時會在其他設置讀取之前優先讀取。
 +
** config_default.cfg - 這份文件包含了一組基本的按鍵配置,如果 config.cfg 不存在時就會被執行作為備份。
 +
* autoexec.cfg - 這是儲存玩家設定的配置文件,你可以把巨集或指令儲存在此文件。當config.cfg和autoexec.cfg都有相同的指令時,遊戲會以autoexec.cfg為准
  
* autoexec.cfg - 這是儲存玩家設定的配置文件,你可以把巨集或指令儲存在此文件。當config.cfg和autoexec.cfg都有相同的指令時,遊戲會以autoexec.cfg為准
+
* <class>.cfg - 每個兵種都有一個配置文件,你可以將綁定鍵位的指令儲存在這些文件。當你選擇了相應的兵種後,相應文件的指令便會執行。需要注意的是,若在文件中使用了開關類型的指令時作用會被保留,直到執行反向指令為止。
  
* <class>.cfg - 每個兵種都有一個配置文件,你可以將綁定鍵位的指令儲存在這些文件。當你選擇了相應的兵種後,相應文件的指令便會執行。
+
==編輯巨集文件==
 +
若在 Windows 系統,巨集文件能在下列資料夾找到:<br/>
 +
<code><Steam Folder>/SteamApps/common/team fortress 2/tf/cfg</code><br/>
 +
若在 Mac 系統,巨集文件能在下列資料夾找到:<br/>
 +
<code>~/Library/Application Support/Steam/SteamApps/common/team fortress 2/tf/cfg</code><br/>
 +
若在 Linux 系統,巨集文件能在下列資料夾找到:<br />
 +
<code>~/.local/share/Steam/SteamApps/common/Team\ Fortress\ 2/tf/cfg</code><br />
 +
Since the SteamPipe update, code can also be placed in
 +
<code>.../team fortress 2/tf/custom/yourfoldernamehere/cfg</code>
  
 
==語法==
 
==語法==
 
+
The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.
 
這是一個語法的規則:
 
這是一個語法的規則:
  
Line 31: Line 41:
 
:* <argument1> 可以是鍵位的名稱或創建別名的名稱
 
:* <argument1> 可以是鍵位的名稱或創建別名的名稱
  
:* <argument2> 可以是被綁定的指令別名的名稱
+
:* <argument2> 可以是被綁定的指令或別名的指令
  
 
*要一次執行多條指令,你必須將所以指令用引號括住,例如:
 
*要一次執行多條指令,你必須將所以指令用引號括住,例如:
Line 40: Line 50:
 
:*按mouse3後,開始執行別名spraynpray,然後別名spraynpray會讓你的武器進行攻擊,接著等待500幀,最後停止射擊。
 
:*按mouse3後,開始執行別名spraynpray,然後別名spraynpray會讓你的武器進行攻擊,接著等待500幀,最後停止射擊。
  
==綁定==
+
===綁定(bind)===
 +
最簡單的語法是 bind 指令,能夠影響按鍵執行的動作,該動作可以是個設定、指令或腳本。
  
絕地要塞2可以將指令綁定到鍵盤上的任何一個鍵,在綁定之前,你需要瞭解在絕地要塞2中每個鍵盤的名稱。
+
<code>bind [KEY] [COMMAND]</code><br />
====絕地要塞2的鍵盤名稱====
+
可以加上雙引號在按鍵名稱或指令的左右。<br />
* 鍵盤按鍵: 鍵盤名稱
 
* 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
 
  
使用上述名稱你可以在下面的示例巨集生成一個配置文件:
+
<code>bind [KEY] "[COMMAND 1]; [COMMAND 2]; [COMMAND 3]"</code><br />
 +
可以加上雙引號在按鍵名,但一定要用雙引號包住多項指令。
  
* bind KP_ENTER "voicemenu 0 1"
 
  
此巨集功用是當你按下小鍵盤的Enter鍵後會觸發『謝謝』的語音指令。
+
綁定有兩種形式:<br />
 +
<code>bind "e" "Voicemenu 0 0"</code><br />
 +
此綁定是當玩家按下{{key|E}}鍵後會觸發『Medic!』的語音指令。
  
==基本指令==
+
<code>bind "w" "+forward"</code><br />
 +
此綁定是當玩家按住不放 {{key|W}} 鍵後能夠讓玩家前進。
  
大多數指令後可以輸入一個參數,在大部份的指令裏同常參數0代表關閉,1代表開啟。
+
===切換(Toggle)===
 +
這項巨集可以設置兩個或兩個以上值的指令進行切換。
 +
<code>toggle "sv_cheats" 0 1</code>
  
'''bind "q" "sv_alltalk 1"'''
+
===綁定切換(Bindtoggle)===
 +
功能和 toggle 相同,只是綁定到一個按鍵上。
 +
<code>bindtoggle o "sv_cheats" 0 1</code>
  
有部分指令可以輸入多個參數,比如:
+
注意:若無設定數值,toggle 和 bindtoggle 則會默認數值為 0 與 1。
  
* disguise X Y - 這是快速偽裝的指令  X是代表兵種的編號;Y是團隊的編號
+
===遞增值(Incrementvar)===
 +
可以設置一個數值以反覆執行增加或減少值。
  
* voicemenu X Y - 這是快速發出語音的指令,相當於系統預設按E鍵呼叫[[Medic|醫護兵]]
+
<code>bind MWHEELUP "incrementvar fov_desired 75 90 1"<br />
 +
bind MWHEELDOWN "incrementvar fov_desired 75 90 -1"</code><br />
 +
此範例能讓玩家向上滾動滑鼠滾輪時增加[[field of view/zh-hant|視野]],向下滾動則減少。<br />
 +
''註:'' Incrementvar 指令如果讓數值超出或變得過小時會重複循環。在此範例中,如果視野超過 90 則會下降到 75 ,反之亦然。
  
假如"voicemenu 1 1"是發現Spy的指令,那麼:
+
===別名(Alias)===
 +
Alias 可以將多項指令以一個名稱代替,成為一個有效用的簡寫名稱。當一系列的指令需要被重複執行時會非常有用。<br />
 +
''註:'' Alias 名稱不能包含空格。可以包含下底線、數字或符號。 Alias 會區分大小寫。<br />
  
'''bind "t" "voicemenu 1 1"'''
+
<code>alias Call_For_Medic "Voicemenu 0 0"<br />
 +
bind "e" "Call_For_Medic"</code><br />
 +
此巨集是一個簡單的綁定,功能是當玩家按下 {{key|E}} 後會觸發『Medic!』語音指令。<br />
  
按t鍵後即會發出Spy!的語音。
+
<code>alias "+Diagonal" "+moveleft; +back"<br />
 +
alias "-Diagonal" "-moveleft; -back"<br />
 +
bind "z" "+Diagonal"</code><br />
 +
此巨集可以讓玩家斜向移動,按下 {{key|Z}} 玩家會往左後方斜著走。
  
==遞增指令==
+
'''警告:下列寫法不會有作用'''<br />
 +
<code>bind "z" "+moveleft; +back"</code><br />
 +
雖然按 {{key|Z}} 可以讓玩家往左邊及後方移動,但遊戲引擎不會反轉 +back 指令,導致放開 {{key|Z}} 後玩家不會停止向後移動。
  
incrementvar這個命令可以讓指令的參數遞增,比如:
+
===執行(Exec)===
 +
此指令可以執行其他的文件檔。意味著複雜的巨集可以存在其他文件檔裡,以免弄亂一般的文件。
  
:'''command "<argument1>" "incrementvar <argument2> X Y Z"'''
+
<code>exec autoexec.cfg</code><br />
 +
此巨集將會讀取 autoexec.cfg 文件內的巨集。
  
:*X和Y可以設定<argument2>的指令參數範圍
+
===回應(Echo)===
:*Z是設定每次遞增的數目
+
此指令會將文字顯示到控制台上,對於偵錯非常有用。
  
如果你想設定指令的參數範圍是1到10,而遞增的數目為2,那麼<argument2>的參數便會實行遞增後的值:2、4、6、8、10等等。
+
<code>echo Scripting is; echo very useful.</code><br />
 +
如果將分號(;)加在文字之間則會顯示 <code>Scripting isvery useful.</code> 。
 +
或將文字用雙引號包住,如下例
  
這裡有一個例子:
+
<code>echo " Scripting is very useful.  "</code><br />
 +
則會將多餘的空格顯示出來,因為它包含在雙引號內。
  
:'''bind "n" "incrementvar net_graphpos 1 3 1"'''
+
''註:'' 雙引號是無法顯示的符號,因為它的用途會被曲解。
  
按n鍵後,net_graphpos便會以參數1、3實行。
+
===等待(Wait)===
 +
此指令可使遊戲等待所設定的 FPS 數值後才執行下一個指令。<br />
 +
''註:'' 這項指令對應的實際時間取決於伺服器的處理速率。<br />
 +
'''警告: Wait 指令在部分伺服器禁用。這會導致某些巨集失效,並且(在極少數的情況下)讓遊戲當機。請看 [[#Wait-testing|Wait Testing]] 避免這種情況發生。'''
  
==+和-命令==
+
<code>echo Why did the chicken cross the road?; wait 66; echo To get to the other side!</code><br />
 +
This script will wait 66 frames (1 second on most servers) before printing the punchline.
  
這些命令有兩種狀態,當綁定的鍵按下時,+命令會一直實行;當鬆開綁定鍵後,-命令會一直實行。
+
==絕地要塞2的鍵盤名稱==
 +
滑鼠移上按鍵即可看到按鍵名稱。
 +
<code>
 +
{|
 +
! width="45%" <!-- Main keyboard -->|
 +
! width="4%" <!-- Spacing -->|
 +
! width="20%" <!-- Special keys -->|
 +
! width="1%" <!-- Spacing -->|
 +
! width="25%" <!-- Keypad 1 -->|
 +
! width="5%" <!-- Keypad 2 -->|
 +
|-
 +
|
 +
{{tooltip|{{key|ESC}}|ESCAPE}}
 +
{{tooltip|{{key|F1}}|F1}}
 +
{{tooltip|{{key|F2}}|F2}}
 +
{{tooltip|{{key|F3}}|F3}}
 +
{{tooltip|{{key|F4}}|F4}}
 +
{{tooltip|{{key|F5}}|F5}}
 +
{{tooltip|{{key|F6}}|F6}}
 +
{{tooltip|{{key|F7}}|F7}}
 +
{{tooltip|{{key|F8}}|F8}}
 +
{{tooltip|{{key|F9}}|F9}}
 +
{{tooltip|{{key|F10}}|F10}}
 +
{{tooltip|{{key|F11}}|F11}}
 +
{{tooltip|{{key|F12}}|F12}}
  
例如:
+
{{tooltip|{{key|`}}|`}}
 +
{{tooltip|{{key|1}}|1}}
 +
{{tooltip|{{key|2}}|2}}
 +
{{tooltip|{{key|3}}|3}}
 +
{{tooltip|{{key|4}}|4}}
 +
{{tooltip|{{key|5}}|5}}
 +
{{tooltip|{{key|6}}|6}}
 +
{{tooltip|{{key|7}}|7}}
 +
{{tooltip|{{key|8}}|8}}
 +
{{tooltip|{{key|9}}|9}}
 +
{{tooltip|{{key|0}}|0}}
 +
{{tooltip|{{key|-}}|-}}
 +
{{tooltip|{{key|{{=}}}}|{{=}}}}
 +
{{tooltip|{{key|Delete}}|BACKSPACE}}
  
:'''bind "c" "+duck"
+
{{tooltip|{{key|TAB}}|TAB}}
 +
{{tooltip|{{key|Q}}|Q}}
 +
{{tooltip|{{key|W}}|W}}
 +
{{tooltip|{{key|E}}|E}}
 +
{{tooltip|{{key|R}}|R}}
 +
{{tooltip|{{key|T}}|T}}
 +
{{tooltip|{{key|Y}}|Y}}
 +
{{tooltip|{{key|U}}|U}}
 +
{{tooltip|{{key|I}}|I}}
 +
{{tooltip|{{key|O}}|O}}
 +
{{tooltip|{{key|P}}|P}}
 +
{{tooltip|{{key|[}}|[}}
 +
{{tooltip|{{key|]}}|]}}
 +
{{tooltip|{{key|\}}|\}}
  
這是+命令,所以當c鍵按下時,玩家就會一直蹲下。當鬆開後,玩家就會停止蹲下。
+
{{tooltip|{{key|⇪ Caps}}|CAPSLOCK}}
 +
{{tooltip|{{key|A}}|A}}
 +
{{tooltip|{{key|S}}|S}}
 +
{{tooltip|{{key|D}}|D}}
 +
{{tooltip|{{key|F}}|F}}
 +
{{tooltip|{{key|G}}|G}}
 +
{{tooltip|{{key|H}}|H}}
 +
{{tooltip|{{key|J}}|J}}
 +
{{tooltip|{{key|K}}|K}}
 +
{{tooltip|{{key|L}}|L}}
 +
{{tooltip|{{key|;}}|SEMICOLON}}
 +
{{tooltip|{{key|'}}|'}}
 +
{{tooltip|{{key|&nbsp; ↵ &nbsp; }}|ENTER}}
  
一般來說,如果一個指令或別名綁定到一個鍵,+會告訴遊戲開始並一直實行指令。相反,如果一個指令或別名綁定到一個鍵,-會告訴遊戲取消+號的工作。
+
{{tooltip|{{key|Shift}}|SHIFT}}
 +
{{tooltip|{{key|Z}}|Z}}
 +
{{tooltip|{{key|X}}|X}}
 +
{{tooltip|{{key|C}}|C}}
 +
{{tooltip|{{key|V}}|V}}
 +
{{tooltip|{{key|B}}|B}}
 +
{{tooltip|{{key|N}}|N}}
 +
{{tooltip|{{key|M}}|M}}
 +
{{tooltip|{{key|,}}|,}}
 +
{{tooltip|{{key|.}}|.}}
 +
{{tooltip|{{key|/}}|/}}
 +
{{tooltip|{{key|Shift}}|RSHIFT}}
  
如果定義一個+別名,將綁定別名的鍵按下時,-命令運行時就是取消
+
{{tooltip|{{key|Ctrl}}|CTRL}}
 +
{{tooltip|{{key|⊞}}|LWIN}}
 +
{{tooltip|{{key|Alt}}|ALT}}
 +
{{tooltip|{{key| &nbsp; &nbsp; &nbsp; Spacebar &nbsp; &nbsp; &nbsp; }}|SPACE}}
 +
{{tooltip|{{key|⊞}}|RWIN}}
 +
{{tooltip|{{key|Menu}}|Cannot be bound}}
 +
{{tooltip|{{key|Ctrl}}|RCTRL}}
  
==等待命令==
+
|<!-- Spacing -->
 +
|
 +
{{tooltip|{{key|PrtScn}}|Cannot be bound}}
 +
{{tooltip|{{key|ScrLk}}|SCROLLOCK}}
 +
{{tooltip|{{key|Pause}}|NUMLOCK}}
  
如果你想按下鍵位後在等一段時間後才實行,可以使用wait命令。
+
{{tooltip|{{key|Insert}}|INS}}
 +
{{tooltip|{{key|Home}}|HOME}}
 +
{{tooltip|{{key|PgUp}}|PGUP}}
  
等待命令是以幀(FPS)為單位,在100FPS的的情況下,每100幀大約為一秒。
+
{{tooltip|{{key|Delete}}|DEL}}
 +
{{tooltip|{{key|End}}|END}}
 +
{{tooltip|{{key|PgDn}}|PGDN}}
  
有些服務器會禁用等待命令,在你執行巨集時會忽略wait命令,這會使一些巨集崩潰。
 
  
==別名==
+
&nbsp; &nbsp; &nbsp; &nbsp; {{tooltip|{{key|&uarr;}}|UPARROW}}
  
別名可以讓玩家按下一個鍵位後實行多個命令,以下是一個簡單例子:
+
&nbsp; &nbsp; {{tooltip|{{key|&larr;}}|LEFTARROW}}
 +
{{tooltip|{{key|&darr;}}|DOWNARROW}}
 +
{{tooltip|{{key|&rarr;}}|RIGHTARROW}}
 +
|<!-- Spacing -->
 +
|
  
'''alias "aliasname" "command1; command2; command3"'''
+
{{Scripting Numpad}}
 +
|}
  
然後,你可以將該別名綁定到一個鍵位
+
{|
 +
! align="left"| 滑鼠按鍵
 +
! 按鍵名稱
 +
|-
 +
| 滾輪上滑
 +
| MWHEELUP
 +
|-
 +
| 滾輪下滑
 +
| MWHEELDOWN
 +
|-
 +
| 左鍵
 +
| MOUSE1
 +
|-
 +
| 右鍵
 +
| MOUSE2
 +
|-
 +
| 點擊滾輪
 +
| MOUSE3
 +
|-
 +
| 左側鍵(下一頁)
 +
| MOUSE4
 +
|-
 +
| 右側鍵(上一頁)
 +
| MOUSE5
 +
|}
  
'''bind "key" "aliasname"'''
+
</code>
  
當按下aliasname後,command1; command2; command3就會按順序執行。
+
==實用的指令==
 +
{{Main|vdc:List_of_TF2_console_commands_and_variables|l1=TF2 指令及值數列表(英)}}
  
===複雜的別名===
+
===Spy快速偽裝===
  
別名可以執行任何指令,也可以執行其他別名。因此,你可以創建一個循環的巨集。
+
這些巨集可以讓玩家按下一個鍵後即偽裝而不用開啟偽裝菜單
 +
 
 +
偽裝命令使用以下語法:
  
'''bind "key" namescroll'''<br>
+
'''disguise <class_number> <team_number>
'''alias namescroll "firstname" '''<br>
 
'''alias firstname "setinfo name "First_name"; alias namescroll secondname" '''<br>
 
'''alias secondname "setinfo name "Second_name"; alias namescroll thirdname"'''<br>
 
'''alias thirdname "setinfo name "Third-name"; alias namescroll firstname"'''<br>
 
  
此巨集難以閱讀,在此分開解釋:
+
<class_number>是代表兵種的編號;<team_number>是代表團隊的編號
  
*第一行將別名namescroll綁定到一個鍵位
+
====偽裝編號參數====
*第二行創建別名namescroll和添加指令"firstname"
 
*第三行定義名字別名和兩個指令
 
:*第一條命令設置遊戲中的名字為First_name
 
:*第二條命令將別名namescroll定義為執行別名secondname
 
*第四行類似於第三行,將別名secondname定義為更改遊戲名字為Second_name,然後將namescroll定義為執行別名thirdname
 
*第五行將別名thirdname定義為更改遊戲名字為Third-name,然後將namescroll定義為執行別名firstname
 
  
這樣就完成一個循環別名,第五行結束後會再次執行第三行的別名。
+
*1 <class_number>
 +
*:1: 偵察兵
 +
*:2: 狙擊手
 +
*:3: 火箭兵
 +
*:4: 爆破兵
 +
*:5: 醫護兵
 +
*:6: 重裝兵
 +
*:7: 火焰兵
 +
*:8: 間諜
 +
*:9: 工程師
  
===循環的別名===
+
*2 <team_number>
Aliases can be used in conjunction with the Wait command to create looping aliases.<br>
+
*:1: 藍隊
 +
*:2: 紅隊
 +
*:-1: 敵隊
 +
*:-2: 同隊
  
'''alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"'''<br>
+
===Engineer快速建造===
'''Loop'''<br>
+
類似[[Spy/zh-hant|Spy]]的快速偽裝,這可以讓[[Engineer/zh-hant|Engineer]]不必開啟建造菜單即能建造。
  
下面解釋以上的巨集:
+
建築指令使用以下語法
  
*第一行建立別名loop,在控制台顯示Looping every 150 ticks後,等待150幀後再次執行別名loop
+
'''build <building_number><br>
*第二行循環別名loop
+
'''destroy <building number>
  
 +
<building_number>是建築的編號
  
您還可以創建循環命令的別名,像這樣的例子:<br>
+
====建築編號參數====
'''alias "Loop1" "echo Loop 1;wait 150;Loop2"'''<br>
+
*Number: Building/Destroying
'''alias "Loop2" "echo Loop 2;wait 150;Loop1"'''<br>
+
*:0: 補給器
 +
*:1: 傳送裝置入口
 +
*:2: 步哨防禦槍/迷你戰鬥步哨
 +
*:3: 傳送裝置出口
  
別名Loop1執行別名Loop2,別名Loop2執行別名Loop1,如此循環<br>
+
以下是快速建造巨集的例子:
這種方法也可用於取消循環,但不清除循環別名:<br>
 
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
 
'''alias "Loop2" "Loop1"'''<br>
 
這將創建一個循環,然後<br>
 
'''alias "Loop2"'''<br>
 
將打破它,清除Loop2別名。<br>
 
  
您可以利用這些按鈕按下(通過 + / - 前綴覆蓋更早)是這樣的:<br>
+
  '''alias sentry "destroy 2; build 2"<br>
'''alias "Loop2" "Loop1"'''<br>
+
  '''alias Dispenser "destroy 0; build 0"<br>
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
+
  '''alias entrance "destroy 1; build 1"<br>
'''alias "+Loop" "alias Loop2 Loop1;Loop2"'''<br>
+
  '''alias exit "destroy 3; build 3"<br>
'''alias "-Loop" "alias Loop2"'''<br>
+
  '''bind f1 sentry<br>
'''bind "<Key>" "+Loop"'''<br>
+
  '''bind f2 dispenser<br>
解讀此巨集:<br>
+
  '''bind f3 entrance<br>
創建別名Loop2執行別名Loop2<br>
+
  '''bind f4 exit<br>
別名Loop1在控制台顯示Loop1字樣,150幀後執行Loop2<br>
 
創建別名-Loop,-Loop執行命令alias Loop2<br>
 
用-Lopp來清除Loop2,取消了循環。<br>
 
  
== 有用的指令 ==
+
這巨集會在建造前先破壞要建造的建築,使玩家建造前無需開啟破壞菜單。
有很多不同的指令可以編寫巨集,這幾乎可以讓巨集做任何事,一下是部分指令的列表
 
  
 
===語音指令===
 
===語音指令===
Line 239: Line 349:
 
*0 <phrase_number>
 
*0 <phrase_number>
 
*:0: 醫生!
 
*:0: 醫生!
*:1: 謝謝
+
*:1: 謝謝!
*:2: Go
+
*:2: 前進! 前進! 前進!
*:3: Move Up
+
*:3: 往前!
*:4: Flank Left
+
*:4: 往左走
*:5: Flank Right
+
*:5: 往右走
*:6:
+
*:6:
*:7:
+
*:7:
 
*1 <phrase_number>
 
*1 <phrase_number>
*:0: Incoming
+
*:0: 敵人來襲
 
*:1: Spy!
 
*:1: Spy!
*:2: 前方有步哨
+
*:2: 前方有步哨!
*:3: 這裡需要步哨防禦槍!
+
*:3: 這裡需要傳送裝置
*:4: 這裡需要傳送裝置!
+
*:4: 這裡需要補給器
*:5: 這裡需要補給器!
+
*:5: 這裡需要步哨
*:6: Activate ÜberCharge
+
*:6: 啟動 ÜberCharge!
*:7: (只有Medic可以使用)ÜberCharge Ready
+
*:7: (只有Medic可以使用)ÜberCharge 就緒
 
*2 <phrase_number>
 
*2 <phrase_number>
*:0: Help
+
*:0: 幫我!
*:1: Battlecry
+
*:1: 戰鬥咆哮
*:2: Cheers
+
*:2: 乾杯
*:3: Jeers
+
*:3: 嘲弄
*:4: Positive
+
*:4: 收到
*:5: Negative
+
*:5: 不行
*:6: Nice Shot
+
*:6: 打得好
*:7: Good Job
+
*:7: 幹得好
 +
 
 +
 
 +
===雜項===
 +
*<code>clear</code> 清除控制台的所有訊息。
 +
*<code>alias</code> 列出所有目前定義的別名。
 +
*<code>fov_desired (75-90)</code> 設置[[field of view/zh-hant|視野]]距離。
 +
*<code>viewmodel_fov </code> 設置武器模型的視野,默認範圍為 54~70 之間。
 +
*<code>r_drawviewmodel (0/1)</code> 顯示(1) 或隱藏(0) 武器模型。
 +
*<code>lastdisguise</code> 使玩家偽裝成上一次偽裝的職業。 <small>(間諜專用)</small>
 +
*<code>load_itempreset [0, 1, 2, 3]</code> 更換自訂的 [A, B, C, D] 裝備欄位。
 +
*<code>say "message"</code> 發送公開的聊天訊息。
 +
*<code>say_team "message"</code> 發送隊伍聊天訊息。
 +
*<code>+taunt</code> 玩家會進行嘲諷動作。
 +
*<code>+use_action_slot_item</code> 玩家會使用動作欄位所裝備的物品。
 +
*<code>volume (0-1)</code> 改變遊戲中的音量。
  
===Spy快速偽裝===
+
==高級巨集技巧==
 +
===Toggles===
 +
It is possible to bind a key to toggle a command which would otherwise be a press and hold command.
  
這些巨集可以讓玩家按下一個鍵後即偽裝而不用開啟偽裝菜單
+
<code>bind w toggle<br />
 +
alias toggle "enable"<br />
 +
alias enable "alias toggle disable; +forward"<br />
 +
alias disable "alias toggle enable; -forward"</code><br />
 +
This script will cause a press of {{key|W}} to keep the player moving forward until {{key|W}} is pressed again.
 +
===Key combinations===
 +
It is possible to create a script where pressing one button while another is held down will change the action of the first button.
  
偽裝命令使用以下語法:
+
<code>bind e call<br />
 +
alias call Call_For_Medic<br />
 +
alias Call_For_Medic "Voicemenu 0 0"<br />
 +
alias Call_For_Ubercharge "Voicemenu 1 6"</code><br />
 +
At this point, the script will mean that every time {{key|E}} is pressed, the player will call for a Medic. It also has an unused alias to call for an [[Ubercharge]].<br />
 +
<code>bind shift +toggleState<br />
 +
alias +toggleState "alias call Call_For_Ubercharge"<br />
 +
alias -toggleState "alias call Call_For_Medic</code><br />
 +
Now, pressing {{Key|Shift}} will redirect <code>call</code> to ask for an ubercharge. Releasing {{Key|Shift}} will make <code>call</code> point back at a Medic call.<br />
 +
When {{Key|Shift|E}} is pressed, the player will call for an Ubercharge, rather than for a Medic.
  
'''disguise <class_number> <team_number>
+
===Wait-testing===
 +
由於 <code>wait</code> 指令是一些巨集不可缺少的部分,利用此指令查看伺服器是否能使用等待指令。
  
<class_number>是代表兵種的編號;<team_number>是代表團隊的編號
+
<code>alias waitTester "alias waitTest waitPositive; wait; waitTest"<br />
 +
alias wait "alias waitTest waitNegative"<br />
 +
alias waitPositive "echo Wait is enabled on this server.; exec waitPositive.cfg"<br />
 +
alias waitNegative "echo Wait is DISABLED on this server!; exec waitNegative.cfg"<br />
 +
waitTester</code><br />
 +
This script relies on the fact that if the wait command is disabled on a server, the alias named <code>wait</code> can be defined by the user. Thus, the script creates an alias named <code>waitTest</code> which by default points to <code>waitPositive</code>, but if <code>wait</code> is not allowed (and can thus be defined by the user), will be redirected to <code>waitNegative</code>.
  
====偽裝編號參數====
+
===Loops===
 +
'''Warning: Loops which run without a wait command will cause the TF2 client to hang. It is highly suggested to run a looping script only after a wait testing script.'''<br />
 +
It is generally considered bad form to have one alias point to itself, as although the loop can be broken out of, it cannot be reset. Therefore, looping scripts tend to include two parts to the loop: The part that waits, and the part that loops.
  
*1 <class_number>
+
<code>bind g "loopKey"<br />
*:1: Scout
+
alias loopKey startLoop<br />
*:2: Sniper
+
alias startLoop "alias loopKey stopLoop; +attack; alias redirect loop; loop"<br />
*:3: Soldier
+
alias stopLoop "-attack; alias redirect; alias loopKey startLoop"<br />
*:4: Demoman
+
alias loop "+left; wait 33; +right; wait 33; redirect"<br />
*:5: Medic
+
alias redirect loop</code><br />
*:6: Heavy
 
*:7: Pyro
 
*:8: Spy
 
*:9: Engineer
 
  
*2 <team_number>
+
This script will start looping once {{Key|G}} is pressed. It begins by firing, and then switches the player's view back and forth every 33 frames (1second on most servers). Pressing {{Key|G}} would cause the next iteration of the loop to stop, also stopping the firing.
*:1: BLU team
 
*:2: RED team
 
*:-1: Opposite team
 
*:-2: Same team
 
  
===Engineer快速建造===
+
<!--old trans
類似[[Spy]]的快速偽裝,這可以讓[[Engineer]]不必開啟建造菜但即能建造。
+
下面解釋以上的巨集:
  
建築指令使用以下語法
+
*第一行建立別名loop,在控制台顯示Looping every 150 ticks後,等待150幀後再次執行別名loop
 +
*第二行循環別名loop
  
'''build <building_number><br>
 
'''destroy <building number>
 
  
<building_number>是建築的編號
+
您還可以創建循環命令的別名,像這樣的例子:<br>
 +
'''alias "Loop1" "echo Loop 1;wait 150;Loop2"'''<br>
 +
'''alias "Loop2" "echo Loop 2;wait 150;Loop1"'''<br>
  
====建築編號參數====
+
別名Loop1執行別名Loop2,別名Loop2執行別名Loop1,如此循環<br>
*Number: Building/Destroying
+
這種方法也可用於取消循環,但不清除循環別名:<br>
*:0: Dispenser
+
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
*:1: Teleporter Entrance
+
'''alias "Loop2" "Loop1"'''<br>
*:2: Sentry Gun/Minisentry
+
這將創建一個循環,然後<br>
*:3: Teleporter Exit
+
'''alias "Loop2"'''<br>
 +
將打破它,清除Loop2別名。<br>
  
以下是快速建造巨集的例子:
+
您可以利用這些按鈕按下(通過 + / - 前綴覆蓋更早)是這樣的:<br>
 +
'''alias "Loop2" "Loop1"'''<br>
 +
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
 +
'''alias "+Loop" "alias Loop2 Loop1;Loop2"'''<br>
 +
'''alias "-Loop" "alias Loop2"'''<br>
 +
'''bind "<Key>" "+Loop"'''<br>
 +
解讀此巨集:<br>
 +
創建別名Loop2執行別名Loop2<br>
 +
別名Loop1在控制台顯示Loop1字樣,150幀後執行Loop2<br>
 +
創建別名-Loop,-Loop執行命令alias Loop2<br>
 +
用-Lopp來清除Loop2,取消了循環。<br>
  
  '''alias sentry "destroy 2; build 2"<br>
+
<code>bind g "loopKey"<br />
  '''alias Dispenser "destroy 0; build 0"<br>
+
alias loopKey startLoop<br />
  '''alias entrance "destroy 1; build 1"<br>
+
alias startLoop "alias loopKey stopLoop; +attack; alias redirect loop; loop"<br />
  '''alias exit "destroy 3; build 3"<br>
+
alias stopLoop "-attack; alias redirect; alias loopKey startLoop"<br />
  '''bind f1 sentry<br>
+
alias loop "+left; wait 33; +right; wait 33; redirect"<br />
  '''bind f2 dispenser<br>
+
alias redirect loop</code><br />
  '''bind f3 entrance<br>
 
  '''bind f4 exit<br>
 
  
這巨集會在建造前先破壞要建造的建築,使玩家建造前無需開啟破壞菜單。
+
This script will start looping once {{Key|G}} is pressed. It begins by firing, and then switches the player's view back and forth every 33 frames (1second on most servers). Pressing {{Key|G}} would cause the next iteration of the loop to stop, also stopping the firing.
 +
-->
  
 
===Medic Radar===
 
===Medic Radar===
 
+
這些巨集可以讓[[Medic/zh-hant|Medic]]只要按住一個按鍵,就將自動呼救的上限提升至150%(醫護兵能超量治療的生命上限),讓他可以看到附近所有隊友的位置。
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.
+
<!--
 +
This set of aliases and commands will temporarily boost the [[Medic/zh-hant|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/zh-hant|Medic]] autocall speech bubbles in the event he finds himself alone.
 +
-->
  
 
   '''alias "autocall_default" "hud_medicautocallersthreshold "75""<br>
 
   '''alias "autocall_default" "hud_medicautocallersthreshold "75""<br>
Line 334: Line 489:
 
   '''bind mouse3 "+radar"<br>
 
   '''bind mouse3 "+radar"<br>
  
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).
+
預設的自動呼救值(也就是沒有使用這個巨集時的自動呼救值)可以調整為任何你想要的值(在這個例子中是75%),啟動巨集的按鈕也可以改為任意按鍵(在這個例子中是mouse3)。
  
 
==值得注意的巨集==  
 
==值得注意的巨集==  
 
 
有些巨集會破壞遊戲的環境和平衡。
 
有些巨集會破壞遊戲的環境和平衡。
  
===補丁巨集===
+
===已被修正的巨集===
  
 
====手槍連射巨集====
 
====手槍連射巨集====
Line 348: Line 502:
 
====Targe Turn Scripts====
 
====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.
+
用鍵盤改變視角與用滑鼠改變視角,是不同的兩個動作。[[Chargin' Targe/zh-hant|衝擊刺盾]]是第一個限制改變視角速度的武器,而Valve雖然對使用該武器時,滑鼠改變視角的速度做出限制,卻忘了對鍵盤指令做出相同限制。<!-- Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands.  The [[Chargin' Targe/zh-hant|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. -->有玩家利用這個特性,寫了重新改變輸出的巨集,讓他們可以用正常的速度改變視角。最複雜的例子中,玩家在衝刺時,滑鼠的x軸指令被改變為相同結果的鍵盤指令,在衝刺結束後再將這個改變還原。
  
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之後對鍵盤指令做出相同限制,因此這個巨集再也沒有作用了。然而,還是可以寫出一個巨集,讓玩家在衝刺時有超高滑鼠靈敏度,在攻擊時恢復正常。It is also possible to turn easily while using a gamepad's analog sticks.
  
Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
+
====蹲跳巨集====
 +
原先跳到空中時,蹲下的次數是沒有限制的。因此你可以在空中執行一個不斷超高速蹲下站起的巨集,讓遊戲沒辦法正常判斷子彈是否擊中你。Valve修正為在空中只能蹲下兩次。
  
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.
+
====Gloves of Running Urgently Scripts====
 +
The [[Gloves of Running Urgently]] used to drain 6 health per second while active. However, jumping preserved the speed bonus granted by this weapon and did not require the weapon to be active. Simple scripting allowed for the player to quickly switch to the gloves, jump, and then switch away.
  
====Air Crouching Scripts====
+
{{Patch name|6|27|2012}}: Replaced the damage over time of the Gloves of Running Urgently with a time-delayed [[mini-crit]] de-buff.
  
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.
+
====Idling Scripts====
 +
Most servers seek to prevent players idling for [[Item drop system|drops]]. Players can try to outsmart these systems with scripts that simulate basic movement.
  
Valve patched it so you could only crouch twice in a single jump.
+
[http://www.teamfortress.com/post.php?id=11105 An Active Solution to an Idle Threat] requires players to accept a pop-up notification in order to continue to get drops.
  
===Current Scripts===
+
===目前的巨集===
 +
====Weapon Viewmodel Hiding Scripts====
 +
There are a large number of scripts which toggle the weapon viewmodel depending on which weapon slot is selected for a class. Players often make their viewmodels 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 viewmodel 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.
  
====Weapon Hiding Scripts====
+
====Sentry Jumping Scripts====
 +
Since the [[Engineer Update]], Engineers have been able to pack up and carry their [[Sentry Gun]]s. Simultaneously introduced in the update, the [[Wrangler]] allows 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.
  
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.
+
While a human can repeat this feat, it is difficult. Some players made scripts which could reliably execute the commands in the right order at the right speed allowing them to make a Sentry jump while carrying their Sentry every time.
  
====Sentry Jumping Scripts====
+
''Note:'' The [[Rescue Ranger]] can circumvent this necessity, as it can pick up buildings at range for 130 metal.
  
Since the [[Engineer]] update, Engineers have been able to pack up and carry their [[Sentry Gun]]s. 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.
+
====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 Combat Mini-Sentry with the click of one or two mouse buttons. Such a script is especially useful when using the [[Frontier Justice]], as the player gains practically instant access to revenge crits when needed.
  
While a human can repeat this feat, it's difficult and sometimes inconsistentSome 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.
+
====靈敏度和控制巨集====
 +
對於一些對於喜歡不同的靈敏度和控制的巨集(例如,改變偵察兵,這就需要高靈敏度去快速轉動和操作,對於狙擊手,鼓勵使用低靈敏度精確瞄準這樣一隻手無意抽搐的時候不會偏離你的目標太大)These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
  
====Gunslinger Scripts====
+
====Charge Dash Scripts====
 +
Since timing a charge and jump can be difficult, some players may use a quick script that binds the two actions to a button so that the charge dash will cover the maximum amount of distance possible. The player is still required to swing their melee weapon normally to end the charge though.
  
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.
+
====Quickscope Scripts====
 +
Many players find it difficult to scope in and fire straight after to get a quick headshot. There are scripts that will zoom in and fire just by clicking one mouse button. This does require players to aim outside of the scope, though.
  
====Sensitivity and Control Scripts====
+
====Rocket Jump Scripts====
 +
In order to Rocket Jump to a maximum height or distance, it is required that the player jumps, crouches, and fires their rocket at roughly the same time. This can be easily scripted to occur with the press of a button.
  
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.
+
====Kill-bind Scripts====
 +
In certain circumstances is it beneficial for a class to be able to kill themselves. Although mostly only relevant in competitive play, there are occasional uses in public servers.
  
==See Also==
+
== 參見 ==
* [[List of useful console commands]]
+
* [[List of useful console commands/zh-hant|有用的主控台指令]]
* [[Customizing#tf.5Ccfg.5Cconfig default.cfg|Customizing - config_default.cfg]]: The default key-binds within TF2.
 
  
==External Links==
+
==外部鏈接==
  
*[http://forums.steampowered.com/forums/showthread.php?t=709568 Steam Users' Forums - TF2 Scripting Tutorial]。
+
*[http://forums.steampowered.com/forums/showthread.php?t=709568 STEAM用戶論壇 - TF2 巨集教程]。
 
*[http://warriornation.net/Forum/showthread.php?t=568008 TF2 scripting tutorial - Warrior Nation Network]。
 
*[http://warriornation.net/Forum/showthread.php?t=568008 TF2 scripting tutorial - Warrior Nation Network]。
*[http://www.gamebanana.com/scripts/games/297 FPSBanana.com - TF2 scripts]。
+
*[http://www.gamebanana.com/scripts/games/297 FPSBanana.com - TF2 巨集]。
[[Category:Customization]]
+
[[Category:Customization/zh-hant]]

Latest revision as of 12:32, 28 April 2015

巨集又稱為腳本,是使用配置文件來把控制台的指令碼綁定到鍵位或把數個指令綁定成一個新的別名

巨集所涵蓋的範圍可以從綁定鍵位到使用別名來自動重複指令。甚至可以使用巨集來創建千變萬化的行為。

巨集的文件

絕地要塞2會自動讀取以下幾個遊戲文件來實行巨集:

  • config.cfg - 這是默認的配置文件,當你在選項裏面做出更改時,便會將設定儲存在此文件。編輯此文件沒有風險,但在啟動遊戲時會影響到修改過的按鍵配置。每次啟動遊戲時會在其他設置讀取之前優先讀取。
    • config_default.cfg - 這份文件包含了一組基本的按鍵配置,如果 config.cfg 不存在時就會被執行作為備份。
  • autoexec.cfg - 這是儲存玩家設定的配置文件,你可以把巨集或指令儲存在此文件。當config.cfg和autoexec.cfg都有相同的指令時,遊戲會以autoexec.cfg為准
  • <class>.cfg - 每個兵種都有一個配置文件,你可以將綁定鍵位的指令儲存在這些文件。當你選擇了相應的兵種後,相應文件的指令便會執行。需要注意的是,若在文件中使用了開關類型的指令時作用會被保留,直到執行反向指令為止。

編輯巨集文件

若在 Windows 系統,巨集文件能在下列資料夾找到:
<Steam Folder>/SteamApps/common/team fortress 2/tf/cfg
若在 Mac 系統,巨集文件能在下列資料夾找到:
~/Library/Application Support/Steam/SteamApps/common/team fortress 2/tf/cfg
若在 Linux 系統,巨集文件能在下列資料夾找到:
~/.local/share/Steam/SteamApps/common/Team\ Fortress\ 2/tf/cfg
Since the SteamPipe update, code can also be placed in .../team fortress 2/tf/custom/yourfoldernamehere/cfg

語法

The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly. 這是一個語法的規則:

  • 無論是綁定或別名,你都要按照以下格式來編寫:
命令 <argument1> <argument2>
  • 目前有三種命令可供選擇:
  • bind - 用於將指令綁定到鍵位
  • alias - 可以將多個指令綁定成別名來一次性執行
  • exec - 可以讓客戶端加載其他配置文件
  • <argument1> 可以是鍵位的名稱或創建別名的名稱
  • <argument2> 可以是被綁定的指令或別名的指令
  • 要一次執行多條指令,你必須將所以指令用引號括住,例如:
alias "spraynpray" "+attack; wait 500; -attack"
bind "mouse3" "spraynpray"
  • 按mouse3後,開始執行別名spraynpray,然後別名spraynpray會讓你的武器進行攻擊,接著等待500幀,最後停止射擊。

綁定(bind)

最簡單的語法是 bind 指令,能夠影響按鍵執行的動作,該動作可以是個設定、指令或腳本。

bind [KEY] [COMMAND]
可以加上雙引號在按鍵名稱或指令的左右。

bind [KEY] "[COMMAND 1]; [COMMAND 2]; [COMMAND 3]"
可以加上雙引號在按鍵名,但一定要用雙引號包住多項指令。


綁定有兩種形式:
bind "e" "Voicemenu 0 0"
此綁定是當玩家按下E鍵後會觸發『Medic!』的語音指令。

bind "w" "+forward"
此綁定是當玩家按住不放 W 鍵後能夠讓玩家前進。

切換(Toggle)

這項巨集可以設置兩個或兩個以上值的指令進行切換。 toggle "sv_cheats" 0 1

綁定切換(Bindtoggle)

功能和 toggle 相同,只是綁定到一個按鍵上。 bindtoggle o "sv_cheats" 0 1

注意:若無設定數值,toggle 和 bindtoggle 則會默認數值為 0 與 1。

遞增值(Incrementvar)

可以設置一個數值以反覆執行增加或減少值。

bind MWHEELUP "incrementvar fov_desired 75 90 1"
bind MWHEELDOWN "incrementvar fov_desired 75 90 -1"

此範例能讓玩家向上滾動滑鼠滾輪時增加視野,向下滾動則減少。
註: Incrementvar 指令如果讓數值超出或變得過小時會重複循環。在此範例中,如果視野超過 90 則會下降到 75 ,反之亦然。

別名(Alias)

Alias 可以將多項指令以一個名稱代替,成為一個有效用的簡寫名稱。當一系列的指令需要被重複執行時會非常有用。
註: Alias 名稱不能包含空格。可以包含下底線、數字或符號。 Alias 會區分大小寫。

alias Call_For_Medic "Voicemenu 0 0"
bind "e" "Call_For_Medic"

此巨集是一個簡單的綁定,功能是當玩家按下 E 後會觸發『Medic!』語音指令。

alias "+Diagonal" "+moveleft; +back"
alias "-Diagonal" "-moveleft; -back"
bind "z" "+Diagonal"

此巨集可以讓玩家斜向移動,按下 Z 玩家會往左後方斜著走。

警告:下列寫法不會有作用
bind "z" "+moveleft; +back"
雖然按 Z 可以讓玩家往左邊及後方移動,但遊戲引擎不會反轉 +back 指令,導致放開 Z 後玩家不會停止向後移動。

執行(Exec)

此指令可以執行其他的文件檔。意味著複雜的巨集可以存在其他文件檔裡,以免弄亂一般的文件。

exec autoexec.cfg
此巨集將會讀取 autoexec.cfg 文件內的巨集。

回應(Echo)

此指令會將文字顯示到控制台上,對於偵錯非常有用。

echo Scripting is; echo very useful.
如果將分號(;)加在文字之間則會顯示 Scripting isvery useful. 。 或將文字用雙引號包住,如下例

echo " Scripting is very useful. "
則會將多餘的空格顯示出來,因為它包含在雙引號內。

註: 雙引號是無法顯示的符號,因為它的用途會被曲解。

等待(Wait)

此指令可使遊戲等待所設定的 FPS 數值後才執行下一個指令。
註: 這項指令對應的實際時間取決於伺服器的處理速率。
警告: Wait 指令在部分伺服器禁用。這會導致某些巨集失效,並且(在極少數的情況下)讓遊戲當機。請看 Wait Testing 避免這種情況發生。

echo Why did the chicken cross the road?; wait 66; echo To get to the other side!
This script will wait 66 frames (1 second on most servers) before printing the punchline.

絕地要塞2的鍵盤名稱

滑鼠移上按鍵即可看到按鍵名稱。

ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12

` 1 2 3 4 5 6 7 8 9 0 - = Delete

Tab ⇆ Q W E R T Y U I O P [ ] \

⇪ Caps A S D F G H J K L ; '   ↵  

⇧ Shift Z X C V B N M , . / ⇧ Shift

Ctrl Alt       Spacebar       ≣ Menu Ctrl

PrtScn ScrLk Pause

Insert Home PgUp

Delete End PgDn


       

   

Num / * -
7 8 9 +
4 5 6
1 2 3
    0     .
滑鼠按鍵 按鍵名稱
滾輪上滑 MWHEELUP
滾輪下滑 MWHEELDOWN
左鍵 MOUSE1
右鍵 MOUSE2
點擊滾輪 MOUSE3
左側鍵(下一頁) MOUSE4
右側鍵(上一頁) MOUSE5

實用的指令

主條目: TF2 指令及值數列表(英)

Spy快速偽裝

這些巨集可以讓玩家按下一個鍵後即偽裝而不用開啟偽裝菜單

偽裝命令使用以下語法:

disguise <class_number> <team_number>

<class_number>是代表兵種的編號;<team_number>是代表團隊的編號

偽裝編號參數

  • 1 <class_number>
    1: 偵察兵
    2: 狙擊手
    3: 火箭兵
    4: 爆破兵
    5: 醫護兵
    6: 重裝兵
    7: 火焰兵
    8: 間諜
    9: 工程師
  • 2 <team_number>
    1: 藍隊
    2: 紅隊
    -1: 敵隊
    -2: 同隊

Engineer快速建造

類似Spy的快速偽裝,這可以讓Engineer不必開啟建造菜單即能建造。

建築指令使用以下語法

build <building_number>
destroy <building number>

<building_number>是建築的編號

建築編號參數

  • Number: Building/Destroying
    0: 補給器
    1: 傳送裝置入口
    2: 步哨防禦槍/迷你戰鬥步哨
    3: 傳送裝置出口

以下是快速建造巨集的例子:

 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

這巨集會在建造前先破壞要建造的建築,使玩家建造前無需開啟破壞菜單。

語音指令

語音指令可以讓你在遊戲內發出特定的語音。

語音指令使用以下語法

voicemenu <menu_number> <phrase_number>

<menu_number>是編號1到3的語音菜單編號,<phrase_number>則是語音菜單1到7的語音編號

語音相關編號

  • 0 <phrase_number>
    0: 醫生!
    1: 謝謝!
    2: 前進! 前進! 前進!
    3: 往前!
    4: 往左走
    5: 往右走
    6: 好
    7: 不
  • 1 <phrase_number>
    0: 敵人來襲
    1: Spy!
    2: 前方有步哨!
    3: 這裡需要傳送裝置
    4: 這裡需要補給器
    5: 這裡需要步哨
    6: 啟動 ÜberCharge!
    7: (只有Medic可以使用)ÜberCharge 就緒
  • 2 <phrase_number>
    0: 幫我!
    1: 戰鬥咆哮
    2: 乾杯
    3: 嘲弄
    4: 收到
    5: 不行
    6: 打得好
    7: 幹得好


雜項

  • clear 清除控制台的所有訊息。
  • alias 列出所有目前定義的別名。
  • fov_desired (75-90) 設置視野距離。
  • viewmodel_fov 設置武器模型的視野,默認範圍為 54~70 之間。
  • r_drawviewmodel (0/1) 顯示(1) 或隱藏(0) 武器模型。
  • lastdisguise 使玩家偽裝成上一次偽裝的職業。 (間諜專用)
  • load_itempreset [0, 1, 2, 3] 更換自訂的 [A, B, C, D] 裝備欄位。
  • say "message" 發送公開的聊天訊息。
  • say_team "message" 發送隊伍聊天訊息。
  • +taunt 玩家會進行嘲諷動作。
  • +use_action_slot_item 玩家會使用動作欄位所裝備的物品。
  • volume (0-1) 改變遊戲中的音量。

高級巨集技巧

Toggles

It is possible to bind a key to toggle a command which would otherwise be a press and hold command.

bind w toggle
alias toggle "enable"
alias enable "alias toggle disable; +forward"
alias disable "alias toggle enable; -forward"

This script will cause a press of W to keep the player moving forward until W is pressed again.

Key combinations

It is possible to create a script where pressing one button while another is held down will change the action of the first button.

bind e call
alias call Call_For_Medic
alias Call_For_Medic "Voicemenu 0 0"
alias Call_For_Ubercharge "Voicemenu 1 6"

At this point, the script will mean that every time E is pressed, the player will call for a Medic. It also has an unused alias to call for an Ubercharge.
bind shift +toggleState
alias +toggleState "alias call Call_For_Ubercharge"
alias -toggleState "alias call Call_For_Medic

Now, pressing ⇧ Shift will redirect call to ask for an ubercharge. Releasing ⇧ Shift will make call point back at a Medic call.
When ⇧ Shift+E is pressed, the player will call for an Ubercharge, rather than for a Medic.

Wait-testing

由於 wait 指令是一些巨集不可缺少的部分,利用此指令查看伺服器是否能使用等待指令。

alias waitTester "alias waitTest waitPositive; wait; waitTest"
alias wait "alias waitTest waitNegative"
alias waitPositive "echo Wait is enabled on this server.; exec waitPositive.cfg"
alias waitNegative "echo Wait is DISABLED on this server!; exec waitNegative.cfg"
waitTester

This script relies on the fact that if the wait command is disabled on a server, the alias named wait can be defined by the user. Thus, the script creates an alias named waitTest which by default points to waitPositive, but if wait is not allowed (and can thus be defined by the user), will be redirected to waitNegative.

Loops

Warning: Loops which run without a wait command will cause the TF2 client to hang. It is highly suggested to run a looping script only after a wait testing script.
It is generally considered bad form to have one alias point to itself, as although the loop can be broken out of, it cannot be reset. Therefore, looping scripts tend to include two parts to the loop: The part that waits, and the part that loops.

bind g "loopKey"
alias loopKey startLoop
alias startLoop "alias loopKey stopLoop; +attack; alias redirect loop; loop"
alias stopLoop "-attack; alias redirect; alias loopKey startLoop"
alias loop "+left; wait 33; +right; wait 33; redirect"
alias redirect loop

This script will start looping once G is pressed. It begins by firing, and then switches the player's view back and forth every 33 frames (1second on most servers). Pressing G would cause the next iteration of the loop to stop, also stopping the firing.


Medic Radar

這些巨集可以讓Medic只要按住一個按鍵,就將自動呼救的上限提升至150%(醫護兵能超量治療的生命上限),讓他可以看到附近所有隊友的位置。

 alias "autocall_default" "hud_medicautocallersthreshold "75""
alias "autocall_all" "hud_medicautocallersthreshold "150""
alias "+radar" "autocall_all"
alias "-radar" "autocall_default"
bind mouse3 "+radar"

預設的自動呼救值(也就是沒有使用這個巨集時的自動呼救值)可以調整為任何你想要的值(在這個例子中是75%),啟動巨集的按鈕也可以改為任意按鍵(在這個例子中是mouse3)。

值得注意的巨集

有些巨集會破壞遊戲的環境和平衡。

已被修正的巨集

手槍連射巨集

原先遊戲裏的手槍只能單發射擊,後來有人編寫了手槍連射巨集,讓玩家一直按下鍵位即可連續發射手槍。後來Valve為了確保遊戲公平性,讓玩家即使不使用巨集也可以連續發射手槍。

Targe Turn Scripts

用鍵盤改變視角與用滑鼠改變視角,是不同的兩個動作。衝擊刺盾是第一個限制改變視角速度的武器,而Valve雖然對使用該武器時,滑鼠改變視角的速度做出限制,卻忘了對鍵盤指令做出相同限制。有玩家利用這個特性,寫了重新改變輸出的巨集,讓他們可以用正常的速度改變視角。最複雜的例子中,玩家在衝刺時,滑鼠的x軸指令被改變為相同結果的鍵盤指令,在衝刺結束後再將這個改變還原。

Valve之後對鍵盤指令做出相同限制,因此這個巨集再也沒有作用了。然而,還是可以寫出一個巨集,讓玩家在衝刺時有超高滑鼠靈敏度,在攻擊時恢復正常。It is also possible to turn easily while using a gamepad's analog sticks.

蹲跳巨集

原先跳到空中時,蹲下的次數是沒有限制的。因此你可以在空中執行一個不斷超高速蹲下站起的巨集,讓遊戲沒辦法正常判斷子彈是否擊中你。Valve修正為在空中只能蹲下兩次。

Gloves of Running Urgently Scripts

The Gloves of Running Urgently used to drain 6 health per second while active. However, jumping preserved the speed bonus granted by this weapon and did not require the weapon to be active. Simple scripting allowed for the player to quickly switch to the gloves, jump, and then switch away.

2012年6月27日更新: Replaced the damage over time of the Gloves of Running Urgently with a time-delayed mini-crit de-buff.

Idling Scripts

Most servers seek to prevent players idling for drops. Players can try to outsmart these systems with scripts that simulate basic movement.

An Active Solution to an Idle Threat requires players to accept a pop-up notification in order to continue to get drops.

目前的巨集

Weapon Viewmodel Hiding Scripts

There are a large number of scripts which toggle the weapon viewmodel depending on which weapon slot is selected for a class. Players often make their viewmodels 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 viewmodel 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 introduced in the update, the Wrangler allows 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 is difficult. Some players made scripts which could reliably execute the commands in the right order at the right speed allowing them to make a Sentry jump while carrying their Sentry every time.

Note: The Rescue Ranger can circumvent this necessity, as it can pick up buildings at range for 130 metal.

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 Combat Mini-Sentry with the click of one or two mouse buttons. Such a script is especially useful when using the Frontier Justice, as the player gains practically instant access to revenge crits when needed.

靈敏度和控制巨集

對於一些對於喜歡不同的靈敏度和控制的巨集(例如,改變偵察兵,這就需要高靈敏度去快速轉動和操作,對於狙擊手,鼓勵使用低靈敏度精確瞄準這樣一隻手無意抽搐的時候不會偏離你的目標太大). These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.

Charge Dash Scripts

Since timing a charge and jump can be difficult, some players may use a quick script that binds the two actions to a button so that the charge dash will cover the maximum amount of distance possible. The player is still required to swing their melee weapon normally to end the charge though.

Quickscope Scripts

Many players find it difficult to scope in and fire straight after to get a quick headshot. There are scripts that will zoom in and fire just by clicking one mouse button. This does require players to aim outside of the scope, though.

Rocket Jump Scripts

In order to Rocket Jump to a maximum height or distance, it is required that the player jumps, crouches, and fires their rocket at roughly the same time. This can be easily scripted to occur with the press of a button.

Kill-bind Scripts

In certain circumstances is it beneficial for a class to be able to kill themselves. Although mostly only relevant in competitive play, there are occasional uses in public servers.

參見

外部鏈接