Page 1 of 2
[Gadget Request] Randomized Explosion sounds
Posted: 28 Oct 2009, 19:42
by Forboding Angel
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!
Re: [Gadget Request] Randomized Explosion sounds
Posted: 28 Oct 2009, 22:53
by Argh
I have one in P.U.R.E., see DeathSounds.lua.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 29 Oct 2009, 11:49
by Forboding Angel
whee! thanks!
Re: [Gadget Request] Randomized Explosion sounds
Posted: 29 Oct 2009, 21:49
by Argh
NP, hope that was helpful.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 10 May 2011, 02:58
by Forboding Angel
In case anyone else gets to looking for it later...
Re: [Gadget Request] Randomized Explosion sounds
Posted: 10 May 2011, 23:04
by knorke
copypastafactory.jpg

if you have that many if's it is usually better to use a table.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 10 May 2011, 23:52
by FLOZi
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
Posted: 11 May 2011, 00:02
by knorke
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.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 11 May 2011, 05:51
by knorke
Spring.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 ]
if this is correct, then
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?
Re: [Gadget Request] Randomized Explosion sounds
Posted: 12 May 2011, 04:40
by Forboding Angel
anyone care to re-write and maek attach?
Re: [Gadget Request] Randomized Explosion sounds
Posted: 13 May 2011, 19:46
by knorke
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...
Re: [Gadget Request] Randomized Explosion sounds
Posted: 13 May 2011, 20:42
by FLOZi
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.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 14 May 2011, 01:34
by Forboding Angel
Flozi: Doin' it rite since 1944.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 19 May 2011, 21:48
by FLOZi
Are you interested in keeping the distinctions about gaia/neutral units?
Re: [Gadget Request] Randomized Explosion sounds
Posted: 19 May 2011, 21:59
by smoth
Just a minor thought forb you do know about the sound altering tags? Check the gundam svn and look at the gm sounds
Re: [Gadget Request] Randomized Explosion sounds
Posted: 19 May 2011, 22:21
by Forboding Angel
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.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 19 May 2011, 22:35
by FLOZi
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
Re: [Gadget Request] Randomized Explosion sounds
Posted: 20 May 2011, 05:07
by Forboding Angel
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

Re: [Gadget Request] Randomized Explosion sounds
Posted: 20 May 2011, 11:41
by FLOZi
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.
Re: [Gadget Request] Randomized Explosion sounds
Posted: 20 May 2011, 12:16
by Forboding Angel
O_O have I ever told you that you're a genius?