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


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make Script puzzles?
Author Message
HumiliatioN Offline
Posting Freak

Posts: 1,131
Joined: Dec 2010
Reputation: 16
Post: #11
RE: How to make Script puzzles?

(06-23-2011 01:26 AM)rojkish Wrote:  Just simply open 03_archives from the original game, take a look at their code and copy it and change the names so it suits you, if the script doesn't work, post here again and I'll take a look at it.

Okay its not working i have "Areas" ready and books and all set just like a normal game part.

Code:


for(int i=1;i<=3;i++) AddEntityCollideCallback("SecretBook_"+i, "AreaSecretBook_"+i, "CollideSecretBook", false, 0);

void CollideSecretBook(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {
SetLocalVarInt("Var"+asParent, 1);

AddTimer(asParent, 20, "PushBackBook");

SetPropObjectStuckState(asParent, 1);

PlaySoundAtEntity("Sound"+asParent, "gameplay_tick", asParent, 0.0f, false);

StartScreenShake(0.001f, 0.5f, 0.5f, 0.5f);

PlayGuiSound("16_lever_stuck", 0.3f);

/*DEBUG
*/
AddDebugMessage("Book in area: "+asParent, true);
} else {
SetLocalVarInt("Var"+asParent, 0);

RemoveTimer(asParent);

PlaySoundAtEntity("Sound2"+asParent, "lock_door", asParent, 1.5f, false);
PlayGuiSound("16_lever_stuck", 0.2f);

StopSound("Sound"+asParent, 1.0f);

/*DEBUG
*/
AddDebugMessage("Book out of area: "+asParent, true);
}

/*All books are pulled before time is out and the secret room is revealed.
*/
if(GetLocalVarInt("VarSecretBook_1") == 1 && GetLocalVarInt("VarSecretBook_2") == 1 && GetLocalVarInt("VarSecretBook_3") == 1) {

FadeLightTo("PointLight_30", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f);

SetMoveObjectState("shelf_secret_door_1", 1);

SetPropObjectStuckState("SecretBook_*", -1);

SetEntityInteractionDisabled("SecretBook_*", true);

PlaySoundAtEntity("BooksDone", "lock_door", "Player", 0, false);

CreateParticleSystemAtEntity("dust", "ps_dust_falling_door_quick", "AreaDoorParticle", false);

for(int i=1;i<=3;i++){ RemoveTimer("SecretBook_"+i); StopSound("SoundSecretBook_"+i, 0.0f); }

GiveSanityBoostSmall();

PlayMusic("03_puzzle_secret.ogg", false, 0.7f, 0, 10, false);

CompleteQuest("03Books", "03Books");

/*DEBUG
*/
AddDebugMessage("All books in position, move shelf!", true);
}

}
void PushBackBook(string &in asTimer)
{
SetPropObjectStuckState(asTimer, -1);

AddTimer("2"+asTimer, 0.25f, "PushBackBook02");

/*DEBUG
*/
AddDebugMessage("Push back book: "+asTimer, true);
}
void PushBackBook02(string &in asTimer)
{
if(asTimer == "2SecretBook_1") SetPropObjectStuckState("SecretBook_1", 0);
else if(asTimer == "2SecretBook_2") SetPropObjectStuckState("SecretBook_2", 0);
else SetPropObjectStuckState("SecretBook_3", 0);
}

/*Give quest after the visions about the books
*/
void VisionOverBooks()
{
AddQuest("03Books", "03Books");

SetEntityPlayerInteractCallback("shelf_secret_door_1", "InteractMoveShelf", true);

AddTimer("enemys", 1.0f, "TimerPlayEnemy");
}


Where is the problem? Undecided

“Life is a game, play it”
06-23-2011 03:04 AM
Find all posts by this user Quote this message in a reply
rojkish Offline
Junior Member

Posts: 45
Joined: Jun 2011
Reputation: 0
Post: #12
RE: How to make Script puzzles?

I remade the script entirely for you, it should work out now.

Spoiler below!


