Frictional Games Forum (read-only)
Help with scripting a "Scary Door" - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Help with scripting a "Scary Door" (/thread-4742.html)



Help with scripting a "Scary Door" - Equil - 09-25-2010

I'm very new to this whole scripting thing and only know a few very basic things, so any help is appreciated.

I've been lurking for a while now looking on how to script a "Scary Door" properly. I saw some threads which did help, it's now functioning properly, slamming shut when the player enters the area I specified.

However, the area still triggers the whole event of slamming and sanity damage when the player enters the area even if the door is closed. I want the event to not occur at all if the player enters the room, closes the door then enters the area.

I know this can be remedied somehow with the "GetSwingDoorClosed" function in an if else ladder, I've experimented with those to no avail, only receiving errors or no results. I believe it's a simple fix but I'm just unsure of how to do this, so again, any help is appreciated.

Here is the existing script:

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
  
    PlayMusic("10_amb.ogg", true, 1.0f, 0, 0, true);
    SetPlayerLampOil(0);
    
    SetEntityPlayerInteractCallback("Door1", "InteractedWithDoor", true);
    AddEntityCollideCallback("Player", "AreaDoorSlam1", "DoorSlam", true, 1);
    
    
}

void InteractedWithDoor(string &in entity)  
{
PlaySoundAtEntity("Grunt", "notice.snt", "AreaGrunt", 0, false);
}


void DoorSlam(string &in asParent, string &in asChild, int alState)
{
  
  StartPlayerLookAt("Door1", 4, 5, "");
  AddTimer("Slam", 0.5f, "TimerSlamDoor");
  
}

void TimerSlamDoor(string &in asTimer)
{
    SetSwingDoorClosed("Door1", true, true);    
    PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);        
    GiveSanityDamage(5.0f, true);
    AddTimer("Stoplook", 1.0f, "PlayerStopLook");
}

void PlayerStopLook(string &in asTimer)
{

//Player stops looking at object
StopPlayerLookAt();

}

    
        
  
////////////////////////////[/quote]
// Run when entering map
void OnEnter()
{

I would appreciate it greatly if someone could point out where this code needs to be. Thanks in advance. Smile


RE: Help with scripting a "Scary Door" - Pandemoneus - 09-25-2010

Code:
void DoorSlam(string &in asParent, string &in asChild, int alState)
{
  if(GetSwingDoorClosed("Door1") == false){
  StartPlayerLookAt("Door1", 4, 5, "");
  AddTimer("Slam", 0.5f, "TimerSlamDoor");
  }
}

When the player enters the area AreaDoorSlam1, the function will still trigger but it won't do anything when the door is closed.


RE: Help with scripting a "Scary Door" - Equil - 09-25-2010

Thanks for that, I knew it was something simple, it works fine now.

I do apologize that I'm completely new at this, but I'm slowly learning and look forward to making great scripts. Thanks again. Smile


RE: Help with scripting a "Scary Door" - Pandemoneus - 09-25-2010

No problem, we all started at that point. Tongue