Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make encounters?
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#1
How to make encounters?

Hi there guys! I am working on a "test map" and is looking very very well! But what I need to know, is how to make enemy encounters? Example:
I enter a new room, but just when I enter, a grunt will spawn near me and he will attack me. I've seen the Active button, wich makes the entity not spawn until something it triggers it. I was looking for some Areas, but there is no such thing for "Activating/Spawning" certain monster! Do I need Scripting knowledge? If this is true, can someone help me? I am very interested on making Amnesia Stories Tongue

Thanks!

09-15-2010, 12:40 AM
Find
MulleDK19 Offline
Senior Member

Posts: 545
Threads: 21
Joined: Jun 2009
Reputation: 10
#2
RE: How to make encounters?

(09-15-2010, 12:40 AM)sacroid Wrote: Hi there guys! I am working on a "test map" and is looking very very well! But what I need to know, is how to make enemy encounters? Example:
I enter a new room, but just when I enter, a grunt will spawn near me and he will attack me. I've seen the Active button, wich makes the entity not spawn until something it triggers it. I was looking for some Areas, but there is no such thing for "Activating/Spawning" certain monster! Do I need Scripting knowledge? If this is true, can someone help me? I am very interested on making Amnesia Stories Tongue

Thanks!

That would indeed require scripting.

Create an area of the type Script where you want the "trigger".
Call it eg. MyRoomArea.

Place an enemy, eg. a servant_grunt.

Create a file in the same folder as your map. Call it the same as your map, but give it the extension .hps.

eg. if your map is called 00_test.map, then you call the file 00_test.hps

Then open it and add the following content:

void OnStart()
{
    //Add a callback for when the player collides with the area you created and called MyRoomArea
    AddEntityCollideCallback("Player", "MyRoomArea", "CollideMyRoomArea", true, 0);
}

void OnEnter()
{
}

//This function is called when the player collides with the area called MyRoomArea
void CollideMyRoomArea(string &in asParent, string &in asChild, int alState)
{
    //Make the entity called "servant_grunt_1" active.
    //Change the servant_grunt_1 to whatever your enemy is called.
    SetEntityActive("servant_grunt_1", true);
}

Save, and load the map.

Also, read through the script, and check the commentaries, to make sure it's all named correct.

[Image: 16455.png]
09-15-2010, 02:53 AM
Find
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#3
RE: How to make encounters?

Thank you very much! That was exactly what I was needing Wink
Also, in this way I'm kinda getting the thing of scripting, thanks again Big Grin
Now there's another problem, how to make waypoints Tongue
If I am not wrong, the waypoints are the Path Node Areas I think.

Now, if you don't mind, would you help me on scripting waypints and also despawning? (for example: the creature is created y searches you [waypoints] and the he goes away and despawns)
I would REALLY appreciate this. THANKS!

---
EDIT: By the way, I have tried the script and it doesn't seem to work.
Mine looks like this:
void OnStart()
{
    //Add a callback for when the player collides with the area you created and called MyRoomArea
    AddEntityCollideCallback("Player", "spawn_hallucination", "Collidespawn_hallucination", true, 0);
}

void OnEnter()
{
}

//This function is called when the player collides with the area called MyRoomArea
void spawn_hallucination(string &in asParent, string &in asChild, int alState)
{
    //Make the entity called "servant_grunt_1" active.
    //Change the servant_grunt_1 to whatever your enemy is called.
    SetEntityActive("Grunt_fake", true);
}
Wich is the problem there? I pass through that Script Area and nothing happens Tongue
09-15-2010, 06:26 AM
Find
theDARKW0LF Offline
Member

Posts: 150
Threads: 17
Joined: Sep 2010
Reputation: 0
#4
RE: How to make encounters?

I followed the same steps and what you need to do is make sure that every box is unchecked in the Area tab of the script box.

Check out my custom stories(1)(2)!
09-15-2010, 08:08 AM
Find
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#5
RE: How to make encounters?

(09-15-2010, 08:08 AM)theDARKW0LF Wrote: I followed the same steps and what you need to do is make sure that every box is unchecked in the Area tab of the script box.

I alredy unchecked it all and still nothing... :S

09-15-2010, 08:16 AM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#6
RE: How to make encounters?

