private void Form1_Load(object sender, EventArgs e) { // Load Play Area top = Properties.Settings.Default.top; bot = Properties.Settings.Default.bot; left = Properties.Settings.Default.left; right = Properties.Settings.Default.right; GameEngine.SetPlayableArea(new Rectangle(left, top, right - left, bot - top)); // By moving here, we do not reload the tasklist every time we stop the program with the GHK // Load Tasks string ret = PlayerEngine.ParseTasklist(Properties.Settings.Default.taskList); if (ret != null) { MessageBox.Show(string.Format("Error parsing task list: {0}", ret)); return; } // Set Discount GameEngine.SetHeroDiscount(1.0 - 0.02 * Properties.Settings.Default.dogcog); // Set Hotkey ghk = new GlobalHotkey(GlobalHotkey.Constants.CTRL + GlobalHotkey.Constants.SHIFT, Keys.D, this); if (!ghk.Register()) { throw new Exception("can't register"); } }
private void reloadBtn_Click(object sender, EventArgs e) { string ret = PlayerEngine.ParseTasklist(Properties.Settings.Default.taskList); if (ret != null) { MessageBox.Show(string.Format("Error parsing task list: {0}", ret)); } TaskBox.Text = Properties.Settings.Default.taskList; }
private void saveBtn_Click(object sender, EventArgs e) { string ret = PlayerEngine.ParseTasklist(TaskBox.Text); if (ret != null) { MessageBox.Show(string.Format("Error parsing task list: {0}", ret)); } else { Properties.Settings.Default.taskList = TaskBox.Text; Properties.Settings.Default.Save(); MessageBox.Show("Tasklist Saved!"); } }
public void ToggleAutoplayer(bool state) { if (state && !GameEngine.ValidatePlayableArea()) { MessageBox.Show("Can't find game, please check your settings"); return; } if (ClickerThread == null) { ClickerThread = new Thread(new ThreadStart(PlayerEngine.ClickThread)); ClickerThread.Start(); // Sets the culture to English (US) ClickerThread.CurrentCulture = new CultureInfo("en-US"); ClickerThread.CurrentUICulture = new CultureInfo("en-US"); } lblCursorPos.ForeColor = state ? Color.Red : Color.Black; button1.Text = state ? "Stop ( CTRL + SHIFT + D )" : "Start"; PlayerEngine.SetThreadActive(state ? 1 : 0); parsegame.Enabled = state; useskills.Enabled = state; toolStripMenuItem1.Enabled = !state; if (state && Properties.Settings.Default.logging) { loggingDirectory = string.Format("{0}\\logs", Application.StartupPath); if (!Directory.Exists(loggingDirectory)) { Directory.CreateDirectory(loggingDirectory); } currentLoggingString = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); Directory.CreateDirectory(string.Format("{0}\\{1}", loggingDirectory, currentLoggingString)); Directory.CreateDirectory(string.Format("{0}\\{1}\\screenshots", loggingDirectory, currentLoggingString)); sw = File.AppendText(string.Format("{0}\\{1}\\{1}.csv", loggingDirectory, currentLoggingString)); TimeToNextLog = DateTime.Now; } else { if (sw != null) { sw.Dispose(); sw = null; } } }
/// <summary> /// Tries to use skills (and also toggle off progress mode, if it is on). /// Lots of room for optimization here. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void useskills_Tick(object sender, EventArgs e) { // Dark Ritual PlayerEngine.PressKey(Imports.VK_6); // Golden Clicks PlayerEngine.PressKey(Imports.VK_8); PlayerEngine.PressKey(Imports.VK_5); PlayerEngine.PressKey(Imports.VK_4); // DPS // PlayerEngine.PressKey(Imports.VK_1); PlayerEngine.PressKey(Imports.VK_2); PlayerEngine.PressKey(Imports.VK_3); PlayerEngine.PressKey(Imports.VK_7); if (!GameEngine.IsProgressModeOn()) { PlayerEngine.AddAction(new Action(GameEngine.GetProgressButton(), 0)); } }
public void ToggleAutoplayer(bool state) { // Load Play Area top = Properties.Settings.Default.top; bot = Properties.Settings.Default.bot; left = Properties.Settings.Default.left; right = Properties.Settings.Default.right; GameEngine.SetPlayableArea(new Rectangle(left, top, right - left, bot - top)); if (state && !GameEngine.ValidatePlayableArea()) { MessageBox.Show("Can't find game, please check your settings"); return; } if (ClickerThread == null) { ClickerThread = new Thread(new ThreadStart(PlayerEngine.ClickThread)); ClickerThread.Start(); // Sets the culture to English (US) ClickerThread.CurrentCulture = new CultureInfo("en-US"); ClickerThread.CurrentUICulture = new CultureInfo("en-US"); } // Load Tasks string ret = PlayerEngine.ParseTasklist(Properties.Settings.Default.taskList); if (ret != null) { MessageBox.Show(string.Format("Error parsing task list: {0}", ret)); return; } // Set Discount GameEngine.SetHeroDiscount(1.0 - 0.02 * Properties.Settings.Default.dogcog); label1.ForeColor = state ? Color.Red : Color.Black; button1.Text = state ? "Stop ( CTRL + SHIFT + D )" : "Start"; PlayerEngine.SetThreadActive(state ? 1 : 0); parsegame.Enabled = state; useskills.Enabled = state; toolStripMenuItem1.Enabled = !state; if (state && Properties.Settings.Default.logging) { loggingDirectory = string.Format("{0}\\logs", Application.StartupPath); if (!Directory.Exists(loggingDirectory)) { Directory.CreateDirectory(loggingDirectory); } currentLoggingString = DateTime.Now.ToString("MM-dd-yyyy HH mm ss"); Directory.CreateDirectory(string.Format("{0}\\{1}", loggingDirectory, currentLoggingString)); Directory.CreateDirectory(string.Format("{0}\\{1}\\screenshots", loggingDirectory, currentLoggingString)); sw = File.AppendText(string.Format("{0}\\{1}\\{1}.csv", loggingDirectory, currentLoggingString)); TimeToNextLog = DateTime.Now; } else { if (sw != null) { sw.Dispose(); sw = null; } } }
private void clickyclicky_Tick(object sender, EventArgs e) { Stopwatch t = new Stopwatch(); t.Start(); double money = GameEngine.GetMoney(); ParsedHeroes ph = GameEngine.GetHeroes(); if (ph != null) { if (Properties.Settings.Default.useTaskList) { label14.Text = PlayerEngine.TryNextTask(ph, money); } else { label14.Text = "None, tasks turned off"; } StringBuilder sb = new StringBuilder(); if (ph.HeroStats != null) { foreach (HeroStats ss in ph.HeroStats) { sb.AppendLine(string.Format("{0}: Lvl {1} Upgrades {2}", ss.Hero.Name, ss.Level, Convert.ToString(ss.UpgradeBitfield, 2))); } } curHeroesTxt.Text = sb.ToString(); } else { curHeroesTxt.Text = string.Empty; } label9.Text = money.ToString(); if (Properties.Settings.Default.logging && DateTime.Now > TimeToNextLog) { Stopwatch imgsw = new Stopwatch(); imgsw.Start(); sw.WriteLine(string.Format("{0},{1}", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"), money)); Rectangle playableArea = GameEngine.GetPlayableArea(); using (Bitmap bitmap = new Bitmap(playableArea.Width, playableArea.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(playableArea.Left, playableArea.Top), Point.Empty, playableArea.Size); } bitmap.Save(string.Format("{0}\\{1}\\screenshots\\{2}.png", loggingDirectory, currentLoggingString, DateTime.Now.ToString("MM-dd-yyyy HH mm ss"))); } TimeToNextLog = TimeToNextLog.AddMinutes(1); imgsw.Stop(); label15.Text = string.Format("Image captured at {0} in {1} ms", DateTime.Now.ToString("hh:mm:ss"), imgsw.ElapsedMilliseconds); } else if (!Properties.Settings.Default.logging) { label15.Text = "Logging turned off"; } t.Stop(); label8.Text = string.Format("{0} ms", t.ElapsedMilliseconds); }
/// <summary> /// Tries to use skills (and also toggle off progress mode, if it is on). /// Lots of room for optimization here. /// Skill usage is not optimal, taken out until can figure them out. /// This function is called every 2 seconds by a Timer in Main.Designer.cs 'useSkills' /// Will have to check to see how this works if you stop the program in the middle of this, /// not sure how the stopwatch will work in that case /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void useskills_Tick(object sender, EventArgs e) { //Check PlayerEngine.useSkils - Only if true execute skills if (PlayerEngine.getUseSkils()) { // First set of skill usage // Clickstorm -> Powersurge -> Lucky Strikes -> Metal Detector -> Golden Clicks -> // Super Clicks -> Energize -> Dark Ritual -> Reload // Check flag and if skillTimer2 is currently not running or it has been running for 15 min if (!skillFlag && (!skillTimer2.IsRunning || skillTimer2.ElapsedMilliseconds > 900000)) { //Stop skillTimer2 if (skillTimer2.IsRunning) { skillTimer2.Stop(); } //First run of Skill Usage - skillFlag = false PlayerEngine.PressKey(Imports.VK_1); PlayerEngine.PressKey(Imports.VK_2); PlayerEngine.PressKey(Imports.VK_3); PlayerEngine.PressKey(Imports.VK_4); PlayerEngine.PressKey(Imports.VK_5); PlayerEngine.PressKey(Imports.VK_7); PlayerEngine.PressKey(Imports.VK_8); PlayerEngine.PressKey(Imports.VK_6); PlayerEngine.PressKey(Imports.VK_9); //Start skillTimer1 skillTimer1.Start(); //Toggle flag skillFlag = true; } // Second set of skill usage // Energize -> Reload -> Clickstorm -> Powersurge -> Lucky Strikes -> Metal Detector -> // Golden Clicks -> Super Clicks // Check flag and if skillTimer1 has been running for 15 min (900,000 milliseconds) else if (skillFlag && (skillTimer1.ElapsedMilliseconds > 900000)) { //Stop skillTimer1 if (skillTimer1.IsRunning) { skillTimer1.Stop(); } //Second run of Skill Usage - skillFlag = true PlayerEngine.PressKey(Imports.VK_8); PlayerEngine.PressKey(Imports.VK_9); PlayerEngine.PressKey(Imports.VK_1); PlayerEngine.PressKey(Imports.VK_2); PlayerEngine.PressKey(Imports.VK_3); PlayerEngine.PressKey(Imports.VK_4); PlayerEngine.PressKey(Imports.VK_5); PlayerEngine.PressKey(Imports.VK_7); //Start skillTimer2 skillTimer2.Start(); //Toggle flag skillFlag = false; } } /* * // Dark Ritual * PlayerEngine.PressKey(Imports.VK_6); * * // Golden Clicks * PlayerEngine.PressKey(Imports.VK_8); * PlayerEngine.PressKey(Imports.VK_5); * PlayerEngine.PressKey(Imports.VK_4); * * // DPS * // PlayerEngine.PressKey(Imports.VK_1); * PlayerEngine.PressKey(Imports.VK_2); * PlayerEngine.PressKey(Imports.VK_3); * PlayerEngine.PressKey(Imports.VK_7); */ /* Moved to First task in tasklist * if (!GameEngine.IsProgressModeOn()) * { * PlayerEngine.AddAction(new Action(GameEngine.GetProgressButton(), 0)); * } */ }
private void clickyclicky_Tick(object sender, EventArgs e) { Stopwatch t = new Stopwatch(); t.Start(); double money = GameEngine.GetMoney(); ParsedHeroes ph = GameEngine.GetHeroes(); //string dps = GameEngine.GetDamagePerSecond(); // ooze var oozePopupActive = GameEngine.IsRelicOozePopupActive(); lblIsOozeActive.Text = oozePopupActive?"YES":"NO"; if (oozePopupActive) { AddLogMessage("A", "Ooze popup is active, trying to close"); PlayerEngine.TryCloseOozePopup(); } // Progressmode handling var progressMode = GameEngine.IsProgressModeOn(); lblProgressMode.Text = progressMode?"ON":"OFF"; if (progressModeWas != progressMode) { AddLogMessage("A", "Progress mode was " + (progressMode ? "Enabled" : "Disabled")); if (!progressMode) { lastProgressDisabled = DateTime.Now; } } progressModeWas = progressMode; if (!progressMode && Properties.Settings.Default.autoEnableProgress) { var timeSinceDisabled = Math.Round(DateTime.Now.Subtract(lastProgressDisabled).TotalSeconds); lblProgressModeExtra.Text = String.Format("Disabled for {0}s, enabling in {1}s", timeSinceDisabled, (Properties.Settings.Default.enableProgressDelay - timeSinceDisabled)); if (timeSinceDisabled > Properties.Settings.Default.enableProgressDelay) { PlayerEngine.ToggleProgressMode(); AddLogMessage("A", String.Format("Time since progress mode was disabled: {0}, enabling again", timeSinceDisabled)); } } else { lblProgressModeExtra.Text = ""; } if (ph != null) { if (Properties.Settings.Default.useTaskList) { var newTask = PlayerEngine.TryNextTask(ph, money); if (newTask != lblCurrGoal.Text) { AddLogMessage("T", newTask); lblCurrGoal.Text = newTask; } } else { lblCurrGoal.Text = "None, tasks turned off"; } StringBuilder sb = new StringBuilder(); if (ph.HeroStats != null) { foreach (HeroStats ss in ph.HeroStats) { sb.AppendLine(string.Format("{0}: Lvl {1} Upgrades {2}", ss.Hero.Name, ss.Level, Convert.ToString(ss.UpgradeBitfield, 2))); } } curHeroesTxt.Text = sb.ToString(); } else { curHeroesTxt.Text = string.Empty; } lblCurrMoney.Text = money.ToString(); //lblCurrentDamagePerSecond.Text = dps.ToString(); //pictureBox1.Image = GameEngine.GetDamagePerSecondBMP(); if (Properties.Settings.Default.logging && DateTime.Now > TimeToNextLog) { Stopwatch imgsw = new Stopwatch(); imgsw.Start(); sw.WriteLine(string.Format("{0},{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), money)); Rectangle playableArea = GameEngine.GetPlayableArea(); using (Bitmap bitmap = new Bitmap(playableArea.Width, playableArea.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(playableArea.Left, playableArea.Top), Point.Empty, playableArea.Size); } bitmap.Save(string.Format("{0}\\{1}\\screenshots\\{2}.png", loggingDirectory, currentLoggingString, DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"))); } TimeToNextLog = TimeToNextLog.AddMinutes(1); imgsw.Stop(); AddLogMessage("I", string.Format("Screenshot & log @ {0} in {1} ms", DateTime.Now.ToString("HH:mm:ss"), imgsw.ElapsedMilliseconds)); } else if (!Properties.Settings.Default.logging) { lblMiscInfo.Text = "Logging turned off"; } t.Stop(); lblParseTime.Text = string.Format("{0} ms", t.ElapsedMilliseconds); }