From: despair@seeker.hermesnet.net

Here's another -- I coded this way back for a merc type mud...back before
OLC and portal spells and such...however, I think it still makes for a
really cool IMMORTAL command.

Portal essentually creates a door from the room you're in, to another room
with the description 'portal'.  It will accept the argument as a number
(vnum of the room to connect with), or a character name (will connect the
room they're in -- also, you specify whether the door will be openpath,
closed..etc... and you can specify a key.  Portals will not save through
reboot.

Type 'portal' with no arguments to see correct syntax.  

I hope that it ports correctly..I really havn't taken a great amount of
time to make sure that it's working spic-n-span with ROM; however, I did
enable it on my mud and it seemed to work fine :)


Amadeus
--------------


 /* An 'Amadeus Contribution' */
void do_portal( CHAR_DATA *ch, char *argument )
{
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
    char arg3 [MAX_INPUT_LENGTH];
    char arg4 [MAX_INPUT_LENGTH];
    char buf  [MAX_STRING_LENGTH];
    EXIT_DATA *pexit;  
    ROOM_INDEX_DATA *location;
    CHAR_DATA *victim;
    int door, j;
    char *dir[] =
     {
       "north", "east", "south", "west", "up", "down" 
     };


    char *stat[] =
     {
       "openpath", "isdoor", "pickproof", "passproof" 
     };
    

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );
    one_argument( argument, arg4 );

      for ( door = 0; door < 6; door++)
        if ( !str_prefix( arg1, dir[door]) )
             break;
    
      for ( j = 0; j < 4; j++ )
        if ( !str_prefix( arg2, stat[j]) )
            break;

      if ( !str_cmp( arg2, "remove") )
      {
	 if ( ( pexit = ch->in_room->exit[door] ) == NULL )
          {
           send_to_char( "\n\rNo exit exists in that direction.\n\r", ch );
           return;
          } 

         if ( str_cmp( pexit->keyword, "portal") )
         {
             send_to_char( "Exit is an area preset, not a portal.\n\r", ch );
             return;
         }

         pexit = ch->in_room->exit[door];
         free_string(pexit->keyword);
         free_string(pexit->description);

/*   Do you have anymore pexit-> strings that should be freed if it were 
 *   removed ( with free_string) ?
 */
	 if (pexit)
           free_mem(pexit,sizeof(EXIT_DATA));
         ch->in_room->exit[door] = NULL;
         sprintf( buf, "\n\rExit to the %s removed.\n\r", dir[door]);
         send_to_char( buf, ch);
         sprintf( buf, "%s concentrates for a moment...and the %s exit suddenly vanishes!\n\r", capitalize( ch->name ), dir[door]);
         act( buf, ch, NULL, NULL, TO_ROOM);     
         return;
      }


      if ( arg1[0] == '\0' || arg2[0] == '\0' 
	   || j == 4 || door == 10 || arg3[0] == '\0'
  	   || ( arg4[0] != '\0' && !is_number(arg4)) )
      {
	send_to_char( "Syntax: portal <direction> <status> <vnum of room to connect> <key vnum>\n\r",         ch );
	send_to_char( "    Or: portal <direction> <status> <person/mob>\n\r", ch );
	send_to_char( "    Or: portal <direction> remove\n\r\n\r",        ch );
        send_to_char( "direction being one of:\n\r",                      ch );
	send_to_char( "  north, south, east, west, up, down\n\r",         ch );
	send_to_char( "status being either:\n\r",                         ch );
        send_to_char( "  openpath, isdoor, pickproof, passproof\n\r\n\r", ch );
        send_to_char( "note:  It is not necessary to set a key vnum.\n\r\n\r", ch);
        return;
      }  
      

      if ( ( pexit = ch->in_room->exit[door] ) != NULL )
      {
           send_to_char( "\n\rAn exit already exists in that direction.\n\r", ch );
           return;
      } 
 
      if ( ( location = find_location( ch, arg3) ) == NULL )
      {
           send_to_char( "The room that you wish to connect to does not exist.\n\r", ch);
           return;
      }

      if ( room_is_private( location = find_location( ch, arg3 )) && get_trust(ch) < MAX_LEVEL )
      {
           send_to_char( "The room that you wish to connect to is private.\n\r", ch);
           return;
      }

      if ( ( location = find_location( ch, arg3 ) ) == ch->in_room )
      {
           send_to_char( "Why would you want to create a portal to this room?\n\r", ch );
           return;
      }
  
       

      pexit                    = alloc_mem( sizeof( EXIT_DATA ) );
      ch->in_room->exit[door]  = pexit;
      pexit->description       = str_dup( "A mysterious portal.\n\r" ); 
      pexit->keyword           = str_dup( "portal");
      pexit->key               = is_number(arg4)?atoi(arg4):-1;
      
      if ( is_number( arg3 ) )
         pexit->u1.vnum              = atoi(arg3);
      else
      {
           victim                 = get_char_world( ch, arg3 );
 	   pexit->u1.vnum	          = victim->in_room->vnum;
      }
      pexit->u1.to_room	       = location;
      pexit->exit_info         = 0; 
	
/*   Does your code have anymore pexit-> fields that need to be set other 
 *   than the ones listed above?  I don't think so..but better check :)
 */


      switch (j)
      {
         case 3: pexit->exit_info |= EX_NOPASS | EX_CLOSED | EX_LOCKED;
         case 2: pexit->exit_info |= EX_PICKPROOF | EX_CLOSED | EX_LOCKED;
         case 1: pexit->exit_info |= EX_ISDOOR;
      } 
         
      if ( is_number( arg3 ) )
	sprintf( buf, "\n\r'Portal' created %s, to room %d - key is object %d.\n\r", dir[door], atoi(arg3), atoi(arg4) );
      else
        sprintf( buf, "\n\r'Portal' created %s, to %s's room - key is object %d.\n\r", dir[door], str_dup(arg3), atoi(arg4) );
      send_to_char( buf, ch);
   
      sprintf( buf, "%s concentrates for a moment as a mysterious portal appears going %s.\n\r", capitalize( ch->name ), dir[door] );
      act( buf, ch, NULL, NULL, TO_ROOM);

      return;

}