Frictional Games Forum (read-only)
Key to a level door - 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: Key to a level door (/thread-22370.html)



Key to a level door - MaTPlays - 08-08-2013

Hello everyone Smile
That's me again. I'm looking for a totorial or help from you, how to make a key which unlocking a level door. Thanks!


RE: Key to a level door - DeAngelo - 08-08-2013

Exact same way you'd make a key unlock a swing door, but instead of the "setswingdoorlocked" part you'd use
SetLevelDoorLocked(string& asName, bool abLocked);


RE: Key to a level door - MaTPlays - 08-08-2013

Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}


RE: Key to a level door - The chaser - 08-08-2013

(08-08-2013, 09:49 PM)MaTPlays Wrote: Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

There, it should be fixed. It's:

SetLevelDoorLocked(string& asName, bool abLocked);
For swing doors:

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


RE: Key to a level door - MaTPlays - 08-08-2013

Now the error is, that this is unexpected end of file. Idk why, because I changed nothing at the end :/






void OnStart()
{
SetSkyBoxActive(true);
SetSkyBoxTexture("Name.dds");
SetPlayerLampOil(0.0f);
AddUseItemCallback("", "Keymaindoor', "Door_1", "UseKeyOnDoor_1", true);
}




void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}




void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("Door_3"))
{
SetMessage("Messages", "Msgname", 0);
}
}




void DoorLockedPlayer_1(string &in entity)
{
if(GetLevelDoorLocked("Door_1", true)
{
SetMessage("Messages", "Msgname1", 0);
}
}


RE: Key to a level door - The chaser - 08-08-2013

The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

You'll have to make a workaround for this...


RE: Key to a level door - MaTPlays - 08-08-2013

Ok, I deleted it. Now everything is working. Thanks for help.


RE: Key to a level door - Tomato Cat - 08-09-2013

(08-08-2013, 11:07 PM)The chaser Wrote: The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

You'll have to make a workaround for this...

Oh wait. You're right. It doesn't exist. :U


RE: Key to a level door - The chaser - 08-09-2013

I have thought a workaround:

Make a script area that has the shape of the level door, and name it "AreaLevel". Now, go to the Area panel and search for Player Interact Callback. There, put "Touch" (without quotation marks)
You know you can use items (like keys) in ScriptAreas, right?

Put this in your script:

void OnStart()
{
SetLocalVarInt("Area_locked_level", 1);
SetEntityCallbackFunc("Key", "WhenPicked"); //Key must be the name of your key
}

void WhenPicked (string &in asEntity, string &in asType)
{
SetLocalVarInt("Area_locked_level", 0);
}

void Touch (string &in asEntity)
{
if (GetLocalVarInt("Area_locked_level") == 1)
{
SetMessage("Messages", "Msgname1", 0);
}
if (GetLocalVarInt("Area_locked_level") == 0)
{
SetLevelDoorLocked("Door_1", false);
SetEntityActive("AreaLevel", false);
}
}

The player won't have to use the key by itself, but I think it's a good workaround.


RE: Key to a level door - MaTPlays - 08-09-2013

Wow, man, thanks! It really working. I'm beginner, learning by creating a custom story. I need to understand a lot of scripts, and that's why I'm asking here for help.