Exemplo n.º 1
0
 public void SetTarget(Structures.FLOAT3 pos, bool smooth)
 {
     if (navLocked)
     {
         return;
     }
     Debug.WriteLine(pos);
     target       = pos;
     smoothAiming = smooth;
     followPlayer = false;
 }
Exemplo n.º 2
0
        public bool Move(ushort index, Structures.FLOAT3 pos)
        {
            if (!CheckParameterValid(index))
            {
                return(false);
            }

            Modified(this, new EventArgs());
            pool[index].Move(pos.X, pos.Y, pos.Z);
            return(true);
        }
Exemplo n.º 3
0
        private void AimAt(Structures.FLOAT3 pos)
        {
            Structures.FLOAT3 localPos = gameState.LocalPosition;
            float             dx       = pos.X - localPos.X;
            float             dy       = pos.Y - localPos.Y;
            float             dz       = pos.Z - localPos.Z;

            float dist = Navigation.Distance3D(pos, localPos);

            float aH = (float)Math.Atan2(dy, dx);
            float aV = (float)Math.Atan2(dz, Math.Sqrt(dx * dx + dy * dy));

            AimAt(aH, aV, dist);
        }
Exemplo n.º 4
0
 public static FLOAT2 ToFLOAT2(Structures.FLOAT3 p, int proj)
 {
     if (proj == 0)
     {
         return(new FLOAT2(p.Y, p.Z));
     }
     else if (proj == 1)
     {
         return(new FLOAT2(p.X, p.Z));
     }
     else
     {
         return(new FLOAT2(p.X, p.Y));
     }
 }
Exemplo n.º 5
0
        public float TargetClosenessToView(Structures.FLOAT3 pos)
        {
            float oldH = gameState.PlayerHorizontalViewAngle;
            float oldV = gameState.PlayerVerticalViewAngle;

            Structures.FLOAT3 localPos = gameState.LocalPosition;
            float             dx       = pos.X - localPos.X;
            float             dy       = pos.Y - localPos.Y;
            float             dz       = pos.Z - localPos.Z;

            float aH = (float)Math.Atan2(dy, dx);
            float aV = (float)Math.Atan2(dz, Math.Sqrt(dx * dx + dy * dy));

            return(TargetClosenessToView(ref oldH, oldV, ref aH, aV));
        }
Exemplo n.º 6
0
 //equivalent to the function below with second argument 0
 public ushort Add(Structures.FLOAT3 pos)
 {
     for (ushort i = 1; i < pool.Length; i++)
     {
         if (pool[i] == null)
         {
             Modified(this, new EventArgs());
             pool[i] = new Waypoint(pos);
             if (i > LastIndex)
             {
                 LastIndex = i;
             }
             return(i);
         }
     }
     return(0);
 }
Exemplo n.º 7
0
        void aimTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (navLocked || lookAheadLocked)
            {
                AimAt(navTarget);
                return;
            }

            if (!aiming)
            {
                return;
            }

            if (followPlayer)
            {
                target = LeadPlayer(targetPlayerIndex, arcMode);
            }

            if (arcMode)
            {
                Structures.FLOAT3 localPos = gameState.LocalPosition;
                float             dx       = target.X - localPos.X;
                float             dy       = target.Y - localPos.Y;
                float             dz       = target.Z - localPos.Z;

                float newH = (float)Math.Atan2(dy, dx);
                float newV = CalculateBallisticAngle(dx, dy, dz, ProjectileVelocity);

                if (!float.IsNaN(newV) && !float.IsNaN(newH))
                {
                    AimAt(newH, newV, 0.0F);
                }
            }
            else
            {
                AimAt(target);
                times++;
                if (times >= TICKS_FOR_NEW_RANDOM)
                {
                    randVal = (float)rand.NextDouble() - 0.5F;
                    times   = 0;
                }
            }
        }
