Frictional Games Forum (read-only)

Full Version: Making monster go away
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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 =)
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
Right, here we go:

Code:
////////////////////////////////
//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
Thanks dude, I'll have to give it a go tomorrow and will let you know! Smile