I think you call the area spawn_hallucination? Then in the script you say that the area "spawn_hallucination" has a function called "Collidespawn_hallucination", but you call that function spawn_hallucination in the script, so rename it to Collidespawn_hallucination and it should work.

Also a tip, always add a debug message to places like this in your script. So in the Collidespawn_hallucination function below SetEntityActive("Grunt_fake", true); write AddDebugMessage("Entered Area!!!", false); and that way you will easily see that if the message "Entered Area!!!" is shown in the bottom left ingame, you know the function works.
09-15-2010, 08:21 AM
Website Find
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#7
RE: How to make encounters?

(09-15-2010, 08:21 AM)jens Wrote: I think you call the area spawn_hallucination? Then in the script you say that the area "spawn_hallucination" has a function called "Collidespawn_hallucination", but you call that function spawn_hallucination in the script, so rename it to Collidespawn_hallucination and it should work.

Also a tip, always add a debug message to places like this in your script. So in the Collidespawn_hallucination function below SetEntityActive("Grunt_fake", true); write AddDebugMessage("Entered Area!!!", false); and that way you will easily see that if the message "Entered Area!!!" is shown in the bottom left ingame, you know the function works.

Wow, really, thanks for the help! I'm going to try it out now, and see if it works Wink It was my mistake, you are right, I named the command "spawn_hallucination". My bad Tongue
Now I'm looking foward for paths and despawns ò.ó

EDIT: Yes! It finally worked! Thank you all Wink

09-15-2010, 08:25 AM
Find
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#8
RE: How to make encounters?

I am starting to make a real encounter now (the other one was an illusion).
I think I figured out how to use waypoints, but still, I don't know how to despawn the enemy. Can someone make me a script since the beginning? (wich is since the spawn of the enemy until the despawn) with waypoints please Tongue

P.S: Sorry for being so pain in the ass, but I guess everyone needs to learn... right? Tongue
By the way, I suggest that, all together, make a "super thread" with all scripts for every situation possible (like open doors with keys, encounters wich is my case, things like touching a locked door but it makes a cammera effect and a sound effecto to shit your pants just like in wine cellar, etc...) so like that everyone will not have so many problems with the editor and triggering Tongue

I Would appreciate the help VERY MUCH!

09-15-2010, 02:21 PM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#9
RE: How to make encounters?

Give the enemy some waypoints (script for this is AddEnemyPatrolNode) in the OnStart, then the enemy will disable by himself when he has walked his path and you are not in a position where you can see him.

Or if you want to force him to be disabled you can for example add an area at the location of the last path node you give him to walk to. You do it just like you do when the player collides with an area to activate the grunt, but instead you add a collide between the grunt and the area to despawn him with SetEntityActive("Grunt_fake", false);

The full path node script is
AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);

asName = name of the grunt -> "Grunt_fake".
asNodeName = name of the node area you give a path to -> "PathNode_1" or what ever name the path node might have.
afWaitTime = how long he should wait at a node when reaching it, set to 0.
asAnimation = set this simply to "".
09-15-2010, 02:31 PM
Website Find
sacroid Offline
Member

Posts: 88
Threads: 11
Joined: Apr 2010
Reputation: 0
#10
RE: How to make encounters?

(09-15-2010, 02:31 PM)jens Wrote: Give the enemy some waypoints (script for this is AddEnemyPatrolNode) in the OnStart, then the enemy will disable by himself when he has walked his path and you are not in a position where you can see him.

Or if you want to force him to be disabled you can for example add an area at the location of the last path node you give him to walk to. You do it just like you do when the player collides with an area to activate the grunt, but instead you add a collide between the grunt and the area to despawn him with SetEntityActive("Grunt_fake", false);

The full path node script is
AddEnemyPatrolNode(string& asName, string& asNodeName, float afWaitTime, string& asAnimation);

asName = name of the grunt -> "Grunt_fake".
asNodeName = name of the node area you give a path to -> "PathNode_1" or what ever name the path node might have.
afWaitTime = how long he should wait at a node when reaching it, set to 0.
asAnimation = set this simply to "".

Wow, THANKS SO MUCH! I would give you a hug right now Blush lol, I'm going to try it right now!

09-15-2010, 02:41 PM
Find




Users browsing this thread: 1 Guest(s)