Welcome to Hard Duty. This is a Half-Life modification with the objective of expanding the Half-Life universe with new content. Explore the Black Mesa Research Facility like never before and fight your way through hordes of enemies! How will you engage the situation? How will you survive?

Report RSS Trigger Events Between Levels

Learn how to trigger events between levels using the logic_auto and env_global entities.

Posted by on - Intermediate Level Design/Theory

Introduction


Note: This article is for singleplayer, as multiplayer games do not handle trigger_changelevel.

As levels become more complex, you may be unable to create a sequence where, for example, a button toggles a light due to engine limits. However, this doesn't mean it isn't possible to have an activator trigger an event in another map.

Note: This article assumes you know how to set up level changes.

Single Use Env_Global


This first section highlights how to create an env_global that can be fired once only after being activated by an activator, which will be a button in this article.

Note: An env_global holds information that can be transferred to the next map transition or even after 15 map transitions. It doesn't matter. This is how the Half-Life 2 mod Underhell handles the number of cards you have picked up (it makes use of the env_global's counter feature as well, but this isn't covered in this article).

The Map Setup

Activator

Entity Setup Map 2

Env_global Map 1

The env_global entities in both maps are identical.

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 and Don't Move set in Flags.
  • An env_global named light_global - with a Global State To Read set to turn_on_light.
  • (Optional) A game_text named text_button_on to check the env_global's state.

Note: You do not have to choose from the drop down list. The Global State To Read can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.

Second Map - Entity Setup

In the second map, you need

  • A logic_auto - with a Global State To Read set to turn_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)

Note: Use the console command 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.

The Input/Output Setup

First Map - Output

Outputs


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

Outputs Game_Text

(It's Display not TurnOn. Small typo. Apologies.)


Second Map - Outputs

Open the logic_auto that will fire the entity or sequence (the light here).

Light Toggle


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.

Multi Use Globals - Map 1

Multi Use Globals - Map 2

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 and Toggle and Don't Move set in Flags)
  • 2 env_global entities:
    • The first one named light_global- with a Global State To Read set to turn_on_light
    • The second one named light_global_off with a Global State To Read set to turn_off_light
  • (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

Second Map - Entity Setup

  • 2 logic_auto entities:
    • The first one with a Global State To Read set to turn_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 to turn_off_light (it must be the same as the second env_global in the first map)
  • 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

Mega Outputs


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

Light Output


Open the logic_auto with Global State To Read set to turn_off_light (logic_auto that will turn off the light)

Light turn off


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

Comments
Qwertyus
Qwertyus

Great tutorial, very detailed & demonstrable.

Reply Good karma Bad karma+7 votes
penTiuname
penTiuname

Okay this is great tutorial, but why it in top of moddb mods???

Reply Good karma Bad karma+4 votes
Peter Brev AuthorSubscriber
Peter Brev

Because it can. How is this a problem? This tutorial might not be related to the mod or GoldSrc, but its implementation is almost identical from one engine to the other.
Besides, there isn't much documentation about complex brushes and env_global.

Reply Good karma+7 votes
Hezus
Hezus

You actually don't need another env_global in the second map. The env_global only sets the game into a state, which then needs to be read by a logic_auto in the second map.

I wrote the same tutorial back in 2012, except for the multi trigger system, which is a nice additon!
Moddb.com

Reply Good karma Bad karma+2 votes
Peter Brev AuthorSubscriber
Peter Brev

It's not a failproof solution, though. I mean, it works when it does, but have the game crash mid-transition and it becomes one big mess. Trust me, I tried it, and the engine acts all funky like when the Global State to Read is getting mucked up during a transition.

By using the method described here, you avoid a lot of weird issues.

Don't get me wrong, I'm not trying to insult nor you or your method, I'm only talking from past experience.

Reply Good karma+3 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Half-Life
Game
Half-Life
Developer
Aggressive Studios
Contact
Send Message
Release date
Mod watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Games
Half-Life
Half-Life First Person Shooter
Related Groups
Aggressive Studios
Aggressive Studios Developer