private bool CheckBoneDistance(Player plr, LocalPlayer local, Config.TriggerbotWeaponConfig cfg) { var localPos = local.ViewPosition; var targetPos = plr.GetBonePosition(cfg.Bone); var angle = Math3.CalcAngle(localPos, targetPos); var fov = Math3.AngleBetweenVec2(CheatMain.clientState.ViewAngles, angle); var dist = Vector3.Distance(localPos, targetPos); if (cfg.DynamicFov) { fov = Math3.GetDistanceFov((float)fov, (float)dist) * 1.4f; } if (fov <= cfg.Fov) { return(true); } else { return(false); } }
public Player FindFovPlayer(LocalPlayer lPlayer, Player[] players, Vector2 view, out double fov, bool FFA = false, int bone = 8) { var lPos = lPlayer.ViewPosition; double bestFov = float.MaxValue; Player bestTarget = null; foreach (var p in players) { if (!FFA && p.Team == lPlayer.Team) { continue; } var pos = p.GetBonePosition(bone); var target = Math3.CalcAngle(lPos, pos); var angle = Math3.AngleBetweenVec2(view, target); if (angle < bestFov) { bestFov = angle; bestTarget = p; } } fov = bestFov; return(bestTarget); }