Screenlocks
How would you lock the screen until all monsters are cleared?
void main(void)
{
// Make this sprite invisible
sp_nodraw(¤t_sprite,1);
// Screenlock the screen
screenlock(1);
// Loop forever, until there aren't any sprites with brains 9 and 10 on the screen
loop:
wait(250);
if (get_sprite_with_this_brain(9, 0) == 0)
{
if (get_sprite_with_this_brain(10, 0) == 0)
{
// Remove the screenlock
screenlock(0);
playsound(43, 22050,0,0,0);
// Kill this sprite forever, so there aren't any more screenlocks! int &editor_sprite = sp_editor_num(¤t_sprite);
if (&editor_sprite != 0)
{
editor_type(&editor_sprite, 1);
}
kill_this_task();
}
}
goto loop;
}
Try this; and attach it to a sprite that you do not want to be in the actual game... I use the giant duck statue...
The kill this sprite forever line is optional, and can be removed if you always want that screen to be screenlocked when there are enemies.
{
// Make this sprite invisible
sp_nodraw(¤t_sprite,1);
// Screenlock the screen
screenlock(1);
// Loop forever, until there aren't any sprites with brains 9 and 10 on the screen
loop:
wait(250);
if (get_sprite_with_this_brain(9, 0) == 0)
{
if (get_sprite_with_this_brain(10, 0) == 0)
{
// Remove the screenlock
screenlock(0);
playsound(43, 22050,0,0,0);
// Kill this sprite forever, so there aren't any more screenlocks! int &editor_sprite = sp_editor_num(¤t_sprite);
if (&editor_sprite != 0)
{
editor_type(&editor_sprite, 1);
}
kill_this_task();
}
}
goto loop;
}
Try this; and attach it to a sprite that you do not want to be in the actual game... I use the giant duck statue...
The kill this sprite forever line is optional, and can be removed if you always want that screen to be screenlocked when there are enemies.
Yes, the script is ok, but I think it's useless, because you can check for other monsters on the screen in a monster's die procedure. When a monster dies, if there aren't any other monsters, unlock the screen(check some monsters scripts from the source).
Anyway, if for some reasons you'll use this script, add
sp_nohit(¤t_sprite,1);
after
sp_nodraw(¤t_sprite,1);
or dink will be able to punch an invisible thing.
Anyway, if for some reasons you'll use this script, add
sp_nohit(¤t_sprite,1);
after
sp_nodraw(¤t_sprite,1);
or dink will be able to punch an invisible thing.
But, then you have to have two copies of monster scripts when you want to have a screenlock. That's rather absurd.
Or you may change the "emake" script (the one that creates goodies when a monster dies) and always check if there are creatures with brain 9 or 10, screenlock or no screenlock.
Create a small (size1) unhittable sprite and give it brain 2 (not quite useful in a dmod) and attach a script that only does screenlock(1).
And if you want to lock the screen only once you check if the brain2 sprite exists on the screen and remove it in the same "emake" script when you do screenlock(0).
This way you don't need en extra script with a loop and no extra copies of monster scripts.
Create a small (size1) unhittable sprite and give it brain 2 (not quite useful in a dmod) and attach a script that only does screenlock(1).
And if you want to lock the screen only once you check if the brain2 sprite exists on the screen and remove it in the same "emake" script when you do screenlock(0).
This way you don't need en extra script with a loop and no extra copies of monster scripts.











