Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Levers in Order
Author Message
TheIcyPickle Offline
Member

Posts: 80
Joined: Feb 2011
Reputation: 0
Post: #1
Levers in Order
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);
}
}


is my current script. It forces the player to only pull levers in a correct order because you CANNOT pull then in any other way. It just wiggles if you pull the wrong one.

The order for my levers is 231.
But lets say I do 321. I pull lever 3, it wont stay in position. It HAS to be lever 2 first. Not much of a puzzle eh?

Thanks for the help in advance!

I figured it out. No need to read. Thanks again.
(This post was last modified: 08-13-2012 07:34 AM by TheIcyPickle.)
08-13-2012 07:10 AM
Find all posts by this user Quote this message in a reply
BeeKayK Offline
Posting Freak

Posts: 2,052
Joined: Mar 2012
Reputation: 82
Post: #2
RE: Levers in Order
How about it all reset if you do it wrong?

We fear what we cannot undo
We fear what we don't know
08-13-2012 09:36 AM
Find all posts by this user Quote this message in a reply
TheIcyPickle Offline
Member

Posts: 80
Joined: Feb 2011
Reputation: 0
Post: #3
RE: Levers in Order
(08-13-2012 09:36 AM)beecake Wrote:  How about it all reset if you do it wrong?
That would be cool. Right now, its just, do it in the right order, if you do it wrong, come back to the first lever.

How would one do such "scriptery"

Oh, and one more thing, this is sort off off the topic, but, I have a door that is supposed to fly open. It does, but its either too slow, or too fast that is closes shut again. Anyway how to make a door fly open quickly and keep it there?
(This post was last modified: 08-13-2012 09:47 AM by TheIcyPickle.)
08-13-2012 09:43 AM
Find all posts by this user Quote this message in a reply
BeeKayK Offline
Posting Freak

Posts: 2,052
Joined: Mar 2012
Reputation: 82
Post: #4
RE: Levers in Order
Resetting all localvarint's to what they were at first, and displaying a message "Sounds like it's resetting" maybe playing a machinery sound.

Thats my guess... Tongue

We fear what we cannot undo
We fear what we don't know
(This post was last modified: 08-13-2012 10:37 AM by BeeKayK.)
08-13-2012 10:36 AM
Find all posts by this user Quote this message in a reply
Theforgot3n1 Offline
Member

Posts: 190
Joined: Apr 2012
Reputation: 6
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
TheIcyPickle Offline
Member

Posts: 80
Joined: Feb 2011
Reputation: 0
Post: #6
RE: Levers in Order
huh, i tried your script, a few errors, easy to fix btw Smile but, it seems that the levers do not stick up when you pull one of the wrong levers first, it does not stay up. Which in turn removes the "puzzle" aspect.

haha I think its something to do with your script. Ill check it as well.

void GiveSanityDamage(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(10, false);
SetMessage("Messages", "holyfuckingshit", 4.0f);
}

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("03_puzzle_secret.ogg", false, 0.3, 0.1, 10, false);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);

FadeLightTo("SpotLight_8", 0, 0, 0, 0, -1, 0.5f);
FadeLightTo("SpotLight_4", 0.4f, 0.5f, 0.9f, -1, -1, 0.5f);



GiveSanityBoost();
}

if(GetLeverState(asEntity) == 1)
//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, false);
SetLeverStuckState("lever_simple01_2", 0, false);
SetLeverStuckState("lever_simple01_1", 0, false);

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.*/
}

}
}


is how I did it. Change a few things from true to false, 0 to 1. And so on. It works now. Haha nice work guys! However if you think it could be better, do tell!

Also. if you can, one more thing, this is sort off off the topic, but, I have a door that is supposed to fly open. It does, but its either too slow, or too fast that is closes shut again. Anyway how to make a door fly open quickly and keep it there?
(This post was last modified: 08-13-2012 07:52 PM by TheIcyPickle.)
08-13-2012 07:39 PM
Find all posts by this user Quote this message in a reply
Theforgot3n1 Offline
Member

Posts: 190
Joined: Apr 2012
Reputation: 6
Post: #7
RE: Levers in Order
(08-13-2012 07:39 PM)TheIcyPickle Wrote:  huh, i tried your script, a few errors, easy to fix btw Smile but, it seems that the levers do not stick up when you pull one of the wrong levers first, it does not stay up. Which in turn removes the "puzzle" aspect.

haha I think its something to do with your script. Ill check it as well.

void GiveSanityDamage(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(10, false);
SetMessage("Messages", "holyfuckingshit", 4.0f);
}

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("03_puzzle_secret.ogg", false, 0.3, 0.1, 10, false);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);

FadeLightTo("SpotLight_8", 0, 0, 0, 0, -1, 0.5f);
FadeLightTo("SpotLight_4", 0.4f, 0.5f, 0.9f, -1, -1, 0.5f);



GiveSanityBoost();
}

if(GetLeverState(asEntity) == 1)
//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, false);
SetLeverStuckState("lever_simple01_2", 0, false);
SetLeverStuckState("lever_simple01_1", 0, false);

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.*/
}

}
}


is how I did it. Change a few things from true to false, 0 to 1. And so on. It works now. Haha nice work guys! However if you think it could be better, do tell!

Also. if you can, one more thing, this is sort off off the topic, but, I have a door that is supposed to fly open. It does, but its either too slow, or too fast that is closes shut again. Anyway how to make a door fly open quickly and keep it there?
Glad that I could help. Smile

Hm, try to find the perfect float number. Otherwise, I suppose it could be something with the positioning of the door.

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 08:22 PM by Theforgot3n1.)
08-13-2012 08:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
TheIcyPickle Offline
Member

Posts: 80
Joined: Feb 2011
Reputation: 0
Post: #8
RE: Levers in Order
(08-13-2012 08:22 PM)Theforgot3n1 Wrote:  
(08-13-2012 07:39 PM)TheIcyPickle Wrote:  
Glad that I could help. Smile

Hm, try to find the perfect float number. Otherwise, I suppose it could be something with the positioning of the door.
Thank you Smile
08-13-2012 08:40 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: