|
|
| -
Tutorial On Keeping Track Of, And Changing The Global State Of Entities
- | |
This tutorial will try to explain how to keep track of, and change the state of an entity. This technique is useful when you want to disable or enable an entity without that particular entity proceeding to trigger its target. One such case where this technique may come in handy is if you were to create a button that could only be used once in a round (possibly a button that targets an explosion which, naturally, you would only want to happen once.)
The first step of this tutorial will be to make a button, give it a "target" of "button_manager" and a "master" of "button_master". Feel free to change any of the other values in the button.
The Half-Life engine does not keep track of what state a particular entity is in by default, but there is a useful entity that can be used to do this. This entity is called a "multisource" entity. Here are its values:
- Targetname - This is the same name as the "master" which is given to the entity that it is to keep track of.
- Target - Not used in this tutorial, it gives a whole different purpose to this entity.
- Globalstate - The name of the global variable used to control the state of the multisource.
Create a "multisource" entity and give it a "targetname" of "button_master" and a "globalstate" of "button_global".
Next create an env_global, this is used to change the state of the global variable (disables and enables the entity.) Only the "multisource" entity is capable of reading an "env_global" entity. A brief run-down of this entities keys:
- Targetname - This is the name of the entity, use it to have other entities target it. When an env_global is targeted it will change the state of the entity to whatever is specified.
- Globalstate - The name of the global state you want to modify, this is the same name of the "globalstate" in the "multisource".
- Triggermode - The state the global variable will be given when the "env_global" is triggered. 0 for off, 1 for on, 2 for dead (monsters), and 3 for toggle.
- Initialstate - The initial state the global variable is given. 0 for off, 1 for on, and 2 for dead (monsters).
- Flags - The "env_global" has one flag called "Set Initial State", with this checked the "env_global" will automatically set this state when the level is loaded rather then waiting for the "env_global" to be triggered.
Give the "env_global" a "globalstate" of "button_global" a "targetname" of "button_off" and a "triggermode" of "off" (0). Next create another "env_global" with a "globalstate" of "button_global" a "targetname" of "button_on" and a "triggermode" of "on" (1).
Next create a func_door and place it somewhere outside your map where no one will see it or touch it, give it a "target" of "button_on" and a "delay" of "0.5". This will target the "env_global" which will activate the button at the beginning of each round and allow you to use it again.
Finally create a "multi_manager" give it a target name of "button_manager" and give it a new "key" of "button_off" with a "value" of "0.1" (You can create new keys and values in WC by clicking off "SmartEdit" and the clicking "Add"). Now the moment we've all been waiting for, have this "multi_manager" target whatever it is that you want the button to target once. Do this by adding another "key" of whatever the "targetname" of the entity you want to target is, you can either give it a "value" of 0 or specify whatever delay you would like.
Thats about all you need to know, and of course you can use this for other entities other then "func_button"'s such as a "func_door" or a "trigger_multiple".

|
|
|
|
|