Zh/Generic Keyvalues, Inputs and Outputs: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
No edit summary
 
Line 1: Line 1:
{{LanguageBar}}
{{LanguageBar|Generic Keyvalues, Inputs and Outputs|title=通用键值、输入与输出}}
{{TabsBar|main=s2|base=Generic Keyvalues, Inputs and Outputs}}
{{TabsBar|main=s2|base=Generic Keyvalues, Inputs and Outputs}}
{{Toc-right}}
{{Toc-right}}


The following are generic keyvalues, inputs and outputs available to all entities. They are not necessarily in {{L|FGD}} of every game / entity but do exist on each entity as they come from {{L|CBaseEntity}} class. If they are not in FGD for an entity it may be because using them for that entity is unintended or may not work well (ex. parenting a {{ent|prop_physics}}) and such cases are up for testing and documenting those would be on given entity's page. Some entities may also override the functionality of the given k/i/o and those cases also would be documented on the given entity's page.
以下是所有实体均可使用的通用键值(Keyvalues)、输入(Inputs)和输出(Outputs)。它们不一定出现在每个游戏/实体的{{L|FGD}}中,但作为{{L|CBaseEntity}}类的成员实际存在于每个实体。若FGD中未包含,可能是因为对该实体的使用不符合设计意图或效果不佳(例如让{{ent|prop_physics}}建立父子关系),此类情况需通过测试验证并在对应实体页面记录。部分实体可能会覆写特定键值/输入/输出的功能,这些例外也将在对应页面说明。


{{Note|Not every single one is neccessarily listed here as many would not be useful or have very niche use. {{Todo|{{L|CBaseEntity}} page will contain every availalbe kio}} }}
{{Note|此处未列出所有键值,因部分用途极为特殊或实用价值有限。}}


