DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Code] Controlling Secret Levels
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Wed Sep 01, 2004 10:16 am
   Subject: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Controlling Secret Levels by BrotherTank

In Wolf3d, the game uses a simple array to hold what they call the "BackTo" levels, that are hard coded into the code. Sure, one can edit the code and set the array to the values you want the secret floor elevator to be on (once you've made your maps). But wouldn't it be easier to just have the game use the values that it already uses to define the "Secret Elevator Floor" to also control which level it goes back to??

Here is a very minor, but simple change, that will allow you to define on which level you are sent to the secret level (by defining the Secret Elevator with the Secret Elevator Floor), and then you don't have to keep changing your code to suit your latest mapset?

Ok... Get ready for this... It's as simple as adding one line of code as follows (Find the lines in Red and add the lines in Blue:

Open WL_GAME.C and go down to the "void PlayLoop (void)" function at the bottom...

::: CODE :::

         //
         // GOING TO SECRET LEVEL
         //
         if (playstate == ex_secretlevel)


            {
               ElevatorBackTo[gamestate.episode] = gamestate.mapon + 1;

               gamestate.mapon = 9;

            }



Pretty Simple Stuff... Now you never have to change the code if you decide that your Secret level will be called on say level 5 instead of level 1... You just set the Secret Elevator Floor code as you would in the original game.

Side Note: This method allows you to call a secret Level in more than 1 place/level and will not send you back to the wrong point in the game. Ie... Using the original game and original code:

The secret level is accessed on level 1. And it returns you to the start of Level 2 when you are done playing the secret level.. But lets say you changed your maps and put the secret level elevator on level 5. The original code would send you to the secret level, and then return you back to the start of Level 2. While this alone creates some interesting concepts in the game, this one line code fix above, will allow you to return to the level the next level in sequence from where you left off...

Hope that helps...

Greg
BrotherTank
jamez
I am Death Incarnate
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 13 Aug 2016

Topics: 13
Posts: 186
Location: Yorkshire, UK
uk.gif

PostPosted: Wed Sep 01, 2004 3:41 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

So, whats the

gamestate.mapon = 9;

for? Or should it be cancelled out?

_________________
~ James
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Wed Sep 01, 2004 8:47 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

jamez wrote:
So, whats the

gamestate.mapon = 9;

for? Or should it be cancelled out?


James... Look at the original code... It's a nested If condition...

IF the playstate flag is set to "Completed" or "Secret Level" then it ends the level you were playing and then does the intermission. It then looks at these 2 nested if statements.

If you are on Gamestate.mapon 9 then it sends you back to the Level stored in the ElevatorBackTo[gamestate.episode] array. If you are not on level 9, then it checks the nested if to see if you should be going "TO" the secret level.

ie: If the playstate == ex_secretlevel then it will send you to gamestate.mapon = 9. What my additional line tells it to do is save the current level + 1 into the "ElevatorBackTo" array before you go to the secret level... This sets where you should be returned once you have completed the secret level...

Thus, it gives control to the map maker on which level the secret levels can be called from, rather than using fixed values in the ElevatorBackTo array, as it was originally programmed. If you take an episode... again using episode 1.. and don't change the hardcoded values in the array, and change the maps... lets say you decide that the secret elevator will now be in level 3... when you finish the secret level, it would return you back to the beginning of level 2... Which you have already played... not to level 4... where you should be going. Because of this hard-coded return, map makers have always been forced to use the values in the "ElevatorBackTo" array, and/or compile a new exe when they want the new secret level elevator located on a different floor.

This 1 line of code alleviates the problem... Add it and when making maps, it doesn't matter what level you put the secret level elevator on...

Greg
BrotherTank

Want to be really creative... make sure to save the elevatorbackto array as part of your saved/loaded games... Smile Big hint... Use the gamestate structure to store it and save a few bytes by removing the "ElevatorBackTo" array...
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 30 Oct 2017

Topics: 55
Posts: 2115
Location: Canada
blank.gif

PostPosted: Thu Sep 02, 2004 3:06 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Funny, I also thought about this idea awhile ago. Like you said, you don't even need to have hardcoded numbers for the "return from secret" floor, you just need to keep track of the number when it actually goes to the secret elevator with a char/byte variable that can be called back later (thus getting rid of the 6 of them in the original ElevatorBackto). I was thinking of posting something about how easy this was to do, and how much easier this would make mapsets in general (since people can than put the secret levels wherever they want automatically without editing the exe), but no one gave me the impression that they needed this, so I didn't find it neccessary to post at the time; although I always found it intrieging.

It's cool to hear that someone else has considered this though, figuring out how to make elevators automatically go back to the next level after they reach the secret level, and realizing how completely irrelevant having hardcoded numbers for that sort of stuff really is. I didn't have much faith that someone else would have had the desire to try this, but you proved me wrong Greg. Smile
WSJ
DieHard Officer
DieHard Officer


Joined: 17 Apr 2004
Last Visit: 08 May 2017

Topics: 24
Posts: 521

blank.gif

PostPosted: Thu Sep 02, 2004 5:24 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Interesting... I wonder why John Carmack hadn't thought of something like this... or if he did, why he didn't use it. It would've made the games more flexible, without being hard-coded so that in this Episode you can only access the secret level from Level Such-and-Such. I remember this being a problem in the Doom games as well... In Doom, if you put the secret elevator on a level other than the level it was on originally, you'll still reappear on the same level as before... and in Doom II, you'll simply restart the level you just finished!
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Thu Sep 02, 2004 9:47 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@WSJ:

I'm not sure why they didn't think of this. It was something that I first did back when SR was being coded by MCS.

@Chris:

Yeah, I like to tinker with most of the code in the game (the wl_??? files that is). I've brought the all of the Spawn Boss routines into 1, and a few other modifications like that. It's nothing major, but most people don't even think about changing it. Seeing as I've made things user friendly in Wolfenstein Plus and this was part of it, this one was simple, and something that I thought should be released to the community.

@all:

When you understand the ElevatorBackTo array and the lines of code that Wolfenstein uses to control where to go and return, it's actually easy to take the secret levels one step further.. especially if you are using the Sequential Levels or Seamless level tutorials. With a little thought and a few lines of code, you can do Nested Secret Levels... Smile

Greg
BrotherTank
jamez
I am Death Incarnate
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 13 Aug 2016

Topics: 13
Posts: 186
Location: Yorkshire, UK
uk.gif

PostPosted: Thu Sep 02, 2004 10:13 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I was thinking too ahead, as I'd normally use seemless level prog..

That's why i was confused there...

_________________
~ James
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Thu Sep 02, 2004 11:49 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I haven't tried the code, but I have a quick question.
If I save a game while in the secret level, quit, then restart the game and load the level, is the stored return level still correct?

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Thu Sep 02, 2004 2:49 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Adam Biser wrote:
I haven't tried the code, but I have a quick question.
If I save a game while in the secret level, quit, then restart the game and load the level, is the stored return level still correct?


If you don't quit.. then everything is ok... otherwise No... That's why I said:
BrotherTank wrote:
Want to be really creative... make sure to save the elevatorbackto array as part of your saved/loaded games... Big hint... Use the gamestate structure to store it and save a few bytes by removing the "ElevatorBackTo" array...


To achieve things that way... In the wl_def.h file add

int backto;

in the gamestate type define... and then change the:

ElevatorBackTo[gamestate.episode] = gamestate.mapon + 1;

to:

gamestate.backto = gamestate.mapon + 1;

and then change the:

gamestate.mapon = ElevatorBackTo[gamestate.episode]; // back from secret

to:

gamestate.mapon = gamestate.backto;

in your wl_game.c file... Then you can remove the ElevatorBackTo array completely, saving yourself a few more bytes in the data group. And for James... Yes, seamless levels change this code considerably... at least they do in my Wolfenstein Plus code...

Greg
BrotherTank
jamez
I am Death Incarnate
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 13 Aug 2016

Topics: 13
Posts: 186
Location: Yorkshire, UK
uk.gif

PostPosted: Thu Sep 02, 2004 4:37 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Quote:
And for James... Yes, seamless levels change this code considerably... at least they do in my Wolfenstein Plus code...


Yeah. I should think quicker before posting Razz

_________________
~ James
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 12 Dec 2017

Topics: 46
Posts: 2291
Location: USA
usa.gif

PostPosted: Thu Sep 02, 2004 4:57 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

BrotherTank wrote:
That's why I said: <snip>

And I should read all of the posts a bit closer before posting... Embarassed

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Guest




Last Visit:





PostPosted: Wed Sep 22, 2004 2:07 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Shocked where in this world they comes from? Shocked

Quote:
Code removed.... by BT


I did tries to put elevator object (floor code) in level 1, test to see if it work, but it don't work..

@BrotherTank: is it your source code from SR????? which I uses this, so I replace this code to new code that you posted here and test again to see if it same thing, and it works.

That's what I did, see below.....

Quote:
Code removed... by BT


THANKS TO BROTHERTANK FOR HIS TIPS, Without his tips, my game will struck in hole and will not able to do this.... Exclamation Too Cool
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Wed Sep 22, 2004 3:11 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Howling_Wolf:

The code is for the "Wolf" side of the code, not the Spear. Spear is something completely different. With Spear, you must set hard limits. With wolf, you always know that level 9 is the secret level, so my code changes it so that you can call the secret level from any floor rather than the hardcoded ones.

What you posted (and I deleted) will only serve to confuse people. Sorry. If you follow the original tutorial or the one where I removed the elevatorbackto array properly, you won't have any problem. If you do or did have a problem, then you didn't enter the changes properly.

Greg
BrotherTank
Guest




Last Visit:





PostPosted: Wed Sep 22, 2004 3:35 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

BrotherTank wrote:
@Howling_Wolf:

The code is for the "Wolf" side of the code, not the Spear. Spear is something completely different. With Spear, you must set hard limits. With wolf, you always know that level 9 is the secret level, so my code changes it so that you can call the secret level from any floor rather than the hardcoded ones.

What you posted (and I deleted) will only serve to confuse people. Sorry. If you follow the original tutorial or the one where I removed the elevatorbackto array properly, you won't have any problem. If you do or did have a problem, then you didn't enter the changes properly.

Greg
BrotherTank



Clear to understand, I just show you what I using, but I tried to figure it out what you did to elevatorbackto array, I look all to closer to end of file, I found it out that array was different then my code.. Until I find something miss, so I decide to post here for you look at them, but I don't know that code will cause them confused..... Now it is work properly... Forgiven me for post the code here Embarassed Feel free to delete my post above.... thanks........ Cheesy Grin
Crane
Registered User
Registered User


Joined: 31 Aug 2008
Last Visit: 14 Sep 2008

Topics: 2
Posts: 15
Location: United Kingdom
uk.gif

PostPosted: Tue Sep 02, 2008 6:44 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I'm posting on old topics again, but there is one thing I should mention.

If you use "tedlevel" or level warping to get to the secret level, the elevator back map will be undefined and nearly impossible to correctly determine, even if you use the gamestate structure as described above. Something to keep in mind.

_________________
J. Gareth "Crane" Moreton
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2256
Location: Ontario
canada.gif

PostPosted: Tue Sep 02, 2008 9:56 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

While using "tedlevel" or the debug code and warping to the secret level will leave the variable set to 0, the player will return to the first level of the game because you must remember the "-1" as it said in the original code. "0" is actually level "1". Hence someone using the cheats to bypass the proper playing of the game with levels in succession would be punished and sent back to the start of the game.

What this code does do though is free the map maker to set which level the secret levels are called from in the game. With things no longer hard-coded, the secret floor value in the elevator is all that is required to send the player to the secret level from whichever map the maker so chooses.

Just something to keep in mind....

Greg
BrotherTank
Crane
Registered User
Registered User


Joined: 31 Aug 2008
Last Visit: 14 Sep 2008

Topics: 2
Posts: 15
Location: United Kingdom
uk.gif

PostPosted: Tue Sep 02, 2008 10:32 am
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ah, so Borland C initialises variables... due to my own experiences with Delphi, I assume that variables start uninitialised - still, initially setting it to zero is the most sensible option.

_________________
J. Gareth "Crane" Moreton
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 15:23 ago.

Topics: 160
Posts: 8007
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Sep 02, 2008 6:49 pm
   Subject: Re: [Code] Controlling Secret Levels
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Crane wrote:
still, initially setting it to zero is the most sensible option.
Easy for me to agree with you there, since I've been programming in BASIC for a *long* time. Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts [Code] Blood Splatz Tutorial - Blood Splatters
Author: Dugtrio17
45 11219 Tue Mar 11, 2008 12:02 am
AlumiuN View latest post
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2381 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 1703 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 1969 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2700 Sun Oct 26, 2003 1:21 am
Guest View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group