Exemplo n.º 8
0
        public ushort GetClosestWaypoint(Structures.FLOAT3 pos)
        {
            float  shortestDistance     = float.PositiveInfinity;
            ushort closestWaypointIndex = 0;

            for (ushort i = 1; i <= graph.LastIndex; i++)
            {
                if (graph.pool[i] != null)
                {
                    float tentativeDistance = Distance3D(graph.pool[i].pos.X, graph.pool[i].pos.Y, graph.pool[i].pos.Z,
                                                         pos.X, pos.Y, pos.Z);
                    if (tentativeDistance < shortestDistance)
                    {
                        shortestDistance     = tentativeDistance;
                        closestWaypointIndex = i;
                    }
                }
            }
            return(closestWaypointIndex);
        }
Exemplo n.º 9
0
        public void WalkTo(Structures.FLOAT3 end, bool alternate)
        {
            ushort dst1 = GetClosestWaypoint(end);

            if (FindPath(dst1, alternate))
            {
                stopRequested = false;

                Stack <Waypoint> temp  = new Stack <Waypoint>();
                Waypoint[]       temp2 = CurrentPath.ToArray();
                temp.Push(new Waypoint(end));
                for (int i = temp2.Length - 1; i >= 0; i--)
                {
                    temp.Push(temp2[i]);
                }
                CurrentPath = temp;
            }
            else
            {
                stopRequested = true;
            }
        }
Exemplo n.º 10
0
        public Structures.FLOAT3 LeadPlayer(int playerIndex, bool arcShot)
        {
            Structures.FLOAT3 pos = gameState.PlayerPosition(playerIndex);
            Structures.FLOAT3 vel = gameState.PlayerVelocity(playerIndex);
            Structures.FLOAT3 me  = gameState.LocalPosition;
            int   ping            = gameState.LocalPing;
            float dist            = Navigation.Distance2D(pos.X - me.X, pos.Y - me.Y);
            float travelTime      = (ProjectileVelocity == 0) ? 0 : (float)(540 * (dist / ProjectileVelocity));

            //aim at their feet if arcshot enabled and also ignore vertical velocity (likely jumping)
            if (arcShot)
            {
                vel.Z  = 0;
                pos.Z -= PLAYER_HEIGHT;
            }

            //account for ping
            pos.X += vel.X * (ping + travelTime) * LEAD_SCALE;
            pos.Y += vel.Y * (ping + travelTime) * LEAD_SCALE;
            pos.Z += vel.Z * (ping + travelTime) * LEAD_SCALE;

            return(pos);
        }
Exemplo n.º 11
0
        //adds a node and automatically links it to the last placed node
        public ushort Add(Structures.FLOAT3 pos, ushort lastNodeAdded)
        {
            for (ushort i = 1; i < pool.Length; i++)
            {
                if (pool[i] == null)
                {
                    Modified(this, new EventArgs());
                    pool[i] = new Waypoint(pos);
                    if (i > LastIndex)
                    {
                        LastIndex = i;
                    }

                    if (lastNodeAdded >= 1)
                    {
                        Link(lastNodeAdded, i, 1);
                        Link(i, lastNodeAdded, 1);
                    }
                    return(i);
                }
            }

            return(0);
        }
Exemplo n.º 12
0
 public static float Distance3D(Structures.FLOAT3 p0, Structures.FLOAT3 p1)
 {
     return(Distance3D(p0.X, p0.Y, p0.Z, p1.X, p1.Y, p1.Z));
 }
Exemplo n.º 13
0
        private void WalkPath()
        {
            while (true)
            {
                Thread.Sleep(150);


stop_walking:
                Walking = false;
                aimbot.NavUnlock();

                if (!stopRequested)
                {
                    Walking = true;
                    Waypoint cameFrom = graph.pool[0];

                    //continue while there are more nodes to go to
                    while (CurrentPath.Count != 0)
                    {
                        Waypoint nextGoal = CurrentPath.Peek();
                        if (nextGoal == null)
                        {
                            break;
                        }

                        byte nextType = graph.pool[nextGoal.Parent].GetLinkType(nextGoal, graph.pool);
                        Structures.FLOAT3 currentPosition = gameState.LocalPosition;
                        Structures.FLOAT3 nextPosition    = nextGoal.pos;

                        float xOffset = nextPosition.X - currentPosition.X;
                        float yOffset = nextPosition.Y - currentPosition.Y;
                        float zOffset = nextPosition.Z - currentPosition.Z;
                        float distToGoal;
                        float initialDist = Distance3D(nextPosition.X, nextPosition.Y, nextPosition.Z,
                                                       currentPosition.X, currentPosition.Y, currentPosition.Z);
                        double initialRatio   = xOffset / yOffset;
                        float  playerVelocity = 0;

                        aimbot.NavUnlock();

                        if (nextType == 5 || nextType == 3)
                        {
                            aimbot.NavLock(nextPosition);
                        }

                        //while not at nextGoal
                        while ((distToGoal = Distance3D(nextPosition.X, nextPosition.Y, nextPosition.Z,
                                                        currentPosition.X, currentPosition.Y, currentPosition.Z)) > NodeRadius)
                        {
                            if (stopRequested)
                            {
                                CurrentPath.Clear();
                                goto stop_walking;
                            }

                            //if the path gets changed by another thread, get out
                            if (!CurrentPath.Contains(nextGoal))
                            {
                                break;
                            }

                            double angleDifference = Math.Atan2(yOffset, xOffset) - gameState.PlayerHorizontalViewAngle;
                            if (angleDifference < -Math.PI)
                            {
                                angleDifference += 2 * Math.PI;
                            }
                            else if (angleDifference > Math.PI)
                            {
                                angleDifference -= 2 * Math.PI;
                            }
                            double myRatio      = xOffset / yOffset;
                            ushort dominantKey  = (ushort)DIK.DIK_W;
                            ushort secondaryKey = (ushort)DIK.DIK_W;
                            ushort modifierKey  = 0;
                            bool   over         = false;

                            #region calculate_keys

                            if (nextType == 3 || (playerVelocity < 0.1F && Math.Abs(initialDist - distToGoal) > 0.5F &&
                                                  nextType != 4))
                            {
                                modifierKey = (ushort)DIK.DIK_SPACE;
                            }
                            else if (nextType == 4)
                            {
                                modifierKey = (ushort)DIK.DIK_LCONTROL;
                            }

                            if (angleDifference > 0)
                            {
                                if (angleDifference < Math.PI / 4)
                                {
                                    dominantKey  = (ushort)DIK.DIK_W;
                                    secondaryKey = (ushort)DIK.DIK_A;
                                }
                                else if (angleDifference < Math.PI / 2)
                                {
                                    dominantKey  = (ushort)DIK.DIK_A;
                                    secondaryKey = (ushort)DIK.DIK_W;
                                    over         = true;
                                }
                                else if (angleDifference < (3 * Math.PI) / 4)
                                {
                                    dominantKey  = (ushort)DIK.DIK_A;
                                    secondaryKey = (ushort)DIK.DIK_S;
                                }
                                else if (angleDifference < Math.PI)
                                {
                                    dominantKey  = (ushort)DIK.DIK_S;
                                    secondaryKey = (ushort)DIK.DIK_A;
                                    over         = true;
                                }
                            }
                            else if (angleDifference < 0)
                            {
                                if (angleDifference > -Math.PI / 4)
                                {
                                    dominantKey  = (ushort)DIK.DIK_W;
                                    secondaryKey = (ushort)DIK.DIK_D;
                                    over         = true;
                                }
                                else if (angleDifference > -Math.PI / 2)
                                {
                                    dominantKey  = (ushort)DIK.DIK_D;
                                    secondaryKey = (ushort)DIK.DIK_W;
                                }
                                else if (angleDifference > -(3 * Math.PI) / 4)
                                {
                                    dominantKey  = (ushort)DIK.DIK_D;
                                    secondaryKey = (ushort)DIK.DIK_S;
                                    over         = true;
                                }
                                else if (angleDifference > -Math.PI)
                                {
                                    dominantKey  = (ushort)DIK.DIK_S;
                                    secondaryKey = (ushort)DIK.DIK_D;
                                }
                            }
                            #endregion

                            if (AimAhead)
                            {
                                aimbot.LookAheadLock(nextPosition);
                            }
                            else
                            {
                                aimbot.LookAheadUnlock();
                            }

                            if (nextType == 5 || nextType == 3 || AimAhead)
                            {
                                secondaryKey = (ushort)DIK.DIK_W;
                            }

                            #region SendInput
                            if (modifierKey != 0 && distToGoal > 1)
                            {
                                Press(modifierKey, -1, true);
                            }
                            Press(dominantKey, -1, true);

                            if ((myRatio > initialRatio && over) || (myRatio < initialRatio && !over))
                            {
                                Press(secondaryKey, 100, true);
                            }
                            else
                            {
                                Thread.Sleep(100);
                            }

                            Press(dominantKey, 0, true);
                            Press(modifierKey, 0, true);
                            #endregion SendInput

                            currentPosition = gameState.LocalPosition;

                            //can modify positions if we don't want it to follow the path exactly
                            if (StrafeMode && nextType != 5 && nextType != 3)
                            {
                                Structures.FLOAT3 randomOffset = new Structures.FLOAT3((float)aimbot.rand.NextDouble() - 0.5F,
                                                                                       (float)aimbot.rand.NextDouble() - 0.5F,
                                                                                       (float)aimbot.rand.NextDouble() - 0.5F);
                                currentPosition += (randomOffset * STRAFE_SCALE);
                            }

                            playerVelocity = Distance3D(xOffset, yOffset, zOffset,
                                                        xOffset = nextPosition.X - currentPosition.X,
                                                        yOffset = nextPosition.Y - currentPosition.Y,
                                                        zOffset = nextPosition.Z - currentPosition.Z);
                        } //end while not at next goal

                        //path might get cleared by another thread and we didnt catch it earlier
                        if (CurrentPath.Count != 0)
                        {
                            CurrentPath.Pop();
                        }
                        cameFrom = graph.pool[0];
                    }

                    stopRequested = true;
                } //end if (Walking)
            }     //end while (true)
        }
