Frictional Games Forum (read-only)
Is it possible to make monsters open doors? - 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: Is it possible to make monsters open doors? (/thread-22255.html)



Is it possible to make monsters open doors? - serbusfish - 07-28-2013

I was wondering if its possible to make monster not break doors when going through them but instead have the door open and let them through?


RE: Is it possible to make monsters open doors? - PutraenusAlivius - 07-28-2013

Sure. Have a script to open the door when the monster simultaneously in front of the door. To do this, add a script area and a AddEntityCollideCallback script but with the Monster as the Parent object.


RE: Is it possible to make monsters open doors? - The chaser - 07-28-2013

Which is the same as:

void OnStart()
{
AddEntityCollideCallback("Monster", "ScriptDoor", "OpenLikeMoses", true, 1);
}

void OpenLikeMoses (string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("Door", false, false);
AddBodyForce("Door_body_1", 0, 0, 0, "world"); ///Without Body force, it won't work, so you have to play with the numbers
}


RE: Is it possible to make monsters open doors? - serbusfish - 07-28-2013

Ah that sounds great, simple yet (should) be effective, thanks!


RE: Is it possible to make monsters open doors? - Adrianis - 07-29-2013

(07-28-2013, 10:42 AM)The chaser Wrote: AddBodyForce("Door_body_1", 0, 0, 0, "world"); ///Without Body force, it

Just to add to this, if you use the coordinate setting "local" rather than "world" as the 5th parameter, then it uses the coordinates (x,y,z) of the door entity itself, rather than the whole world. That means that if you have 2 doors at a right angle to each other, you can apply force in the same direction and it will still open it, meaning you can use 1 generic function for any door

For example, I used this function in a test i was doing

Code:
void OnStart()
{
    SetEntityPlayerInteractCallback("castle_1", "OpenTheDoors", false);
    SetEntityPlayerInteractCallback("castle_arched01_1", "OpenTheDoors", false);
    SetEntityPlayerInteractCallback("prison_1", "OpenTheDoors", false);
    SetEntityPlayerInteractCallback("sewer_arched_1", "OpenTheDoors", false);
    SetEntityPlayerInteractCallback("metal_1", "OpenTheDoors", false);
}

void OpenTheDoors(string &in strEnt)
{
    SetSwingDoorDisableAutoClose(strEnt, true);
    if (GetSwingDoorClosed(strEnt)) SetSwingDoorClosed(strEnt, false, true);
    AddPropImpulse(strEnt, 0, 0, 4, "Local");
}

That meant I could call OpenTheDoors("name_of_any_door") or use SetEntityPlayerInteractCallback to swing open any door, keeping the function generic enough to work (with the exception of mansion doors, iirc)
Should be easy to transfer that idea to using an area collide callback