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...


4 posters

    [Code Tutorial]Non-Actor Flame Walls

    Airslide
    Airslide
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 115
    Age : 30
    Location : Central Valley [Formerly Bay Area] (California USA)
    Job : Student
    Hobbie : Indie Game Development
    Registration date : 2007-05-17

    [Code Tutorial]Non-Actor Flame Walls Empty [Code Tutorial]Non-Actor Flame Walls

    Post by Airslide Thu May 24, 2007 8:41 pm

    Well, here's my first big tutorial, so there's bound to be mistakes Very Happy It comes from my project source, so if you have any problems let me know and I'll try to fix it. I said flame wall, but really it is just using the rocket, you'll have to add your own flame projectile. Some credit goes to Wolf3DBreaker, as I used a modified portion of his code for player shooting projectiles in the T_Projectile function (so it will kill guards).

    It uses an object to spawn rockets at set intervals rather than the actor concept I've already seen on these forums. Hopefully this runs alot faster and takes less memory & data bytes.. Also note that I haven't made the switch to turn it off yet, I'll update the tut when I do. Also, you can have as many as you want, however they all currently shoot EAST.

    Okay, here we go. First we'll need to add a new flag, so open up "WL_DEF.H". Look for this code, near the top, and add the red line:
    Code:

    #define FL_SHOOTABLE   1
    #define FL_BONUS      2
    #define FL_NEVERMARK   4
    #define FL_VISABLE      8
    #define FL_ATTACKMODE   16
    #define FL_FIRSTATTACK   32
    #define FL_AMBUSH      64
    #define FL_NONMARK      128
    [color=red]#define FL_KILLALL   16[/color]

    Next, go to the gamestate structure, and add this:

    Code:
       
    int         ammo;
    int         keys;
    weapontype      bestweapon,weapon,chosenweapon,nextweapon;

    [color=red]boolean       firewall;[/color]

    Close that file, and open "WL_PLAY.C". The majority of the code is here. Scroll down to the play loop function (at the very bottom) and add the red lines:

    Code:
    /*
    ===================
    =
    = PlayLoop
    =
    ===================
    */
    long funnyticount;
    [color=red]long fireticount;[/color]


    void PlayLoop (void)
    {
       int      give;
       int   helmetangle;

       playstate = TimeCount = lasttimecount = 0;
       frameon = 0;
       running = false;
       anglefrac = 0;
       facecount = 0;
       funnyticount = 0;
       memset (buttonstate,0,sizeof(buttonstate));
       ClearPaletteShifts ();

       if (MousePresent)
          Mouse(MDelta);   // Clear accumulated mouse movement

       if (demoplayback)
          IN_StartAck ();

       do
       {
          if (virtualreality)
          {
             helmetangle = peek (0x40,0xf0);
             player->angle += helmetangle;
             if (player->angle >= ANGLES)
                player->angle -= ANGLES;
          }


          PollControls();

    //
    // actor thinking
    //
          madenoise = false;

          MoveDoors ();
          MovePWalls ();

          for (obj = player;obj;obj = obj->next)
             DoActor (obj);

          UpdatePaletteShifts ();

          ThreeDRefresh ();

          //
          // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
          //
          #ifdef SPEAR
          funnyticount += tics;
          if (funnyticount > 30l*70)
          {
             funnyticount = 0;
             StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
             facecount = 0;
          }
          #endif
    [color=red]
          fireticount+=tics;
          if (fireticount>100)
             {
             FireScan();
             fireticount=0;
             }
    [/color]

    rest of function skipped...

    Now, at the very bottom of the file, add this:

    Code:
    [color=red]
    /*
    ===================
    =
    = Scan for Firewall
    =
    ===================
    */

    #define FireObject 600

    extern   statetype s_rocket; //For Fire Wall

    void FireScan (void)
    {
    int x,y,tile;

    if (gamestate.firewall==true) //No sense scanning if it isn't on
       {
       for (y=0;y<mapheight;y++)
          for (x=0;x<mapwidth;x++)
          {
             tile=MAPSPOT(x,y,1);
             if (tile==FireObject)
             {
             GetNewActor ();
             new->state = &s_rocket;
             new->ticcount = 1;

             new->tilex = x;
             new->tiley = y;
             //new->x = ob->x;
             //new->y = ob->y;
             new->x = ((long)x<<TILESHIFT)+TILEGLOBAL/2;
             new->y = ((long)y<<TILESHIFT)+TILEGLOBAL/2;
             new->obclass = rocketobj;
             new->dir = nodir;
             new->angle = 0;
             new->speed = 0x2000l;
             new->flags = FL_NONMARK | FL_KILLALL;
             new->active = true;
             }
                
                
          }
       }

    }[/color]

    FireObject is whatever object you want to spawn the fire. You could modify this to include multible objects for diffrent directions.

    Now close that file, and open up "WL_ACT2.C". Go to the T_Projectile function, and add the red lines:

    Code:

          // Check if player hit by anything

    [color=red]
       if (ob->obclass == rocketobj && ob->flags & FL_NONMARK && ob->flags & FL_KILLALL)
          {
           check = objlist ;
             while (check)
             {
            if (check->flags & FL_SHOOTABLE)
            {
                deltax = LABS(ob->x - check->x);
                deltay = LABS(ob->y - check->y);

                if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE)
                {
                  //if (check->obclass != angelobj)
                          //  PlaySoundLocActor(MISSILEHITSND,ob);
                  ob->state = &s_boom1;     
                  damage = (US_RndT() >>3) + 30;
                  DamageActor (check,damage);
                 
                }
            }
            check = check->next ;
          }
        }   [/color]

          deltax = LABS(ob->x - player->x);
          deltay = LABS(ob->y - player->y);

          if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE)
          {  // hit the player
            switch (ob->obclass)
            {
            case needleobj:
                damage = (US_RndT() >>3) + 20;
                break;
            case rocketobj:
            case hrocketobj:
                //  case sparkobj:
                damage = (US_RndT() >>3) + 30;
                break;

    rest of code not included...

    Close that file. Now, I'm assuming you'll want the firewalls to come on every level if you add a switch to turn them off...simple. Open up "WL_INTER.C". In the PreloadGraphics function, add this:

    Code:

       LatchDrawPic (20-14,80-3*8,GETPSYCHEDPIC);

       WindowX = 160-14*8;
       WindowY = 80-3*8;
       WindowW = 28*8;
       WindowH = 48;
       VW_UpdateScreen();
       VW_FadeIn ();

       PM_Preload (PreloadUpdate);
       IN_UserInput (70);
       VW_FadeOut ();

       DrawPlayBorder ();
       VW_UpdateScreen ();

       [color=red]//Update Variables
       gamestate.firewall=true;[/color]
    }

    Ta da! Now place object 600 in your favorite map editor (preferably in front of a wall) and watch rockets fly from it! I'll add the code for the switch later. Remeber to give credit, and please report any bugs!

    EDIT: Seems red doesn't work in code boxes like on DHW. Well, just add what's between the [color] boxes, don't actually add those Very Happy



    [Code Tutorial]Non-Actor Flame Walls Marchtowarsigez7
    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 Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

    Post by Dark_wizzie Thu May 24, 2007 9:48 pm

    interesting, like in eod.
    how much damage does it do? 1 hit ko?



    Wolf3d Haven
    Minute Logic Blog
    ronwolf1705
    ronwolf1705
    Hardcore Wolfer
    Hardcore Wolfer


    Male
    Number of posts : 1252
    Age : 33
    Registration date : 2007-03-26

    [Code Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

    Post by ronwolf1705 Fri May 25, 2007 5:07 am

    It does the same damage as rockets.
    drchainsaw
    drchainsaw
    Bring em' On!
    Bring em' On!


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

    [Code Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

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

    Good Stuff Airslide! Cool



    Mods;
    Castle Hasselhoff
    Nazis With Attitude
    Hitler's Ark
    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 Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

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

    in the eod it is 1 hit ko, although rokets are fine.



    Wolf3d Haven
    Minute Logic Blog
    Airslide
    Airslide
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 115
    Age : 30
    Location : Central Valley [Formerly Bay Area] (California USA)
    Job : Student
    Hobbie : Indie Game Development
    Registration date : 2007-05-17

    [Code Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

    Post by Airslide Fri May 25, 2007 7:05 pm

    Just FYI, updated tut is here:
    http://diehardwolfers.areyep.com/viewtopic.php?t=4487
    Didn't feel like updating the one above, and it should be easier to read on DHW.



    [Code Tutorial]Non-Actor Flame Walls Marchtowarsigez7

    Sponsored content


    [Code Tutorial]Non-Actor Flame Walls Empty Re: [Code Tutorial]Non-Actor Flame Walls

    Post by Sponsored content


      Current date/time is Thu Nov 21, 2024 12:46 am