Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Vector3 ForceGroundZ(this Vector3 v)
- {
- float zcoord = 0.0f;
- var outArgb = new OutputArgument();
- float[] firstCheck = new float[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
- float[] secondCheck = new float[] { 1000, 900, 800, 700, 600, 500,
- 400, 300, 200, 100, 0, -100, -200, -300, -400, -500 };
- float[] thirdCheck = new float[] { -500, -400, -300, -200, -100, 0,
- 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
- if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
- zcoord = outArgb.GetResult<float>();
- if (zcoord == 0)
- {
- for (int i = 0; i < firstCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, firstCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
- zcoord = outArgb.GetResult<float>();
- }
- if (zcoord == 0)
- {
- Log.Write(true, "ZCoord secondCheck");
- for (int i = 0; i < secondCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, secondCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
- zcoord = outArgb.GetResult<float>();
- }
- if (zcoord == 0)
- {
- Log.Write(true, "ZCoord thirdCheck");
- for (int i = 0; i < thirdCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, thirdCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, v.X, v.Y, 1000f, outArgb))
- zcoord = outArgb.GetResult<float>();
- }
- return new Vector3(v.X, v.Y, zcoord);
- }
- public static Vector3 ForceWaterZ(this Vector3 v)
- {
- float zcoord = -500.0f;
- var outArgb = new OutputArgument();
- float[] firstCheck = new float[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
- float[] secondCheck = new float[] { 1000, 900, 800, 700, 600, 500,
- 400, 300, 200, 100, 0, -100, -200, -300, -400, -500 };
- float[] thirdCheck = new float[] { -500, -400, -300, -200, -100, 0,
- 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
- if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
- zcoord = outArgb.GetResult<Vector3>().Z;
- if (zcoord == -500)
- {
- for (int i = 0; i < firstCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, firstCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
- zcoord = outArgb.GetResult<Vector3>().Z;
- }
- if (zcoord == -500)
- {
- Log.Write(true, "ZCoord secondCheck");
- for (int i = 0; i < secondCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, secondCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
- zcoord = outArgb.GetResult<Vector3>().Z;
- }
- if (zcoord == -500)
- {
- Log.Write(true, "ZCoord thirdCheck");
- for (int i = 0; i < thirdCheck.Length; i++)
- {
- Function.Call(Hash.REQUEST_COLLISION_AT_COORD, v.X, v.Y, thirdCheck[i]);
- GTA.Script.Wait(0);
- }
- if (Function.Call<bool>(Hash.TEST_PROBE_AGAINST_ALL_WATER, v.X, v.Y, 1000f, v.X, v.Y, -500f, 1, outArgb))
- zcoord = outArgb.GetResult<Vector3>().Z;
- }
- return new Vector3(v.X, v.Y, zcoord);
- }
- public static float ForceWaterDepth(this Vector3 v)
- {
- float result = 0.0f;
- var ground = v.ForceGroundZ().Z;
- var water = v.ForceWaterZ().Z;
- if (water > ground)
- result = water - ground;
- else if (ground == 0)
- result = -500f;
- return result;
- }
Add Comment
Please, Sign In to add comment