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
Lamp puzzle scripting help
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#4
RE: Lamp puzzle scripting help

Alright then, just whipped together your exact scenario in my map after I saw your reply. Hopefully this code helps you understand a bit better.

void combolit(string &in asEntity, string &in asType)
{
    if(asType == "OnIgnite")
    {
    
        // Here I named the candles in ascending order, 1 being what I want lit first, 4 last.  Using a local variable, I keep
        // track of how far along I am in the sequence.  If the right one is lit at the right time, it adds one to how many
        // were gotten right, if not, it does nothing.
        if((asEntity == "candle_combo_1") && (GetLocalVarInt("combototal") == 0))
        {
            AddLocalVarInt("comboright", 1);
        }
        if((asEntity == "candle_combo_2") && (GetLocalVarInt("combototal") == 1))
        {
            AddLocalVarInt("comboright", 1);
        }
        if((asEntity == "candle_combo_3") && (GetLocalVarInt("combototal") == 2))
        {
            AddLocalVarInt("comboright", 1);
        }
        if((asEntity == "candle_combo_4") && (GetLocalVarInt("combototal") == 3))
        {
            AddLocalVarInt("comboright", 1);
        }
        
        // I add one to the total lit regardless
        AddLocalVarInt("combototal", 1);
        
        // If we have all 4 lit...
        if((GetLocalVarInt("combototal") == 4))
        {
            // Were all the ones lit in correct order?
            if(GetLocalVarInt("combototal") == GetLocalVarInt("comboright"))
            {
                PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
            }
            // Or did we get off track somewhere.
            else if(GetLocalVarInt("comboright") < GetLocalVarInt("combototal"))
            {
                // If we got something wrong, reset the checking values
                SetLocalVarInt("comboright", 0);
                SetLocalVarInt("combototal", 0);
                
                // And kill the candles (timer due to trouble otherwise)
                // so player can try again.
                AddTimer("killcandles", 0.25f, "killcandles");
            }
        }
    }
}

void killcandles(string &in asTimer)
{
for(int i = 1; i <= 4 ; i++)
    {
        SetLampLit("candle_combo_" + i, false, false);
    }
}

Gotta love how abstractly you have to think for this stuff!
10-03-2010, 11:08 PM
Find


Messages In This Thread
Lamp puzzle scripting help - by Soon - 10-03-2010, 07:18 PM
RE: Lamp puzzle scripting help - by Entih - 10-03-2010, 07:40 PM
RE: Lamp puzzle scripting help - by Soon - 10-03-2010, 10:35 PM
RE: Lamp puzzle scripting help - by Entih - 10-03-2010, 11:08 PM
RE: Lamp puzzle scripting help - by Soon - 10-04-2010, 12:58 AM
RE: Lamp puzzle scripting help - by Entih - 10-04-2010, 02:01 AM
RE: Lamp puzzle scripting help - by Soon - 10-04-2010, 03:13 AM
RE: Lamp puzzle scripting help - by Alexander - 10-04-2010, 09:35 AM



Users browsing this thread: 1 Guest(s)