Firing Sound Question

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze 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.
Post Reply
User avatar
Valherran
Posts: 1405
Joined: Tue Oct 27, 2009 12:58 pm

Firing Sound Question

Post by Valherran »

In Slade 3, Is there a way to make a weapon play 1 continuous sound while holding down the fire button? If yes, is there a way to make it start at random intervals of the sound file?
User avatar
Cherno
Posts: 1311
Joined: Tue Dec 06, 2016 11:25 am

Re: Firing Sound Question

Post by Cherno »

You can loop a sound with A_PlaySound. Assign certain channel and make it loop in the firing state. In the other states (or possible at the end of the firing state), play on the same channel again but stop the looping.

You can only play sound effects from the start.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Firing Sound Question

Post by Enjay »

And just to add to that, if/when you want the sound to stop, you may also find [wiki]A_StopSound[/wiki] useful.
User avatar
Valherran
Posts: 1405
Joined: Tue Oct 27, 2009 12:58 pm

Re: Firing Sound Question

Post by Valherran »

Nice, I will give it a shot.
User avatar
Valherran
Posts: 1405
Joined: Tue Oct 27, 2009 12:58 pm

Re: Firing Sound Question

Post by Valherran »

GRRR, this is harder than I thought it would be for me...

This minigun I am trying to change the sound on uses the primary fire as a start-up sequence (chain spin-up), and then uses a hold function to fire the bullets after. Somehow this thing is rigged to perform everything twice in quick succession as a means of double ROF I am assuming. The default sound it came with is a second and a half long and it rapidly plays that sound per shot, which is why it sounds like crap. And because it is doing that, I can't figure out how to get it to play the sound for as long I am firing bullets.

Code: Select all

