Frictional Games Forum (read-only)
Script - Piano Music - 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 - Piano Music (/thread-40661.html)

Pages: 1 2 3


RE: Script - Piano Music - Spelos - 02-27-2016

There is a number of things wrong with what you just showed me.
But the truth is that this could just go on forever, so let's make it easy.

Post your full .hps content.
If you want it to look organized on the forum, make sure to use the PHP tags.
Code:
[php]Paste your .hps here[/php]

Explain what you want to happen
Briefly explain what is it that you want to achieve.

Explain what actually happens
What is happening when you launch the game?
Is there an error message? (if so, post it as well)
Is something not playing?
Is something not stopping playing?


RE: Script - Piano Music - Abihishi - 02-27-2016

Code:
void OnStart()
{
    FadeOut(0.01f);
    AddTimer("", 2.1f, "awake2");
    AddTimer("", 5.0f, "awake");
    FadePlayerRollTo(90, 1, 2);
    MovePlayerHeadPos(0, -1.5f, 0, 1, 0.1f);
    
    PlayMusic("00_event_gallery", true, 1, 0.1, 10, false);
    StopMusic(1.0f, 1);
    
    PreloadSound("general_piano01.snt");
    SetEntityPlayerInteractCallback("ScriptArea_001", "PianoFunc", false);
    
    AddEntityCollideCallback("Player", "Script001", "Script001", true, 1);
    AddEntityCollideCallback("Player", "kappa33", "kappa33", true, 1);
    AddUseItemCallback("", "key01", "door01", "UseKeyOnDoor", true);
    AddUseItemCallback("", "key02", "door02", "UseKeyOnDoor", true);
    
    
    AddEntityCollideCallback("Player", "ScryptArea1_1", "Scrypt2", true, 1);
    AddEntityCollideCallback("Player", "Jumpperro", "Jumpscare2", true, 1);
    AddEntityCollideCallback("Player", "jumperro022", "Jumpscare3", true, 1);
    AddUseItemCallback("", "KeyDesc01", "level_hub_1", "FUNCTION", true);
    }
    
    
    
    
void PianoFunc(string &in asEntity)
{
    StopSound("PianoSound", 2.5f);
    PlaySoundAtEntity("PianoSound", "general_piano01.snt", "Script001", 0.5f, false);
}

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

    
    void FUNCTION(string &in item, string &in door)
    {
    SetLevelDoorLocked("level_hub_1", false);
    PlayGuiSound("unlock_door.snt", 100);
    RemoveItem("KeyDesc01");
    }
    
    
void Scrypt2(string &in asParent, string &in asChild, int alState)
{
SetMessage("MessageCategory2", "MessageEntry2", 0);
}

void kappa33(string &in asParent, string &in asChild, int alState)
{
SetMessage("MessageCategory3", "MessageEntry3", 0);
}

void Jumpscare2(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("15_the_big_scream.snt", 1.0f);
SetEntityActive("portret1", true);
SetEntityActive("portret2", true);
SetEntityActive("portret3", true);
SetEntityActive("portret4", true);
SetEntityActive("portret5", true);
SetEntityActive("portret6", true);
SetEntityActive("portret7", true);

SetEntityActive("redlamp1", true);
SetEntityActive("redlamp2", true);
SetEntityActive("redlamp3", true);
SetEntityActive("redlamp4", true);
SetEntityActive("redlamp5", true);
SetEntityActive("redlamp6", true);
SetEntityActive("redlamp7", true);
SetEntityActive("redlamp8", true);
AddTimer("", 2.5f, "JumpscareEntity_Gone");


}

void Jumpscare3(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("15_body_impact.snt", 1.0f);
SetEntityActive("rycerz1", true);
SetEntityActive("rycerz2", true);
SetEntityActive("rycerz3", true);
SetEntityActive("rycerz4", true);
SetEntityActive("rycerz5", true);
SetEntityActive("rycerz6", true);
SetEntityActive("rycerz7", true);
SetEntityActive("rycerz8", true);
AddTimer("", 2.5f, "JumpscareEntity_Gone");
}


void awake2(string asTimer)
{
    FadeIn(5.0f);
}

void awake(string asTimer)
{
    FadePlayerRollTo(0, 1, 2);
    MovePlayerHeadPos(0, 0.0f, 0, 0.5, 0.1f);
}

When i launch game nothing but when i start in CS music in piano not work and music in intro play the infinity.
No, this is not error message


I want play a music when my character wake up with floor. And stop this music after 15 second, would not play in infinity.

Piano similarly, when my character touch script area it has piano music in room which just we had the intention to enter. And too stop music, when music comes to an end.


RE: Script - Piano Music - Spelos - 02-27-2016

