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.
"Get available levels" from ZScript
Moderator: GZDoom Developers
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
"Get available levels" from ZScript
Last edited by JPL on Thu Jul 02, 2020 5:40 pm, edited 1 time in total.
-
- Admin
- Posts: 6190
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
Re: "Get available levels" from ZScript
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).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.
-
- Posts: 2383
- Joined: Thu Feb 11, 2016 9:59 am
Re: "Get available levels" from ZScript
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.
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
Re: "Get available levels" from ZScript
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.Caligari87 wrote: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).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.
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.
-
- Posts: 2383
- Joined: Thu Feb 11, 2016 9:59 am
Re: "Get available levels" from ZScript
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.
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
Re: "Get available levels" from ZScript
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 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.
-
- Posts: 2383
- Joined: Thu Feb 11, 2016 9:59 am
Re: "Get available levels" from ZScript
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...
-
- Posts: 199
- Joined: Fri May 11, 2018 2:39 pm
- Location: Canada
Re: "Get available levels" from ZScript
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.
-
- Lead GZDoom+Raze Developer
- Posts: 49118
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "Get available levels" from ZScript
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.
-
-
- Posts: 17454
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "Get available levels" from ZScript
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.