Looping? (Still need help) - 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: Looping? (Still need help) (/thread-16458.html) |
Looping? (Still need help) - SiderealStop - 06-24-2012 Okay, I understand how to get something to follow a path. I understand how to do it rather than just knowing what to copy&paste. But what I don't know how to do is loop it so that when it gets to the last path node, it starts again at the first. It gets a bit more complicated than that though. The room is a big circled hallway which is what I have him patrolling around. The player has to go around to the little dips and rooms and flick switches to start up some machines so that the player can then go and open a door (that is in the same map) to the room with all the machines. Once you flick the last switch and start turning the valve that opens the door, I want the grunt to start going after the player. There could be walls between the player and the grunt, would that be an issue? Thanks! RE: Looping? - Rapture - 06-24-2012 Add a Timer that loops back on the function that has your monster node paths. RE: Looping? - SiderealStop - 06-24-2012 How...would I do that? XD I'm reasonably new to the scripting. =3 RE: Looping? - SilentStriker - 06-24-2012 A timer loop looks like this AddTimer("1", 2, "Loop"); void Loop(string &in asTimer) { //Do your stuff AddTimer("2", 1, "Loop"); } so that's how a Timer loop looks like, you first call the function and in the function you call the same function which ends up in an infinite loop untill you stop it by using RemoveTimer("1"); RemoveTimer("2"); the 1 and the 2 is only there to be able to remove the timers. RE: Looping? - SiderealStop - 06-24-2012 Alright, I think I understand. I'm playing around with it in my script at the moment. Not sure how to work it still though D= I have this: void OnStart() { AddEntityCollideCallback("Player", "PlayerCollide", "servant_grunt_1", true, 1); InteractConnectPropWithMoveObject("MachineryDoor", "valve_iron_rusty_1", "MachineryDoor", true, false, -1); } void OnEnter() void Loop(string &in asTimer) { SetEntityActive("servant_grunt_1", true); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 1, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0, ""); AddTimer("2", 1, "Loop"); } (I have a door that opens using one of the valve entities. Ignore that part o3o ) I'm certain this is wrong. XD I just threw it in. Any way someone can help me understand how to fill the loop out? =D Thanks~ RE: Looping? - Cruzore - 06-24-2012 Don't know about this, but maybe add a collide callback for the player/grunt(what the hell did you say, player? how the..) and let that collide callback add that timer. Just an idea though. RE: Looping? - SiderealStop - 06-24-2012 Ah...how would you do a collide callback for a timer? O-o RE: Looping? - Cruzore - 06-24-2012 place a script area near the last path node, or right at it, idk.(try it out) Then, add to OnStart, the collide callback. You probably know how to. Then, let that callback call a function to add the timer. If you don't know how to write something, I can explain it to you. RE: Looping? - SiderealStop - 06-24-2012 Hmm I think I know how to do up to calling the function- Added the script area. To add the callback would it be 'AddEntityCollideCallback("ScriptArea_1", "servant_grunt_1 ", "ActivateTimer", true, 1); ?
I took a look at the wiki page of all the functions, second "" should be thing thing that collides with the first "" and then the function in the third "". Am I using the right callback thing? XDTrying to understand this~ o3o RE: Looping? - Cruzore - 06-24-2012 as far as I know, it doesn't matter which is parent and which is child. But since I see evryone use the player as the child, you should stick to the grunt being the child, in this case your collide callback is right. However, the true you got there refers to: bool abDeleteOnCollide and that means it will delete after called. Which, since we want a loop, don't want. so set it to false. That should answer your question, and you should have no problem with the timer. |