home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
GAMES
/
informosk.lha
/
dejavu.inf
next >
Wrap
Text File
|
1993-11-27
|
22KB
|
613 lines
! ----------------------------------------------------------------------------
! Deja Vu: An Inform Demonstration
!
! This second release corrects a quite major bug in the parser, whose cure
! (provided by Jon Drukman, whom I thank) turned out to be trivial.
!
! It also incorporates an overhaul of the parser made between early and late
! testing versions of "Curses": in particular, implicit taking of objects, a
! slightly better understanding of darkness, better resolution of ambiguity,
! more context-sensitive "again", fixes for some rare bugs, understanding of
! "all of", replies like "both" and "either"
!
! The parser itself lives in a file "Parser" which also sets up standard
! attributes, properties and pseudo-objects (directions, darkness, etc).
! This ought to make it easier to transplant the parser to other games,
! without needing to know how it works.
!
! I have reformatted these files to 80 columns wide for the benefit of
! readers trapped with old monitors.
!
! There is now a "help" verb, in order to demonstrate verbs whose noun may
! be any arbitrary word, recognised or not.
!
! ----------------------------------------------------------------------------
Constant Story "DEJA VU";
Constant Headline "^An Interactive Demonstration^\
Copyright (c) 1993 by Graham Nelson. All rights given away.^";
Release 2;
Statusline score;
Constant MAX_CARRIED 5;
Constant MAX_SCORE 50;
Constant NUMBER_TASKS 3;
Constant OBJECT_SCORE 4;
Constant ROOM_SCORE 5;
#include "Parser";
Global task_scores initial 3 7 4;
#include "VerbLib";
! ----------------------------------------------------------------------------
! One attribute of our own...
! ----------------------------------------------------------------------------
Attribute is_cube;
! ----------------------------------------------------------------------------
! And now genuine objects... there is little distinction between rooms and
! objects.
! Note that: "name" of a room gives a list of words to which the game replies
! with "you don't need to refer to that in this game" - ie, names of irrelevant
! things.
! ----------------------------------------------------------------------------
Object cave "Y2 Rock Room" nothing
with longdesc "You are in a large room, veined with quartz, with a passage \
to the south, \
a passage to the west, and a wall of broken rock to the \
east. There is a large ~Y2~ on a rock in the room's centre.",
name "vein" "quartz",
w_to broken, s_to reservoir,
cantgo "The only paths through the rubble are west and south."
has light;
Object rubble "rubble" cave
with name "rubble" "wall" "broken" "rocks"
has scenery;
Object rock "Y2 rock" cave
with name "rock", article "the",
longdesc "The author of this demonstration has never, ever \
understood what the Y2 rock was \
for. Was it a grid reference? Or a question?"
has scenery supporter;
Object cube1 "featureless white cube" rock
with name "white" "cube",
preroutine Cube1Pre
has is_cube scored;
Object sword "Elvish-made sword" selfobj
with name "elven" "elvish" "sword", article "an";
Object cube2 "featureless white cube" selfobj
with name "white" "cube"
has is_cube;
Object lamp "brass lantern" selfobj
with name "brass" "lamp" "lantern"
has light;
Object car "little red car" cave
with name "little" "red" "car",
longdesc "Large enough to sit inside. Among the controls is a \
prominent on/off switch. The numberplate is KAR 1.",
initpos "The red car sits here, its engine still running.",
closedpos "A little red car is parked here.",
preroutine RedCarPre, postroutine RedCarPost
has switchable enterable static container open;
Object note "small note" car
with name "small" "note",
longdesc " !!!! FROBOZZ MAGIC CAR COMPANY !!!!^\
^Hello, Driver!^\
^Instructions for use:^\
^Switch on the ignition and off you go!^\
^Warranty:^\
^This car is guaranteed against all defects for a period of \
76 milliseconds from date of purchase or until used, \
whichever comes first.^\
^Good Luck!";
Object view "Window" nothing
with longdesc "You're at a low window overlooking a huge pit, which \
extends up out of sight. A floor is indistinctly visible \
over 50 feet below. Traces of white mist cover the floor \
of the pit, becoming thicker to the right. Marks in the \
dust around the window would seem to indicate that \
someone has been here recently.^^Directly across the pit \
from you and 25 feet away there is a similar window \
looking into a lighted room. A shadowy figure can \
be seen there peering back at you.^^A narrow crack in the \
rocks leads back down.",
d_to broken, preroutine ViewPre
has light;
Object key "iron key" view
with name "iron" "key", article "an";
Object broken "Broken Passage" nothing
with longdesc "You are in a dirty broken passage. To the east is a \
crawl. To the south is a large passage. Above you is another \
passage.",
e_to cave, n_to door, s_to yriver, u_to view;
Object door "iron door" broken
with name "iron" "door",
initpos "In the north wall is an open iron door.",
closedpos "In the north wall is a shut iron door.",
portalto ledge,
dirprop n_to,
with_key key
has portal static openable lockable locked;
Object ledge "Canyon Ledge" nothing
with longdesc "The door opened out onto a tiny ledge at the top of the \
Great Canyon on its west wall. From here there \
is a marvelous view of the canyon and parts of the Frigid River \
upstream. Across the canyon, the walls of the White Cliffs join \
the mighty ramparts of the Flathead Mountains to the east. \
Following the Canyon upstream to the north, Aragain \
Falls may be seen, complete with rainbow. The mighty Frigid River \
flows out from a \
great dark cavern. To the west and south can be seen an immense \
forest, stretching for miles around. It is absolutely impossible \
to climb down into the canyon from here.",
s_to broken;
Object yriver "Yellow River Rock" nothing
with longdesc "You are in a splendid chamber thirty feet high. The walls \
are frozen rivers of orange stone. An awkward canyon and a \
good passage exit from north and south sides of the chamber.",
n_to broken, s_to debris;
Object sack "brown paper sack" yriver
with name "brown" "paper" "sack",
initpos "Hanging mysteriously in mid-air, at about the height of a \
kitchen table, is an elongated brown sack, smelling of hot \
peppers.", preroutine SackPre, capacity 3
has container interior openable;
Object cube3 "featureless white cube" sack
with name "white" "cube"
has is_cube scored;
Object clove "clove of garlic" sack
with name "clove" "of" "garlic", preroutine ClovePre
has edible;
Object sandwich "pepper sandwich" sack
with name "pepper" "sandwich", preroutine SandwichPre
has edible;
Object debris "Debris" nothing
with longdesc
"You are in a debris room filled with stuff washed in from the \
surface. A low wide passage with cobbles becomes plugged \
with mud and debris here, so that you could only just squeeze \
by northeast, but an awkward canyon leads \
north and steps lead up. A note on the wall says:^\
^ Magic Word ~XYZZY~",
n_to yriver, u_to mists, ne_to traproom;
Object gun "ray gun" debris
with name "ray" "gun",
longdesc "Labelled Frobozz Magic Ray Gun Co., it works on \
gerontological principles."
has scored;
Object mists "Hall of Mists" nothing
with longdesc "You are at one end of a vast hall stretching forward out of \
sight to the west. There are bricked-up openings to either side. \
Nearby, a wide stone staircase leads downward. The hall \
is filled with wisps of white mist swaying to and fro \
almost as if alive. A cold wind blows up the staircase. \
There is a passage at the top of a dome behind you.",
d_to debris, w_to wend,
preroutine MistsPre;
Object snake "sullen snake" mists
with name "sullen" "snake",
longdesc "Perhaps a boa constrictor. Perhaps not.",
liferoutine SnakeLife
has animate;
Object oldsnake "aged, sullen snake" nothing
with name "sullen" "snake", article "an",
longdesc "A sad and decrepit echo of a once-great serpent."
has animate;
Object wend "West End of Hall of Mists" nothing
with longdesc "You are on the east bank of a fissure slicing clear across \
the hall. The mist is quite thick here, and the fissure \
is too wide to jump.",
e_to mists
has scored;
Object grenade "hand grenade" wend
with name "hand" "grenade",
initpos "A nasty-looking hand grenade (there is no other kind) \
rolls about on the floor here.",
timeleft 0,
preroutine GrenadePre;
Object reservoir "Reservoir" nothing
with longdesc "You are at the edge of a large underground reservoir. An \
opaque cloud of white mist fills the room and rises \
rapidly upward. The lake is fed by a stream which tumbles \
out of a hole in the wall about 10 feet overhead and \
splashes noisily into the water somewhere within the mist. \
The only passages go north and east.",
n_to cave, e_to loud, preroutine ReservoirPre
has scored;
Object clover "two-leafed clover" reservoir
with name "two" "two-lea" "clover",
longdesc "Unlucky for some.",
initpos "Growing from a tuft of mould is a single two-leafed clover.",
postroutine CloverPost;
Object loud "Loud Room" nothing
with longdesc "This is a large room with a ceiling which cannot be detected \
from the ground. \
There is a narrow passage turning sharply from west to southwest. \
The room is deafeningly loud with an undetermined rushing sound. \
The sound seems to reverberate from all of the walls, making it \
difficult even to think.",
w_to reservoir, sw_to traproom,
preroutine LoudPre;
Object bar "platinum bar" loud
with name "bar" "platinum",
longdesc "Exquisite."
has scored;
Object traproom "@00" nothing
with longdesc "This is a medium-sized, quite unremarkable furnished sitting \
room, with skirting boards, floral wallpaper and a pine floor. \
Unremarkable that is...^^...except for the huge red sign over the \
mantelpiece reading ~TRAP~, \
and the sage advice ~Leave by the lowest way~, which could be \
either of the northeast or southwest exits, for all you know.",
ne_to loud, sw_to debris, preroutine TraproomPre;
Object mantelpiece "heavy mantelpiece" traproom
with name "mantel" "mantle"
has scenery supporter;
Object lantern "iron lantern" mantelpiece
with name "iron" "lantern" "lamp", article "an"
has light;
Object level "spirit level" traproom
with name "spirit" "level",
longdesc "A length of wood containing a flask of viscous green liquid, \
in which a bubble is trapped.", postroutine LevelPost;
Object block "wooden block" traproom
with name "wooden" "block", capacity 2
has supporter;
! ----------------------------------------------------------------------------
! Game control code: put initialisation in Initialise(), which is called
! by Game() in the Parser. (This happens before the banner is printed.)
! Initialise is expected to set "location" to the initial location.
!
! The Parser keeps control, calling out to verb routines as needed.
! TimePasses is called after every turn of "real" time has passed (but not,
! for instance, after a "score" command).
!
! The line about plurals declares a new dictionary word "cubes" which is
! to refer to all objects with the is_cube attribute (declared above).
! ----------------------------------------------------------------------------
[ Initialise;
location=cave;
plural_word1 = #n$cubes; plural_filter1 = is_cube;
string 0 "Paranoia Room";
print "^^^^^What a horrid dream, all about compiling something. \
Thank heavens you've finally woken up, even if you seem to have been \
sleep-walking. \
As you dizzily shake your head, you can't help feeling this place is \
somehow familiar...^^";
];
[ TimePasses i;
if random(4)==1
{ i=random(60);
if i==1 { print "^Far away, you hear the hammering of dwarven anvils.^"; }
if i==2 { print "^A shadowy figure glides by in the corner of view.^"; }
if i==3 { print "^Bats flutter through the cave, startling you.^"; }
if i==4 { print "^A hoarse voice whispers, ~PLUGH~.^"; }
if i==5 { print "^The floor shakes in a sudden earth tremor!^"; }
if i==6
{ print "^You hear a door creak open, somewhere in the distance.^"; }
}
if TimeUp(grenade)==1
{ print "^There is suddenly an immense explosion! This is unlikely to \
teach you not to meddle with things you don't understand... \
On the other hand you'll never do so again.^"; deadflag=1;
}
];
[ PrintRank;
print ", earning you the rank of ";
if score >= 35 { print_ret "navigator."; }
if score >= 20 { print_ret "adventurer."; }
if score >= 5 { print_ret "explorer."; }
if score >= 1 { print_ret "tourist."; }
print_ret "somnambulist.";
];
[ PrintTaskName ach;
if ach==0 { print_ret "driving the car"; }
if ach==1 { print_ret "zapping the snake"; }
if ach==2 { print_ret "drinking some water"; }
print_ret "(something else)";
];
[ DarkToDark;
deadflag=1;
print_ret "As you step falteringly through the darkness, \
cowardly but evil creatures devour you whole!";
];
[ DeathMessage;
if deadflag==3 { print "You have drowned"; }
];
[ LookRoutine;
clear_attr sword light;
if location==parent(snake)
{ if player==parent(sword)
{ print "^Your sword gives off a bright greenish light!^";
set_attr sword light;
}
}
];
[ Amusing;
print_ret "Why not write an Inform game?";
];
[ GamePreRoutine;
rfalse;
];
[ NewRoom;
rfalse;
];
! ----------------------------------------------------------------------------
! Verb action routines
! ----------------------------------------------------------------------------
[ MagicWordSub;
print_ret "For a moment you can almost hear a hoarse voice \
say something to you. But it passes.";
];
[ EchoSub;
if location==loud
{ give loud general;
print_ret "The acoustics of the room subtly alter...";
}
print_ret "There isn't an echo here.";
];
[ ShootSub;
if player~=parent(gun)
{ print_ret "You have nothing to shoot with.";
}
if inp1==gun { print_ret "It is unable to shoot itself."; }
if inp1==selfobj
{ deadflag=1;
print_ret "Your hands suddenly look rather white and skeletal, \
but then again the light is getting dimmer, and dear oh dear but \
it seems cold in here, and so sleepy..."; }
if inp1 has edible { remove inp1; print "Zap! "; CDefArt(inp1);
print_ret " decays into a noisome mess and expires messily into dust."; }
if inp1==clover
{ remove clover; print_ret "Zap! The clover shrivels into dust."; }
if inp1==snake
{ remove snake; move oldsnake to mists; itobj=oldsnake; Achieved(1);
print_ret "Zap! The snake suddenly wrinkles and concertinas, sheds \
a layer of skin and lurches back upright, looking sadly decrepit."; }
if inp1==oldsnake { deadflag=1;
print_ret "Zap! The old snake dodges your callous blast, leaps \
forward and sinks its aged fangs into your wrist. Amazing how \
the venom is still effective even at that age, isn't it?"; }
print_ret "Zap! There is no appreciable effect.";
];
[ SnakeLife;
if reason_code==0
{ if action==#a$GoSub { print_ret "The snake wasn't born yesterday. \
It is going nowhere."; }
rfalse;
}
if reason_code==#a$AttackSub
{ print_ret "Lazily, the snake dodges your attack.";
}
if reason_code==#a$KissSub
{ print_ret "What a repulsive idea.";
}
if reason_code==#a$ThrowAtSub
{ print "Effortlessly, the snake dodges "; DefArt(inp1);
print_ret ".";
}
if reason_code==#a$AnswerSub
{ print_ret "The snake disdains to comment.";
}
if reason_code==#a$AskSub
{ print_ret "~I'm only the obligatory monster.~";
}
if reason_code==#a$GiveSub
{ if inp1 has edible
{ remove_obj inp1;
print_ret "~Mmm! Thanks! I still hate you, though.~";
}
print_ret "~Bleurghh! Are you trying to poison me?~";
}
rfalse;
];
[ ClovePre;
if action==#a$SmellSub { print_ret "That'll keep the vampires away."; }
rfalse;
];
[ SandwichPre;
if action==#a$SmellSub { print_ret "Peppers! Excellent."; }
rfalse;
];
[ SackPre;
if action==#a$SmellSub { print_ret "A tantalising aroma."; }
rfalse;
];
[ RedCarPre;
if action==#a$PushDirSub { AllowPushDir(); rtrue; }
if action~=#a$GoSub { rfalse; }
if inp1==u_obj or d_obj { rfalse; }
if car has on { Achieved(0); print_ret "Brmm! Brmm!"; }
print "(The ignition is off at the moment.)^";
rfalse;
];
[ RedCarPost;
if action==#a$PushDirSub
{ print_ret "The car rolls very slowly as you push it."; }
rfalse;
];
[ CloverPost;
if action~=#a$TakeSub { rfalse; }
if player~=parent(sword) { rfalse; }
print_ret "As you take the clover, your sword shines \
a sudden burst of light!";
];
[ ViewPre;
if action==#a$WaveHandsSub
{ print_ret "The shabby figure waves back at you."; }
rfalse;
];
[ ReservoirPre;
if action==#a$DrinkSub
{ Achieved(2); print_ret "Unfluoridated and clear. You feel better."; }
if action==#a$FillSub { print_ret "The water is too sacred."; }
if action==#a$SwimSub
{ deadflag=3;
print_ret "Your first reaction is, this is very cold water. Your \
second reaction is that it is also very inhabited water. What with \
the sea-serpent dragging you down to a rapid drowning (gurgling \
~that's for the white crystal ball, you greedy swine~, \
perhaps mistaking you for someone else) there is no opportunity for \
a third opinion."; }
rfalse;
];
[ Cube1Pre;
if action~=#a$TakeSub { rfalse; }
print_ret "You flinch from touching the cube, which is white hot!";
];
[ LoudPre i;
if loud has general { rfalse; }
if action==#a$GoSub { rfalse; }
i=parse-->1;
print_addr i; print_char ' '; print_addr i;
print_char ' '; print_addr i; print "...^";
if action==#a$EchoSub { rfalse; }
rtrue;
];
[ MistsPre;
if action~=#a$GoSub { rfalse; }
if inp1~=w_obj { rfalse; }
if mists==parent(snake)
{ print_ret "The snake, predictably, won't let you pass."; }
print "You dodge the sad old snake without difficulty.^";
rfalse;
];
[ GrenadePre;
if action~=#a$PullSub { rfalse; }
if grenade has general { rfalse; }
SetTimer(grenade, 5); give grenade general;
print_ret "You pull the pin out, an irrevocable act.";
];
Global trap_slope = 0;
[ TraproomPre;
if action~=#a$GoSub { rfalse; }
if inp1==sw_obj or ne_obj
{ if level has general
{ if trap_slope==0 { jump WrongWay; }
if trap_slope==1 { if inp1==sw_obj { jump WrongWay; } }
if trap_slope==2 { if inp1==ne_obj { jump WrongWay; } }
}
if traproom hasnt general
{ string 0 "Trap Room";
give traproom general;
print_ret "A voice booms out, ~This is your only warning!~ and \
stops you in your tracks.";
}
}
rfalse;
.WrongWay; deadflag=1; print_ret "To the sound of maniacal laughter, \
a thousand tons of rubble falls upon your head.";
];
[ LevelPost;
if action~=#a$PutOnSub { rfalse; }
if inp2~=mantelpiece { rfalse; }
if level hasnt general { trap_slope=random(2); }
give level general;
print "You put the spirit level on the mantelpiece, and the bubble \
slowly drifts towards the ";
if trap_slope==1 { print_ret "northeast."; }
print_ret "southwest.";
];
[ SHelpSub;
print_ret "Try ~help credits~ or ~help instructions~.";
];
Dictionary h1_word "instru";
Dictionary h2_word "credit";
[ HelpSub i;
i=special_word;
new_line;
if i==#w$instru
{ print_ret "This is Deja Vu, a demonstration game only. \
Do with it as you please. This unhelpful message is \
provided only so a help routine could been coded.";
}
if i==#w$credit
{ Banner();
print_ret "^Release 2 is the second edition posted to the \
interactive-fiction archive. It is substantially \
rewritten. Updated versions may possibly follow.^";
}
print_ret "There's no help on that, sorry.";
];
! ----------------------------------------------------------------------------
! The grammar table consists of the standard one, plus some of our own:
! ----------------------------------------------------------------------------
#include "Grammar";
Verb "echo"
* -> EchoSub;
Verb "xyzzy" "plugh" "plover" "blorple"
* -> MagicWordSub;
Verb "shoot" "zap"
* noun -> ShootSub;
Verb "help"
* -> SHelpSub
* special -> HelpSub;
! ----------------------------------------------------------------------------
end;