[SCRIPT] Two locked doors + keys on one map??? - 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] Two locked doors + keys on one map??? (/thread-18536.html) |
Two locked doors + keys on one map??? - Duncansch - 09-28-2012 Hey guys. I have started scripting my new amnesia map lately and i have an annoying problem: lets say i have three rooms. you start in room one. in room one you find the key to door one leading to room two. in room two, you find key two for door two which leads into room three. the problem here though, is that when i use key one on door one, door two unlocks too, without me using any key on it... i guess the script is not good. well, here it is: //////////////////////////// // Run first time starting map void OnStart() { AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_1", 0, false); SetSwingDoorLocked("door_1", false, true); RemoveItem("key_1"); PlaySoundAtEntity("", "unlock_door", "door_2", 0, false); SetSwingDoorLocked("door_2", false, true); RemoveItem("key_2"); } //////////////////////////// // Run when entering map void OnEnter() { } //////////////////////////// // Run when leaving map void OnLeave() { Sorry, I couldn't find any threads on this and it is really bugging me. i have tried moving them around a bit, but it didn't work. help is very, very much appreciated RE: Two locked doors + keys on one map??? - FlawlessHappiness - 09-28-2012 You are calling the same function! What you do is making key_1 open both doors when used on door_1. key_2 opens both doors when used on door_2. The engine cannot separate: void UsedKeyOnDoor(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_1", 0, false); SetSwingDoorLocked("door_1", false, true); RemoveItem("key_1"); PlaySoundAtEntity("", "unlock_door", "door_2", 0, false); SetSwingDoorLocked("door_2", false, true); RemoveItem("key_2"); } It believes it has to do it all at the same time. Heres what you have to do: void OnStart() { AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor_1", true); AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor_2", true); } void UsedKeyOnDoor_1(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_1", 0, false); SetSwingDoorLocked("door_1", false, true); RemoveItem("key_1"); } void UsedKeyOnDoor_2(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_2", 0, false); SetSwingDoorLocked("door_2", false, true); RemoveItem("key_2"); } I don't want to make you more confused, but if you want to make it a bit easier for yourself, you can do this: void OnStart() { AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); SetSwingDoorLocked(asEntity, false, true); RemoveItem(asItem); } If it doesn't make sense to you, or if you don't understand it, use the first script. Never use something you don't understand! RE: Two locked doors + keys on one map??? - The chaser - 09-28-2012 You're using the same callback. Try this instead: //////////////////////////// // Run first time starting map void OnStart() { AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true); AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor_2", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_1", 0, false); SetSwingDoorLocked("door_1", false, true); RemoveItem("key_1"); } void UsedKeyOnDoor_2(string &in asItem, string &in asEntity) { PlaySoundAtEntity("", "unlock_door", "door_2", 0, false); SetSwingDoorLocked("door_2", false, true); RemoveItem("key_2"); } //////////////////////////// // Run when entering map void OnEnter() { } //////////////////////////// // Run when leaving map void OnLeave() { } Got ninja'd by beecake XD RE: Two locked doors + keys on one map??? - FlawlessHappiness - 09-28-2012 Sorry, Chaser |