Frictional Games Forum (read-only)

Full Version: Make a Swing Door which has already been auto-closed swing open?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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)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.
Add this one too and it should work:

SetSwingDoorClosed("crowbardoor", false, false);
Thanks to Damascus' Solution, I got it to work. If you want an example script:

PHP Code:
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.