22 Nov, 2008, yzor wrote in the 1st comment:
Votes: 0
i added this double snippet http://www.mudbytes.net/pastebin-11186 and am trying to get it use its own pulse beat in stead of tick. in my update.c i added to void update_handler ** if ( –pulse_bonuses <= 0)
{
pulse_bonuses = PULSE_BONUSES;
update_bonuses ( );
}

i added pulse bonus to merc.h and set each pulse to be one min, but for some reason it still runs of of pulse_tick. its bad when you start double and its just before the tick and when the tick happens it drops it 1 min no matter how long its been running for.
22 Nov, 2008, Davion wrote in the 2nd comment:
Votes: 0
Show us the entire update_handler() function. Sounds like you've done everything correctly, just need to make sure.

Also include your definition for PULSE_BONUSES from merc.h
22 Nov, 2008, yzor wrote in the 3rd comment:
Votes: 0
just so you know i'm not a coder, i'm reading books and trying the easy stuff right now. this mud was originally my brothers who died from cancer last year and his daughter was trying to get it going in his name, now shes fighting the same thing so i'm trying to get it going for her. then i will keep it going for as long as i can in there name.
but here's the update_handler
void update_handler( void )
{
static int pulse_area;
static int pulse_mobile;
static int pulse_violence;
static int pulse_point;
static int pulse_music;
static int pulse_auction;
static int pulse_hint;
static int pulse_bonuses;

if ( –pulse_area <= 0 )
{
pulse_area = PULSE_AREA;
/* number_range( PULSE_AREA / 2, 3 * PULSE_AREA / 2 ); */
area_update ( );
}

if ( –pulse_music <= 0 )
{
pulse_music = PULSE_MUSIC;
song_update();
}

if (–pulse_auction <= 0)
{
pulse_auction = PULSE_AUCTION;
auction_update ();
}

if ( –pulse_mobile <= 0 )
{
pulse_mobile = PULSE_MOBILE;
mobile_update ( );
}

if ( –pulse_violence <= 0 )
{
pulse_violence = PULSE_VIOLENCE;
violence_update ( );
}

if ( –pulse_hint <= 0)
{
pulse_hint = PULSE_HINT;
hint_update ( );
}

if ( –pulse_bonuses <= 0)
{
pulse_bonuses = PULSE_BONUSES;
update_bonuses ( );
}

if ( –pulse_point <= 0 )
{
wiznet("{W-{B*{W->{BTICK!{W<-{B*{W-{x",NULL,NULL,WIZ_TICKS,0,0);
pulse_point = PULSE_TICK;
/* number_range( PULSE_TICK / 2, 3 * PULSE_TICK / 2 ); */
weather_update ( );
char_update ( );
obj_update ( );
quest_update ( );
gquest_update ( );
war_update ( );
// update_bonuses ( );
}

aggr_update( );
tail_chain( );
return;
}

here is what's in merc.h
#define PULSE_BONUSES (60 * PULSE_PER_SECOND)

hope this helps and thanks for the help
22 Nov, 2008, Davion wrote in the 4th comment:
Votes: 0
It's not running based off ticks, it's running in parallel. PULSE_TICK and PULSE_BONUSES are both triggered every 60 seconds. So technically you've done everything correctly, just, you've set the pulses for the bonuses to be exactly the same as ticks. Simply change your PULSE_BONUSES to something other than 60 seconds for it to run out of sync with ticks.
22 Nov, 2008, yzor wrote in the 5th comment:
Votes: 0
what i'm trying to get it to do is when you start double it will count down from when it started, hence start double for 10 mins, 1 min later it will be 9 mins here is my code for update_bonus.

void update_bonuses()
{
if ( global_exp– >= -1 )
{
display++;

if ( display >= 5 && global_exp > 0 )
{
info( NULL, 0, "{R[INFO]:{x {BThere are %d minutes of double exp left.{x\n\r", global_exp );
display = 0;
return;
}

if (global_exp == 0)
{
info( NULL, 0, "{R[INFO]:{x {BDouble exp has run out!{x\n\r" );
double_exp = FALSE;
return;
}
}

if ( global_qp– >= 0 )
{
qpdisplay++;

if ( qpdisplay >= 5 && global_qp > 0 )
{
info( NULL, 0, "{R[INFO]:{x {BThere are %d minutes of double questpoints left.{x\n\r", global_qp );
qpdisplay = 0;
return;
}

if ( global_qp == 0 )
{
info( NULL, 0, "{R[INFO]:{x {BDouble questpoints has run out!{x\n\r" );
double_qp = FALSE;
return;
}

}

}

if everything is right i'll go back in game and double check it to see if it is running right.
23 Nov, 2008, Davion wrote in the 6th comment:
Votes: 0
That's not necessarily the problem. Every time update_bonuses is called, global_exp and global_qp decrease by 1. So, say you use your do_double to set global_exp to, say 10. It'll then exist for 10 calls to update_bonuses. If you want it on a per-second basis, you'd want to call update_bonuses every second, and then set your time by seconds (or modify do_double to accept the argument as minutes, and convert it to seconds.) The easiest way would simply be changing PULSE_BONUSES to PULSE_PER_SECOND, then moving from there. Then to set it to 10 minutes, you'd do "double exp 600" which would set it for 600 calls to update_bonuses, and calling it every second would end it at 10 minutes.
23 Nov, 2008, ghasatta wrote in the 7th comment:
Votes: 0
Hi,

I think I understand what you are trying to do. The code you posted as update_handler() is continually cycling through and calling update_bonus() every so often (determined by whatever PULSE_BONUSES is defined as). In fact, the update_bonus() function is even called when double exp is not turned on. So, when you use the do_double() command to turn the double exp on, the update_handler() doesn't do anything different, it just keeps calling update_bonus() on its regular cycle. The problem is that the update_bonus() function counts down the double exp time assuming that when it is called and double exp is on, a full minute has passed. In reality, it could be anywhere in the range of 1-60 seconds.

There are two ways to address this:
1. Make the pulse_bonuses variable in update_handler() be a global variable and reset it when you use the do_double() command.
or:
2. Change handle the counting in update_bonuses() and call it every cycle in update_handler().

If you don't feel up to doing this yourself I will be happy to help you with it.
0.0/7