A functional geiger counter that detects NUKAGE texture

Handy guides on how to do things, written by users for users.
Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.

A functional geiger counter that detects NUKAGE texture

Postby crowbars82 » Tue Jan 09, 2018 2:58 pm

Hi,

I've always wanted a geiger counter sound effect for GZDoom so I worked out the following:

Link to download

To use the mod, place the "Crow_Geiger.zip" into your ZDoom/GZDoom folder and add this line under the "Global.Autoload" section in your "gzdoom-YOURPCNAME.ini":

Code: Select allExpand view
[Global.Autoload]
Path=$PROGDIR/Crow_Geiger.zip


Explained:

Inside Crow_Geiger.WAD I have a decorate file with 1 actor:
Code: Select allExpand view
ACTOR WanderingGeiger
{
   +NOTRIGGER
   +NOBLOCKMONST
   +NOBLOCKMAP
   +DONTSPLASH
   +NOCLIP
   +DROPOFF
   +CANPASS
   +JUMPDOWN
   Speed 2
   Radius 10
   Height 10
   RenderStyle None
   States
   {
   Spawn:
      TNT1 AAA 0 A_Wander(CHF_NORANDOMTURN)
      TNT1 A 1 A_Wander(CHF_NORANDOMTURN)
      Loop
   }
}


Then in the SNDINFO file the follow sounds are defined:

Code: Select allExpand view
GEIGER1 GEIGER1
GEIGER2 GEIGER2
GEIGER3 GEIGER3

$pitchshift GEIGER1 0
$pitchshift GEIGER2 0
$pitchshift GEIGER3 0
$pitchshift GEIGER 0

$random GEIGER {GEIGER1 GEIGER2 GEIGER3}


If the "randomise pitches" is enabled in GZDoom/ZDoom sound options then the geiger counter noises get pitch shifted too, which is not what we want, so the "$pitchshift" entries are to stop this by setting the variance to "0" for these sounds only.

Inside the WAD are 3 separate geiger counter sound effects GEIGER1, GEIGER2 and GEIGER3.

Inside the ACS folder is the following script:

Code: Select allExpand view
#library "crowgeiger"
#include "zcommon.acs"

script "Geiger Counter" ENTER
{
        //set up the variables for use in the script
   int x;
   int y;
   int z;
   int UniqueNoClipTIDA;
   int UniqueNoClipTIDB;
   int UniqueNoClipTIDC;
   int UniqueNoClipTIDD;
   int UniqueNoClipTIDE;
   
   while(true)
      {
                //get the player's current coordinates
      x = GetActorX (0);
      y = GetActorY (0);
      z = GetActorZ (0) + 4.0;
      
                //set unique identifier numbers for the TIDs to assign to the wanderers
      UniqueNoClipTIDA = UniqueTID();
      UniqueNoClipTIDB = UniqueTID();
      UniqueNoClipTIDC = UniqueTID();
      UniqueNoClipTIDD = UniqueTID();
      UniqueNoClipTIDE = UniqueTID();
      
                //spawn wanders defined in the DECORATE file where the player is
      Spawn ("WanderingGeiger", x, y, z, UniqueNoClipTIDA);
      Spawn ("WanderingGeiger", x, y, z, UniqueNoClipTIDB);
      Spawn ("WanderingGeiger", x, y, z, UniqueNoClipTIDC);
      Spawn ("WanderingGeiger", x, y, z, UniqueNoClipTIDD);
      Spawn ("WanderingGeiger", x, y, z, UniqueNoClipTIDE);
      
                //this section tells the wanders to look for the NUKAGE1,2 OR  3 textures underneath themselves
      for (int i = 0; i < 5; i++ )
         {
         if (CheckActorFloorTexture(UniqueNoClipTIDA, "NUKAGE1") || CheckActorFloorTexture(UniqueNoClipTIDA, "NUKAGE2") || CheckActorFloorTexture(UniqueNoClipTIDA, "NUKAGE3"))
            {
            LocalAmbientSound("GEIGER", Random(50,127));
            }
         if (CheckActorFloorTexture(UniqueNoClipTIDB, "NUKAGE1") || CheckActorFloorTexture(UniqueNoClipTIDB, "NUKAGE2") || CheckActorFloorTexture(UniqueNoClipTIDB, "NUKAGE3"))
            {
            LocalAmbientSound("GEIGER", Random(50,127));
            }
         if (CheckActorFloorTexture(UniqueNoClipTIDC, "NUKAGE1") || CheckActorFloorTexture(UniqueNoClipTIDC, "NUKAGE2") || CheckActorFloorTexture(UniqueNoClipTIDC, "NUKAGE3"))
            {
            LocalAmbientSound("GEIGER", Random(50,127));
            }
         if (CheckActorFloorTexture(UniqueNoClipTIDD, "NUKAGE1") || CheckActorFloorTexture(UniqueNoClipTIDD, "NUKAGE2") || CheckActorFloorTexture(UniqueNoClipTIDD, "NUKAGE3"))
            {
            LocalAmbientSound("GEIGER", Random(50,127));
            }
         if (CheckActorFloorTexture(UniqueNoClipTIDE, "NUKAGE1") || CheckActorFloorTexture(UniqueNoClipTIDE, "NUKAGE2") || CheckActorFloorTexture(UniqueNoClipTIDE, "NUKAGE3"))
            {
            LocalAmbientSound("GEIGER", Random(50,127));
            }
         delay(5);
         }
      
                //after a very short while, remove the wanderers and the loop starts again
      Thing_Remove(UniqueNoClipTIDA);
      Thing_Remove(UniqueNoClipTIDB);
      Thing_Remove(UniqueNoClipTIDC);
      Thing_Remove(UniqueNoClipTIDD);
      Thing_Remove(UniqueNoClipTIDE);
      }
}


