Page 1 of 1

Unblocking Windows [Updated 11-14-21]

PostPosted: Wed Nov 10, 2021 9:19 am
by Hey Doomer
One of my peeves with Doom level design is arbitrary windows that allow projectiles through but not the player. This is my take on unblocking those windows to let the player jump through them.

CVars:
Code: Select allExpand view
user bool win_window = false;
user bool win_win2floor = false;
user bool win_win2ceiling = false;
user bool win_blocking = true;


win_blocking unblocks all two-sided lines. The others give more control depending on the status of DONTPEGTOP and DONTPEGBOTTOM. win_window unblocks "real" windows, for example.

ZScript:
Code: Select allExpand view
class windows_EventHandler : EventHandler
{
   override
   void WorldLoaded(WorldEvent e)
   {
      int BLOCKING = 1;                 // bit 0x0001
      int TWOSIDED = 2;                 // bit 0x0004
      int DONTPEGTOP = 4;               // bit 0x0008
      int DONTPEGBOTTOM = 8;            // bit 0x0010

      for(int i = 0; i < Level.Sectors.Size(); i++)
      {
         for (int ii = 0; ii < Level.Sectors[i].lines.Size(); ii++)
         {
            int f = Level.Sectors[i].lines[ii].flags;
            int peg_top = f & (BLOCKING + TWOSIDED + DONTPEGTOP);
            int peg_bottom = f & (BLOCKING + TWOSIDED + DONTPEGBOTTOM);
            int blocking = f & (BLOCKING + TWOSIDED);

            if (CVar.FindCVar("win_window").GetBool() && peg_top && peg_bottom)
            {
               Level.Sectors[i].lines[ii].flags = f ^ BLOCKING;
            }
            if (CVar.FindCVar("win_win2floor").GetBool() && peg_top && !peg_bottom)
            {
               Level.Sectors[i].lines[ii].flags = f ^ BLOCKING;
            }
            if (CVar.FindCVar("win_win2ceiling").GetBool() && !peg_top && peg_bottom)
            {
               Level.Sectors[i].lines[ii].flags = f ^ BLOCKING;
            }
            if (CVar.FindCVar("win_blocking").GetBool() && blocking)
            {
               Level.Sectors[i].lines[ii].flags = f ^ BLOCKING;
            }
         }
      }
   }
}


This seems to work, although I haven't tested it extensively with different kinds of windows in different levels. It doesn't check for adjacent sector exits, and it's possible to jump through a window and get stuck, a peril of self-defenestration.

Update 11/14/21
Spoiler:

Re: Unblocking Windows [Updated 11-14-21]

PostPosted: Thu Dec 02, 2021 8:13 pm
by thugsta
Nice mod, is there any chance you can add a window panel to the windows? That will also be a nice touch to those empty holes, maybe you can even shoot them and hearing a smash noise with the window disappearing or leaving it partially shattered around it's edge of the window hole.

Just some idea if you want to extend this. Thanks for bring this some attention.

Re: Unblocking Windows [Updated 11-14-21]

PostPosted: Fri Dec 03, 2021 5:05 am
by Hey Doomer
That will also be a nice touch to those empty holes


You are correct. Empty holes that may or may not be solid windows are an annoyance. I may do that as a separate mod, since it's somewhat different from just changing line flags. Great idea and definitely a quality of life thing in Doom.