Frictional Games Forum (read-only)
Problems spawning an entity - 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: Problems spawning an entity (/thread-10738.html)



Problems spawning an entity - flamez3 - 10-13-2011



void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

{
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}

}


highlighted in bold is the one that is having the problems, it says there's an expected ( between the
void and the MonsterFunc1

Any help on this?


RE: Problems spawning an entity - Tanshaydar - 10-13-2011

You should put your collision callbacks in a function blog, just putting them loose will not work like that

Code:
{
  something
}

Second thing is, you cannot put same name to two different functions. Make it MonsterFunc2 and put your callback into your OnStart function.


RE: Problems spawning an entity - flamez3 - 10-13-2011

(10-13-2011, 11:07 AM)Tanshaydar Wrote: You should put your collision callbacks in a function blog, just putting them loose will not work like that

Code:
{
  something
}

Second thing is, you cannot put same name to two different functions. Make it MonsterFunc2 and put your callback into your OnStart function.
Thanks for the response, when your talking about the callbacks, where would i have to the callbacks in my script?


RE: Problems spawning an entity - Tanshaydar - 10-13-2011

Usually in OnStart, which runs when your map starts.


RE: Problems spawning an entity - flamez3 - 10-13-2011

(10-13-2011, 12:05 PM)Tanshaydar Wrote: Usually in OnStart, which runs when your map starts.
Thanks for that, but it comes up with unexpected token in Line 12 column 1


void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

{ <<<<----- Right here
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}
void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}


I've looked at some tutorials in basic scripting and haven't found anything that i could use in this situation. I need some help here Smile


RE: Problems spawning an entity - Tanshaydar - 10-13-2011

Code:
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}


void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}



RE: Problems spawning an entity - flamez3 - 10-13-2011

(10-13-2011, 12:21 PM)Tanshaydar Wrote:
Code:
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}


void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}
Thank you, i really appreciate that. You didn't have to give me the script. You could of told me what was in the wrong place, I am SOOOOO glad it works now, thank you for your help Smile



RE: Problems spawning an entity - Tanshaydar - 10-13-2011

Actually you can see what I've changed in the script so that might tell you how to do it. But showing it with a working script would be better I thought.