hidexits.txt  Hidden exits by Yukon

  The idea of hidden exits is simple:  They don't show up on "exits" or
with autoexit on.  This is just a cheap method for making it worthwhile
for players to pay attention to what's going on around them.

  A door has the same effect, but messages of the sort: "the bush is
locked" or "you open the large rug" tend to remind me that I'm playing
a game.

  An exit with the hidden flag is not blocked in any way, so "bumping" 
around can result in stumbling in an unintended direction.  Its the
builder's responsibility to offer sufficient clues in exit description,
long room descriptions, or wherever is appropriate to unlock the
secret of the hidden exit: otherwise it winds up looking like a bug
instead of a feature.

  I leave it as a future exercise to give characters a chance to spot
a hidden exit based on a stat, or maybe even a specialized skill.
Personally, I'd rather have the player notice "suspiciously dense foliage"
or the like and decide it warrants further investigation.

For the benefit of newbie coders (You vets probably don't care how I did
it) I'll give detailed instructions.  Hopefully, it will serve as an
exercise in adding minor alterations to the codebase.  (I read every
snippet I could find when I was starting out, although I rarely have
used any.)

Yukon
mhaney@bisc.com



First, define the new exit flag in merc.h:

#define EX_LOCKED		      (C)
#define EX_HIDDEN		      (D) <-I don't know why D was available,
						but who's complaining?
#define EX_PICKPROOF		(F)

 
Next, in Tables.c, we need to match up EX_HIDDEN with some more info.

const struct flag_type exit_flags[] =
{
    { "door",		EX_ISDOOR,		TRUE  },
    {	"closed",		EX_CLOSED,		TRUE	},
    {	"locked",		EX_LOCKED,		TRUE	},
    { "hidden",		EX_HIDDEN,		TRUE	},
   [...]


the way db.c handles exits is a bit clumsy, but we'll adapt!
find this ugly thing:

		switch ( locks )
		{
		case 1: pexit->exit_info = EX_ISDOOR;               
			pexit->rs_flags  = EX_ISDOOR;		     break;
		case 2: pexit->exit_info = EX_ISDOOR | EX_PICKPROOF;
			pexit->rs_flags  = EX_ISDOOR | EX_PICKPROOF; break;
		case 3: pexit->exit_info = EX_ISDOOR | EX_NOPASS;    
			pexit->rs_flags  = EX_ISDOOR | EX_NOPASS;    break;
		case 4: pexit->exit_info = EX_ISDOOR|EX_NOPASS|EX_PICKPROOF;
			pexit->rs_flags  = EX_ISDOOR|EX_NOPASS|EX_PICKPROOF;
			break;
 Our's is	case 5: pexit->exit_info = EX_HIDDEN;
 the new		pexit->rs_flags  = EX_HIDDEN;
 case 5!			break;
		}

If you have OLC, then you need to make a change to olc_save.c:
Find this monstrosity:

                for( door = 0; door < MAX_DIR; door++ )  /* I hate this! */
                {
                    if ( ( pExit = pRoomIndex->exit[door] )
                          && pExit->u1.to_room )
                    {
			int locks = 0;
			if ( IS_SET( pExit->rs_flags, EX_ISDOOR ) 
			&& ( !IS_SET( pExit->rs_flags, EX_PICKPROOF ) ) 
		    	&& ( !IS_SET( pExit->rs_flags, EX_NOPASS ) ) )
			    locks = 1;
			if ( IS_SET( pExit->rs_flags, EX_ISDOOR )
			&& ( IS_SET( pExit->rs_flags, EX_PICKPROOF ) )
		        && ( !IS_SET( pExit->rs_flags, EX_NOPASS ) ) )
			    locks = 2;
			if ( IS_SET( pExit->rs_flags, EX_ISDOOR )
			&& ( !IS_SET( pExit->rs_flags, EX_PICKPROOF ) )
		        && ( IS_SET( pExit->rs_flags, EX_NOPASS ) ) )
			    locks = 3;
			if ( IS_SET( pExit->rs_flags, EX_ISDOOR )
			&& ( IS_SET( pExit->rs_flags, EX_PICKPROOF ) )
		        && ( IS_SET( pExit->rs_flags, EX_NOPASS ) ) )
			    locks = 4;

And add this right on the end:

		 	/* I hate it too! I'm too lazy to change it too! */ 
			if ( IS_SET( pExit->rs_flags, EX_HIDDEN ) )
			    locks = 5;

If we wanted EX_HIDDEN to be usable in combination with other flags, we'd
need to add more locks='s or change the system.

Now, the only step left is to add the functionality, that is: make it so
that exits which have been blessed with our new flag are left out of
the exits list.

In act_info.c, in the function do_exits:

	sprintf(buf,"Obvious exits:\n\r");

    found = FALSE;
    for ( door = 0; door <= 5; door++ )
    {
	if ( ( pexit = ch->in_room->exit[door] ) != NULL
	&&   pexit->u1.to_room != NULL
	&&   can_see_room(ch,pexit->u1.to_room) 
	&&   !IS_SET(pexit->exit_info, EX_CLOSED) 
	&&   !IS_SET(pexit->exit_info, EX_HIDDEN) ) <-- Here's our line!!!
	{ [...]

Congratulations! You can now add the bug, er...feature of hidden exits!


