[Gadget Request] Randomized Explosion sounds
Moderator: Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
[Gadget Request] Randomized Explosion sounds
Hey guys, I would like a simple gadget that would rotate sounds for unit/weapon explosions randomly from a list?
I assume that pretty much anything can be done with lua, but would anyone be willing to write this for me? I imagine that we could probably all benefit from it.
In case it matters, I'm using luadefs. Thanks!
I assume that pretty much anything can be done with lua, but would anyone be willing to write this for me? I imagine that we could probably all benefit from it.
In case it matters, I'm using luadefs. Thanks!
Re: [Gadget Request] Randomized Explosion sounds
I have one in P.U.R.E., see DeathSounds.lua.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
whee! thanks!
Re: [Gadget Request] Randomized Explosion sounds
NP, hope that was helpful.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
In case anyone else gets to looking for it later...
Re: [Gadget Request] Randomized Explosion sounds
copypastafactory.jpg 
if you have that many if's it is usually better to use a table.

if you have that many if's it is usually better to use a table.
Re: [Gadget Request] Randomized Explosion sounds
Doesn't even need additional tables, Argh just needs to learn how to concatenate to strings.
Code: Select all
PlaySoundFile("sounds/unitdeath/e" .. randomPick .. ".wav",15, x, y, z )
Re: [Gadget Request] Randomized Explosion sounds
or that, if your file names are numbered anyway.
also might want to add check if you really want to play every unit death sound. (enemies outside LOS, canceled construction, lots of units dying at same time,...)
i would guess zerok's unit voice widget does that.
also might want to add check if you really want to play every unit death sound. (enemies outside LOS, canceled construction, lots of units dying at same time,...)
i would guess zerok's unit voice widget does that.
Re: [Gadget Request] Randomized Explosion sounds
if this is correct, thenSpring.PlaySoundFile Plays WAV or OGG sounds.
( string "soundfile" [, number volume = 1.0
[, number posx, number posy, number posz
[, number speedx, number speedy, number speedz ] ] ], [string/number channel ]
PlaySoundFile("sounds/unitdeath/e1.wav",15, x, y, z ) will play sounds at 15x the normal volume. I guess to compensate for the unit <-> camera distance.
uh oh?
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
anyone care to re-write and maek attach?
Re: [Gadget Request] Randomized Explosion sounds
if it works for you, just use it.
or try the voices widget thing from zero k.
or try replacing the if's with the line from Flozi.
I think not many cba to create 32 deathsounds just for testing...
or try the voices widget thing from zero k.
or try replacing the if's with the line from Flozi.
I think not many cba to create 32 deathsounds just for testing...
Re: [Gadget Request] Randomized Explosion sounds
I'll probably rewrite this at some point.
When I do, I'll probably add files to 'death sound classes' based on their subfolder of /sounds/deaths/ which can then be pointed to by unitdef customparams (similar to how my automatic resources.lua works). This will remove the need to name them numerically etc.
When I do, I'll probably add files to 'death sound classes' based on their subfolder of /sounds/deaths/ which can then be pointed to by unitdef customparams (similar to how my automatic resources.lua works). This will remove the need to name them numerically etc.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
Flozi: Doin' it rite since 1944.
Re: [Gadget Request] Randomized Explosion sounds
Are you interested in keeping the distinctions about gaia/neutral units?
Re: [Gadget Request] Randomized Explosion sounds
Just a minor thought forb you do know about the sound altering tags? Check the gundam svn and look at the gm sounds
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
Yeah, I know about them, but tbh while that is one way of doing it (my results with it were kinda blah :-/ ), this way is completely different.
Thing is, I wasn't going to mention it but fuckit, why should I have all the fun? This plays the random sound in addition to the sound you have specified as the death sound in the unitdef.
This is good for a variety of reasons, but basically the volume set in the gadget is slightly lower than the norm. This means that you get the same death sound, but with extras.
For a perfect example, load up the current evo test rev and give yourself several elighttank3 then self d them one at a time. It's pretty cool.
@flozi, yes, because sometimes map features are gaia/neutral units (e.g. gunmetal harbor)
Also, I would like to be able to call it from ANY customparam if that's possible, including weapon customparams. It would be nice to be able to randomize nuke explosions and shit like that.
Thing is, I wasn't going to mention it but fuckit, why should I have all the fun? This plays the random sound in addition to the sound you have specified as the death sound in the unitdef.
This is good for a variety of reasons, but basically the volume set in the gadget is slightly lower than the norm. This means that you get the same death sound, but with extras.
For a perfect example, load up the current evo test rev and give yourself several elighttank3 then self d them one at a time. It's pretty cool.
@flozi, yes, because sometimes map features are gaia/neutral units (e.g. gunmetal harbor)
Also, I would like to be able to call it from ANY customparam if that's possible, including weapon customparams. It would be nice to be able to randomize nuke explosions and shit like that.
Re: [Gadget Request] Randomized Explosion sounds
Explosions will have to be done differently (via SetWatchWeapon and Explosion callin).
The stuff in Argh's gadget is mainly to not play sounds for neutral units, or play them for Gaia units... but the way it's done only units with the customParam will ever play sounds anyway. I don't quite get the idea behind it.
Anyway, completely untested and without the neutral/gaia rules as yet;
http://pastebin.com/Lvz7Vmhg
The stuff in Argh's gadget is mainly to not play sounds for neutral units, or play them for Gaia units... but the way it's done only units with the customParam will ever play sounds anyway. I don't quite get the idea behind it.
Anyway, completely untested and without the neutral/gaia rules as yet;
http://pastebin.com/Lvz7Vmhg
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
That's a good point flozi. I hadn't thought about that honestly...
In looking over the code here, the only real quibble I have is that it seems to be very generic and all encompassing.
Which in a way is good, but for certain units, you need to use a completely different pool of sounds (like nukes, or large units in general).
Regardless, very cool
In looking over the code here, the only real quibble I have is that it seems to be very generic and all encompassing.
Which in a way is good, but for certain units, you need to use a completely different pool of sounds (like nukes, or large units in general).
Regardless, very cool

Re: [Gadget Request] Randomized Explosion sounds
It loads classes from the subdirs of /sounds/deathsounds
So you can have your nuke sounds in /sounds/deathsounds/nuke/ and assign death_sounds = "nuke", in the customParams of your unitdef. => Unit only uses nuke sounds on death.
So you can have your nuke sounds in /sounds/deathsounds/nuke/ and assign death_sounds = "nuke", in the customParams of your unitdef. => Unit only uses nuke sounds on death.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: [Gadget Request] Randomized Explosion sounds
O_O have I ever told you that you're a genius?