public static Vector3 GetOrthogonalVector(Vector3 vCenter, Vector3 vPoint) { Vector3 ortho = vCenter - vPoint; double magnitude = VectorUtilities.GetDistance(vCenter, vPoint); #if DEBUG DebugUtilities.Log("Original ortho vector: " + ortho); #endif return(ortho / (float)magnitude); }
public static bool GetRaycast(GameObject Target, Vector3 StartPos, out Vector3 Point) { Point = Vector3.zero; if (Target == null) { return(false); } int BackupLayer = Target.layer; Target.layer = LayerMasks.AGENT; RaycastComponent Component = Target.GetComponent <RaycastComponent>(); if (VectorUtilities.GetDistance(Target.transform.position, StartPos) <= 15.5f) { Point = OptimizationVariables.MainPlayer.transform.position; return(true); } Vector3[] verts = Component.Sphere.GetComponent <MeshCollider>().sharedMesh.vertices; Vector3[] nVerts = verts .Select(v => Component.Sphere.transform.TransformPoint(v)) .ToArray(); for (int i = 0; i < nVerts.Length; i++) { Vector3 Vertex = nVerts[i]; Vector3 Normal = VectorUtilities.Normalize(Vertex - StartPos); double Distance = VectorUtilities.GetDistance(StartPos, Vertex); if (Physics.Raycast(StartPos, Normal, (float)Distance + 0.5f, RayMasks.DAMAGE_CLIENT)) { continue; } Target.layer = BackupLayer; Point = Vertex; return(true); } Target.layer = BackupLayer; return(false); }
public static LocationNode GetClosestLocation(Vector3 pos) { double Distance = 1337420; LocationNode closestNode = null; LocationNode[] LNodes = LevelNodes.nodes.Where(n => n.type == ENodeType.LOCATION) .Select(n => (LocationNode)n).ToArray(); for (int i = 0; i < LNodes.Length; i++) { LocationNode node = LNodes[i]; double nDist = VectorUtilities.GetDistance(pos, node.point); if (nDist < Distance) { Distance = nDist; closestNode = node; } } return(closestNode); }
public static bool GetTargetObject(HashSet <GameObject> Objects, out GameObject Object, out Vector3 Point, float Range) { double Distance = Range + 1; double FOV = 180; Object = null; Point = Vector3.zero; Vector3 AimPos = OptimizationVariables.MainPlayer.look.aim.position; Vector3 AimForward = OptimizationVariables.MainPlayer.look.aim.forward; foreach (GameObject go in Objects) { if (go == null) { continue; } Vector3 TargetPos = go.transform.position; Player p = go.GetComponent <Player>(); if (p && (p.life.isDead || FriendUtilities.IsFriendly(p))) { continue; } Zombie z = go.GetComponent <Zombie>(); if (z && z.isDead) { continue; } RaycastComponent Component = go.GetComponent <RaycastComponent>(); if (Component == null) { go.AddComponent <RaycastComponent>(); continue; } double NewDistance = VectorUtilities.GetDistance(AimPos, TargetPos); if (NewDistance > Range) { continue; } if (RaycastOptions.SilentAimUseFOV) { double _FOV = VectorUtilities.GetAngleDelta(AimPos, AimForward, TargetPos); if (_FOV > RaycastOptions.SilentAimFOV) { continue; } if (_FOV > FOV) { continue; } FOV = _FOV; } else if (NewDistance > Distance) { continue; } if (!SphereUtilities.GetRaycast(go, AimPos, out Vector3 _Point)) { continue; } Object = go; Distance = NewDistance; Point = _Point; } return(Object != null); }