private void buttonSave_Click(object sender, RoutedEventArgs e) { SaveConfiguration(); configWindow.Close(); LastFullEvaluation.Restart(); bNeedFullItemUpdate = true; }
public void OnPulse() { if (!LastLoop.IsRunning) { LastLoop.Start(); } if (!LastFullEvaluation.IsRunning) { LastFullEvaluation.Start(); } if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.Me.IsDead || ZetaDia.IsLoadingWorld) { return; } AnimationState aState = ZetaDia.Me.CommonData.AnimationState; if (aState == AnimationState.Attacking || aState == AnimationState.Casting || aState == AnimationState.Channeling || aState == AnimationState.Dead || aState == AnimationState.TakingDamage) { return; } // FUGLY HACK // DB .302+ runs through the stashing routine like Flash Gordon... Can't use a soft hook like the Potion method... // TODO: Look into overloading the TownRun routine and appending stash checks on TownRuns... if (Zeta.Internals.UIElements.StashWindow.IsVisible) { // Stash Checks Diagnostic("UIElement Detected: StashWindow, Initiating Stash Checks..."); if (bCheckStash) { // Spam Prevention (Can not run more than once per 3 minutes) double _tempLastStashCheck = DateTime.Now.Subtract(_lastStashCheck).TotalSeconds; Diagnostic("Last potion was purchased " + _tempLastStashCheck + " seconds ago"); if (_tempLastStashCheck < 180) { Diagnostic("CheckPotions can not run again for another " + (180 - _tempLastStashCheck) + " seconds"); } else { BotMain.PauseWhile(CheckStash, 0, new TimeSpan?(TimeSpan.FromSeconds(30.0))); } } } // Spam Prevention (Can not run more than once per 3 Seconds) if (LastLoop.ElapsedMilliseconds > 3000) { LastLoop.Restart(); try { if (LastFullEvaluation.ElapsedMilliseconds > 300000) { LastFullEvaluation.Restart(); bNeedFullItemUpdate = true; } if (currentLevel != ZetaDia.Me.Level) { LastFullEvaluation.Restart(); bNeedFullItemUpdate = true; currentLevel = ZetaDia.Me.Level; } if (Zeta.Internals.UIElements.VendorWindow.IsVisible) { // Vendor Checks Diagnostic("UIElement Detected: VendorWindow, Initiating Potion Checks..."); if (bBuyPots) { // Spam Prevention (Can not run more than once per 1 minute) double _tempLastBuy = DateTime.Now.Subtract(_lastBuy).TotalSeconds; Diagnostic("Last potion was purchased " + _tempLastBuy + " seconds ago"); if (_tempLastBuy < 60) { Diagnostic("CheckPotions can not run again for another " + (60 - _tempLastBuy) + " seconds"); } else { BotMain.PauseWhile(CheckPotions, 0, new TimeSpan?(TimeSpan.FromSeconds(30.0))); } } } else if (Zeta.Internals.UIElements.StashWindow.IsVisible) { // Stash Checks // Moved outside of the spam prevention loop... So that it will check on every pulse.. } else { // Backpack Checks CheckBackpack(); } } catch (System.AccessViolationException ex) { // Maybe someday the DB core will stop throwing this error.... O_o throw; } catch (Exception ex) { Log("An exception occured: " + ex.ToString()); //throw; } } }