There are up to 10 types of traps on a level. These are defined after the room descriptions.
{
// TN
byte MonsterIdForAmbush[10];
// TV
byte Level[10];
// TP
byte TriggerPrecentage[10];
// TG: FLAME,DUST,MOLD,PIT,MONSTER,SPEAR,NEEDLE,XBOW,CAVEIN,CEILING
byte Type[10];
}
With the exception of monster traps, the trap type is used only to display the name of the trap using one of the 9 hard-coded names. Unlike monsters, the names of the traps are part of the engine, so expansions are forced to use the same names. Some examples from the first level, along with more their more evocative descriptions taken from the manual.
LILY TRAP - The lilies give off a cloud of fine powder which causes severe swelling in your throat.( Type: Dust Trigger: 99 Level: 8)
MOLD TRAP - The yellow mold on the floor gives off a cloud of spores as it is stepped on. These spores cause a severe coughing fit.
( Type: Mold Trigger: 9 Level: 9)
PIT TRAP - A ten foot pit opens beneath your feet.
( Type: Pit Trigger: 75 Damage: 6 )
A trap triggers if it exists and the player is close enough ( no more than 3 feet away along either axis ), there is no monster present ( a strange condition, but traps can spawn monsters so authors probably felt it was better that the trap didn't go off rather than replace the existing monster ) and the d100 roll is less than the trigger probability.
Treasures are trapped by placing the trap at the same location as the treasure. This makes traps like the one in room 24 difficult to avoid.
We then print the trap name; if the trap spawns a monster we create the monster at the trap location. Otherwise, the trap will "attack" the player as a monster of the given level. This will do damage equal two twice the level.
695 N = PEEK (NP + KR):L = 0: IF NB > 0 OR N = 0 OR ABS (XL - PEEK (XP + KR)) > 3 OR ABS (YL - PEEK (YP + KR)) > 3 OR RND (11) * 100 > PEEK (TP + N) THEN RETURN
700 QX = 195:QY = 72: GOSUB 15010:QX = 195:QY = 72:Q$ = T$( PEEK (TG + N)) + " TRAP": GOSUB 75: GOSUB 65: GOSUB 65: IF PEEK (TN + N) > 0 THEN I = PEEK (TN + N):NB = 1: GOSUB 4830:XM = PEEK (XP + KR):YM = PEEK (YP + KR)
702 IF PEEK (TN + N) > 0 THEN QX = 195:QY = 72:Q$ = A$: GOSUB 15010: GOSUB 75: GOTO 720
710 IF PEEK (TV + N) > 0 THEN ML = PEEK (TV + N):L = 1:MD = 2 * ML
720 POKE NP + KR,0: RETURN
Comments