Actually I'm having troubles too. It's only slamming the door, whether it's already closed or open.
Firstly, I have this in my void OnStart section:
//Callback to slam door
AddEntityCollideCallback("Player", "area_lock_door", "CollideLock", true, 1);
//Function called when player steps into area_lock_door
void CollideLock(string &in asParent, string &in asChild, int alState)
{
//Door is closed so activate CreakOpen function
if(GetSwingDoorClosed("castle_1") == true)
CreakOpen();
//Door is open so slam it shut
else
StartPlayerLookAt("castle_1", 3, 4, "");
AddTimer("", 0.5f, "TimerSlamDoor");
}
void TimerSlamDoor(string &in asTimer)
{
SetSwingDoorClosed("castle_1", true, true);
SetSwingDoorLocked("castle_1", true, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
AddTimer("", 3.0f, "TimerStopLook");
}
void CreakOpen()
{
SetSwingDoorDisableAutoClose("castle_1", true);
SetSwingDoorClosed("castle_1", false, false);
StartPlayerLookAt("castle_1", 2, 2, "");
GiveSanityDamage(5.0f, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
AddTimer("castle_1", 0.05f, "TimerCreakDoor");
AddTimer("castle_1", 0.1f, "TimerCreakDoor");
AddTimer("castle_1", 0.2f, "TimerCreakDoor");
AddTimer("castle_1", 0.3f, "TimerCreakDoor");
AddTimer("", 3.0f, "TimerStopLook");
}
void TimerCreakDoor(string &in asTimer)
{
AddPropForce("castle_1", 1, 0, 0, "World");
}
void TimerStopLook(string &in asTimer)
{
StopPlayerLookAt();
}