Monster Death Events

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Monster Death Events

Postby Beetow Brode » Mon Apr 16, 2018 9:57 pm

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
 
Joined: 24 Sep 2016

Re: Monster Death Events

Postby Beetow Brode » Mon Apr 16, 2018 9:58 pm

But this includes multiple monsters
not one
User avatar
Beetow Brode
 
Joined: 24 Sep 2016

Re: Monster Death Events

Postby Blue Shadow » Mon Apr 16, 2018 11:57 pm

Thing_Destroy. You can use it from DECORATE/ZScript and ACS.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

Re: Monster Death Events

Postby Beetow Brode » Wed Apr 18, 2018 7:07 pm

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 allExpand view
baronsKilled++;
if(baronsKilled >= 2)
User avatar
Beetow Brode
 
Joined: 24 Sep 2016

Re: Monster Death Events

Postby m8f » Wed Apr 18, 2018 8:05 pm

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 allExpand view
Thing_Destroy(0, 0, 0);
will kill every monster.

If the second, then
Code: Select allExpand view
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 allExpand view
    if (ThingCountName("DoomImp", 0) == 0)
    {
      // do something that you want when all imps are killed
    }
User avatar
m8f
the dreamer
 
Joined: 29 Dec 2017
Location: Siberia
Discord: m8f#0629

Re: Monster Death Events

Postby Beetow Brode » Sat Apr 21, 2018 5:21 pm

Thank you this helped very much! (:
User avatar
Beetow Brode
 
Joined: 24 Sep 2016


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest