"Get available levels" from ZScript

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

"Get available levels" from ZScript

Postby JPL » Wed Jul 01, 2020 3:22 pm

I'd like to make a generic randomizer mod that, among other things, exits any level to a random level instead of the one defined by "next" / "secretnext" in MAPINFO. The actual level transition I think I can do with the ACS function ChangeLevel, but I don't think ZScript has a way of getting a list (dynarray of strings?) of all available levels, ie all levels in currently loaded IWADs and PWADs, sort of like what you get with the "listmaps" console command. Not sure if this would be part of the "Wads" ZScript function group or something else, that's an implementation decision.

Edit based on some discussion below: for this to be most useful, it would be good to have an optional bool argument to pass in to this function that specifies whether to return an array of all levels including ones defined in the IWAD, or just the levels that are defined in PWADs.

It'd also be nice to not have to involve any ACS, and have the equivalent of ACS ChangeLevel in ZScript, but I can file that as a separate request if need be.
Last edited by JPL on Thu Jul 02, 2020 5:40 pm, edited 1 time in total.
User avatar
JPL
 
 
 
Joined: 09 Apr 2012

Re: "Get available levels" from ZScript

Postby Caligari87 » Thu Jul 02, 2020 8:27 am

JPL wrote:It'd also be nice to not have to involve any ACS, and have the equivalent of ACS ChangeLevel in ZScript, but I can file that as a separate request if need be.

Reasonably sure this part can be done in zscript by (roughly) setting level.nextmap and then calling level.ExitLevel() (there's probably slightly more to it than that, but it's the basic gist).

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: "Get available levels" from ZScript

Postby Accensus » Thu Jul 02, 2020 9:08 am

That would work. But keep in mind that if you jump to a map outside of the cluster, you'll have to watch the cluster text every time. I learned this when trying to make an intermission map addon that could be used with any mapset, but unfortunately it didn't work and the cluster thing completely ruined the immersion.
User avatar
Accensus
Vector, locked in.
 
Joined: 11 Feb 2016
Location: Somalia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "Get available levels" from ZScript

Postby JPL » Thu Jul 02, 2020 11:55 am

Caligari87 wrote:
JPL wrote:It'd also be nice to not have to involve any ACS, and have the equivalent of ACS ChangeLevel in ZScript, but I can file that as a separate request if need be.

Reasonably sure this part can be done in zscript by (roughly) setting level.nextmap and then calling level.ExitLevel() (there's probably slightly more to it than that, but it's the basic gist).
8-)


How do I know which levels are actually valid though? A WAD might have 9 levels, 32 levels, or something else. They might be called ExMx, MAPxx, or something else.

Now that I think of it, an optional bool argument for my original request that specifies "get all available levels, including IWAD levels" vs "get only levels defined in loaded PWADs" would be useful. If a PWAD includes MAP01 through MAP03, I don't want the random pick to come up a vanilla MAP15, for example.
User avatar
JPL
 
 
 
Joined: 09 Apr 2012

Re: "Get available levels" from ZScript

Postby Accensus » Thu Jul 02, 2020 12:38 pm

NextMap is a string, meaning you'd have to hardcode the list. There's currently no way to get the name of an arbitrary map at runtime.
User avatar
Accensus
Vector, locked in.
 
Joined: 11 Feb 2016
Location: Somalia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "Get available levels" from ZScript

Postby JPL » Thu Jul 02, 2020 5:39 pm

Accensus wrote:NextMap is a string, meaning you'd have to hardcode the list. There's currently no way to get the name of an arbitrary map at runtime.


Right, that's what I'm asking for: a way, from ZScript, to get an array of valid map names based on the currently loaded WADs. As far as I can tell there is no way to do this.
User avatar
JPL
 
 
 
Joined: 09 Apr 2012

Re: "Get available levels" from ZScript

Postby Accensus » Thu Jul 02, 2020 6:23 pm

Christ, today is one of those days where I spend exactly 0 seconds thinking before posting. To redeem myself, I second this feature suggestion, as it'd allow the creation of map selector mods, like a PDA that allows you to exit early. Maybe I could revise my hub idea too. Just need to figure out what to do about the cluster text...
User avatar
Accensus
Vector, locked in.
 
Joined: 11 Feb 2016
Location: Somalia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "Get available levels" from ZScript

Postby 3saster » Sun Jul 05, 2020 7:59 pm

While the feature could certainly be useful, you could write a parser that reads the MAPINFO lumps and parses them to extract what the map name is. I may try this out later, sounds like it could be an interesting task.
User avatar
3saster
 
Joined: 11 May 2018
Location: Canada

Re: "Get available levels" from ZScript

Postby Graf Zahl » Sun Jul 05, 2020 11:57 pm

That'd be a very inefficient way to handle this - you need 3 parsers that need to be kept up to date with the internal ones.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests