User:Yakumo koishi/Trigger Events Between Levels:zh-cn: Difference between revisions
(Created page with "== 前言 == {{Note|本教程仅适用于单人游戏,因为多人游戏不支持trigger_changelevel(L4D系列和传送门2除外)。对于回合制多人游戏,...") |
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:跨地图触发事件}} | |||
== 前言 == | == 前言 == | ||
{{Note|本教程仅适用于单人游戏,因为多人游戏不支持[[trigger_changelevel]](L4D系列和传送门2除外)。对于回合制多人游戏,请参阅底部的[[#External | {{Note|本教程仅适用于单人游戏,因为多人游戏不支持[[trigger_changelevel]](L4D系列和传送门2除外)。对于回合制多人游戏,请参阅底部的[[#External links|外部链接]]以获取更多信息}} | ||
随着关卡变得越来越复杂,您可能无法创建事件,例如,由于引擎限制,按钮会切换灯光。但是,这并不意味着不可能让激活器触发另一个地图中的事件。 | 随着关卡变得越来越复杂,您可能无法创建事件,例如,由于引擎限制,按钮会切换灯光。但是,这并不意味着不可能让激活器触发另一个地图中的事件。 | ||
{{Note|本文假设您知道如何进行[[Level_Transitions:zh-cn|关卡转换]].}} | {{Note|本文假设您知道如何进行[[Level_Transitions:zh-cn|关卡转换]].}} | ||
== | == 一次性[[env_global|全局实体]] == | ||
第一部分重点介绍如何创建一个[[env_global]],它只能在被触发器激活后触发一次,本部分中的触发器为一个[[func_button|按钮]] | |||
{{Note| | {{Note|env_global所包含的信息可以保留到下一张地图甚至是15张地图。这不是啥大问题,这就是[http://www.moddb.com/mods/underhell 地狱之下]处理你捡到的卡片数量的方式(它也利用了env_global 的计数器功能,但是,它的代码已被修改,以通过I/O系统输出新的全局状态。}} | ||
=== | === 地图设置 === | ||
[[Image:Map 1 Setup.png|thumb|250px|right| | [[Image:Map 1 Setup.png|thumb|250px|right|第一张地图的设置]] | ||
[[Image:Globals_Entity_Setup.png|thumb|250px|right| | [[Image:Globals_Entity_Setup.png|thumb|250px|right|第二张地图的设置]] | ||
[[Image:Env global State.png|thumb|250px|right| | [[Image:Env global State.png|thumb|250px|right|Env_global设置。它们在两张地图中都是相同的。]] | ||
==== | ==== 第一张地图:实体设置 ==== | ||
在第一张地图,你需要: | |||
* | *一个触发器(在本案例中,一个命名为<code>button</code>,设置了<code>Don't Move</code>且触发延迟(Delay Before Reset)为-1[[func_button]]将充当触发器) | ||
*An env_global named <code>light_global</code>- with a <code>Global State To Read</code> set to <code>turn_on_light</code> | *An env_global named <code>light_global</code>- with a <code>Global State To Read</code> set to <code>turn_on_light</code> | ||
{{Note|You do not have to choose from the drop down list. The <code>Global State To Read</code> can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.}} | {{Note|You do not have to choose from the drop down list. The <code>Global State To Read</code> can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.}} | ||
Line 67: | Line 68: | ||
| [[Image:Io11.png]] || OnMapSpawn || red || TurnOn || <none> || 0.00 || Yes | | [[Image:Io11.png]] || OnMapSpawn || red || TurnOn || <none> || 0.00 || Yes | ||
|} | |} | ||
{{bug|Avoid using <code>OnMapTransition</code> with the logic_auto as crashing during a transition will cause problems when reloading a save.}} | {{bug|hidetested=1|Avoid using <code>OnMapTransition</code> with the logic_auto as crashing during a transition will cause problems when reloading a save.}} | ||
And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on. | And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on. | ||
Line 149: | Line 150: | ||
You can download the example VMFs [https://www.dropbox.com/s/myanwcawkou0nk0/env_global.zip?dl=0 here]. | You can download the example VMFs [https://www.dropbox.com/s/myanwcawkou0nk0/env_global.zip?dl=0 here]. | ||
== External | == External links == | ||
Multiplayer - [https://www.youtube.com/watch?v=HjQUUPkfqDA Change The Nature Of Next Round] | Multiplayer - [https://www.youtube.com/watch?v=HjQUUPkfqDA Change The Nature Of Next Round] | ||
==See | ==See also== | ||
* [[Env_global]] | * [[Env_global]] | ||
* [[Logic_auto]] | * [[Logic_auto]] | ||
[[Category:Level Design Tutorials]] | [[Category:Level Design Tutorials:zh-cn]] |
Latest revision as of 07:19, 20 May 2025
前言

随着关卡变得越来越复杂,您可能无法创建事件,例如,由于引擎限制,按钮会切换灯光。但是,这并不意味着不可能让激活器触发另一个地图中的事件。

一次性全局实体
第一部分重点介绍如何创建一个env_global,它只能在被触发器激活后触发一次,本部分中的触发器为一个按钮

地图设置
第一张地图:实体设置
在第一张地图,你需要:
- 一个触发器(在本案例中,一个命名为
button
,设置了Don't Move
且触发延迟(Delay Before Reset)为-1func_button将充当触发器) - An env_global named
light_global
- with aGlobal State To Read
set toturn_on_light

Global State To Read
can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.- (Optional) A game_text named
text_button_on
to check the env_global's state

developer 4
if you want to print out entity information (such as outputs being called, etc.) and other meaningful information. The game_text entity is simply used to print text seperately from the developer
console command so that if your map has complex I/O sequences spamming (such as logic_timer and logic_case entities), the game_text makes it easier.
Second Map - Entity Setup
In the second map, you need:
- A logic_auto - with a
Global State To Read
set toturn_on_light
(it must be the same as the env_global's) - The entity you want to fire (in this example - a light named
red
)
The Input/Output Setup
First Map - Outputs
Open the activator (the button here) that will fire the env_global.
My Output > Target Entity Target Input Parameter Delay Only Once OnPressed light_global TurnOn <none> 0.00 Yes OnPressed !self Lock <none> 0.01 Yes
If you are using a game_text, fire it as well as you enable the env_global. Remember that the game_text is only used for debugging purposes. Remove it before shipping your level.
My Output > Target Entity Target Input Parameter Delay Only Once OnPressed text_button_on Display <none> 0.00 Yes
Second Map - Outputs
Open the logic_auto that will fire the entity or sequence (the light here).
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOn <none> 0.00 Yes

OnMapTransition
with the logic_auto as crashing during a transition will cause problems when reloading a save.And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on.
Multiple Use Env_Global
Let's say we want the light to be toggled on and off when pressing the button. It requires a little more setup, but the process is fairly easy.
First Map - Entity Setup
In the first map, you need:
- An activator (in this example - a button named
button
with a delay before reset set to-1
andToggle
andDon't Move
set inFlags
) - 2 env_global entities:
- The first one named
light_global
- with aGlobal State To Read
set toturn_on_light
- The second one named
light_global_off
- with aGlobal State To Read
set toturn_off_light
- The first one named
- (Optional) 2 game_text entities to check the env_global entities state
- The first one named
text_button_on
- The second one named
text_button_off
- The first one named
Second Map - Entity Setup
- 2 logic_auto entities:
- The first one with a
Global State To Read
set toturn_on_light
(it must be the same as the first env_global in the first map) - The second one with a
Global State To Read
set toturn_off_light
(it must be the same as the second env_global in the first map)
- The first one with a
- The entity you want to fire (in this example - a light named
red
)
First Map - Outputs
Open the activator (the button here) that will fire the env_global entities.
Second Map - Outputs
Open the logic_auto with Global State To Read
set to turn_on_light
(logic_auto that will turn on the light)
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOn <none> 0.00 No
Open the logic_auto with Global State To Read
set to turn_off_light
(logic_auto that will turn off the light)
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOff <none> 0.00 No
And that's all there is to it.
Wrapping Things Up
You can download the example VMFs here.
External links
Multiplayer - Change The Nature Of Next Round