by m8f » Wed Apr 18, 2018 7: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
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
}
Do you want to: 1. [i]kill[/i] everything in the end by a script, or 2. [i]detect[/i] that everything is killed?
If the first, then
[code=php]Thing_Destroy(0, 0, 0);[/code] will kill every monster.
If the second, then
[code=php]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.
}
}
[/code]
If you want to check not everything, but a particular type of monster, you can use [url=https://zdoom.org/wiki/ThingCountName]ThingCountName[/url]:
[code=php] if (ThingCountName("DoomImp", 0) == 0)
{
// do something that you want when all imps are killed
}[/code]