• View unanswered postsView active topics

  • Secret problem in episode

    Discuss Wolf3D and Wolf3D modding/ports

    Postby Officer-Michael John 18 Dec 2016, 21:27

    I use my more secret levels in episode routine and I found a bug,that a given level go to level 11 and not level 10. I can't fixing. What is problem?

    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
             //
             if (gamestate.mapon == 10)
                gamestate.mapon == 8;   // back from secret 2
             else
             //
             // GOING TO SECRET LEVEL 2
             //
             if (playstate == ex_secretlevel2)
                gamestate.mapon == 10;   
    Officer-Michael John
    User avatar

     
    Posts: 131
    Location: Hungary

        

    Postby linuxwolf 19 Dec 2016, 23:38

    Code: Select all
    namespace SecretLevel
    {
        bool nextLevel(int from, int to, short int &mapon)
        {
            if (mapon == to)
            {
                mapon = from + 1;
                return true;
            }

            if (mapon == from && playstate == ex_secretlevel)
            {
                mapon = to;
                return true;
            }

            return false;
        }

        bool nextLevelAny(short int &mapon)
        {
            return SecretLevel::nextLevel(4, 15, mapon) ||
                SecretLevel::nextLevel(12, 16, mapon);
        }
    }

    void GameLoop (void)
    {
        // ...
                case ex_completed:
                case ex_secretlevel:
                    DrawPlayScreen();
                    gamestate.keys = 0;
                    DrawKeys ();
                    VW_FadeOut ();

                    ClearMemory ();
                    LevelCompleted ();              // do the intermission
                    DrawPlayScreen();

                    gamestate.oldscore = gamestate.score;
                    if (!SecretLevel::nextLevelAny(gamestate.mapon))
                    {
                        gamestate.mapon++;
                    }
                    break;
        // ...
    }
    linuxwolf
    User avatar

     
    Posts: 5015
    Location: Australia

        

    Postby Officer-Michael John 20 Dec 2016, 11:19

    Now it looks like this GameLoop part:

    Code: Select all
    namespace SecretLevel
    {
        bool nextLevel(int from, int to, short int &mapon)
        {
            if (mapon == to)
            {
                mapon = from + 1;
                return true;
            }

            if (mapon == from && playstate == ex_secretlevel)
            {
                mapon = to;
                return true;
            }

            return false;
        }

        bool nextLevelAny(short int &mapon)
        {
            return SecretLevel::nextLevel(4, 15, mapon) ||
                SecretLevel::nextLevel(12, 16, mapon);
        }
    }

    void GameLoop (void)
    {
        boolean died;
    #ifdef MYPROFILE
        clock_t start,end;
    #endif

    restartgame:
        ClearMemory ();
        ClearMScreen();
        BeginningScreens (); // Beginning Text - Shown when starting new game
        ClearMemory ();
       
        SETFONTCOLOR(0,15);
        VW_FadeOut();
        DrawPlayScreen ();
        died = false;
        do
        {
            if (!loadedgame)
                gamestate.score = gamestate.oldscore;
            if(!died || viewsize != 21)
            {
                ResetScore();
                DrawScore();
            }

            startgame = false;
            if (!loadedgame)
                SetupGameLevel ();

    #ifdef SPEAR
            if (gamestate.mapon == 20)      // give them the key allways
            {
                gamestate.keys |= 1;
                DrawKeys ();
            }
    #endif

            ingame = true;
            if(loadedgame)
            {
                ContinueMusic(lastgamemusicoffset);
                loadedgame = false;
            }
            else StartMusic ();

            if (!died)
                PreloadGraphics ();             // TODO: Let this do something useful!
            else
            {
                died = false;
                fizzlein = true;
            }

            DrawLevel ();

    #ifdef SPEAR
    startplayloop:
    #endif
            PlayLoop ();

    #ifdef SPEAR
            if (spearflag)
            {
                SD_StopSound();
                SD_PlaySound(GETSPEARSND);
                if (DigiMode != sds_Off)
                {
                    Delay(150);
                }
                else
                    SD_WaitSoundDone();

                ClearMemory ();
                gamestate.oldscore = gamestate.score;
                gamestate.mapon = 20;
                SetupGameLevel ();
                StartMusic ();
                player->x = spearx;
                player->y = speary;
                player->angle = (short)spearangle;
                spearflag = false;
                Thrust (0,0);
                goto startplayloop;
            }
    #endif

            StopMusic ();
            ingame = false;

            if (demorecord && playstate != ex_warped)
                FinishDemoRecord ();

            if (startgame || loadedgame)
                goto restartgame;

            switch (playstate)
            {
                case ex_completed:
                case ex_secretlevel:
                    DrawPlayScreen();
                    gamestate.keys = 0;
                    DrawKeys ();
                    VW_FadeOut ();

                    ClearMemory ();
                    LevelCompleted ();              // do the intermission
                    DrawPlayScreen();

                    gamestate.oldscore = gamestate.score;
                    if (!SecretLevel::nextLevelAny(gamestate.mapon))
                    {
                        gamestate.mapon++;
                    }
                    break;

    #ifdef SPEARDEMO
                    if (gamestate.mapon == 1)
                    {
                        died = true;                    // don't "get psyched!"

                        VW_FadeOut ();

                        ClearMemory ();

                        CheckHighScore (gamestate.score,gamestate.mapon+1);
    #ifndef JAPAN
                        strcpy(MainMenu[viewscores].string,STR_VS);
    #endif
                        MainMenu[viewscores].routine = CP_ViewScores;
                        return;
                    }
    #endif

    #ifdef JAPDEMO
                    if (gamestate.mapon == 3)
                    {
                        died = true;                    // don't "get psyched!"

                        VW_FadeOut ();

                        ClearMemory ();

                        CheckHighScore (gamestate.score,gamestate.mapon+1);
    #ifndef JAPAN
                        strcpy(MainMenu[viewscores].string,STR_VS);
    #endif
                        MainMenu[viewscores].routine = CP_ViewScores;
                        return;
                    }
    #endif

                    gamestate.oldscore = gamestate.score;

    #ifndef SPEAR
                    //
                    // 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;
    #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;

                case ex_died:
                    Died ();
                    died = true;                    // don't "get psyched!"

                    if (gamestate.lives > -1)
    //                    break;                          // more lives left
                       
                    {
                     VW_FadeOut();
                     ClearMScreen();
                     ClearMemory ();
                     BeginningScreens (); // Beginning Text
                     ClearMemory ();
                     DrawPlayScreen ();
                     break;                          // more lives left
                    }   

                    VW_FadeOut ();
                    if(screenHeight % 200 != 0)
                        VL_ClearScreen(0);

    #ifdef _arch_dreamcast
                    DC_StatusClearLCD();
    #endif

                    ClearMemory ();

                    CheckHighScore (gamestate.score,gamestate.mapon+1);
    #ifndef JAPAN
                    strcpy(MainMenu[viewscores].string,STR_VS);
    #endif
                    MainMenu[viewscores].routine = CP_ViewScores;
                    return;

                case ex_victorious:
                    if(viewsize == 21) DrawPlayScreen();
    #ifndef SPEAR
                    VW_FadeOut ();
    #else
                    VL_FadeOut (0,255,0,17,17,300);
    #endif
                    ClearMemory ();

                    Victory ();

                    ClearMemory ();

                    CheckHighScore (gamestate.score,gamestate.mapon+1);
    #ifndef JAPAN
                    strcpy(MainMenu[viewscores].string,STR_VS);
    #endif
                    MainMenu[viewscores].routine = CP_ViewScores;
                    return;

                default:
                    if(viewsize == 21) DrawPlayScreen();
                    ClearMemory ();
                    break;
            }
        } while (1);
    }


    I would like to have the 1st secret levels to the specified level and go to the boss and the 2nd level.
    Officer-Michael John
    User avatar

     
    Posts: 131
    Location: Hungary

        

    Postby linuxwolf 20 Dec 2016, 13:56

    You have enough information to do it.
    linuxwolf
    User avatar

     
    Posts: 5015
    Location: Australia

        

    Postby Officer-Michael John 20 Dec 2016, 14:53

    How you gonna do that in a given level to 1st secret level. E.G:Episode 1 Level 1 -->Episode 1 Level 10 (1st secret level).
    Officer-Michael John
    User avatar

     
    Posts: 131
    Location: Hungary

        

    Postby linuxwolf 21 Dec 2016, 01:15

    Update nextLevelAny() function as per your requirements.
    linuxwolf
    User avatar

     
    Posts: 5015
    Location: Australia

        

    Postby Officer-Michael John 21 Dec 2016, 11:50

    I updated,but from 3rd episode can't work secret level. My code buggy? :shock:

    Code: Select all
        bool nextLevelAny(short int &mapon)
        {
            return SecretLevel::nextLevel(0, 9, mapon) ||
                SecretLevel::nextLevel(8, 10, mapon) ||
             SecretLevel::nextLevel(11, 20, mapon) ||
                SecretLevel::nextLevel(19, 21, mapon) ||
             SecretLevel::nextLevel(28, 31, mapon) ||
                SecretLevel::nextLevel(30, 32, mapon) ||
             SecretLevel::nextLevel(35, 42, mapon) ||
                SecretLevel::nextLevel(41, 43, mapon) ||
             SecretLevel::nextLevel(48, 53, mapon) ||
                SecretLevel::nextLevel(52, 54, mapon) ||
             SecretLevel::nextLevel(57, 64, mapon) ||
                SecretLevel::nextLevel(63, 65, mapon);
        }
    }
    Officer-Michael John
    User avatar

     
    Posts: 131
    Location: Hungary

        

    Postby linuxwolf 21 Dec 2016, 15:13

    Not sure. Must be.
    linuxwolf
    User avatar

     
    Posts: 5015
    Location: Australia

        

    Postby Officer-Michael John 21 Dec 2016, 19:52

    So what do I do now?
    Officer-Michael John
    User avatar

     
    Posts: 131
    Location: Hungary

        

    Postby linuxwolf 21 Dec 2016, 23:34

    Debug.
    linuxwolf
    User avatar

     
    Posts: 5015
    Location: Australia

        

    Next

    Return to General Wolf3D/modding Discussion and tutorials


    Who is online

    Users browsing this forum: No registered users and 1 guest