• View unanswered postsView active topics

  • (Tutorial) More secret levels in episodes

    Discuss Wolf3D and Wolf3D modding/ports

    Postby Officer-Michael John 19 Jun 2016, 12:46

    We have my new routine:More secret levels in episodes. After much time it would normally forming with Chris Chokan and István Bohács help.

    A This tutorial was used. But with minor changes:

    http://www.areyep.com/Codingtips/morelvls.html

    ID_CA.H:

    Code: Select all
    #define NUMMAPS         66


    WL_INTER.CPP:

    Code: Select all
           //
           // Episode One Par Times
           //
           {1.5, "01:30"},
           {2, "02:00"},
           {2, "02:00"},
           {3.5, "03:30"},
           {3, "03:00"},
           {3, "03:00"},
           {2.5, "02:30"},
           {2.5, "02:30"},
           {0, "??:??"},           // Boss level
           {0, "??:??"},           // Secret level
           {0, "??:??"},           // Secret level 2

           //
           // Episode Two Par Times
           //
           {1.5, "01:30"},
           {3.5, "03:30"},
           {3, "03:00"},
           {2, "02:00"},
           {4, "04:00"},
           {6, "06:00"},
           {1, "01:00"},
           {3, "03:00"},
           {0, "??:??"},
           {0, "??:??"},
           {0, "??:??"},          
           
           //
           // Episode Three Par Times
           //
           {1.5, "01:30"},
           {1.5, "01:30"},
           {2.5, "02:30"},
           {2.5, "02:30"},
           {3.5, "03:30"},
           {2.5, "02:30"},
           {2, "02:00"},
           {6, "06:00"},
           {0, "??:??"},
           {0, "??:??"},        

           //
           // Episode Four Par Times
           //
           {2, "02:00"},
           {2, "02:00"},
           {1.5, "01:30"},
           {1, "01:00"},
           {4.5, "04:30"},
           {3.5, "03:30"},
           {2, "02:00"},
           {4.5, "04:30"},
           {0, "??:??"},
           {0, "??:??"},
           {0, "??:??"},          
           
           //
           // Episode Five Par Times
           //
           {2.5, "02:30"},
           {1.5, "01:30"},
           {2.5, "02:30"},
           {2.5, "02:30"},
           {4, "04:00"},
           {3, "03:00"},
           {4.5, "04:30"},
           {3.5, "03:30"},
           {0, "??:??"},
           {0, "??:??"},    
           {0, "??:??"},          

           //
           // Episode Six Par Times
           //
           {6.5, "06:30"},
           {4, "04:00"},
           {4.5, "04:30"},
           {6, "06:00"},
           {5, "05:00"},
           {5.5, "05:30"},
           {5.5, "05:30"},
           {8.5, "08:30"},
           {0, "??:??"},
           {0, "??:??"},
           {0, "??:??"}

    #ifdef SPANISH
           Write (30, 12, parTimes[gamestate.episode * 11 + mapon].timestr);
    #else
           Write (26, 12, parTimes[gamestate.episode * 11 + mapon].timestr);
    #endif

           if (gamestate.TimeCount < parTimes[gamestate.episode * 11 + mapon].time * 4200)
               timeleft = (int32_t) ((parTimes[gamestate.episode * 11 + mapon].time * 4200) / 70 - sec);


    WL_PLAY.CPP:

    Code: Select all
       //
       // Episode One
       //
       GETTHEM_MUS,
       SEARCHN_MUS,
       POW_MUS,
       SUSPENSE_MUS,
       GETTHEM_MUS,
       SEARCHN_MUS,
       POW_MUS,
       SUSPENSE_MUS,

       ULTIMATE_MUS,               // Boss level
       CORNER_MUS,                 // Secret level
       CORNER_MUS,                 // Secret level 2

       //
       // Episode Two
       //
       NAZI_OMI_MUS,
       PREGNANT_MUS,
       GOINGAFT_MUS,
       HEADACHE_MUS,
       NAZI_OMI_MUS,
       PREGNANT_MUS,
       HEADACHE_MUS,
       GOINGAFT_MUS,

       WARMARCH_MUS,               // Boss level
       DUNGEON_MUS,                // Secret level
       DUNGEON_MUS,                // Secret level 2

       //
       // Episode Three
       //
       INTROCW3_MUS,
       NAZI_RAP_MUS,
       TWELFTH_MUS,
       ZEROHOUR_MUS,
       INTROCW3_MUS,
       NAZI_RAP_MUS,
       TWELFTH_MUS,
       ZEROHOUR_MUS,

       ULTIMATE_MUS,               // Boss level
       PACMAN_MUS,                 // Secret level
       PACMAN_MUS,                 // Secret level 2    

       //
       // Episode Four
       //
       GETTHEM_MUS,
       SEARCHN_MUS,
       POW_MUS,
       SUSPENSE_MUS,
       GETTHEM_MUS,
       SEARCHN_MUS,
       POW_MUS,
       SUSPENSE_MUS,

       WARMARCH_MUS,               // Boss level
       CORNER_MUS,                 // Secret level
       CORNER_MUS,                 // Secret level 2

       //
       // Episode Five
       //
       NAZI_OMI_MUS,
       PREGNANT_MUS,
       GOINGAFT_MUS,
       HEADACHE_MUS,
       NAZI_OMI_MUS,
       PREGNANT_MUS,
       HEADACHE_MUS,
       GOINGAFT_MUS,

       WARMARCH_MUS,               // Boss level
       DUNGEON_MUS,                // Secret level
       DUNGEON_MUS,                // Secret level 2

       //
       // Episode Six
       //
       INTROCW3_MUS,
       NAZI_RAP_MUS,
       TWELFTH_MUS,
       ZEROHOUR_MUS,
       INTROCW3_MUS,
       NAZI_RAP_MUS,
       NAZIS_MUS,
       ZEROHOUR_MUS,

       ULTIMATE_MUS,               // Boss level
       FUNKYOU_MUS,                // Secret level
       FUNKYOU_MUS                 // Secret level 2  

    void StartMusic ()
    {
       SD_MusicOff ();
       lastmusicchunk = (musicnames) songs[gamestate.mapon + gamestate.episode * 11];
       SD_StartMusic(STARTMUSIC + lastmusicchunk);
    }

    void ContinueMusic (int offs)
    {
       SD_MusicOff ();
       lastmusicchunk = (musicnames) songs[gamestate.mapon + gamestate.episode * 11];
       SD_ContinueMusic(STARTMUSIC + lastmusicchunk, offs);
    }


    WL_DRAW.CPP:

    Code: Select all
    byte vgaCeiling[]=
    {
    #ifndef SPEAR
    0x17,0x1d,0x45,0x20,0x09,0x0,0x04,0x0,0x17,0xbf,0x0,
    0x4e,0x4e,0x4e,0x1d,0x8d,0x4e,0x1d,0x2d,0x1d,0x8d,0x8d,
    0x1d,0x1d,0x1d,0x1d,0x1d,0x2d,0xdd,0x1d,0x1d,0x98,0x98,

    0x1d,0x9d,0x2d,0xdd,0xdd,0x9d,0x2d,0x4d,0x1d,0xdd,0xdd,
    0x7d,0x1d,0x2d,0x2d,0xdd,0xd7,0x1d,0x1d,0x1d,0x2d,0x2d,
    0x1d,0x1d,0x1d,0x1d,0xdd,0xdd,0x7d,0xdd,0xdd,0xdd,0xdd
    #else
    0x6f,0x4f,0x1d,0xde,0xdf,0x2e,0x7f,0x9e,0xae,0x7f,
    0x1d,0xde,0xdf,0xde,0xdf,0xde,0xe1,0xdc,0x2e,0x1d,0xdc
    #endif
    };

    void VGAClearScreen (void)
    {
       byte ceiling=vgaCeiling[gamestate.episode*11+mapon];


    WL_DEBUG.CPP:

    Code: Select all
       else if (Keyboard[sc_W])        // W = warp to level
       {
           CenterWindow(26,3);
           PrintY+=6;
    #ifndef SPEAR
           US_Print("  Warp to which level(1-11): ");
    #else
           US_Print("  Warp to which level(1-21): ");
    #endif
           VW_UpdateScreen();
           esc = !US_LineInput (px,py,str,NULL,true,2,0);
           if (!esc)
           {
               level = atoi (str);
    #ifndef SPEAR
               if (level>0 && level<12)
    #else
               if (level>0 && level<22)
    #endif
               {
                   gamestate.mapon = level-1;
                   playstate = ex_warped;
               }
           }
           return 1;
       }


    WL_GAME.CPP:

    Code: Select all
    //
    // ELEVATOR BACK MAPS - REMEMBER (-1)!!
    //
    //int ElevatorBackTo[]={1,1,7,3,5,3};

    US_Print(" Demo number (0-10): ");

    #ifdef UPLOAD
       US_Print("  Demo which level(1-11): "); maps = 11;
    #else
       US_Print("  Demo which level(1-66): "); maps = 66;
    #endif

    #ifndef SPEAR
       NewGame (gd_hard,level/11);
       gamestate.mapon = level%11;
    #else
       NewGame (gd_hard,0);
       gamestate.mapon = level;
    #endif

    /*
       Commented out for New Year's Eve
            //
            // COMING BACK FROM SECRET LEVEL
            //
            if (gamestate.mapon == 9)
               gamestate.mapon = ElevatorBackTo[gamestate.episode];   // back from secret
            else
            //
            // GOING TO SECRET LEVEL
            //
            if (playstate == ex_secretlevel)
               gamestate.mapon = 9;
    */

    // Real Secret Elevator Levels for Wolf 3D

    #define FROMSEC1             0
    #define FROMSEC2             9
    #define FROMSEC3             11
    #define FROMSEC4             20
    #define FROMSEC5             28
    #define FROMSEC6             31
    #define FROMSEC7             35
    #define FROMSEC8             40
    #define FROMSEC9             48
    #define FROMSEC10            50
    #define FROMSEC11            57
    #define FROMSEC12            60

            //
            // GOING TO SECRET LEVEL
            //
            if (playstate == ex_secretlevel)
               switch(gamestate.mapon)
               {
                                    case FROMSEC1: gamestate.mapon = 9; break;
                                    case FROMSEC2: gamestate.mapon = 10; break;
                                    case FROMSEC3: gamestate.mapon = 20; break;
                                    case FROMSEC4: gamestate.mapon = 21; break;
                                    case FROMSEC5: gamestate.mapon = 31; break;
                                    case FROMSEC6: gamestate.mapon = 32; break;
                                    case FROMSEC7: gamestate.mapon = 42; break;
                                    case FROMSEC8: gamestate.mapon = 43; break;
                                    case FROMSEC9: gamestate.mapon = 53; break;
                                    case FROMSEC10: gamestate.mapon = 54; break;
                                    case FROMSEC11: gamestate.mapon = 64; break;
                                    case FROMSEC12: gamestate.mapon = 65; break;
               }
            else
            //
            // COMING BACK FROM SECRET LEVEL
            //
                           if (gamestate.mapon == 9 || gamestate.mapon == 10 || gamestate.mapon == 20 || gamestate.mapon == 21 || gamestate.mapon == 31 || gamestate.mapon == 32 || gamestate.mapon == 42
                            || gamestate.mapon == 43 || gamestate.mapon == 53 || gamestate.mapon == 54 || gamestate.mapon == 64 || gamestate.mapon == 65)
               switch(gamestate.mapon)
               {
                                    case 9: gamestate.mapon = FROMSEC1+1; break;
                                    case 10: gamestate.mapon = FROMSEC2+1; break;
                                    case 20: gamestate.mapon = FROMSEC3+1; break;
                                    case 21: gamestate.mapon = FROMSEC4+1; break;
                                    case 31: gamestate.mapon = FROMSEC5+1; break;
                                    case 32: gamestate.mapon = FROMSEC6+1; break;
                                    case 42: gamestate.mapon = FROMSEC7+1; break;
                                    case 43: gamestate.mapon = FROMSEC8+1; break;
                                    case 53: gamestate.mapon = FROMSEC9+1; break;
                                    case 54: gamestate.mapon = FROMSEC10+1; break;
                                    case 64: gamestate.mapon = FROMSEC11+1; break;
                                    case 65: gamestate.mapon = FROMSEC12+1; break;
               }
               
    #else

    #define FROMSECRET1 3
    #define FROMSECRET2 11

    //
    // GOING TO SECRET LEVEL
    //
    if (playstate == ex_secretlevel)
    switch(gamestate.mapon)
    {
    case FROMSECRET1: gamestate.mapon = 18; break;
    case FROMSECRET2: gamestate.mapon = 19; break;
    }
    else
    //
    // COMING BACK FROM SECRET LEVEL
    //
    if (gamestate.mapon == 18 || gamestate.mapon == 19)
    switch(gamestate.mapon)
    {
    case 18: gamestate.mapon = FROMSECRET1+1; break;
    case 19: gamestate.mapon = FROMSECRET2+1; break;
    }
    #endif            
                       else
                           //
                           // GOING TO NEXT LEVEL
                           //
                           gamestate.mapon++;
                   break;


    WL_AGENT.CPP:

    Code: Select all
    /*
    ===============
    =
    = DrawLevel
    =
    ===============
    */

    void DrawLevel (void)
    {
       if(viewsize == 66 && ingame) return;
    //#ifdef SPEAR
       if (gamestate.mapon == 65)
           LatchNumber (2,16,2,18);
       else
    //#endif
           LatchNumber (2,16,2,gamestate.mapon+1);
    }


    WL_MAIN.CPP:

    Code: Select all
    #ifndef SPEAR
            gamestate.episode = (param_tedlevel-1)/11;
            gamestate.mapon = (param_tedlevel-1)%11;
    #else
            gamestate.episode = 0;
            gamestate.mapon = param_tedlevel;
    #endif
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        

    The following user would like to thank Officer-Michael John for this post
    DoomJedi

    Postby Officer-Michael John 04 Jan 2017, 11:03

    Here I write together code updates.

    Updated 26/12/2016 7:03 am

    I found a bug,that you can't go to 1st secret level. I fixed bug.

    Note:Some code with originally version working.

    New code:

    Please you don't deleting int ElevatorBackTo[]= because with this working. (WL_GAME.CPP)
    The code is not required DrawLevel I wrote. (WL_AGENT.CPP)

    WL_GAME.CPP:

    Insert in below int ElevatorBackTo

    Code: Select all
    int ElevatorBackTo2[]={10,10,10,10,10,10};   


    Updated 26/12/2016 12:01 pm

    Now have a fully working code.

    WL_DEF:

    You need to add:

    Code: Select all
    #define ELEVATORTILE    21
    #define ELEVATORTILE2   52 <--new evelator tile on 2nd secret level

       ex_secretlevel,
       ex_secretlevel2 <--secret level 2


    WL_AGENT.CPP:

    You search ELEVATORTILE and Insert in below this:

    Code: Select all
       if (!buttonheld[bt_use] && doornum == ELEVATORTILE2 && elevatorok)
       {
           //
           // use elevator
           //
           buttonheld[bt_use] = true;

           tilemap[checkx][checky]++;              // flip switch
           if (*(mapsegs[0]+(player->tiley<<mapshift)+player->tilex) == ALTELEVATORTILE)
               playstate = ex_secretlevel2;
           else
               playstate = ex_completed;    
           SD_PlaySound (LEVELDONESND);
           SD_WaitSoundDone();
       }


    Updated 31/12/2016 11:48 am

    I found a bug,that you can't go back from secret level 1 to normal level.

    You go to in WL_GAME.CPP and you add:

    Code: Select all
                   //
                   // COMING BACK FROM SECRET LEVEL
                   //
                   if (gamestate.mapon == 9)
                       gamestate.mapon = ElevatorBackTo[gamestate.episode];    // back from secret
                   else
                       //
                       // GOING TO SECRET LEVEL
                       //
                       if (playstate == ex_secretlevel)
                           gamestate.mapon = 9;
                           
                   //
                   // COMING BACK FROM SECRET LEVEL 2
                   //
                   else if (gamestate.mapon == 10)
                       gamestate.mapon = ElevatorBackTo2[gamestate.episode];    // back from secret 2
                   else
                       //
                       // GOING TO SECRET LEVEL 2
                       //
                       if (playstate == ex_secretlevel2)
                           gamestate.mapon = 10;  


    This code work 100%. I tested in my New Year's Eve mod. 8)
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        


    Return to General Wolf3D/modding Discussion and tutorials


    Who is online

    Users browsing this forum: No registered users and 3 guests

    cron