"MAIN for
ENCHANTER
Copyright 1983 Infocom, Inc. All Rights Reserved.
"
Set if the parser successfully parsed a command. (As opposed to a blank line or an error.)
No relation to whether the player has won.
<GLOBAL P-WON <>>
<CONSTANT M-FATAL 2>
<CONSTANT M-HANDLED 1>
<CONSTANT M-NOT-HANDLED <>>
<CONSTANT M-OBJECT <>>
<CONSTANT M-BEG 1>
<CONSTANT M-END 6>
<CONSTANT M-ENTER 2>
<CONSTANT M-LOOK 3>
<CONSTANT M-FLASH 4>
<CONSTANT M-OBJDESC 5>
<GLOBAL DEBUG <>>
Set up the world at the start of the game. Start the timers. Print the banner. Set all those useful globals like HERE and WINNER.
<ROUTINE GO ()
<TELL
"It must be the warlock Krill. The odd disappearances, the mysterious
dissolution of regions sacred to the Circle, the lessening of the Powers --
these could only be his handiwork. The Circle gathers and its leader, the
“Krill” may be intended to be serious, but “Belboz” is at least a little bit silly.
The name comes from the same syllable bucket as “foo”, “bar”, “Frobozz”, “Borphee”, and the eight reset buttons in Suspended.
esteemed Belboz, reveals to them an ancient document which portends evil days
much like our own.|
|
\"Krill's evil must be unmade,\" he begins, \"but to send a powerful Enchanter
is ill-omened. It would be ruinous to reveal oversoon our full powers.\" A
ripple of concern spreads over the face of each Enchanter. Belboz pauses, and
collects his resolve. \"Have hope! This has been written by a hand far wiser
than mine!\"|
|
He recites a short spell and you appear. Belboz approaches, transfixing you
with his gaze, and hands you the document. The other Enchanters await his
decree. \"These words, written ages ago, can have only one meaning.
You, a novice Enchanter with but a few simple spells in your Book, must seek
out Krill, explore the Castle he has overthrown, and learn his secrets. Only
then may his vast evil be lessened or, with good fortune, destroyed.\"|
|
The Circle rises and intones a richly woven spell, whose many textures imbue
the small, darkened chamber with warmth and hope. There is a surge of power;
you are Sent." CR>
<CRLF>
<CRLF>)>
<AGAIN>>
<ROUTINE MAIN-LOOP ("AUX" TRASH)
<REPEAT ()
<ROUTINE MAIN-LOOP-1 ("AUX" ICNT OCNT NUM CNT OBJ TBL V PTBL OBJ1 TMP)
#DECL ((CNT OCNT ICNT NUM) FIX (V) <OR 'T FIX FALSE> (OBJ) <OR FALSE OBJECT>
(OBJ1) OBJECT (TBL) TABLE (PTBL) <OR FALSE ATOM>)
<SET CNT 0>
<SET OBJ <>>
<SET PTBL T>
<SET TMP <>>
<REPEAT ()
<COND (<G? <SET CNT <+ .CNT 1>> .ICNT>
<RETURN>)
(T
<SET TMP T>
<RETURN>)>)>>
<COND (<NOT .TMP>
<SET CNT 0>
<REPEAT ()
<COND (<G? <SET CNT <+ .CNT 1>> .OCNT>
<RETURN>)
(T
<RETURN>)>)>>)>
<SET CNT 0>)>
<SET NUM
<COND (<0? .OCNT> .OCNT)
(<G? .OCNT 1>
<COND (<0? .ICNT> <SET OBJ <>>)
(T <SET OBJ <GET ,P-PRSI 1>>)>
.OCNT)
(<G? .ICNT 1>
<SET PTBL <>>
.ICNT)
(T 1)>>
<COND (<AND <NOT .OBJ> <1? .ICNT>> <SET OBJ <GET ,P-PRSI 1>>)>
(<0? .NUM>
<TELL "It's too dark to see." CR>)
(T
<TELL "There isn't anything to ">
<PRINTB <GET .TMP 0>>)
(T
<TELL "!" CR>
<SET V <>>)>)
(T
<COND (<G? .NUM 1> <SETG P-MULT T>)>
<SET TMP <>>
<REPEAT ()
<COND (<G? <SET CNT <+ .CNT 1>> .NUM>
<TELL "The ">
<TELL "other ">)>
<TELL "object">
<TELL "s">)>
<TELL " that you mentioned ">
<TELL "are">)
(T <TELL "is">)>
<TELL "n't here." CR>)
(<NOT .TMP>
<TELL
"I don't know what you're referring to." CR>)>
<RETURN>)
(T
<COND (.PTBL <SET OBJ1 <GET ,P-PRSO .CNT>>)
(T <SET OBJ1 <GET ,P-PRSI .CNT>>)>
<SETG PRSO <COND (.PTBL .OBJ1) (T .OBJ)>>
<SETG PRSI <COND (.PTBL .OBJ) (T .OBJ1)>>
<COND (<VERB? MAKE-LINE ERASE-LINE> T)
(<OR <G? .NUM 1>
0>
,W?ALL>>
<COND (<EQUAL? .OBJ1
<AGAIN>)
<VERB? TAKE>
<NOT <EQUAL?
<LOC .OBJ1>
.OBJ>>>
<AGAIN>)
(<AND <VERB? TAKE>
0>
,W?ALL>
<AGAIN>)
(T
<COND (<EQUAL? .OBJ1 ,IT>
(T <PRINTD .OBJ1>)>
<TELL ": ">)>)>
<SET TMP T>
<COND (<==? .V ,M-FATAL> <RETURN>)>)>>)>
<SET V
<COND (<VERB? SAVE RESTORE SCORE VERSION> T)
(T
(T
TIME QUIT RESTART SCORE SCRIPT UNSCRIPT RESTORE> T)
<GLOBAL L-PRSA <>>
<GLOBAL L-PRSO <>>
<GLOBAL L-PRSI <>>
<GLOBAL P-MULT <>>
<GLOBAL P-NOT-HERE 0>
%<COND (<GASSIGNED? PREDGEN>
'<ROUTINE PERFORM (A "OPTIONAL" (O <>) (I <>) "AUX" V OA OO OI)
#DECL ((A) FIX (O) <OR FALSE OBJECT FIX> (I) <OR FALSE OBJECT> (V) ANY)
<COND (<AND <EQUAL? ,IT .I .O>
<TELL "I don't see what you are referring to." CR>
<RFATAL>)>
<COND (<AND ,PRSO <NOT <VERB? WALK>>>
.V)
(T
<COND
(<SET V <APPLY <GET ,PREACTIONS .A>>> .V)
(<AND .I <SET V <APPLY <GETP .I ,P?ACTION>>>> .V)
(<AND .O
<NOT <==? .A ,V?WALK>>
<LOC .O>
.V)
(<AND .O
<NOT <==? .A ,V?WALK>>
.V)
(<SET V <APPLY <GET ,ACTIONS .A>>> .V)>)>
.V>)
(T
'<PROG ()
<SETG DEBUG <>>
<ROUTINE PERFORM (A "OPTIONAL" (O <>) (I <>) "AUX" V OA OO OI)
#DECL ((A) FIX (O) <OR FALSE OBJECT FIX> (I) <OR FALSE OBJECT> (V) ANY)
<COND (,DEBUG
<TELL "** PERFORM: PRSA = ">
<PRINC <NTH ,ACTIONS <+ <* .A 2> 1>>>
<COND (<AND .O <NOT <==? .A ,V?WALK>>>
<TELL " | PRSO = " D .O>)>
<COND (.I <TELL " | PRSI = " D .I>)>)>
<SET OA ,PRSA>
<SET OO ,PRSO>
<SET OI ,PRSI>
<COND (<AND <EQUAL? ,IT .I .O>
<NOT <ACCESSIBLE? ,P-IT-OBJECT>>>
<TELL "I don't see what you are referring to." CR>
<RFATAL>)>
<COND (<==? .O ,IT> <SET O ,P-IT-OBJECT>)>
<COND (<==? .I ,IT> <SET I ,P-IT-OBJECT>)>
<SETG PRSA .A>
<SETG PRSO .O>
<COND (<AND ,PRSO <NOT <VERB? WALK>>>
<SETG P-IT-OBJECT ,PRSO>)>
<SETG PRSI .I>
<COND (<AND <EQUAL? ,NOT-HERE-OBJECT ,PRSO ,PRSI>
<SET V <D-APPLY "Not Here" ,NOT-HERE-OBJECT-F>>>
<SETG P-WON <>>
.V)
(T
<SET O ,PRSO>
<SET I ,PRSI>
<COND (<SET V <D-APPLY "Actor"
<GETP ,WINNER ,P?ACTION>>> .V)
(<SET V <D-APPLY "Room (M-BEG)"
<GETP <LOC ,WINNER> ,P?ACTION>
,M-BEG>> .V)
(<SET V <D-APPLY "Preaction"
<GET ,PREACTIONS .A>>> .V)
(<AND .I <SET V <D-APPLY "PRSI"
<GETP .I ,P?ACTION>>>> .V)
(<AND .O
<NOT <==? .A ,V?WALK>>
<LOC .O>
<SET V <D-APPLY "Container"
<GETP <LOC .O> ,P?CONTFCN>>>>
.V)
(<AND .O
<NOT <==? .A ,V?WALK>>
<SET V <D-APPLY "PRSO"
<GETP .O ,P?ACTION>>>>
.V)
(<SET V <D-APPLY <>
<GET ,ACTIONS .A>>> .V)>)>
<SETG PRSA .OA>
<SETG PRSO .OO>
<SETG PRSI .OI>
.V>
<DEFINE D-APPLY (STR FCN "OPTIONAL" FOO "AUX" RES)
<COND (<NOT .FCN> <>)
(T
<COND (,DEBUG
<COND (<NOT .STR>
<TELL CR " Default ->" CR>)
(T <TELL CR " " .STR " -> ">)>)>
<SET RES
<COND (<ASSIGNED? FOO>
<APPLY .FCN .FOO>)
(T <APPLY .FCN>)>>
<COND (<AND ,DEBUG .STR>
<COND (<==? .RES 2>
<TELL "Fatal" CR>)
(<NOT .RES>
<TELL "Not handled">)
(T <TELL "Handled" CR>)>)>
.RES)>>
>)>
The time of day. This runs on a scale of dawn (0) to the following dawn (128), at which time it’s reset to zero. (See I-TIME.) The game does not deal in clock time, but TIME-TABLE gives an idea of how the day runs. Five turns approximate an hour of game time.
DUSK and NIGHTFALL come earlier every day as Krill’s power increases, but the total length of the day does not change.
<GLOBAL TOD 0>
<GLOBAL DAWN 0>
<GLOBAL SUNRISE 10>
The expected time of sunset, as compared to TOD. This starts unrealistically late — about 10 PM if you take the TIME-TABLE comments seriously. It decreases by 20 every day (see I-TIME).
<GLOBAL DUSK 81>
The expected time of full night, as compared to TOD. This starts unrealistically late — about 1 AM if you take the TIME-TABLE comments seriously. This makes for better drama, of course. Since NIGHTFALL decreases by 20 every day (see I-TIME), you have five dwindling game days before doom arrives.
<GLOBAL NIGHTFALL 97>
The time-of-day timer. This advances TOD every turn.
When TOD reaches 128 (roughly 24 in-game hours), it’s reset to zero and a new day begins. Krill’s power increases: LOSSAGE goes up by one, and DUSK and NIGHTFALL are brought forward by 20 (about two game hours). The MUNCHED and MOLESTED probabilities also increase.
Time also advances when you SLEEP. This is handled elsewhere; see V-SLEEP. But there is a serious bug in the sleep-time logic.
<ROUTINE I-TIME ()
<RTRUE>)
(<G? <SETG TOD <+ ,TOD 1>> 127>
<TELL
"Belboz appears before you, in a magical sending. He speaks, his voice
soft and saddened. \"You have failed. Universal night has now fallen.
Krill and his creatures now may freely roam the earth. The power of the
Circle is diminished, if not broken. I go to prepare the last defense.\"
The sending vanishes." CR>
<TELL
"The darkened sky is now full of bright stars. It is night." CR>
<TELL
"Today seemed shorter than yesterday, somehow." CR>)>
<RTRUE>)
<TELL
"The sun has now risen above the hills." CR>)
<TELL
"The sun starts to set behind the Lonely Mountain in the west." CR>
<TELL
"The day is coming to an end earlier than you would have expected." CR>)>
<RTRUE>)>>