Frictional Games Forum (read-only)
How to script Music when walking into a ScriptArea? - 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: How to script Music when walking into a ScriptArea? (/thread-19108.html)



How to script Music when walking into a ScriptArea? - taylor122002 - 11-05-2012

[attachment=3472]Firstly, I want to say thank you to everyone at the forums for all of your help on scripting! I've learned many new things which could help my custom story come along nicely! I finally finished my first map, which was 128 lines of scripting! Big Grin And it all works! Now I'm working on the second map of the custom story, which is downstairs. I want to make it so when you walk into a script area, music will play, and that Daniel turns his head to the side and a monster charges at you but then disappears at last second It could be for a small scare. I already no how to set it up with sounds, but I want music, and know how to make it so when walked into the scripted area, the character will turn his head and see a monster.

Here is what I have for my script so far, but I get a ton of errors.:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "Start", true, 1);
}

void Start(string &in asParent, string &in asChild, int alState)
{
PlayMusic("", "10_event_coming.ogg", true, 0.8, 2, 1, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

And I don't know how to script so you turn your head.
That script I got from YouTube except changed the sound with music.
And I'll use an attachment for what the errors say.

I noticed though that the error had some things from the first map I used. Like the "Low Sanity" thing I used in my first map, Room01. But it's included in the error for Downstairs01. But I don't get these errors when I use an actual sound and not music.


RE: How to script Music when walking into a ScriptArea? - ZodiaC - 11-05-2012

(11-05-2012, 10:33 PM)taylor122002 Wrote: Firstly, I want to say thank you to everyone at the forums for all of your help on scripting! I've learned many new things which could help my custom story come along nicely! I finally finished my first map, which was 128 lines of scripting! Big Grin And it all works! Now I'm working on the second map of the custom story, which is downstairs. I want to make it so when you walk into a script area, music will play, and that Daniel turns his head to the side and a monster charges at you but then disappears at last second It could be for a small scare. I already no how to set it up with sounds, but I want music, and know how to make it so when walked into the scripted area, the character will turn his head and see a monster.

Here is what I have for my script so far, but I get a ton of errors.:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "Start", true, 1);
}

void Start(string &in asParent, string &in asChild, int alState)
{
PlayMusic("", "10_event_coming.ogg", true, 0.8, 2, 1, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

And I don't know how to script so you turn your head.
That script I got from YouTube except changed the sound with music.
And I'll use an attachment for what the errors say.

I noticed though that the error had some things from the first map I used. Like the "Low Sanity" thing I used in my first map, Room01. But it's included in the error for Downstairs01. But I don't get these errors when I use an actual sound and not music.
StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
To look at entity and
StopPlayerLookAt();
to stop looking


RE: How to script Music when walking into a ScriptArea? - taylor122002 - 11-06-2012

(11-05-2012, 10:40 PM)ZodiaC Wrote:
(11-05-2012, 10:33 PM)taylor122002 Wrote: Firstly, I want to say thank you to everyone at the forums for all of your help on scripting! I've learned many new things which could help my custom story come along nicely! I finally finished my first map, which was 128 lines of scripting! Big Grin And it all works! Now I'm working on the second map of the custom story, which is downstairs. I want to make it so when you walk into a script area, music will play, and that Daniel turns his head to the side and a monster charges at you but then disappears at last second It could be for a small scare. I already no how to set it up with sounds, but I want music, and know how to make it so when walked into the scripted area, the character will turn his head and see a monster.

Here is what I have for my script so far, but I get a ton of errors.:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "Start", true, 1);
}

void Start(string &in asParent, string &in asChild, int alState)
{
PlayMusic("", "10_event_coming.ogg", true, 0.8, 2, 1, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

And I don't know how to script so you turn your head.
That script I got from YouTube except changed the sound with music.
And I'll use an attachment for what the errors say.

I noticed though that the error had some things from the first map I used. Like the "Low Sanity" thing I used in my first map, Room01. But it's included in the error for Downstairs01. But I don't get these errors when I use an actual sound and not music.
StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
To look at entity and
StopPlayerLookAt();
to stop looking
Thanks! I got the head motion right! But I can't get it right so when you walk into a script area, it happens. Right when I enter the level door leading to downstairs, then it goes straight to the "Grunt_1", and when I try to look away, it keeps going back there. Even after waiting for a long period of time.


RE: How to script Music when walking into a ScriptArea? - craven7 - 11-06-2012

Like taylor said, to stop the LookAt- effect use
StopPlayerLookAt();

However, I don't understand your other problems, could you reexplain them and post your code?


RE: How to script Music when walking into a ScriptArea? - Adrianis - 11-06-2012

You need to make sure that StartPlayerLookAt is being used in the function called by 'AddEntityCollideCallback', which in this case seems to be 'void Start'. In the function called from StartPlayerLookAt, you should have StopPlayerLookAt, so that once the player is looking at the thing, it unlocks the camera

If this doesnt help, I recommend you re-post your updated script so we can see whats up with it