Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DavidN

Vanilla Doom secret level behaviour

Recommended Posts

I'm piecing together another tutorial video, this time about the MAPINFO lump and how to use it to define episodes and clusters. It inspired me to ask people who might know more about hacking around in the original Doom than I do... does anyone know why nobody ever worked out how to alter the behaviour of the secret level exits?

 

The code that handles them is here: https://github.com/id-Software/DOOM/blob/77735c3ff0772609e9c8d29e3ce2ab42ff54d20b/linuxdoom-1.10/g_game.c#L1069 It's a load of ifs and switch statements that define where to go next if you're in Doom, Doom 2, heading to a secret level, returning from a secret level, and so on. (Confusingly, the current level is 1-based but the next level is 0-based - therefore, MAP31 has "31" as its next level, which means MAP32!) The destinations of the secret levels are decided based on the episode and map number.

 

It seems (to my untrained ears) that these hard-coded destination numbers must exist as bytes in the EXE somewhere that could be altered in the same way that Dehacked alters the monster and item data, therefore allowing a mapper with a hacked EXE to place secret levels wherever they like and to have the player return from the secret level to the correct place... does anyone with more EXE hacking knowledge than me know why changing these around wasn't so easy?

Share this post


Link to post

There are two different behaviors there.

 

In Doom, it's episode-based. If you put a secret exit switch on E1M1, it'll lead you to E1M9. Leaving E1M9 then leads you to E1M4, because the secret exit is normally on E1M3. If you put a secret exit on E1M9, it'll leads you back to a fresh new E1M9. Same deal for the other episodes, with just the secret level's normal exit destination changing (E2M6, E3M7, or E4M3).

 

In Doom II and Final Doom, it's level-based. A secret exit in MAP15 leads you to MAP31, a secret exit in MAP31 leads you to MAP32. A secret exit anywhere else and wminfo.next is not initialized, so you get undefined behavior. If wminfo.next had been previously initialized, by completing a level, it'll leads you to that level. Otherwise, presumably its value is 0 and it'll leads you to MAP01.

 

What does it mean? IIRC, the implication is that, if you put a secret exit on MAP02, start a new game, reach MAP02 and use the secret exit, you'll loop back to MAP02. Now instead of doing that, make a save on MAP02, quit, launch the game again, load your save, use the secret exit, and you'll warp back to MAP01. Or, like, idclev to MAP29, complete it, idclev to MAP02, use the secret exit, you'll get to MAP30. Or go to MAP15, find the secret exit, idclev to MAP02, use the secret exit, you get to MAP31.

Share this post


Link to post

There is something you can do about Doom2's secret exists with dehacked, but it's not tremendously useful. See the end of fraggle's post here.

 

Quote
Quote

The effect of changing the following is not clear to me:

6880-6887 [default: map01]
10728-10736 [default: map31]
Possibly something to do with secret exits?

 

Uber geek mode on.
Doom checks for the existence of a lump named "map01". If the player is playing Doom II and that lump isn't present, it assumes that the special "store demo" version of the game is playing, so any inputs (keyboard, mouse etc) are ignored.
The "map31" is used to disable the Doom 2 secret exit when playing the German version with no wolfenstein levels.

 

So, e.g., change that to map33, and secret exits won't take you to the secret levels.

Share this post


Link to post
14 hours ago, Gez said:

There are two different behaviors there.

 

Yep, that seems to match what I'm seeing in the code :) What I'm wondering is if there's a way to identify where those hard-coded numbers end up in the EXE and to modify them so that, say, episode 1's secret level goes back to E1M7 instead. I've been hunting around for likely places and haven't found anything yet, but I have discovered the word "fuck" at 0xaac10 (Ultimate Doom 1.9).

 

I found the bytes that @Grazza mentioned as well, and was able to trigger both those effects by messing with them directly!

Share this post


Link to post

This is pretty interesting, unfortunatelly i can't help much.
But i will have my ears pointing in this direction for whatever you found, guys!

 

Always dreamed of altering the secret exit location without mapinfo.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×