ACTOR MiniGun : BrutalWeapon
{
	Game Doom
	SpawnID 28
	Weapon.SelectionOrder 700
	Weapon.AmmoType1 "Clip2"
	Weapon.AmmoGive 0
	Weapon.AmmoUse1 1
	+WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+FORCEXYBILLBOARD
	Inventory.PickupSound "CBOXPKUP"
	Inventory.PickupMessage "You got the Minigun!"
	Obituary "%o was mowed down by %k's Minigun."
	AttackSound "none"
	Scale 0.9
	States
	{
	Spawn:
		MGUN A 1
		MGUN A -1
		Stop
		
		 Ready: 
		 Ready3:
		  CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		
		  CHAG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		  CHAG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		  CHAG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		  CHAG A 1 A_WeaponReady
		  CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		  CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			
		  CHAG A 0 A_JumpIfInventory("Spin",1,"Ready2")
		  CHAG A 0 A_JumpIfInventory("Clip2",1,"Ready")
		  Goto IdleNoAmmo
		  
		  IdleNoAmmo:
		  CHAE A 1 A_WeaponReady
		  CHAG A 0 A_TakeInventory ("Spin",1)
		  CHAG A 0 A_JumpIfInventory("Clip2",1,"Ready")
		  CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		  CHAG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		  CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		  Loop

		Ready2:
		  CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		  CHAG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		  CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		  CHAG ABCD 1 A_WeaponReady 
		  CHAG A 0 A_AlertMonsters
		  CHAG A 0 A_PlaySound("CHAINSPI", 5)
		  Loop
		  
	CheckSprint:
		CHAG A 1 A_WeaponReady(WRF_NOFIRE)
		CHAG A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		CHAG A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		CHAG A 1 A_WeaponReady(WRF_NOFIRE)
		CHAG A 0 A_Takeinventory("Zoomed",1)
		CHAG A 0 A_Takeinventory("ADSmode",1)
		CHAG A 0 A_ZoomFactor(1.0)
		CHAG A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		CHSP A 0 offset(-9,32) 
		CHAG A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		CHAG A 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		CHAG A 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
		CHAG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 9)
		CHAG A 0 offset(-9,32)
		CHSP A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(0,38) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(3,36) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(6,34) A_SetPitch(pitch -0.5)
		CHSP A 1 offset(9,32) A_SetPitch(pitch -0.5)
		CHAG A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        CHAG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		CHAG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 9)
		CHAG A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		CHSP A 1 offset(9,34) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(6,36) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(3,38) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(0,38) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		CHSP A 1 offset(-9,32) A_SetPitch(pitch +0.5)
		CHAG A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		CHAG A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		CHAG A 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		CHAG A 0 A_PlaySound("Tired", 2)
		CHAG A 0 A_TakeInventory("UsedStamina", 2)
		CHAG A 5 A_WeaponReady
		CHAG A 0 A_TakeInventory("UsedStamina", 2)
		CHAG A 5 A_WeaponReady
		CHAG A 0 A_TakeInventory("UsedStamina", 2)
		CHAG A 5 A_WeaponReady
		CHAG A 0 A_TakeInventory("UsedStamina", 2)
		CHAG A 5 A_WeaponReady
		CHAG A 0 A_TakeInventory("UsedStamina", 2)
		CHAG A 5 A_WeaponReady
		Goto Ready
	StopSprint:
		CHSP A 1
		CHAG A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready 

		Deselect:
			CHAG A 0 A_TakeInventory ("Spin",1)
			CHAG A 0 A_TakeInventory("TossGrenade", 1)
			CHAG A 0 A_Takeinventory("HeavyAutomaticWeapon",1)
			CHAG A 0 A_TakeInventory("RandomHeadExploder", 1)
			CHAG A 0 SetPlayerProperty(0,0,0)
			CHGS DCBA 1
			TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
			TNT1 A 1 A_Lower
			Wait

		Select:
			CHAG A 0
			CHAG A 0 A_Giveinventory("GoSpecial",1)
			CHAG A 0 A_Giveinventory("HeavyAutomaticWeapon",1)
			CHAG A 0 A_Takeinventory("FistsSelected",1)
			CHAG A 0 A_Takeinventory("SawSelected",1)
			CHAG A 0 A_Takeinventory("ShotgunSelected",1)
			CHAG A 0 A_Takeinventory("SSGSelected",1)
			CHAG A 0 A_Giveinventory("MinigunSelected",1)
			CHAG A 0 A_Takeinventory("PlasmaGunSelected",1)
			CHAG A 0 A_Takeinventory("RocketLauncherSelected",1)
			CHAG A 0 A_Takeinventory("GrenadeLauncherSelected",1)
			CHAG A 0 A_Takeinventory("BFGSelected",1)
			CHAG A 0 A_Takeinventory("BFG10kSelected",1)
			CHAG A 0 A_Takeinventory("RailGunSelected",1)
			CHAG A 0 A_Takeinventory("SubMachineGunSelected",1)
			CHAG A 0 A_Takeinventory("RevenantLauncherSelected",1)
			CHAG A 0 A_Takeinventory("LostSoulSelected",1)
			CHAG A 0 A_Takeinventory("FlameCannonSelected",1)
			CHAG A 0 A_Takeinventory("HasBarrel",1)
			CHAG A 0 A_TakeInventory("TossGrenade", 1)
			CHAG A 0 A_GiveInventory("RandomHeadExploder", 1)
			CHAG A 0 A_JumpIfInventory("IsPlayingAsPurist", 1, "PuristGun")
			CHAG A 0 A_PlaySound("CHGNPKUP")
			CHGS AAAAAA 1 A_Raise
			TNT1 AAAAAA 0 A_Raise
		
		SelectAnimation:
			CHAG A 0
			CHAG A 0 A_GunFlash
			CHGS ABCD 1 A_JumpIfInventory("GoFatality", 1, "Steady")
			Goto Ready

		NoAmmo:
			CHAE A 10 A_PlaySound("weapons/empty")
			Goto IdleNoAmmo
			
			
		Fire:
			CHAG A 0
			CHAG A 0 A_JumpIfInventory("Spin",1,"Hold")
			CHAG A 0 A_PlaySound("CHAINSTA", 5)
			CHAG A 0 BRIGHT A_FireCustomMissile("Alerter", 0, 0, 0, 0)
			CHAG BC 1
			CHAG D 1
			CHAG AB 1
			CHAG A 0 A_StopSound(5)
			//CHAG A 0 A_PlaySound("CHAINSPI", 5)
			CHAG A 0
		Hold:
			CHAG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			CHAG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			
			CHAG A 0 A_PlaySound("CHGNSHOT", 1)
			CHAG A 0 A_PlaySound("FARMGN", 5)
			CHAG A 0 A_ZoomFactor(0.98)
			
			CHAF A 1 BRIGHT A_FireBullets(5, 5, -1, 16, "MachineGunBulletPuff", FBF_NORANDOM | FBF_USEAMMO)

			CHAG A 0 A_Firecustommissile("50CaseSpawn",0,0,-12,-18)
			CHAG A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
			CHAF A 0 BRIGHT A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 0, -12, 0, random(-2,2))
			CHAG A 0 A_ZoomFactor(1.0)
			CHAG A 0 A_JumpIfInventory("IsTacticalClass", 1, 2)//Tactical mode skips a frame, fires faster
			CHAF B 1
			CHAG A 0
			
			RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
			RIFG A 0 A_SetPitch(pitch-1.0)
			RIFG A 0
			
			CHAG A 0 A_PlaySound("CHGNSHOT", 1)
			CHAG A 0 A_PlaySound("FARMGN", 5)
			CHAG A 0 A_ZoomFactor(0.98)
			//TNT1 AA 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
			//RIFF A 0 A_FireCustomMissile("GunFireSmoke", 0, 0, 0, -5, 0, 0)
			CHAF C 1 BRIGHT A_FireBullets(5, 5, -1, 16, "MachineGunBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
			CHAG A 0 A_Firecustommissile("50CaseSpawn",0,0,-12,-18)
			CHAG A 0 A_SpawnItemEx("PlayerMuzzle3",30,5,27)
			CHAF A 0 BRIGHT A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 0, -12, 0, random(-2,2))
			CHAG A 0 A_ZoomFactor(1.0)
			CHAG A 0 A_JumpIfInventory("IsTacticalClass", 1, 2)//Tactical mode skips a frame, fires faster
			CHAF D 1
			CHAG A 0
			
			RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
			RIFG A 0 A_SetPitch(pitch-1.0)
			RIFG A 0
			
			
			MNGG B 0 A_ReFire
			CHAG A 0 A_PlaySound("MINIGEN", 5)
			CHAG A 0 A_JumpIfInventory("Spin",1,"Ready2")
			
		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 CHAG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		 CHAG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		 CHAG A 0 A_PlaySound("CHAINSTO", 5)
		 CHAG A 1 A_WeaponReady
		
		 CHAG B 1 A_WeaponReady
		 CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		 CHAG A 0 A_Refire
		
		 CHAG C 1 A_WeaponReady
		 CHAG A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		 CHAG D 1 A_WeaponReady
				

		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 
		 CHAG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		 CHAG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		 CHAG A 1 A_WeaponReady
		 CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		
		 CHAG B 1 A_WeaponReady
		 CHAG A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		 CHAG C 2 A_WeaponReady
		
		 CHAG D 2 A_WeaponReady
		 CHAG A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		 CHAG A 0 A_JumpIfInventory("Spin",1,"Ready2") 
		 CHAG A 0 A_TakeInventory("Spin", 1)
		 CHAG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		 CHAG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		 CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		 
		 CHAG A 2 A_WeaponReady
		
		 CHAG B 2 A_WeaponReady
		 CHAG A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		 CHAG C 2 A_WeaponReady
		
		 CHAG D 2 A_WeaponReady
		 CHAG A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		 CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		 CHAG ABCD 2 A_WeaponReady
		 CHAG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		 CHAG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		 CHAG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		 CHAG ABCD 3 A_WeaponReady
		 
		 goto Ready



	  AltFire:
		 
		 CHAG A 0 A_JumpIfInventory("Spin",1,"StopAlt")
		 CHAG A 0 A_GiveInventory ("Spin",1)
		 //CHAG A 0 SetPlayerProperty(0,1,0)
		  CHAG A 0 A_PlaySound("CHAINSTA", 5)
		  CHAG A 0 A_JumpIfInventory("Clip2",1,1)
		  Goto IdleNoAmmo
		 CHAG ABCD 2
		 CHAG A 0
		 Goto Ready2

	  StopAlt:
		CHAG A 0
		 CHAG A 0 A_TakeInventory ("Spin",1)
		 CHAG A 0 A_PlaySound("CHAINSTO", 6)
		 CHAG A 0 A_StopSound(5)
		 CHAG A 0 A_StopSound(1)
		 //CHAG A 0 SetPlayerProperty(0,0,0)
		 CHAG ABCD 1
		 CHAG ABCDABCD 2 A_WeaponReady
		 CHAG ABCD 3 A_WeaponReady
		 CHAG A 0
		 Goto Ready


		
		
		PuristGun:
			TNT1 A 1
			CHAG A 0 A_GiveInventory("ClassicChaingun", 1)
			CHAG A 0 A_TakeInventory("MiniGun", 1)
			TNT1 A 10
			Goto Ready2	
		
		
		
		}
}
The "CHGNSHOT" sound file would be replaced with my new one, so I need to get that to run and loop for as long as I am firing bullets. How do I go about doing that?
User avatar
Valherran
Posts: 1405
Joined: Tue Oct 27, 2009 12:58 pm

Re: Firing Sound Question

Post by Valherran »

Any info?
Post Reply

Return to “Assets (and other stuff)”