Brain stuff
How do I use that get_sprite_with_this_brain properly. I've got this script attached to a sprite, and I do a script_attach(1000); and sp_active(¤t_sprite, 0); but when I do that if...get_sprite... = 0... it doesn't work. As in, the script doesn't continue.
The problem is likely that you've killed the sprite with sp_active(¤t_sprite, 0), and therefore, there is no sprite to be found with get_sprite_with_this_brain(). The script exists, but it's attached now to sprite 1000, which is fake.
Okay, let me change the question:
I've got a sprite, it talks to Dink, Dink fights some other guys, while the sprite stays hidden on the screen. But, how do I tell when all the enemies are dead so I can continue with the script.
I've got a sprite, it talks to Dink, Dink fights some other guys, while the sprite stays hidden on the screen. But, how do I tell when all the enemies are dead so I can continue with the script.
Propably simplest to do a loop, or add a braincheck in each monster's die() procedure (like what's done to remove screenlocks).
Eg.
loop:
wait(100);
if (get_sprite_with_this_brain(9,¤t_sprite) != 0)
goto loop;
say("Thar script continuas!",1);
Eg.
loop:
wait(100);
if (get_sprite_with_this_brain(9,¤t_sprite) != 0)
goto loop;
say("Thar script continuas!",1);
But I think what's wrong, is that the sprite the script is attached to, is still there, and it's seeing that as well.
How do I do that braincheck thing?
How do I do that braincheck thing?
Look in en-pill1 for the braincheck, which is this:
if (get_sprite_with_this_brain(9, ¤t_sprite) == 0)
{
//no more brain 9 monsters here, lets unlock the screen
screenlock(0);
playsound(43, 22050,0,0,0);
}
in the die procedure.
It isn't seeing the sprite it's attached to because the second bit tells it a sprite to ignore - get_sprite_with_this_brain(9, <ignore this one> );
Edit: Your enemies are brain 9, right?
If the sprite with the script is out of the way somewhere, try sp_nodraw() instead of sp_active().
if (get_sprite_with_this_brain(9, ¤t_sprite) == 0)
{
//no more brain 9 monsters here, lets unlock the screen
screenlock(0);
playsound(43, 22050,0,0,0);
}
in the die procedure.
It isn't seeing the sprite it's attached to because the second bit tells it a sprite to ignore - get_sprite_with_this_brain(9, <ignore this one> );
Edit: Your enemies are brain 9, right?

If the sprite with the script is out of the way somewhere, try sp_nodraw() instead of sp_active().
Personally, I'd completely kill off the old inactive sprite and put the braincheck procedure in each enemy before it dies. When no more are found, just recreate the sprite inside that braincheck and attach a new script with everything you wanted to do with him after the battle is over. Believe it or not, this is a less messy way to do things in Dink.
Right. I'll try it and get back to you all.
I got it working! Finally! This is what I did:
I had my script attached to a sprite, the first part of the cutscene runs, then, a couple of enemy scripts get attached to nearby sprites. I put a braincheck it each of their die() procedures, and killed off the original sprite with an sp_active(¤t_sprite, 0);. Then, when there were no monsters left on the screen, it spawned a script which spawns a new sprite, exactly like the first one, then another part of the cutscene runs and Dink fights him.
Thanks guys!
I had my script attached to a sprite, the first part of the cutscene runs, then, a couple of enemy scripts get attached to nearby sprites. I put a braincheck it each of their die() procedures, and killed off the original sprite with an sp_active(¤t_sprite, 0);. Then, when there were no monsters left on the screen, it spawned a script which spawns a new sprite, exactly like the first one, then another part of the cutscene runs and Dink fights him.
Thanks guys!