The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lever Puzzle "solution"
Endrek03 Offline
Junior Member

Posts: 8
Threads: 3
Joined: Dec 2010
Reputation: 0
#1
Lever Puzzle "solution"

Also, for those interested -
Spoiler below!

void combolever(string &in asEntity)
{
        if((asEntity == "lever_combo_1") && (GetLocalVarInt("combototal") > 2))
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if((asEntity == "lever_combo_1") && (GetLocalVarInt("combototal") < 2))
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if(asEntity == "lever_combo_2")
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if(asEntity == "lever_combo_4")
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if((asEntity == "lever_combo_3") && (GetLocalVarInt("combototal") > 0) && (GetLocalVarInt("combototal") < 3))
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if((asEntity == "lever_combo_5") && (GetLocalVarInt("combototal") < 1))
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if((asEntity == "lever_combo_5") && (GetLocalVarInt("combototal") > 1))
        {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
        }
        if((asEntity == "lever_combo_3") && (GetLocalVarInt("combototal") == 0))
        {
            AddLocalVarInt("comboright", 1);
            AddLocalVarInt("combototal", 1);
            AddDebugMessage("That's 1", false);
        }
        if((asEntity == "lever_combo_5") && (GetLocalVarInt("combototal") == 1))
        {
            AddLocalVarInt("comboright", 1);
            AddLocalVarInt("combototal", 1);
            AddDebugMessage("That's 2", false);
        }
        if((asEntity == "lever_combo_1") && (GetLocalVarInt("combototal") == 2))
        {
            AddLocalVarInt("comboright", 1);
            AddLocalVarInt("combototal", 1);
            AddDebugMessage("That's 3", false);
        }
        if((asEntity == "lever_combo_3") && (GetLocalVarInt("combototal") == 3))
        {
            AddLocalVarInt("comboright", 1);
            AddLocalVarInt("combototal", 1);
            AddDebugMessage("That's 4!", false);
        }
        if((GetLocalVarInt("combototal") == 4))
        {
            if(GetLocalVarInt("combototal") == GetLocalVarInt("comboright"))
            {
                SetEntityPlayerInteractCallback("lever_combo_1", "", false);
                SetEntityPlayerInteractCallback("lever_combo_2", "", false);
                SetEntityPlayerInteractCallback("lever_combo_3", "", false);
                SetEntityPlayerInteractCallback("lever_combo_4", "", false);
                SetEntityPlayerInteractCallback("lever_combo_5", "", false);
                PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
                AddTimer("ChestSuccess", 3.0f, "ChestLookAt");
                AddTimer("PlayerLook", 1, "PlayerLookKitchen");
                AddDebugMessage("WIN!", false);
            }
            else if(GetLocalVarInt("comboright") < GetLocalVarInt("combototal"))
            {
                AddDebugMessage("You Lose!", false);
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
            }
        }
}


In the end it actually turned out rather simple. All levers pull up the string "combolever" in which case it checks many, many things. I'm sure this is "sloppy" work, but it works. In fact, I think that last part (The else if(Get...) is completely unnecessary, but if it works -- don't fix it. Smile

All in all it just checks each lever pull, and if you pull a lever anywhere outside of sequence, it resets the sequence. Once completed it removes all the player interact call backs from the levers. My guess is the player will discover multiple combinations of lever pulls throughout the adventure, and each one will create and remove the call back as necessary.

Feel free to leave any comments, or questions . . . but I'm still new, so mainly comments. Big Grin Especially regarding how to clean up the code -- I could use some help with that. Sad
12-19-2010, 02:55 PM
Find


Messages In This Thread
Lever Puzzle "solution" - by Endrek03 - 12-19-2010, 02:55 PM
RE: Lever Puzzle "solution" - by LoneWolf - 12-19-2010, 03:05 PM
RE: Lever Puzzle "solution" - by Endrek03 - 12-19-2010, 10:02 PM
RE: Lever Puzzle "solution" - by LoneWolf - 12-20-2010, 12:30 AM



Users browsing this thread: 1 Guest(s)