Jump to content
What you need to know about Doomworld and the GDPR Read more... ×
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Empyre

[ACS](Solved)How can I detect when all monsters are dead?

Question

I gave all the cyberdemons in my map the TID 100. Then, I wrote a script that detects when all things with that TID are dead, and then does some stuff. This worked fine until I added a gameplay mod that replaces the monsters with custom monsters. the replacements did not inherit the TID that I gave them, and the script moved on to the next thing to do immediately. I want to map to work with or without any mod. If I could detect whether all hostile monsters are dead, that would be good enough.

 

How can I do that? It would specifically need to detect hostile monsters because some mods have friendly monsters. I searched the ZDoom Wiki and these forums and couldn't find the answer.

 

Blue Shadow's GetLevelInfo idea solved the problem.

Edited by Empyre : report success

Share this post


Link to post

9 answers to this question

Recommended Posts

  • 0

Use a WHILE loop to wait until they are dead to execute a script.

 

While (ThingCount(T_CYBERDEMON > 0) {

delay (1);

        SomeAction(Id, something, something);

 

This will delay some action until monsters (cyberdemons) are equal to 0.

 

 

Edited by everennui : code was wrong. I didn't include ThingCount

Share this post


Link to post
  • 0

T_CYBERDEMON or T_NONE should do the trick, like this:

 

script 2 (void)
{
while(ThingCount(T_NONE, 100) > 0) <---since you tagged the spawned monsters to 100
    {
        Delay(1);
    }
    anyaction(x,x,x);
}

Share this post


Link to post
  • 0
1 hour ago, Empyre said:

the replacements did not inherit the TID that I gave them,

That means that the gameplay mod was made really badly, otherwise the replacements would retain their TIDs. There is probably no generic way at all to refer to the original monsters with gameplay mods like this.

Share this post


Link to post
  • 0
2 hours ago, scifista42 said:

That means that the gameplay mod was made really badly, otherwise the replacements would retain their TIDs. There is probably no generic way at all to refer to the original monsters with gameplay mods like this.

That's why I am now trying to find a way to detect that all monsters of all types are dead. What about ThingCount (T_NONE,0)? Would that count only monsters, or would it also count other things like trees, lamps, etc?

 

What leodoom and everennui said is what I did already. It works perfectly when there is no gameplay mod added.

 

Here's an idea: If a mod tries to break things, I could fall back to using a timer.

// beginning of an OPEN script
if (ThingCount(T_NONE,100) = 0)
{
  Delay(35*60*5); // 5 minutes
}
else
{
  while (ThingCount(T_NONE,100) > 0)
  {
    Delay(35); // Once a second should be often enough to check.
  }
};
// Do stuff ...

I would still rather be able to detect where there are any monsters of any kind alive than resort to a timer.

Share this post


Link to post
  • 0

I think (T_NONE, 0) might do that. IIRC, all monsters are defaulted to zero unless tagged otherwise.

Edited by everennui

Share this post


Link to post
  • 0

I was just coming here to report the results of my experiment with ThingCount(T_NONE,0) (nothing happened, ever), but I find the answer I was looking for.

 

I'll like your answer now, and come back and mark it as Best Answer if it works.

 

EDIT: YES! It works! Not only does it work, but it also doesn't count friendly monsters.

Edited by Empyre : It works!

Share this post


Link to post
  • 0
2 hours ago, Empyre said:

What about ThingCount (T_NONE,0)? Would that count only monsters, or would it also count other things like trees, lamps, etc?

ThingCount only counts things that are living monsters. That's why you can use it to check that monsters are killed (it doesn't count their corpses).

Share this post


Link to post
  • 0
19 minutes ago, Gez said:

ThingCount only counts things that are living monsters. That's why you can use it to check that monsters are killed (it doesn't count their corpses).

When I tried ThingCount(T_NONE,0), nothing happened. Even when all hostile and friendly monsters were dead, the stuff that was supposed to happen when all monsters were dead didn't happen. That's OK because Blue Shadow's GetLevelInfo idea worked perfectly.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×