== Keyvalues ==
<noinclude>{{/Keyvalues}}
{{KV|Collisions|intn=solid|choices|该实体的碰撞方式。
:*0: 无
:*1: BSP ({{L|QPhysics}}) {{Not in FGD:zh-cn}} {{bug|hidetested=1|在 {{portal2}} 中,如果使用 QPhysics 碰撞的实体被 {{L|Gel}} 击中,游戏将崩溃!}}
:*2: {{L|Bounding box|Bounding Box|边界框}}
:*3: {{L|Bounding box|Oriented Bounding Box|定向边界框}} (用于运行时生成的要旋转的笔刷实体) {{Not in FGD:zh-cn}}
:*4: {{L|Bounding box|Oriented Bounding Box|定向边界框}},仅限于 {{L|QAngle|Yaw}} {{Not in FGD:zh-cn}}
:*5: Custom/Test<nowiki>|</nowiki>自定义/测试(通常不会与任何东西发生碰撞) {{Not in FGD:zh-cn}}
:*6: {{L|VPhysics}}}}
{{KV|{{L|targetname|Name}}|intn=targetname|string|其他实体用来指代该实体的名称。}}
{{KV|{{L|Parent}}|intn=parentname|targetname|实体的父级实体,该实体可以与父实体保持移动偏移。名称后面可以添加一个附属点,以逗号隔开。 (<code>parentname [targetname],[attachment]</code>){{tip|转换至下一张地图的实体关系会依然存在。}}{{tip|一些不适合做父实体的实体可能难以运行,利用{{ent|phys_constraint}}可以解决。}}}}
{{KV|{{L|Origin}} (X Y Z)|intn=origin|coordinates|实体处于世界中的位置,旋转实体会以实体坐标原点旋转。{{note|Hammer 不会仅在编辑器中相应地移动实体。}}}}
{{KV|{{L|Pitch Yaw Roll}} (Y Z X)|intn=angles|angle|实体在世界中的方位,Pitch围绕X轴旋转,可以称为俯仰角。Yaw围绕Z轴旋转,可以称为偏航角,roll围绕Y轴旋转。{{note|尽管 Hammer 不显示新角度,但其仍然适用于固实体。}}}}
{{KV|{{L|Classname}}|intn=classname|string|nofgd=1|确定实体''之前''它生成的特征。{{tip|使用{{ent|AddOutput}}输入更改 Classname 仍然会影响游戏的代码,例如使类名与 {{L|S_PreserveEnts}} 列表中的一个元素匹配将使实体在新一轮中持续存在!}}}}
{{KV|{{L|Spawnflags}}|intn=spawnflags|flags|实体所具有的标志/标签,依实体所具有而定。|nofgd=1}}
{{KV|{{L|Effect flags|Effects}}|intn=effects|flags|要使用的效果标志的组合。|nofgd=1}}
{{KV|Entity Scripts|intn=vscripts|scriptlist|在所有实体生成后执行的 {{L|VScript}} 文件(无文件扩展名)的空格分隔列表。这些脚本都在同一个脚本范围内执行,以后的脚本会覆盖任何相同的变量和函数。在 {{L|worldspawn}} 实体上执行的脚本将放置在根作用域中。|since=L4D2|also={{tf2}}}}
{{KV|{{L|Entity_Scripts#Thinker_Functions|Think function}}|intn=thinkfunction|string|此实体脚本中的函数名称,该函数将在脚本持续时间内每 100 毫秒(每秒 10 次)自动调用一次。它可用于创建计时器或模拟自主行为。返回值(如果存在)将设置下一次调用之前的时间。尽量避免在此函数中进行{{L|expensive|昂贵}}的操作,因为它可能会导致性能问题。|since=L4D2|also={{tf2}}}}
{{KV|{{L|Lag Compensation}}|intn=LagCompensate|boolean|设置为'''是'''以延迟补偿此实体。应该非常谨慎地使用!|nofgd=1|since=L4D2}}
{{KV|Is Automatic-Aim Target|intn=is_autoaim_target|bool|如果设置为 1,当实体位于十字准线下方时,该实体将减慢控制台和操纵杆控制器的瞄准移动速度。|nofgd=1|since=CSGO}}


{{/Inputs}}


== Inputs ==
{{/Outputs}}</noinclude><includeonly>{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Keyvalues}}
{{I|AddContext|将此实体添加到{{L|Response System|响应上下文}}列表中。参见 {{L|Context|上下文}}。|param=string}}
{{I|{{Lx|AddOutput}}|为此实体分配一个新的键值/输出。对于键值,有些依赖于额外的代码,不能仅通过此输入进行更改。必须遵循严格的格式:
:{{Expand|<syntaxhighlight lang="PowerShell">
// 更改键值的格式: "AddOutput [键] [值]"
//// 原始文本:
"OnUser1" "!self,AddOutput,targetname new_name"


// 添加输出的格式: "AddOutput {目标名称}:{输入名称}:{参数}:{延迟}:{最大触发次数,-1 代表无限}"
{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Inputs}}
//// 原始文本:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// 参数可以留空,但仍应包含空的空白。
//// 原始文本:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
</syntaxhighlight>| 语法<nowiki>:</nowiki>}}|param=string}}
{{I|ClearContext|从此实体的列表中移除所有上下文。}}
{{I|ClearParent|从运动层次结构中移除此实体,使其可以独立移动。}}
{{I|FireUser1|to=FireUser4|触发相应的<code>OnUser</code>输出;参见 {{L|User Inputs and Outputs}}。}}
{{I|{{L|Kill}}|从世界中移除此实体及任何附属于它的实体。}}
{{I|KillHierarchy|功能与<code>Kill</code>相同,但此实体和任何附属于它的实体在同一帧内被击杀,比<code>Kill</code>输入稍快。}}
{{I|RemoveContext|从此实体的列表中移除一个上下文。名称应与现有上下文的键匹配。|param=string}}
{{I|SetParent|与此实体一起移动。参见 {{L|Entity Hierarchy (parenting)}}。|param=string}}
{{I|SetParentAttachment|将此实体更改为附加到其父级上的特定{{L|attachment}}点。实体将被传送,以便其根{{L|bone}}的位置与附件的位置匹配。实体必须在发送此输入之前被附加。|param=string}}
{{I|SetParentAttachmentMaintainOffset|如上所述,但不进行传送。实体保留相对于附件的当前位置。|param=string}}
{{I|Use|与玩家调用{{L|+use}}相同;在大多数情况下没有效果。|nofgd=1}}
{{I|SetTeam|更改此实体的团队。|nofgd=1|param=integer}}
{{I|TeamNum|此输入更改<code>TeamNum</code>属性的值。|nofgd=1|param=integer}}
{{I|DispatchResponse|向实体分发响应。参见 {{L|Response}} 和 {{L|Concept}}。|param=string|nofgd=1}}
{{I|DispatchEffect|从实体的原点分发特殊效果;另见 {{L|List of Client Effects}}。自{{l4d}}以来被{{L|particle}}系统取代。|param=string|removed={{l4d}}|nofgd=1}}
{{I|RunScriptFile|从磁盘执行{{L|VScript}}文件,无需文件扩展名。脚本内容与接收实体的脚本作用域合并。|param=script|since={{l4d2}}|also={{tf2}}}}
{{I|RunScriptCode|在接收输入的实体的作用域中执行一串VScript源代码。通过控制台触发时可能需要字符串引号。|param=string|since={{l4d2}}|also={{tf2}}}}
{{I|CallScriptFunction|调用在接收实体的作用域中定义的VScript函数。|param=string|since={{l4d2}}|also={{tf2}}|nofgd=1}}
{{I|TerminateScriptScope|销毁接收实体的脚本作用域。|only={{tf2}}|nofgd=1}}
{{I|SetLocalOrigin|将此实体发送到地图中的某个位置。如果实体附属于某个东西,它将相对于父级偏移此量。|param=coordinates|since={{as}}|nofgd=1}}
{{I|SetLocalAngles|设置此实体的角度。|param=angles|since={{as}}|nofgd=1}}


== Outputs ==
{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Outputs}}</includeonly>
{{O|OnUser1|to=OnUser4|这些输出分别在相应编号的 FireUser1 到 FireUser4 输入触发时触发;参见 {{L|User Inputs and Outputs|用户输入和输出}}。}}
{{O|OnKilled|only={{l4d}}|当实体被击杀并从游戏中移除时触发此输出。}}


== See Also ==
== 另见 ==
* {{L|CBaseEntity}}
* {{L|CBaseEntity}}
* {{L|Rendering and studio model related KIO}}
* {{L|FGD}}
* {{L|FGD}}
<!--
以下includeonly区块用于通过LanguageBar标志按钮翻译页面时使用
(在英文版本中这些子页面仅保留其页面历史记录)
--></noinclude><includeonly>{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Keyvalues}}
{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Inputs}}
{{safesubst::Generic_Keyvalues,_Inputs_and_Outputs/Outputs}}</includeonly>

