Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Direction decides what script is called
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#1
Direction decides what script is called

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!

Approaching from around the hallway blocks the exit.
[Image: ujoYe.jpg]
Approaching from the central room opens the exit.
[Image: ZzX62.jpg]


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
}

(This post was last modified: 04-16-2012, 11:07 AM by Damascus.)
04-16-2012, 10:37 AM
Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#2
RE: Direction decides what script is called

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.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
04-16-2012, 12:39 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#3
RE: Direction decides what script is called

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.

04-16-2012, 05:06 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#4
RE: Direction decides what script is called

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: (Select All)
void StudyKey(string &in asEntity)
{
    
SetEntityActive("fake_wall"false);
    
AddEntityCollideCallback("Player""LeftDoor_1""OpenPass"false1);
    
AddEntityCollideCallback("Player""LeftDoor_2""ClosePass"false1);
    
AddEntityCollideCallback("Player""RightDoor_1""OpenPass"false1);
    
AddEntityCollideCallback("Player""RightDoor_2""ClosePass"false1);
}

void OpenPass(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("fake_wall"false);
}

void ClosePass(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("fake_wall"true);


That way the fake wall is simply active or inactive depending on which side of each doorway you pass last.

(This post was last modified: 04-16-2012, 08:25 PM by Damascus.)
04-16-2012, 08:24 PM
Find




Users browsing this thread: 1 Guest(s)