Gary L. Simmons  rev 02/23/06
Home  Marathon  Joke OT Weak  Web Building  Resumé  Lynx  Hobbies  Extra  Site Map Links Page Extra Go to next department

The Battle Cat's Litterbox

Forge Tips | Harper's Tutorials | Stacked Walkways | Heartbeat | Combination Lock | Clock | Pedestal Problem | Zig Zag Stairs | Illusory Bridges | Fake Elevators | Texture Flexing | Untextured Walls | Stacked Windows | Multi-Message Terms | Counters | Level Detector

The combination lock

The Combination Lock

The Combination Lock
By Jason Harper,
From "Missed Island"

The fundamental trick behind the combination lock is that it is possible to make a platform move in arbitrary increments (rather than going all the way to one of its limits), by controlling it with another platform that has the Deactivates At Each Level, Activate Adjacent On Activating, and Deactivate Adjacent On Deactivating flags set. Both platforms will move for exactly the same period of time, set by the control platform's speed and min/max height. If the time required for a complete cycle of the controlled platform's movement is an exact multiple of the control platform's time, it will reliably step through a set of evenly spaced positions (the number of positions being equal to the multiple of the control platform's time).

Figure 1
lock tumbler schematic

Figure 2
Figure 2

This effect is used to implement each digit of the combination lock. The controlled platform has one side textured with a pattern containing a vertical strip of digits (other symbols could be used, of course). This is visible through a window the size of a single digit, showing the current setting. The only constraint is that the strip of digits, and therefore the vertical range of the platform, be no higher than a texture (128 pixels, or 1 WU): if there was any more vertical motion, some digits would repeat themselves. I chose to use 8 digits (0 thru 7) for each position of the combination lock, since that divides evenly into 128. If I had used 0-9, each digit would have to be somewhat smaller (12 instead of 16 pixels high), and it might have been impossible to get the timing of the control platform exactly right (since none of the relevant parameters are exactly divisible by 10).

The next room (Editors Note: Please refer to Figure 2 or level 3 in "Missed Island", the large room that contains the polygon index 50 - gls) contains a working model of a 1-digit combination lock. From left to right, you'll see:

1. A platform switch, which activates:

2. The control platform, which moves through a fairly small range (about 1/8 WU). It is not visible in the actual combination lock on Missed Island. It must have the Can't Deactivate Externally flag set, so that it can't be stopped in mid-digit. It controls:

3. The indicator platform, which has the texture with the strip of digits. The gap in the red column represents the window through which you see the current digit. This platform moves through 7/8 WU (if it moved a full WU it would repeat a digit). It, in turn, controls:

4. The target platform. This has exactly 8 times the vertical range of the indicator platform (7 WU), but is also exactly 8 times as fast. It therefore stays in perfect sync with the indicator, and is basically an 8X magnified version of it. The purpose of the target platform, and of the switch that's in mid-air in front of it, will be explained later.

Please play around with the model so that you can see how it works. There is an observation deck at the south end of the room, which may help you to see "the big picture". It is accessible by teleporters in the corners, and has a duplicate of the platform switch (1).

If you've managed to follow the description so far, you can see how a combination lock with any number of digits can be built. The next step is to somehow determine when these digits are set to the proper value, so that some action can be triggered (unlocking a safe, perhaps).

Unfortunately, Marathon offers no direct way of detecting when a platform is in a certain position. Time for another trick... try not to laugh too hard when you see how I solved this problem.

