Zscript Secrets
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!)
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!)
Zscript Secrets
Hi, I'm looking to find a way to find if a line or sector is tagged as secret using Zscript... is this possible? I know there are ways to search for damaging floors and such, but I specifically want to detect secret areas if possible.
- Caligari87
- Admin
- Posts: 6236
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Zscript Secrets
You can iterate over the sector or line array in zscript to find the information you need.
(pseudocode, may not work as-is)

Code: Select all
// loop over all sectors
for (int i=0; i<level.sectors.size(); i++) {
// check for secret flag
if (level.sectors[i].flags & SECF_SECRET) {
// Do secret stuff!
}
}

Re: Zscript Secrets
There's IsSecret() that you can use. Level.sectors.IsSecret().
EDIT: My post was vague, sorry for that. If you want to do this on map start, you override WorldLoaded in an event handler. Here's some code where I detect secret sectors to spawn some actors in their center.
If that's not what you want, you'd have to be more specific. When exactly do you want to get if a sector is a secret?
EDIT: My post was vague, sorry for that. If you want to do this on map start, you override WorldLoaded in an event handler. Here's some code where I detect secret sectors to spawn some actors in their center.
If that's not what you want, you'd have to be more specific. When exactly do you want to get if a sector is a secret?
Re: Zscript Secrets
Accensus wrote:There's IsSecret() that you can use. Level.sectors.IsSecret().
If you want to do this on map start, you override WorldLoaded in an event handler. Here's some code where I detect secret sectors to spawn some actors in their center.
Great! I had this idea of spawning some things in the centerspot of secret sectors, but couldn't make it work. Only after finding this thread and looking at your code I was able to do it! Thanks a lot! Do you mind if I use your code, giving you credit for it, if I publish my mod?
Re: Zscript Secrets
Go ahead. Keep in mind WasSecret is also a thing, just in case you run into a situation where you need to know that. I can't recall off the top of my head where it's useful, but I have certainly used it in situations where IsSecret wasn't useful as the secret had already been discovered.
EDIT: https://gitlab.com/accensi/hd-addons/sp ... PT.zsc#L66 I use it here to exclude secret sectors from having toxic air.
EDIT: https://gitlab.com/accensi/hd-addons/sp ... PT.zsc#L66 I use it here to exclude secret sectors from having toxic air.