The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove a Timer Loop which opens a door using AddPropForce?
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#1
How to remove a Timer Loop which opens a door using AddPropForce?

I wanted to make a door open by itself slowly behind the player and used Frictional's code in their .hps of the first level (Rainy Hall) as reference.
The door opens nicely and behaves as expected, but I can't figure out how to remove the loop so the player can close the door without it wanting to open again Sad

Here's the code:

void OpenDoor(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorClosed("prison_section_2", false, false);
    SetSwingDoorDisableAutoClose("prison_section_2", true);
    AddTimer("swing_door", 0.01f, "TimerDoor");
    AddTimer("stop_creak", 1.5f, "TimerCreak");
}

void TimerDoor(string &in asTimer)
{
    if(asTimer == "swing_door")
    {
        AddPropForce("prison_section_2", 0.0f, 0.0f, 25.0f, "");
    }
    else
    {
        AddPropForce("prison_section_2", 0.0f, 0.0f, -95.0f, "");
    }
    AddTimer(asTimer, 0.03, "TimerDoor");
}

void TimerCreak(string &in asTimer)
{
    RemoveTimer("swing_door");
    PlaySoundAtEntity("pant", "react_scare.snt", "Player", 0.0f, false);
}

I think it has something to do with the devs using the same string for the timer and door name, but I can't really figure out how.


DEV VERSION
Spoiler below!
/*When in hall4 gallery door swings open slowly
*/
void CollideAreaGalleryDoor(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorClosed("door_gallery", false, false);
    SetSwingDoorDisableAutoClose("door_gallery", true);
    
    PlaySoundAtEntity("creaking_door", "joint_door_move_special.snt", "door_gallery", 1.0 / 0.7f, false);
    
    AddTimer("door_gallery", 0.01f, "TimerSwingDoor");
    
    AddDebugMessage("Boho, the gallery door creaks open.", false);    
    
    AddTimer("stopcreak", 2.0f, "TimerStopCreak");
}
void TimerSwingDoor(string &in asTimer)
{
    if(GetLocalVarInt("SwingDoor") == 10){
        SetLocalVarInt("SwingDoor", 0);
        return;
    }
    
    if(asTimer == "door_gallery") AddPropForce(asTimer, 70.0f, 0, 0, "World");
    else AddPropForce(asTimer, -95.0f, 0, 0, "World");
    
    AddLocalVarInt("SwingDoor", 1);
    
    AddTimer(asTimer, 0.03f, "TimerSwingDoor");
    
    AddDebugMessage("Swing: "+GetLocalVarInt("SwingDoor"), false);
}
void TimerStopCreak(string &in asTimer)
{
    if(asTimer == "scare2"){
        PlaySoundAtEntity("scare", "react_scare.snt", "Player", 1.0 / 1, false);
        return;
    }
    if(asTimer == "scare"){
        PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0, false);
        //PlaySoundAtEntity("laugh", "00_laugh.snt", "door_gallery", 1.0 / 1, false);
        PlaySoundAtEntity("loop", "00_loop.snt", "Player", 1.0 / 0.1f, false);
        return;
    }
    if(asTimer == "breath1"){
        PlaySoundAtEntity("breath", "react_breath.snt", "Player", 1.0 / 1, false);
        return;
    }
    if(asTimer == "breath2"){
        PlaySoundAtEntity("breath", "react_breath.snt", "Player", 1.0 / 0.9f, false);
        return;
    }
    if(asTimer == "breath3"){
        //SetSwingDoorLocked("door_gallery", false, true);
        PlaySoundAtEntity("breath", "react_breath.snt", "Player", 1.0 / 0.8f, false);
        AddTimer("lookloop", RandFloat(2.0f,3.0f), "TimerRandomLook");    //Re-activate the spinning head
        FadePlayerFOVMulTo(1.0f, 0.1f);
        StopSound("loop", 1);
        StartScreenShake(0.01f,0.25f, 0.01f,0.5f);
        return;
    }
    if(asTimer == "lightsout"){
        SetLampLit("chandelier_nice_1", false, true);
        SetLampLit("candlestick_floor_2", false, true);
        FadeLightTo("PointLight_25", 0, 0, 0, 0, 0, 1);
        FadePlayerFOVMulTo(1.5f, 0.25f);
        return;
    }
    
    if(asTimer == "sanity"){
        //SetSwingDoorLocked("door_gallery", true, false);
        GiveSanityDamage(10, true);
        return;
    }
    
    StopSound("creaking_door", 0.4f);
}



╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
12-11-2010, 05:29 PM
Find


Messages In This Thread
How to remove a Timer Loop which opens a door using AddPropForce? - by Frontcannon - 12-11-2010, 05:29 PM



Users browsing this thread: 1 Guest(s)