Zscript Secrets

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
saegiru
Posts: 143
Joined: Mon Jun 23, 2014 1:55 pm

Zscript Secrets

Post by saegiru »

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.
User avatar
Caligari87
Admin
Posts: 6236
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Zscript Secrets

Post by Caligari87 »

You can iterate over the sector or line array in zscript to find the information you need.

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!
  }
}
(pseudocode, may not work as-is)

8-)
User avatar
Accensus
Banned User
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: Zscript Secrets

Post by Accensus »

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?
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Zscript Secrets

Post by Kzer-Za »

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?
User avatar
Accensus
Banned User
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: Zscript Secrets

Post by Accensus »

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.
Post Reply

Return to “Scripting”