Exemple #1
0
        static void targetBestEnemyViaScore()
        {
            byte    currentTeam     = GameHelper.getPlayerTeam(localEntityIndex);
            Vector3 currentPosition = GameHelper.getPlayerPositon(localEntityIndex);

            float[] targetScores = new float[Botv2.Bot.numPlayers];

            if (!waited && lastTargetIndex != -1 && GameHelper.getPlayerHealth(lastTargetIndex) <= 0)
            {
                Thread.Sleep(800);
                waited = true;
                return;
            }

            for (int i = 0; i < Botv2.Bot.numPlayers; i++)
            {
                Vector3 position = GameHelper.getPlayerPositon(i);
                byte    team     = GameHelper.getPlayerTeam(i);
                byte    health   = GameHelper.getPlayerHealth(i);

                targetScores[i] = 1000000;

                if (team != currentTeam && !position.isZero() && health > 0 && i != localEntityIndex)
                {
                    Vector2 angleDifference = AimHelper.getAngleDifference(position);

                    if (angleDifference.x <= angleConeLimit && angleDifference.y <= 15)
                    {
                        targetScores[i] = 0;

                        targetScores[i] += angleDifference.x * 7;
                        targetScores[i] += angleDifference.y / 1.5f;
                        targetScores[i] += position.distance(currentPosition) / 10;
                    }
                }
            }

            float winnerScore = targetScores.Min();
            int   winnerIndex = targetScores.ToList().IndexOf(winnerScore);

            if (winnerIndex != 0)
            {
                Vector3 vecToAim = GameHelper.getPlayerBonePosition(winnerIndex, 10);
                //if (vecToAim.z < GameHelper.getPlayerPositon(winnerIndex).z) vecToAim = GameHelper.getPlayerPositon(winnerIndex);

                AimHelper.setCameraPosition(vecToAim);
                lastTargetIndex = winnerIndex;
                waited          = false;
            }

            Console.WriteLine("Winner has index of {0} with a score of {1}", winnerIndex, winnerScore);
        }
Exemple #2
0
        /*
         *      Least obvious method, will only snap to enemies within <CONFIG:angleConeLimit> degrees of your view angle and will wait a second and a half before aiming to another enemy after killing
         */
        static void targetBestEnemy()
        {
            byte    currentTeam         = GameHelper.getPlayerTeam(localEntityIndex);
            Vector3 currentPosition     = GameHelper.getPlayerPositon(localEntityIndex);
            Vector2 bestAngleDifference = null;
            int     target = -1;

            if (!waited && lastTargetIndex != -1 && GameHelper.getPlayerHealth(lastTargetIndex) <= 0)
            {
                Thread.Sleep(800);
                waited = true;
                return;
            }

            for (int i = 0; i < 32; i++)
            {
                Vector3 position = GameHelper.getPlayerPositon(i);
                byte    team     = GameHelper.getPlayerTeam(i);
                byte    health   = GameHelper.getPlayerHealth(i);

                if (team != currentTeam && !position.isZero() && health > 0)
                {
                    Vector2 angleDifference = AimHelper.getAngleDifference(position);
                    if ((bestAngleDifference == null || angleDifference.x < bestAngleDifference.x) && angleDifference.x <= angleConeLimit && angleDifference.y <= 15)
                    {
                        target = i;
                        bestAngleDifference = angleDifference;
                    }
                }
            }

            if (bestAngleDifference == null)
            {
                return;
            }
            if (target >= 0)
            {
                Vector3 vecToAim = GameHelper.getPlayerBonePosition(target, 10);
                //if (vecToAim.z < GameHelper.getPlayerPositon(target).z) vecToAim = GameHelper.getPlayerPositon(target);
                //if (vecToAim.z > GameHelper.getPlayerPositon(target).z + 40) vecToAim = GameHelper.getPlayerPositon(target);


                AimHelper.setCameraPosition(vecToAim);
                lastTargetIndex = target;
                waited          = false;
            }
        }