 The Bit -- By Brian Osman
A Storage Unit for Quake Maps

IDEA:
----
In wanting to create puzzles an complicated doors with combination locks
and such, I realized that some form of storage or memory was needed.
Beleiving that QuakeC is for pansies, I set out to make a single bit of
storage as a map component. It can store a value of 0 or 1, be set
absolutely to one of those values, toggled, or read. Reading the bit
causes one of two things to happen. These are user deifned actions: when
the bit is read, it either triggers the BitIsSetTo1 action, or the
BitIsSetTo0 action.

ENTITIES:
--------
4 @ trap_spikeshooter, 3 @ trigger_multiple, 1 @ func_door

CONSTRUCTION:
------------
This is not for the faint of heart. If you want to just use one of
these, you're better off to just use my .MAP file. If that's the case,
jump to the next section. Otherwise, read on . . .

Begin by arranging the 3 trigger_multiples as shown (all thin in the y
direction, and shown below in the xz plane):

  x
+-+-+
|1|2|
+---+ z
| 3 |
+---+

Good. Keep these numbers in mind. Now, we need two brushes in the door.
One of them needs to occupy the same space as trigger 2, and half of
trigger 3, while the other starts there and goes further down in the z
direction. For reference, the x and z in the two figures should line up:

  x
  +-+
  | |
  | | z
  | |
+-+-+
| |
| |
| |
+-+

In this view, the targets would be one "layer" behind the doors. Now
position the four traps so that two are aimed at triggers 1 and 2, while
the other two are aimed at trigger three, but each one is lined up with
one of the two door panels. These should be one more "layer" out in the
y direction. (The doors will block the nail traps from hitting the
triggers if closed, and they will hit the triggers if the doors are
open.) Again, the x and z should line up:

  x
+-+-+
|1|2|
+-+-+ z
|3|4|
+-+-+

Just to make sure all is going well, looking at this from the top, we
should have three "layers" of stuff:

     x
  --------
 |Triggers
y|Doors
 |Traps

OK. Now we need to add some behavior and stuff. I suggest immediately
choosing a name for your bit. I use b1, both in my .MAP and in the
following sections. Any targets or targetnames associated with this bit
are thus b1* where * is either the command I'm issuing, or something
else the bit is doing.

We need two states for the bit, and this is accomplished through the
door. When the door is closed (initial state) the bit is 0. When it is
open, the bit is 1. Set the TOGGLE field of the door. (Spawnflags 32)
Now set it's ANGLE to -1, SPEED to 1000, and LIP to be equal to the z-
height of one of the two panels. (16 in my map, because each panel is 16
units tall.) Finally, set the TARGETNAME to b1f. (Bit 1 flip) Our first
input is done. By triggering b1f, we can toggle the state of the bit.

Now let's look at reading the bit. Modify spikeshooters 1 and 2 so that
they each have an ANGLE of 90 (or whatever is necessary to aim at the
triggers if you're working on a rotated map.) Next set the TARGETNAME of
each to b1r. (Bit 1 read) This is our second input. When b1r is
triggered, both nails fire. One of them bounces off the door, while the
other one hits one of the triggers. Let's fix the triggers so this does
what it's supposed to.

Both triggers 1 and 2 should have a health of 1, so the spikeshooters
can trigger them. Set the TARGET for trigger 1 to be b1r0 and the TARGET
for trigger 2 to be b1r1. If the nail trap on the left gets through,
then the bit's value is 0, so we trigger b1r0 (Bit 1 Read 0). If the
nail trap on the right gets through, we trigger b1r1 (Bit 1 Read 1).
Simply make b1r0 and b1r1 the TARGETNAMES for whatever you want to
happen (choose which value depending on whether you want the bit to be 0
or 1.)

Although we can toggle the bit, we don't have any way of putting an
absolute (0 or 1) value in. Yet. Look at the two remaining
spikeshooters. Give them the same ANGLE as above (probably 90).
Spikeshooter 3 should have a TARGETNAME of b1w1 (Bit 1 Write 1) and
spikeshooter 4 should have a TARGETNAME of b1w0 (Bit 1 Write 0). These
are our last two inputs. Calling either one of these will cause the
corresponding shooter to fire. If it gets through the door, then the bit
is in the wrong state, so we have to toggle it . . .

Edit trigger 3 so it has a HEALTH of 1 (shootable by spikeshooters 3 and
4) and a TARGET of b1f. Thus, when a nail hits it, (as described just
above) we know that we're in the wrong state. Toggle the doors, and we
know we have written the correct state to the bit.

That's it! Wow! My MAP also has six brushes in it. I encapsulated the
bit so I could copy and paste it in my levels, and stick it way beyond
the confines of my level. This prevents people from hearing the
nailtraps.

OPERATION:
---------
Stick the fully encapsulated bit somewhere way outside your level. It
uses several nailtraps, and you don't want people hearing it go off. The
bit has four inputs, and two outputs:

INPUT:
Target:  What it does:
b1f      Toggles the bit
b1w0     Writes a 0 to the bit
b1w1     Writes a 1 to the bit
b1r      Reads the bit (Triggers one of the ouputs)

OUTPUT:
Targetname:  When it's triggered:
b1r0         On a b1r (bit read) if the bit is 0
b1r1         On a b1r (bit read) if the bit is 1


FINAL NOTES:
-----------
When using many bits in a level, there is one small problem. Copying and
pasting several of them outside your level is fine (use SEPARATE
LOCATIONS!) But for every bit used, all of the TARGET and TARGETNAME
fields MUST be changed, so that every instance of b1* is changed to b2*
or b3* etc . . . This can be quite time consuming, but I haven't found
an easy way to enumerate entities.

I am REALLY curious what people think of this. I have put a significant
amount of work into this, and I'm wondering if people can come up with
ways to streamline it more, or new applications for storage. Please e-
mail me (osmanb@rpi.edu) with questions or comments.
