*** The Reprogrammable Combination Lock - By Brian Osman ***

A Quake Component for --> The QuakeLab <--
http://www.in2nett.com/stevefu/QuakeLab

IDEA:
----
If you've seen the previous combination locks, this will be some old
material and some new. The idea is to have a door (to your base, for
example) which is opened through a combination (hitting some but not
all buttons in a panel). This has been accomplished in COMBO2.ZIP.
This version though, has the added benefit of being reprogrammable.

If you control the base, you can use a set of switches on the inside
to change the combination (which buttons need to be hit.) Commit the
combination to "memory" and then leave. People can try to open the
door, and if they succeed, great. (Well, not for you.) If not, when
you come back, you punch in your combination, and go into your base.

Then you decide that you don't like your old combination, so you enter
a new one. Now the old one doesnt' work anymore. Only the new one!

Some people are probably going "Oooh. Big deal. This guy wrote a little
QuakeC and he's hyping the hell out of it." Nope. No code. All in a map.

ENTITIES:
--------
Many. :)
If you are not familiar with my other recent project, the "Bit" then
you really won't be able to build one of these. Go learn about it.
Other than that, it's just some func_doors, func_buttons, and
trigger_relays. Be warned, though, that the bit itself is quite a
complex trick, using nailtraps, trigger_relays, trigger_multiples, and
func_doors. (Author's final note: The bit described in the other file
is not the same one used in this particular map. I streamlined it
for the final version.)

CONSTRUCTION:
------------
The door right now has a three bit combination, and uses six bits to do
so. There are three "Tumbler Bits" henceforth known as tb1, tb2, and
tb3. These hold the users current attempt at opening the lock. There are
also three "State Bits" henceforth known as sb1, sb2, and sb3. These
hold the current combination, for resetting after an attempt at opening.
Put all the bits in no-man's land so no one hears the racket of nails.

Initially, all three door panels are closed. When reading each tbit, if
it contains a 1, then it opens the corresponding door panel, otherwise
it does nothing. The initial states for the three tbits (and also sbits)
is 101. Thus, only the second one need be toggled, and all three will
open their corresponding panels when read.

--> NOTE: That just told you the starting combination. Shoot only the
second button. Then press the open switch.

Shooting one of the three buttons on the left wall will toggle the
corresponding tbit. This is the same as "trying a combination." When you
think you have the combination correct, press the other, large button.
The large button causes all three of the tbits to read, thus either
opening or not opening their corresponsing door panels. The door panels
all have WAIT set, so they will reset on their own. The big button
(OPEN) also causes, with a delay of three, the tset action. (See below.)

When tset is triggered, all three of the sbits are read. When any sbit
is read, it's value is used to set the corresponding tbit to the same
value. (i.e. If sb1 is 1 when read, then it performs a write1 on tb1,
otherwise it performs a write0 on tb0 etc...) Basically, the contents of
the three sbits are copied to the tbits. This restores the lock after
a failed attempt (or a successful one for that matter).

Tset is also called when a user wants to change the combination. By
putting the buttons for setting the combination inside the door, only
someone who knows the combination can change it. In my map, it's the six
buttons in the back room. (Arranged in two rows.) The top row sets the
corresponsind sbit to 1, and the bottom row sets the corresponding sbit
to 0. So: If you shoot the top button, then that one won't need to be shot,
if you shoot the bottom button, then that one will need to be shot.

Having used those six buttons to set the sbits, press the other big
button (right next to them.) This simply issues a tset, which again
copies the contents of the sbits to the tbits. The lock has been
updated.

Finally, people in the inside need to get out. So I added the large
wooden button. This simply triggers three trigger_relays, each of which
then triggers one of the door panels. All three open, and the people
inside can get out.

NOTES:
-----
Hmmm. Lot's here. What do I talk about? A few things. The buttons on the
outside merely toggle the tbits, because they are reset every time the
lock is tried or set, and whether or not to switch (toggle) IS the
combination. The inside buttons, however, set the values of the sbits
directly. Imagine that they merely toggled them. Some moron logs on
("player") and shoots at the second funny looking buttons. You go back,
remembering that the old combo was 011. (Only first button.) You want to
change it to 010. (First and third buttons.) So you toggle the third
button, and enter the combo. BUT, the second button has been hit also,
so your REAL combo is now 000 (all buttons.) No one can open the door,
and no one knows what happened.

There is so much more to explain, but I don't want to go into great
detail that no one cares about. If anyone has questions or comments, I'm
really anxious to see what other people think. E-mail me:
osmanb@rpi.edu, or post to rec.games.computer.quake.editing (E-mail will
get you a faster response.) Thanks a bunch, especially to Steve Fukuda.
(Quake Lab)
