Frictional Games Forum (read-only)
How to script sounds - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to script sounds (/thread-9847.html)



How to script sounds - Khan - 08-18-2011

I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?


RE: How to script sounds - zeravia - 08-18-2011

(08-18-2011, 02:49 PM)Khan Wrote: I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?

isint it this?

void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);


RE: How to script sounds - Khan - 08-18-2011

(08-18-2011, 03:16 PM)zeravia Wrote:
(08-18-2011, 02:49 PM)Khan Wrote: I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?

isint it this?

void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);


Ok, so like, when you place down a sound thing in game, and pick a sound to play, do you need to script that? And make an area for the player to walk into to triger it? And if so, exactly wat would that script be, lets say I pick something like "Prisoner_Scream" how would I script that into an area and make it go off when I hit that area?


Im thinking (this my fail noob script skills) I make a Player colide, name it all that stuff, then make a void function with the same thing you have? so something like this?

Void OnEnter()
{
AddEntityCollideCallback("Player", "sound_area1", "prisoner_scream", true, 1);
}
void prisoner_scream(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
{
Void Onleave()
{

}


Would that be wat Im trying to do? Or did I just make some complete failure BS that will crash mygame? lol


RE: How to script sounds - Kyle - 08-18-2011

You really messed up your script. Try this, and then compare. Tongue

Code:
void OnStart()
{
     AddEntityCollideCallback("Player", "sound_area1", "SoundPlay", true, 1);
}
void SoundPlay(string &in asParent, string &in asChild, int alState)
{
     PlaySoundAtEntity("", "prisoner_scream.snt", "Player", 0, false);
}

The sound you want to play is "prisoner_scream.snt"? Change "Player", located in the PlaySoundAtEntity command function if you want to change the position in the editor from which the sound will play at.

You don't need to script the sound "object" that you place in the editor. It will play on the start of the level. If it isn't a repeating sound, then the player may not be able to hear it because the sound might have already ended before the player comes close enough to it.


RE: How to script sounds - zeravia - 08-18-2011

i'm not sure exactly, but i think it's similiar to what i have for one of my own scares... here...does this help at all? i'm just getting started with my own scripting, but i like helping people...especially since i was helped. XD

void Scare(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("armour_nice_complete_7", 7.0f, 7.0f, "");
SetEntityActive("Scareskull", true);
AddPropImpulse("armour_nice_complete_7", 2, 1, 0, "World");
PlayGuiSound("react_scare.snt", 1.2f);
AddTimer("S", 0.4, "S");


RE: How to script sounds - Kyle - 08-18-2011

(08-18-2011, 04:02 PM)zeravia Wrote: i'm not sure exactly, but i think it's similiar to what i have for one of my own scares... here...does this help at all? i'm just getting started with my own scripting, but i like helping people...especially since i was helped. XD

void Scare(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("armour_nice_complete_7", 7.0f, 7.0f, "");
SetEntityActive("Scareskull", true);
AddPropImpulse("armour_nice_complete_7", 2, 1, 0, "World");
PlayGuiSound("react_scare.snt", 1.2f);
AddTimer("S", 0.4, "S");

You should first try to get a good ground with scripting before helping them, like in this case. By the way, you can use [cod*e] and [/cod*e] between your script (without asterisk (*)) as so it is easier to indicate when it starts and ends.