[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Need help getting SCAN to work right
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Need help getting SCAN to work right

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Toy   (206 posts)  [Biography] bio
Date Fri 06 Feb 2004 10:54 PM (UTC)  quote  ]

Amended on Sat 07 Feb 2004 08:18 PM (UTC) by Nick Gammon

Message

void do_scan( CHAR_DATA *ch, char *argument )
{
    ROOM_INDEX_DATA *was_in_room;
    EXIT_DATA *pexit;
    sh_int dir = -1;
    sh_int dist;
    sh_int max_dist = 8;

    set_char_color( AT_ACTION, ch );

    if ( IS_AFFECTED( ch, AFF_BLIND ) )
    {
  send_to_char( "Not very effective when you're blind...\n\r", ch );
  return;
    }
 
//    if ( argument[0] == '\0' )
//    {
//  send_to_char( "Scan in a direction...\n\r", ch );
//  return;
//    }

//    if ( ( dir = get_door( argument ) ) == -1 )
//    {
//  send_to_char( "Scan in WHAT direction?\n\r", ch );
//  return;
//    }

    was_in_room = ch->in_room;
    act( AT_GREY, "Scanning $t...", ch, dir_name[dir], NULL, TO_CHAR );
    act( AT_GREY, "$n scans $t.", ch, dir_name[dir], NULL, TO_ROOM );

    if ( IS_VAMPIRE( ch ) )
    {
  if ( time_info.hour < 21 && time_info.hour > 5 )
  {
      send_to_char( "You have trouble seeing clearly through all the "
    "light.\n\r", ch );
      max_dist = 1;
  }
    }

    if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
    {
  act( AT_GREY, "You can't see $t.", ch, dir_name[dir], NULL, TO_CHAR );
  return;
    }

    if ( ch->level < 50 ) --max_dist;
    if ( ch->level < 40 ) --max_dist;
    if ( ch->level < 30 ) --max_dist;

    for ( dist = 1; dist <= max_dist; )
    {
  if ( IS_SET(pexit->exit_info, EX_CLOSED) )
  {
      if ( IS_SET(pexit->exit_info, EX_SECRET)
      ||   IS_SET(pexit->exit_info, EX_DIG) )
    act( AT_GREY, "Your view $t is blocked by a wall.", ch,
        dir_name[dir], NULL, TO_CHAR );
      else
    act( AT_GREY, "Your view $t is blocked by a door.", ch, 
        dir_name[dir], NULL, TO_CHAR );
      break;
  }
  if ( room_is_private( pexit->to_room )
  &&   ch->level < LEVEL_BUILDER )
  {
      act( AT_GREY, "Your view $t is blocked by a private room.", ch, 
    dir_name[dir], NULL, TO_CHAR );
      break;
  }
  char_from_room( ch );
  char_to_room( ch, pexit->to_room );    
  set_char_color( AT_RMNAME, ch );
  send_to_char( ch->in_room->name, ch );
  send_to_char( "\n\r", ch );
  show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE );
  show_char_to_char( ch->in_room->first_person, ch );

  switch( ch->in_room->sector_type )
  {
      default: dist++; break;
      case SECT_AIR:
    if ( number_percent() < 80 ) dist++; break;
      case SECT_INSIDE:
      case SECT_FIELD:
      case SECT_UNDERGROUND:
    dist++; break;
      case SECT_FOREST:
      case SECT_CITY:
      case SECT_DESERT:
      case SECT_HILLS:
    dist += 2; break;
      case SECT_WATER_SWIM:
      case SECT_WATER_NOSWIM:
    dist += 3; break;
      case SECT_MOUNTAIN:
      case SECT_UNDERWATER:
      case SECT_OCEANFLOOR:
    dist += 4; break;
  }

  if ( dist >= max_dist )
  {
      act( AT_GREY, "Your vision blurs with distance and you see no "
    "farther $t.", ch, dir_name[dir], NULL, TO_CHAR );
      break;
  }
  if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
  {
      act( AT_GREY, "Your view $t is blocked by a wall.", ch, 
    dir_name[dir], NULL, TO_CHAR );
      break;
  }
    }
  
    char_from_room( ch );
    char_to_room( ch, was_in_room );

    return;
}

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #1 on Fri 06 Feb 2004 10:56 PM (UTC)  quote  ]
Message
Much like Search, I'm attempting to make scan into a command, not a skill. I've got it changed around, removed the gsn_ parts, now I'm attepting to make scan need to arguement. I removed the first one, then it called to the second one. I removed the second, and it caused a segment core drop.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #2 on Fri 06 Feb 2004 11:01 PM (UTC)  quote  ]
Message
Well, I see the problem. First, if you can make sure that when you post code you check the forum codes box, it makes reading the post much easier.

As for the code part, you've made it not use an argument... How do you know what direction to scan in? This bit of code here:
// if ( ( dir = get_door( argument ) ) == -1 )
// {
// send_to_char( "Scan in WHAT direction?\n\r", ch );
// return;
// }

is the part that assigns what direction your trying to scan. Since you've commented it out, the variable dir has no valid number, and that will cause your crash. You'll need to figure out how to get a direction with no argument, which I don't think you can do.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Toy   (206 posts)  [Biography] bio
Date Reply #3 on Fri 06 Feb 2004 11:08 PM (UTC)  quote  ]
Message
Sorry about the code codes.. thought I was following it right. ;p

Ah, so it's not really possible to set scan to not have an arguement huh? Ah well. Not a major issue, just had seen it work without an arguement before on another game I'd played. No biggie, just being experimentive. :)

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio   Moderator
Date Reply #4 on Sat 07 Feb 2004 08:51 AM (UTC)  quote  ]
Message
It is possible to set scan without any arguments, but he was saying that you have to learn how. In order to have scan work without arguments, you'd most likely have to redo the whole code, if not most of it.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #5 on Sat 07 Feb 2004 10:04 AM (UTC)  quote  ]
Message
Yeah, I meant that since your not entering a direction, it doesn't know where to look. You could make it look in the opposite direction from where you came from(aka, forward). You could make it look in a random direction, or... I dunno, my point wasn't that it can't be done, but that you have to decide how to do it.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Meerclar   USA  (569 posts)  [Biography] bio
Date Reply #6 on Sat 07 Feb 2004 11:08 AM (UTC)  quote  ]
Message
You might try looking at the circle and dawn codeabses since they both have scan available without arguments. It's unlikely you can just drop their code directly into smaug but it might help you figure out where you've missed something.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,080 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]