Changing skills to commands

Posted by Toy on Sun 19 May 2002 04:41 PM — 10 posts, 35,939 views.

#0
Could someone help me? I'm trying to figure out how to change skills into commands, such as Scan and Search. I'd like for my players to be able to use the abilities without having to practice/train them.
-Alexander
USA #1
I never actually saw how these skills work, but probably you would want to add something like void do_search, then in it make when a player types to search it does the same thing the skill would have done, then in tables.c add the appropriate entries for do_search.

-Jay
Australia Forum Administrator #2
Or, simply take the skills in question and give the player full ability to use it without having to train first.
#3
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;
}
This is the "search" skill. What would I have to change in it give the player full ability to use it without trains? I know, you're saying to yourself "This guy has no idea what's he's doing." Well, you're right. I just need someone to point me in the right direction. :)
-Alexander
#4
Ok, you might be able to get off bu using these commands in the game itself
cedit <skill> create
cedit savecmdtable
and somethign sset to delete the skill, you'd ahve to ask nick about that one.. heh heh heh... that should fix it all up.
Australia Forum Administrator #5
It is not a case of fixing do_search, you need to make the skill learnt. I suggest taking this code from comm.c, which teaches each new player the "common" language, and adapt it to the skills in question.


        if ( (iLang = skill_lookup( "common" )) < 0 )
            bug( "Nanny: cannot find common language." );
        else
            ch->pcdata->learned[iLang] = 100;


Replace "common" with your skill and you should have it. If you put it in the nanny routine each new player will get the skill, and you can always "sset" existing players.
#6
Well, I added the skills to nanny like such:
if ( (iLang = skill_lookup( "scan" )) < 0 )
bug( "Nanny: cannot find scan." );
else
ch->pcdata->learned[iLang] = 100
worked like a charm, with the exception that everytime I boot the mud, it gives me bug messages. But I can live with that. thanks for the help Nick.
-Alexander
USA #7
Can't he just edit commands.dat to have a search command for level 0? Although he would have to modify the timer part since that factors in skill level.

-Jay
#8
OK... so it didn't work like I thought it would. New players that log on have the effect from Nanny, but if they save and quit, and reconnect, they lose all use of the skill. Any ideas?

Alexander the Frustrated.
Australia Forum Administrator #9
Sounds like it isn't saving for some reason. Don't know why.