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


Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"If in an area..." Script Problem
Dr4konite Offline
Junior Member

Posts: 12
Threads: 1
Joined: Oct 2010
Reputation: 0
#1
"If in an area..." Script Problem

Hey Guys.

I successfully scripted my way through the first events of my map, but now I got to a problem, which I don't know how to solve. Even the search engine gave me no results on this, so maybe you can help me out.

First of all my idea:
I scripted an event, that makes a key disappear on pickup, starting a timer which will initialise another event a little bit later. In this event, a door will crack open but before this happens, the player still got time (and is advised) to hide himself (as for this expample it's in a cabinet).

Now there are two ways the player can act:
1. He stays in the room, not hiding himselft. In this case, I want to let him faint when the door cracks open.
2. He hides in the cabinet (my "Safe-Area"), where he will not faint or loose much sanity.

So I'm thinkin about "disabling" a command, when the player is in this area (cabinet) so he won't faint, but I don't know if this is the right way and if the command "AddEntityCollideCallback" is the right choice, because the player should not collide, but be "in" the area.

Hope you can help me.
Greetings
Dr4konite
10-28-2010, 04:41 PM
Find
SLi78 Offline
Junior Member

Posts: 23
Threads: 6
Joined: Sep 2010
Reputation: 0
#2
RE: "If in an area..." Script Problem

(10-28-2010, 04:41 PM)Dr4konite Wrote: Hey Guys.

I successfully scripted my way through the first events of my map, but now I got to a problem, which I don't know how to solve. Even the search engine gave me no results on this, so maybe you can help me out.

First of all my idea:
I scripted an event, that makes a key disappear on pickup, starting a timer which will initialise another event a little bit later. In this event, a door will crack open but before this happens, the player still got time (and is advised) to hide himself (as for this expample it's in a cabinet).

Now there are two ways the player can act:
1. He stays in the room, not hiding himselft. In this case, I want to let him faint when the door cracks open.
2. He hides in the cabinet (my "Safe-Area"), where he will not faint or loose much sanity.

So I'm thinkin about "disabling" a command, when the player is in this area (cabinet) so he won't faint, but I don't know if this is the right way and if the command "AddEntityCollideCallback" is the right choice, because the player should not collide, but be "in" the area.

Hope you can help me.
Greetings
Dr4konite



I would use a flag variable for example an int value.

In the Function that is called when the player collides wit the area you set the value on 1 for safe.

If the player is leaving the safe area you set 0 for not safe.

In your timerfunction you just lok for the flag with an if-statement.
10-28-2010, 04:52 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#3
RE: "If in an area..." Script Problem

AddEntityCollideCallback is the right way to go. Choose int alStates = 0 as parameter so it triggers when entering and leaving. Then add an if-clause in the callback function asking for the state.
Example: AddEntityCollideCallback("Player", "InsideCabinetArea", "CabinetStuff", false, 0);
void CabinetStuff(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {                //when entering
//disable faint trigger
}
else                 //which would be on alState == -1 which is leaving
{
//enable faint trigger
}
}

10-28-2010, 05:40 PM
Find
Dr4konite Offline
Junior Member

Posts: 12
Threads: 1
Joined: Oct 2010
Reputation: 0
#4
RE: "If in an area..." Script Problem

First of all: Thank you for your answers!

The problem is that if the player never enters the area, the faint function will not be triggered.
It worked when I entered the area (the cabinet in which the area is placed) - the function gave me my testing-message, but not if I just stayed outside (nothing happened there).
And that's what I want to have: The player faints when staying outside (in this case he never even touches the area) and he don't faint when inside the area. I was thinking about just reversing the areas, but I imagine this won't solve the problem. In addition, I would actually need a area that isn't rectangular, hehe.

Is there any function that you can use like "If the callback function is not triggered"? Or did I just do anything wrong?

Hope I don't annoy you with this, but it's really important for my storyline. Depending on if the player faints or not, the story will take different twists.

Greetings
Dr4konite
10-28-2010, 11:37 PM
Find
Dr4konite Offline
Junior Member

Posts: 12
Threads: 1
Joined: Oct 2010
Reputation: 0
#5
RE: "If in an area..." Script Problem

Okay, got the problem fixed by myself.

I'll add the code later on, if wanted. Actually this may be a good one for the script collection...

Greetings
Dr4konite
10-30-2010, 10:59 AM
Find




Users browsing this thread: 1 Guest(s)