How do I make an enemy spawn when the player enters a script area? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: How do I make an enemy spawn when the player enters a script area? (/thread-7191.html) |
How do I make an enemy spawn when the player enters a script area? - KHShox - 04-03-2011 I want to make an enemy spawn in the hallway right when the player gets into an area. How could I do this? RE: How do I make an enemy spawn when the player enters a script area? - Austums - 04-04-2011 First make a script area, name it whatever you want. In your script file under OnStart, put this Code: AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1); "Monster_1" is the name of my script area. Change it to whatever yours is called. "MonsterFunc1" is the name of the function we're going to use later. Oh, I forgot. Make sure the enemy is "disabled" in the editor. Do this by clicking on the enemy and finding the box called "Active" and click it if it's checked. Once all that is done, add this to your script Code: void MonsterFunc1(string &in asParent, string &in asChild, int alState) MonsterFunc1 is the name of your function. The string stuff is just randomness and I don't know what they do, but you need them, lol Replace the name of "servant_grunt_1" with whatever you named your grunt. Voila. Your enemy should appear when you walk into the area script ~_^ RE: How do I make an enemy spawn when the player enters a script area? - KHShox - 04-04-2011 Quote:////////////////////////////There is my whole code after I added your stuff in it. But I got an error upon loading my map. RE: How do I make an enemy spawn when the player enters a script area? - Austums - 04-04-2011 Well... Yeah. It looks like there are a lot of things wrong with your script, tbh. RE: How do I make an enemy spawn when the player enters a script area? - Pandemoneus - 04-04-2011 Check the link in my sig. RE: How do I make an enemy spawn when the player enters a script area? - KHShox - 04-04-2011 (04-04-2011, 12:37 AM)Austums Wrote: Well... Yeah. It looks like there are a lot of things wrong with your script, tbh.Lol, that's what I thought (04-04-2011, 12:49 AM)Pandemoneus Wrote: Check the link in my sig.I have been there several times. I downloaded all the videos and reviewed them. But they don't answer all of my questions. I don't know how to keep adding commands without having the ones before it mess up, or my game just crashes. (04-04-2011, 12:49 AM)Pandemoneus Wrote: Check the link in my sig.I have been there several times. I downloaded all the videos and reviewed them. But they don't answer all of my questions. I don't know how to keep adding commands without having the ones before it mess up, or my game just crashes. RE: How do I make an enemy spawn when the player enters a script area? - Pandemoneus - 04-04-2011 Also use the search function. http://www.frictionalgames.com/forum/thread-5117.html RE: How do I make an enemy spawn when the player enters a script area? - iNs - 04-04-2011 Code: void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates); What does it? It calls a function when two entites collide. Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState) asParentName internal name of main object asChildName internal name of object that collides with main object (asterix (*) NOT supported!) asFunction function to call (for example "MyFunction") abDeleteOnCollide delete the callback after it was called? alStates: 1 = on enter (when the 2 entities collide) -1 = on leave (when they dont collide anymore) 0 = on enter AND on leave --- I have fixed your code: Code: //////////////////////////// What do you need to get this code to work? - Script Area named: "AreaCloseDoor" - Script Area named: "AreaCloseDoor2" (optional) - Script Area named: "MonsterArea" - Your Monster named: "NotSoScaryMonster" --- I hope that helps ya. Regards iNs RE: How do I make an enemy spawn when the player enters a script area? - KHShox - 04-04-2011 Thanks man! This surely does help! |