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
Help with scripting a "Scary Door"
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#1
Help with scripting a "Scary Door"

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:

////////////////////////////
// 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
09-25-2010, 09:55 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#2
RE: Help with scripting a "Scary Door"

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.

09-25-2010, 11:27 AM
Find
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#3
RE: Help with scripting a "Scary Door"

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
09-25-2010, 11:57 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#4
RE: Help with scripting a "Scary Door"

No problem, we all started at that point. Tongue

09-25-2010, 12:10 PM
Find




Users browsing this thread: 1 Guest(s)