ok i made this code in order for people to get there percentage of a skill up a little faster than what the stock code does. What this code does is allows a player to "research" a skill at a library. I had the code working great before i put a timer on it and made it to a skill. if you could please show me what i did wrong with the timer.
void do_research( CHAR_DATA *ch, char *argument )
{
int sn;
int adept = 75;
char arg[MAX_INPUT_LENGTH];
int chance;
strcpy( arg, argument );
switch( ch->substate )
{
default:
if ( IS_NPC(ch) )
return;
if ( argument[0] == '\0' )
{
send_to_char("&RWhat skill would you like to research?\n\r", ch);
return;
}
{
bool can_prac = TRUE;
if ( !IS_AWAKE(ch) )
{
send_to_char( "In your dreams, or what?\n\r", ch );
return;
}
if(!(xIS_SET(ch->in_room->room_flags, ROOM_LIBRARY)))
{
send_to_char( "You need to be in a library to research skills.\n\r", ch );
return;
}
sn = skill_lookup( argument );
if ( sn == -1 )
{
send_to_char("&RYou can't seem to find that skill in any books.\n\r", ch);
return;
}
if ( skill_table[sn]->guild < 0 || skill_table[sn]->guild >= MAX_ABILITY )
{
send_to_char("&RYou cannot learn that skill.\n\r", ch);
return;
}
if ( can_prac && !IS_NPC(ch)
&& ch->skill_level[skill_table[sn]->guild] < skill_table[sn]->min_level )
{
send_to_char("&RYour not ready to research that yet.\n\r", ch);
return;
}
if ( is_name( skill_tname[skill_table[sn]->type], CANT_PRAC ) )
{
send_to_char ("&RYou can't find that in any books.\n\r'", ch);
return;
}
chance = IS_NPC(ch) ? ch->top_level
: (int) (ch->pcdata->learned[gsn_research]);
if ( number_percent( ) < chance )
{
ch->dest_buf = str_dup(arg);
send_to_char( "&GYou you begin the long proccess of researching a skill.\n\r", ch );
add_timer ( ch , TIMER_DO_FUN , 0 , do_research , 1 );
return;
}
send_to_char("&RYou're not quite sure how to do it...\n\r",ch);
learn_from_failure( ch, gsn_research );
return;
case 1:
if ( !ch->dest_buf )
return;
strcpy(arg, ch->dest_buf);
DISPOSE( ch->dest_buf);
break; /*EVERYTHING WORKED RIGHT UP TO THIS POINT THEN THE CODE STOPPED*/
case SUB_TIMER_DO_ABORT:
ch->substate = SUB_NONE;
send_to_char("&RYou fail to complete your research.\n\r", ch);
return;
}
ch->substate = SUB_NONE;
if ( number_percent( ) > chance )
{
send_to_char( "&RAfter much study you fail to learn anything about your skill.\n\r", ch);
learn_from_failure( ch, gsn_research );
return;
}
if ( number_percent( ) < chance )
{
if ( ch->pcdata->learned[sn] >= adept )
{
send_to_char("You've learned everything you can from the books,\n\r", ch);
send_to_char("you must practice it on your own now.\n\r", ch);
}
else
{
ch->pcdata->learned[sn] += 5;
act( AT_ACTION, "You gain some knowledge in the skill of $T.",
ch, NULL, skill_table[sn]->name, TO_CHAR );
}
}
}
return;
}
|