Advertisement
ipsbruno2016

FCNPC_GoToFixZ

Mar 18th, 2016
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.33 KB | None | 0 0
  1. /*------------------
  2. -   FCNPC_GoToFixZ 0.1
  3. -   This Function fix Z ground of FCNPC in mostly cases
  4. -   By Bruno da Silva @ ipsBruno
  5. ------------------------------------*/
  6.  
  7.  
  8. #if defined _included_FCNPC_GoToFixZ
  9.     #endinput
  10. #endif
  11.  
  12. #define _included_FCNPC_GoToFixZ
  13.  
  14. stock FCNPC_GoToFixZ ( n, Float:x, Float:y, Float:z, type = MOVE_TYPE_AUTO, Float: speed, bool: mapAndreas = true, Float:radius = 0.0, bool:getangle = true, Float: pitch = 0.1) {
  15.  
  16.     mapAndreas = true;
  17.    
  18.     static
  19.         Float:a[3],
  20.         Float:b[3];
  21.  
  22.     FCNPC_GetPosition(n, a[0], a[1], a[2]);
  23.  
  24.     b[0] = x, b[1] = y, b[2] = z;
  25.  
  26.     static Float:c[3];
  27.     static Float:d[3];
  28.  
  29.     static Float:angle;
  30.  
  31.     angle = (atan2(a[0]-b[0], a[1]-b[1]))+180.0;
  32.  
  33.     if(angle > 360.0) angle -= 360.0;
  34.  
  35.     static Float: i;
  36.  
  37.     i = pitch;
  38.  
  39.     static Float: j;
  40.  
  41.     j = VectorSize(a[0]-b[0], a[1]-b[1], 0.0);
  42.  
  43.     while( i <= (j) ) {
  44.  
  45.         c[0]=a[0]+(i*floatsin(angle,degrees));
  46.         c[1]=a[1]+(i*floatcos(angle,degrees));
  47.  
  48.         d[0]=a[0]+((i-pitch)*floatsin(angle,degrees));
  49.         d[1]=a[1]+((i-pitch)*floatcos(angle,degrees));
  50.  
  51.         c[2] = a[2]+(i*( (a[2]-b[2]==0.0?0.0000001:a[2]-b[2])/j));
  52.         CA_FindZ_For2DCoord(d[0],d[1],d[2]);
  53.  
  54.         i += pitch;
  55.  
  56.         if (  d[2] - c[2] > 1.0 ) {
  57.             mapAndreas = false;
  58.             break;
  59.         }
  60.  
  61.     }
  62.  
  63.     return FCNPC_GoTo( n, x, y, z,  type, speed, mapAndreas, radius, getangle);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement