Direction decides what script is called - 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: Direction decides what script is called (/thread-14836.html) |
Direction decides what script is called - Damascus - 04-16-2012 Okay this one is a tough one to describe, let alone program. I'm looking for a way to change which function is called depending on which direction you pass through a doorway. Basically, the player finds himself in a corridor where you come to an adjoining hallway, and a doorway into what I'll call the "green room" across from it. If you reach that junction by either direction in the corridor, the hallway is blocked. But, if you backtrack and get into the "green room" through a back entrance, then out the doorway, the hallway is clear. I'm trying to design the level so that, if you go INTO the back entrance to the green room, the blockage disappears, but if you go OUT OF the back entrance into the corridor, the blockage appears. I also want to be able to reset everything, so the blockage will keep appearing and disappearing if the player goes back and forth. Any help I can get for this? If all that was about as clear as mud, here's some screenshots to illustrate my point: Spoiler below!
Okay, I just sort of figured out how to do this on my own, but I'm still having a different problem with it. I just took those script areas next to those doorways and am going to have them open and close the passageway. The interior script areas are labeled "_1" and the exteriors are "_2" The fake_wall is a move object that raises when opened. I know it successfully moves because when you pick up a key, it opens. But, I can't get it to close again. void StudyKey(string &in asEntity) //picking up the key { SetMoveObjectState("fake_wall", 1); //this works AddEntityCollideCallback("Player", "LeftDoor_1", "OpenPass", false, 1); AddEntityCollideCallback("Player", "LeftDoor_2", "ClosePass", false, 1); AddEntityCollideCallback("Player", "RightDoor_1", "OpenPass", false, 1); AddEntityCollideCallback("Player", "RightDoor_2", "ClosePass", false, 1); } void OpenPass(string &in asParent, string &in asChild, int alState) { SetMoveObjectState("fake_wall", 1); SetMessage("Doors", "inside", 0); //works } void ClosePass(string &in asParent, string &in asChild, int alState) { SetMoveObjectState("fake_wall", 0); //won't close for some reason SetMessage("Doors", "inside", 0); //works } RE: Direction decides what script is called - nemesis567 - 04-16-2012 Create two areas close to each other and check if the player's speed is enough to make sure the player is actually moving and not changing direction or something else. Create a script area in front of each direction of the entrance. Now, to check the direction you check what combination of triggering the two areas in the doorway is done. Which one the player enters first and which one does he enter later. To avoid errors use the in front of each direction to make sure the player is turned into the direction pretended. RE: Direction decides what script is called - palistov - 04-16-2012 Another thing you could also do it make the script area so large it encloses the entire level past the point you want the collision to occur. That way there's only one possible way to enter it and one possible way to exit it. RE: Direction decides what script is called - Damascus - 04-16-2012 Well, I think I was making that way more complicated than it needed to be. I changed it to a SetEntityActive and it worked like a charm. PHP Code: void StudyKey(string &in asEntity) That way the fake wall is simply active or inactive depending on which side of each doorway you pass last. |