Need help on patrolling guards...

Topics regarding Scripting with Reality Factory
Post Reply
CRxTRDude
Posts: 11
Joined: Fri May 13, 2011 6:26 pm
Contact:

Need help on patrolling guards...

Post by CRxTRDude » Sun May 15, 2011 12:48 pm

Hello again. Now that I'm in the game in making a lot of stuff for myself... I have now begun making development for my comic book adapted game. It's a stealth game where Nikki, the protagonist, would be avoiding guards, UFOs and a bunch of stuff... Now by doing that, I have begun my first level, Nikki should proceed to the elevator...

There I kinda did the first thing that I always do... the "Monkey See, Monkey Do" (More like search and use) technique. I observed the tech demo (rftechv1.3DT) 'cuz I played the RF demos first before doing the game... I tried to use the guards and observed the coding, but it was like relearning programming stuff again.

Now here's the questions:
> What do I consider while coding the guards?
> How do I code the guards like the one at the tech demo?
> What other suggestions can you give and how to implement them.

Thanks ;-)

**PS, I kinda noticed that this place is getting deserted... :D But then I still support this system. And I'm a fast learner regarding these things...
~~THIS IS TEH CRxTRDUDE~~
Cañalita Comics junkie...

User avatar
Nighthawk_0973
Posts: 234
Joined: Tue Apr 19, 2011 2:08 am
Location: In front of my computer.

Re: Need help on patrolling guards...

Post by Nighthawk_0973 » Sun May 15, 2011 5:16 pm

Yeah this place is sort of broken, thats why we try to revive it :)

About making robots. Go into RF Edit Pro, when you make a good guy, just place player start/player setup by the desired spawn point. To make a bad guy, make a pawn, set the following and leave everything else alone:

Code: Select all

Pawn Type: robot
Script Name: robot.s
Spawn Order: Spawn
szentityname: robot
it's case sensitive too. Next if you want to learn how to do the patrols, just open up the RF Demo in RF Edit Pro, you can see what went down there. It's great to learn by example.

Course nothing beats a good tutorial series. Look up: how to make a first person shooter for free part 1 on youtube. This is where I discoverd RF, and I still use it when I'm getting frustrated over my MMO :wink:

Good Luck!
https://sites.google.com/site/theneverendinguniverse/ <-- Infinite Universe Website. It's a 2D MMORPG I'm releasing into beta near the late summer (I hope :D) note: RF isn't an MMO maker. Not yet anyways.

CRxTRDude
Posts: 11
Joined: Fri May 13, 2011 6:26 pm
Contact:

Re: Need help on patrolling guards...

Post by CRxTRDude » Sun May 15, 2011 6:23 pm

Thanks! :D I saw the vids! It's nice! ;-)

BTW, I'm gonna be investigating the patrolling guard sample in the RF tech demo. If any one of you guys (if you guys are still here) here knows how that worked, it's more nicer.

Oh yeah, forgot. I wrote there:
CRxTRDude wrote:I observed the tech demo (rftechv1.3DT) 'cuz I played the RF demos first before doing the game... I tried to use the guards and observed the coding, but it was like relearning programming stuff again.
I meant that I opened the 3DT on the RFEditPro, and looked at the properties of the robot and the scriptnodes (forgot the name) plus I checked the SimKin codes of the robot.... I then copy pasted the robot from the demo. I got stuck there when I played it when it detected me... No matter how much I modified there, I thought there was something missing... The robot always stays guarding. I got lost afterwards... Dunno where to go from there...

EDIT: DONE MY RESEARCH. It seems that the Simkin code used there looked like this (In fact this is actually "robot1.s"):

Code: Select all

{
	IDLE			[idle]
	WALK			[walk]
	RUN			[walk]

	FOV			[160]
	SIGHTDIST		[1000]
	YAWSPEED		[70]
	WALKSPEED		[30]
	SCALE			[1.7]
	DAMAGEATTRIBUTE		[health]
	TELEPORTTARGET		[Rezpoint1] // or whatever the name of the ScriptPoint...
	SW			[0]
	SH			[0]
	

	Start[ ()
	{	
		// Console(true);	
		SetFOV(FOV);					// set field of view
		BoxWidth(50);
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE);	// seen a target to chase
		RotateToPoint(IDLE, YAWSPEED, false, ""); 	// go to point if any specified
		MoveToPoint(WALK, WALKSPEED*SCALE, "");		// move to starting point	
		NewOrder("Guard");
	} ]

	
	Patrol[ ()
	{	
		// patroling from point to point, looking for special orders in each script point (i.e. "Guard")
		NextPoint(); 
		NextOrder();	
		RotateToPoint(IDLE, YAWSPEED, false, "");
		MoveToPoint(WALK, WALKSPEED*SCALE, "");			
		RestartOrder();
	} ]
	
	Guard[()
	{
		// just look around a bit
		Rotate(IDLE, YAWSPEED, 0, -160, 0, "");  
		Delay(IDLE, random(3,5), "");
		Rotate(IDLE, YAWSPEED, 0, 160, 0, "");
		Delay(IDLE, random(3,5), "");
		Align();
		NewOrder("Patrol"); // continue to patrol
	}]
	
	FoundTarget[ ()
	{
		// target discovered
		SetKeyPause(true); 		// disable keyboard
		RotateToPlayer(IDLE, YAWSPEED, false, "");
		LowLevel("camera");
		
	}]
	
	camera[()
	{		
		// place the camera behind the pawn so the player can see who found him
		SW = GetScreenWidth()/2;
            	SH = GetScreenHeight()/2;
            	AttachCamera(); 
		TiltCamera(ConvertDegrees(20));
		HighLevel("ViewTarget");
	}]

	ViewTarget[()
	{
		// just look at the player
		ShowTextDelay(0, "", IDLE, "<Player><CR>You were discovered", 12, 5, "", SW, SH, "center", 255); 
		LowLevel("forbidden");
	} ]

	forbidden[()
	{	
		// move player to TELEPORTTARGET
		DetachCamera(); // return camera to player
		TeleportEntity("Player", TELEPORTTARGET, 64, 0, 0, true);		
		// name of the 1st scriptpoint in the path is equal to the seven leftmost characters of the pawn's name
		POINTNAME=LeftCopy(self.EntityName, 7); 
		TeleportEntity(self.EntityName, POINTNAME, 0, 0, 0, true); // move the pawn to the 1st scriptpoint 
		NewPoint(POINTNAME);HighLevel("Continue");
	} ]
	
	Continue[()
	{
		SetKeyPause(false); // re-enable keys
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // re-activate target order
		NewOrder("Guard"); 
	}]
}
Now what I wanted to do here was the guard (instead of displaying the message) would chase after Nikki first long before Nikki is captured and respawn.

Now is there a way to modify that code for that purpose? Would be happy if someone would.
~~THIS IS TEH CRxTRDUDE~~
Cañalita Comics junkie...

Post Reply