Frictional Games Forum (read-only)
[SCRIPT] Sound-Area doesn't work [Solved] - 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] Sound-Area doesn't work [Solved] (/thread-25135.html)



Sound-Area doesn't work [Solved] - ShipinShen - 04-22-2014

Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?


RE: Sound-Area doesn't work - Mudbill - 04-22-2014

Is your .snt file set to loop? Why is this sound only playing when you collide with the area? You could just have it play at all times with a low radius.


RE: Sound-Area doesn't work - ShipinShen - 04-22-2014

(04-22-2014, 02:51 PM)Mudbill Wrote: Is your .snt file set to loop? Why is this sound only playing when you collide with the area? You could just have it play at all times with a low radius.

Thats right.
OnStart()
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

Is this correct ?
Thats the .snt file
Quote:<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="ClockChime" />
</Main>
</SOUNDS>
<PROPERTIES Volume="0.7" MinDistance="2" MaxDistance="16" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="True" Blockable="False" BlockVolumeMul="0.8" Priority="0" />
</SOUNDENTITY>



RE: Sound-Area doesn't work - Mudbill - 04-22-2014

What kind of sound is this, and how do you want it to play? Do you only want a single ding-dong to occur when the player comes close to the clock? You could try making the Priority="1" instead. Where are the audio files located?


RE: Sound-Area doesn't work - ShipinShen - 04-22-2014

(04-22-2014, 02:57 PM)Mudbill Wrote: What kind of sound is this, and how do you want it to play? Do you only want a single ding-dong to occur when the player comes close to the clock? You could try making the Priority="1" instead. Where are the audio files located?

Thats this sound https://www.youtube.com/watch?v=tOIA9Ii2Ihk
The clock is in a room, and i want that the sound come from the clock, i just looped the sound a bit longer so the chimes wont appear 2 times if someone stays longer in this room.

The audiofiles are located in C:\Program Files (x86)\Steam\SteamApps\common\Amnesia The Dark Descent\custom_stories\Haunted Mind\sounds the sounds should work, because the phonogram works


RE: Sound-Area doesn't work - Daemian - 04-22-2014

If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.


RE: Sound-Area doesn't work - ShipinShen - 04-22-2014

(04-22-2014, 03:33 PM)Amn Wrote: If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.

The sound is 5minutes long, the fade time shouldnt be a problem..
The entity is in the room so i can walk to the clock instantly. Maybe its the intro who stops the sound ?

Quote:void OnStart()
{
TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntro");

SetEntityCallbackFunc("Lantern", "OpenDoor");
SetLocalVarInt("Door", 0);




AddUseItemCallback("", "KeyTable", "DeskDoor", "UseKeyOnDoor", true);
PlayMusic("RainyMood.ogg", false, 1, 3, 1, true);

PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 0, false);
}
Quote:void TimerIntro(string &in asTimer)
{
if(GetLocalVarInt("Intro") < 3) {

if(asTimer == "fadein") {
TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
FadeIn(1);
AddTimer("fadeout", 4, "TimerIntro");
}
if(asTimer == "fadeout") {
FadeOut(1);
AddTimer("fadein", 1, "TimerIntro");
AddLocalVarInt("Intro", 1);
}
}
else
{
TeleportPlayer("Spawn");
FadeIn(2);
SetPlayerActive(true);
SetSanityDrainDisabled(false);
ShowPlayerCrossHairIcons(true);
}
}
The Intro works fine. After the intro, the player stands in near of the entity "grandfather"

(04-22-2014, 02:41 PM)ShipinShen Wrote: Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?

I know where the mistake is.. the sound file works fine, because when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "Player", 1, false); I can hear the noise, but i dont understand, why the sound doesnt work when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false); the entity has the exact same name in the level editor and the same .snt settings than the phonogram, which works fine

(04-22-2014, 03:56 PM)ShipinShen Wrote:
(04-22-2014, 03:33 PM)Amn Wrote: If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.

The sound is 5minutes long, the fade time shouldnt be a problem..
The entity is in the room so i can walk to the clock instantly. Maybe its the intro who stops the sound ?

Quote:void OnStart()
{
TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntro");

SetEntityCallbackFunc("Lantern", "OpenDoor");
SetLocalVarInt("Door", 0);




AddUseItemCallback("", "KeyTable", "DeskDoor", "UseKeyOnDoor", true);
PlayMusic("RainyMood.ogg", false, 1, 3, 1, true);

PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 0, false);
}
Quote:void TimerIntro(string &in asTimer)
{
if(GetLocalVarInt("Intro") < 3) {

if(asTimer == "fadein") {
TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
FadeIn(1);
AddTimer("fadeout", 4, "TimerIntro");
}
if(asTimer == "fadeout") {
FadeOut(1);
AddTimer("fadein", 1, "TimerIntro");
AddLocalVarInt("Intro", 1);
}
}
else
{
TeleportPlayer("Spawn");
FadeIn(2);
SetPlayerActive(true);
SetSanityDrainDisabled(false);
ShowPlayerCrossHairIcons(true);
}
}
The Intro works fine. After the intro, the player stands in near of the entity "grandfather"

(04-22-2014, 02:41 PM)ShipinShen Wrote: Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?

I know where the mistake is.. the sound file works fine, because when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "Player", 1, false); I can hear the noise, but i dont understand, why the sound doesnt work when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false); the entity has the exact same name in the level editor and the same .snt settings than the phonogram, which works fine

I solved it, by adding an area which names "grandfather" !


RE: Sound-Area doesn't work [Solved] - Mudbill - 04-22-2014

Oh boy, that's a lot of quoting.

But yeah, that actually makes sense, because the grandfather clock is likely a static entity type, so interacting with it won't work. I prefer to use areas for these things anyway, gives me more control. Glad you got it working!