[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Timer - re-run

Timer - re-run

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


Pages: 1  2 

Posted by Gohan_TheDragonball   USA  (183 posts)  [Biography] bio
Date Reply #15 on Wed 10 Aug 2005 03:56 AM (UTC)
Message

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.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #16 on Wed 10 Aug 2005 07:09 AM (UTC)
Message
As I said in the other post (http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5779) what you suggest will not work in a version of SMAUG that behaves as does the code I posted. Just mentioning this as a disclaimer to people who have trouble with this code.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] 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.


38,784 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]