这篇条目有关 Source引擎。如需详情,点击这里。

func_button

From Valve Developer Community
< Zh
Jump to navigation Jump to search
English (en)Русский (ru)中文 (zh)Translate (Translate)
C++ 类层级
CBaseButton
CBaseToggle
CBaseEntity
C++ buttons.cpp

func_button是一个固体实体(en),可在所有的 起源 起源 游戏中使用。

该实体设计用于玩家可使用的按钮。当玩家使用+use(en)时,按钮会移动到按下位置。 要查看使用func_button制作键盘的示例,请参阅button_keypad(en)预设。

Tip.png提示:如果需要在模型上创建按钮(通过伤害按钮笔刷触发输出),可以直接使用prop_dynamic实体并设置其"OnTakeDamage"输出。这样会使用模型的collision mesh(en)作为按钮,而不是笔刷。
这对小物件特别有用,因为小按钮笔刷可能会因vbsp(en)的bug[澄清]导致面丢失。

Keyvalues

Note.png注意:For Keyvalues and Inputs affecting brush rendering, see Brush entity/Rendering related keyvalues and inputs(en)


Name (目标名称) <target_source>[ Edit ]
这个名称是其他实体通过 输入/输出(en) 或其他 关键值(en)(如 parentnametarget) 来引用该实体时使用的标识符。
该名称也会显示在 Hammer 编辑器的 2D 视图和 实体报告(en) 中。
参见:  所有实体均可使用的 通用键值、输入与输出(en)

