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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making monster go away
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#1
Making monster go away

Hey I got a question, I've got it so a monster appears after I walk into a script area. He chases me and smashes down the door, I hid in the closet. But he just stands there, he does not look around the room and such. How can I script it so after like 10 seconds or so the monster will go away and disappear or become non-active again, is it something to do with Path nodes? (Which i got no idea about).
Sorry I am still very new to this scripting business.
05-03-2011, 12:46 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#2
RE: Making monster go away

You can use pathnodes to move the monster around and another pathnode which will lead the monster through a script area. When they collide, call a FadeEnemyToSmoke function. I'll give you an example script in an hour or so if you can't figure it out =)
05-03-2011, 01:57 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#3
RE: Making monster go away

I example script would help a lot, I would learn a lot quicker that way Smile But I can give it a try as well. Just the example would help Smile
05-03-2011, 02:01 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#4
RE: Making monster go away

Right, here we go:

////////////////////////////////
//Run when starting the map
void OnStart()
{
AddEntityCollideCallback("Player", "MonsterActive_Area", "MonsterActive", true, 1); //When the player collides with "MonterActive_Area", run function "MonsterActive". True means delete on use (i.e will only be called once. If you want to go through the monster part again even if you die, switch the false to true and it will call the function every time you enter it.) and the 1 means that it should run the function when you first enter the script area. (-1 is on leave, 0 is both iirc)
AddEntityCollideCallback("Monster", "MonsterGone_Area", "MonsterGone", true, 1); //When the entity "Monster" collides with "MonsterGone_Area", run function MonsterGone. true and 1 are the same as before.
}

void MonsterActive(string &in asParent , string &in asChild , int alState) //Pay extra attention to the part in parentheses, according to the script functions wiki page the AddEntityCollideCallback has a callback syntax of the stuff in parantheses. By adding this to the function you want to call, the first callback will know how to run it. (Or something like that)
{
  SetEntityActive("Monster", true); //Sets the entity "Monster" to active.
  AddEnemyPatrolNode("Monster", "MonsterPath_1", 2, ""); // "Monster" walks to "MonsterPath_1" from his previous position, and stays there for two seconds.
  AddEnemyPatrolNode("Monster", "MonsterPath_2", 2, ""); // "Monster" walks to "MonsterPath_2" from his previous position, and stays there for two seconds.
  AddEnemyPatrolNode("Monster", "MonsterPath_3", 2, ""); // "Monster" walks to "MonsterPath_3" from his previous position, and stays there for two seconds.
  AddEnemyPatrolNode("Monster", "MonsterPath_4", 5, ""); // "Monster" walks to "MonsterPath_4" from his previous position, and stays there for two seconds.
  AddEnemyPatrolNode("Monster", "MonsterPath_5", 5, ""); // "Monster" walks to "MonsterPath_5" from his previous position, and stays there for two seconds. In this case, this path would have to move the monster through the area called "MonsterGone_Area", calling the MonsterGone function.
  PlayGuiSound("enemy/brute/enabled04.ogg", 1.0f); //Plays "enabled04.ogg" with a fade of 1.0f.
}

void monstergone(string &in asParent , string &in asChild , int alState) //Same callback as before - same syntax.
{
FadeEnemyToSmoke("Monster", true); //Fades the monster to smoke. It will be gone forever.
}


That should do it, all the stuff in quotes will need to be named exactly like in the script, so be sure to either switch the names of the entities, paths, areas, etc, to the script names, or vice versa.

"//" Means that it is a comment explaining what each part does, and will not have any effect on the script.

If I didn't mess something up, it should function if you did your part correctly. Good luck! Please respond if you're getting any error and I'll fix it Smile
(This post was last modified: 05-03-2011, 03:44 PM by Roenlond.)
05-03-2011, 03:43 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#5
RE: Making monster go away

Thanks dude, I'll have to give it a go tomorrow and will let you know! Smile
05-03-2011, 11:49 PM
Find




Users browsing this thread: 2 Guest(s)