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


Script help. - Storfigge - 04-16-2013

I wonder how to make like. Let's say I have three collide areas. When I place a barrel in one area nothing happens, but then if I place one barrel in each collide area a door open. So with to open the door I must place an object in three different areas. How to do this Tongue


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

Just noticed that I posted this in the wrong place -.- I tried to delete it but it doesn't work.


RE: Script help. - 7heDubz - 04-16-2013

sounds like it would be a condition.. (If there is a barrel in these 3 area's then door will open) not sure how to do this though im a very basic scripter.

As for the second a mod will move it (I'll PM statyk and let him know.)


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

Moved to development support.


RE: Script help. - 7heDubz - 04-17-2013

Thaaanks Traggey!


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

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.


RE: Script help. - PutraenusAlivius - 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.
You put the SetLocalVarInt to the void OnStart() part. And if the Player must do all this to unlock a door, and if it locks again if no barrels are in place then you'll need another script.


RE: Script help. - Linus Ågren - 04-17-2013

Keep in mind that unless you make the barrels unmovable after it has been placed, the player can freely remove the barrels and still have the possibility to unlock the door. To avoid this, I would make three separate variables. For each of the areas the barrels are supposed to stand in, I would make sure that the alState of the collide area can be triggered both when inside, and outside of the box. When the barrel is inside the box, the variable would be set to 1 and when outside, it would be set back to 0.
That way, the barrels must be inside the areas in order to unlock the door.


RE: Script help. - Your Computer - 04-17-2013

The script provided satisfies what Storfigge wanted, since only one barrel is going to be used for the three areas anyway, not three barrels for three areas.


RE: Script help. - Linus Ågren - 04-17-2013

Quote: but then if I place one barrel in each collide area a door open
I went from that, which he implies that it is one for each collide, hence three barrels.