/// <summary> /// /// </summary> /// <param name="hero">Hero to change settings for. Set to null for general settings.</param> /// <param name="team">Team to change hero settings for.</param> /// <param name="set">Array of settings to change. Must be the same size as setto.</param> /// <param name="setto">Array to change settings to. Must be the same size as set.</param> public SetHero(Hero?hero, BotTeam team, string[] set, object[] setto) { Hero = hero; Team = team; Set = set; SetTo = setto; }
/// <summary> /// Add AI to the game. /// </summary> /// <param name="hero">Hero type to add.</param> /// <param name="difficulty">Difficulty of hero.</param> /// <param name="team">Team that AI joins.</param> /// <param name="count">Amount of AI that is added. Set to -1 for max. Default is -1</param> /// <returns></returns> public bool AddAI(AIHero hero, Difficulty difficulty, BotTeam team, int count = -1) { cg.updateScreen(); // Find the maximum amount of bots that can be placed on a team, and store it in the maxBots variable if (cg.DoesAddButtonExist()) /* * If the blue shade of the "Move" button is there, that means that the Add AI button is there. * If the Add AI button is missing, we can't add AI, so return false. If it is there, add the bots. * The AI button will be missing if the server is full */ { // Open AddAI menu. cg.Cursor = new Point(835, 182); cg.WaitForUpdate(835, 182, 20, 2000); cg.LeftClick(835, 182, 500); List <Keys> press = new List <Keys>(); if (hero != AIHero.Recommended) { press.Add(Keys.Space); int heroid = (int)hero; for (int i = 0; i < heroid; i++) { press.Add(Keys.Down); } press.Add(Keys.Space); press.Add(Keys.Down); } press.Add(Keys.Down); if (difficulty != Difficulty.Easy) { press.Add(Keys.Space); int difficultyID = (int)difficulty; for (int i = 0; i < difficultyID; i++) { press.Add(Keys.Down); } press.Add(Keys.Space); press.Add(Keys.Down); press.Add(Keys.Down); } press.Add(Keys.Down); press.Add(Keys.Down); if (team != BotTeam.Both) { press.Add(Keys.Space); int teamID = (int)team; for (int i = 0; i < teamID; i++) { press.Add(Keys.Down); } press.Add(Keys.Space); press.Add(Keys.Down); press.Add(Keys.Down); press.Add(Keys.Down); press.Add(Keys.Down); } if (count > 0) { press.Add(Keys.Up); for (int i = 0; i < 12; i++) { press.Add(Keys.Left); } for (int i = 0; i < count; i++) { press.Add(Keys.Right); } press.Add(Keys.Down); } press.Add(Keys.Down); press.Add(Keys.Space); cg.KeyPress(press.ToArray()); cg.ResetMouse(); return(true); } else { return(false); } }
/// <summary> /// Toggles what heroes can be selected. /// </summary> /// <param name="ta">Determines if all heroes should be enabled, disabled or neither before toggling</param> /// <param name="team">Team to change roster for.</param> /// <param name="heroes">Heroes to toggle.</param> public void SetHeroRoster(ToggleAction ta, BotTeam team, params Hero[] heroes) { GoToSettings(); LeftClick(351, 311); // click heroes LeftClick(287, 158); // click hero roster // If team doesn't equal both, click a team to change hero roster for. if (team == BotTeam.Blue) { LeftClick(492, 127, 250); LeftClick(484, 173, 250); } if (team == BotTeam.Red) { LeftClick(492, 127, 250); LeftClick(484, 193, 250); } // If the toggle action is disable all, disable all heroes before toggling. if (ta == ToggleAction.DisableAll) { LeftClick(635, 130, 250); } // If the toggle action is enable all, enable all heroes before toggling. else if (ta == ToggleAction.EnableAll) { LeftClick(597, 130, 250); } if (OpenChatIsDefault) { Chat.CloseChat(); } KeyPress(Keys.Down); Thread.Sleep(1); if (team == BotTeam.Both) { KeyPress(Keys.Down); Thread.Sleep(1); } // For each hero for (int i = 0; i < Enum.GetNames(typeof(Hero)).Length; i++) { // Toggle hero if current hero selected is set in the heroes array. for (int hi = 0; hi < heroes.Length; hi++) { if ((int)heroes[hi] == i) { KeyPress(Keys.Space); Thread.Sleep(1); } } KeyPress(Keys.Down); Thread.Sleep(1); } GoBack(3, 0); if (OpenChatIsDefault) { Chat.OpenChat(); } }
/// <summary> /// Toggles what heroes can be selected. /// </summary> /// <param name="ta">Determines if all heroes should be enabled, disabled or neither before toggling</param> /// <param name="team">Team to change roster for.</param> /// <param name="heroes">Heroes to toggle.</param> /// <example> /// The example below will enable random heroes for a team. /// <code> /// using System; /// using System.Collections.Generic; /// using System.Linq; /// using Deltin.CustomGameAutomation; /// /// public class SetHeroRosterExample /// { /// public static void ChooseRandomHeroes(CustomGame cg, BotTeam team, int randomHeroCount) /// { /// Random rnd = new Random(); /// int heroCount = Enum.GetNames(typeof(MyEnum)).Length - 1; /// /// List<Hero> chooseHeroes = new List<Hero>(); /// while (chooseHeroes.Count < randomHeroCount) /// { /// int heroID = rnd.Next(heroCount); /// if (chooseHeroes.Select(v => v as int).Contains(heroID)) /// continue; /// chooseHeroes.Add(heroID as Hero); /// } /// /// cg.SetHeroRoster(ToggleAction.DisableAll, team, chooseHeroes.ToArray()); /// } /// } /// </code> /// </example> public void SetHeroRoster(ToggleAction ta, BotTeam team, params Hero[] heroes) { GoToSettings(); LeftClick(Points.SETTINGS_HEROES); // click heroes LeftClick(Points.SETTINGS_HEROES_ROSTER); // click hero roster // If team doesn't equal both, click a team to change hero roster for. if (team == BotTeam.Blue) { LeftClick(Points.SETTINGS_HEROES_ROSTER_TEAM_DROPDOWN, 250); LeftClick(Points.SETTINGS_HEROES_ROSTER_TEAM_BLUE, 250); } if (team == BotTeam.Red) { LeftClick(Points.SETTINGS_HEROES_ROSTER_TEAM_DROPDOWN, 250); LeftClick(Points.SETTINGS_HEROES_ROSTER_TEAM_RED, 250); } // If the toggle action is disable all, disable all heroes before toggling. if (ta == ToggleAction.DisableAll) { LeftClick(Points.SETTINGS_HEROES_ROSTER_DISABLE_ALL, 250); } // If the toggle action is enable all, enable all heroes before toggling. else if (ta == ToggleAction.EnableAll) { LeftClick(Points.SETTINGS_HEROES_ROSTER_ENABLE_ALL, 250); } if (OpenChatIsDefault) { Chat.CloseChat(); } KeyPress(Keys.Down); Thread.Sleep(1); if (team == BotTeam.Both) { KeyPress(Keys.Down); Thread.Sleep(1); } // For each hero for (int i = 0; i < Enum.GetNames(typeof(Hero)).Length; i++) { // Toggle hero if current hero selected is set in the heroes array. for (int hi = 0; hi < heroes.Length; hi++) { if ((int)heroes[hi] == i) { KeyPress(Keys.Space); Thread.Sleep(1); } } KeyPress(Keys.Down); Thread.Sleep(1); } GoBack(3, 0); if (OpenChatIsDefault) { Chat.OpenChat(); } }