The Dink Network

Command crashes Dink

December 24th 2004, 09:52 AM
spike.gif
void main( void )
{
sp_seq(&current_sprite, 449);
sp_sound(&current_sprite, 34);
sp_brain(&current_sprite, 6);
sp_hitpoints(&current_sprite, 0);
}
void hit( void )
{
&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
if (sp_brain(&current_sprite, -1) == 6)
{
playsound(50, 22050, 0, 0, 0);
sound_set_kill(34);
sp_brain(&current_sprite, 0);
return;
}
//rest of the script

The sound_set_kill(); command crashes the game. Why is that? I've never tried that command before, am I doing it wrong??

BTW, is there a way to make the savebot instantly stop on the frame it's on when Dink hits it? I can't think of anything better than disabling the sprite and pasting the pic on it...
December 24th 2004, 10:12 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
sound_set_kill() uses a sound's number as input. This number is the value of &sound in:

&sound = playsound(whatever);

Just like you use &sprite = create_sprite(whatever);

My guess is that it crashes because there aren't 34 sounds playing.

A way to stop the animation of the savebot would be:

void hit( void )
{
&crap = sp_pframe(&current_sprite, -1);
sp_brain(&current_sprite, 0);
sp_pframe(&current_sprite, &crap);
}

This basically stops the animation and gives the sprite the last frame. You have to place an "int &crap" in the main proc.
December 24th 2004, 10:23 AM
spike.gif
So, basically, I can't kill a sound that's attached to a sprite without killing the sprite?? And sp_pframe(); won't stop the animation...
December 24th 2004, 12:10 PM
spike.gif
Heh, sp_sound(&current_sprite, 0); seems to that... I feel myself a little stupid now. Something I find weird though, is that the following crashes Dink as well:

sp_disabled(&current_sprite, 1);
sp_brain(&current_sprite, 0);
int &pic = sp_pframe(&current_sprite, -1);
int &replica = create_sprite(&save_x, &save_y, 0, 449, &pic);

It doesn't matter though, it's better that the machine goes off when you hit it than stop at the last frame, it's just weird..
December 24th 2004, 01:10 PM
goblinm.gif
pframe is zero, unless you set it AFAIK. Have you tried sp_frame instead?
December 25th 2004, 06:24 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Try the sp_picfreeze() command, use 1 to free the frame and 0 to unfreeze it.
December 27th 2004, 02:00 PM
wizardg.gif
Paul
Peasant He/Him United States
 
I would have thought you'd simply use sp_sound(&current_sprite, 0); or does that not work?