void CollideSecretBook(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {
SetLocalVarInt("Var"+asParent, 1);

AddTimer(asParent, 20, "PushBackBook");

SetPropObjectStuckState(asParent, 1);

PlaySoundAtEntity("Sound"+asParent, "gameplay_tick", asParent, 0.0f, false);

StartScreenShake(0.001f, 0.5f, 0.5f, 0.5f);

PlayGuiSound("16_lever_stuck", 0.3f);

AddDebugMessage("Book in area: "+asParent, true);
}
else
{
SetLocalVarInt("Var"+asParent, 0);

RemoveTimer(asParent);

PlaySoundAtEntity("Sound2"+asParent, "lock_door", asParent, 1.5f, false);
PlayGuiSound("16_lever_stuck", 0.2f);

StopSound("Sound"+asParent, 1.0f);

AddDebugMessage("Book out of area: "+asParent, true);
}


if(GetLocalVarInt("VarSecretBook_1") == 1 && GetLocalVarInt("VarSecretBook_2") == 1 && GetLocalVarInt("VarSecretBook_3") == 1)
{
SetMoveObjectState("shelf_secret_door_1", 1);

SetPropObjectStuckState("SecretBook_*", -1);

SetEntityInteractionDisabled("SecretBook_*", true);

PlaySoundAtEntity("BooksDone", "lock_door", "Player", 0, false);

CreateParticleSystemAtEntity("dust", "ps_dust_falling_door_quick", "AreaDoorParticle", false);

for(int i=1;i<=3;i++){ RemoveTimer("SecretBook_"+i); StopSound("SoundSecretBook_"+i, 0.0f); }

GiveSanityBoostSmall();

PlayMusic("03_puzzle_secret.ogg", false, 0.7f, 0, 10, false);

CompleteQuest("03Books", "03Books");

AddDebugMessage("All books in position, move shelf!", true);
}

}

void PushBackBook(string &in asTimer)
{
SetPropObjectStuckState(asTimer, -1);

AddTimer("2"+asTimer, 0.25f, "PushBackBook02");

AddDebugMessage("Push back book: "+asTimer, true);
}

void PushBackBook02(string &in asTimer)
{
if(asTimer == "2SecretBook_1") SetPropObjectStuckState("SecretBook_1", 0);
else if(asTimer == "2SecretBook_2") SetPropObjectStuckState("SecretBook_2", 0);
else SetPropObjectStuckState("SecretBook_3", 0);
SetEntityPlayerInteractCallback("shelf_secret_door_1", "InteractMoveShelf", true);
}



If it doesn't, try putting the script area closer so the book can reach.
06-23-2011 03:17 AM
Find all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,131
Joined: Dec 2010
Reputation: 16
Post: #13
RE: How to make Script puzzles?

(06-23-2011 03:17 AM)rojkish Wrote:  I remade the script entirely for you, it should work out now.

Spoiler below!


void CollideSecretBook(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {
SetLocalVarInt("Var"+asParent, 1);

AddTimer(asParent, 20, "PushBackBook");

SetPropObjectStuckState(asParent, 1);

PlaySoundAtEntity("Sound"+asParent, "gameplay_tick", asParent, 0.0f, false);

StartScreenShake(0.001f, 0.5f, 0.5f, 0.5f);

PlayGuiSound("16_lever_stuck", 0.3f);

AddDebugMessage("Book in area: "+asParent, true);
}
else
{
SetLocalVarInt("Var"+asParent, 0);

RemoveTimer(asParent);

PlaySoundAtEntity("Sound2"+asParent, "lock_door", asParent, 1.5f, false);
PlayGuiSound("16_lever_stuck", 0.2f);

StopSound("Sound"+asParent, 1.0f);

AddDebugMessage("Book out of area: "+asParent, true);
}


if(GetLocalVarInt("VarSecretBook_1") == 1 && GetLocalVarInt("VarSecretBook_2") == 1 && GetLocalVarInt("VarSecretBook_3") == 1)
{
SetMoveObjectState("shelf_secret_door_1", 1);

SetPropObjectStuckState("SecretBook_*", -1);

SetEntityInteractionDisabled("SecretBook_*", true);

PlaySoundAtEntity("BooksDone", "lock_door", "Player", 0, false);

CreateParticleSystemAtEntity("dust", "ps_dust_falling_door_quick", "AreaDoorParticle", false);

for(int i=1;i<=3;i++){ RemoveTimer("SecretBook_"+i); StopSound("SoundSecretBook_"+i, 0.0f); }

GiveSanityBoostSmall();

PlayMusic("03_puzzle_secret.ogg", false, 0.7f, 0, 10, false);

CompleteQuest("03Books", "03Books");

AddDebugMessage("All books in position, move shelf!", true);
}

}

void PushBackBook(string &in asTimer)
{
SetPropObjectStuckState(asTimer, -1);

AddTimer("2"+asTimer, 0.25f, "PushBackBook02");

AddDebugMessage("Push back book: "+asTimer, true);
}

void PushBackBook02(string &in asTimer)
{
if(asTimer == "2SecretBook_1") SetPropObjectStuckState("SecretBook_1", 0);
else if(asTimer == "2SecretBook_2") SetPropObjectStuckState("SecretBook_2", 0);
else SetPropObjectStuckState("SecretBook_3", 0);
SetEntityPlayerInteractCallback("shelf_secret_door_1", "InteractMoveShelf", true);
}



If it doesn't, try putting the script area closer so the book can reach.

Still, no luck.. Damn :I

“Life is a game, play it”
06-23-2011 03:29 AM
Find all posts by this user Quote this message in a reply
rojkish Offline
Junior Member

Posts: 45
Joined: Jun 2011
Reputation: 0
Post: #14
RE: How to make Script puzzles?

Well it worked out fine for me. What's wrong then? Nothing happens or what?
06-23-2011 03:35 AM
Find all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,131
Joined: Dec 2010
Reputation: 16
Post: #15
RE: How to make Script puzzles?

(06-23-2011 03:35 AM)rojkish Wrote:  Well it worked out fine for me. What's wrong then? Nothing happens or what?

Yep. Nothing happens not even when you move books there is no sound. And nothing triggers :/

“Life is a game, play it”
06-23-2011 11:01 AM
Find all posts by this user Quote this message in a reply
rojkish Offline
Junior Member

Posts: 45
Joined: Jun 2011
Reputation: 0
Post: #16
RE: How to make Script puzzles?

Well, in that case the script areas are too far away(if you've named them right), try clicking off grid snapping and just drag them forward. If it doesn't work give me a message with your skype/MSN.
06-23-2011 01:40 PM
Find all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,131
Joined: Dec 2010
Reputation: 16
Post: #17
RE: How to make Script puzzles?

(06-23-2011 01:40 PM)rojkish Wrote:  Well, in that case the script areas are too far away(if you've named them right), try clicking off grid snapping and just drag them forward. If it doesn't work give me a message with your skype/MSN.

Not working i have area touching with book. All 3 areas nothing happens.

See it yourself look editor "Mansion Entry" map.

Here: http://www.mediafire.com/?ipn1jn2nruy62wv

My MSN: joonas134@hotmail.com

“Life is a game, play it”
(This post was last modified: 06-23-2011 02:22 PM by HumiliatioN.)
06-23-2011 02:19 PM
Find all posts by this user Quote this message in a reply
rojkish Offline
Junior Member

Posts: 45
Joined: Jun 2011
Reputation: 0
Post: #18
RE: How to make Script puzzles?

I see what's wrong with the script now, you should use AreaSecretBook_1 on SecretBook_1, because right now, you've used AreaSecretBook_2 on SecretBook_1.

Let me explain this further;

for(int i=1;i<=3;i++) AddEntityCollideCallback("SecretBook_"+i, "AreaSecretBook_"+i, "CollideSecretBook", false, 0);

for(int i=1;i<=3;i++) <- this means that they'll be three script areas/books. i.e;

Spoiler below!


AddEntityCollideCallback("SecretBook_1", "AreaSecretBook_1", "CollideSecretBook", false, 0);
AddEntityCollideCallback("SecretBook_2", "AreaSecretBook_2", "CollideSecretBook", false, 0);
AddEntityCollideCallback("SecretBook_3", "AreaSecretBook_3", "CollideSecretBook", false, 0);



But since SecretBook_1 doesn't collide with AreaSecretBook_1, it buggs. So if you want to fix it, rename the areas so they match the books.

Also, if you want it too look even better, remember to use the mansion_extension wall over the regular mansion_02.
(This post was last modified: 06-23-2011 02:31 PM by rojkish.)
06-23-2011 02:30 PM
Find all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,131
Joined: Dec 2010
Reputation: 16
Post: #19
RE: How to make Script puzzles?

(06-23-2011 02:30 PM)rojkish Wrote:  I see what's wrong with the script now, you should use AreaSecretBook_1 on SecretBook_1, because right now, you've used AreaSecretBook_2 on SecretBook_1.

Let me explain this further;

for(int i=1;i<=3;i++) AddEntityCollideCallback("SecretBook_"+i, "AreaSecretBook_"+i, "CollideSecretBook", false, 0);

for(int i=1;i<=3;i++) <- this means that they'll be three script areas/books. i.e;

Spoiler below!


AddEntityCollideCallback("SecretBook_1", "AreaSecretBook_1", "CollideSecretBook", false, 0);
AddEntityCollideCallback("SecretBook_2", "AreaSecretBook_2", "CollideSecretBook", false, 0);
AddEntityCollideCallback("SecretBook_3", "AreaSecretBook_3", "CollideSecretBook", false, 0);



But since SecretBook_1 doesn't collide with AreaSecretBook_1, it buggs. So if you want to fix it, rename the areas so they match the books.

Also, if you want it too look even better, remember to use the mansion_extension wall over the regular mansion_02.

Oh my god it works now! Thanks! Tongue

“Life is a game, play it”
06-23-2011 02:42 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)