The script will spawn some invisible actors which will fly out of the player in a straight line. They have noclip enabled too. The "wanderers" fly out of the player and exist only for a few seconds and are removed then the process loops constantly.

During the time the wanders are 'alive' they check for the NUKAGE textures underneath them and if they find it then they will play a random geiger counter sound effect.

Image

You can view the wandering entities flying out of the player by typing the map cheat IDDT twice, first to show the map, second time to show all the entities in the map.

Please let me know if there is anything I am able to do that would make this better or more reliable or if the script could be written less copy-pastey!

Much thanks!
User avatar
crowbars82
 
Joined: 05 Nov 2017

Re: A functional geiger counter that detects NUKAGE texture

Postby XLightningStormL » Mon Jan 28, 2019 12:13 am

The only issue I see with this is the lack of Underwater 3d floor Nukage support, though I assume that's an engine issue, not so much of this mod.
User avatar
XLightningStormL
DUSK Wiki Master
 
Joined: 09 May 2016
Discord: XLightningStormL#7461
Twitch ID: XLightmingStormL

Re: A functional geiger counter that detects NUKAGE texture

Postby Gez » Mon Jan 28, 2019 7:52 am

crowbars82 wrote:Please let me know if there is anything I am able to do that would make this better or more reliable or if the script could be written less copy-pastey!


Make an array for your unique TIDs. Then you can replace the copy-pasted checks for each wanderer by an iteration through the array.
You can also make an array for texture names I think. Pseudocode would be something like this:

Code: Select allExpand view
for (int i = 0; i < 5; ++i) // time loop
{
   for (int tid = 0; tid < 5; ++tid) // TID loop
   {
       for (int name = 0; name < 3; ++name) // texture name loop
       {
           if (CheckActorFloorTexture(uniqueTIDs[tid], texturenames[name]))
               LocalAmbientSound("GEIGER", Random(50, 127));
       }
   }
   delay(5);
}


For legibility and ease of maintenance, you should also probably use named constants instead using 5 or 3 in the loop condition, because here it's not clear that the 5 in the time loop isn't the same as the 5 in the TID loop.
Gez
 
 
 
Joined: 06 Jul 2007


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests