Exemplo n.º 1
0
        /// <summary>
        /// Gets the team a player in the queue is queueing for.
        /// </summary>
        /// <param name="slot">Slot to check.</param>
        /// <param name="noUpdate"></param>
        /// <returns>Team that the player is queueing for.</returns>
        /// <include file='docs.xml' path='doc/exceptions/invalidslot/exception'/>
        public QueueTeam GetQueueTeam(int slot, bool noUpdate = false)
        {
            using (cg.LockHandler.Passive)
            {
                if (!CustomGame.IsSlotInQueue(slot))
                {
                    throw new InvalidSlotException(slot);
                }
                Point check = cg.Interact.FindSlotLocation(slot, true);
                if (!noUpdate)
                {
                    cg.UpdateScreen();
                }
                Color color = Capture.GetPixel(check.X, check.Y);

                // If the blue color is greater than the red color, the queue slot is on blue team.
                if (color.B > color.R)
                {
                    return(QueueTeam.Blue);
                }
                // If the green color is less than 90, the queue slot is on the red team.
                else if (color.G < 90)
                {
                    return(QueueTeam.Red);
                }
                // Else, the queue slot is on neutral team.
                else
                {
                    return(QueueTeam.Neutral);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the team a player in the queue is queueing for.
        /// </summary>
        /// <param name="slot">Slot to check.</param>
        /// <returns>Team that the player is queueing for.</returns>
        /// <include file='docs.xml' path='doc/exceptions/invalidslot/exception'/>
        public QueueTeam GetQueueTeam(int slot)
        {
            if (!CustomGame.IsSlotInQueue(slot))
            {
                throw new InvalidSlotException(slot);
            }
            Point check = cg.Interact.FindSlotLocation(slot);

            check.X -= 25;
            cg.updateScreen();
            Color color = cg.GetPixelAt(check.X, check.Y);

            // If the blue color is greater than the red color, the queue slot is on blue team.
            if (color.B > color.R)
            {
                return(QueueTeam.Blue);
            }
            // If the green color is less than 90, the queue slot is on the red team.
            else if (color.G < 90)
            {
                return(QueueTeam.Red);
            }
            // Else, the queue slot is on neutral team.
            else
            {
                return(QueueTeam.Neutral);
            }
        }
 /// <summary>
 /// Swaps the team of a player.
 /// </summary>
 /// <param name="slot">Slot to swap team.</param>
 /// <returns>Returns true if swapping team is successful.</returns>
 /// <include file='docs.xml' path='doc/exceptions/invalidslot/exception'/>
 public bool SwapTeam(int slot)
 {
     // If the player is in blue, use the swap to red option.
     if (CustomGame.IsSlotBlue(slot))
     {
         return(ClickOption(slot, Markups.SWAP_TO_RED)); // Swap blue player to red
     }
     // If the player is in red, use the swap to blue option.
     else if (CustomGame.IsSlotRed(slot))
     {
         return(ClickOption(slot, Markups.SWAP_TO_BLUE)); // Swap red player to blue
     }
     else if (CustomGame.IsSlotInQueue(slot))
     {
         QueueTeam team = cg.PlayerInfo.GetQueueTeam(slot);
         if (team == QueueTeam.Blue)
         {
             return(ClickOption(slot, Markups.SWAP_TO_RED));
         }
         else if (team == QueueTeam.Red)
         {
             return(ClickOption(slot, Markups.SWAP_TO_BLUE));
         }
     }
     return(false);
 }
        internal Point FindSlotLocation(int slot, bool noUpdate = false)
        {
            if (!CustomGame.IsSlotValid(slot))
            {
                throw new InvalidSlotException(slot);
            }

            if (!noUpdate)
            {
                cg.UpdateScreen();
            }

            int yoffset = 0;
            int xoffset = 0;

            /*
             * if (cg.IsDeathmatch(true))
             * {
             *  if (CustomGame.IsSlotBlue(slot))
             *  {
             *      xoffset += Distances.LOBBY_SLOT_DM_BLUE_X_OFFSET;
             *      yoffset += Distances.LOBBY_SLOT_DM_Y_OFFSET;
             *  }
             *  else if (CustomGame.IsSlotRed(slot))
             *  {
             *      xoffset += Distances.LOBBY_SLOT_DM_RED_X_OFFSET;
             *      yoffset += Distances.LOBBY_SLOT_DM_Y_OFFSET;
             *  }
             * }
             */

            if (CustomGame.IsSlotInQueue(slot) && !cg.CheckRange(CustomGame.QueueMin, CustomGame.QueueMax, 0, true).Contains(slot))
            {
                return(Point.Empty);                                                                                                                    // If a queue slot is selected and there is no one in that queue slot, return empty.
            }
            if (CustomGame.IsSlotSpectator(slot))
            {
                yoffset = cg.FindSpectatorOffset(true);                                   // If there is players in the queue, the spectator slots move down. Find the offset in pixels to spectator.
            }
            if (CustomGame.IsSlotSpectatorOrQueue(slot))
            {
                xoffset = -150;                                          // Prevents the player context menu from orientating left for slots in the spectator and queue.
            }
            if (CustomGame.IsSlotInQueue(slot))
            {
                slot = slot - 6;                                                                                 // selecting a person in the queue where spectator slots are normally at.
            }
            return(new Point(Points.SLOT_LOCATIONS[slot].X + xoffset, Points.SLOT_LOCATIONS[slot].Y + yoffset)); // Blue, Red, Spectators, and all of queue except for the first slot.
        }
Exemplo n.º 5
0
            /// <summary>
            /// Checks if the input slot is an AI.
            /// </summary>
            /// <param name="slot">Slot to check.</param>
            /// <param name="noUpdate">Determines if the captured screen should be updated before scanning.</param>
            /// <returns>Returns true if slot is AI.</returns>
            public bool IsAI(int slot, bool noUpdate = false)
            {
                // Look for the commendation icon for the slot chosen.

                // If the slot is not valid, throw an exception.
                if (!cg.IsSlotValid(slot))
                {
                    throw new InvalidSlotException(string.Format("Slot {0} is out of range of possible slots to check for AI.", slot));
                }

                // Since AI cannot join spectator, return false if the slot is a spectator slot.
                if (cg.IsSlotSpectator(slot))
                {
                    return(false);
                }

                // The chat covers blue slot 5. Close the chat so the scanning will work accurately.
                if (slot == 5)
                {
                    cg.Chat.CloseChat();
                }

                if (!noUpdate)
                {
                    cg.updateScreen();
                }

                int[] checkY       = new int[0]; // The potential Y locations of the commendation icon
                int   checkX       = 0;          // Where to start scanning on the X axis for the commendation icon
                int   checkXLength = 0;          // How many pixels to scan on the X axis for the commendation icon

                if (cg.IsSlotBlue(slot) || cg.IsSlotRed(slot))
                {
                    int checkslot = slot;
                    if (cg.IsSlotRed(checkslot))
                    {
                        checkslot -= 6;
                    }

                    // Find the potential Y locations of the commendation icon.
                    // 248 is the Y location of the first commendation icon of the player in the first slot of red and blue. 28 is how many pixels it is to the next commendation icon on the next slot.
                    int y1 = 248 + (checkslot * 28),
                        y2 = y1 + 9; // The second potential Y location is 9 pixels under the first potential spot.
                    checkY = new int[] { y1, y2 };

                    if (cg.IsSlotBlue(slot))
                    {
                        checkX = 74; // The start of the blue slots on the X axis
                    }
                    else if (cg.IsSlotRed(slot))
                    {
                        checkX = 399;   // The start of the red slots on the X axis
                    }
                    checkXLength = 195; // The length of the slots.
                }
                else if (cg.IsSlotInQueue(slot))
                {
                    int checkslot = slot - Queueid;

                    // 245 is the Y location of the first commendation icon of the player in the first slot in queue. 14 is how many pixels it is to the next commendation icon on the next slot.
                    int y = 245 + (checkslot * 14);
                    checkY = new int[] { y };

                    checkX       = 707; // The start of the queue slots on this X axis
                    checkXLength = 163; // The length of the queue slots.
                }

                bool isAi = true;

                for (int x = checkX; x < checkX + checkXLength; x++)
                {
                    for (int yi = 0; yi < checkY.Length; yi++)
                    {
                        int y = checkY[yi];
                        // Check for the commendation icon.
                        if (cg.CompareColor(x, y, new int[] { 85, 140, 140 }, new int[] { 115, 175, 175 }))
                        {
                            isAi = false;
                            break;
                        }
                    }
                }

                if (slot == 5 && cg.OpenChatIsDefault)
                {
                    cg.Chat.OpenChat();
                }

                return(isAi);
            }
        /// <summary>
        /// Checks if the input slot is an AI.
        /// </summary>
        /// <param name="slot">Slot to check.</param>
        /// <param name="noUpdate">Determines if the captured screen should be updated before scanning.</param>
        /// <returns>Returns true if slot is AI.</returns>
        /// <include file='docs.xml' path='doc/exceptions/invalidslot/exception'/>
        public bool IsAI(int slot, bool noUpdate = false)
        {
            using (cg.LockHandler.Passive)
            {
                // Look for the commendation icon for the slot chosen.

                // If the slot is not valid, throw an exception.
                if (!CustomGame.IsSlotValid(slot))
                {
                    throw new InvalidSlotException(slot);
                }

                if (CustomGame.IsSlotSpectator(slot) || // Since AI cannot join spectator, return false if the slot is a spectator slot.
                    !cg.GetSlots(SlotFlags.All, true).Contains(slot))    // Return false if the slot is empty.
                {
                    return(false);
                }

                // The chat covers blue slot 5. Close the chat so the scanning will work accurately.
                if (slot == 5 && cg.OpenChatIsDefault)
                {
                    cg.Chat.CloseChat();
                }

                if (!noUpdate || (slot == 5 && cg.OpenChatIsDefault))
                {
                    cg.UpdateScreen();
                }

                int checkY       = 0; // The potential Y locations of the commendation icon
                int checkX       = 0; // Where to start scanning on the X axis for the commendation icon
                int checkXLength = 0; // How many pixels to scan on the X axis for the commendation icon

                if (CustomGame.IsSlotBlue(slot) || CustomGame.IsSlotRed(slot))
                {
                    int checkslot = slot;
                    if (CustomGame.IsSlotRed(checkslot))
                    {
                        checkslot -= 6;
                    }

                    // Find the potential Y locations of the commendation icon.
                    // 248 is the Y location of the first commendation icon of the player in the first slot of red and blue. 28 is how many pixels it is to the next commendation icon on the next slot.
                    checkY = 257 + (checkslot * Distances.LOBBY_SLOT_DISTANCE);

                    if (CustomGame.IsSlotBlue(slot))
                    {
                        checkX = 74; // The start of the blue slots on the X axis
                    }
                    else if (CustomGame.IsSlotRed(slot))
                    {
                        checkX = 399; // The start of the red slots on the X axis
                    }
                    if (cg.IsDeathmatch(true))
                    {
                        checkY += Distances.LOBBY_SLOT_DM_Y_OFFSET - 9;
                        if (CustomGame.IsSlotBlue(slot))
                        {
                            checkX += Distances.LOBBY_SLOT_DM_BLUE_X_OFFSET;
                        }
                        else if (CustomGame.IsSlotRed(slot))
                        {
                            checkX += Distances.LOBBY_SLOT_DM_RED_X_OFFSET;
                        }
                    }

                    checkXLength = 195; // The length of the slots.
                }
                else if (CustomGame.IsSlotInQueue(slot))
                {
                    int checkslot = slot - CustomGame.QueueID;

                    // 245 is the Y location of the first commendation icon of the player in the first slot in queue. 14 is how many pixels it is to the next commendation icon on the next slot.
                    checkY = 245 + (checkslot * 14); // - Distances.LOBBY_QUEUE_OFFSET;

                    checkX       = 707;              // The start of the queue slots on this X axis
                    checkXLength = 163;              // The length of the queue slots.
                }

                bool isAi = true;

                for (int x = checkX; x < checkX + checkXLength && isAi; x += 1)
                {
                    // Check for the commendation icon.
                    isAi = !Capture.CompareColor(Convert.ToInt32(x), checkY, new int[] { 75, 130, 130 }, new int[] { 115, 175, 175 });
                }

                if (slot == 5 && cg.OpenChatIsDefault)
                {
                    cg.Chat.OpenChat();
                }

                return(isAi);
            }
        }