04-12-2013, 06:05 AM
Okay, so here's the scenario. Four valves (each starting at the middle position) turn in a specific order to open a portcullis. The correct order goes as such: R R L R. If the player gets one wrong, steam spurts out of a pipe and the order resets. Seems simple enough, right? Right. Here's the code.
Here's where it sucks. If I input the correct order, nothing happens. The portcullis is still stuck there. If I move any of the wheels other than the third to any position, nothing happens. Left or right, wheels 1, 2, and 4 do nothing. Wheel 3 acts as it should; right (the wrong direction) does the steam thing and resets the wheels, and left clicks as it should.
So, what do? Why won't this work? I feel like my logic is fairly sound withing the coding. It's late, and I don't want to work on this any more, so I was hoping someone more experienced had some insight.
Code:
void valve1turn(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("gateopen", 1);
if(GetLocalVarInt("gateopen") == 4)
{
SetMoveObjectState("castle_portcullis_1", 0.7);
}
else
{
AddLocalVarInt("gateopen", 1);
}
}
if(alState == 0)
{
SetMoveObjectState("castle_portcullis_1", 0);
PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
SetLocalVarInt("gateopen", 0);
for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
}
}
void valve2turn(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("gateopen", 1);
if(GetLocalVarInt("gateopen") == 4)
{
SetMoveObjectState("castle_portcullis_1", 0.7);
}
else
{
AddLocalVarInt("gateopen", 1);
}
}
if(alState == 0)
{
SetMoveObjectState("castle_portcullis_1", 0);
PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
SetLocalVarInt("gateopen", 0);
for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
}
}
void valve3turn(string &in asEntity, int alState)
{
if(alState == 0)
{
AddLocalVarInt("gateopen", 1);
if(GetLocalVarInt("gateopen") == 4)
{
SetMoveObjectState("castle_portcullis_1", 0.7);
}
else
{
AddLocalVarInt("gateopen", 1);
}
}
if(alState == 1)
{
SetMoveObjectState("castle_portcullis_1", 0);
PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
SetLocalVarInt("gateopen", 0);
for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
}
}
void valve4turn(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("gateopen", 1);
if(GetLocalVarInt("gateopen") == 4)
{
SetMoveObjectState("castle_portcullis_1", 0.7);
}
else
{
AddLocalVarInt("gateopen", 1);
}
}
if(alState == 0)
{
SetMoveObjectState("castle_portcullis_1", 0);
PlaySoundAtEntity("", "13_press_done.snt", "steamarea", 0, false);
CreateParticleSystemAtEntity("", "ps_steam_puff.ps", "steamarea", false);
SetLocalVarInt("gateopen", 0);
for(int i=1;i<=4;i++)SetWheelAngle("valvepuzzle_"+i, 0, true);
}
}
Here's where it sucks. If I input the correct order, nothing happens. The portcullis is still stuck there. If I move any of the wheels other than the third to any position, nothing happens. Left or right, wheels 1, 2, and 4 do nothing. Wheel 3 acts as it should; right (the wrong direction) does the steam thing and resets the wheels, and left clicks as it should.
So, what do? Why won't this work? I feel like my logic is fairly sound withing the coding. It's late, and I don't want to work on this any more, so I was hoping someone more experienced had some insight.