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
Levers in Order
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#5
RE: Levers in Order

The way I've redone your script is to have the lever stick until you're done pulling all three, whereas it checks if it is correctly done and either unsticks or you "win".

void OnEnter()

{
SetEntityConnectionStateChangeCallback("lever_simple01_1", "SetSwingDoorLocked");
SetEntityConnectionStateChangeCallback("lever_simple01_2", "SetSwingDoorLocked");
SetEntityConnectionStateChangeCallback("lever_simple01_3", "SetSwingDoorLocked");
}

void SetSwingDoorLocked(string &in asEntity, int alState)
{
if(GetLocalVarInt("Sequence") == 0 && asEntity == "lever_simple01_2")
{
AddLocalVarInt("Sequence", 1);
SetLeverStuckState(asEntity, alState, true);
}

if(GetLocalVarInt("Sequence") == 1 && asEntity == "lever_simple01_3")
{
AddLocalVarInt("Sequence", 1);
SetLeverStuckState(asEntity, alState, true);
}

if(GetLocalVarInt("Sequence") == 2 && asEntity == "lever_simple01_1")
{
AddLocalVarInt("Sequence", 1);
SetLeverStuckState(asEntity, alState, true);
SetSwingDoorLocked("hatch_metal01_1", false, true);
PlayMusic("10_puzzle02.ogg", false, 0.3, 0.1, 10, false);
FadeLightTo("SpotLight_8", 0, 0, 0, 0, -1, 0.5f);
FadeLightTo("SpotLight_4", 0.4f, 0.5f, 0.9f, -1, -1, 0.5f);
}

if(GetLeverState(asEntity) == 0)
//If it does not get stuck due to success, it means it failed, so make it stuck as failed.
{
AddLocalVarInt("Fail", 1);
SetLeverStuckState(asEntity, alState, true);
if((GetLeverState("lever_simple01_3") == alState) && (GetLeverState("lever_simple01_2") == alState) && (GetLeverState("lever_simple01_1") == alState))
//If the last possible stuck one was due to a fail, then reset all and play a "machine fail" sound.

/*This little "if" is only possible thanks to the fact that you can't have a success at the last lever without success at all of them. So if you intend to make the lever pulls rely only on themselves, then redo this "if". (Ignore this part if you like it the way it is)*/

{
PlaySoundAtEntity("", "13_machine_fail.snt","Player",0.1f, false);
SetLeverStuckState(lever_simple01_3, 0, true);
SetLeverStuckState(lever_simple01_2, 0, true);
SetLeverStuckState(lever_simple01_1, 0, true);
SetMessage("CATEGORY","YOUR_MESSAGE",INSERT NUMBER HERE);
SetLocalVarInt("Sequence",0);
SetLocalVarInt("Fail",0);
/*Note that in this script, the Variable "Fail" is entirely useless. I just wanted to put it there for you to use if you want to, for like having different sounds depending on how many fails there were.*/
}

}


I might've missed something, as I always do, but I hope my explanations were at least moderate, and you now get the general idea. Smile

Gud lak.

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
(This post was last modified: 08-13-2012, 11:32 AM by Theforgot3n1.)
08-13-2012, 11:13 AM
Website Find


Messages In This Thread
Levers in Order - by TheIcyPickle - 08-13-2012, 07:10 AM
RE: Levers in Order - by FlawlessHappiness - 08-13-2012, 09:36 AM
RE: Levers in Order - by TheIcyPickle - 08-13-2012, 09:43 AM
RE: Levers in Order - by FlawlessHappiness - 08-13-2012, 10:36 AM
RE: Levers in Order - by Theforgot3n1 - 08-13-2012, 11:13 AM
RE: Levers in Order - by TheIcyPickle - 08-13-2012, 07:39 PM
RE: Levers in Order - by Theforgot3n1 - 08-13-2012, 08:22 PM
RE: Levers in Order - by TheIcyPickle - 08-13-2012, 08:40 PM



Users browsing this thread: 1 Guest(s)