Frictional Games Forum (read-only)
Script for traumatic/fear visual effects - 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 for traumatic/fear visual effects (/thread-22622.html)



Script for traumatic/fear visual effects - JohnnyMedieval - 08-28-2013

Hi people,

I'll start by saying I'm very much new to Amnesia map making, and this one thing I'm working on will probably be the only time I ever do it, so I don't need to learn everything about scripting. Sorry if my question/request is stupid, and if you answer it for me, please explain it to me in a way a newbie can understand. Thanks.

I'm just trying to do something very simple (for a custom video, I'm not even making a whole custom story), so I hope you guys can please just give me a few lines of script or something, without directing me to some long complicated tutorial or just saying "go read the whole wiki."

Anyway, all I'm trying to do is script so that when the player enters an area I placed on the map it triggers the sort of "tunnel vision" or "shockwave" visual effects that trigger when Daniel gets scared by something in the game.

I've been looking around for a few hours, have watched a few tutorial on youtube and skimmed through the wiki, but I just can't seem to find anything that tells me how to script these visual effects. I have watched a tutorial on how to set up an area and script it to slam a door though, so I know some basics.

Anyway, if someone could help me out and tell me what scripts I need to add to do this, I'd appreciate it. Thanks in advance.


RE: Script for traumatic/fear visual effects - Kreekakon - 08-28-2013

Well according to what you said knowing how to set up an "area", I'll assume you're familiar with AddEntityCollideCallback. If you're not, tell me, and I'll elaborate.

The visual effect you're looking for is actually very simple, and is built into the engine. it plays when the player takes sanity damage. It works as follows:

Quote:
Code:
void GiveSanityDamage(float afAmount, bool abUseEffect);

Reduces the sanity of the player.

afAmount - amount of sanity damage done

abUseEffect - determines whether an effect is played when the sanity damage is dealt



RE: Script for traumatic/fear visual effects - JohnnyMedieval - 08-28-2013

Hey, thanks for the quick response Smile

I'm sorry I'm not really familiar with AddEntityCollideCallback, I actually didn't pay that much attention yet to the door slamming tutorial since that wasn't what I'm looking to do.

Basically, I have my map set up, I added an area, and I just need to know I guess what exactly I have to type into the .hps to make the area cause sanity damage when I step into it. It's really a simple thing, just one room and I'll be adding two scripted areas, that cause sanity damage.

Thanks for the help.

Ok I just looked at that tutorial again quick, so the AddEntityCollideCallback is just for when the player collides with the area. I understand, kind of Tongue pardon my noobishness.


RE: Script for traumatic/fear visual effects - FlawlessHappiness - 08-28-2013

Great thing you read on it again, and understood it better! Smile Ask again if you need more help!


RE: Script for traumatic/fear visual effects - JohnnyMedieval - 08-28-2013

Thanks again guys. Ok, so this is what I have, please let me know if I've done this right:

Code:
void OnStart ()
{
    AddEntityCollideCallback("player", "Area1", "CollideArea1", true, 1)
}

void CollideArea1
{
    void GiveSanityDamage(float 1, true)
}

I'm not sure if I'm supposed to leave "float" in there, or if "1" is the right variable format to set the sanity damage.


RE: Script for traumatic/fear visual effects - The chaser - 08-28-2013

(08-28-2013, 03:49 PM)JohnnyMedieval Wrote: Thanks again guys. Ok, so this is what I have, please let me know if I've done this right:

Code:
void OnStart ()
{
    AddEntityCollideCallback("player", "Area1", "CollideArea1", true, 1)
}

void CollideArea1
{
    void GiveSanityDamage(float 1, true)
}

I'm not sure if I'm supposed to leave "float" in there, or if "1" is the right variable format to set the sanity damage.

Code:
void OnStart ()
{
    AddEntityCollideCallback("player", "Area1", "CollideArea1", true, 1);
}

void CollideArea1 (string &in asParent, string &in asChild, int alState)

{
GiveSanityDamage(1, true);
}

This is the right code. By tunnel, I think you mean the Field Of View:

FadePlayerFOVMulTo(float afX, float afSpeed);

Changes the field of view of the player. A shorter FOV will create a zoom effect.

afX - multiplier of default FOV (1 is default)
afSpeed - the speed of change between FOV's


RE: Script for traumatic/fear visual effects - JohnnyMedieval - 08-28-2013

Thanks, yeah I got an error when I tried it the first way.

I just changed it to your code, but the area didn't trigger any visual effects.
This is what I have now:
Code:
void OnStart ()
{
    AddEntityCollideCallback("player", "ScriptArea_1", "CollideArea1", true, 1);
}

void CollideArea1(string &in asParent, string &in asChild, int alState)

{
    FadePlayerFOVMulTo(3, 2);

    GiveSanityDamage(5.0f, true);
}
I tried remaking the area too, and used the default name in the editor and in the script. It's still not working and I have no idea what I'm doing wrong.
Sorry, like I said, I know nothing about scripting.
If someone could tell me what to fix I appreciate it, thanks.


RE: Script for traumatic/fear visual effects - FlawlessHappiness - 08-28-2013

I think "player" must be capitalized.


RE: Script for traumatic/fear visual effects - JohnnyMedieval - 08-28-2013

(08-28-2013, 04:34 PM)FlawlessHair Wrote: I think "player" must be capitalized.

lol, that did it, now it's working. Thanks alot!

I can stop bugging you guys with my noob questions now Smile thanks for all the help everyone.