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_MAGIC, "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->mana >= ch->max_mana)
{
send_to_char_color("&BYou complete your trance.\n\r", ch);
ch->position = POS_STANDING;
return;
}
if (ch->mana < ch->max_mana)
{
percent = number_percent( ) + number_percent( ) - ( ch->level / 10 );
if (can_use_skill( ch, percent, gsn_trance ) )
{
send_to_char_color("&BYou fail to gain any mana.\n\r", ch);
learn_from_failure( ch, gsn_trance );
ch->position = POS_STANDING;
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
return;
}else{
send_to_char_color("&BYou 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;
}
learn_from_success( ch, gsn_trance );
ch->position = POS_STANDING;
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 2 );
return;
}
}
case 2:
if (ch->mana >= ch->max_mana)
{
send_to_char_color("&BYou complete your trance.\n\r", ch);
ch->position = POS_STANDING;
return;
}
if (ch->mana < ch->max_mana)
{
percent = number_percent( ) + number_percent( ) - ( ch->level / 10 );
if (can_use_skill( ch, percent, gsn_trance ) )
{
send_to_char_color("&BYou fail to gain any mana.\n\r", ch);
learn_from_failure( ch, gsn_trance );
ch->position = POS_STANDING;
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
return;
}else{
send_to_char_color("&BYou 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;
}
learn_from_success( ch, gsn_trance );
ch->position = POS_STANDING;
add_timer( ch, TIMER_DO_FUN, 3, do_trance, 1 );
return;
}
}
case SUB_TIMER_DO_ABORT:
if (ch->position != POS_TRANCE)
{
send_to_char("Something went wrong...\n\r", ch);
bug("do_trance: Character didn't go in POS_TRANCE -report to samryn",0);
return;
}
}
}
i had replied like this on another post, but this is how smaug timers are dealt with. You must toggle between the 2 substates. in case 1: you do add_timer(....., 2) in case 2: you do add_timer(....., 1);
this will loop it how you want it as well, i did the change that was posted, the removing of extract_timer, and my codebase uses a lot of these types of timers, and i had a few of them mess up considerably. |