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
Script Help Make a Swing Door which has already been auto-closed swing open?
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#1
Make a Swing Door which has already been auto-closed swing open?

Hey there all. I've got a small problem. I'm trying to do an event where a door slowly swings open. However, the player will likely interact with this door beforehand which might result it being "auto-closed". The script I have so far:

SetSwingDoorDisableAutoClose("crowbardoor", true);
AddPropForce("crowbardoor",-800,0,0,"world");

This only seems to work if the player has not interacted with the door in a way that would let it become auto-closed, which given the nature of the level, the player is likely to do.

Any idea on how to fix this? If anyone needs more info, I'd be happy to give it.
06-28-2012, 06:25 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#2
RE: Make a Swing Door which has already been auto-closed swing open?

If you disable autoclose right before slowly opening it, it should still work.
Or, if you mean that the door might be open before, close it before the player has a sight of it.
06-28-2012, 06:28 PM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#3
RE: Make a Swing Door which has already been auto-closed swing open?

(06-28-2012, 06:28 PM)FastHunteR Wrote: If you disable autoclose right before slowly opening it, it should still work.
But I've already tried that as seen in my script. I disabled auto-close prior to applying the force.
Quote:Or, if you mean that the door might be open before, close it before the player has a sight of it.
No, the door will start off closed. It's just that after the player interacts with it, my scripts can only play their part right if the player does not close the door behind them.

Here's a breakdown of the scene I'm trying to do:
Player enters a room
After entering player can choose to leave the door he just entered through open, or close it behind him.
Player picks up item
Player turns around to leave
Door slowly opens

As I've said, the second step is key, and I can't seem to stop the door from auto-closing if the player has interacted with it.

EDIT: Ah, seem to have solved it. I added a timer which repeats "SetSwingDoorDisableAutoClose("crowbardoor", true);" every 0.01 seconds, which is more than enough to stop the door from ever closing.
(This post was last modified: 06-28-2012, 06:55 PM by Kreekakon.)
06-28-2012, 06:34 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#4
RE: Make a Swing Door which has already been auto-closed swing open?

Add this one too and it should work:

SetSwingDoorClosed("crowbardoor", false, false);

06-28-2012, 07:14 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#5
RE: Make a Swing Door which has already been auto-closed swing open?

Thanks to Damascus' Solution, I got it to work. If you want an example script:

PHP Code: (Select All)
void OnStart()
{
 
SetEntityCallbackFunc("ItemnameHere""OnPickup");
}
void OnPickup(string &in asEntitystring &in astype)
{
if(
asEntity == "CrowbarNameHere")
{
SetEntityPlayerLookAtCallback("ScriptAreaNameHere""CloseDoorFunc"true);
}
}
void CloseDoorFunc(string &in asEntityint alState
{
if(
GetSwingDoorState("DoorNameHere")==-1)
{
SetSwingDoorDisableAutoClose("DoorNameHere"true); 
SetSwingDoorClosed("DoorNameHere"falsefalse); 
AddPropForce("DoorNameHere", -80000"world");
}


Now for how I did it:
At first, we got a entity callback for picking up the item(function name must be Onpickup).
Inside the function, we set up a look at callback for a script area, which is around the door(the whole wall, not just the door). When you look at that area, the CloseDoorFunc will be run, where, if the door is closed(state = -1), it will disable the autoclose, it will open the door and use AddpropForce to slightly open it.
06-28-2012, 07:33 PM
Find




Users browsing this thread: 1 Guest(s)