Help needed with SetEntityActive in custom story - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +--- Thread: Help needed with SetEntityActive in custom story (/thread-53444.html) |
Help needed with SetEntityActive in custom story - hagridas - 01-03-2017 Hello. I decided to make a custom story. I am green at scripting, however i can make some simple things like key that unlocks specific doors n stuff. Today i tried to make a script where a monster spawns when player collides with ScriptArea, walks abit and then despawns at certain pathnode. The monster spawns, walks, however it doesnt despawn i tried multiple times watched multiple videos but it doesnt work. I will appreciate any help. My script: void OnStart() { AddEntityCollideCallback("Player", "area", "monster", true,1); AddEntityCollideCallback("grunt", "PathNodeArea_12", "CollideStop", true, 1); } void monster(string &in asParent, string &in asChild, int alState) { SetEntityActive("grunt",true); AddEnemyPatrolNode("grunt", "PathNodeArea_1", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_2", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_3", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_4", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_5", 4, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_6", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_7", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_8", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_9", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_10", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_11", 0.001, ""); AddEnemyPatrolNode("grunt", "PathNodeArea_12", 0.001, ""); } void CollideStop(string &in asParent, string &in asChild, int alState) { SetEntityActive("grunt", false); } THANK YOU !!! RE: Help needed with SetEntityActive in custom story - Spelos - 01-03-2017 Alright, a few things. I'll order them by their relevance to your case: WHY IT DOESN'T WORK While you are creating a collision callback for the enemy, a path node is just a single point in the world. It is just a directional helper, a flag if you will, that the enemies use to calculate their path towards their destination. Collision can be calculated with things that actually take up space. Such as Script Areas. Tell me more: Spoiler below!
HOW TO MAKE IT WORK Instead of referencing the last PathNode, create a script area there. The enemy will collide with that area. WHAT TO THINK ABOUT Enemies disappear on their own once far enough from a player & at the end of their patrol instructions. (!) SCRIPT RELATED WARNINGS AND TIPS
RE: Help needed with SetEntityActive in custom story - hagridas - 01-04-2017 It is working now, thanks alot! I thought Amnesia is dead and didn't expect anyone to reply, but WOW your reply was big and helpful Thanks again, everything is working fine now. Ill definately check your Youtube channel for some tutorials n stuff RE: Help needed with SetEntityActive in custom story - FlawlessHappiness - 01-04-2017 (01-04-2017, 10:11 AM)hagridas Wrote: I thought Amnesia is dead and didn't expect anyone to reply Don't worry. We're still a small group of people here! |