private static C_CSPlayer GetClosestPlayer(C_CSPlayer local) { var maxFov = fov.GetValue(); C_CSPlayer target = new C_CSPlayer(IntPtr.Zero); var viewAngles = CEngineClient.Instance.GetViewAngles(); var eyePos = local.GetEyePos(); for (int i = 1; i < CEngineClient.Instance.GetMaxClients(); i++) { var potentialTarget = new C_CSPlayer(i); if (!potentialTarget.IsValid() || potentialTarget.m_BaseAddress == local.m_BaseAddress) { continue; } if (!potentialTarget.IsPlayer() || !potentialTarget.IsAlive() || potentialTarget.IsDormant() || !potentialTarget.IsEnemy()) { continue; } var targetBone = utils.GetEntityBone(potentialTarget, Bones.HEAD_0); var targetFov = GetFov(viewAngles, utils.CalcAngle(eyePos, targetBone)); if (targetFov > maxFov) { continue; } maxFov = targetFov; target = potentialTarget; } return(target); }
private static void PaintTraverse_AfterPaintTraverse(IntPtr pPanel, uint vguiPanel) { if (!(menu.Children[0] as GUIManager.ToggleMenu).IsToggled()) { return; } for (int i = 1; i < CEngineClient.Instance.GetMaxClients(); i++) { if (i == CEngineClient.Instance.GetLocalPlayer()) { continue; } var pTarget = new C_CSPlayer(i); //TODO: cache this to Array if (!pTarget.IsPlayer()) { continue; } if (!pTarget.IsAlive() || pTarget.IsDormant() || !pTarget.IsEnemy()) { continue; } var vOrigin = pTarget.GetOrigin(); var vHead = Utils.Utils.GetEntityBone(pTarget, Bones.HEAD_0); vHead.Z += 14; Vector3 vScreenOrigin = new Vector3(), vScreenHead = new Vector3(); if (!Utils.Utils.WorldToScreen(vHead, ref vScreenHead) || !Utils.Utils.WorldToScreen(vOrigin, ref vScreenOrigin)) { continue; } var height = Math.Abs(vScreenHead.Y - vScreenOrigin.Y); var width = height * 0.65f; Drawing.DrawOutlineRect((int)vScreenHead.X - (int)width / 2, (int)vScreenHead.Y, (int)width, (int)height, new Color(255, 255, 255, 255)); Drawing.DrawText((int)vScreenOrigin.X, (int)vScreenOrigin.Y, pTarget.GetName(i), new Color(255, 255, 255), true); } }