Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Scan command w/ no direction
|
Scan command w/ no direction
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Idimmu
USA (3 posts) Bio
|
| Date
| Tue 24 Jan 2006 09:50 PM (UTC) |
| Message
| 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. | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Tue 24 Jan 2006 09:52 PM (UTC) |
| Message
| | 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. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Dralnu
USA (277 posts) Bio
|
| Date
| Reply #2 on Tue 24 Jan 2006 09:54 PM (UTC) |
| Message
| | 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. | | Top |
|
| Posted by
| Idimmu
USA (3 posts) Bio
|
| Date
| Reply #3 on Tue 24 Jan 2006 10:00 PM (UTC) |
| Message
| 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! | | Top |
|
| Posted by
| Zeno
USA (2,871 posts) Bio
|
| Date
| Reply #4 on Tue 24 Jan 2006 10:13 PM (UTC) |
| Message
| | Look over do_exits to see how to do an exit loop works. Follow some examples, and it shouldn't be too hard. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Wed 25 Jan 2006 01:07 AM (UTC) |
| Message
|
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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Idimmu
USA (3 posts) Bio
|
| Date
| Reply #6 on Thu 26 Jan 2006 03:46 AM (UTC) |
| Message
| 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 );
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #7 on Thu 26 Jan 2006 05:41 AM (UTC) |
| Message
| 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. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | 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.
28,704 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top