Latest revision as of 21:42, 28 June 2025

English (en)中文 (zh)Translate (Translate)
Info content.png
This page has not been fully translated.
You can help by finishing the translation.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)
This notice is put here by LanguageBar template and if you want to remove it after updating the translation you can do so on this page.


以下是所有实体均可使用的通用键值(Keyvalues)、输入(Inputs)和输出(Outputs)。它们不一定出现在每个游戏/实体的FGD(en)中,但作为CBaseEntity(en)类的成员实际存在于每个实体。若FGD中未包含,可能是因为对该实体的使用不符合设计意图或效果不佳(例如让prop_physics建立父子关系),此类情况需通过测试验证并在对应实体页面记录。部分实体可能会覆写特定键值/输入/输出的功能,这些例外也将在对应页面说明。

Note.png注意:此处未列出所有键值,因部分用途极为特殊或实用价值有限。

键值(Keyvalues)

Name(en) (targetname) <字符串(en)>
其他实体引用此实体时使用的名称。
Class(en) (classname) <字符串(en)>
决定实体生成前的特性。
Tip.png提示:运行时修改仍有特定用途,但需谨慎使用。
Global Entity Name(en) (globalname) <字符串(en)>
当实体转移到具有相同全局名称的另一地图时,属性将复制到目标实体。
Icon-Important.png重要:仅适用于半衰期2风格地图过渡的单人游戏
Model (model) <字符串(en)>
实体的游戏内表现形式。
Origin(en) (X Y Z) (origin) <coordinates(en)>
实体中心在世界中的位置。
Icon-Bug.png错误:在Hammer中手动编辑此值不会同步移动点实体。
Pitch Yaw Roll(en) (Y Z X) (angles) <angle(en)>
实体的世界空间朝向。
Flags(en) (spawnflags) <flags(en)>
切换实体专属特性。
Damage Filter (damagefilter) <target_destination>
控制哪些实体可伤害此实体的过滤器名称。

