Register forum user name Search FAQ

Gammon Forum

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 ➜ Need a little help getting SEARCH to work right

Need a little help getting SEARCH to work right

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Toy   (206 posts)  Bio
Date Fri 06 Feb 2004 10:20 PM (UTC)
Message
[code]
void do_search( CHAR_DATA *ch, char *argument )
{
char arg [MAX_INPUT_LENGTH];
OBJ_DATA *obj;
OBJ_DATA *container;
OBJ_DATA *startobj;
int percent, door;

door = -1;
switch( ch->substate )
{
default:
if ( IS_NPC(ch) && IS_AFFECTED( ch, AFF_CHARM ) )
{
send_to_char( "You can't concentrate enough for that.\n\r", ch );
return;
}
if ( ch->mount )
{
send_to_char( "You can't do that while mounted.\n\r", ch );
return;
}
argument = one_argument( argument, arg );
if ( arg[0] != '\0' && (door = get_door( arg )) == -1 )
{
container = get_obj_here( ch, arg );
if ( !container )
{
send_to_char( "You can't find that here.\n\r", ch );
return;
}
if ( container->item_type != ITEM_CONTAINER )
{
send_to_char( "You can't search in that!\n\r", ch );
return;
}
if ( IS_SET(container->value[1], CONT_CLOSED) )
{
send_to_char( "It is closed.\n\r", ch );
return;
}
}
// add_timer( ch, TIMER_DO_FUN, UMIN(skill_table[gsn_search]->beats / 10, 3),
// do_search, 1 );
send_to_char( "You begin your search...\n\r", ch );
ch->alloc_ptr = str_dup( arg );
return;

case 1:
if ( !ch->alloc_ptr )
{
send_to_char( "Your search was interrupted!\n\r", ch );
bug( "do_search: alloc_ptr NULL", 0 );
return;
}
strcpy( arg, ch->alloc_ptr );
DISPOSE( ch->alloc_ptr );
break;
case SUB_TIMER_DO_ABORT:
DISPOSE( ch->alloc_ptr );
ch->substate = SUB_NONE;
send_to_char( "You stop your search...\n\r", ch );
return;
}
ch->substate = SUB_NONE;
if ( arg[0] == '\0' )
startobj = ch->in_room->first_content;
else
{
if ( (door = get_door( arg )) != -1 )
startobj = NULL;
else
{
container = get_obj_here( ch, arg );
if ( !container )
{
send_to_char( "You can't find that here.\n\r", ch );
return;
}
startobj = container->first_content;
}
}

if ( (!startobj && door == -1) || IS_NPC(ch) )
{
send_to_char( "You find nothing.\n\r", ch );
// learn_from_failure( ch, gsn_search );
return;
}

percent = number_percent( ) + number_percent( ) - ( ch->level / 10 );

if ( door != -1 )
{
EXIT_DATA *pexit;

if ( (pexit = get_exit( ch->in_room, door )) != NULL
&& IS_SET( pexit->exit_info, EX_SECRET )
&& IS_SET( pexit->exit_info, EX_xSEARCHABLE ) )
// && can_use_skill( ch, percent, gsn_search ) )
{
act( AT_SKILL, "Your search reveals the $d!", ch, NULL, pexit->keyword, TO_CHAR );
act( AT_SKILL, "$n finds the $d!", ch, NULL, pexit->keyword, TO_ROOM );
REMOVE_BIT( pexit->exit_info, EX_SECRET );
// learn_from_success( ch, gsn_search );
return;
}
}
else
for ( obj = startobj; obj; obj = obj->next_content )
{
if ( IS_OBJ_STAT( obj, ITEM_HIDDEN ) )
// && can_use_skill(ch, percent, gsn_search ) )
{
separate_obj(obj);
xREMOVE_BIT( obj->extra_flags, ITEM_HIDDEN );
act( AT_SKILL, "Your search reveals $p!", ch, obj, NULL, TO_CHAR );
act( AT_SKILL, "$n finds $p!", ch, obj, NULL, TO_ROOM );
// learn_from_success( ch, gsn_search );
return;
}
}

send_to_char( "You find nothing.\n\r", ch );
// learn_from_failure( ch, gsn_search );
return;
}
[/code]

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

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Fri 06 Feb 2004 10:22 PM (UTC)
Message
Uhhhh, whats the problem? A bunch of code makes it hard to know where to look. Is it crashing? Is it always failing? Perhaps your getting a bug message?

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Toy   (206 posts)  Bio
Date Reply #2 on Fri 06 Feb 2004 10:23 PM (UTC)
Message
OK, what I'm trying to do is alter the code so instead of players needing to practice search over and over, it just because a normal command. I made the changes above, recompiled clean, and started the mud up. Here's the thing: the command now works... it just doesn't finish the search. You see this:

You begin your search...

But then it looks like it just totally aborts the search. Can someone gimme some help on what I'm doing wrong?

-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
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #3 on Fri 06 Feb 2004 10:29 PM (UTC)
Message
Yeah, I think I see the problem.
send_to_char( "You begin your search...\n\r", ch );
ch->alloc_ptr = str_dup( arg );
return;


This return will just end it. What would normally happen is it would return after the timer was added, but since you commented it out, it won't do anything, it will just end. You options are put the timer back, but make it use, perhaps, 5 as the beats value to pass, or to add a wait_state, and have it work instantly, but they be delayed.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Toy   (206 posts)  Bio
Date Reply #4 on Fri 06 Feb 2004 10:35 PM (UTC)
Message
OK... need help with those options. I see that the time calls to the skill_table for the previous skill search. HOw can I change that so it won't, or how do I make a wait_state? Never done that before.

-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
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #5 on Fri 06 Feb 2004 10:39 PM (UTC)

Amended on Fri 06 Feb 2004 10:40 PM (UTC) by Greven

Message
Well, if you uncomment the add_timer function, you can do something simple like this:

 add_timer( ch, TIMER_DO_FUN, 4 , do_search, 1 );


That should work.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Toy   (206 posts)  Bio
Date Reply #6 on Fri 06 Feb 2004 10:47 PM (UTC)
Message
Ah... there we go. Cool. Thanks. Now I'm gonna attempt to tackle do_scan. See if I can get my last issue with that one fixed so an arguement isn't needed when using scan. Tried to remove the arguement calls and segment faulted. ;p

-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
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.


20,626 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.