ZoriaRPG

Experimental Ghost_CanMoveAtAngle()

Jan 28th, 2020
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Experimental canmoe functions for 2.8.x
  2.  
  3. // The maths here depend on if the Ghost_Step is in full pixels per frame
  4. // or if it isPixels per frame * 100.//e.g., IDR if it is 100 for one pixel/frame using Ghost_Step, or 1.0
  5.  
  6. // Basic model for imprecision, assuming that step is an integer (e.g. 250 == 2.5 pixels per frame), as in the Enemy Editor
  7. // If step is a float as in the engine (type 'fix' there), then we need to remove the *0.01
  8. void Ghost_CanMoveAtAngle(float angle, float step, float imprecision, bool onlycheckdest)
  9. {
  10.     if(onlycheckdest)
  11.     {
  12.         if(Ghost_CanMovePixel(VectorX(q, angle), VectorY(q, angle), Ghost_Z>0))
  13.         {
  14.             //can_move_imprecise
  15.             return true;
  16.         }
  17.         if(Ghost_CanMovePixel(VectorX(q+imprecision, angle), VectorY(q+imprecision, angle), Ghost_Z>0))
  18.         {
  19.             return true;
  20.         }
  21.         return false;
  22.     }
  23.     else
  24.     {
  25.         //bool can_move_imprecise;
  26.         for ( int q = Max((step*0.01), 1); q > 0; --q )
  27.         {
  28.             if(Ghost_CanMovePixel(VectorX(q, angle), VectorY(q, angle), Ghost_Z>0))
  29.             {
  30.                 //can_move_imprecise
  31.                 return true;
  32.             }
  33.             if(Ghost_CanMovePixel(VectorX(q+imprecision, angle), VectorY(q+imprecision, angle), Ghost_Z>0))
  34.             {
  35.                 return true;
  36.             }
  37.         }
  38.         return false;
  39.     }
  40. }
RAW Paste Data