Unblocking Windows [Updated 11-14-21]

Post your example zscripts/ACS scripts/etc here.

Unblocking Windows [Updated 11-14-21]

Postby Hey Doomer » Wed Nov 10, 2021 9:19 am

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:
You do not have the required permissions to view the files attached to this post.
Hey Doomer
 
Joined: 25 Sep 2021
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Return to Script Library

Who is online

Users browsing this forum: wildweasel and 0 guests