Fluid Motion [Updated 1/2/22]

Post your example zscripts/ACS scripts/etc here.

Fluid Motion [Updated 1/2/22]

Postby Hey Doomer » Fri Nov 26, 2021 5:06 am

ZDoom can have various 3D water effects that are more or less convincing, which of course don't affect existing maps. Otherwise fluids are flat and somewhat disappointing textures. So this is my minimalist take to improve that.

Zscript:
Code: Select allExpand view
class fm_PostProcessor : LevelPostProcessor
{
   // add sector tags by flat name
   protected void Apply(Name checksum, String mapname)
   {
      Array<string> fluids = {
         "NUKAGE1",
         "NUKAGE2",
         "NUKAGE3",
         "FWATER1",
         "FWATER2",
         "FWATER3",
         "FWATER4"
      };
      int start = Cvar.FindCVar("fm_start").GetInt();
      int FLOOR = 0;
      TexMan texture;
      for (int i = 0; i < Level.Sectors.Size(); i++)
      {
         textureid floorid = Level.Sectors[i].GetTexture(FLOOR);
         if (fluids.Find(texture.GetName(floorid)) != fluids.Size())
         {
            AddSectorTag(i, start);
            start++;
         }
      }
      Cvar.FindCVar("fm_end").SetInt(start);
   }
}


The purpose above is to attach a different tag to each sector with a fluid flat and store the tag range in cvars. I didn't see a simpler way to do this on an existing map. Note that fm_end isn't really the end of the tag sequence but one beyond, which is deliberate. I also only add this to NUKAGE and FWATER textures, which can be changed by using different textures in the Array declaration. Slime is, well, slimy and not noisy. I suppose blood is another matter, but that would need a different sound. That's possible but beyond this minimalist scope.

ACS:
Code: Select allExpand view
script "fluidmotion" ENTER
{
    // cvars
    int fm_start = GetCVar("fm_start");
    int fm_end = GetCVar("fm_end");

    for (int tag = fm_start; tag < fm_end; tag++)
    {
        if (Random(0,1) == 0)
        {
            SoundSequenceOnSector(tag, "FluidMotion0", SECSEQ_INTERIOR);
        }
        else
        {
            SoundSequenceOnSector(tag, "FluidMotion1", SECSEQ_INTERIOR);
        }
        Floor_Waggle(tag, Random(16,64), Random(4,16), 0, 0);
    }
}


All this does is loop through the range of affected tags and add a sound sequence and Floor_Waggle to the sector. Floor_Waggle is silent and doesn't play platform/floor up and down sounds. That means a sound sequence can be applied to these sectors. This isn't fancy at all. I chose two small, random water sounds.

SNDSEQ:
Code: Select allExpand view
:FluidMotion0
   volumerand 0 30
   playuntildone fm_splash
   delayrand 17 47
   playuntildone fm_pour
   delayrand 17 47
   restart
end

:FluidMotion1
   volumerand 0 30
   playuntildone fm_pour
   delayrand 17 47
   playuntildone fm_splash
   delayrand 17 47
   restart
end


This crudely introduces random elements. It should work on ZDoom water 3D floor effects, too. I suppose it will break if a fluid texture rises and flats change (as in the small chainsaw courtyard in E1M2), since the ACS only fires once.

Update 1/2/22
Spoiler:
You do not have the required permissions to view the files attached to this post.
User avatar
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: No registered users and 1 guest