Glow Entity (glow) <目标名(en)> (存在于 求生之路系列求生之路系列 之中)
指定一个实体的名称,该实体会为此按钮显示+use高光效果。
Note.png注意:求生之路2中当看向发光实体时会播放"Hand Extend"动画。
Icon-Bug.png错误:如果发光实体不在网格上,引擎可能无法正确定位,会选择靠近该位置的其他实体。  [todo tested in ?]
Use Look-At Limit (min_use_angle) <字符串(en)> (存在于自 反恐精英:全球攻势 以来) (也存在于 Garry's Mod 之中)
限制可使用的视角范围。-1表示完全背离,0表示垂直视角,1表示直视。要允许最多45°偏差,可设为cos(45°)≈0.7071;5°则为cos(5°)≈0.9962(参见点积(en))。
Move Direction (Pitch Yaw Roll) (movedir) <angle(en)>
指定按钮被使用时的移动方向。
Delay Before Reset (-1 stay) (wait) <整数(en)>
按钮按下后返回初始位置的延迟时间(秒)。返回后可再次使用。设为-1则永不返回。
Speed (speed) <整数(en)>
按钮移动速度(单位/秒)。
Health (Obsolete) (health) <整数(en)>
旧版设置按钮是否可通过射击激活的方法。应改用Damage Activates生成标志。
Lip (lip) <整数(en)>
按钮按下时留在墙外的长度(英寸)。负值会使按钮更深地缩入墙内。
Sounds (sounds) <integer choices(en)>
设置按钮按下时播放的音效。
Note.png注意:下表基于Half-Life 2制作。所有游戏都支持此键值,但部分游戏可能缺少某些音效文件。要修改这些音效,请查看hl2/scripts/game_sounds_world.txt或相应游戏的Soundscript(en)文件中Buttons.snd开头的条目(后跟此表中Value列的数字)。
Choices 
Value Description Default Sound
Buttons
0 None (Silent) common/null.wav
1 Big zap & Warmup buttons/button1.wav
2 Access Denied buttons/button2.wav
3 Access Granted buttons/button3.wav
4 Quick Combolock buttons/button4.wav
5 Power Deadbolt 1 buttons/button5.wav
6 Power Deadbolt 2 buttons/button6.wav
7 Plunger buttons/button7.wav
8 Small zap buttons/button8.wav
9 Keycard Sound buttons/button9.wav
10 Buzz buttons/button10.wav
11 Buzz Off buttons/button11.wav
12 latch locked doors/latchlocked2.wav
13 Latch Unlocked doors/latchunlocked1.wav
14 Lightswitch buttons/lightswitch2.wav
15 small bleek buttons/button15.wav
16 small deny buttons/button16.wav
17 small doop buttons/button17.wav
18 small tech deny buttons/button18.wav
19 click and combine screen fuzz buttons/button19.wav
20 roomy beep buttons/button20.wav
Levers
21 lever or wheel: turn + move sqeek buttons/lever1.wav
22 lever or wheel: latch + release gas buttons/lever2.wav
23 lever or wheel: ratchet + sqeek buttons/lever3.wav
24 lever or wheel: large ratchet buttons/lever4.wav
25 lever or wheel: clanky + gas release buttons/lever5.wav
26 lever or wheel: latch + large metal thud buttons/lever6.wav
27 lever or wheel: smaller ratchet buttons/lever7.wav
28 lever or wheel: smaller lever move buttons/lever8.wav
New buttons
31 shock buzz buttons/button21.wav
32 clickbeep buttons/button22.wav
33 tech blip buttons/button23.wav
34 clickbeepbeep open buttons/button24.wav
35 small high blip buttons/button12.wav
36 small tech fuzz blip buttons/button13.wav
37 small click bleep (change to lightswitch) buttons/button14.wav
Combine Buttons
40 combine door lock - locked buttons/combine_button_locked.wav
41 combine blip growl buttons/combine_button1.wav
42 combine squick growl buttons/combine_button2.wav
43 combine whine purr buttons/combine_button3.wav
44 combine click talk buttons/combine_button4.wav
45 combine click growl fizz buttons/combine_button5.wav
46 combine click fizz (deny) buttons/combine_button6.wav
47 combine click talker buttons/combine_button7.wav
Locked Sound (locked_sound) <integer choices(en)>
当玩家尝试使用被锁定的按钮时播放的音效。
Choices 
Value Description Default Sound
0 None common/null.wav
2 Access Denied buttons/button2.wav
8 Small zap buttons/button8.wav
10 Buzz buttons/button10.wav
11 Buzz Off buttons/button11.wav
12 Latch Locked doors/latchlocked2.wav
Unlocked Sound (unlocked_sound) <integer choices(en)>
按钮解锁时播放的音效。
证实:似乎不起作用?
Choices 
Value Description Default Sound
0 None common/null.wav
1 Big zap & Warmup buttons/button1.wav
3 Access Granted buttons/button3.wav
4 Quick Combolock buttons/button4.wav
5 Power Deadbolt 1 buttons/button5.wav
6 Power Deadbolt 2 buttons/button6.wav
7 Plunger buttons/button7.wav
8 Small zap buttons/button8.wav
9 Keycard Sound buttons/button9.wav
10 Buzz buttons/button10.wav
13 Latch Unlocked doors/latchunlocked1.wav
14 Lightswitch buttons/lightswitch2.wav
Locked Sentence (locked_sentence) <integer choices(en)>
当玩家尝试使用被锁定的按钮时播放的语音。
Choices 
Value Description
0 None
1 Gen. Access Denied
2 Security Lockout
3 Blast Door
4 Fire Door
5 Chemical Door
6 Radiation Door
7 Gen. Containment
8 Maintenance Door
9 Broken Shut Door
Unlocked Sentence (unlocked_sentence) <integer choices(en)>
按钮解锁时播放的语音。
Choices 
Value Description
0 None
1 Gen. Access Granted
2 Security Disengaged
3 Blast Door
4 Fire Door
5 Chemical Door
6 Radiation Door
7 Gen. Containment
8 Maintenance area
Master (Obsolete) (master) <target_destination>
旧版支持:主控实体的名称。如果主控未被激活,此按钮无法按下。

Flags

Don't move : [1]
Toggle : [32]
使按钮在被反复按下时触发"OnIn"和"OnOut"输出。
当同时设置"Damage Activates"时不会触发"OnOut"。解决方法是可以让此按钮"按下"另一个只设置了"toggle"和"don't move"标志的按钮。
Touch Activates : [256]
Damage Activates : [512]
设置后,按钮在被伤害时会触发"OnPressed"。与其他输入选项一样会遵守锁定状态。
"OnDamaged"会在按钮被按下时触发,即使被锁定也会触发。
Use(en) Activates : [1024]
Starts locked : [2048]
默认锁定
Sparks : [4096]
Non-solid : [16384] (存在于自 反恐精英:全球攻势(也存在于 Garry's Mod 之中) 以来)
无碰撞
Tip.png提示:在其他游戏中使用func_rot_button替代非固体按钮,或使用%CompileNonSolid(en)材质。
Icon-Bug.png错误:Half-Life 2 series中非固体按钮可能导致你与按钮后面或旁边的物体交互。

Inputs

Lock
锁定按钮,使其无法使用。
Icon-Bug.png错误:不要在按下状态时锁定;解锁后将无法返回。  [todo tested in ?]
Unlock
解锁按钮,使其可用。
Press
模拟按下按钮的操作。
PressIn
模拟按下按钮的操作,将其移动到底部位置。
PressOut
模拟松开按钮的操作,将其移动到顶部位置。触发OnPressed输出。

Outputs

OnDamaged
!activator = 造成伤害的实体
!caller = this entity
当按钮受到伤害时触发,无论是否锁定或是否设置了"Damage Activates"。
PlacementTip.png示例:可用于通过摧毁被锁按钮来开门,而按"+use"会播放"Deny"音效。
OnPressed
!activator = 按下按钮的玩家或触发此输入的实体
!caller = this entity
当按钮通过标志设置的任何方式被激活时触发。
OnUseLocked
!activator = 使用按钮的玩家
!caller = this entity
当按钮在锁定时被使用时触发。
OnIn
!activator = 导致按下的实体或最后伤害按钮的实体[证实]
!caller = this entity
当按钮到达按下位置时触发。
OnOut
!activator = 导致按下的实体或最后伤害按钮的实体[证实]
!caller = this entity
当按钮到达松开位置时触发。"Delay Before Reset"会在延迟结束后触发此输出。如果设置了"Toggle"标志,再次按下按钮会触发此输出。

参见