父级关系

Parent(en) (parentname) <目标名(en)>
保持与此实体的初始偏移量。

Vscript

Entity Scripts (vscripts) <脚本列表(en)>
以空格分隔的VScript文件列表,在所有实体生成后执行。
Think function(en) (thinkfunction) <字符串(en)>
实体脚本中定期自动调用的函数名。

渲染

RenderFields:


渲染模式(en) (rendermode) <byte choices(en)>
在此实体上设置非标准渲染模式。
Render Modes
  • 0: 正常
  • 1: 颜色
  • 2: 纹理
  • 3: 发光
  • 4: 实体/阿尔法测试 Obsolete
  • 5: 叠加
  • 6: 已移除,无作用 Obsolete
  • 7: 叠加分数帧
  • 8: 阿尔法叠加
  • 9: 世界空间发光
  • 10: 不渲染
Render FX(en) (renderfx) <byte choices(en)>
各种有点遗留的阿尔法效果。请参见渲染效果(en)
Render Amount / Transparency (renderamt) <byte(en)>
Transparency amount, requires a Render Mode other than Normal. 0 is invisible, 255 is fully visible.
Render Color (R G B) (rendercolor) <color255(en)>
Color tint.

阴影:

Disable Shadows (disableshadows) <布尔值(en)>
防止该实体生成廉价的渲染到纹理的阴影,或如果实体是 prop_static 的光照贴图阴影。不影响影子映射。
禁用接收阴影 (disablereceiveshadows) <布尔值(en)>
防止该实体接收动态阴影。
Shadow Cast Distance (shadowcastdist) <整数(en)> 不存在于FGD!
设置实体投射动态阴影的距离。0 表示从 shadow_control 实体开始的默认距离。
Disable Shadow Depth (disableshadowdepth) <布尔值(en)> (存在于自 传送门2 以来)
用于禁用此实体的阴影深度(用于投影纹理)的渲染。
Disable flashlight (disableflashlight) <布尔值(en)> (存在于自 传送门2 以来)
用于禁用此实体的投影纹理照明和阴影。
Projected Texture Cache (shadowdepthnocache) <integer choices(en)> (存在于自 传送门2 以来)
用于提示投影纹理系统缓存此实体的阴影体积是否足够,或改为强制每帧渲染。
选项
  • 0 : 默认
  • 1 : 无缓存 - 每帧渲染
  • 2 : 缓存 - 只渲染一次

其他

Effects(en) (effects) <flags(en)>
特效标志组合。
Lag Compensation(en) (LagCompensate) <布尔值(en)>
延迟补偿开关。
Is Automatic-Aim Target (is_autoaim_target) <布尔值(en)>
控制是否作为自动瞄准目标。

输入

AddOutput(en) <字符串(en)>
为实体添加新的键值/输出。某些键值需要额外代码支持,仅通过此输入修改可能无效。
格式:<键名> <值>
格式:<输出名称> <目标实体>:<输入名称>:<参数>:<延迟>:<最大触发次数(-1表示无限)>
Kill(en)
从场景中移除该实体及其所有子实体。
FireUser1 to FireUser4  <字符串(en)>
触发对应的OnUser输出;参见用户输入与输出(en)
Warning.png警告:此输入会接收但不处理字符串参数。若从可能发送值的输出触发此输入会导致问题,请确保指定虚拟字符串参数,否则控制台会报"错误的输入/输出链接"错误。
SetDamageFilter <目标名(en)>
设置实体受到伤害时使用的过滤器(en)

父子关系

