Frictional Games Forum (read-only)
Script help. - 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: Script help. (/thread-21191.html)

Pages: 1 2


RE: Script help. - Storfigge - 04-17-2013

(04-17-2013, 01:55 AM)Yare Wrote: I think it will be like this, step by step:

Code:
SetLocalVarInt("BarrelCollisionCount", 0);

Just after "void OnStart/OnEnter" you declare a variable. It doesn't have to be "BarrelCollisionCount", name it as you wish.

Code:
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA1 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA2 NAME", "FUNCTION NAME", true, 1);
AddEntityCollideCallback("BARREL NAME", "SCRIPTAREA3 NAME", "FUNCTION NAME", true, 1);

Here we add collide callback for 3 script areas. You can do it this way, though for more than 2 objects I usually use "for" loop.

Code:
void FUNCTION NAME(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("BarrelCollisionCount", 1);
    if (GetLocalVarInt("BarrelCollisionCount")==3)
    {
        SetSwingDoorLocked("DOOR NAME", false, false);
        (And here put any other effects you would like to play. Maybe unlock sound, or something like that)
    }
}

Every time the function is played, it adds 1 to the variable and checks if the variable equals 3. On the 3rd collision it should unlock the door.

This was perfect thank you a lot Big Grin