Spoiler: My MinigunCode: Select all
class MWSChaingun : MWSWeapon { // I can only hope I never need to touch the minigun code again. private bool minigun; Default { AttackSound "weapons/chngun"; Weapon.SlotNumber 4; Decal "BulletChip"; Weapon.SelectionOrder 700; Weapon.AmmoUse 1; Weapon.AmmoType "Clip"; Weapon.AmmoUse2 1; Weapon.AmmoType2 "Clip"; Weapon.AmmoGive 20; Inventory.PickupMessage "$GOTCHAINGUN"; Obituary "$OB_MPCHAINGUN"; Tag "$TAG_CHAINGUN"; } action void A_ZFireCGun(int damage = 5, double spread_horz = 5.6, double spread_vert = 5.6) { if (MWS_accuratechaingun) { A_FireBullets (0, 0, 1, damage, "BulletPuff"); A_GunFlash(); } else { if(GetCVar("vertspread")) { A_FireBullets (spread_horz, spread_vert, 1, damage, "BulletPuff"); } if(!GetCVar("vertspread")) { A_FireBullets (spread_horz, 0, 1, damage, "BulletPuff"); } A_GunFlash(); } } States { Select: CHGG A 1 A_FastRaise(); Loop; Deselect: CHGG A 1 A_FastLower(); Wait; Ready: CHGG A 1 { invoker.minigun = false; A_MWSReady(WRF_NOSECONDARY); if(player.cmd.buttons & BT_ALTATTACK && !(player.oldbuttons & BT_ALTATTACK)) { return ResolveState("WindUp"); } return ResolveState(null); } Loop; WindUp: PKCG A 1 { A_StartSound("weapons/minigun_start", CHAN_WEAPON); A_MWSReady(WRF_NOFIRE); } //1-frame buffer TNT1 A 0 A_StartSound("weapons/minigun_spin", CHAN_WEAPON, CHANF_LOOPING); PKCG AAABBBCCCDDD 1 { invoker.minigun = true; A_MWSReady(); if(player.cmd.buttons & BT_ALTATTACK && !(player.oldbuttons & BT_ALTATTACK)) { invoker.minigun = false; return ResolveState("MinigunDeactivate"); } return ResolveState(null); } Goto WindUp+2; //Skip the first frame Loop; Fire: PKCG A 0 A_JumpIf(invoker.minigun, "FireMinigun"); PKCG A 0 A_JumpIf(!MWS_responsive, "FireOld"); Goto FireNormal; FireNormal: PKCG "#" 1 A_ZFireCGun(); PKCG BCD 1; PKCG "#" 0 A_ReFire(); Goto CoolDown; FireMinigun: PKCG "#" 0 { A_FireBullets(7, 0, -1, 10, "BulletPuff"); A_GunFlash(); } PKCG BD 1; PKCG "#" 0 A_ReFire(); Goto MinigunCoolDown; FireOld: PKCG A 1 A_ZFireCGun(); PKCG BCD 1; PKCG A 1 A_ZFireCGun(); PKCG BCD 1; PKCG B 0 A_ReFire(); Goto CoolDown; CoolDown: PKCG A 1 A_MWSReady(); PKCG BBCCCDDD 1 A_MWSReady(); Goto Ready; MinigunCoolDown: TNT1 A 0 A_StartSound("weapons/minigun_stop", CHAN_WEAPON); PKCG A 4 A_MWSReady(); PKCG BBCCCDDD 2; Goto WindUp; MinigunDeactivate: TNT1 A 0 A_StopSound(CHAN_WEAPON); TNT1 A 0 A_StartSound("weapons/minigun_stop", CHAN_WEAPON); PKCG A 4 A_MWSReady(); PKCG BBCCCDDD 2; Goto Ready; Flash: TNT1 A 0; TNT1 A 0 A_Jump(128, "Flash2"); PKCF A 1 Bright A_Light1(); PKCF B 1 Bright A_Light2(); TNT1 A 2 A_Light1(); Goto LightDone; Flash2: PKCF C 1 Bright A_Light1(); PKCF D 1 Bright A_Light2(); TNT1 A 2 A_Light1(); Goto LightDone; Spawn: MGUN A -1; Stop; } } [/spoiler]
Spoiler: MWSWeaponThe code itself probably won't solve anything, so https://mega.nz/file/OZJgxZ5B#jclx1WNqg4WLVIJWseh9wHIchT_exc5awNGy2XAVaj8Code: Select all
Class MWSWeapon : Weapon abstract { Default { Weapon.BobStyle "Inverse"; Weapon.Kickback 50; } States { User2: FlashLight: "####" "#" 0 FlashLight(); "####" "#" 0 A_WeaponReady(); "####" "#" 20; "####" "#" 0 ResolveState("Ready"); Stop; // never reached. } action void A_FastRaise(void) { // this is a leftover from when fast weapon switching was tied to responsive weapons being enabled. A_Raise(MWS_switchspeed); } action void A_FastLower(void) { // this is a leftover from when fast weapon switching was tied to responsive weapons being enabled. A_Lower(MWS_switchspeed); } action void A_MoveOverlay(int layer = PSP_WEAPON, double x = 0, double y = 32, int flags = 0) { // introduced to avoid typing WOF_ADD everywhere. WOF_ADD implies WOF_INTERPOLATE. A_OverlayOffset(layer, x, y, WOF_ADD|flags); } action void A_MoveOverlayAbs(int layer = PSP_WEAPON, double x = 0, double y= 32, int flags = 0) { // some offsets are absolute offsets, so to avoid typing WOF_INTERPOLATE all the time i use this. A_OverlayOffset(layer, x, y, WOF_INTERPOLATE|flags); } action void A_MoveWeapon(double x = 0, double y = 32, int flags = 0) { // introduced to avoid typing WOF_ADD everywhere. WOF_ADD implies WOF_INTERPOLATE. A_WeaponOffset(x, y, WOF_ADD|flags); } action void A_MoveWeaponAbs(double x = 0, double y= 32, int flags = 0) { // some offsets are absolute offsets, so to avoid typing WOF_INTERPOLATE all the time i use this. A_WeaponOffset(x, y, WOF_INTERPOLATE|flags); } action void A_SpawnSwirl(string color, int flags = 0) { A_SpawnParticle ( color, SPF_FULLBRIGHT|SPF_RELVEL|SPF_RELACCEL|flags, lifetime:random(50,90), size:frandom(5,10), angle:frandom(0,359), xoff:frandom(-radius,radius), yoff:frandom(-radius,radius), zoff:frandom(height,height+9), velx:frandom(0.5,1.5), velz:frandom(1,2), accelx:frandom(-0.05,-0.2), accelz:-0.1, startalphaf:0.9, sizestep:-0.2 ); } action void FlashLight(void) { EventHandler.SendNetworkEvent("flashlight_plus_toggle"); } action void A_MWSReady(int flags = 0) { A_WeaponReady(MWS_READYFLAGS|flags); } } [/spoiler]
[SOLVED] [ZS] Why do my minigun sounds sound ugly?
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!)
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!)
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
[SOLVED] [ZS] Why do my minigun sounds sound ugly?
My Chaingun with a "press altfire to spin the barrels to shoot faster" thing. Naturally, you'd expect the barrels to make some sounds. Mainly, a "start spinning sound", a "spinning" sound, and a "stop spinning" sound. The problem is my sound sounds terrible.
Spoiler: My Minigun
Last edited by yum13241 on Fri May 12, 2023 2:44 am, edited 1 time in total.
Re: [ZS] Why do my minigun sounds sound ugly?
There isn't much we can do without access to your files and especially your sounds.
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
Open both spoilers. Then, you'll find them.
Re: [ZS] Why do my minigun sounds sound ugly?
Please don't hide the file inside spoilers like that or put it at the very beginning of them, not at the end.
Regardless, changing the WindUp state to this seemed to have improved it:
There is still a cut between the start and spin sounds, but the only way to fix that will be to either make a dedicated StartSpinning state or cutting the sound file a bit in Audacity or similar program.
As for the stop sound not playing, the filename for it is actually called MingunStop.ogg and not MinigunStop.wav.
Regardless, changing the WindUp state to this seemed to have improved it:
Code: Select all
WindUp:
PKCG A 1
{
A_StartSound("weapons/minigun_start", CHAN_WEAPON);
A_MWSReady(WRF_NOFIRE);
} //1-frame buffer
PKCG AAABBBCCCDDD 1
{
invoker.minigun = true;
If(!IsActorPlayingSound(CHAN_WEAPON))
{ //CHANF_NOSTOP included in CHANF_LOOPING only prevents stopping a sound if the sound is the same, otherwise it will replace it no matter what, so I used the above check in its place.
A_StartSound("weapons/minigun_spin", CHAN_WEAPON, CHANF_LOOPING);
}
A_MWSReady();
if(player.cmd.buttons & BT_ALTATTACK && !(player.oldbuttons & BT_ALTATTACK))
{
invoker.minigun = false;
return ResolveState("MinigunDeactivate");
}
return ResolveState(null);
}
Goto WindUp+1; //Skip the first frame
//The loop keyword here was breaking the above keyword, making the first state be executed regardless
As for the stop sound not playing, the filename for it is actually called MingunStop.ogg and not MinigunStop.wav.
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
That was purely unintentional.Please don't hide the file inside spoilers like that or put it at the very beginning of them, not at the end.
D'oh! I fixed that in SNDINFO (on my end obv), but I still can't hear the stop and start sounds. Either they aren't playing or I need to get my hearing checked.As for the stop sound not playing, the filename for it is actually called MingunStop.ogg and not MinigunStop.wav.
Spoiler: new weapon code
Re: [ZS] Why do my minigun sounds sound ugly?
That's odd, it works fine on my end.
Try using the playsound console command to see if it works:
playsound weapons/minigun_start
playsound weapons/minigun_stop
Try using the playsound console command to see if it works:
playsound weapons/minigun_start
playsound weapons/minigun_stop
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
playsound weapons/minigun_start works, but A_StartSound doesn't play it.
playsound weapons/minigun_stop doesn't work, neither does A_StartSound play it.
playsound weapons/minigun_stop doesn't work, neither does A_StartSound play it.
Re: [ZS] Why do my minigun sounds sound ugly?
The only thing that comes to my mind is an issue with SNDINFO, so could you post your updated SNDINFO here?
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
SNDINFO:
weapons/usp "sounds/Weapons/Enforcer/usp.ogg"
weapons/chngun "sounds/Weapons/Enforcer/ENFCFIRE"
weapons/grenadebounce "sounds/Weapons/Grenades/grenadebounce.wav"
weapons/grenadedeploy "sounds/Weapons/Grenades/grenadedeploy.wav"
weapons/grenadeexplode "sounds/Weapons/Grenades/grenadeexplode.wav"
weapons/railshot "sounds/Weapons/Railgun/dsrail.ogg"
weapons/railpwron "sounds/Weapons/Railgun/railon.ogg"
weapons/railpwron2 "sounds/Weapons/Railgun/railchrge.ogg"
misc/flashlight "sounds/Misc./dsclick.ogg" // taken from Zagemod.
weapons/shotfire "sounds/Weapons/shotgun/shotfire.ogg"
weapons/minigun_start "sounds/Weapons/Minigun/MinigunStart.wav"
weapons/minigun_spin "sounds/Weapons/Minigun/MinigunSpin.wav"
weapons/minigun_stop "sounds/Weapons/Minigun/MinigunStop.ogg"
weapons/usp "sounds/Weapons/Enforcer/usp.ogg"
weapons/chngun "sounds/Weapons/Enforcer/ENFCFIRE"
weapons/grenadebounce "sounds/Weapons/Grenades/grenadebounce.wav"
weapons/grenadedeploy "sounds/Weapons/Grenades/grenadedeploy.wav"
weapons/grenadeexplode "sounds/Weapons/Grenades/grenadeexplode.wav"
weapons/railshot "sounds/Weapons/Railgun/dsrail.ogg"
weapons/railpwron "sounds/Weapons/Railgun/railon.ogg"
weapons/railpwron2 "sounds/Weapons/Railgun/railchrge.ogg"
misc/flashlight "sounds/Misc./dsclick.ogg" // taken from Zagemod.
weapons/shotfire "sounds/Weapons/shotgun/shotfire.ogg"
weapons/minigun_start "sounds/Weapons/Minigun/MinigunStart.wav"
weapons/minigun_spin "sounds/Weapons/Minigun/MinigunSpin.wav"
weapons/minigun_stop "sounds/Weapons/Minigun/MinigunStop.ogg"
Re: [ZS] Why do my minigun sounds sound ugly?
The stop sound not working is due to a typo.
As I mentioned, the sound file is actually MingunStop.ogg, without the second i.
It's useful to copy-paste the sound names into SNDINFO to avoid such issues.
As for the start sound not working, frankly I have no idea.
Copying your updated code and running it myself still makes the sound play.
Edit: Try this.
Maybe I did another change I simply forgot that was essential in making this work.
But if this doesn't work, then I'm out of ideas.
As I mentioned, the sound file is actually MingunStop.ogg, without the second i.
It's useful to copy-paste the sound names into SNDINFO to avoid such issues.
As for the start sound not working, frankly I have no idea.
Copying your updated code and running it myself still makes the sound play.
Edit: Try this.
Maybe I did another change I simply forgot that was essential in making this work.
But if this doesn't work, then I'm out of ideas.
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
I didn't see thatAs I mentioned, the sound file is actually MingunStop.ogg, without the second i.

EDIT: Your edited version makes the stop sound play, but I fixed that in my version by changing the sound file name.
The start sound never plays in either case.
- Player701
-
- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
As for why the start sound is not playing, see here for details. I assume the issue was closed as "not a bug", as the current behavior hasn't changed since then.
upd: This might be a potential engine bug, as I can see IsActorPlayingSound is already used. It can be worked around by adding the sound name in there, e.g. if (!IsActorPlayingSound(CHAN_WEAPON, "weapons/minigun_start") { A_StartSound(...); }.
Investigating further now.
upd2: This has already been fixed in development builds, for GZDoom 4.10 and below please use the above workaround.
upd: This might be a potential engine bug, as I can see IsActorPlayingSound is already used. It can be worked around by adding the sound name in there, e.g. if (!IsActorPlayingSound(CHAN_WEAPON, "weapons/minigun_start") { A_StartSound(...); }.
Investigating further now.
upd2: This has already been fixed in development builds, for GZDoom 4.10 and below please use the above workaround.
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: [ZS] Why do my minigun sounds sound ugly?
Thanks, your solution worked!
Spoiler: MWSWeapon
Spoiler: Working MinigunThere's an annoying cut in the sounds, but I guess I'll have to live with it since I'm trash at sound editing lol.