scan if you want it...

From: Melissa (madison@nevada.edu)
Date: 04/10/95


   I was just about done getting the standard merc scan ported over, when I 
thought, what is the difference between "scan" and "look"? There shouldn't be
any! So, I removed the do_scan part of it, and added a call to scan from 
do_look. My code is below. If you like the original better, just make a 
do_scan function that loops 6 times, and calls scan with the direction. Or, to
improve this one, change my do_look part, to check a PRF_ASTUTE flag.



Okay... in act.informative.c, make the first part of look_in_direction look
like this: 


void look_in_direction(struct char_data * ch, int dir)
{

   if (EXIT(ch, dir)) {
    if (EXIT(ch, dir)->general_description) {
      scan(ch, dir);
      send_to_char(EXIT(ch, dir)->general_description, ch);
    }
    else
      scan(ch, dir);




Then, add this function anywhere before the previous one. I chose the very
beginning, so I could alter it as I thought of new things...

/*
 * Nagilum's scan function and related constants.
 * (contributed by VampLestat 17-Feb-94)
 * (modified by Mikko Kilpikoski 12-Jun-94)
 * Ported to circle 3.0 and improved by Larcevious 4/5/95
 */


char * const dist_name [] =
{
  "just",
  "close by", "not far off", "a brief walk away",
  "rather far off", "in the distance", "almost out of sight"
};

char * const dir_desc [] =
{
  "to your north", "to your east", "to your south", "to your west",
  "above you", "below you"
};

void scan( struct char_data * ch, int dir )
{
  char buf[MAX_STRING_LENGTH];
  int distance, visibility;
  bool found;
  struct char_data *vict;
  int was_in_room, percent, count = 0;

  visibility = 6;
    if (!PRF_FLAGGED(ch, PRF_HOLYLIGHT)) {
      switch( weather_info.sunlight )
        {
        case SUN_SET:   visibility = 4; break;
        case SUN_DARK:  visibility = 2; break;
        case SUN_RISE:  visibility = 4; break;
        case SUN_LIGHT: visibility = 6; break;
        default:        visibility = 6; break;
        }
      switch( weather_info.sky )
        {
        case SKY_CLOUDLESS: break;
        case SKY_CLOUDY:    visibility -= 1; break;
        case SKY_WINDY:     visibility -= 1; break;
        case SKY_RAINING:   visibility -= 2; break;
        case SKY_LIGHTNING: visibility -= 3; break;
        default:            break;
        }
    }
  was_in_room = ch->in_room;
  found = FALSE;

  for( distance = 1; distance <= 6; distance++ ) {

     switch( world[ch->in_room].sector_type )
        {
        case SECT_FOREST:     count += 25; break;    /* Trees and such will */
        case SECT_HILLS:      count += 50; break;    /* block ones view     */
        case SECT_MOUNTAIN:   count += 75; break;
        case SECT_UNDERWATER: count += 80; break;
             default:              break;
        }
      percent = number(1, 101) - count;

      if (EXIT(ch, dir) && EXIT(ch, dir)->to_room != NOWHERE) {
          if (IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED)) {
              char door_name[80];

              one_argument( fname(EXIT(ch, dir)->keyword), door_name );
              if( door_name[0] == '\0' )
                strcat( door_name, "door" );

              sprintf( buf, "A closed %s %s %s.\n\r",
                      door_name, dist_name[distance-1], dir_desc[dir] );
              send_to_char( buf, ch );

              found = TRUE;
              break;
            }
                if (IS_DARK(ch->in_room) && !CAN_SEE_IN_DARK(ch)) {
              visibility--;
              continue;
            }


   for(vict = world[EXIT(ch, dir)->to_room].people; vict != NULL; vict = vict->next_in_room ) {
          if (count > 5)
            count += 2;              /* gets harder, the more people around */
          else if (count > 10)
            count += 3;
          else if (count > 15)
            count += 10;             /* big jump to cut down spam */
          else
            count++;
                                     /* switch on race here, if imped */
                                     /* giants being easier than pixies! */

          if(GET_LEVEL(ch) >= LVL_IMMORT)
             percent = 100;
             if(CAN_SEE(ch, vict) && (percent > 5)) {
                found = TRUE;
                sprintf( buf, "%s who is %s %s.\n\r",
                        PERS( vict, ch ),
                        dist_name[distance],
                        dir_desc[dir] );
                buf[0] = UPPER(buf[0]);
                send_to_char( buf, ch);
            }
   }
                ch->in_room = world[ch->in_room].dir_option[dir]->to_room;
      }
  }

  ch->in_room = was_in_room;
  if( !found )
    {
      sprintf( buf, "You don't notice anyone %s.\n\r",
              dir_desc[dir] );
      send_to_char( buf, ch );
    }

  return;
}



This archive was generated by hypermail 2b30 : 12/07/00 PST