Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!news.rwth-aachen.de!news-koe1.dfn.de!RRZ.Uni-Koeln.DE!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!news.belwue.de!swidir.switch.ch!news.grnet.gr!btnet-feed2!btnet!tank.news.pipex.net!pipex!arclight.uoregon.edu!feed1.news.erols.com!howland.erols.net!netcom.com!erkyrath
From: erkyrath@netcom.com (Andrew Plotkin)
Subject: Re: [Inform] Two questions about odd stuff
Message-ID: <erkyrathE0Ep5A.KH5@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <55n3e2$n1g@dfw-ixnews11.ix.netcom.com>
Date: Tue, 5 Nov 1996 16:43:57 GMT
Lines: 117
Sender: erkyrath@netcom.netcom.com

Russell Wain Glasser (rglasser@ix.netcom.com) wrote:
>     First question.  I want to know how to create a dummy object that
> can be assigned to become another object.  For example, suppose I have
> a crown, a ball, and a lamp, and one of these three objects (perhaps
> randomly assigned) might be designated the Most Amazing Thing.  You
> must put the Most Amazing Thing on a pedestal to complete the game, but
> if you use the wrong object then the true Amazing Thing will be
> destroyed.

> Object pedestal "pedestal" AmazingRoom
>     with before
>     [;
>         Receive:
>             if (noun == MostAmazingThing)
>             {
>                 deadflag = 2;
>                 "Fame and glory are yours.";
>             }
>             else
>             {
>                 remove MostAmazingThing;
>                 print "Suddenly, ", (the) MostAmazingThing, " vanishes 
>                     in a blaze of light!!!";
>                 if (MostAmazingThing == lamp)
>                     print "^^Unfortunately, that was your only light 
>                     source...";
>             }
>     ];

>     You get the idea, right?  How would you declare "MostAmazingThing"
> to begin with?

As a variable.

Global MostAmazingThing 0;

It starts out as zero (nothing), and you can assign to it, or text it, or 
whatever. It's a variable. 

Or am I missing the point? 

>     Second question.  I'm planning to implement a car chase scene. 
> Here's some sample text.

> "Whizzard Drive
>     You are headed north on Whizzard Drive at about 70 miles per hour. 
> Up ahead, you see the road turn east and west.

> >TURN WEST
> With a squeal of tires, the car spins off to the west.  The friction
> slows you down a lot.

> Nelson Blvd
>     You are speeding west on Nelson Blvd at about 45 miles per hour. 
> The road does not turn soon.
>     In your rear-view mirror, you see the evil Dr. Rees gaining on you
> fast.

> >Z
> Still tromping on the accelerator, you continue down the road...

> Nelson Blvd
>     You are speeding west on Nelson Blvd at about 60 miles per hour. 
> Up ahead, you see Main Street cutting diagonally from southeast to
> northwest.

> >TURN SOUTHEAST
> What?!?  You could never make such a sharp turn at your present speed!

> >NORTHWEST
> The car banks gently to the northwest..."

>     The important point here is that adjacent directions must be
> recognized as such; i.e., north is one turn away from northeast and two
> turns away from east, so turning east while going north is hard,
> turning southeast can only be done at very slow speeds, and turning
> south is impossible.
>     How could I best manage this?

First, the game should accept just "SOUTH" as well as "TURN SOUTH".

Second, hm... there are a few options. One is to trap the Go action -- 
maybe in the before clause of the room, maybe in the react_before of the 
car, or some other thing; it depends on the rest of your code. You'd 
check noun against the current travel direction (stored in a variable), 
print a message, and either return true or false (depending on whater it 
was legal.)

The other options... now that I think about it, aren't very good. (I was 
thinking of making a rooms where all the travellable direction properties 
looked like
  n_to [; return FastDriveCheck(n_obj, NelsonBlvd); ];
but you wind up writing a lot of these. Although frankly I think I would. 
Nothing wrong with copy and paste.)

Now for all these cases you have the problem of "checking" a direction 
(n_obj, e_obj, etc) against the current travel direction. Do this by 
using the number property of the direction objects (which is defined but 
not used in the parser library.) In your initialization, put
  n_obj.number = 1;
  ne_obj.number = 2;
  e_obj.number = 3;
etc. Then, to compare two directions, you can compute 
  (dir1.number - dir2.number + 8) % 8
If the result is 0, there is no change of direction; 4 is a U-turn; 1 or 
7 is a shallow turn; 2 or 6 is a right turn; 3 or 5 is a sharp turn.

(The +8 is in there so that you aren't performing modulo on a negative 
number. Modulo or division on negative numbers is buggy on some 
interpreters.)

--Z

-- 

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
borogoves..."
