The Dink Network

get_sprite_with_this_brain

September 22nd 2007, 05:38 PM
dinkdead.gif
I create 11 sprites and kill them using hurt(); in a seperate script (not attached to them).
Then when I do this:
int &alldead = get_sprite_with_this_brain(9, 0);
if (&alldead == 0)
{
say_xy("`3test", 0, 200);
}

nothing happens, even though all sprites did die (at least they look dead, lots of blood and not moving ).
I checked in debug mode and when it gets to the if statement it counts 11 sprites still... so what's wrong? Do I need to set the brains to 0 myself? I thought that happened anyway when it died, at least I can't find any references to it in a normal enemy script.
September 22nd 2007, 06:19 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I tested that and it works ok. I've even tested it after killing off created brain 9 enemies using a hurt command.. I can't tell you whats wrong
September 23rd 2007, 09:09 PM
spike.gif
Where is int &alldead = get_sprite_with_this_brain(9, 0); located? It needs to run after the enemies are dead, or the if check will give an old value.
September 24th 2007, 11:44 AM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
Put a wait(100) before your lines.
September 25th 2007, 10:12 PM
dinkdead.gif
I managed to get it working, it was in a loop but before the wait(); so I suppose was still counting the recently killed sprites. I did notice in debug.txt that it still counts 11 brains until all are dead, even if there are really only 2 or 3 on the screen. Odd.
Thanks all!