Monster Death Events

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Beetow Brode
Posts: 69
Joined: Sat Sep 24, 2016 1:46 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: "We've Got Hostiles"

Monster Death Events

Post by Beetow Brode »

I need help with a project that includes everything dying at the end, is there anyway that I can add this to my mod
or maybe can someone put an example. Thanks :wub:
User avatar
Beetow Brode
Posts: 69
Joined: Sat Sep 24, 2016 1:46 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: "We've Got Hostiles"

Re: Monster Death Events

Post by Beetow Brode »

But this includes multiple monsters
not one
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Monster Death Events

Post by Blue Shadow »

[wiki]Thing_Destroy[/wiki]. You can use it from DECORATE/ZScript and ACS.
User avatar
Beetow Brode
Posts: 69
Joined: Sat Sep 24, 2016 1:46 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: "We've Got Hostiles"

Re: Monster Death Events

Post by Beetow Brode »

Could I maybe see an example, also I had a script where this could maybe work, but it doesnt because its 2 imps and a arachnatron, so i'm thinking this could maybe work?

Code: Select all

baronsKilled++;
if(baronsKilled >= 2)
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: Monster Death Events

Post by m8f »

Do you want to: 1. kill everything in the end by a script, or 2. detect that everything is killed?
If the first, then

Code: Select all

Thing_Destroy(0, 0, 0);
will kill every monster.

If the second, then

Code: Select all

script "CheckEverythingKilled" Enter
{
  int totalMonsters  = GetLevelInfo(LEVELINFO_TOTAL_MONSTERS);
  int killedMonsters = GetLevelInfo(LEVELINFO_KILLED_MONSTERS);
  bool allMonstersKilledOld = (totalMonsters == killedMonsters);

  while (true)
  {
    totalMonsters  = GetLevelInfo(LEVELINFO_TOTAL_MONSTERS);
    killedMonsters = GetLevelInfo(LEVELINFO_KILLED_MONSTERS);
    bool allMonstersKilled = (totalMonsters == killedMonsters);

    if (allMonstersKilled != allMonstersKilledOld)
    {
      // do something that you want when everything is killed
    }
    allMonstersKilledOld = allMonstersKilled;

    delay(35); // check every second.
  }
}
If you want to check not everything, but a particular type of monster, you can use ThingCountName:

Code: Select all

    if (ThingCountName("DoomImp", 0) == 0)
    {
      // do something that you want when all imps are killed
    }
User avatar
Beetow Brode
Posts: 69
Joined: Sat Sep 24, 2016 1:46 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: "We've Got Hostiles"

Re: Monster Death Events

Post by Beetow Brode »

Thank you this helped very much! (:
Post Reply

Return to “Scripting”