Esempio n. 1
0
        //With this we see which enemy is closest to OUR player, we return their index that way we aim directly

        private int FindClosestEnemyIndex(PlayerDataVec[] enemiesDataVec, PlayerDataVec myPosition)
        {
            float[] distances = new float[enemiesDataVec.Length];

            //store all our distances between us and the enemies to see which is closest
            for (int i = 0; i < enemiesDataVec.Length; i++)
            {
                //only store their distance if they are ALIVE
                if (enemiesDataVec[i].health > 0)
                {
                    distances[i] = Get3dDistance(enemiesDataVec[i], myPosition);
                }
                else
                {
                    // sets these as very high floats
                    distances[i] = float.MaxValue;
                }
            }
            //Make a copy of our array so we dont lose track of which position our closest enemy is
            float[] newDistances = new float[distances.Length];
            Array.Copy(distances, newDistances, distances.Length);

            //sorts our array from LOWEST TO HIGHEST
            Array.Sort(newDistances);

            //See which enemy was closest and return that Index for us to aim at them
            for (int i = 0; i < distances.Length; i++)
            {
                if (distances[i] == newDistances[0])
                {
                    return(i);
                }
            }
            return(-1);
        }
Esempio n. 2
0
 private float Get3dDistance(PlayerDataVec to, PlayerDataVec from)
 {
     return((float)
            (Math.Sqrt(
                 ((to.xPos - from.xPos) * (to.xPos - from.xPos)) +
                 ((to.yPos - from.yPos) * (to.yPos - from.yPos)) +
                 ((to.zPos - from.zPos) * (to.zPos - from.zPos))
                 )));
 }
Esempio n. 3
0
        private void AimAtTarget(PlayerDataVec enemyDataVector, PlayerDataVec playerDataVector)
        {
            float yaw = -(float)Math.Atan2(enemyDataVector.xPos - playerDataVector.xPos, enemyDataVector.yPos - playerDataVector.yPos)
                        / PI * 180 + 180;

            float pitch = (float)Math.Asin((enemyDataVector.zPos - playerDataVector.zPos) /
                                           Get3dDistance(enemyDataVector, playerDataVector))
                          * 180 / PI;

            //Set our  mouse values with our new YAW and PITCH
            Mem.WriteFloat(MainPlayer.baseAddress + MainPlayer.offsets.yaw, yaw);
            Mem.WriteFloat(MainPlayer.baseAddress + MainPlayer.offsets.pitch, pitch);
        }
Esempio n. 4
0
        //get all the data and store it
        private PlayerDataVec GetPlayerVecData(PlayerData updatePlayer)
        {
            PlayerDataVec playerRet = new PlayerDataVec();

            playerRet.yaw   = Mem.ReadFloat(updatePlayer.baseAddress + updatePlayer.offsets.yaw);
            playerRet.pitch = Mem.ReadFloat(updatePlayer.baseAddress + updatePlayer.offsets.pitch);

            playerRet.xPos = Mem.ReadFloat(updatePlayer.baseAddress + updatePlayer.offsets.xPos);
            playerRet.yPos = Mem.ReadFloat(updatePlayer.baseAddress + updatePlayer.offsets.yPos);
            playerRet.zPos = Mem.ReadFloat(updatePlayer.baseAddress + updatePlayer.offsets.zPos);

            playerRet.health = Mem.ReadInt(updatePlayer.baseAddress + updatePlayer.offsets.health);
            return(playerRet);
        }
Esempio n. 5
0
        private void AimBot()
        {
            //Grab our player's information
            PlayerDataVec playerDataVec = GetPlayerVecData(MainPlayer);
            //this will store every enemy that we have information
            List <PlayerDataVec> enemiesDataVec = new List <PlayerDataVec>();

            for (int i = 0; i < EnemyAddresses.Count; i++)
            {
                //Using our pointer we grab all the enemies information
                PlayerDataVec enemyDataVector = GetPlayerVecData(EnemyAddresses[i]);
                //add our enemy information to the list if hes alive otherwise ignore them
                enemiesDataVec.Add(enemyDataVector);
            }

            //only aim if we are ALIVE
            if (playerDataVec.health > 0)
            {
                int target = 0;
                if (FocusingOnEnemy && FocusTarget != -1)
                {
                    //If our previous target is still alive we focus on them otherwise go after someone else
                    if (enemiesDataVec[FocusTarget].health > 0)
                    {
                        target = FocusTarget;
                    }
                    else
                    {
                        target = FindClosestEnemyIndex(enemiesDataVec.ToArray(), playerDataVec);
                    }
                }
                else//By default aim at the first guy that appears, with this we focus on whos closest to us
                {
                    target = FindClosestEnemyIndex(enemiesDataVec.ToArray(), playerDataVec);
                }

                //if there are more enemies we find the closest one to us then aim
                if (target != -1) //-1 means something went wrong
                {
                    FocusTarget = target;
                    //this condition is only here in case all enemies are dead to aim at NO one
                    //previously if all were dead it would aim at the last guy killed
                    if (enemiesDataVec[target].health > 0)
                    {
                        AimAtTarget(enemiesDataVec[target], playerDataVec);
                    }
                }
            }
        }