Frictional Games Forum (read-only)

Full Version: [SOLVED] How to use areas to kill monsters/poof them?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Second post, woo! In my custom story, you start with a monster chasing you, with the text "Run and hide!".

I want the player to hide in a closet, and when they do, the monster disappears after about 1-2 seconds. All help is appreciated.
Make area. Use this:
Code:
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);


Calls a function when two entites collide.

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)

alState: 1 = enter, -1 = leave



asParentName - internal name of main object

asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)

asFunction - function to call

abDeleteOnCollide - determines whether the callback after it was called

alStates - 1 = only enter, -1 = only leave, 0 = both
Then into response use one of those:
Code:
void SetEnemyIsHallucination(string& asName, bool abX);


Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.

void FadeEnemyToSmoke(string& asName, bool abPlaySound);


Instantly fades an enemy to smoke.
(02-04-2012, 11:01 PM)Elven Wrote: [ -> ]Make area. Use this:
Code:
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);


Calls a function when two entites collide.

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)

alState: 1 = enter, -1 = leave



asParentName - internal name of main object

asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)

asFunction - function to call

abDeleteOnCollide - determines whether the callback after it was called

alStates - 1 = only enter, -1 = only leave, 0 = both
Then into response use one of those:
Code:
void SetEnemyIsHallucination(string& asName, bool abX);


Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.

void FadeEnemyToSmoke(string& asName, bool abPlaySound);


Instantly fades an enemy to smoke.
Thanks. I am somewhat familiar with scripting, but I am unsure what I am supposed to copy and paste in your lines of code, and what I am supposed to change. Do I only copy and paste what you have given me?
You have to change some info too. Below it gives info what u need to change into what.

Only thing what u cant change is that part:

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)

Well, u can change MyFunc, but what is AFTER THAT...
(02-04-2012, 11:12 PM)Elven Wrote: [ -> ]You have to change some info too. Below it gives info what u need to change into what.

Only thing what u cant change is that part:

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)

Well, u can change MyFunc, but what is AFTER THAT...
Okay, thank you. One last question that I could eventually figure out but I am too lazy to mess with the editor: Where do I put that code? Into the "lookat_callback" thing, or the other one?
Welcome to the world of scripting:

http://wiki.frictionalgames.com/hpl2/tut...ng/article
What you could do is make and area and name it "Area_1" inside the closet and add this to the onStart thing:

AddEntityCollideCallback("Player", "Area_1", "MonsterDisappear")

then:

void MonsterDisappear(string &in asParent, string &in asChild, int alState)
{
AddTimer("TimerMonsterGone", 2);
}

void TimerMonsterGone(string &in asTimer)
{
SetEntityActive("Monster_1", false);
}


Now, to learn something from this. Read the article the other poster sendt you :] and study this script.
I'm sure your brain will make the logical connection.

Also I'm far from good myself, and I probably made some errors in the script ^ above, so please correct me if I'm wrong!

Hope it helped : p!