Frictional Games Forum (read-only)
Gandalf's scripting questions thread - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Gandalf's scripting questions thread (/thread-6787.html)

Pages: 1 2


Gandalf's scripting questions thread - gandalf91 - 03-04-2011

Hello. I'm pretty new here and just underway with a custom story of my own. So far my map isn't very large, just one decent sized room and a few corridors, but I'm having trouble with some of the sounds. I placed two instances of the sound 00_creak.snt near a large castle door on one side of the map. I changed the parameters so that the volume was lower and the range the sound could be heard much shorter...however, I'm still hearing the sound way on the other end of the map, far beyond how I set it. The volume seemed to work to some extent, just not the range of the sound. Any ideas?


RE: Modifying sound volumes and distances - Nye - 03-04-2011

(03-04-2011, 08:26 PM)gandalf91 Wrote: Hello. I'm pretty new here and just underway with a custom story of my own. So far my map isn't very large, just one decent sized room and a few corridors, but I'm having trouble with some of the sounds. I placed two instances of the sound 00_creak.snt near a large castle door on one side of the map. I changed the parameters so that the volume was lower and the range the sound could be heard much shorter...however, I'm still hearing the sound way on the other end of the map, far beyond how I set it. The volume seemed to work to some extent, just not the range of the sound. Any ideas?

Is it a sound that repeats?

Also, if the maximum range is too large, and the player is always inside it, you will not be able to detect where the sound is coming from.

Make sure the 'Use Defaults' box is UNTICKED and ensure that the maximum range is greater than the minimum range and ensure that the maximum range has a radius that is small enough for the player to walk into to experience the rise in volume as they move closer to the source.

If it is a sound that you only want to play once, you shouldn't be using the level editor to play the sound, although that is an entirely different story Tongue


RE: Modifying sound volumes and distances - gandalf91 - 03-04-2011

Yup, use default is unchecked, I meant to mention that but forgot. It's meant to be a looping sound as well. I even tried min 0.5 and max 1.0 but could still hear it from far away. I've looked through dev scripts before and seen scripts about "pre-loading" sounds. Wouldn't need to do something like that, would I?


RE: Modifying sound volumes and distances - Nye - 03-04-2011

(03-04-2011, 10:08 PM)gandalf91 Wrote: Yup, use default is unchecked, I meant to mention that but forgot. It's meant to be a looping sound as well. I even tried min 0.5 and max 1.0 but could still hear it from far away. I've looked through dev scripts before and seen scripts about "pre-loading" sounds. Wouldn't need to do something like that, would I?

I assume that it only plays the sound as soon as you enter the map and doesn't play it again.

The creak sound is not designed for use in the level editor. You will need to use scripting to play the sound Undecided


RE: Modifying sound volumes and distances - gandalf91 - 03-04-2011

Oh really? So I guess it's more like an ambient track then, like in the first level of the game. :/

For now I suppose I could just leave it out though, and sort it out later. Thank you for your help though! Big Grin I know I made the topic of this thread about sounds, but I'll probably have quite a few questions here and there about the scripting. Would it be better just to keep all my questions (regarding this particular map of course) to this one thread?


RE: Modifying sound volumes and distances - Nye - 03-04-2011

(03-04-2011, 11:53 PM)gandalf91 Wrote: Oh really? So I guess it's more like an ambient track then, like in the first level of the game. :/

For now I suppose I could just leave it out though, and sort it out later. Thank you for your help though! Big Grin I know I made the topic of this thread about sounds, but I'll probably have quite a few questions here and there about the scripting. Would it be better just to keep all my questions (regarding this particular map of course) to this one thread?

Sure, just use 'Full Edit' on your original post and rename the thread title and bump your thread each time you have a question. Maybe rename it "Gandalf's Scripting Question Thread" or something Smile


RE: Gandalf's scripting questions thread - gandalf91 - 03-05-2011

Lol, I just might take you up on that. Anyway, just looks like I have one more quick question for tonight. It seems I've learned to use basic "EntityCollide" callbacks pretty well, but I seem to be unable to figure out how to create an interact callback. Tried trial and error a couple times but got error messages about unmatching signatures.

Aside from that, I figured out one my own how to spawn a servant with disabled triggers (so he can't detect you) and then add a 6 second timer upon which the enemy triggers a re-enabled. So I felt accomplished about that. Big Grin


RE: Gandalf's scripting questions thread - Samuelblitz - 03-05-2011

(03-05-2011, 03:31 AM)gandalf91 Wrote: Lol, I just might take you up on that. Anyway, just looks like I have one more quick question for tonight. It seems I've learned to use basic "EntityCollide" callbacks pretty well, but I seem to be unable to figure out how to create an interact callback. Tried trial and error a couple times but got error messages about unmatching signatures.

Aside from that, I figured out one my own how to spawn a servant with disabled triggers (so he can't detect you) and then add a 6 second timer upon which the enemy triggers a re-enabled. So I felt accomplished about that. Big Grin

Here is the interact callback script:

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);

under Name put the name of the entity in quotes.
under Callback choose a callback name in quotes.
the last one true or false depending on weather you want the callback to be removed after or not.

and then obviously later in the script you put

void WhatEverYourCallBackNameWas(string &in asParent, string &in asChild, int alState)
{
}

with whatever you want the callback to trigger in the {}'s.

oh and by the way, this: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions
has all the script functions you'll ever need Smile


RE: Gandalf's scripting questions thread - gandalf91 - 03-05-2011

Thanks. Smile I had just kept using "add" instead of "set", but I've corrected it now. Impulse script on a door now is frustrating me though!

In the void Onstart() section I have these callback functions listed:

AddEntityCollideCallback("Player", "ScriptArea_3", "Candlelight1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "Candlelight2", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_5", "Candlelight3", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_6", "Candlelight4", true, 1);

Then further down in my script I have:

void Candlelight1(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candle_floor_1", true, true);
SetLampLit("candle_floor_2", true, true);
AddPropImpulse("prison_section_1", 0.0f, 0.0f, 0.2f, false);
}

void Candlelight2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candle_floor_3", true, true);
SetLampLit("candle_floor_4", true, true);
AddPropImpulse("prison_section_1", 0.0f, 0.0f, 0.2f, false);
}

void Candlelight3(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candle_floor_5", true, true);
SetLampLit("candle_floor_6", true, true);
AddPropImpulse("prison_section_1", 0.0f, 0.0f, 0.25f, false);
}


void Candlelight4(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candle_floor_7", true, true);
SetLampLit("candle_floor_8", true, true);
AddPropImpulse("prison_section_1", 0.0f, 0.0f, 0.3f, false);
}

The effect is to light candles on either side of you as you walk down a corridor and slowly push a door ("prison_section_1") open in front of you. My AddPropImpulse section keeps returning non-matching signatures.


RE: Gandalf's scripting questions thread - Pandemoneus - 03-05-2011

Yeah, because the last parameter is not correct.

Check the script functions: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

Code:
void  AddPropImpulse(string& asName, float afX, float afY, float afZ, string& asCoordSystem);

That means you need a string, float, float, float, string.
But you got a boolean at the end instead of a string.