Frictional Games Forum (read-only)
Area Triggers Help! - 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: Area Triggers Help! (/thread-9815.html)

Pages: 1 2


Area Triggers Help! - JetlinerX - 08-17-2011

Hey all!

So I am trying to make this happen here:

Player walks through level transfer door into new map. Player goes to end of map and finds note. When player returns to the same level transfer door they entered from, the following "area" is triggered with the following events:

{
GiveSanityDamage(20, true);
SetPlayerActive(false);
AddPlayerBodyForce(-40000, 25000, 0, false);
FadePlayerRollTo(75, 3, 2);
StartPlayerLookAt("level_celler_1", 2, 2, "");
SetPlayerCrouching(true);
AddTimer("", 2, "");
AddTimer("", 10, "");
GivePlayerDamage(10, "BloodSplat", false, false);
SetLanternDisabled(true);
PlaySoundAtEntity("", "player_bodyfall", "Player", 0, false);
FadeRadialBlurTo(1, 0.5);
}

How is it possible for me to make these events triggered by the area, and is it possible to make the area in-active until the player finds the note at the end of the level?


RE: Area Triggers Help! - Your Computer - 08-17-2011

(08-17-2011, 05:10 AM)JetlinerX Wrote: How is it possible for me to make these events triggered by the area, and is it possible to make the area in-active until the player finds the note at the end of the level?

AddEntityCollideCallback(): pass "Player" and the area name into the two entity parameters. This only after the user has interacted with the note. For that you should be able to use SetEntityPlayerInteractCallback().


RE: Area Triggers Help! - JetlinerX - 08-17-2011

I'm actually pretty new to scripting, can you make that a tad more simple please?


RE: Area Triggers Help! - Your Computer - 08-17-2011

(08-17-2011, 05:19 AM)JetlinerX Wrote: I'm actually pretty new to scripting, can you make that a tad more simple please?
  • In OnStart(), SetEntityPlayerInteractCallback("name_of_note", "name_of_callback_function", true), which should call a function upon interacting with the note.

    • Inside the callback function put AddEntityCollideCallback("Player", "name_of_area", "name_of_callback_function", true, 1), which will call a function when player enters the area.

      • Inside the next callback function do all that stuff you posted.

Be sure to end each statement with a semicolon.


RE: Area Triggers Help! - JetlinerX - 08-17-2011

Soooo... Like this?

SetEntityPlayerInteractCallback("note_attic_desk1, "OnPickup", true);
AddEntityCollideCallback("Player", "scarearea1", "WHAT GOES HERE?!", true, 1);
{
GiveSanityDamage(20, true);
SetPlayerActive(false);
AddPlayerBodyForce(-40000, 25000, 0, false);
FadePlayerRollTo(75, 3, 2);
StartPlayerLookAt("level_celler_1", 2, 2, "");
SetPlayerCrouching(true);
AddTimer("", 2, "viimenen2");
AddTimer("", 10, "viimenen6");
GivePlayerDamage(10, "BloodSplat", false, false);
SetLanternDisabled(true);
PlaySoundAtEntity("", "player_bodyfall", "Player", 0, false);
FadeRadialBlurTo(1, 0.5);
}




RE: Area Triggers Help! - Your Computer - 08-17-2011

(08-17-2011, 05:44 AM)JetlinerX Wrote: Soooo... Like this?

Code:
void OnStart(){
     SetEntityPlayerInteractCallback("name_of_note", "name_of_first_callback_function", true);
}

void name_of_first_callback_function(string &in entity){
     if (entity == "name_of_note")
          AddEntityCollideCallback("Player", "name_of_area", "name_of_second_callback_function", true, 1);
}

void name_of_second_callback_function(string &in parent, string &in child, int state){
     if (parent == "Player" && child == "name_of_area")
     {
          // put all your stuff here...
     }
}



RE: Area Triggers Help! - JetlinerX - 08-17-2011

Oh! Okay! But what should the second callback function be?!


RE: Area Triggers Help! - Your Computer - 08-17-2011

(08-17-2011, 06:01 AM)JetlinerX Wrote: Oh! Okay! But what should the second callback function be?!

I'm not sure what you're asking here. The name of callback functions can be just about anything so long as they match the names specified in SetEntityPlayerInteractCallback() and AddEntityCollideCallback(), which they do in the code example i provided.


RE: Area Triggers Help! - JetlinerX - 08-17-2011

Oh, so they dont have to be something like: OnPickup, OnIgnite etc? My bad! I shall test now, and report back!
So I am getting these errors:
ExcuteString (1,1):ERR No Mathing Signatures to OnStart()
and
41,2 ERR Unexpected end of file (I dont have a line 41)

Here is my code, whats wrong?

Code:
void OnStart ()
{
AddEntityCollideCallback("Player", "attic_sound_scare1", "Noise", true, 1);
}
void Noise(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amb_idle_whimp.snt", "attic_sound_scare1", 0.0f, true);
PlaySoundAtEntity("", "insanity_baby_cry.snt", "attic_sound_scare1", 0.0f, true);
PlaySoundAtEntity("", "door_level_cistern_close.snt", "attic_sound_scare1", 0.0f, true);
PlaySoundAtEntity("", "general_thunder.snt", "attic_sound_scare1", 0.0f, true);
PlaySoundAtEntity("", "break_stairs.snt", "attic_sound_scare1", 0.0f, true);
PlaySoundAtEntity("", "lurker_hit_Wood", "mainatticscare", 0, false);
}
SetEntityPlayerInteractCallback("note_attic_desk1", "OnPickup", true);

void OnPickup(string &in entity){
     AddEntityCollideCallback("Player", "mainatticscare", "OnScare", true, 1);


void OnScare(string &in parent, string &in child, int state){
     if (parent == "Player" && child == "mainatticscare")
     {
          GiveSanityDamage(20, true);
         SetPlayerActive(false);
         AddPlayerBodyForce(-40000, 25000, 0, false);
         FadePlayerRollTo(75, 3, 2);
         StartPlayerLookAt("level_celler_1", 2, 2, "");
         SetPlayerCrouching(true);
         AddTimer("", 2, "viimenen2");
         AddTimer("", 10, "viimenen6");
         GivePlayerDamage(10, "BloodSplat", false, false);
         SetLanternDisabled(true);
         PlaySoundAtEntity("", "player_bodyfall", "Player", 0, false);
         FadeRadialBlurTo(1, 0.5);
     }

void OnLeave ()
{
}



RE: Area Triggers Help! - JetlinerX - 08-17-2011

Anyone know?