View Single Post
  #6  
Old 01-12-2004, 02:54 PM
Doodman's Avatar
Doodman
Developer
 
Join Date: Aug 2003
Posts: 246
Default Re: Fix for "jumpy" mobs and pets - Updated

One note:

Code:
...
...
      ratio = (speed/target_distance);

   	  if(target_distance >= speed)  // If we need to go father than we can in one cycle... 
      { 
         x_pos += tar_vx * ratio;
         y_pos += tar_vy * ratio;
		 if(tar_vz>2)
			z_pos += tar_vz * ratio;
		 else
			z_pos = z;
      } 
      else //If we are with-in our one cycle distance... 
      { 
         x_pos = x; 
         y_pos = y; 
         z_pos = z;  
      } 
...
...
Should be:
Code:
...
...
   	  if(target_distance >= speed)  // If we need to go father than we can in one cycle... 
      { 
         ratio = (speed/target_distance);

         x_pos += tar_vx * ratio;
         y_pos += tar_vy * ratio;
		 if(tar_vz>2)
			z_pos += tar_vz * ratio;
		 else
			z_pos = z;
      } 
      else //If we are with-in our one cycle distance... 
      { 
         x_pos = x; 
         y_pos = y; 
         z_pos = z;  
      } 
...
...
Since ratio is only used in there, no point in wasting cycles on the division.
Reply With Quote