go to nearest scriptpont in case can not reach the player

Topics regarding Scripting with Reality Factory
User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Re: go to nearest scriptpont in case can not reach the playe

Post by paradoxnj »

If you're in the US, you'll get Algebra in 9th, Geometry in 10th, Trigonometry in 11th and Pre-Calculus in 12th. You got some time. Try the ebook instead of the manual. The manual is more of a "what does this do", the ebook is more of a "how do I do this". It's in the documentation section. It holds your hand through the making of a full game using RF. Is that badguy1.act the same one from Jean Louis' site?
Many Bothans died to bring you this signature....
megatop
Posts: 184
Joined: Thu Jun 02, 2011 12:36 am

Re: go to nearest scriptpont in case can not reach the playe

Post by megatop »

i recently learned a little of Algebra
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: go to nearest scriptpont in case can not reach the playe

Post by Veleran »

Will i need to add UpdateEnemyVis(); before the move to script points so the pawn knows where player is,or not...
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: go to nearest scriptpont in case can not reach the playe

Post by Veleran »

I thought making a non rendered pawn attached to the player that checks which point is near him but i do not know how i can tell the pawns which is that point.
Then all alert pawns would try to go to that script point i guess,like there is an alarm set on.

I thought to use bool NearestPoint for checking which point to go to.

One of the scripts has this in the walk_movetogoal[ (dist) :
{
if(IsFalling = true)
{
return 0; // don't move while falling
}
if(dist < 0)
{
return 0;
}
if(back_up = false)
{
ai_face(); // turn to face enemy
if(FacingIdeal())
{
if(walkmove(self.current_yaw, dist) = true)
{
return 0; // can move in current direction
}
else
{
if(random(1,10)<3) // backup and move sideways
{
back_up = true;
back_time = time + 0.5;
back_flag = false;
return 0;
}
else
{
ForceUp(FORCEUP*SCALE); // jump up, forward and to side
ForceForward(FORCEFORWARD*SCALE);
if(random(1,10)<6)
{
ForceRight(FORCESIDE*SCALE);
}
else
{
ForceLeft(FORCESIDE*SCALE);
}
}
}
}
}
else
{
if(back_flag = false) // go backward 1/2 sec
{
if(back_time > time)
{
walkmove((self.current_yaw-(180*0.0174532925199433)), dist);
return 0;
}
else
{
back_time = time + 0.5;
back_flag = true;
}
}
if(back_time > time) // go sideways 1/2 sec
{
walkmove((self.current_yaw-(90*0.0174532925199433)), dist);
return 0;
}
back_up = false;
else
{
NearestPoint(float MinDistance, float MaxDistance);
NextPoint();
}
} ]

And,i do not know how many "}" tp add at the end of this section i thought to add in this order order.
Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: go to nearest scriptpont in case can not reach the playe

Post by Allanon »

First off when posting scripts please place them between the code tags to keep the script formatted and easier to read.

The script you posted it wrong, the following code won't work:

Code: Select all

else
{
    NearestPoint(float MinDistance, float MaxDistance); 
    NextPoint();
}
I think if you look at the robot.s script that comes with RF you will see the walk_movetogoal() code uses the NearestPoint() command and probably does what you want:

Code: Select all

	// use walkmove to naviagte to enemy

	walk_movetogoal[(dist)
	{		
		if(self.IsFalling = true)
		{
			return 0;			// don't move while falling
		} 
		if(back_up = false)
		{
			ai_face();			// turn to face enemy
			if(FacingIdeal())
			{
				yaw  = self.current_yaw;
				if(NearestPoint(10, 500))
				{	
					yaw = GetYawToPoint();
					self.ideal_yaw = yaw;
					ChangeYaw(); 
				}
				if(walkmove(yaw, dist) = true)
				{
					return 0;		// can move in current direction
				}
				else
				{
					if(random(1,10)<3)	// backup and move sideways
					{
						back_up = true;
						back_time = self.time + 0.5;
						back_flag = false;
						return 0;
					}
					else 
					{ 
						ForceUp(20);	// jump up, forward and to side
						ForceForward(10);
						if(random(1,10)<6)
						{
							ForceRight(10);
						}
						else
						{
							ForceLeft(10);
						} 
					} 
				} 
			}
		}
		else
		{
			if(back_flag = false) 		// go backward 1/2 sec
			{
				if(back_time > self.time)
				{
					walkmove((self.current_yaw-(3.14159)), dist);
					return 0;
				}
				else
				{
					back_time = self.time + 0.5;
					back_flag = true;
				}
			}
			if(back_time > self.time) 		// go sideways 1/2 sec
			{
				walkmove((self.current_yaw-(1.570796)), dist);
				return 0;
			}
			back_up = false;
		}
	} ]
Post Reply