Frictional Games Forum (read-only)
Item pickup trigger sound 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: Item pickup trigger sound help (/thread-48990.html)



Item pickup trigger sound help - Xallikk - 06-05-2016

Hey, sorry for posting so much, just running into a few problems that I can't figure out. I want to make it so when the player picks up a key, a sound is played, but besides using an area near the key to simulate that, I can't see a way to do that.

Also, along the same lines, is it possible to take control of player's camera after the key is picked up and turn them to a closet so a monster can come out kinda thing?


RE: Item pickup trigger sound help - Mudbill - 06-05-2016

You can use PlayGuiSound() if you don't care where the sound is coming from. If you want the sound positioned 3D in the level, use an area with PlaySoundAtEntity().

You can control the player's view with StartPlayerLookAt(). Just tell it where to look (I recommend script areas) and how fast and such. Remember to use StopPlayerLookAt() or else they will be stuck looking there. Combine these with AddTimer() to have it happen at specific times.

You'll find all the info on the scripts page. Just ctrl-F what you need:
https://wiki.frictionalgames.com/doku.php?id=hpl2/amnesia/script_functions


RE: Item pickup trigger sound help - Xallikk - 06-05-2016

When I run the game, it crashes and says expected data type. I'm pretty sure my code is wrong, I'll put it here:

void OnStart()
{

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



void PickUp("Key", "OnPickup")
{
PlaySoundAtEntity("pickupsound", "21_screams.snt", "PickupSound", 0.01f, false);
}


void SoundCheck2(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("ambientsound", "ambience_wind_eerie.snt", "SpawnScare", 0.01f, true);
}

void SoundCheck(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("scaresound", "notice.snt", "Player", 0.01f, 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()
{
SetupLoadScreen("Loading", "LoadScreen1", 0, "LoadingScreen1.jpg");
}


RE: Item pickup trigger sound help - Mudbill - 06-06-2016

void PickUp("Key", "OnPickup")

This line; you're not supposed to fill in the constructor. Copy and paste the original callback syntax.


RE: Item pickup trigger sound help - Xallikk - 06-06-2016

Also, this isn't really related but I didn't want to start a whole thread, but how do I import custom sounds? I took a YouTube link, converted to MP3, and then exported to OGG, but when I put in my script, no sound plays in the level. It's in my custom story folder so I don't know whats wrong.

Oh never mind, got it to snt


RE: Item pickup trigger sound help - Mudbill - 06-06-2016

I also just noticed this line

SetEntityCallbackFunc("Key", PickUp);

is missing a pair of quotes around PickUp. Other than that, what did you mean by your last comment?


RE: Item pickup trigger sound help - Xallikk - 06-07-2016

Oh that was just me getting the sound to work, kinda worded it weirdly.