Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


5 posters

    [code] defusable bombs...

    avatar
    WLHack
    Senior Member
    Senior Member


    Male
    Number of posts : 800
    Age : 35
    Location : Finland
    Registration date : 2007-03-26

    [code] defusable bombs... Empty [code] defusable bombs...

    Post by WLHack Fri May 25, 2007 12:36 am

    This is a really easy tutorial...
    Though I suppose in this tutorial that you have enabled WSJs
    in-game messages and Flamer46s timer display.

    We start from WL_Def.H. Add these lines in the end of the file:
    Code:

    //--Bomb variables

    int bombs;
    int bombcount;

    int active;
    int deact;

    int test;

    //--

    Now open WL_Agent.C (the main code is implemented here),
    and search for "Thrust" (without quotes). Now in the end of the
    function add these lines:

    Code:

    if(*(mapsegs[1] + offset) == 399)  //399 is the objects ID 
    {
      if(!test) //Well, this isn't really needed
      {
        switch(gamestate.mapon) //If you want the object to act differently
        {                                    //from level to level
          case 1:
              if(deact==true){}      //Do nothing...
              else                          //Bombs defused
              {
                if(!active) //Bombs activated?
                {
                    active = true;
                    test = true;               
        gamestate.finaltime = 70l*70; //Set TimerDisplay: 2min
        GetMessage("2 minutes time to defuse the bombs");
                }
              }
            break;
            default: break; //If map isn't defined
        }
      } 
    }

    This code activates the bombs... Now to make them "defusable",
    go to the Cmd_Use function (still in WL_Agent.C)
    and underneath this block:
    Code:

    //
    // use elevator
    //
      buttonheld[bt_use] = true;

    //--
        gamestate.finaltime = 0; //Remember to add this!!!
    //--
        tilemap[checkx][checky]++;   // flip switch
        if (*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) == ALTELEVATORTILE)
              playstate = ex_secretlevel;
        else
              playstate = ex_completed;
          SD_PlaySound (LEVELDONESND);
          SD_WaitSoundDone();
    }

    Add these lines (note: this is based partly on Dugtrios "opening crates"
    code, so remember to credit him too) directly under it:

    Code:

    for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
    {
      if(statptr->tilex == checkx && statptr->tiley == checky &&
        statptr->shapenum == SPR_STAT_X1 && !buttonheld[bt_use])
      {
        buttonheld[bt_use] = true;
        statptr->shapenum = SPR_STAT_X2;

        SD_PlaySound(BONUS1UPSND);
        bombs = bombs+1; //also bombs++; works
        switch(bombs) // for different messages
        {
              case 1: GetMessage("Bombs defused 1/4"); break;
              case 2: GetMessage("Bombs defused 2/4"); break;
              case 3: GetMessage("Bombs defused 3/4"); break;
              case 4: GetMessage("All bombs are now defused.");
                        deact=true; break;
          }
          if(bombs >3) // All bombs defused... No need for timer
            gamestate.finaltime=0;
      }
    }

    Note: "SPR_STAT_X1" and "SPR_STAT_X2" are the definitions for
    the active bomb and the defused bomb... Change the X1,X2 to match
    the sprite you have selected (make sure they're blocking ones in WL_Act1.C)...
    Or you can just define new sprites in the source.

    Then the final touchups. Open WL_Play.C, and scroll down to "Playloop" and add
    these lines in to it:

    Code:

    if(active)
      {
      bombcount += tics;
      if(bombs <4) //Check wether all bombs are defused in time.
      {
          if(bombcount > 70l*70) //two minutes
          {  playstate = ex_died;//kill player
                            active = false;
          }
      }
      else //Player made it on time
      {
          bombcount = 0;
          active = false;
          deact = true;
      }
    }
    #endif

    Now last thing to do is to add these line:
    Code:

     active = false;
     gamestate.finaltime=0;
     bombcount=0;
     bombs = 0;
     deact = false;
    to the "NewGame" - function in WL_Main.C and in the
    "Died" - function in WL_Game.C...

    Now you just need to compile and you're ready to go...
    In case I didn't forgot to mention something.
    PicNic
    PicNic
    Veteran
    Veteran


    Male
    Number of posts : 1584
    Age : 31
    Registration date : 2007-04-16

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by PicNic Fri May 25, 2007 12:47 am

    you say this is easy? wow, heh because you're really good in coding. Smile
    drchainsaw
    drchainsaw
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 192
    Location : UK
    Hobbie : Wolf3D
    Registration date : 2007-04-01

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by drchainsaw Fri May 25, 2007 6:44 am

    I loved this feature in Operation Wintersturm, good work! Very Happy

    @ Wolf3D Fan - Its just a matter of copy and pasting the code and defining the sprites.



    Mods;
    Castle Hasselhoff
    Nazis With Attitude
    Hitler's Ark
    PicNic
    PicNic
    Veteran
    Veteran


    Male
    Number of posts : 1584
    Age : 31
    Registration date : 2007-04-16

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by PicNic Fri May 25, 2007 6:49 am

    drchainsaw wrote:I loved this feature in Operation Wintersturm, good work! Very Happy

    @ Wolf3D Fan - Its just a matter of copy and pasting the code and defining the sprites.

    No? I dont understand how you all make codes.. heh I only maded changing the amount of otto's rockets.
    Dark_wizzie
    Dark_wizzie
    I am Death Incarnate!
    I am Death Incarnate!


    Female
    Number of posts : 5120
    Age : 30
    Location : California, USA
    Job : Investor
    Hobbie : Computers, chess, computer chess, fashion, and philosophy
    Message : I made this forum when I was 13 High on Drugs
    Registration date : 2007-03-24

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by Dark_wizzie Fri May 25, 2007 4:38 pm

    hm...it requires understanding of the code.
    anyways, nice work. who is flame?
    i remember the time stuff in double trouble, though i never used it...



    Wolf3d Haven
    Minute Logic Blog
    Richter Belmont
    Richter Belmont
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 231
    Age : 34
    Location : New Jersey, USA
    Job : Pushing Carts At Shop-rite
    Hobbie : Makeing Games, Playing Castlevania
    Message : Playing Lord of Shadows And I love it!!!
    Registration date : 2007-07-09

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by Richter Belmont Wed Jun 11, 2008 2:07 pm

    hmmmm i keep on getting "Undefined symbol 'statptr' "
    avatar
    WLHack
    Senior Member
    Senior Member


    Male
    Number of posts : 800
    Age : 35
    Location : Finland
    Registration date : 2007-03-26

    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by WLHack Wed Sep 03, 2008 9:40 am

    Have you defined the statpr to the beginning of CMD_Use?



    Hammer: I can see it now: you and the moon - wear a necktie so I'll know you.
    Building a new webpage...

    Sponsored content


    [code] defusable bombs... Empty Re: [code] defusable bombs...

    Post by Sponsored content


      Current date/time is Thu Nov 21, 2024 3:49 am