You are playing as Alma. A young girl living in a castle somewhere in England. Alma's father don't like Alma and do what ever it takes to punish her if things don't turn out the way he want. Everything went even more downhill when Alma's mother left their family. You wake up in a prison cell and have a feeling you have been there before. Its like the time have been turned backwards and you have to live through a horrible part of your life again. Alma is a psychiatric story about feelings and seeing the world through the eyes of a young girl with special needs. This CS focus a lot on the story itself, so please don't rush, explore and read notes carefully. Justine patch required Credits: Chad Pain - voice acting (steamcommunity.com/id/ChadPain)

Post tutorial Report content RSS feed Amnesia - Spawning monsters

A tutorial for Amnesia. How to spawn monsters, how to make them walk around and how to remove them.

Posted by on - Basic Mapping/Technical

Want to know how you spawn monsters and make them patrol your map?

To start with, add a monster from the "enemy" folder in "entities" in the level editor. Brute or grunt is recommended for this tutorial. Place it anymore in your map, click on it and click on the "active" box. We DONT want him to be active from start. Remember to name the monster. I will call it "grunt". Click on "Entity" and you can see 2 options. One of them says "Disable triggers". Activate it and that means the monster will ignore the player and sounds you are making. Only recommended for cut-scenes and moments you dont want the monster to be distracted by other sounds. "Hallucination" is exactly what it says. The monster will be a hallucination and will disapear once the player is close enough to the monster.
Now, use the "Areas" tool and select "Script\". Drag the script any where you want (the monster will be activated once the player touch this script). Name it, or keep the original name. To make it simple, I will call it "script\" This is the command we are going to work with:

AddEntityCollideCallback("Player", "script\", "monster", true, 1);

AddEntityColideCallback is always used if you want something to happen when the player is touching something. A script is the most common thing to use. First field is who you want to activate the event. Name it "Player" and the player will be the one to active it. Second field is what the player is touching. I decided to call it "script\". The third field is the callback. What we want the game to do once the player have touched the trigger. I will call it "monster" to make it simple.
The fourth field is if you want this to happen once. If false, the player can trigger as many times he like. True is recommended. The fifth field is if we want this to happen once the player have touched the trigger, if the player is inside the trigger or if the player is leaving the trigger. Leave it "1". Much easier.

Now go to your level editor again and select the "Areas" tool and select "PathNode". The pathnode is where you want your monster to go to. It's important to place it as close to the ground as possible and make it linear! I recommend you to create one node and then copy that one and move it forward in a stright line to not confuse the monster! Also, you dont need to create a node for every step the monster is taking. But the monster will patrol faster if you have few nodes. Name the nodes what ever you want. To make it simple, I will call them node_1, node_2, node_3 etc.

Now, let's make make the callback
The Callback is what you want the game to do once the player have touched the script.

void monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",true);
AddEnemyPatrolNode("grunt","node_1",0,"");
AddEnemyPatrolNode("grunt","node_2",0,"");
AddEnemyPatrolNode("grunt","node_3",0,"");
}


Just continue to copy the same commands and continue the same way if you have more nodes in your map.

SetEntityActive is the entitiy you want to activate. The monster in this case.
AddEnemyPatrolNode is the nodes you have placed in your map. First field is the monster (grunt), second field is where he is supposed to go. Third field is how long he will stand at each node before moving on to the next one and the last field is the animation he is using while moving. Keep it blank!

Now we have a monster and he is moving to the nodes we want. But what if we want the monster to go away after awhile?

Let's see how that works. To start with, copy this command:

AddEntityCollideCallback("grunt","stop","CollideStop",true,1);

First field is the person or entity we want to touch the trigger. The monster in this case (grunt). Second field is the script we want him to touch. I named it "stop". Third field is the callback. Leave the other two fields as they are.

The callback is:

void CollideStop(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",false);
}

What do we want to happen? We want the grunt to go away. The command is called "SetEntityActive" but since we want him to be disabled, type "false" in the second field instead of "true", First field is ofcourse the entity we want to be disabled. If this is going to work, make sure the monster is going to touch the script by putting the last node behind the "stop" script.

This is how it will look like once everything is done:

void OnStart()
{
AddEntityCollideCallback("Player", "script\", "monster", true,1);
AddEntityCollideCallback("grunt","stop","CollideStop",true,1);
}

void monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",true);
AddEnemyPatrolNode("grunt","node_1",0,"");
AddEnemyPatrolNode("grunt","node_2",0,"");
AddEnemyPatrolNode("grunt","node_3",0,"");
}

void CollideStop(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",false);
}

Post comment Comments
Taylor122002
Taylor122002

Thanks for the information! I didn't know how to make the enemies disappear, and this helped. :D

Reply Good karma Bad karma+3 votes
KrustiClawn Author
KrustiClawn

No problem ;)

Reply Good karma+1 vote
DragonStar325
DragonStar325

The grunt won't activate
What about void OnEnter and OnLeave?

Reply Good karma Bad karma+1 vote
DragonStar325
DragonStar325

Okay it works now thank you.

Reply Good karma Bad karma+1 vote
KrustiClawn Author
KrustiClawn

Alright good. No problem :3

Reply Good karma+1 vote
DragonStar325
DragonStar325

Can the "FUNCTION"

AddEntityCollideCallback("PLAYER", "AREA", "FUNCTION", true, 1);

have to be a specific name or you can name it what ever you want?

Reply Good karma Bad karma+1 vote
KrustiClawn Author
KrustiClawn

Can be what ever you want.

Reply Good karma+1 vote
Guest
Guest

I have copied script from you but when i load my map its says unexpected end of file.can you give me a true script for it?

Reply Good karma Bad karma0 votes
KrustiClawn Author
KrustiClawn

This is a "true script". The error you have can be anywhere in the script file, not just from this.

Reply Good karma+1 vote
Post a comment

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account: