Ensuring a sound will play during PowerTimeFreezer

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Chaosvolt
Posts: 74
Joined: Mon Apr 19, 2021 12:58 pm

Ensuring a sound will play during PowerTimeFreezer

Post by Chaosvolt »

I was trying to figure out if there's any way to rig it so that projectiles and other actors with the NOTIMEFREEZE flag can play sounds during the effect of timefreezing powerups. DeathSound for example doesn't seem to add any special behavior, and fairly certain none of the flags in A_StartSound seem like they'd affect that.

This seems like a general behavior question than a Scripting one specifically, but posted here for lack of a new topic button in the main Editing forum.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Jarewill »

Not as far as I'm aware.
TimeFreezer freezes all sounds and music and there's no way to enable specific sounds, at least no way that I know of.
You can however make all sounds still happen by creating a new powerup in ZScript and using S_ResumeSound/S_PauseSound:
Spoiler:
This will not cause monsters to make noises, since they are frozen and can't access their A_Pain function.

Also, since PowerTimeFreezer is something that is coded, I would say that the scripting subforum is the place for this topic.
User avatar
Chaosvolt
Posts: 74
Joined: Mon Apr 19, 2021 12:58 pm

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Chaosvolt »

Jarewill wrote:Not as far as I'm aware.
TimeFreezer freezes all sounds and music and there's no way to enable specific sounds, at least no way that I know of.
You can however make all sounds still happen by creating a new powerup in ZScript and using S_ResumeSound/S_PauseSound:
Spoiler:
This will not cause monsters to make noises, since they are frozen and can't access their A_Pain function.

Also, since PowerTimeFreezer is something that is coded, I would say that the scripting subforum is the place for this topic.
Seems like that'd be a good workaround to be honest. Plenty enough for the original use case that came to mind, specifically a weapon that grants time freeze as a side effect, I found in testing that the freezing cut off the sound I'd mixed up for it.

EDIT: Just tested and that does the job just perfectly. Thanks!

EDIT 2: One oddity however, pausing the game breaks that entirely.
User avatar
Wally0222
Posts: 22
Joined: Wed Apr 28, 2021 1:18 am
Location: Pantai Remis, Perak, Malaysia

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Wally0222 »

Chaosvolt wrote:EDIT 2: One oddity however, pausing the game breaks that entirely.
I think something has been omitted, so I simply copy the code from gzdoom.pk3 like this.
Spoiler:
I just tested once and it's works perfectly for me, hope it helps.

Note: Erase or disable "S_PauseSound(false, true)" to keep playing music and sounds during PowerTimeFreezer.
User avatar
Chaosvolt
Posts: 74
Joined: Mon Apr 19, 2021 12:58 pm

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Chaosvolt »

Ah, will test that later on.

That said, the "pausing breaks the sounds" thing doesn't seem to prevent the next altfire from still playing its sound (since I have it set so the player can't use the altifre again while under the powerup's duration), so so the problem is a very minor one.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Logan MTM »

Just make a New actor with +Notimefreeze flag and use It to play ALL your sound
User avatar
Wally0222
Posts: 22
Joined: Wed Apr 28, 2021 1:18 am
Location: Pantai Remis, Perak, Malaysia

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Wally0222 »

Logan MTM wrote:Just make a New actor with +Notimefreeze flag and use It to play ALL your sound
The +NOTIMEFREEZE flag won't play ALL sounds during "PowerTimeFreezer", as I tested in the latest GZDoom 4.6.0.
Only creating a new TimeFreezer powerup in ZScript and using/editing S_ResumeSound/S_PauseSound can play all sounds.

Code: Select all

class PowerFreezeMusic : PowerTimeFreezer
{
	Default
	{
		Powerup.Duration -12; // 12 seconds
	}

	override void DoEffect()
	{ // Overriding InitEffect doesn't work here.
		Super.DoEffect();
		S_ResumeSound(false);
		S_PauseSound(false, true); // This will freeze music, but not sound effects.
	}
}
User avatar
Chaosvolt
Posts: 74
Joined: Mon Apr 19, 2021 12:58 pm

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Chaosvolt »

Logan MTM wrote:Just make a New actor with +Notimefreeze flag and use It to play ALL your sound
Basically the first thing I'd tested was to see if the notimefreeze would at least allow specific actors to still play their sounds, sadly that didn't work. The overriding of timefreeze powerup seems to work fine though.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Logan MTM »

Wally0222 wrote:
Logan MTM wrote:Just make a New actor with +Notimefreeze flag and use It to play ALL your sound
The +NOTIMEFREEZE flag won't play ALL sounds during "PowerTimeFreezer", as I tested in the latest GZDoom 4.6.0.
Are you sure? This is exactly what i'm doing here and works fine for me. Well, i use 4.5 anyway. Lets see 4.6!

Yeah! It does! :D

Code: Select all

ACTOR ShellsBelt : CustomInventory 3401
{
Inventory.PickupMessage "$NADA"
Inventory.PickupSound "GotAmmoItems"
FloatBobStrength 0.25
+FLOATBOB
+COUNTITEM
+NOTIMEFREEZE

 States
 {
 Spawn:
 NULL B 1 Bright
 NULL B 70
 Loop
 
 Pickup:
 NULL A 0 ACS_NamedExecute("ShellsBelt",0)
 Stop
 }
}
User avatar
Wally0222
Posts: 22
Joined: Wed Apr 28, 2021 1:18 am
Location: Pantai Remis, Perak, Malaysia

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Wally0222 »

Logan MTM wrote:Are you sure? This is exactly what i'm doing here and works fine for me. Well, i use 4.5 anyway. Lets see 4.6!

Yeah! It does! :D
It works fine for you? I am curiously if you played with any mods that replaces/related to PowerTimeFreezer, or you have modified gzdoom.pk3...

Edit: Check the ACS named "ShellsBelt" first.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Logan MTM »

That actor needs to play the pickupsound. The ACS Just make some hud events.
User avatar
Wally0222
Posts: 22
Joined: Wed Apr 28, 2021 1:18 am
Location: Pantai Remis, Perak, Malaysia

Re: Ensuring a sound will play during PowerTimeFreezer

Post by Wally0222 »

I think the pickup sound can play normally during PowerTimeFreezer (both with and without NOTIMEFREEZE flag), but other sounds such as gunfire and monster attack sound still frozen.
Chaosvolt wrote:I was trying to figure out if there's any way to rig it so that projectiles and other actors with the NOTIMEFREEZE flag can play sounds during the effect of timefreezing powerups. DeathSound for example doesn't seem to add any special behavior, and fairly certain none of the flags in A_StartSound seem like they'd affect that.
Chaosvolt wrote:Basically the first thing I'd tested was to see if the notimefreeze would at least allow specific actors to still play their sounds, sadly that didn't work. The overriding of timefreeze powerup seems to work fine though.
And Chaosvolt already tried the NOTIMEFREEZE flag.
User avatar
camaxide
Posts: 386
Joined: Thu Jun 11, 2015 8:38 am

Re: Ensuring a sound will play during PowerTimeFreezer

Post by camaxide »

Wally0222 wrote: Sat May 29, 2021 9:58 am
Logan MTM wrote:Just make a New actor with +Notimefreeze flag and use It to play ALL your sound
The +NOTIMEFREEZE flag won't play ALL sounds during "PowerTimeFreezer", as I tested in the latest GZDoom 4.6.0.
Only creating a new TimeFreezer powerup in ZScript and using/editing S_ResumeSound/S_PauseSound can play all sounds.

Code: Select all

class PowerFreezeMusic : PowerTimeFreezer
{
	Default
	{
		Powerup.Duration -12; // 12 seconds
	}

	override void DoEffect()
	{ // Overriding InitEffect doesn't work here.
		Super.DoEffect();
		S_ResumeSound(false);
		S_PauseSound(false, true); // This will freeze music, but not sound effects.
	}
}
If I set S_PauseSound(true, true) in order to not pause music - I get a 1 tick pause of the music before it continues - a tiny stutter each time I freeze - can this be solved? is there an error in the code?

Return to “Scripting”