Strembitsky
Senior Member
Posts: 254
Threads: 37
Joined: Feb 2012
Reputation:
3
|
[SOLVED] How to use areas to kill monsters/poof them?
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.
(This post was last modified: 02-06-2012, 01:17 AM by Strembitsky.)
|
|
02-04-2012, 10:58 PM |
|
Elven
Posting Freak
Posts: 862
Threads: 37
Joined: Aug 2011
Reputation:
26
|
RE: How to use areas to kill monsters/poof them?
Make area. Use this:
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: 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 |
|
Strembitsky
Senior Member
Posts: 254
Threads: 37
Joined: Feb 2012
Reputation:
3
|
RE: How to use areas to kill monsters/poof them?
(02-04-2012, 11:01 PM)Elven Wrote: Make area. Use this:
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: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?
|
|
02-04-2012, 11:04 PM |
|
Elven
Posting Freak
Posts: 862
Threads: 37
Joined: Aug 2011
Reputation:
26
|
RE: How to use areas to kill monsters/poof them?
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 |
|
Strembitsky
Senior Member
Posts: 254
Threads: 37
Joined: Feb 2012
Reputation:
3
|
RE: How to use areas to kill monsters/poof them?
(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?
|
|
02-04-2012, 11:14 PM |
|
Elven
Posting Freak
Posts: 862
Threads: 37
Joined: Aug 2011
Reputation:
26
|
RE: How to use areas to kill monsters/poof them?
(This post was last modified: 02-04-2012, 11:18 PM by Elven.)
|
|
02-04-2012, 11:18 PM |
|
Rokotain
Member
Posts: 54
Threads: 9
Joined: Jul 2011
Reputation:
0
|
RE: How to use areas to kill monsters/poof them?
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!
|
|
02-06-2012, 12:13 AM |
|
|