![]() |
Levers in Order - 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: Levers in Order (/thread-17725.html) |
Levers in Order - TheIcyPickle - 08-13-2012 void OnEnter() { SetEntityConnectionStateChangeCallback("lever_simple01_1", "SetSwingDoorLocked"); SetEntityConnectionStateChangeCallback("lever_simple01_2", "SetSwingDoorLocked"); SetEntityConnectionStateChangeCallback("lever_simple01_3", "SetSwingDoorLocked"); } void SetSwingDoorLocked(string &in asEntity, int alState) { if(GetLocalVarInt("Sequence") == 0 && asEntity == "lever_simple01_2") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); } if(GetLocalVarInt("Sequence") == 1 && asEntity == "lever_simple01_3") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); } if(GetLocalVarInt("Sequence") == 2 && asEntity == "lever_simple01_1") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); SetSwingDoorLocked("hatch_metal01_1", false, true); PlayMusic("10_puzzle02.ogg", false, 0.3, 0.1, 10, false); FadeLightTo("SpotLight_8", 0, 0, 0, 0, -1, 0.5f); FadeLightTo("SpotLight_4", 0.4f, 0.5f, 0.9f, -1, -1, 0.5f); } } is my current script. It forces the player to only pull levers in a correct order because you CANNOT pull then in any other way. It just wiggles if you pull the wrong one. The order for my levers is 231. But lets say I do 321. I pull lever 3, it wont stay in position. It HAS to be lever 2 first. Not much of a puzzle eh? Thanks for the help in advance! I figured it out. No need to read. Thanks again. RE: Levers in Order - FlawlessHappiness - 08-13-2012 How about it all reset if you do it wrong? RE: Levers in Order - TheIcyPickle - 08-13-2012 (08-13-2012, 09:36 AM)beecake Wrote: How about it all reset if you do it wrong?That would be cool. Right now, its just, do it in the right order, if you do it wrong, come back to the first lever. How would one do such "scriptery" Oh, and one more thing, this is sort off off the topic, but, I have a door that is supposed to fly open. It does, but its either too slow, or too fast that is closes shut again. Anyway how to make a door fly open quickly and keep it there? RE: Levers in Order - FlawlessHappiness - 08-13-2012 Resetting all localvarint's to what they were at first, and displaying a message "Sounds like it's resetting" maybe playing a machinery sound. Thats my guess... ![]() RE: Levers in Order - Theforgot3n1 - 08-13-2012 The way I've redone your script is to have the lever stick until you're done pulling all three, whereas it checks if it is correctly done and either unsticks or you "win". Code: void OnEnter() I might've missed something, as I always do, but I hope my explanations were at least moderate, and you now get the general idea. ![]() Gud lak. RE: Levers in Order - TheIcyPickle - 08-13-2012 huh, i tried your script, a few errors, easy to fix btw ![]() haha I think its something to do with your script. Ill check it as well. void GiveSanityDamage(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false); PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false); GiveSanityDamage(10, false); SetMessage("Messages", "holyfuckingshit", 4.0f); } void SetSwingDoorLocked(string &in asEntity, int alState) { if(GetLocalVarInt("Sequence") == 0 && asEntity == "lever_simple01_2") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); } if(GetLocalVarInt("Sequence") == 1 && asEntity == "lever_simple01_3") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); } if(GetLocalVarInt("Sequence") == 2 && asEntity == "lever_simple01_1") { AddLocalVarInt("Sequence", 1); SetLeverStuckState(asEntity, alState, true); SetSwingDoorLocked("hatch_metal01_1", false, true); PlayMusic("03_puzzle_secret.ogg", false, 0.3, 0.1, 10, false); PlaySoundAtEntity("", "unlock_door", "Player", 0, false); FadeLightTo("SpotLight_8", 0, 0, 0, 0, -1, 0.5f); FadeLightTo("SpotLight_4", 0.4f, 0.5f, 0.9f, -1, -1, 0.5f); GiveSanityBoost(); } if(GetLeverState(asEntity) == 1) //If it does not get stuck due to success, it means it failed, so make it stuck as failed. { AddLocalVarInt("Fail", 1); SetLeverStuckState(asEntity, alState, true); if((GetLeverState("lever_simple01_3") == alState) && (GetLeverState("lever_simple01_2") == alState) && (GetLeverState("lever_simple01_1") == alState)) //If the last possible stuck one was due to a fail, then reset all and play a "machine fail" sound. /*This little "if" is only possible thanks to the fact that you can't have a success at the last lever without success at all of them. So if you intend to make the lever pulls rely only on themselves, then redo this "if". (Ignore this part if you like it the way it is)*/ { PlaySoundAtEntity("", "13_machine_fail.snt","Player",0.1f, false); SetLeverStuckState("lever_simple01_3", 0, false); SetLeverStuckState("lever_simple01_2", 0, false); SetLeverStuckState("lever_simple01_1", 0, false); SetLocalVarInt("Sequence",0); SetLocalVarInt("Fail",0); /*Note that in this script, the Variable "Fail" is entirely useless. I just wanted to put it there for you to use if you want to, for like having different sounds depending on how many fails there were.*/ } } } is how I did it. Change a few things from true to false, 0 to 1. And so on. It works now. Haha nice work guys! However if you think it could be better, do tell! Also. if you can, one more thing, this is sort off off the topic, but, I have a door that is supposed to fly open. It does, but its either too slow, or too fast that is closes shut again. Anyway how to make a door fly open quickly and keep it there? RE: Levers in Order - Theforgot3n1 - 08-13-2012 (08-13-2012, 07:39 PM)TheIcyPickle Wrote: huh, i tried your script, a few errors, easy to fix btwGlad that I could help. ![]() Hm, try to find the perfect float number. Otherwise, I suppose it could be something with the positioning of the door. RE: Levers in Order - TheIcyPickle - 08-13-2012 (08-13-2012, 08:22 PM)Theforgot3n1 Wrote:Thank you(08-13-2012, 07:39 PM)TheIcyPickle Wrote:Glad that I could help. ![]() |