Frictional Games Forum (read-only)
How to make a "Scary door?" - Printable Version

+- Frictional Games Forum (read-only) (
+-- Forum: Amnesia: The Dark Descent (
+--- Forum: Custom Stories, TCs & Mods (
+--- Thread: How to make a "Scary door?" (/thread-4425.html)

How to make a "Scary door?" - sacroid - 09-16-2010

Hey there guys, I'm making now a serious story and I need to know how to make a "scary door". What I mean with Scary door, I mean:
You interact with a locked door, and by touching it, the cammera will make a cammera effect and then a scary sound and a grunt behind makes noises, just like in wine Cellar (ofc, I would change it a bit).
So, what's the script I need to write? with the time I'm starting a bit to understand scripting, but I still need help >_<
I've been looking at the win cellar.hps file, and I read the part of the door, but it's so big, and strange (for me Tongue) that for only making 1 interaction causes 3 things, I think is too much -_-

Help is very appreciated!
Thanks Wink

RE: How to make a "Scary door?" - MulleDK19 - 09-16-2010

In your OnStart() function you add

SetEntityPlayerInteractCallback("name_of_door_here", "FunctionToCall", true);

Then make the callback function:
void FunctionToCall(string &in entity)
    PlaySoundAtEntity("instance_name", "soundfile.ogg/snt", "name_of_entity_to_play_sound_from", 0, false);
    SetEntityActive("name_of_grunt_or_brute", true); //Spawn monster

Edit: For the camera effect, you could simply use
void GiveSanityDamage(float afAmount, bool abUseEffect);

Which will "bend" the camera little".

void FunctionToCall(string &in entity)
    PlaySoundAtEntity("instance_name", "soundfile.ogg/snt", "name_of_entity_to_play_sound_from", 0, false);
    SetEntityActive("name_of_grunt_or_brute", true); //Spawn monster
    GiveSanityDamage(15.0f, true);

I've written a small function for you, that should give a more twisted camera effect:
void DoScaryCamera(float afSanityDamage)
    //Enable image trail
    FadeImageTrailTo(1.0f, 10.0f);
    //Enable radial blur
    FadeRadialBlurTo(0.15f, 10.0f);
    //If the function was called with a sanity damage larger than 0, apply it (with effects)
    if(afSanityDamage > 0.0f)
        GiveSanityDamage(afSanityDamage, true);
    //End the effects, half a second later
    AddTimer("", 0.5f, "TimerEndEffects");

void TimerEndEffects(string &in asTimer)
    //Disable image trail
    FadeRadialBlurTo(0.0f, 0.5f);
    //Disable radial blur
    FadeImageTrailTo(0.0f, 1.0f);

Simply add that to your script file, and simply do DoScaryCamera(15.0f) from anywhere in your code, to perform a little twisting camera effect. 15.0f being the sanity damage to apply.

Haven't tested it as I just wrote it here, but it should work just fine.

RE: How to make a "Scary door?" - sacroid - 09-16-2010

Thanks! I just needed it Tongue