Frictional Games Forum (read-only)
Need help with this scripting. - 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: Need help with this scripting. (/thread-16592.html)

Pages: 1 2 3


RE: Need help with this scripting. - EXAWOLT - 06-29-2012

AddEntityCollideCallback("Player", "ScriptArea_1", "SetMonsterActive", false, 1);
!
false means that the area wont disappear after use
void SetMonsterActive(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
}
///////////////
set the monster disabled in the level editor, and it will work!


RE: Need help with this scripting. - ApeCake - 06-29-2012

Exawolts solution should work just fine. I'd put the AddEntityCollideCallback in void OnStart() instead of void OnEnter() though... maybe that's the problem?


RE: Need help with this scripting. - HoyChampoy - 06-29-2012

(06-29-2012, 10:19 PM)EXAWOLT Wrote: AddEntityCollideCallback("Player", "ScriptArea_1", "SetMonsterActive", false, 1);
!
false means that the area wont disappear after use
void SetMonsterActive(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
}
///////////////
set the monster disabled in the level editor, and it will work!
This works great but there's a problem. I need it too work once because if the player unfortunately runs into the area again their screen fades out while the monster is chasing them. Undecided Basically, is it possible to have the area work once until the player dies?


RE: Need help with this scripting. - Cruzore - 06-29-2012

If I understood your question right, you want to use a part of the callback only once, and the rest allways? If so:
1 option is to make a local variable, which is set 0 in OnStart(), the stuff you want to happen only once gets an if statement to check if the variable is 0, and inside you set the variable 1.


RE: Need help with this scripting. - HoyChampoy - 06-29-2012

(06-29-2012, 11:57 PM)FastHunteR Wrote: If I understood your question right, you want to use a part of the callback only once, and the rest allways? If so:
1 option is to make a local variable, which is set 0 in OnStart(), the stuff you want to happen only once gets an if statement to check if the variable is 0, and inside you set the variable 1.
Im sorry im a n00b when it comes to this. Sad How would that possibly look like?


RE: Need help with this scripting. - Your Computer - 06-30-2012

Make sure the first collision callback gets removed when triggered. Then in the checkpoint callback, you can just add the same collision callback.


RE: Need help with this scripting. - Cruzore - 06-30-2012

example script:
PHP Code:
void OnStart()
 {
  
SetLocalVarInt("YourVariableNameHere"0);

 }
 
void YourFunction(string &in asNameint alCount
 {
 if(
GetLocalVarInt("YourVariableNameHere")==0)
 {
 
SetLocalVarInt("YourVariableNameHere"1);

 
//and stuff you want to happen only once comes here
 
}
 
//stuff you want to happen allways comes here
 

void YourFunction is the Function that comes from your Checkpoint callback.


RE: Need help with this scripting. - EXAWOLT - 06-30-2012

just make 2 areas in same place. one area where the monster comes up, that will be repeated, an one for the fades that will not happen again, simply nuff said


RE: Need help with this scripting. - Cruzore - 06-30-2012

As I said, there are multiple ways. A variable is 1 way, another callback is the other. There are most likely more.


RE: Need help with this scripting. - HoyChampoy - 06-30-2012

(06-30-2012, 12:04 AM)FastHunteR Wrote: example script:
PHP Code:
void OnStart()
 {
  
SetLocalVarInt("YourVariableNameHere"0);

 }
 
void YourFunction(string &in asNameint alCount
 {
 if(
GetLocalVarInt("YourVariableNameHere")==0)
 {
 
SetLocalVarInt("YourVariableNameHere"1);

 
//and stuff you want to happen only once comes here
 
}
 
//stuff you want to happen allways comes here
 

void YourFunction is the Function that comes from your Checkpoint callback.
"your variable name here" is the name of the area correct? Ill try this