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

Zh/Trigger changelevel: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(Created page with "{{base brush|trigger_changelevel}} It triggers a level change. {{code class|CChangeLevel|triggers.cpp}} {{note|This brush entity does not work in Half-Life 2: Deathmatch...")
 
m (Substituted IO templates)
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{base brush|trigger_changelevel}} It [[trigger]]s a level change.
<!-- When this page is updated to {{langsp}} or {{language subpage}} instead of {{lang}}, please move {{this is a}} to the base page, as it is automatically translated. -->{{lang|Trigger changelevel}}{{subpage|[[Level Transitions]]}}
{{code class|CChangeLevel|triggers.cpp}}
{{note|This brush entity does not work in [[Half-Life 2: Deathmatch]].}}


==Notes==
{{CD|CChangeLevel|file1=triggers.cpp}}
Place an [[info_landmark]] in both maps to mark the ''same'' location in both maps.
{{this is a|brush entity|name=trigger_changelevel}}当被触发时,它将提示游戏加载下一个关卡
{{note|此实体在多人游戏中不起作用。如果你需要在多人游戏中更换关卡,你必须要通过{{ent|point_servercommand}}实体或在代码中使用<code>changelevel</code>指令,这不会保留实体状态}}
{{note|在{{l4ds}}中,建议使用[[info_changelevel]],尽管此实体仍然可用{{cite|1}},但游戏不会将其体积内的导航网格附加CHECKPOINT属性}}
{{bug|如果<code>Start Disabled</code>键值设置为<code>“是”</code>,此实体对于[[player|玩家]]会有碰撞,如果此时正在其体积内进行关卡转换,这会导致玩家被卡住}}


To fire events in the next level, use a trigger output to turn on an [[env_global]] in the current level. The entity has a few pre-defined states but you can manually type your own custom state. Create a [[logic_auto]] in the next level that checks for the state set by the env_global. Now use the '''OnChangeLevel''' output of the logic_auto to trigger events.
==注意事项==
在两个地图中放置一个[[info_landmark]],以标记两个地图中的''相同''位置
触发关卡转换时,[[info_landmark]]必须位于[[player|玩家]]的[[PVS|视野范围]]内。否则关卡转换将失败
两个[[info_landmark]]实体必须具有相同的名字。并且不能带有空格。它们也不能位于实心固体内
landmark的实体名称和地图名称的长度都必须小于32个字符


To control which entities go through the level transition, create one or more [[trigger_transition]]s and give them the same name as the landmark. Any entities within the trigger_transition(s) will go to the next map.
<!--TODO:需要更好的翻译↓-->
{{note|虽然Landmark实体在几何空间上必须位于同一位置,但其并不要求坐标上的完全一致。Landmark实体实际上可以放置在正在更改的新地图网格中的任何位置,只要它周围的转换场景与上一个关卡的完全相同即可。这可以帮助解决大场景下的换图,即:玩家在顶视图的东边移动,并且必须在下一张地图中继续这样做,而这在从结束位置开始下一张地图的情况下是不可能的。简化关卡过渡附近的几何图形可以使处理它们变得更容易!}}


Level transitions must be two-way. That is to say, there must be a trigger_changelevel in the next level that points to the current level, as well as the trigger_changelevel taking the player to the next level. If a one-way level transition is desired, simply make this second trigger_changelevel inaccessible to the player (and/or check the "Disable Touch" flag).
关卡转换必须是双向的,即下一张地图必须有一个指向当前地图的trigger_changelevel,而当前地图也必须要有一个指向下一张地图的trigger_changelevel。如果需要进行单向关卡转换,只需要让玩家无法接触到回到当前地图的trigger_changelevel即可(或者勾选Flags中的<code>Disable Touch</code>选项)


The [[info_landmark]] must be in the player's [[PVS]] when the level change is triggered. If it is not, the level change will fail. Both [[info_landmark]] entities must have the same name.
{{warning|尽管[[info_landmark]]应该在两个关卡之间位于相同位置,但两张图的trigger_changelevel固体'''不能'''位于同一位置,否则玩家将会陷入死循环,不断的在两个关卡之间来回切换}}


Although the [[info_landmark]] should be in a corresponding position in both levels, the two trigger_changelevel brushes must '''NOT''' be in the same place in each level. If they are, you will be thrown into an infinite loop, endlessly ping-ponging back and forth between the two levels.
要在下一关触发事件,请在当前地图通过输出启用[[env_global]]。实体有几个预定义状态,但您可以手动输入自己的自定义状态。然后创建一个[[logic_auto]]来检查env_global的状态。在env_global启用的情况下,你可以使用'''OnMapTransition'''来在完成关卡转换后触发事件