Figure 3My solution is to have one creature firing at another, one of which is on a platform. (This is the purpose for the target platform mentioned earlier: the indicator platform itself doesn't move far enough for this to work.) A switch is positioned such that it will be struck by the creature's fire only when the platform is in a specific position.

I have arbitrarily chosen the Enforcer Minor as the firing creature (since their normal weapon is capable of triggering switches), and the Tick Kamikaze as its target (since they don't seem otherwise very useful for anything). However, some physics model tweaking is necessary to make this technique work reliably, and could just as easily be applied to any two creatures that aren't otherwise needed on the level.

Here are the necessary physics and monster parameter settings:

The Tick is made completely immobile (movement speed 0, can't float or fly) so that it doesn't wander off. It is set to have no dying or dead shape, to avoid cluttering up the level with corpses (an alternative would be to have the shot being fired do 0 damage). In Forge, Ticks are set to have an infinite number available, with 100% appearance. The min count is set equal to the initial number of Ticks present. In short, Ticks are turned into immortal, immobile lumps.

The Enforcer is set to fire individual shots instead of bursts, with 0 error (otherwise, the switch would occasionally be hit even if the indicator was off by one). The firing rate, and the movement speed of the shot itself, are increased in order to minimize the response time. The player is removed from the Enforcer's list of enemies, so that their actions can be observed without drawing fire. The Minor/Major flags are cleared for both types of Enforcers, so that neither gets transformed into the other based on the difficulty level. Both creatures have the Can't Skip flag set, so there's no chance of any of them being omitted on easier levels.

To summarize how all this fits together: For each of the three digits of the combination lock on Missed Island, there is a corresponding "shooting gallery" consisting of a target platform, Tick, Enforcer, and a switch (what the switch triggers will be discussed later). The vertical positions of the three switches are adjusted to set the lock's combination. The shooting galleries are located far to the north of the player-accessible portions of the map, so that they can't be noticed either by sound or via motion detector.

lock tumbler schematicThe indicator platforms are extremely long: one end of each is visible in the cabin where the combination lock is located, and the other end reaches through 5D space to touch the target platform in the associated shooting gallery. The control platforms are adjacent to the indicator platforms, immediately behind the visible part of the lock (but of course they could be located anywhere along the length of the indicator platforms).

One gotcha that came up during the development of this technique is the need to somehow activate the Enforcers so that they start firing at the Ticks. Marathon normally does not activate monsters that are nowhere near the player, since their actions would take up CPU time that would be better spent on something the player could actually see. However, this behavior can be overridden with the use of Visible Trigger and related polygon types: all that is needed is a contiguous series of non-Zone Border polygons leading from the trigger polygon to the monster's location. In the case of the combination lock, a Visible Trigger is located just inside the cabin, where you can't avoid stepping on it before setting any of the digits. The trigger message propagates through the indicator polygons into each of the shooting galleries. The fact that you can't see into the indicator polygons is irrelevant: only the connectivity between polygons counts. There is a Zone Border polygon in the doorway of the cabin, to keep the trigger message from uselessly propagating all over the island.

Another gotcha: the raised area containing the Enforcer must have at least three polygons. A creature with less potential mobility than that seems to be incapable of attacking normally. To see an Enforcer/Tick shooting gallery in operation, just take a few more steps down the corridor you're in. (Editors Note: Please refer to Figure 2 or level 3 in "Missed Island" - gls) This will teleport in a pair of creatures to the demo room you just left. You can go back and play with the demo some more, this time with it fully functional. When the proper digit is selected (2), the Enforcer's shots will hit the switch. For the purposes of the demo, the switch simply toggles the lights in the room. The Enforcer does not consider you to be an enemy, so it will not intentionally shoot at you unless you bother it.

I have described how a multi-digit combination lock can be built, and how to detect when each individual digit is set properly. All that remains is to somehow detect when ALL digits are set properly, and trigger some action based on this (such as opening a safe). In terms of digital logic, this function is called an "AND gate": to implement the 3-digit lock on Missed Island, a 3-input AND gate is needed.

As you will recall from the previous terminal, the result of each individual digit being correctly set is the triggering of a switch. Here's one idea for opening a safe based on all three digits being correctly set: have three doors on the safe, each controlled by one of the digit-triggered switches, such that all three have to be opened to access the contents of the safe. There are a few problems with this approach:

  1. The safe's contents would be at least 4 polygons away from the outside of the safe: Marathon doesn't check that far away from the polygon containing the player for items to be picked up (this problem wouldn't affect a walk-in safe, however).
  2. A safe designed like this would be fairly easy to solve by brute force. Just try all of the digits until you see the front most safe door open; then try the other two digits until the second door opens;
    and finally try the remaining digit until the inner door opens. For three digits with eight possibilities each, at most 48 combinations need to be tried (instead of the 512 total combinations of the lock). This would only work well if the safe was not visible from the lock, so that many long trips back and forth would be needed.
  3. Keep in mind that the individual digit switches are hit repeatedly for as long as the digit setting is correct. If these directly controlled the doors to the safe, they would be in nearly constant motion when the safe is "open". This wouldn't make the safe unusable, but it's definitely not the desired behavior. Each door could be made to open only once (by using a destroyable switch, or a once-only platform), but that would make the lock ridiculously easy to pick: just cycle each digit through all of its possibilities, and the lock is guaranteed to be open by that time.

Figure 4In summary, this simple approach isn't really usable. It was described because it forms the basis of one of the more practical forms of AND gates, described next.
The multi-door AND gate becomes quite usable if placed inside an additional Enforcer/Tick shooting gallery: a switch is located so that it will be hit by the Enforcer's fire only if all the doors are simultaneously open.

The doors are initially extended, and deactivate at their initial level. They must have the Can't Deactivate Externally flag set, so they can't remain in an open position if their controlling digit is changed to an incorrect setting. The delay or speed of each door should be slightly different: otherwise, a situation might arise where two doors are opening exactly out of sync with each other, never giving the Enforcer a clear line of fire.

lock tumbler schematic


An N-digit combination lock requires:

  • 4N platforms (a different AND gate technique, to be discussed shortly, would allow 3N platforms + N lights + N liquids as an alternative).
  • N+1 Enforcers.
  • N+1 Ticks.
  • 1 texture with the strip of digits or other symbols (only a narrow strip is needed, the rest of the texture can be used elsewhere).
  • Whatever is triggered by the lock (1 platform, for a simple safe as seen on Missed Island).

For reference, here are Marathon Infinity's limits on these resources:

  • 64 platforms
  • 64 lights
  • 16 liquids
  • 32 active creatures


  • Have multiple combinations for a lock, each of which triggers a different action. This would require an additional switch located in each digit's shooting gallery, plus an additional AND gate for each additional combination.
  • Use letters instead of digits for the components of the lock: this would be more of a password-activated lock. You could use different lists of letters for each component (a single texture could have about 8 different strips of symbols).
  • Build a huge, non-linear scenario in which the central hub level is based on a multi-combination password lock as described in the two ideas above. Scattered throughout the scenario would be clues (of varying difficulty of either finding or solving the clue) to passwords which would open gateways to additional levels.

Figure 5The Missed Island level also needed an AND gate to implement the fountain puzzle, in which 8 switches have to be set to a certain state in order to raise the sunken ships. For a few reasons, the door-based AND gate described previously wasn't suitable:

1. The inputs are on/off switches, not continuously triggered switches as in the combination lock.

2. With eight doors between the Enforcer and its target, you might have to wait quite a while before they all happened to be open simultaneously.

3. Missed Island didn't have enough platforms left for me to be able to afford using eight of them on this puzzle.

Figure 6Problem #1 could be solved by using pairs of platforms: one controlled directly by the switch, which in turn continuously activates the door in the AND gate (using the Activate Adjacent At Each Level flag). However, this doesn't help problem #2 any, and makes problem #3 even worse.

Instead of platforms, the switches in this puzzle control lights, which in turn control liquid levels. Since the Enforcer's shots are not set to penetrate liquids (like SMG flechettes are), a raised liquid is just as effective as a raised platform for blocking the shots.

The floor of the liquid-filled area is set very low (below the Enforcer's min ledge jump setting) to keep the Enforcer from simply walking over to the Tick, which would ruin the puzzle.

Note that the situation pictured here is not one that the Marathon engine can display properly. A boundary between different liquid levels produces smearing: basically, liquids define a volume with a top but no sides. This isn't actually a problem in the game, since the player can never see into the AND gate mechanism. Just make sure that Enforcers have the Don't Complain About Ugly Texture Smearing flag set. (that was a joke, not a feature request)

Figure 7The fountain puzzle requires that 3 switches be "on" and the other 5 be "off" (puzzles in which you simply have to turn on all the switches are boring). There are a few ways in which an AND gate can require certain inputs to be on, and others to be off. The one I used was to paint the two types of switches differently: ALL of the switches must be active to solve the puzzle, but only 3 of them appear to be on when in the active state. The other 5 switches are active to start with, but only appear to be on if you mistakenly deactivate them.

In retrospect, this wasn't the ideal solution, since it makes it rather difficult to change the solution of the puzzle.

Two better ways to reverse the meaning of some of the switches:

1. Define the light that the switch controls in a backwards manner: 0% when active, 100% when inactive.

2. Define the liquid that the light controls in a backwards manner: low tide higher than the high tide. Yes, Marathon handles this situation just fine.

Note that switches which should be in the active state to solve the puzzle (assuming the normal assignment of switch images to the active/inactive textures) MUST use one of the two techniques above, since the liquid level must be lowered to trigger the AND gate. A switch which should be in the inactive state must use neither of the two techniques, or both.

Figure 5


A puzzle of this sort, with N switches each having to be set to a certain state, requires the following resources:

  • N lights
  • N liquids
  • 1 Enforcer
  • 1 Tick
  • Whatever is triggered by the puzzle (in the case of the Missed Island fountain puzzle, this is 1 tag + 7 platforms + 1 light)

Figure 6There is a demo AND gate right next to your current location. (Editors Note: Please refer to Figure 2 above or level 3 in "Missed Island", you will have been standing in the large room that contains the polygon index 50 - gls) It has three inputs (controlled directly by switches), and uses the variable liquid level technique. Its output is simply a light that is activated when all three switches are on. Keep in mind that there WILL be some texture smearing, as described earlier.

Skully dares ya ta download

Missed Island

Download Jason Harper's prize winning map, "Missed Island". This is not only a playable puzzle map, it is also an example map and tutorial. This tutorial was taken from that map. The tutorial on this page can be reached by "warping" to level 3. You must use the provided shapes file to make any sense of this map.

Forge Tips | Harper's Tutorials | Stacked Walkways | Heartbeat | Combination Lock | Clock | Pedestal Problem | Zig Zag Stairs | Illusory Bridges | Fake Elevators | Texture Flexing | Untextured Walls | Stacked Windows | Multi-Message Terms | Counters | Level Detector

Top of page

Back to the Litterbox