Scan command w/ no direction

Posted by Idimmu on Tue 24 Jan 2006 09:50 PM — 8 posts, 30,748 views.

USA #0
Ok, I know it's been posted before, but I really want the scan skill to be a command and scan only adjacent rooms.
The output would be something like this:

Scanning you see:
<mobname> to the north.
<mobname> to the southwest.
<mobname> to the southwest.
<mobname> to the south.

If anyone has done this, please let me know. We can even leave the scan skill there if they'd like to scan in a particular direction for a distance.

Hopefully someone can help me.
USA #1
This shouldn't be terribly hard. Just loop over the exits in the room, and run the normal scan skill on each of those directions. Might want to make sure that you don't scan hidden or otherwise secret exits, though.
USA #2
Look at how scan works, and since it ask for an agrument, where it returns because of a lack of an argument, change it to read the exits and all that like the rest, but instead of just using 1 direction, have it check each direction, and if there is something there, return the name and direction. Thats just what I think, so, yeah.
USA #3
I suppose I should have said that I wasn't a programmer. I work with PHP/MySQL...different ball game.

In looking at the code, I guess I'm lost. Sorry to be a pain, and thank you for being so damn quick at responses!
USA #4
Look over do_exits to see how to do an exit loop works. Follow some examples, and it shouldn't be too hard.
Australia Forum Administrator #5
Quote:

I should have said that I wasn't a programmer. I work with PHP ...


PHP and C are really quite similar. If you are using PHP you are a programmer.
USA #6
Ok, I understand where the command starts, and I understand where the argument returns without an argument, but I'm not understanding what exactly I'm looping.
I would assume it's the dir, which is 1, and i want it to loop until 8?
I thank Nick for the vote of confidence, but I'm obviously not as good as picking up on things as I thought I would be.
Dralnu hit exactly what I was looking for.



void do_scan( CHAR_DATA * ch, char *argument )
{
   ROOM_INDEX_DATA *was_in_room;
   EXIT_DATA *pexit;
   short dir = 1;
   short dist;
   short 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 looks around furiously.", ch, dir_name[dir], NULL, TO_ROOM );
USA #7
Look at the code for do_exits, as Zeno suggested. That shows how to loop over the visible exits in a room.

Then, once you have each exit name, you can loop (inside do_scan) calling do_scan on that exit name. Basically, do_scan with no arguments will call do_scan with arguments as many times as there are visible exits in the room.

And Nick is entirely correct, PHP is quite legitimate programming.