PHP Code:
void OnStart()
{
    
FadeOut(0.01f);
    
AddTimer(""2.1f"awake2");
    
AddTimer(""5.0f"awake");
    
FadePlayerRollTo(9012);
    
MovePlayerHeadPos(0, -1.5f010.1f);
    
    
PlayMusic("00_event_gallery"true10.110false);
    
AddTimer("StopMusicTimer"15.0f"StopMusicFunc");
    
    
PreloadSound("general_piano01.snt");
    
SetEntityPlayerInteractCallback("ScriptArea_001""PianoFunc"false);
     
    
AddEntityCollideCallback("Player""Script001""Script001"true1);
    
AddEntityCollideCallback("Player""kappa33""kappa33"true1);
    
AddUseItemCallback("""key01""door01""UseKeyOnDoor"true);
    
AddUseItemCallback("""key02""door02""UseKeyOnDoor"true);
    
    
    
AddEntityCollideCallback("Player""ScryptArea1_1""Scrypt2"true1);
    
AddEntityCollideCallback("Player""Jumpperro""Jumpscare2"true1);
    
AddEntityCollideCallback("Player""jumperro022""Jumpscare3"true1);
    
AddUseItemCallback("""KeyDesc01""level_hub_1""FUNCTION"true);
}
    
void StopMusicFunc(string &in asTimer)
{
    
StopMusic(1.0f10);
}
    
    
void PianoFunc(string &in asEntity)
{
    
StopSound("PianoSound"2.5f);
    
PlaySoundAtEntity("PianoSound""general_piano01.snt""Script001"0.5ffalse);


    
    
void UseKeyOnDoor(string &in asItemstring &in asEntity)
{
        
SetSwingDoorLocked(asEntityfalsetrue);
        
PlaySoundAtEntity("""unlock_door.snt"asEntity0false);
        
RemoveItem(asItem);
}
    
    

    
    
void FUNCTION(string &in itemstring &in door)
    {
    
SetLevelDoorLocked("level_hub_1"false);
    
PlayGuiSound("unlock_door.snt"100);
    
RemoveItem("KeyDesc01");
    }
    
    
void Scrypt2(string &in asParentstring &in asChildint alState)
{
SetMessage("MessageCategory2""MessageEntry2"0);


void kappa33(string &in asParentstring &in asChildint alState)
{
SetMessage("MessageCategory3""MessageEntry3"0);


void Jumpscare2(string &in asParentstring &in asChildint alState)
{
PlayGuiSound("15_the_big_scream.snt"1.0f);
SetEntityActive("portret1"true);
SetEntityActive("portret2"true);
SetEntityActive("portret3"true);
SetEntityActive("portret4"true);
SetEntityActive("portret5"true);
SetEntityActive("portret6"true);
SetEntityActive("portret7"true);

SetEntityActive("redlamp1"true);
SetEntityActive("redlamp2"true);
SetEntityActive("redlamp3"true);
SetEntityActive("redlamp4"true);
SetEntityActive("redlamp5"true);
SetEntityActive("redlamp6"true);
SetEntityActive("redlamp7"true);
SetEntityActive("redlamp8"true);
AddTimer(""2.5f"JumpscareEntity_Gone");


}

void Jumpscare3(string &in asParentstring &in asChildint alState)
{
PlayGuiSound("15_body_impact.snt"1.0f);
SetEntityActive("rycerz1"true);
SetEntityActive("rycerz2"true);
SetEntityActive("rycerz3"true);
SetEntityActive("rycerz4"true);
SetEntityActive("rycerz5"true);
SetEntityActive("rycerz6"true);
SetEntityActive("rycerz7"true);
SetEntityActive("rycerz8"true);
AddTimer(""2.5f"JumpscareEntity_Gone");
}


void awake2(string asTimer)
{
    
FadeIn(5.0f);
}

void awake(string asTimer)
{
    
FadePlayerRollTo(012);
    
MovePlayerHeadPos(00.0f00.50.1f);




RE: Script - Piano Music - Abihishi - 02-27-2016

Mhm i copy that but in game i not hear. I dont know why Sad Name script in editor is same, perhaps script can not find that sound file?


RE: Script - Piano Music - Spelos - 02-27-2016

You said the music is playing infinitely...
Well if the music file is not playing, then you obviously need to include ".ogg" with the file name.


RE: Script - Piano Music - Abihishi - 02-28-2016

Ok.

You know how make script when start Custom story my character musnt move, but only after 6-7 seconds?


RE: Script - Piano Music - Spelos - 02-28-2016

PHP Code:
SetPlayerActive(false); 
Makes the player unable to move or look around.
You put that into a function that runs as you want it to happen.
That means that if you want player to NOT be able to move as the custom story starts, you put that command into an OnStart() function.

PHP Code:
AddTimer(""7.0f"MyTimerFunc"); 
Adds a timer that will run MyTimerFunc function after 7.0f Seconds.
You put that into a function that runs as you want the timer to start.
That means that if you want "MyTimerFunc" to happen after 7 seconds FROM the beginning of your custom story, you put that command into an OnStart() function.

PHP Code:
void MyTimerFunc(string &in asTimer)
{


Is a FUNCTION that the previous Timer will call.
Everything in this function will happen after 7.0f Second specified in the Timer command.
If you want player to start moving at this point, put
PHP Code:
SetPlayerActive(true); 
command in this function.

Full script should look something like this:
PHP Code:
void OnStart()
{
    
SetPlayerActive(false);
    
AddTimer(""7.0f"MyTimerFunc");
}

void MyTimerFunc(string &in asTimer)
{
    
SetPlayerActive(true);




RE: Script - Piano Music - Abihishi - 02-28-2016

You are amazing!

Do you know yet how to add the effect of the blue flash when eg . open the door key ? And do you know perhaps how to add the blue glow to better visible key or note .


RE: Script - Piano Music - Spelos - 02-28-2016

All entities that are labeled as
"Item" "Note" "Oil" "tinderbox"
in Model Editor have that glow by default.

So only items and things you can pickup have it.


RE: Script - Piano Music - Mudbill - 02-28-2016

You can use
PHP Code:
GiveSanityBoost(); 
to give that "blue flash" effect. Put that in the event that unlocks the door with the key (for example right after SetSwingDoorLocked)