Call of Duty: Black Ops III

Call of Duty: Black Ops III

Not enough ratings
[Scripting] Playing Sounds
By Mysti and 1 collaborators
   
Award
Favorite
Favorited
Unfavorite
Introduction
Hey everyone, I guess this wraps up my "trilogy" of tutorials that covered Models, FX and now Models. This one is a bit harder to do as you need to re-rencode your sounds to specific formats that the engine understands, don't worry I won't skip on explaing that.
Converting Sounds
So, I guess you have the sound you're wanting to use? Good. Let's get into it!
You're gonna need to grab Audacity[www.audacityteam.org] install it and open it up and load your sound. If you get a warning or error about your file being an MP3 you'll need to grab FFMPEG[lame.buanzo.org] for it. This is just a licence issue as to why it's not included defaultly. Anyway yeah. You can open your file by either dragging and dropping it onto Audcaity or go File->Open

Once it's open the first thing we need to do is change the Project Rate, you can find this down the bottom left of your screen

Change it to that value (48000) then go up to file and choose "Export Audio" as we need to save it as a wav, specifically we need to set it to "WAV (Microsoft) signed 16bit PCM" not "WAV (Microsoft) signed 32bit PCM" save it to your "Call of Duty Black Ops III\sound_assets" directory. Don't worry about putting any of the metadata feilds in, we just need it saved, so save it up and we'll get onto putting in the alias file and getting it in our map.


To start off, go to this location: "Call of Duty Black Ops III\share\raw\sound\aliases", open up the user_aliases in Excell (Or your spreadsheet program) we pretty much just need to copy what's in for the test sound, so here's our name is going to be "Awesome" FileSpec is going to be "Awesome.wav" this is where your folder is inside Call of Duty Black Ops III\sound_assets, so if you put it inside another folder make sure to put that here. Template will be UIN_MOD, VolMin and VolMax can be anything from 0 - 100, but let's leave it at 80, now save the file and close it, we're done with the hard parts, now we just need to put a script origin in Radiant where we want it to play, and then some scripting then we're done! So let's go!
Radiant Requirements [Optional]
I say this is optional since you might want to play this globally, or from a models position so you won't need to add a script_origin for it.

It's up to you for what you're going to do, but if you're going to add a script_origin or another ent, give it KVPs like this

Key
Value
targetname
MusicOrigin

Then let's move onto the script side!
Scripting Side
So, if you setup a trigger do your magic with that, however whatever you've set up you can test using these functions

//One foreach(Player in GetPlayers()) { Player playlocalsound("awesome"); } //Two SoundPos = GetEnt("MusicOrigin","targetname"); SoundPos playsound("awesome"); //Three SoundPos = GetEnt("MusicOrigin","targetname"); playsoundatposition(SoundPos.origin, "awesome");

The first one will play a local sound to that player only, which can be useful for easter eggs.
The second one will play at a models location, from the model, so if you walk around it, it will sound like you are.
The third one will play at that location as an omni sound, like it's coming from nowhere, you'd need to play in game to understand what I mean.


Anyway, that's sounds! So woohoo! You did it.
Final Words
Well, that's that everyone. Thanks for reading, I hope you understood it all, if not as usual just add me and I'll walk you through it.


Thanks, Johnathon.