![]() |
Crowbar/Key Script Problem - 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: Crowbar/Key Script Problem (/thread-18285.html) |
Crowbar/Key Script Problem - wagiwombledog - 09-12-2012 Hi, I'm having trouble with a script for my custom story. If you could help I would greatly appreciate it + tell me what i did wrong, as i can't see anything, although i am new to scripting. It involve a crowbar, a key and 2 door's. Crowbar=crowbar_1 Key=Waterworks_Key Door1=Waterworks_Door Door2=Storage The key goes with the Waterworks door and the crowbar goes with the storage door. Here is the script: void OnStart() { AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true); AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true); AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1); } void UsedCrowbarOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); RemoveItem(asItem); } void FUNCTION(string &in asItem, string &in asEntity) { AddTimer("", 0.2, "TimerSwitchShovel"); RemoveItem("crowbar_1"); } void TimerSwitchShovel(string &in asTimer) { PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false); SetEntityActive("crowbar_joint_1", true); } void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState) { AddPlayerSanity(25); PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false); SetSwingDoorLocked("Waterworks_Door", false, true); AddPropImpulse("Waterworks_Door", 0, 0, -50, "World"); SetSwingDoorDisableAutoClose("Waterworks_Door", true); SetSwingDoorClosed("Waterworks_Door", false, false); SetMoveObjectState("Waterworks_Door", 1); PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false); CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false); SetEntityActive("crowbar_joint_1", false); SetLocalVarInt("Door", 1); } { AddUseItemCallback("", "Waterworks_Key", "Waterworks_Door", "UsedKeyOnDoor", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("asEntity", false, true); PlaySoundAtEntity("", "unlock_door", "asEntity", 0, false); RemoveItem(asItem); } } //////////////////////////// // Run when entering map void OnEnter() { } //////////////////////////// // Run when entering map void OnLeave() { } Thanks! ,wagiwombledog RE: Crowbar/Key Script Problem - Tomato Cat - 09-12-2012 I'm going to assume that the key is not working on the door, and the crowbar is not properly prying the door open. Regardless, this should fix your problems. Spoiler below!
RE: Crowbar/Key Script Problem - The chaser - 09-12-2012 Wait... you want the key to open a door and a crowbar to open another door? I say it because both (crowbar and key) target the same door. RE: Crowbar/Key Script Problem - Tomato Cat - 09-12-2012 (09-12-2012, 05:00 PM)The chaser Wrote: Wait... you want the key to open a door and a crowbar to open another door? I say it because both (crowbar and key) target the same door.Yeah, using the crowbar on the "Storage" door would open the "Waterworks_Door." RE: Crowbar/Key Script Problem - wagiwombledog - 09-12-2012 Thank you all for your fast replies, ![]() |