Frictional Games Forum (read-only)
Can you re-enable areas once used? - 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: Can you re-enable areas once used? (/thread-13867.html)

Pages: 1 2


Can you re-enable areas once used? - Nevicar - 03-09-2012

Example:
There is a room where the player walks into, the door behind them closes as they enter via a script, but then don't collect the item from the room and has to come back to it. Is it possible to have the area reset and have it activate again when the player passes through it in an event that happens later in the level on the way to the end of the level?

I... think that's clear.


RE: Can you re-enable areas once used? - jessehmusic - 03-09-2012

void OnStart()
{

AddEntityCollideCallback(" ", "Script Area", "callback1", true, 1);

AddEntityCollideCallback(" ", "
Script Area ", "callback2", true, 1);

}


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


{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}




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

{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

try that dude Smile
and you that If(Haveitem) bla bla bla or how that script is

http://wiki.frictionalgames.com/hpl2/amnesia/script_functions#sounds_music


RE: Can you re-enable areas once used? - flamez3 - 03-09-2012

(03-09-2012, 08:01 AM)Nevicar Wrote: Example:
There is a room where the player walks into, the door behind them closes as they enter via a script, but then don't collect the item from the room and has to come back to it. Is it possible to have the area reset and have it activate again when the player passes through it in an event that happens later in the level on the way to the end of the level?

I... think that's clear.
In the callback, change the "true" to "false". Like:

AddEntityCollideCallback(" ", "Script Area", "callback1", false, 1);




RE: Can you re-enable areas once used? - Nevicar - 03-09-2012

The easiest answer is always the right one... ugh.

Thanks!


RE: Can you re-enable areas once used? - flamez3 - 03-09-2012

np ^^


RE: Can you re-enable areas once used? - Your Computer - 03-09-2012

Also, script areas are considered "entities" for the SetEntityActive function.


RE: Can you re-enable areas once used? - Nevicar - 03-09-2012

Alright, it's not all fixed, I tried to venture into the valley of if statements and constructed this.

AddEntityCollideCallback("Player", "Area_7", "fdoorclose_func1", true, 1);

void fdoorclose_func1(string &in asParent, string &in asChild, int alState)
{
if (HasItem("key1")) SetEntityActive("Area_6", false);
else SetEntityActive("Area_6", true);
}

Basically a character walks out of the room and through an area to check if he has the key, if he doesn't have it then the area should be activated, but it doesn't get activated so obviously what I'm doing is wrong. Any ideas?


RE: Can you re-enable areas once used? - Nevicar - 03-09-2012

Anyone have any idears?


RE: Can you re-enable areas once used? - Your Computer - 03-09-2012

(03-09-2012, 08:54 AM)Nevicar Wrote: Any ideas?

For starters, you need to think things through before engaging in scripting. Do you want the collision callback to be removed when colliding with Area_7? Is Area_6 in the same map? What state do you want Area_6 to be in before the player collides with Area_7? What is the purpose of Area_6 when active?


RE: Can you re-enable areas once used? - Nevicar - 03-09-2012

Basically right now I have the area set to inactive. I have two sets of areas that are both right next to each (Area_4 and Area_6) other that do the same thing, close the door.

This is the best way I can sum up the way I want it to work, and the way I thought it through while attempting to code it:

1) Player enters the room, Area_4, and the door closes behind him, that function is gone and used.

2)The player then leaves the room without collecting the key which does not activate (Area_3) the other area in the room to use that when the player passes inside of it, making the door close worthless.

3) The player leaves the room and then collides with Area_7 and this area is supposed to check the player for the key and if he has it Area_6 stays inactive, but if he doesn't it becomes active.

Hope that didn't sound snobby and pretentious in the way I worded it out, I appreciate the help and know that I do need to think things through before delving into coding it all.