Frictional Games Forum (read-only)
[SCRIPT] Trigger Sounds not working - 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: [SCRIPT] Trigger Sounds not working (/thread-48972.html)

Pages: 1 2


Trigger Sounds not working - Xallikk - 06-04-2016

I'm trying to make it so when the player walks into an area, a sound plays but it's not working. Here's the script I'm using:

void OnStart()
{

AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("OpenDoor", "LevelKey1", "LevelDoor1", "UseKeyOnLevelDoor", true);
AddEntityCollideCallback("Player", "OpenScare", "SoundCheck", false, 1);
}



void SoundCheck(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "notice.snt", "OpenScare", 1.0f, false);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", "asEntity", 0, false);
RemoveItem(asItem);
}

void UseKeyOnLevelDoor(string &in asItem, string &in asEntity)
{

SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
void OnLeave()
{

}

Also, is there anything I have to do with the area besides the name?


RE: Trigger Sounds not working - Slanderous - 06-04-2016

Is it a custom voice? Do you have the debug tool on?


RE: Trigger Sounds not working - Xallikk - 06-04-2016

It's one of amnesia's own sound files and I don't know where the debug tool is.


RE: Trigger Sounds not working - Slanderous - 06-04-2016

(06-04-2016, 09:43 PM)Xallikk Wrote: It's one of amnesia's own sound files and I don't know where the debug tool is.

To enable the debug menu, go into your documents/Amnesia/Main and open up "main_settings.cfg". There find a line
PHP Code:
LoadDebugMenu
and change it to "true". Now in-game you will be able to open up the debug menu (F1), which is of great help while building your custom story.

Regarding the issue: try changing
PHP Code:
float afFadeTime 
in your function
Spoiler below!
[Image: ade4aca738594bf39082e6bb7a2a32c8.png]
into something like 0.1, or even 0.01. Your issue might occur because the sound you're trying to play is so short that the fade effect might actually "swallow" it.


RE: Trigger Sounds not working - Xallikk - 06-04-2016

There is still no sound. Is it perhaps because I have to put a PlayerInteractCallback on the script area in the editor or is that not needed?


RE: Trigger Sounds not working - Slanderous - 06-04-2016

(06-04-2016, 10:52 PM)Xallikk Wrote: There is still no sound. Is it perhaps because I have to put a PlayerInteractCallback on the script area in the editor or is that not needed?

No, it's unnecessary. Try changing the source of the sound into "Player"
[Image: 6b6df4cc70bb447bb2c6372b81aa9ceb.png]


RE: Trigger Sounds not working - Xallikk - 06-04-2016

Still nothing although I noticed I hear a monster growl when I spawn in. It's not the same as the sound I chose, but it might be related?


RE: Trigger Sounds not working - Slanderous - 06-04-2016

(06-04-2016, 10:58 PM)Xallikk Wrote: Still nothing although I noticed I hear a monster growl when I spawn in. It's not the same as the sound I chose, but it might be related?

.snt files usually contain several diffrent audio clips, thus they randomize which sound to play. The notice sounds in Amnesia usually look like this:

PHP Code:
<SOUNDENTITY>
  <
SOUNDS>
      <
Main>
          <
Sound File="brute/notice01" />
          <
Sound File="brute/notice02" />
      </
Main>
  </
SOUNDS

You can see it by yourself by opening the .snt file in any text editor you're using. So in this case, using PlaySoundAtEntity will as I said randomize which sound to play among those 2.

If you want a particular sound to play, I reccomend using this function:
PHP Code:
void PlayGuiSound(stringasSoundFilefloat afVolume);
Plays a soundnot using 3D.

asSoundFile the sound to play (extension is .snt)
afVolume the volume of the sound 

In GuiSound function, you just type in the name of the sound which you want to hear, for example "notice02.snt"
Make sure to have the .snt extension as well!


RE: Trigger Sounds not working - Xallikk - 06-04-2016

Well either one is fine, but that means it's playing on my spawn in to the map. How do I fix that?


RE: Trigger Sounds not working - Slanderous - 06-04-2016

(06-04-2016, 11:06 PM)Xallikk Wrote: Well either one is fine, but that means it's playing on my spawn in to the map. How do I fix that?

Where is your "OpenScare" area? Is it located right where the player starts the map? If so, then that's the case of having the sound played at the spawn.