HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
picking up item activating script area
hey guys. i was wondering if i could do this. lets say a player walks through a hallway until the end and nothing happens. Lets says there's a key waiting at the end of the hallway. I want it so that when the player picks up the key, it activates a script area that is located in the hall way that the player previously crossed and when the player collides with it, it activates a scare. I just cant find out how to do this. Is there and engine script that sets a script area active after picking up an item? please help!
|
|
07-08-2012, 09:05 AM |
|
Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
|
RE: picking up item activating script area
I'm pretty sure you could use this code:
SetEntityActive("Area_Name", false);
For Area's too.
CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
|
|
07-08-2012, 09:30 AM |
|
Cruzore
Senior Member
Posts: 301
Threads: 2
Joined: Jun 2012
Reputation:
37
|
RE: picking up item activating script area
you could also just add the callback under the function for the key pickup, instead of adding it to OnStart() and setting it inactive.
Think, before you speak Google, before you post
|
|
07-08-2012, 10:34 AM |
|
ApeCake
Member
Posts: 116
Threads: 20
Joined: Jun 2012
Reputation:
4
|
RE: picking up item activating script area
I prefer this way; put a name in the "PlayerInteractCallback" of your key, I put "ActivateMonsterKey" there.
Then, go to your .hps file and write;
void ActivateMonsterKey(string &in entity)
{
AddEntityCollideCallback("Player", "NameofScriptArea", "nameoffunction", true, 1);
}
void nameoffunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("NameofMonster", true);
}
I'm pretty certain that this works. Make sure to set the script area ACTIVE (in the level editor) and the monster INACTIVE.
Explaination (although it is very simple); PlayerInteractCallback activates when the player interacts with the entity. With a door it activates at the moment the player opens the door. However, there is NO other interactivity than picking up with keys. So, when you interact with the key AKA pick it up, this activates the EntityCollideCallback. So, now your script area has a function, before this it was just an invisible wall, but now you gave it code. So, when the player collides with the script area, "nameoffunction" happens. "nameoffunction" sets the monster active thanks to SetEntityActive. I hope that was clear enough, I suck at explaining things.
There are multiple ways (see above posts), but I prefer this one.
(This post was last modified: 07-08-2012, 12:34 PM by ApeCake.)
|
|
07-08-2012, 12:28 PM |
|
HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
RE: picking up item activating script area
(07-08-2012, 12:28 PM)ApeCake Wrote: I prefer this way; put a name in the "PlayerInteractCallback" of your key, I put "ActivateMonsterKey" there.
Then, go to your .hps file and write;
void ActivateMonsterKey(string &in entity)
{
AddEntityCollideCallback("Player", "NameofScriptArea", "nameoffunction", true, 1);
}
void nameoffunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("NameofMonster", true);
}
I'm pretty certain that this works. Make sure to set the script area ACTIVE (in the level editor) and the monster INACTIVE.
Explaination (although it is very simple); PlayerInteractCallback activates when the player interacts with the entity. With a door it activates at the moment the player opens the door. However, there is NO other interactivity than picking up with keys. So, when you interact with the key AKA pick it up, this activates the EntityCollideCallback. So, now your script area has a function, before this it was just an invisible wall, but now you gave it code. So, when the player collides with the script area, "nameoffunction" happens. "nameoffunction" sets the monster active thanks to SetEntityActive. I hope that was clear enough, I suck at explaining things.
There are multiple ways (see above posts), but I prefer this one. makes perfect sense to me. Thanks
|
|
07-08-2012, 10:14 PM |
|
|