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
Let's play "why doesn't my script work?"!
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#13
RE: Let's play "why doesn't my script work?"!

I've updated the code to include 5 valves (and I fixed the extra 1 input for each correct turn, which was making it activate earlier than it should have), and right now the only problem it has is the wheels not changing alState after an incorrect turn. It's actually breaking the puzzle as of now, because if you turn one wheel the wrong way, you have to turn it back the wrong way and then again back the right way in order to get it to tally +1 to "gateopen" again, and until then it'll always be however many wheels are turned the wrong way short of completing the puzzle.
void valve1turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve2turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve3turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve4turn(string &in asEntity, int alState)
{
if(alState == 1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    else
        {
        AddLocalVarInt("gateopen", 1);
        }
    }
if(alState == -1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valve5turn(string &in asEntity, int alState)
{
if(alState == -1)
    {
    AddLocalVarInt("gateopen", 1);
    if(GetLocalVarInt("gateopen") >= 5)
        {
        SetMoveObjectState("castle_portcullis_1", 0.7);
        PlaySoundAtEntity("", "13_ignite.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "rustyvalve", 0, false);
        PlaySoundAtEntity("hum", "27_hum.snt", "doorhum", 0, false);
        SetEntityActive("endwalk", true);
        }
    }
if(alState == 1)
    {
    SetMoveObjectState("castle_portcullis_1", 0);
    PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
    StopSound("hum", 1);
    CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
    SetLocalVarInt("gateopen", 0);
    for(int i=1;i<=5;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
    for(int i=1;i<=5;i++)SetWheelStuckState("valvepuzzle_" +i, 0, true);
    AddTimer("", 0.25, "valvereset");
    SetEntityActive("endwalk", false);
    }
}
void valvereset(string &in asTimer)
{
    for(int i=1;i<=5;i++)ResetProp("valvepuzzle_"+i);
    for(int i=1;i<=5;i++)SetPropObjectStuckState("valvepuzzle_"+i, 0);
}
What code can I use that does reset the stuck state?

[Image: signature-2.png]
(This post was last modified: 04-13-2013, 01:44 AM by Streetboat.)
04-13-2013, 01:42 AM
Find


Messages In This Thread
RE: Let's play "why doesn't my script work?"! - by Streetboat - 04-13-2013, 01:42 AM



Users browsing this thread: 2 Guest(s)