Пример #1
0
        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);
        }
Пример #2
0
        private static Vector3 GetDelta(C_CSPlayer local, C_CSPlayer target, Bones bone)
        {
            var viewAngles = CEngineClient.Instance.GetViewAngles();

            var eyePos     = local.GetEyePos();
            var targetBone = utils.GetEntityBone(target, bone);
            var aimAngles  = utils.CalcAngle(eyePos, targetBone);
            var delta      = viewAngles - aimAngles;

            delta.Clamp();
            return(delta);
        }