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



Amnesia script help - theodorg - 08-29-2014

So im tryng to make TWO keys open ONE door but only nailed it with one so far Smile
Any suggestions???


RE: Amnesia script help - PutraenusAlivius - 08-29-2014

Try using LocalVarInts that increments it's amount by 1 each time you used a key and then have a script to check if the LocalVarInt is 2 or not. If so, unlock the door.


RE: Amnesia script help - theodorg - 08-29-2014

(08-29-2014, 04:34 PM)First Captain Wrote: Try using LocalVarInts that increments it's amount by 1 each time you used a key and then have a script to check if the LocalVarInt is 2 or not. If so, unlock the door.

Am a little new to this so if you could post a script here it would be appreciated!


RE: Amnesia script help - FlawlessHappiness - 08-29-2014

void OnStart()
{
AddUseItemCallback("", "Key_1", "Door", "DoubleKeyOnDoor", false);
AddUseItemCallback("", "Key_2", "Door", "DoubleKeyOnDoor", false);
}

void DoubleKeyOnDoor(string &in asItem, string &in asEntity)
{
AddLocalVarInt("DoubleDoorVar", 1);
RemoveItem(asItem);

if(GetLocalVarInt("DoubleDoorVar") == 2)
{
SetSwingDoorLocked("Door", false, true);
}
}


There might be mistakes in this script, since I didn't test it. But it should work.


RE: Amnesia script help - theodorg - 08-29-2014

(08-29-2014, 04:48 PM)FlawlessHappiness Wrote: void OnStart()
{
AddUseItemCallback("", "Key_1", "Door", "DoubleKeyOnDoor", false);
AddUseItemCallback("", "Key_2", "Door", "DoubleKeyOnDoor", false);
}

void DoubleKeyOnDoor(string &in asItem, string &in asEntity)
{
AddLocalVarInt("DoubleDoorVar", 1);
RemoveItem(asItem);

if(GetLocalVarInt("DoubleDoorVar") == 2)
{
SetSwingDoorLocked("Door", false, true);
}
}


There might be mistakes in this script, since I didn't test it. But it should work.

Will it make a difference if the door is a level door? Put the script in but nothing happens but a unlock sound i put in when adding the second key.


RE: Amnesia script help - FlawlessHappiness - 08-29-2014

Yes, it makes a difference.

Because the script line you need to use then is SetLevelDoorLocked and not SetSwingDoorLocked.

You can find all the functions here:
https://wiki.frictionalgames.com/doku.php?id=hpl2/amnesia/script_functions

use Ctrl+F og Cmd+F to search


RE: Amnesia script help - Neelke - 08-29-2014

For a swing door.

SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);

For a level door.

SetLevelDoorLocked(string& asName, bool abLocked);