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
Get a door to open?
gruzz Offline
Member

Posts: 76
Threads: 24
Joined: Jun 2013
Reputation: 2
#1
Get a door to open?

Hello!

Creating a CS and i just want to know how i make a door open when i enter a area.. Found no guides on YT or on http://wiki.frictionalgames.com/hpl2/amn...ions#doors !

Please, help me! Smile
09-12-2013, 06:32 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#2
RE: Get a door to open?

I'm using SetSwingDoorDisableAutoClose and AddPropForce. Like this:

void NAMEOFSCRIPT()

SetSwingDoorDisableAutoClose("DOORNAME", true);
SetSwingDoorClosed("DOORNAME", false, false);

if(GetLocalVarInt("Door") == 8){
Some stuff you want to happen after the door has opened
}
else
{
AddTimer("", 0.15f, "DoorOpenRepeat");
AddPropForce("DOORNAME", 0.0f, 0, 100.0f, "World");
AddLocalVarInt("Door", 1);
}
void DoorOpenRepeat(string &in asTimer)
{
NAMEOFSCRIPT();
}

Quite simple. But I would recommend trying some stuff yourself. Also, the AddPropForce might not be correct so test it until it starts opening.
09-12-2013, 06:44 PM
Find
gruzz Offline
Member

Posts: 76
Threads: 24
Joined: Jun 2013
Reputation: 2
#3
RE: Get a door to open?

(09-12-2013, 06:44 PM)Neelke Wrote: I'm using SetSwingDoorDisableAutoClose and AddPropForce. Like this:

void NAMEOFSCRIPT()

SetSwingDoorDisableAutoClose("DOORNAME", true);
SetSwingDoorClosed("DOORNAME", false, false);

if(GetLocalVarInt("Door") == 8){
Some stuff you want to happen after the door has opened
}
else
{
AddTimer("", 0.15f, "DoorOpenRepeat");
AddPropForce("DOORNAME", 0.0f, 0, 100.0f, "World");
AddLocalVarInt("Door", 1);
}
void DoorOpenRepeat(string &in asTimer)
{
NAMEOFSCRIPT();
}

Quite simple. But I would recommend trying some stuff yourself. Also, the AddPropForce might not be correct so test it until it starts opening.

Well, as a guy who totally new to scripting, this honestly did not say much..
09-12-2013, 07:00 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#4
RE: Get a door to open?

In the wiki there are some great tutorials, not every one covers your need, however. The thing is learning what things do and learning it. Then, you can do it by yourself with your knowledge.

And I see that you are new to scripting, so I'm going to write the script for what you want and I'm going to explain what does what:

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea", "OPEN", true, 1);
}

///These lines (/) are commentary, useful when making very long scripts, so you can keep them tidied. So, here's an explanation of OnStart(), OnEnter() and all of that: http://wiki.frictionalgames.com/hpl2/amn...tions#main

////AddEntityCollideCallback means "Add a callback when an entity collides". The first 2 brackets are the ///entity that triggers an event when colliding (in this case, Player). "ScriptArea" is the name of the ///Entity/Area that has to receive the collision to trigger the event. This means that, when "Player" ///collides with "ScriptArea", "OPEN" will hapen. More information about the AddEntityCollideCallback:

///void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);


//Calls a function when two entites collide.


//Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)


//alState: 1 = enter, -1 = leave




//asParentName - internal name of main object


//asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)


//asFunction - function to call


//abDeleteOnCollide - determines whether the callback after it was called


//alStates - 1 = only enter, -1 = only leave, 0 = both

So:

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea", "OPEN", true, 1);
}

void OPEN (string &in asParent, string &in asChild, int alState) //http://www.frictionalgames.com/forum/thread-18368.html
{
SetSwingDoorDisableAutoClose("YourDoor", true); //This will stop the door from closing as soon as it opens.
SetSwingDoorClosed("YourDoor", false, true); //This opens the door so that the force will do something, and not act like throwing a book at a closed door.

AddPropForce(entity, 0, 0, -900, "world"); //This will actually push the door open. This assumes that the door opens towards -Z, and "world" tells it to use the -Z
//for the level editor, and not base on I suppose the direction the player is facing? You'd probably almost always want "world" and not something else.


}

And that's the script explained. Have a nice scripting time! Smile

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
09-12-2013, 08:09 PM
Find




Users browsing this thread: 1 Guest(s)