| 
		
	
		| SiderealStop   Junior Member
 
 Posts: 32
 Threads: 3
 Joined: Jun 2012
 Reputation: 
0
 | 
			| Looping? (Still need help) 
 
				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!
 
				
(This post was last modified: 06-24-2012, 09:08 PM by SiderealStop.)
 |  |  
	| 06-24-2012, 02:39 PM |  |  
	
		| Rapture   Posting Freak
 
 Posts: 1,078
 Threads: 79
 Joined: May 2011
 Reputation: 
30
 | 
			| RE: Looping? 
 
				Add a Timer that loops back on the function that has your monster node paths.
			 |  |  
	| 06-24-2012, 03:19 PM |  |  
	
		| SiderealStop   Junior Member
 
 Posts: 32
 Threads: 3
 Joined: Jun 2012
 Reputation: 
0
 | 
			| RE: Looping? 
 
				How...would I do that? XD I'm reasonably new to the scripting. =3
			 |  |  
	| 06-24-2012, 03:37 PM |  |  
	
		| SilentStriker   Posting Freak
 
 Posts: 950
 Threads: 26
 Joined: Jul 2011
 Reputation: 
43
 | 
			| RE: Looping? 
 
				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.
 
 |  |  
	| 06-24-2012, 05:02 PM |  |  
	
		| SiderealStop   Junior Member
 
 Posts: 32
 Threads: 3
 Joined: Jun 2012
 Reputation: 
0
 | 
			| RE: Looping? 
 
				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~
 |  |  
	| 06-24-2012, 06:15 PM |  |  
	
		| Cruzore   Senior Member
 
 Posts: 301
 Threads: 2
 Joined: Jun 2012
 Reputation: 
37
 | 
			| RE: Looping? 
 
				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.
			 |  |  
	| 06-24-2012, 06:28 PM |  |  
	
		| SiderealStop   Junior Member
 
 Posts: 32
 Threads: 3
 Joined: Jun 2012
 Reputation: 
0
 | 
			| RE: Looping? 
 
				Ah...how would you do a collide callback for a timer? O-o
			 |  |  
	| 06-24-2012, 07:22 PM |  |  
	
		| Cruzore   Senior Member
 
 Posts: 301
 Threads: 2
 Joined: Jun 2012
 Reputation: 
37
 | 
			| RE: Looping? 
 
				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.
			 |  |  
	| 06-24-2012, 07:28 PM |  |  
	
		| SiderealStop   Junior Member
 
 Posts: 32
 Threads: 3
 Joined: Jun 2012
 Reputation: 
0
 | 
			| RE: Looping? 
 
				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? XD
 
Trying to understand this~ o3o
			 |  |  
	| 06-24-2012, 07:42 PM |  |  
	
		| Cruzore   Senior Member
 
 Posts: 301
 Threads: 2
 Joined: Jun 2012
 Reputation: 
37
 | 
			| RE: Looping? 
 
				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.
 |  |  
	| 06-24-2012, 07:48 PM |  |  |