the-infocom-files / trinity

Trinity
23 stars 5 forks source link

Walking bugs when the world is flipped #24

Open eriktorbjorn opened 4 years ago

eriktorbjorn commented 4 years ago

The way flipping is handled, all map connections remain the same but V-WALK causes you to walk in the other direction:

<ROUTINE V-WALK ("AUX" PT PTS STR OBJ RM)
     <COND (<AND <T? ,FLIP?>
             <T? ,P-WALK-DIR>
             <IS? ,HERE ,SHADOWY>>
        <SETG PRSO <COND (<PRSO? P?EAST> ,P?WEST)
                     (<PRSO? P?WEST> ,P?EAST)
                     (<PRSO? P?SE> ,P?SW)
                     (<PRSO? P?SW> ,P?SE)
                     (<PRSO? P?NE> ,P?NW)
                     (<PRSO? P?NW> ,P?NE)
                 (T ,PRSO)>>)>

The problem is when you force the player to walk in a certain direction by calling DO-WALK. It's implemented in terms of <PERFORM ,V?WALK ...>, so the direction ends up being flipped. It's a bit confusing, so consider the example below:

Let's say you're standing inside the cottage. The garden is to the east on the unflipped map, and to the west on the flipped map. When you type "WEST", V-WALK flips it so that you are actually walking east into the garden. But if you type "ENTER GARDEN", the COTTAGE-F routine will call <DO-WALK ,P?EAST>. This gets flipped to west, so you walk in the opposite direction compared to what you intended to:

>LOOK
Cottage

An iron cauldron, brown with the crust of years, squats in the middle of this
tiny chamber. Coils of steam writhe from its depths, filling the air with a
greasy stench that makes your nose wrinkle. Luckily, the front door is wide
open. Another door leading west is closed.

A crudely drawn map hangs upon the wall.

The biggest book you've ever seen lies open on a pedestal in the corner.

There's a birdcage here. Inside the birdcage you see a magpie.

>ENTER GARDEN
Bluff

A spectacular crop of toadstools extends far and wide across the valley below.
Narrow trails curve southeast and southwest, away from the edge of the bluff.

To the west stands a little cottage, nestled in a shady copse. The front door is
open.
           (<ENTERING?>
        <COND (<ZERO? .IN>
               <DO-WALK ,P?EAST>
               <RTRUE>)>
        <ALREADY-IN>
        <RTRUE>)
           (<EXITING?>
        <COND (<ZERO? .IN>
               <NOT-IN>
               <RTRUE>)>
        <DO-WALK ,P?WEST>
        <RTRUE>)

I'm going to list all the cases I can find where this causes problems here, unless they warrant separate bug reports.

eriktorbjorn commented 4 years ago

The same bug appears in WATERFALL-F:

           (<VERB? WALK-AROUND>
        <COND (<T? .IN>
               <DO-WALK ,P?EAST>
               <RTRUE>)
              (<IS? ,CAVE-HOLE ,SEEN>
               <DO-WALK ,P?WEST>
               <RTRUE>)>
        <TELL "There's no obvious way around the "
              D ,PRSO ,PERIOD>
        <RTRUE>)

If the world is flipped, "WALK AROUND WATERFALL" takes you in the wrong direction.

eriktorbjorn commented 4 years ago

CAVE-HOLE-F:

           (<OR <ENTERING?>
            <VERB? WALK-AROUND CROSS>>
        <DO-WALK <COND (<ZERO? .IN> ,P?WEST) (T ,P?EAST)>>
        <RTRUE>)

"ENTER HOLE" takes you in the wrong direction when the world is flipped.

eriktorbjorn commented 4 years ago

Same thing with STREAM-F:

           (<VERB? FOLLOW CLIMB-DOWN>
        <DO-WALK <COND (<HERE? SBOG> ,P?SE)
                       (<HERE? AT-TRELS> ,P?NE)
                       (T ,P?EAST)>>
        <RTRUE>)
           (<VERB? CLIMB-UP CLIMB-ON>
        <DO-WALK <COND (<HERE? AT-BEND> ,P?SW)
                       (<HERE? AT-TRELS> ,P?NW)
                       (T ,P?WEST)>>
        <RTRUE>)
eriktorbjorn commented 4 years ago

CAVE-F looks like it should have the same bug, but apparently it's not actually used?

        <COND (<ZERO? .IN>
               <DO-WALK ,P?WEST>
               <RTRUE>)>
        <ALREADY-IN>
        <RTRUE>)
           (<EXITING?>
        <COND (<ZERO? .IN>
               <NOT-IN>
               <RTRUE>)>
        <DO-WALK ,P?EAST>
        <RTRUE>)

I would have expected CAVE to be local global to ICE-CAVE and AT-FALLS, but it's not. So... yay?

eriktorbjorn commented 4 years ago

COTTAGE-F has the same bug, so "ENTER COTTAGE" fails from either direction when the world is flipped:

           (<ENTERING?>
        <COND (<HERE? IN-GARDEN>
               <DO-WALK ,P?WEST>
               <RTRUE>)
              (<HERE? ON-BLUFF>
               <DO-WALK ,P?EAST>
               <RTRUE>)>
        <ALREADY-IN>
        <RTRUE>)
eriktorbjorn commented 4 years ago

HEDGE-F:

           (<VERB? FOLLOW>
        <COND (<HERE? DOCKSIDE>
               <DO-WALK ,P?WEST>
               <RTRUE>)
              (<HERE? FCLEARING>
               <DO-WALK ,P?EAST>
               <RTRUE>)>
        <V-WALK-AROUND>
        <RTRUE>)

So "FOLLOW HEDGE" fails from either endpoint when the world is flipped.

eriktorbjorn commented 4 years ago

Same thing with SUMMIT-F:

           (<OR <ENTERING?>
            <VERB? CLIMB-ON CLIMB-UP CLIMB-OVER CROSS STAND-ON>>
        <COND (<ZERO? .ON>
               <DO-WALK <COND (<HERE? IN-MEADOW>
                       ,P?NORTH)
                      (<HERE? FCLEARING>
                       ,P?WEST)
                      (T
                       ,P?SW)>>
               <RTRUE>)>
        <ALREADY-IN ,PRSO T>
        <RTRUE>)
eriktorbjorn commented 4 years ago

Note that there is at least one place where DO-WALK works as intended, even when the world is flipped. See https://github.com/the-infocom-files/trinity/issues/96 which, while it does describe a bug, is not caused by the above problem at all.