I'm kinda new with timers and aint had much experience with them, but i was just wondering if there is a way of making a timer RE-RUN once its completed it for the first time.
Reason i ask is because im doing a do_trance command which is slightly different than the other one thats on here, i want it so the player types trance, and it will allow the player to trance until it reachs its max_mana.
Here is what i have so far:-
void do_trance( CHAR_DATA *ch, char *argument )
{
int percent;
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 concentrate, whiles being mounted.\n\r", ch );
return;
}
act( AT_ACTION, "You enter a peaceful trance, collecting mana as you rest.", ch, NULL, NULL, TO_CHAR );
ch->position = POS_TRANCE;
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
return;
case 1:
if (ch->position != POS_TRANCE)
{
send_to_char("Something went wrong...\n\r", ch);
return;
}
case SUB_TIMER_DO_ABORT:
if (ch->mana >= ch->max_mana)
{
send_to_char("You complete your trance.\n\r", ch);
return;
}
if (ch->mana < ch->max_mana)
percent = number_percent( ) + number_percent( ) - ( ch->level / 10 );
if (can_use_skill( ch, number_percent(), gsn_trance ) )
{
send_to_char("You fail to gain any mana.\n\r", ch);
learn_from_failure( ch, gsn_trance );
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
return;
}else{
send_to_char("You gain some mana from your trance.\n\r", ch);
if (ch->mana < (ch->max_mana - 50))
{
ch->mana = (ch->mana + 50);
}else{
ch->mana = ch->max_mana;
}
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
learn_from_success( ch, gsn_trance );
return;
}
}
}
Thanks,
Samryn |