SetParent <目标名(en)>
支持!activator但不支持!caller
使实体跟随目标实体移动。参见实体层级(父子关系)(en)
SetParentAttachment <字符串(en)>
将实体附着到父实体的特定附着点(en)。实体会传送使其根骨骼(en)位置与附着点匹配。使用前需先建立父子关系。
SetParentAttachmentMaintainOffset <字符串(en)>
功能同上,但保持当前位置偏移。
ClearParent
将实体从移动层级中移除,使其可独立移动。
KillHierarchy
功能与Kill相同,但会同时移除所有子实体,执行效率略高。

VScript

RunScriptFile <脚本(en)> (存在于自 求生之路2 以来) (也存在于 军团要塞2分支 之中)
执行磁盘上的VScript(en)文件(不含扩展名)。脚本内容会合并到接收实体的脚本作用域。
RunScriptCode <字符串(en)> (存在于自 求生之路2 以来) (也存在于 军团要塞2分支 之中)
在接收实体的作用域中执行VScript代码。可使用activatorcallerself变量(同RunScriptFile)。
Warning.png警告:Hammer对象属性对话框(en)的任何文本字段中使用引号符号"会导致VMF(en)文件损坏,必须通过文本编辑器直接编辑VMF文件并删除额外添加的引号符号才能修复。
Tip.png提示:军团要塞2分支中反引号`会被转为引号"。如需字符串建议使用RunScriptFile实体脚本(en)
Icon-Bug.png错误:在无脚本作用域的实体上使用此输入访问activatorcaller会导致错误。军团要塞2分支 军团要塞2分支已修复此问题。
CallScriptFunction <字符串(en)> (存在于自 求生之路2 以来) (也存在于 军团要塞2分支 之中) 不存在于FGD!
调用接收实体作用域中定义的VScript函数。
TerminateScriptScope  (存在于 军团要塞2分支 之中) 不存在于FGD!
销毁接收实体的脚本作用域。

上下文

AddContext <字符串(en)>
添加响应系统(en)上下文。参见上下文(en)
ClearContext
清除实体的所有上下文。
Warning.png警告:除非调试需要,否则不建议使用此输入,特别是对玩家实体,可能清除VScript模块存储的重要数据。
RemoveContext <字符串(en)>
移除指定的上下文。

渲染

RenderFields:

Alpha <整数 0-255 (en)>
Sets the entity's transparency to a number from 0 (invisible) to 255 (fully visible). Requires the entity to have its rendermode set to a number other than 0.
Color <color255(en)>
Sets an RGB color for the entity.

Shadow:

DisableShadow
Turn dynamic shadows off for this entity. Identical to applying  EF_NOSHADOW.
EnableShadow
Turn dynamic shadows on for this entity.
DisableReceivingFlashlight  (存在于自 传送门2 以来)
This object will not receive light or shadows from projected textures.
EnableReceivingFlashlight  (存在于自 传送门2 以来)
This object may receive light or shadows from projected textures.

其他

Use  不存在于FGD!
模拟玩家按+use键,多数情况下无效。
SetTeam <整数(en)> 不存在于FGD!
更改实体所属队伍。
TeamNum <整数(en)> 不存在于FGD!
修改TeamNum属性值。
DispatchResponse <字符串(en)> 不存在于FGD!
触发实体响应。参见响应(en)概念(en)
DispatchEffect <字符串(en)> (被移除求生之路 以来) 不存在于FGD!
从实体位置触发特效(求生之路后改用粒子系统)。
SetLocalOrigin <coordinates(en)> (存在于自 传送门2 以来) 不存在于FGD!
设置实体局部坐标(若存在父实体则为相对偏移)。
SetLocalAngles <angles(en)> (存在于自 传送门2 以来) 不存在于FGD!
设置实体角度。

输出

OnUser1 to OnUser4
!activator = FireUser1-4输入的触发者
!caller = this entity
这些输出会分别在对应的FireUser1至FireUser4输入触发时激活;参见用户输入与输出(en)
OnKilled  (存在于 求生之路 之中)
!activator = !caller = none
当实体被杀死并从游戏中移除时触发此输出。

另见