![]() |
Locked 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: Locked doors (/thread-18436.html) |
Locked doors - Storfigge - 09-21-2012 Hello! I am very new with HPL editor and im working on my first custom story. I have no real coding experience but it's gone quite good so far. The problem I have right now is that i first made a locked door and managed to create a key that opens it. Now I've made a new locked door with a key that's suppose to open it. The thing is that when i unlock my first door the second one also unlocks. I can still use my second key on my second unlocked door. I've put the door on locked in the editor so I don't know what the problem is ![]() Here is the code for the doors. { AddUseItemCallback("", "key1", "bedroomdoor1", "UsedKeyOnDoor", true); AddUseItemCallback("", "key2", "bedroomdoor2", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("bedroomdoor1", false, true); PlaySoundAtEntity("", "unlock_door", "bedroomdoor1", 0, false); RemoveItem("key1"); SetSwingDoorLocked("bedroomdoor2", false, true); PlaySoundAtEntity("", "unlock_door", "bedroomdoor2", 0, false); RemoveItem("key2"); } RE: Locked doors - Chap - 09-21-2012 I'm not so good with code but from my assumption you've put both unlock statements in the same method. So any time someone unlocks bedroomdoor1 or 2, both doors are called to be unlocked. Try making another method for each door. Otherwise if all doors are under this same function, then every door in your level will have the same problem. Something like this: void UsedKeyOnDoor2(string &in asItem, string &in asEntity) { SetSwingDoorLocked("bedroomdoor2", false, true); PlaySoundAtEntity("", "unlock_door", "bedroomdoor2", 0, false); RemoveItem("key2"); } I'm not so great with scripting so this could be the wrong way to do it but this is how I assume it's done properly - If not i'm sure someone will correct me soon =) GL RE: Locked doors - The chaser - 09-21-2012 Try using SetSwingDoorLocked(asEntity, false, true); RemoveItem(asItem); Those never failed me. Of course, it only works if you do what Chap1400 said. RE: Locked doors - FlawlessHappiness - 09-21-2012 Chap1400 is right! You see: This line calls the function UsedKeyOnDoor: AddUseItemCallback("", "key1", "bedroomdoor1", "UsedKeyOnDoor", true); Which is here: void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("bedroomdoor1", false, true); PlaySoundAtEntity("", "unlock_door", "bedroomdoor1", 0, false); RemoveItem("key1"); } You'll have to make a new one, otherwise it will just link to the same function as the first one did. results in: Key1 works on door1 but opens both door1 and door2 RE: Locked doors - Storfigge - 09-21-2012 Hey thank you guys for the help ![]() As I said I'm very new when it comes to coding so I'm just experimenting my way through ![]() Again thank you for the help! RE: Locked doors - FlawlessHappiness - 09-21-2012 Very good idea! Start by experiementing! Don't release anything before you know what you are working with ![]() |