Change Reverb While a PowerUp is Active?

Mon Sep 20, 2021 8:35 am

Is it possible to change the reverb while a powerup is active and then when the powerup runs out, return the game to use whichever reverbs are active in the area where the player is?

I was personally thinking about making a muffled effect to simulate the player wearing an environmental suit but I can also see uses such as "adrenaline-charged distortion" during a berserk, or (not really a powerup) semi-deafness caused by an explosion or whatever.

I'm guessing the something like this might be possible using ZScript but I'm not familiar enough with how it works to do it myself (not from scratch anyway). So, can anyone point me in the direction of a mod that already does something similar, or perhaps even post some code for me to work with?

Thanks. :)

Re: Change Reverb While a PowerUp is Active?

Mon Sep 20, 2021 11:28 am

This is probably the function you want:
struct Sector native play
   native void SetEnvironment(String env);
   native void SetEnvironmentID(int envnum);

Here's the definition of the Sound Environment thing which sets the reverb for whatever sector it's placed in. The part you're interested in is the Activate() function. Note it uses the first and second arg of the thing as low and high bits. I'm not sure if you need to do that if setting the number directly, but it seems you can also just use the name string.

You can get a sector reference several ways, but for this case you probably want to make sure it gets set it for the whole map instead of just the player's current sector / zone. Possible example code:
// in your powerup
PowerupActivatedFunction() {
  for (int i=0; i < level.sectors.size(); i++) {
You may also wish to save the existing environment ID for each sector in an array, instead of resetting back to zero when your powerup is done. I did this in DarkDoomZ for light levels.


Re: Change Reverb While a PowerUp is Active?

Mon Sep 20, 2021 12:22 pm

Thanks, that'll give me something to try and play around with. There's a good chance I'll come unstuck, but I'll definitely give it a go as soon as I get a chance.