Frictional Games Forum (read-only)
Problem with playing sound on pickup! Please help! - 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: Problem with playing sound on pickup! Please help! (/thread-13488.html)

Pages: 1 2


Problem with playing sound on pickup! Please help! - Zebraa - 02-21-2012

Hello, I am working on a custom map and I'm trying to get a sound to play when the lantern is picked up. Could someone please help. Here's my .HPS file:
Code:
void OnStart()
{
PlaySoundOnPickup("amb_alert", "amb_alert.snt", "lantern_1", float 1, bool false);
}

void OnEnter()
{

}

void OnLeave()
{

}



RE: Problem with playing sound on pickup! Please help! - Obliviator27 - 02-21-2012

For starters, PlaySoundOnPickup isn't a proper function.
Use
SetEntityPlayerInteractCallback instead.



RE: Problem with playing sound on pickup! Please help! - Zebraa - 02-21-2012

(02-21-2012, 05:45 PM)Obliviator27 Wrote: For starters, PlaySoundOnPickup isn't a proper function.
Use
SetEntityPlayerInteractCallback instead.
Thanks I'm pretty new to script and when I was trying to wprk things out from the engine scripts on the wiki.

I changed the script yet the sound still does not play.


RE: Problem with playing sound on pickup! Please help! - Juby - 02-21-2012

This is one way to do what you want.


void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}

void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}

void OnEnter()
{

}

void OnLeave()
{

}


RE: Problem with playing sound on pickup! Please help! - Zebraa - 02-21-2012

(02-21-2012, 06:37 PM)Juby Wrote: This is one way to do what you want.


void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}

void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}

void OnEnter()
{

}

void OnLeave()
{

}
I did this, changed the lantern names and it still seems to not work.



void OnStart()
{
SetEntityPlayerInteractCallback("Lantern_1", "PickedUpLantern", true);
}

void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "Lantern_1", 0.1f, false);
}

void OnEnter()
{

}

void OnLeave()
{

}
(02-21-2012, 06:37 PM)Juby Wrote: This is one way to do what you want.


void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}

void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}

void OnEnter()
{

}

void OnLeave()
{

}
Also, would I need to put anything into the HPL level editor?


RE: Problem with playing sound on pickup! Please help! - Juby - 02-21-2012

Okay, I noticed something, the sound you want played won't work because there are multiple "amb_alert.snt" files. The reason it won't play is because the game can't figure out which sound to play, so it doesn't do either one of them. In order for the sound to play, you need to add specification to what sound you want to play.

PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
or
PlaySoundAtEntity("", "brute/amb_alert.snt", "Lantern_1", 0.1f, false);



RE: Problem with playing sound on pickup! Please help! - Zebraa - 02-21-2012

(02-21-2012, 06:51 PM)Juby Wrote: Okay, I noticed something, the sound you want played won't work because there are multiple "amb_alert.snt" files. The reason it won't play is because the game can't figure out which sound to play, so it doesn't do either one of them. In order for the sound to play, you need to add specification to what sound you want to play.

PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
or
PlaySoundAtEntity("", "brute/amb_alert.snt", "Lantern_1", 0.1f, false);
Thanks again but the sound, for some reason, still won't play. Here is my hps files again... but what it looks like now:

void OnStart()
{
SetEntityPlayerInteractCallback("Lantern_1", "PickedUpLantern", true);
}

void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
}

void OnEnter()
{

}

void OnLeave()
{

}


RE: Problem with playing sound on pickup! Please help! - Your Computer - 02-21-2012

When the game is confronted with two or more files that bear the same name, it picks the first one it finds and ignores the rest. So, there is no need to provide the directory path of the file.

As for debugging sounds, there's an option in the debug menu that you can enable that has the game list all sounds being played at the upper left of the screen. Enable that feature, test the story again, and see if it is listed there.


RE: Problem with playing sound on pickup! Please help! - Zebraa - 02-21-2012

(02-21-2012, 07:06 PM)Your Computer Wrote: When the game is confronted with two or more files that bear the same name, it picks the first one it finds and ignores the rest. So, there is no need to provide the directory path of the file.

As for debugging sounds, there's an option in the debug menu that you can enable that has the game list all sounds being played at the upper left of the screen. Enable that feature, test the story again, and see if it is listed there.
Where is the debug menu in HPL Level Editor?


RE: Problem with playing sound on pickup! Please help! - Your Computer - 02-21-2012

(02-21-2012, 08:40 PM)Zebraa Wrote: Where is the debug menu in HPL Level Editor?

It's a feature of the game, not the level editor. You are testing the sounds in game, right?