Using Logic_Case for Random Effect
Author: Stadric
For this example, we?re going to use buttons, we?ll unlock one at random, then lock them all, then unlock another. First of all, make a room with three buttons(
func_button) and an
info_player_start in it.
Give your buttons these properties:
Locked Sound: Access Denied
Unlocked Sound: Access Granted
Flags:
Don?t move
Use Activates
Name each of the buttons, I named them
button1, button2, and
button3.
Now we need to give our buttons to do something, like open a door. Place a
prop_door_rotating somewhere in your map, and give it these properties:
World Model: models/props_c17/door01_left.mdl
Flags:
Ignore Player +USE
Now hold down shift and drag the door somewhere, then do once more, now you should have three doors, give each a name. I named mine
door1, door2, and
door3
Now give your buttons outputs, for button1:
for button2:
for button3:
Now make a
logic_case and give it a name, I named mine
case. Give it these properties:
Case 01: case1
Case 02: case2
Case 03: case3
In all reality, it doesn?t matter what you call these, but you have to name any that you will use. You use as many as you have outputs to choose from, in this case, we?re going to unlock one of three buttons, so we have three possible outputs:
-Unlock button1
-Unlock button2
-Unlock button3
And we name three cases inside our
logic_case
Now add these outputs to your
logic_case:
Now we need something to make the
logic_case randomly choose a button to unlock. We?ll use a
logic_timer. Give your
logic_timer these properties:
Refire interval: 5
Give this output to your
logic_timer:
Now all of the doors will be closed so that when you press a button, they?ll all be ready to open again, and all of the buttons will be locked, and ready to be unlocked again.
When a
logic_case receives a
PickRandom input, it randomly chooses one of the cases that have been named. We named three of them, so it will randomly choose between the three cases, and unlock one of the buttons accordingly, so that we can open a door with it.
Compile your map and run it.
EDIT
You don't need to name cases inside of a logic_case, the
"pickrandom" output only chooses between cases that have outputs.