{{note|Although the Landmark entity must be in the same place geometry-wise, it doesn't need to be in the exact location in the map's coordinates (This also includes height). A landmark could literally be placed anywhere in the new map grid thats being changed too, as long as the transition geometry surrounding it is exactly as the previous level's geometry. This can help with scenarios such as having large maps, i.e: The player traverses east of the top view, and must continue to do so in the next map, which would be impossible given starting the next map in the ending location. Simplifying your geometry near level transitions can make working on them much easier!}}
要控制哪些实体会保留到下一张地图,创建一个或多个[[trigger_transition]],并给予它们和Landmark实体相同的名字。其体积内的所有实体都将保留到下一张地图
{{note|不适用于{{l4ds}}
}}


==Keyvalues==
==Keyvalues==
{{KV|Name|target_source|Name of the brush.}}
{{KV Targetname}}
{{KV|New Map Name|string|Name of the map to change to.}}
{{KV|New Map Name|intn=map|string|要转换到的下一张地图名}}
{{KV|Landmark Name|target_destination|Name of the landmark to use. (See above for details!)}}
{{KV|Landmark Name|intn=landmark|target_destination|要使用的Landmark实体名称(具体细节见上方)}}


==Flags==
==Flags==
* 2 : Disable Touch
{{Fl|2|Disable Touch|禁止通过触碰触发关卡转换}}
* 4 : To Previous Chapter
{{Fl|4|To Previous Chapter|至上一个章节}}
{{bug|此Flag会导致实体完全实心|tested={{hl2}}}}


==Inputs==
==Inputs==
{{IO|ChangeLevel|Cause the level change. Use this when triggering the level change with a button, etc.}}
{{I|ChangeLevel|手动触发关卡转换,用于通过按钮触发等非直接触碰进行的关卡转换}}
{{Warning|Since the 2007 engine this input will do nothing when used on a multiplayer server.}}
{{Warning|自{{src07|4}}起,此输入对于多人游戏不起作用}}


==Outputs==
==Outputs==
{{IO|OnChangeLevel|Fired when the level changes.}}
{{O|OnChangeLevel|当进行关卡转换时触发}}


{{sensor brush}}
{{sensor brush}}
{{references|1=
{{ref2|cite id=1|详见<code>l4d_smalltown02_drainage</code> / <code>c10m2_drainage</code>}}}}

Latest revision as of 07:52, 21 April 2025

English (en)中文 (zh)Translate (Translate)
C++ 类层级
CChangeLevel
CBaseTrigger
CBaseToggle
CBaseEntity
C++ triggers.cpp

trigger_changelevel是一个固体实体(en),可在所有的 起源 起源 游戏中使用。当被触发时,它将提示游戏加载下一个关卡

Note.png注意:此实体在多人游戏中不起作用。如果你需要在多人游戏中更换关卡,你必须要通过point_servercommand实体或在代码中使用changelevel指令,这不会保留实体状态
Note.png注意:求生之路系列求生之路系列中,建议使用info_changelevel,尽管此实体仍然可用[1],但游戏不会将其体积内的导航网格附加CHECKPOINT属性
Icon-Bug.png错误:如果Start Disabled键值设置为“是”,此实体对于玩家会有碰撞,如果此时正在其体积内进行关卡转换,这会导致玩家被卡住  [todo tested in ?]

注意事项

在两个地图中放置一个info_landmark,以标记两个地图中的相同位置 触发关卡转换时,info_landmark必须位于玩家视野范围内。否则关卡转换将失败 两个info_landmark实体必须具有相同的名字。并且不能带有空格。它们也不能位于实心固体内 landmark的实体名称和地图名称的长度都必须小于32个字符

Note.png注意:虽然Landmark实体在几何空间上必须位于同一位置,但其并不要求坐标上的完全一致。Landmark实体实际上可以放置在正在更改的新地图网格中的任何位置,只要它周围的转换场景与上一个关卡的完全相同即可。这可以帮助解决大场景下的换图,即:玩家在顶视图的东边移动,并且必须在下一张地图中继续这样做,而这在从结束位置开始下一张地图的情况下是不可能的。简化关卡过渡附近的几何图形可以使处理它们变得更容易!

关卡转换必须是双向的,即下一张地图必须有一个指向当前地图的trigger_changelevel,而当前地图也必须要有一个指向下一张地图的trigger_changelevel。如果需要进行单向关卡转换,只需要让玩家无法接触到回到当前地图的trigger_changelevel即可(或者勾选Flags中的Disable Touch选项)

Warning.png警告:尽管info_landmark应该在两个关卡之间位于相同位置,但两张图的trigger_changelevel固体不能位于同一位置,否则玩家将会陷入死循环,不断的在两个关卡之间来回切换

要在下一关触发事件,请在当前地图通过输出启用env_global。实体有几个预定义状态,但您可以手动输入自己的自定义状态。然后创建一个logic_auto来检查env_global的状态。在env_global启用的情况下,你可以使用OnMapTransition来在完成关卡转换后触发事件

要控制哪些实体会保留到下一张地图,创建一个或多个trigger_transition,并给予它们和Landmark实体相同的名字。其体积内的所有实体都将保留到下一张地图

Note.png注意:不适用于求生之路系列求生之路系列

Keyvalues

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

New Map Name (map) <字符串(en)>
要转换到的下一张地图名
Landmark Name (landmark) <target_destination>
要使用的Landmark实体名称(具体细节见上方)

Flags

Disable Touch : [2]
禁止通过触碰触发关卡转换
To Previous Chapter : [4]
至上一个章节
Icon-Bug.png错误:此Flag会导致实体完全实心  (tested in: 半衰期2)

Inputs

ChangeLevel
手动触发关卡转换,用于通过按钮触发等非直接触碰进行的关卡转换
Warning.png警告:起源2007 起源2007起,此输入对于多人游戏不起作用

Outputs

OnChangeLevel
当进行关卡转换时触发

参考文献

参考文献
1. 详见l4d_smalltown02_drainage / c10m2_drainage.