[Gadget Request] Randomized Explosion sounds

[Gadget Request] Randomized Explosion sounds

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

[Gadget Request] Randomized Explosion sounds

Post 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!
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: [Gadget Request] Randomized Explosion sounds

Post by Argh »

I have one in P.U.R.E., see DeathSounds.lua.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post by Forboding Angel »

whee! thanks!
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: [Gadget Request] Randomized Explosion sounds

Post by Argh »

NP, hope that was helpful.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post by Forboding Angel »

In case anyone else gets to looking for it later...
DeathSounds.lua
(10.07 KiB) Downloaded 65 times
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: [Gadget Request] Randomized Explosion sounds

Post by knorke »

copypastafactory.jpg :shock:
if you have that many if's it is usually better to use a table.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: [Gadget Request] Randomized Explosion sounds

Post 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 )
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: [Gadget Request] Randomized Explosion sounds

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: [Gadget Request] Randomized Explosion sounds

Post 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?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post by Forboding Angel »

anyone care to re-write and maek attach?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: [Gadget Request] Randomized Explosion sounds

Post 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...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: [Gadget Request] Randomized Explosion sounds

Post 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.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post by Forboding Angel »

Flozi: Doin' it rite since 1944.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: [Gadget Request] Randomized Explosion sounds

Post by FLOZi »

Are you interested in keeping the distinctions about gaia/neutral units?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: [Gadget Request] Randomized Explosion sounds

Post 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
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: [Gadget Request] Randomized Explosion sounds

Post 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
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post 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 :-)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: [Gadget Request] Randomized Explosion sounds

Post 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.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Gadget Request] Randomized Explosion sounds

Post by Forboding Angel »

O_O have I ever told you that you're a genius?
Post Reply

Return to “Lua Scripts”