"Get available levels" from ZScript

Moderator: GZDoom Developers

Post Reply
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm
Contact:

"Get available levels" from ZScript

Post by JPL »

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

Re: "Get available levels" from ZScript

Post by Caligari87 »

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

Re: "Get available levels" from ZScript

Post by Accensus »

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
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm
Contact:

Re: "Get available levels" from ZScript

Post by JPL »

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

Re: "Get available levels" from ZScript

Post by Accensus »

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
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm
Contact:

Re: "Get available levels" from ZScript

Post by JPL »

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

Re: "Get available levels" from ZScript

Post by Accensus »

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
3saster
Posts: 199
Joined: Fri May 11, 2018 2:39 pm
Location: Canada

Re: "Get available levels" from ZScript

Post by 3saster »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "Get available levels" from ZScript

Post by Graf Zahl »

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
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "Get available levels" from ZScript

Post by Nash »

You can now use the LevelInfo struct for this. The 'Level' global has an 'info' member that can be easily accessed. See this file for some examples.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”