Frictional Games Forum (read-only)
Why doesnt this script work!? - 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: Why doesnt this script work!? (/thread-9030.html)



Why doesnt this script work!? - Angerpull - 07-08-2011

Hey can anyone tell me what's wrong with my script? I want a grunt to spawn and walk against a path, but no matter what I do it will not work.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player" , "GruntCorner" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("CornerGrunt" , true);
AddEnemyPatrolNode("CornerGrunt", "Path1", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path2", 5, "");
AddEnemyPatrolNode("CornerGrunt", "Path3", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path4", 0, "");
}



RE: I see no Problems!? - Zypherzemus - 07-08-2011

(07-08-2011, 10:59 PM)Angerpull Wrote: Hey can anyone tell me what's wrong with my script? I want a grunt to spawn and walk against a path, but no matter what I do it will not work.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player" , "GruntCorner" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("CornerGrunt" , true);
AddEnemyPatrolNode("CornerGrunt", "Path1", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path2", 5, "");
AddEnemyPatrolNode("CornerGrunt", "Path3", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path4", 0, "");
}

Does the enemy even become active? As in, does it actually spawn?
I personally think that the "CreateEntityAtArea" command works better than the "SetEntityActive" command. That's just me though, first off, does the map even load?


RE: I see no Problems!? - Angerpull - 07-08-2011

(07-08-2011, 11:12 PM)Snuffalofagus Wrote:
(07-08-2011, 10:59 PM)Angerpull Wrote: Hey can anyone tell me what's wrong with my script? I want a grunt to spawn and walk against a path, but no matter what I do it will not work.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player" , "GruntCorner" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("CornerGrunt" , true);
AddEnemyPatrolNode("CornerGrunt", "Path1", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path2", 5, "");
AddEnemyPatrolNode("CornerGrunt", "Path3", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path4", 0, "");
}

Does the enemy even become active? As in, does it actually spawn?
I personally think that the "CreateEntityAtArea" command works better than the "SetEntityActive" command. That's just me though, first off, does the map even load?

Yes the map loads, how could I know if the script worked or not? But I see no problems with my script.




RE: I see no Problems!? - Zypherzemus - 07-09-2011

I'm not so sure about the path nodes but for the entity to spawn, try this:

In the level editor, create an enemy area (i think thats the name of the type of area) where you want it to spawn, then in the .hps file add this

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

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
CreateEntityAtArea("grunt_1", "servant_grunt.ent", "SpawnArea", true);
AddEnemyPatrolNode("CornerGrunt", "Path1", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path2", 5, "");
AddEnemyPatrolNode("CornerGrunt", "Path3", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path4", 0, "");
}

"SpawnArea" is the name of what you named the area, it doesn't have to be "SpawnArea"

P.S. If there is no area named "EnemyArea" or whatever in the level editor, just use a regular "ScriptArea"



RE: I see no Problems!? - Angerpull - 07-09-2011

(07-09-2011, 12:57 AM)Snuffalofagus Wrote: I'm not so sure about the path nodes but for the entity to spawn, try this:

In the level editor, create an enemy area (i think thats the name of the type of area) where you want it to spawn, then in the .hps file add this

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

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
CreateEntityAtArea("grunt_1", "servant_grunt.ent", "SpawnArea", true);
AddEnemyPatrolNode("CornerGrunt", "Path1", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path2", 5, "");
AddEnemyPatrolNode("CornerGrunt", "Path3", 0, "");
AddEnemyPatrolNode("CornerGrunt", "Path4", 0, "");
}

"SpawnArea" is the name of what you named the area, it doesn't have to be "SpawnArea"

P.S. If there is no area named "EnemyArea" or whatever in the level editor, just use a regular "ScriptArea"

I like to use the Activate Entity better.

But here's my Script.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player" , "ZP" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("Z1" , true);
AddEnemyPatrolNode("Z1", "Path1", 0, "");
AddEnemyPatrolNode("Z1", "Path2", 5, "");
AddEnemyPatrolNode("Z1", "Path3", 0, "");
AddEnemyPatrolNode("Z1", "Path4", 0, "");
}

Now let me explain. Z1 = The Grunt that is Spawning. ZP Is the Script AREA. Can you tell me what is wrong?