how do i make a win requirement

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.

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
3O9XT
Posts: 4
Joined: Wed Jul 14, 2021 8:11 pm

how do i make a win requirement

Post by 3O9XT »

how do i make a requirement to win a level so its like hunting monsters?
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: how do i make a win requirement

Post by Jarewill »

If it's for a custom map, you can use ACS scripting for it:

Code: Select all

Script 666 (void)
{
    If(GetLevelInfo(LEVELINFO_KILLED_MONSTERS)>=GetLevelInfo(LEVELINFO_TOTAL_MONSTERS))
    { //If the monster have been killed, end the level
        Exit_Normal(0);
    }
    Else
    { //Otherwise print a message
        Print(s:"There are still monsters left!");
    }
} 
Just call this script instead of Exit_Normal you would normally use and it should work.
Used in this example was GetLevelInfo to retrieve the number of killed monsters and compare it with the number of total monsters.

If it's for a general gameplay mod meant to be used with Doom maps, I heavily advise against it.
There are plenty maps where getting 100% kills is impossible and it will cause your mod to prevent progression.
But if you really want to do it, you can use a ZScript Event Handler for it and overriding WorldLinePreActivated, checking the line's special, number of killed monsters compared to total monsters and setting ShouldActivate.
Once again, I advise against it as it will break several games, so win requirements are best used in custom maps.
3O9XT
Posts: 4
Joined: Wed Jul 14, 2021 8:11 pm

Re: how do i make a win requirement

Post by 3O9XT »

thank you so much sir!
Post Reply

Return to “Scripting”