Exemplo n.º 14
0
 public void LookAheadLock(Structures.FLOAT3 pos)
 {
     navTarget       = pos;
     lookAheadLocked = true;
 }
Exemplo n.º 15
0
 public void NavLock(Structures.FLOAT3 pos)
 {
     navTarget = pos;
     navLocked = true;
 }
Exemplo n.º 16
0
 public Waypoint(Structures.FLOAT3 pos)
 {
     this.pos            = pos;
     NumberOfConnections = 0;
 }
Exemplo n.º 17
0
        //-------------------------------------------------------------
        // DATA SOURCES GIVEN VALUES HERE
        //-------------------------------------------------------------
        public double RequestData(int dataSource)
        {
            if (sourceTouches[dataSource] != random)
            {
                switch (dataSource)
                {
                //sources: value1-5 dont need cases, works anyway

                //LOCAL COORDINATES AND ANGLES
                case (int)DATA_SOURCES.PLAYER_X:
                    Structures.FLOAT3 pos = gameState.LocalPosition;
                    dataSources[(int)DATA_SOURCES.PLAYER_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.PLAYER_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.PLAYER_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_Y] = random;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_Z] = random;
                    break;

                case (int)DATA_SOURCES.PLAYER_Y:
                    pos = gameState.LocalPosition;
                    dataSources[(int)DATA_SOURCES.PLAYER_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.PLAYER_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.PLAYER_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_X] = random;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_Z] = random;
                    break;

                case (int)DATA_SOURCES.PLAYER_Z:
                    pos = gameState.LocalPosition;
                    dataSources[(int)DATA_SOURCES.PLAYER_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.PLAYER_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.PLAYER_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_X] = random;
                    sourceTouches[(int)DATA_SOURCES.PLAYER_Y] = random;
                    break;

                case (int)DATA_SOURCES.VIEW_ANGLE_H:
                    dataSources[(int)DATA_SOURCES.VIEW_ANGLE_H] = (double)gameState.PlayerHorizontalViewAngle;
                    break;

                case (int)DATA_SOURCES.VIEW_ANGLE_V:
                    dataSources[(int)DATA_SOURCES.VIEW_ANGLE_V] = (double)gameState.PlayerVerticalViewAngle;
                    break;

                case (int)DATA_SOURCES.CAMERA_X:
                    pos = gameState.CameraPosition;
                    dataSources[(int)DATA_SOURCES.CAMERA_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.CAMERA_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.CAMERA_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_Y] = random;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_Z] = random;
                    break;

                case (int)DATA_SOURCES.CAMERA_Y:
                    pos = gameState.CameraPosition;
                    dataSources[(int)DATA_SOURCES.CAMERA_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.CAMERA_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.CAMERA_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_X] = random;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_Z] = random;
                    break;

                case (int)DATA_SOURCES.CAMERA_Z:
                    pos = gameState.CameraPosition;
                    dataSources[(int)DATA_SOURCES.CAMERA_X]   = pos.X;
                    dataSources[(int)DATA_SOURCES.CAMERA_Y]   = pos.Y;
                    dataSources[(int)DATA_SOURCES.CAMERA_Z]   = pos.Z;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_X] = random;
                    sourceTouches[(int)DATA_SOURCES.CAMERA_Y] = random;
                    break;


                //MISC
                case (int)DATA_SOURCES.CAN_WALK:
                    bool cw = gameState.CanWalk;
                    dataSources[(int)DATA_SOURCES.CAN_WALK] = cw ? 1 : 0;
                    break;

                case (int)DATA_SOURCES.CLEAR_SHOT:
                    dataSources[dataSource] = gameState.HasClearShot ? 1.0 : 0.0;
                    break;

                case (int)DATA_SOURCES.CLEAR_SHOT_ADVANCED:
                    dataSources[dataSource] = gameState.BSPIntersectionCheck(
                        gameState.LocalPosition, gameState.PlayerPosition(form1.nav.aimbot.GetTargetIndex()))
                            ? 0.0 : 1.0;
                    break;

                case (int)DATA_SOURCES.SHIFT_KEY:
                    dataSources[dataSource] = Form1.GetKeyState(Form1.VirtualKeyStates.VK_SHIFT) < 0 ?
                                              1.0 : 0.0;
                    break;

                case (int)DATA_SOURCES.PLAYER_COUNT:
                    dataSources[dataSource] = (double)gameState.PlayerCount;
                    break;

                case (int)DATA_SOURCES.RANDOM:
                    dataSources[dataSource] = r.NextDouble();
                    break;

                //LOCAL INFO
                case (int)DATA_SOURCES.LOCAL_HEALTH:
                    dataSources[dataSource] = (double)gameState.LocalHealth;
                    break;

                case (int)DATA_SOURCES.TARGET_HEALTH:
                    dataSources[dataSource] =
                        (double)gameState.PlayerHealth(form1.nav.aimbot.GetTargetIndex());
                    break;

                case (int)DATA_SOURCES.TARGET_DIST:
                    dataSources[dataSource] =
                        (double)Navigation.Distance3D(form1.nav.aimbot.GetTargetPos(), gameState.LocalPosition);
                    break;

                case (int)DATA_SOURCES.TARGET_SHIELD:
                    dataSources[dataSource] =
                        (double)gameState.PlayerShield(form1.nav.aimbot.GetTargetIndex());
                    break;

                case (int)DATA_SOURCES.LOCAL_SHIELD:
                    dataSources[dataSource] = (double)gameState.LocalShield;
                    break;

                case (int)DATA_SOURCES.LOCAL_TEAM:
                    dataSources[dataSource] = (double)gameState.LocalTeam;
                    break;

                case (int)DATA_SOURCES.LOCAL_PING:
                    dataSources[dataSource] = (double)gameState.LocalPing;
                    break;

                case (int)DATA_SOURCES.ZOOM_LEVEL:
                    dataSources[dataSource] = (double)gameState.ZoomLevel;
                    break;

                case (int)DATA_SOURCES.FLASHLIGHT:
                    dataSources[dataSource] = gameState.FlashlightOn ? 1.0 : 0.0;
                    break;

                //WEAPONS
                case (int)DATA_SOURCES.PRIMARY_WEAPON:
                    dataSources[dataSource] = gameState.PrimaryWeapon ? 1.0 : 0.0;
                    break;

                case (int)DATA_SOURCES.WEAPON0_TYPE:
                    dataSources[dataSource] = gameState.GetWeaponType(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, true)));
                    break;

                case (int)DATA_SOURCES.WEAPON1_TYPE:
                    dataSources[dataSource] = gameState.GetWeaponType(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, false)));
                    break;

                case (int)DATA_SOURCES.WEAPON0_CLIP:
                    dataSources[dataSource] = gameState.GetWeaponClip(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, true)));
                    break;

                case (int)DATA_SOURCES.WEAPON1_CLIP:
                    dataSources[dataSource] = gameState.GetWeaponClip(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, false)));
                    break;

                case (int)DATA_SOURCES.WEAPON0_RESERVE:
                    dataSources[dataSource] = gameState.GetWeaponReserve(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, true)));
                    break;

                case (int)DATA_SOURCES.WEAPON1_RESERVE:
                    dataSources[dataSource] = gameState.GetWeaponReserve(
                        gameState.GetObjectOffset(
                            gameState.GetWeaponIndex(gameState.LocalIndex, false)));
                    break;

                case (int)DATA_SOURCES.GRENADE_TYPE:
                    dataSources[dataSource] = (double)gameState.LocalGrenadeType;
                    break;

                case (int)DATA_SOURCES.PLASMA_GRENADE_COUNT:
                    dataSources[dataSource] = (double)gameState.LocalPlasmaGrenadeCount;
                    break;

                case (int)DATA_SOURCES.FRAG_GRENADE_COUNT:
                    dataSources[dataSource] = (double)gameState.LocalFragGrenadeCount;
                    break;

                //TARGET INFO
                case (int)DATA_SOURCES.TARGET_CAMO:
                    dataSources[dataSource] = gameState.PlayerHasCamo(form1.nav.aimbot.GetTargetIndex()) ? 1.0 : 0.0;
                    break;

                case (int)DATA_SOURCES.LOCAL_CAMO:
                    dataSources[dataSource] = gameState.LocalCamo ? 1.0 : 0.0;
                    break;

                case (int)DATA_SOURCES.TARGET_STANCE:
                    dataSources[dataSource] = (double)gameState.PlayerStance(form1.nav.aimbot.GetTargetIndex());
                    break;

                case (int)DATA_SOURCES.LOCAL_STANCE:
                    dataSources[dataSource] = (double)gameState.LocalStance;
                    break;

                //GETTING TARGETS
                case (int)DATA_SOURCES.CLOSEST_ENEMY:
                case (int)DATA_SOURCES.CLOSEST_ALLY:
                case (int)DATA_SOURCES.CLOSEST_ANYONE:
                //call FID CLOSEST_ENEMY/ALLY/ANYONE before CLOSEST_DIST to set DIST's mode
                case (int)DATA_SOURCES.CLOSEST_DIST:
                    #region CLOSEST_PLAYER
                    pos = gameState.LocalPosition;
                    int localTeam = gameState.LocalTeam;

                    int   maxSlots     = gameState.MaxSlots;
                    int   closestIndex = -1;
                    float closestDist  = float.MaxValue;

                    //for every player
                    for (int i = 0; i < maxSlots; i++)
                    {
                        int    staticPlayerPointer = gameState.GetStaticPlayerPointer(i);
                        ushort objectID            = gameState.GetPlayerObjectID(staticPlayerPointer);
                        ushort objectIndex         = gameState.GetPlayerObjectIndex(staticPlayerPointer);
                        short  playerId2           = gameState.GetPlayerId2(staticPlayerPointer);

                        if (objectID == 65535 || objectID == 0 || objectIndex == gameState.LocalObjectIndex ||
                            objectID != gameState.GetObjectID(objectIndex))    // || playerId2 == -1)
                        {
                            continue;
                        }

                        if (dataSource == (int)DATA_SOURCES.CLOSEST_ENEMY ||
                            dataSource == (int)DATA_SOURCES.CLOSEST_DIST)
                        {
                            if (gameState.GetPlayerTeam(staticPlayerPointer) == localTeam)
                            {
                                continue;
                            }
                        }
                        else if (dataSource == (int)DATA_SOURCES.CLOSEST_ALLY)
                        {
                            if (gameState.GetPlayerTeam(staticPlayerPointer) != localTeam)
                            {
                                continue;
                            }
                        }

                        float dist = Navigation.Distance3D(gameState.PlayerPosition(i), pos);
                        if (dist < closestDist)
                        {
                            closestDist  = dist;
                            closestIndex = i;
                        }
                    }

                    dataSources[dataSource] = (double)closestIndex;
                    dataSources[(int)DATA_SOURCES.CLOSEST_DIST] = (double)closestDist;

                    if (dataSource == (int)DATA_SOURCES.CLOSEST_DIST)
                    {
                        sourceTouches[(int)DATA_SOURCES.CLOSEST_ENEMY] = random;
                    }
                    else
                    {
                        sourceTouches[(int)DATA_SOURCES.CLOSEST_DIST] = random;
                    }

                    break;
                    #endregion

                case (int)DATA_SOURCES.ENEMY_NEAREST_VIEW:
                case (int)DATA_SOURCES.ALLY_NEAREST_VIEW:
                case (int)DATA_SOURCES.ANYONE_NEAREST_VIEW:
                    #region PLAYER_NEAREST_VIEW
                    pos       = gameState.LocalPosition;
                    localTeam = gameState.LocalTeam;

                    maxSlots     = gameState.MaxSlots;
                    closestIndex = -1;
                    float closestAngle = float.MaxValue;

                    //for every player
                    for (int i = 0; i < maxSlots; i++)
                    {
                        int    staticPlayerPointer = gameState.GetStaticPlayerPointer(i);
                        ushort objectID            = gameState.GetPlayerObjectID(staticPlayerPointer);
                        ushort objectIndex         = gameState.GetPlayerObjectIndex(staticPlayerPointer);

                        if (objectID == 65535 || objectID == 0 || objectIndex == gameState.LocalObjectIndex ||
                            objectID != gameState.GetObjectID(objectIndex))
                        {
                            continue;
                        }

                        if (dataSource == (int)DATA_SOURCES.ENEMY_NEAREST_VIEW)
                        {
                            if (gameState.GetPlayerTeam(staticPlayerPointer) == localTeam)
                            {
                                continue;
                            }
                        }
                        else if (dataSource == (int)DATA_SOURCES.ALLY_NEAREST_VIEW)
                        {
                            if (gameState.GetPlayerTeam(staticPlayerPointer) != localTeam)
                            {
                                continue;
                            }
                        }

                        //calculate angle from view center to player i
                        float closeness = form1.nav.aimbot.TargetClosenessToView(gameState.PlayerPosition(i));

                        //compare angle to previously closest
                        if (closeness < closestAngle)
                        {
                            closestAngle = closeness;
                            closestIndex = i;
                        }
                    }     //for every player

                    dataSources[dataSource] = (double)closestIndex;
                    break;

                    #endregion
                case (int)DATA_SOURCES.RANDOM_NODE:
                    //if no nodes, do nothing
                    if (form1.graph.pool[0] == null)
                    {
                        break;
                    }

                    //otherwise, find a node that exists (may have holes in the array)
                    int node;
                    do
                    {
                        node = r.Next(1, form1.graph.LastIndex + 1);
                    }while (form1.graph.pool[node] == null);
                    dataSources[dataSource] = node;
                    break;
                } //end switch

                sourceTouches[dataSource] = random;
            } //if requested data source hasn't been calculated this tick

            return(dataSources[dataSource]);
        }