Jump to content

Script to play a random clip from a list of voice clips?


Recommended Posts

Seeing what is possible with the GECK and plenty of time, I wanted to try something myself. By the looks of things, I will have to rely on scripts for this one.

I am trying to mimic the TF2 Heavy in FNV, I managed to make the two weapons he uses, might make more items to make it feel more authentic, but I have no clue how to make a taunt function.

Basically, either a button press, or after a killstreak, the player would yell one of the random taunt clips of the Heavy. I'd love to make it randomized, as there is quite the selection of sound clips available.

 

How am I supposed to continue?

 

Thanks to everyone in advance!

Link to comment
Share on other sites

Well the random aspect would be handled by this function http://geck.bethsoft.com/index.php?title=GetRandomPercent

 

Which what that yeilds leads to a choice with this function http://geck.bethsoft.com/index.php?title=PlaySound

 

And you'll need to extract the audio files you want to use from the archive ... with something like this ...

https://www.nexusmods.com/fallout3/mods/34 (which works for FNV also)

 

Then convert those into something the PlaySound fucntion can work with ... which a .wav should work , but maybe an mp3 would work also to save space , but 10-20 short .wav files shouldn't be to bad.

Then place them in your "Data/Sound/YourMod" loose folder.

And in geck create a sound object under "Audio/Sound" in the object tree for each one of those.

 

How your scripting is set up , really depends on the method you want to have it fire the GetRandomPercent line which leads to the PlaySound choice.

 

Which I guess a Quest script running a GameMode block would be best ?

And this Quest gets started and stopped by having the gun equipped.

 

A button press would be the easiest , but you could set up time and integer counters for it also.

So just mention a little more specific for how you want it to work , then can line out that path better for you.

Link to comment
Share on other sites

Here's the formatting:

https://wiki.nexusmods.com/index.php/Getting_started_creating_mods_using_GECK#TIP-AddingASound

 

If you want to make it a sound that plays and isn't technically connected to the player, it can be stereo or mono, but if you want it to come out of the player's mouth, it needs to be mono. There are other formatting guidelines in that link.

 

It seems reasonable that it should work using Say:

https://geckwiki.com/index.php/Say

 

But I've never tried to get the player character to say anything, so you may need to use PlaySound as Mktavish suggests.

 

I would use a button-press event handler for this:

https://geckwiki.com/index.php/SetOnControlDownEventHandler

 

Or you can increment a death count with this:

https://geckwiki.com/index.php/SetEventHandler

 

Either way, GetRandomPercent is still the function you want for randomising the lines. I've found GetRandomPercent to be a little buggy when you don't store its result as a variable first. So, when the conditions are met (the event calls the script, essentially), you'd set/let a variable (iRand would be a popular naming choice) to GetRandomPercent. Then you'd check the value of iRand or whatever you've called your variable, and play a sound or have the player speak a line depending on that value.

 

If you need more detailed help, post back.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...