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
LoneWolf Offline
Senior Member

Posts: 308
Threads: 43
Joined: Sep 2010
Reputation: 0
#2
RE: Lever Puzzle "solution"

Are the levers the ones from the machien room? the one with 4 levers?

Also what do you name the levers as? combo_lever_1 - 4 ?
12-19-2010, 03:05 PM
Find
Endrek03 Offline
Junior Member

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

(12-19-2010, 03:05 PM)LoneWolf Wrote: Are the levers the ones from the machien room? the one with 4 levers?

Also what do you name the levers as? combo_lever_1 - 4 ?

No, the levers used were "Lever_small01.ent". Really, in essence, you can use any entity so long as the player can interact with it. One "problem" I noticed is you don't even need to pull the levers, you just need to click on them and the trigger activates. Of course, this is minor, as most players will still pull the levers for effect.

As for the naming, yes. There are actually 5 levers in total, "lever_combo_1" - "lever_combo_5". You can name the entities anything you want so long as you change the if((asEntity == "lever_combo_x") to the name of the entity you want to use.
12-19-2010, 10:02 PM
Find
LoneWolf Offline
Senior Member

Posts: 308
Threads: 43
Joined: Sep 2010
Reputation: 0
#4
RE: Lever Puzzle "solution"

Okay thanks, the lever part that i have only has 4 levers Sad it shouldnt effect anything though i wouldnt think. I will test out tomorrow though.

Using - elevator_machine_coal_lever_1 should still work.
(This post was last modified: 12-20-2010, 12:33 AM by LoneWolf.)
12-20-2010, 12:30 AM
Find




Users browsing this thread: 2 Guest(s)