The Dink Network

Problems with multiple hits

July 21st 2008, 11:07 AM
dinkdead.gif
The animation (and noise etc) plays every time if I keep hitting this sprite, how can I make it play just once? It does disappear from sight though.
If I hit it then wait for a bit it disappears properly and is unhittable, presumably after the wait(600).

It makes no difference if I put the nohit first with a wait(1) afterwards. How can I fix this?

void hit (void)
{
playsound(61, 44100, 0, &current_sprite, 0);
&chickpanic = 1;
sp_nodraw(&current_sprite, 1);
sp_nohit(&current_sprite, 1);
freeze(&current_sprite);
&x = sp_x(&current_sprite, -1);
&y = sp_y(&current_sprite, -1);
&y -= 5;
&temp = create_sprite(&x, &y, 7, 945, 1);
sp_seq(&temp, 945);

wait(600);
&chickpanic = 0;
sp_active(&current_sprite, 0);
kill_this_task();
}
July 21st 2008, 11:50 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Posted an empty post by accident, Tal?
July 21st 2008, 11:58 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Sprite's hit procedure is run even if it's nohit is set to 1. Try this:

void hit (void)
{
if (&chickpanic == 1)
return;

&chickpanic = 1;
playsound(61, 44100, 0, &current_sprite, 0);
sp_nodraw(&current_sprite, 1);
sp_nohit(&current_sprite, 1);
freeze(&current_sprite);
&x = sp_x(&current_sprite, -1);
&y = sp_y(&current_sprite, -1);
&y -= 5;
&temp = create_sprite(&x, &y, 7, 945, 1);
sp_seq(&temp, 945);

wait(600);
&chickpanic = 0;
sp_active(&current_sprite, 0);
kill_this_task();
}

So the hit proc is simply skipped if &chickpanic is set to 1. Was this what you wanted?
July 21st 2008, 12:04 PM
duck.gif
Tal
Noble He/Him United States
Super Sexy Tal Pal 
Your post was so close to being deleted, too...

July 21st 2008, 12:16 PM
dinkdead.gif
That's great, thanks. Forgot about that.
It still plays the hit sound more than once though...? The normal hit sound, not the playsound one.
July 21st 2008, 12:50 PM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Hmm. Try moving the sp_nohit before the if-statement. BTW, you don't need to use kill_this_task as the sprite and it's script is killed automatically by setting sp_active to 0.
July 21st 2008, 01:02 PM
dinkdead.gif
"Try moving the sp_nohit before the if-statement."

I did, that's what's odd.

Sometimes kill_this_task is needed there as the script isn't killed until it gets to the next wait(), so I put it in just in case while I was writing the rest. Now there's no need for it so I probably will take it out
July 21st 2008, 01:13 PM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Hmm! Try sp_nohit(&temp, 1); after the &temp sprite has been created.
July 21st 2008, 01:41 PM
dinkdead.gif


That's it!