How to make things happen only in a certain 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: How to make things happen only in a certain area (/thread-30120.html) |
How to make things happen only in a certain area - MrWallas - 06-15-2015 I'm using a script based off of Wapez's Custom Ambient Map Scares script. But one thing about the script that I'm finding is that the random things continue to happen even when you're outside of the area. I have one area where I want there to be random breath sounds coming from the player but I want it to ONLY happen in that particular area, and stop outside of the area, but then start back up when you enter the area again. Is there any way I can do that? Here's the code, which works as it is right now, but it doesn't do exactly what I want it to do. Code: void OnStart() RE: How to make things happen only in a certain area - Artsy - 06-15-2015 Just put the contents of the timer in a collision callback...? RE: How to make things happen only in a certain area - DnALANGE - 06-15-2015 Try this : PHP Code: void ChangeCAMSState(string &in asEntity, int alState) RE: How to make things happen only in a certain area - Darkfire - 06-15-2015 That's why I don't paste code which I can't understand. Try replacing PlayGuiSound function with PlaySoundAtEntity and use the area you want as the entity. Seems you're not too experienced, so make sure to check these functions in the engine scripts site. RE: How to make things happen only in a certain area - FlawlessHappiness - 06-15-2015 To me, the idea is to have an area that starts a repeating timer, and stops a repeating timer. void CollideCallback(string &in asParent, string &in asChild, int alState) { if(alState == 1) //If going inside area. { if(GetTimerTimeLeft("Breath") > 0) else { AddTimer("Breath", 1.0f, "BreathTimer"); } SetLocalVarInt("BreathTimerVar", 1); } if(alState == -1) //If going outside of area { SetLocalVarInt("BreathTimerVar", 0); } } void BreathTimer(string &in asTimer) { if(GetLocalVarInt("BreathTimerVar") == 1) { //PlaySound AddTimer("Breath", 1.0f, "BreathTimer"); } } RE: How to make things happen only in a certain area - MrWallas - 06-15-2015 (06-15-2015, 10:49 AM)Darkfire Wrote: That's why I don't paste code which I can't understand. Yeah, you're right, I'm not too experienced, but I'm capable of learning, I learned how that code, in and of itself, works. I appreciate the suggestion but I really don't appreciate the snarky attitude you seem to be giving me. RE: How to make things happen only in a certain area - Mudbill - 06-15-2015 I'd say there are two common ways to trigger an event only while in an area. One is to activate it when you enter, then deactivate it when you leave. The other is to run it, but always check if the player is in the area before doing it. The latter is more robust, but there's (as far as I know) no super easy way of checking player collision. You might be able to if you tinker with more than one function though. GetEntitiesCollide does not support Player. Here's an example using the activation method (which is much like what has already been suggested): PHP Code: void OnStart() |