/*
** This file is the std.t replacement for "Arrival". As such it contains
** a lot of the basic definitions for the adventure.
**
** Copyright (c) 1998, Stephen Granade. All rights reserved.
*/
#pragma C+
/*
* Pre-declare all functions, so the compiler knows they are functions.
* (This is only really necessary when a function will be referenced
* as a daemon or fuse before it is defined; however, it doesn't hurt
* anything to pre-declare all of them.)
*/
die: function;
win: function;
theEnd: function;
endCredits: function;
scoreRank: function;
init: function;
initRestore: function;
initCommon: function;
getSysInfo: function;
terminate: function;
pardon: function;
darkTravel: function;
/*
** The die() function is called when the player dies. Since I also have
** a win() function, all this does is tell the player that he lost, then
** calls another function which prints the quit/restore/etc. bit.
*/
die: function
{
if (global.isHTMLRuntime)
"\b
You have let the aliens
win
\b";
else "\b\(You have let the aliens win\)\b";
endCredits(nil);
}
/*
** The win() function is just like the die function, only with a
** different message.
*/
win: function
{
if (global.isHTMLRuntime)
"\b
You have defeated the aliens...for
now
\b";
else "\b\(You have defeated the aliens...for now\)\b";
endCredits(true);
}
/*
** theEnd() function is like win()/die(), only without a specific message.
** Instead, you pass the message you want printed to this function.
*/
theEnd: function(msg)
{
if (global.isHTMLRuntime)
"\b
<>
\b";
else "\b\(<>\)\b";
endCredits(nil);
}
/*
** amusingList contains the list of amusing things to be done.
*/
amusingList: object
listItems = [
'Looking underneath the refrigerator?'
'Looking under the carpet in the living room?'
'Looking at the dirty dishes each time you wash one?'
'Cleaning different things around the house?'
'Turning on the water faucet when Zigurt and Floban are around?'
'Entering the ship’s shadow?'
'...more than once?'
'Asking WHAT IS about stuff?'
'Asking WHO IS ZIGURT or FLOBAN before the ship lands? Before the aliens
come out into the backyard?'
'Calling the ship a sheep?'
'Turning the rain stick over in the presence of Zigurt and Floban?'
'Playing with the universal translator?'
]
;
/*
** The endCredits() function tells the player how well he has done
** and asks if he'd like to start over. If the player won, it also
** asks him if he'd like to see some amusing things to do.
** I've modified the usual version found in std.t so that you can
** type 'Q' to quit, 'R' to restore, 'S' to restart, and 'U' to undo.
*/
endCredits: function(won)
{
local len, i, sepString = '';
scoreRank();
if (won)
"\bYou may restore a saved game, start over, quit, see a list of
amusing things to try, or undo the current command.\n";
else "\bYou may restore a saved game, start over, quit, or undo
the current command.\n";
while ( 1 )
{
local resp;
"\nPlease enter (R)ESTORE, RE(S)TART, (Q)UIT, ";
if (won)
"(A)MUSING, AUTHOR’S (N)OTE, ";
"or (U)NDO: >";
resp = upper(input());
if ( resp == 'RESTORE' || resp == 'R' )
{
resp = askfile( 'File to restore' );
if ( resp == nil ) "Restore failed. ";
else if ( restore( resp )) "Restore failed. ";
else
{
Me.location.lookAround(true);
scoreStatus( global.score, global.turnsofar );
abort;
}
}
else if ( resp == 'RESTART' || resp == 'S' )
{
scoreStatus( 0, 0 );
restart();
}
else if ( resp == 'QUIT' || resp == 'Q' )
{
terminate();
quit();
abort;
}
else if ( (resp == 'AUTHOR\'S NOTE' || resp == 'NOTE' || resp == 'N')
&& won ) {
authors_note.give;
}
else if ( (resp == 'AMUSING' || resp == 'A') && won )
{
if (global.isHTMLRuntime) {
"
Have you tried:";
sepString = '
';
}
else {
"\bHave you tried:\n";
sepString = '\n\t';
}
len = length(amusingList.listItems);
for (i = 1; i <= len; i++)
"<><>";
if (global.isHTMLRuntime)
"
";
else "\n";
}
else if (resp == 'UNDO' || resp == 'U' )
{
if (undo())
{
"(Undoing one command)\b";
Me.location.lookAround(true);
scoreStatus(global.score, global.turnsofar);
abort;
}
else
"Sorry, no undo information is available. ";
}
}
}
/*
* The scoreRank() function displays how well the player is doing.
* This default definition doesn't do anything aside from displaying
* the current and maximum scores. Some game designers like to
* provide a ranking that goes with various scores ("Novice Adventurer,"
* "Expert," and so forth); this is the place to do so if desired.
*
* Note that "global.maxscore" defines the maximum number of points
* possible in the game; change the property in the "global" object
* if necessary.
*/
scoreRank: function
{
"You have achieved a score of ";
if (global.score == 0 || !global.isHTMLRuntime)
"<> ";
else ">.jpg\"
alt=\"<> \"> ";
"points out of a possible ";
if (!global.isHTMLRuntime)
"<> ";
else ">.jpg\"
alt=\"<> \"> ";
"in <> turns. ";
}
/*
** The init() function is run at the very beginning of the game.
** It prints introductory text, moves the player to the beginning room
** (which defaults to startroom), and sets up some background activity.
*/
init: function
{
initCommon(); // Do the common init stuff
// put introductory text here
"\bGeez, mom really hacks you off sometimes. I mean, making you do dishes
while that new show Captain Dangerous is on. Last week,
Cap’n was having to fight off the slavering hordes of Gamma Proxima
Epsilon Centauri
Five B, and he and his side-kick Billy Bob had used up the last of their
ammo keeping the zombie mind troopers at bay. The evil over-leader
had just shown up with his mucilage-ray when the show ended.\b
And you’re stuck cleaning the Pfaltzgraff while Cap’n and Billy
Bob fight for their lives.\b
Life’s not fair when you’re eight.\b";
setdaemon( turncount, nil ); // start the turn counter daemon
// I don't like having the player have to eat or sleep, so I removed the
// lines that start those daemons
Me.location = startroom; // move player to initial location
startroom.lookAround( true ); // show player where he is
startroom.isseen = true; // note that we've seen the room
scoreStatus(0, 0); // initialize the score display
notify(alien_daemon, &arrival, 12); // Start up the beginning alien
// daemon
}
/*
** initRestore() is called if the player restores a saved game from the
** command line. This allows me to handle restoring saved games at the start
** gracefully. It also lets me make sure that any leftover sounds are
** silenced.
*/
initRestore: function(savedGame)
{
initCommon(); // Do the stuff common to us & to init()
""; // Turn off any sounds
mainRestore(savedGame); // Now restore the saved game
}
/*
** As suggested in the manual, I've put the code which is common to both
** init() and initRestore() into this separate function, initCommon().
*/
initCommon: function
{
"\H+"; // Turn on HTML formatting
clearscreen(); // Clear the screen
getSysInfo(); // Set up the sys-dependent info
randomize(); // If you're going to have random events
// occur, you're going to want to call
// randomize() so that the random-number
// generator doesn't do the same thing
// every game
}
/*
** getSysInfo updates all the interpreter-specific flags we maintain
** (i.e. can we print graphics, make sounds, etc.). This is a separate
** function because the flags must be updated at *every* restore--there's
** a slim chance that the player was playing using an HTML runtime, saved
** their game, then restored that game on a non-HTML runtime. Yeah, it's
** not very likely, but I've done it, and it's easy enough to add.
*/
getSysInfo: function
{
if (systemInfo(__SYSINFO_SYSINFO) == true) { // Adjust the graphics stuff
global.isHTMLRuntime = (systemInfo(__SYSINFO_HTML) == 1);
global.graphicsOnce = true;
global.canDoGraphics = (systemInfo(__SYSINFO_JPEG) == 1) ||
(systemInfo(__SYSINFO_PNG) == 1);// True if we can do PNG or JPEG
}
else {
"\b\(WARNING: This particular TADS interpreter is an earlier version
than 2.2.4. Because of this, this game will look mighty funky to
you, or may not run at all. I highly suggest you get an updated
version of the TADS interpreter. You should be able to find
one at
ftp://ftp.gmd.de/if-archive/programming/tads/executables.\)\b";
global.isHTMLRuntime = nil; // This runtime's not HTML capable
global.graphicsOnce = nil; // runtime, so we can't do any
global.canDoGraphics = nil; // graphics
}
if (global.isHTMLRuntime) {
"