Frictional Games Forum (read-only)
Problem with Scripts: AddPropForce not working - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Problem with Scripts: AddPropForce not working (/thread-21741.html)



Problem with Scripts: AddPropForce not working - Webber1900 - 06-06-2013

Hello, I am trying to get a swing door to open slowly by itself using AddPropForce. An example of what I want is in the original Amnesia in the Rain Hall level. However for the past 2 hours I have been trying to do this but every single time I enter the script area, the door does nothing. Everything looks fine in the script but it just doesn't want to work.

Here is the entire script for the level:
Code:
//This is only executed when the map is loaded for the first time. Only happens once. Can be used for adding effects that should not repeat.//
void OnStart()
{  
    SetPlayerLampOil(70);
    GiveItemFromFile("lantern", "lantern.ent");
    AddEntityCollideCallback("Player", "Door_Creepy", "DoorOpens", true, 1);
}

void DoorOpens(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorClosed("CreepyDoor", false, false);
    SetSwingDoorDisableAutoClose("CreepyDoor", true);
    AddTimer("swing_door", 0.01f, "TimerDoor");
}

void TimerDoor(string &in asTimer)
{
    if(asTimer == "swing_door")
    {
        AddPropForce("CreepyDoor", 500.0f, 0.0f, 0.0f, "world");
    }
}

//This is executed every time you enter the level. Can be executed several times. Can be used for playing music and adding checks.//
void OnEnter()
{
    AddEntityCollideCallback("Player", "ReturnPlayerArea_0", "ReturnPlayer", false, 1);
}

void ReturnPlayer(string &in asParent, string &in asChild, int alState)
{
    TeleportPlayer("PlayerStartArea_1");
}

//This is executed every time you leave the level. Can be executed several times. Can be used for stopping music//
void OnLeave()
{

}

I just don't know what to do and need help.


RE: Problem with Scripts: AddPropForce not working - DeAngelo - 06-06-2013

I think you're not adding enough. From the wiki:

These functions push objects. Note that rather high values are needed when applying forces (on the order of ~100 (weak) to ~10000 (strong)),

Pump that number up a bit and you should see some effects.


RE: Problem with Scripts: AddPropForce not working - Webber1900 - 06-06-2013

That's not the problem unfortunately, I think it's the script or the AddEntityCollideCallback...


RE: Problem with Scripts: AddPropForce not working - DeAngelo - 06-06-2013

I don't think that "if astimer" part is needed. I've used tons of timers and never needed to use an if statement to get them to work.


RE: Problem with Scripts: AddPropForce not working - Webber1900 - 06-06-2013

I did some changes to the script and the objects in the level editor, and seems I can now only get it to work until after I interact with the door.

Here is the modified script:

Code:
//This is only executed when the map is loaded for the first time. Only happens once. Can be used for adding effects that should not repeat.//
void OnStart()
{  
    SetPlayerLampOil(70);
    GiveItemFromFile("lantern", "lantern.ent");
    AddEntityCollideCallback("Player", "TestDoorScript", "TestFunction", false, 1);
}

void TestFunction(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorClosed("mansion_1", false, false);
    SetSwingDoorDisableAutoClose("mansion_1", true);
    AddTimer("swing_door", 0.001f, "TimerDoor");
}

void TimerDoor(string &in asTimer)
{
    AddPropForce("mansion_1", -1000.0f, 0.0f, 0.0f, "world");
}

//This is executed every time you enter the level. Can be executed several times. Can be used for playing music and adding checks.//
void OnEnter()
{
    AddEntityCollideCallback("Player", "ReturnPlayerArea_0", "ReturnPlayer", false, 1);
}

void ReturnPlayer(string &in asParent, string &in asChild, int alState)
{
    TeleportPlayer("PlayerStartArea_1");
}

//This is executed every time you leave the level. Can be executed several times. Can be used for stopping music//
void OnLeave()
{

}



RE: Problem with Scripts: AddPropForce not working - PutraenusAlivius - 06-06-2013

AddPropForce must be above 2000 to get visible effects.