Ejemplo n.º 1
0
        public static double CalcFov(Structures.Vector2 src, Structures.Vector2 dist)
        {
            double i = Math.Sqrt(
                ((dist.x - src.x) * (dist.x - src.x)) +
                ((dist.y - src.y) * (dist.y - src.y))
                );

            return(i);
        }
Ejemplo n.º 2
0
        public static float VectorDistance(Structures.Vector2 src, Structures.Vector2 dist)
        {
            double distance = Math.Sqrt(
                (dist.x - src.x) * (dist.x - src.x) +
                (dist.y - src.y) * (dist.y - src.y)
                );

            distance = Math.Round(distance, 4);
            return((float)distance);
        }
Ejemplo n.º 3
0
 public static Structures.Vector2 NormalizeAngle(this Structures.Vector2 angle)
 {
     while (0f > angle.x || angle.x > 360f)
     {
         if (angle.x < 0f)
         {
             angle.x += 360.0f;
         }
         if (angle.x > 360f)
         {
             angle.x -= 360.0f;
         }
     }
     return(angle);
 }
Ejemplo n.º 4
0
        public Structures.Vector2 NewViewAngle()
        {
            var lPlayer           = Global.LocalPlayer;
            var currentViewAngles = lPlayer.ViewAngle;
            var aimPunch          = lPlayer.PunchAngle * 2f;

            var newViewAngles = new Structures.Vector2
            {
                x = ((currentViewAngles + _oldAimPunch).x - aimPunch.x),
                y = ((currentViewAngles + _oldAimPunch).y - aimPunch.y)
            };

            _oldAimPunch = aimPunch;
            return(newViewAngles);
        }
Ejemplo n.º 5
0
        public static Structures.Vector2 ClampAngle(this Structures.Vector2 angle)
        {
            while (angle.x > 180f)
            {
                angle.x -= 360f;
            }

            while (angle.x < -180f)
            {
                angle.x += 360f;
            }

            while (angle.y > 89f)
            {
                angle.y -= (angle.y - 89) * 2;
            }

            while (angle.y < -89f)
            {
                angle.y += (-89 - angle.y) * 2;
            }


            if (angle.x > 180f)
            {
                return(Global.LocalPlayer.ViewAngle);
            }

            if (angle.x < -180f)
            {
                return(Global.LocalPlayer.ViewAngle);    //This is to FORCE clamped angles
            }
            //even if i failed it somehow
            if (angle.y > 89f)
            {
                return(Global.LocalPlayer.ViewAngle);
            }

            if (angle.y < -89f)
            {
                return(Global.LocalPlayer.ViewAngle);
            }


            return(angle);
        }
Ejemplo n.º 6
0
        public void Reset()
        {
            var lPlayer    = Global.LocalPlayer;
            var punchAngle = lPlayer.PunchAngle;

            var oldAbsSum = Math.Abs(_oldAimPunch.x + _oldAimPunch.y);
            var newAbsSum = Math.Abs(punchAngle.x + punchAngle.y);

            if (oldAbsSum > 1.9f)
            {
                while (newAbsSum > 0.25)
                {
                    Thread.Sleep(5);

                    newAbsSum = Math.Abs(lPlayer.PunchAngle.x + lPlayer.PunchAngle.y);
                }

                var newViewAngle = NewViewAngle();
                var playerAngle  = lPlayer.ViewAngle;
                var diffX        = Math.Max(playerAngle.x, newViewAngle.x) - Math.Min(playerAngle.x, newViewAngle.x);
                var diffY        = Math.Max(playerAngle.y, newViewAngle.y) - Math.Min(playerAngle.y, newViewAngle.y);
                var diff         = new Structures.Vector2(diffX, diffY);

                for (int i = 0; i < 4; i++)
                {
                    lPlayer.SendPackets = false;
                    lPlayer.ViewAngle  -= diff / 4;
                    Thread.Sleep(6);
                    lPlayer.SendPackets = true;
                }
            }
            else
            {
                lPlayer.SendPackets = false;
                _oldAimPunch        = new Structures.Vector2();
                Thread.Sleep(10);
                lPlayer.SendPackets = true;
            }
        }
Ejemplo n.º 7
0
        public static Structures.Vector2 CalcAngle(Structures.Vector3 src, Structures.Vector3 dist)
        {
            Structures.Vector3 delta = new Structures.Vector3()
            {
                x = dist.x - src.x,
                y = dist.y - src.y,
                z = dist.z - src.z,
            };

            float magn = (float)Math.Sqrt(
                (delta.x * delta.x) +
                (delta.y * delta.y) +
                (delta.z * delta.z)
                );

            Structures.Vector2 returnAngle = new Structures.Vector2()
            {
                x = (float)(Math.Atan2(delta.y, delta.x) * (180f / 3.14f)),
                y = (float)(-Math.Atan2(delta.z, magn) * (180f / 3.14f)),
            };

            return(returnAngle);
        }
Ejemplo n.º 8
0
 public static Structures.Vector3 ToVector3(this Structures.Vector2 angle)
 {
     return(new Structures.Vector3(angle.y, angle.x, 0));
 }
Ejemplo n.º 9
0
 public void HardReset()
 {
     _oldAimPunch = new Structures.Vector2();
 }