LostProphet

Untitled

Jul 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static Vector3 ForceGroundZ(this Vector3 v)
  2.     {
  3.         float zcoord = 0.0f;
  4.         var outArgb = new OutputArgument();
  5.  
  6.  
  7.         float[] firstCheck = new float[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
  8.  
  9.         float[] secondCheck = new float[] { 1000, 900, 800, 700, 600, 500,
  10.             400, 300, 200, 100, 0, -100, -200, -300, -400, -500 };
  11.  
  12.         float[] thirdCheck = new float[] { -500, -400, -300, -200, -100, 0,
  13.             100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
  14.  
  15.         if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
  16.             zcoord = outArgb.GetResult<float>();
  17.  
  18.         if (zcoord == 0)
  19.         {
  20.             for (int i = 0; i < firstCheck.Length; i++)
  21.             {
  22.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, firstCheck[i]);
  23.                 GTA.Script.Wait(0);
  24.             }
  25.  
  26.             if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
  27.                 zcoord = outArgb.GetResult<float>();
  28.         }
  29.  
  30.         if (zcoord == 0)
  31.         {
  32.             Log.Write(true, "ZCoord secondCheck");
  33.  
  34.             for (int i = 0; i < secondCheck.Length; i++)
  35.             {
  36.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, secondCheck[i]);
  37.                 GTA.Script.Wait(0);
  38.             }
  39.  
  40.             if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
  41.                 zcoord = outArgb.GetResult<float>();
  42.         }
  43.  
  44.         if (zcoord == 0)
  45.         {
  46.             Log.Write(true, "ZCoord thirdCheck");
  47.  
  48.             for (int i = 0; i < thirdCheck.Length; i++)
  49.             {
  50.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, thirdCheck[i]);
  51.                 GTA.Script.Wait(0);
  52.             }
  53.  
  54.             if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
  55.                 zcoord = outArgb.GetResult<float>();
  56.         }
  57.  
  58.         return new Vector3(v.X, v.Y, zcoord);
  59.     }
  60.  
  61.  
  62.     public static Vector3 ForceWaterZ(this Vector3 v)
  63.     {
  64.         float zcoord = -500.0f;
  65.         var outArgb = new OutputArgument();
  66.  
  67.  
  68.         float[] firstCheck = new float[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
  69.  
  70.         float[] secondCheck = new float[] { 1000, 900, 800, 700, 600, 500,
  71.             400, 300, 200, 100, 0, -100, -200, -300, -400, -500 };
  72.  
  73.         float[] thirdCheck = new float[] { -500, -400, -300, -200, -100, 0,
  74.             100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
  75.  
  76.         if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
  77.             zcoord = outArgb.GetResult<Vector3>().Z;
  78.  
  79.         if (zcoord == -500)
  80.         {
  81.             for (int i = 0; i < firstCheck.Length; i++)
  82.             {
  83.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, firstCheck[i]);
  84.                 GTA.Script.Wait(0);
  85.             }
  86.  
  87.             if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
  88.                 zcoord = outArgb.GetResult<Vector3>().Z;
  89.         }
  90.  
  91.         if (zcoord == -500)
  92.         {
  93.             Log.Write(true, "ZCoord secondCheck");
  94.  
  95.             for (int i = 0; i < secondCheck.Length; i++)
  96.             {
  97.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, secondCheck[i]);
  98.                 GTA.Script.Wait(0);
  99.             }
  100.  
  101.             if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
  102.                 zcoord = outArgb.GetResult<Vector3>().Z;
  103.            
  104.         }
  105.  
  106.         if (zcoord == -500)
  107.         {
  108.             Log.Write(true, "ZCoord thirdCheck");
  109.  
  110.             for (int i = 0; i < thirdCheck.Length; i++)
  111.             {
  112.                 Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, thirdCheck[i]);
  113.                 GTA.Script.Wait(0);
  114.             }
  115.  
  116.             if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
  117.                 zcoord = outArgb.GetResult<Vector3>().Z;
  118.         }
  119.  
  120.         return new Vector3(v.X, v.Y, zcoord);
  121.     }
  122.  
  123.  
  124.     public static float ForceWaterDepth(this Vector3 v)
  125.     {
  126.         float result = 0.0f;
  127.         var ground = v.ForceGroundZ().Z;
  128.         var water = v.ForceWaterZ().Z;
  129.  
  130.         if (water > ground)
  131.             result = water - ground;
  132.  
  133.         else if (ground == 0)
  134.             result = -500f;
  135.  
  136.         return result;
  137.     }
Add Comment
Please, Sign In to add comment