Frictional Games Forum (read-only)
How to activate a 'Puzzle completed' script - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to activate a 'Puzzle completed' script (/thread-12724.html)



How to activate a 'Puzzle completed' script - Quotentote - 01-20-2012

PHP Code:
void OnStart()
{

AddEntityCollideCallback("book_01""bookarea_1""book1"true1);
AddEntityCollideCallback("book_02""bookarea_1""book2"true1);

///BOOKS
void book1(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_01"false);
SetEntityActive("book_001"true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
}
void book2(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_02"false);
SetEntityActive("book_002"true);
PlayGuiSound("impact_book_med2.ogg",10.0f);


How do i activate the 'puzzle completed' script (like spawning a key or something)
the player has no regular order to do it (so he could do the book2 thing first, then book1)

greetings



RE: How to activate a 'Puzzle completed' script - Tripication - 01-20-2012

(01-20-2012, 09:18 AM)Quotentote Wrote:
PHP Code:
void OnStart()
{

AddEntityCollideCallback("book_01""bookarea_1""book1"true1);
AddEntityCollideCallback("book_02""bookarea_1""book2"true1);

///BOOKS
void book1(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_01"false);
SetEntityActive("book_001"true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
}
void book2(string &in asParentstring &in asChildint alState)
{
SetEntityActive("book_02"false);
SetEntityActive("book_002"true);
PlayGuiSound("impact_book_med2.ogg",10.0f);


How do i activate the 'puzzle completed' script (like spawning a key or something)
the player has no regular order to do it (so he could do the book2 thing first, then book1)

greetings
Do you mean you want book 1 to be put in first, then book 2?


RE: How to activate a 'Puzzle completed' script - Quotentote - 01-20-2012

no. he can do it random. i just need a help with the check function: when every book is placed (no matter in what order) i want to start a new script



RE: How to activate a 'Puzzle completed' script - Tripication - 01-20-2012

Ok, give me a minute of testing


RE: How to activate a 'Puzzle completed' script - Quotentote - 01-20-2012

(01-20-2012, 09:25 AM)Tripication Wrote: Ok, give me a minute of testing
okay Smile




RE: How to activate a 'Puzzle completed' script - Linus Ă…gren - 01-20-2012

Make a new function with the complete script in it. Then place the function inside an if-statement for every book collide areas.

Example:

PHP Code:
void BookComplete()
{
    
Blahblah events..
}

void BookCol1(string &in...)
{
    if(
== 1)
{
    
BookComplete();
}


That's how I do it. Wink


RE: How to activate a 'Puzzle completed' script - Tripication - 01-20-2012

Ok, i've done it.


void OnStart()
{
AddEntityCollideCallback("Player", "bookarea_1", "book1", true, 1);
AddEntityCollideCallback("book_02", "bookarea_1", "book2", true, 1);
SetLocalVarInt("Var01", 0); //THIS MAKES A COUNTER
}


void book1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("book_01", false);
SetEntityActive("book_001", true);
PlayGuiSound("impact_book_med1.ogg",10.0f);
AddLocalVarInt("Var01", 1); //THIS ADDS 1 TO THE COUNTER
if (GetLocalVarInt("Var01") == 2) //THIS CHECKS IF THE COUNTER =2
{
[CODE IN HERE]
}
}

void book2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("book_02", false);
SetEntityActive("book_002", true);
PlayGuiSound("impact_book_med2.ogg",10.0f);
AddLocalVarInt("Var01", 1); //THIS ADDS 1 TO THE COUNTER
if (GetLocalVarInt("Var01") == 2)//THIS CHECKS IF THE COUNTER =2
{
[SAME CODE IN HERE]
}
}

Probably not the most efficient way, but it works.

When the "Counter" = 2, it will call whatever you have in the CODE IN HERE or SAME CODE IN HERE space.
NOTE: WHAT EVER GOES IN THE FIRST CODE SECTION, ALSO GOES IN THE OTHER, WORD FOR WORD OR IT PROBABLY WILL NOT WORK!

Also, http://wiki.frictionalgames.com/hpl2/tutorials/script/localandglobalvariables (tells you how to use variables)


RE: How to activate a 'Puzzle completed' script - Quotentote - 01-20-2012

thank you guys, i guess...ehm i hope i will get it now Big Grin <3



RE: How to activate a 'Puzzle completed' script - Tripication - 01-20-2012

(01-20-2012, 09:49 AM)Quotentote Wrote: thank you guys, i guess...ehm i hope i will get it now Big Grin <3



If you just read through this tutorial.
http://wiki.frictionalgames.com/hpl2/tutorials/script/localandglobalvariables


It will eventually sink in. Very useful when it comes to puzzles Big Grin


RE: How to activate a 'Puzzle completed' script - Quotentote - 01-20-2012

reading this right now ^^ well...as i said i hope i will get it ;D