Frictional Games Forum (read-only)
Sound not playing at the right times - 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: Sound not playing at the right times (/thread-10024.html)



Sound not playing at the right times - ZRPT - 08-28-2011

Code:
////////////////////////////
// Run when the map starts
void OnStart()

{
AddUseItemCallback("", "starterroomkey_1", "starterdoor", "Usekeyondoor", true);
AddEntityCollideCallback("Player", "BLAM1", "func_slam", true, 1);
SetEntityCallbackFunc("earthquakenote", "Func");
}

void Usekeyondoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("starterdoor", false, true);
    PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
    RemoveItem("starterroomkey_1");
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("starterdoor", true, true);

SetSwingDoorLocked("starterdoor", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);  PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

void Func(string &in asEntity, string &in type)
{
if(type == "OnPickup")
    {
    StartScreenShake(0.10f, 5.0f, 1.5f, 4.0f);
    StartPlayerLookAt("lookat", 0.5, 0.5, "");
    SetPlayerActive(false);
    SetPlayerCrouching(true);
    AddTimer("", 1.0, "Timer1");
    AddTimer("", 4.0, "Timer2");
    AddTimer("", 1.0, "PlayShit");
    }
}
void Timer1(string &in asTimer)
{
        PlaySoundAtEntity("", "react_sigh", "Player", 0, false);
}
void Timer2(string &in asTimer)
{
        SetPlayerCrouching(false);
        StopPlayerLookAt();
        SetPlayerActive(true);
}
void PlayShit(string &in asParent, string &in asChild, int alState)
{
        PlaySoundAtEntity("", "general_rock_rumble", "Player", 0, false);
}

The rumble sound seems to be delayed, then it repeats. Also for some reason after the timer ends and the stopplayerlookat function is called, it still automatically looks at random objects.


RE: Sound not playing at the right times - ZRPT - 08-28-2011

Can anyone help?


RE: Sound not playing at the right times - Elven - 08-28-2011

Use that instead of CallEntityCallbackFunc

Code:
void SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);

Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity)

asName - internal name
asCallback - function to call
abRemoveOnInteraction - determines whether the callback should be removed when the player interacts with the entity