public static void ResetEverythingNewGame() { // In-thread stuff V.ValidateLoad(); // Out of thread Async stuff BeginInvoke(new Action(() => { Logger.Log("New Game - resetting everything"); Trinity.IsReadyToTownRun = false; Trinity.ForceVendorRunASAP = false; TownRun.TownRunCheckTimer.Reset(); TownRun.SendEmailNotification(); TownRun.PreTownRunPosition = Vector3.Zero; TownRun.PreTownRunWorldId = -1; TownRun.WasVendoring = false; CacheData.AbilityLastUsed.Clear(); SpellHistory.HistoryQueue.Clear(); DeathsThisRun = 0; LastDeathTime = DateTime.UtcNow; _hashsetItemStatsLookedAt = new HashSet <string>(); _hashsetItemPicksLookedAt = new HashSet <string>(); _hashsetItemFollowersIgnored = new HashSet <string>(); Blacklist60Seconds = new HashSet <int>(); Blacklist90Seconds = new HashSet <int>(); Blacklist15Seconds = new HashSet <int>(); BacktrackList = new SortedList <int, Vector3>(); TotalBacktracks = 0; HasMappedPlayerAbilities = false; PlayerMover.TotalAntiStuckAttempts = 1; PlayerMover.vSafeMovementLocation = Vector3.Zero; PlayerMover.LastPosition = Vector3.Zero; PlayerMover.TimesReachedStuckPoint = 0; PlayerMover.TimeLastRecordedPosition = DateTime.MinValue; PlayerMover.LastGeneratedStuckPosition = DateTime.MinValue; PlayerMover.TimesReachedMaxUnstucks = 0; PlayerMover.CancelUnstuckerForSeconds = 0; PlayerMover.LastCancelledUnstucker = DateTime.MinValue; NavHelper.UsedStuckSpots = new List <GridPoint>(); CacheData.FullClear(); // Reset all the caches ProfileHistory = new List <string>(); CurrentProfile = ""; FirstProfile = ""; Logger.Log("New Game, resetting Gold Inactivity Timer"); GoldInactivity.Instance.ResetCheckGold(); CombatBase.IsQuestingMode = false; GenericCache.ClearCache(); GenericBlacklist.ClearBlacklist(); })); }
internal static void TrinityOnItemSalvaged(object sender, ItemEventArgs e) { ACDItem i = e.Item; var cachedItem = CachedACDItem.GetCachedItem(i); ResetTownRun(); switch (i.ItemBaseType) { case ItemBaseType.Gem: case ItemBaseType.Misc: break; default: TownRun.LogJunkItems(cachedItem, cachedItem.TrinityItemBaseType, cachedItem.TrinityItemType, ItemValuation.ValueThisItem(cachedItem, cachedItem.TrinityItemType)); break; } }
private static double SetKillRange() { // Always within kill range if in the NoCheckKillRange list! if (DataDictionary.NoCheckKillRange.Contains(CurrentCacheObject.ActorSNO)) { return(CurrentCacheObject.RadiusDistance + 100f); } double killRange; // Bosses, always kill if (CurrentCacheObject.IsBoss) { return(CurrentCacheObject.RadiusDistance + 100f); } // Elitey type mobs and things if ((c_unit_IsElite || c_unit_IsRare || c_unit_IsUnique)) { // using new GUI slider for elite kill range killRange = Settings.Combat.Misc.EliteRange; } else { killRange = CurrentBotKillRange; } if (!TownRun.IsTryingToTownPortal()) { return(killRange); } // Safety for TownRuns if (killRange <= V.F("Cache.TownPortal.KillRange")) { killRange = V.F("Cache.TownPortal.KillRange"); } return(killRange); }
private static void Monk_MaintainTempestRush() { if (!Monk_TempestRushReady()) { return; } if (Player.IsInTown || Zeta.Bot.Logic.BrainBehavior.IsVendoring) { return; } if (TownRun.IsTryingToTownPortal()) { return; } if (TimeSinceUse(SNOPower.Monk_TempestRush) > 150) { return; } bool shouldMaintain = false; bool nullTarget = CurrentTarget == null; if (!nullTarget) { // maintain for everything except items, doors, interactables... stuff we have to "click" on switch (CurrentTarget.Type) { case GObjectType.Unit: case GObjectType.Gold: case GObjectType.Avoidance: case GObjectType.Barricade: case GObjectType.Destructible: case GObjectType.HealthGlobe: case GObjectType.PowerGlobe: { if (Settings.Combat.Monk.TROption == TempestRushOption.TrashOnly && (TargetUtil.AnyElitesInRange(40f) || CurrentTarget.IsBossOrEliteRareUnique)) { shouldMaintain = false; } else { shouldMaintain = true; } } break; } } else { shouldMaintain = true; } if (Settings.Combat.Monk.TROption != TempestRushOption.MovementOnly && SNOPowerUseTimer(SNOPower.Monk_TempestRush) && shouldMaintain) { Vector3 target = LastTempestRushLocation; const string locationSource = "LastLocation"; if (target.Distance2D(ZetaDia.Me.Position) <= 1f) { // rrrix edit: we can't maintain here return; } if (target == Vector3.Zero) { return; } float DestinationDistance = target.Distance2D(ZetaDia.Me.Position); target = TargetUtil.FindTempestRushTarget(); if (DestinationDistance > 10f && NavHelper.CanRayCast(ZetaDia.Me.Position, target)) { Monk_TempestRushStatus(String.Format("Using Tempest Rush to maintain channeling, source={0}, V3={1} dist={2:0}", locationSource, target, DestinationDistance)); var usePowerResult = ZetaDia.Me.UsePower(SNOPower.Monk_TempestRush, target, CurrentWorldDynamicId, -1); if (usePowerResult) { CacheData.AbilityLastUsed[SNOPower.Monk_TempestRush] = DateTime.UtcNow; } } } }
/// <summary> /// Find fresh targets, start main BehaviorTree if needed, cast any buffs needed etc. /// </summary> /// <param name="ret"></param> /// <returns></returns> internal static bool TargetCheck(object ret) { using (new PerformanceLogger("TargetCheck")) { // If we aren't in the game or a world is loading, don't do anything yet if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.IsLoadingWorld) { return(false); } // We keep dying because we're spawning in AoE and next to 50 elites and we need to just leave the game if (DateTime.UtcNow.Subtract(Trinity.LastDeathTime).TotalSeconds < 30 && ZetaDia.Me.Inventory.Equipped.Any() && ZetaDia.Me.Inventory.Equipped.Average(i => i.DurabilityPercent) < 0.05 && !ZetaDia.IsInTown) { Logger.Log("Durability is zero, emergency leave game"); ZetaDia.Service.Party.LeaveGame(true); Thread.Sleep(11000); return(false); } if (ZetaDia.Me.IsDead) { return(false); } if (GoldInactivity.Instance.GoldInactive()) { BotMain.PauseWhile(GoldInactivity.Instance.GoldInactiveLeaveGame); return(false); } if (!HotbarRefreshTimer.IsRunning) { HotbarRefreshTimer.Start(); } if (!HasMappedPlayerAbilities || HotbarRefreshTimer.ElapsedMilliseconds > 1000 || ShouldRefreshHotbarAbilities) { PlayerInfoCache.RefreshHotbar(); // Pick an appropriate health set etc. based on class switch (Player.ActorClass) { case ActorClass.Barbarian: PlayerEmergencyHealthPotionLimit = Settings.Combat.Barbarian.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.Barbarian.HealthGlobeLevel; CombatBase.PlayerKiteDistance = Settings.Combat.Barbarian.KiteLimit; CombatBase.PlayerKiteMode = Config.Combat.KiteMode.Never; break; case ActorClass.Crusader: PlayerEmergencyHealthPotionLimit = Settings.Combat.Crusader.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.Crusader.HealthGlobeLevel; CombatBase.PlayerKiteDistance = 0; CombatBase.PlayerKiteMode = Config.Combat.KiteMode.Never; break; case ActorClass.Monk: PlayerEmergencyHealthPotionLimit = Settings.Combat.Monk.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.Monk.HealthGlobeLevel; // Monks never kite :) CombatBase.PlayerKiteDistance = 0; CombatBase.PlayerKiteMode = Config.Combat.KiteMode.Never; break; case ActorClass.Wizard: PlayerEmergencyHealthPotionLimit = Settings.Combat.Wizard.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.Wizard.HealthGlobeLevel; CombatBase.PlayerKiteDistance = Settings.Combat.Wizard.KiteLimit; CombatBase.PlayerKiteMode = Config.Combat.KiteMode.Always; break; case ActorClass.Witchdoctor: PlayerEmergencyHealthPotionLimit = Settings.Combat.WitchDoctor.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.WitchDoctor.HealthGlobeLevel; CombatBase.PlayerKiteDistance = Settings.Combat.WitchDoctor.KiteLimit; CombatBase.PlayerKiteMode = Config.Combat.KiteMode.Always; break; case ActorClass.DemonHunter: PlayerEmergencyHealthPotionLimit = Settings.Combat.DemonHunter.PotionLevel; _playerEmergencyHealthGlobeLimit = Settings.Combat.DemonHunter.HealthGlobeLevel; CombatBase.PlayerKiteDistance = Settings.Combat.DemonHunter.KiteLimit; CombatBase.PlayerKiteMode = Settings.Combat.DemonHunter.KiteMode; break; } } // Clear target current and reset key variables used during the target-handling function //CurrentTarget = null; DontMoveMeIAmDoingShit = false; _timesBlockedMoving = 0; IsAlreadyMoving = false; lastMovementCommand = DateTime.MinValue; _isWaitingForPower = false; _isWaitingAfterPower = false; _isWaitingForPotion = false; wasRootedLastTick = false; ClearBlacklists(); using (new PerformanceLogger("TargetCheck.RefreshCache")) { // Refresh Cache if needed RefreshDiaObjectCache(); } // We have a target, start the target handler! if (CurrentTarget != null) { _isWholeNewTarget = true; DontMoveMeIAmDoingShit = true; _shouldPickNewAbilities = true; return(true); } // if we just opened a horadric cache, wait around to open it if (DateTime.UtcNow.Subtract(Composites.LastFoundHoradricCache).TotalSeconds < 5) { return(true); } using (new PerformanceLogger("TargetCheck.OOCPotion")) { // Pop a potion when necessary if (Player.CurrentHealthPct <= PlayerEmergencyHealthPotionLimit) { Trinity.UsePotionIfNeeded(); } } _statusText = "[Trinity] No more targets - DemonBuddy/profile management is now in control"; if (Settings.Advanced.DebugInStatusBar && _resetStatusText) { _resetStatusText = false; BotMain.StatusText = _statusText; } // Nothing to do... do we have some maintenance we can do instead, like out of combat buffing? if (DateTime.UtcNow.Subtract(lastMaintenanceCheck).TotalMilliseconds > 150) { using (new PerformanceLogger("TargetCheck.OOCBuff")) { lastMaintenanceCheck = DateTime.UtcNow; bool isLoopingAnimation = ZetaDia.Me.LoopingAnimationEndTime > 0; if (!isLoopingAnimation && !IsReadyToTownRun && !ForceVendorRunASAP) { BarbarianCombat.AllowSprintOOC = true; DisableOutofCombatSprint = false; powerBuff = AbilitySelector(false, true, false); if (powerBuff.SNOPower != SNOPower.None) { Logger.Log(TrinityLogLevel.Verbose, LogCategory.Behavior, "Using OOC Buff: {0}", powerBuff.SNOPower.ToString()); if (powerBuff.WaitTicksBeforeUse > 0) { BotMain.PauseFor(new TimeSpan(0, 0, 0, 0, (int)powerBuff.WaitBeforeUseDelay)); } ZetaDia.Me.UsePower(powerBuff.SNOPower, powerBuff.TargetPosition, powerBuff.TargetDynamicWorldId, powerBuff.TargetACDGUID); LastPowerUsed = powerBuff.SNOPower; CacheData.AbilityLastUsed[powerBuff.SNOPower] = DateTime.UtcNow; if (powerBuff.WaitTicksAfterUse > 0) { BotMain.PauseFor(new TimeSpan(0, 0, 0, 0, (int)powerBuff.WaitAfterUseDelay)); } } } else if (isLoopingAnimation) { _keepKillRadiusExtendedForSeconds = 20; _timeKeepKillRadiusExtendedUntil = DateTime.UtcNow.AddSeconds(_keepKillRadiusExtendedForSeconds); } } } CurrentTarget = null; if ((Trinity.ForceVendorRunASAP || Trinity.IsReadyToTownRun) && TownRun.TownRunTimerRunning()) { Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Waiting for town run timer (Target Check)", true); return(true); } // Ok let DemonBuddy do stuff this loop, since we're done for the moment //DbHelper.Log(TrinityLogLevel.Verbose, LogCategory.GlobalHandler, sStatusText); return(false); } }
/// <summary> /// Find fresh targets, start main BehaviorTree if needed, cast any buffs needed etc. /// </summary> /// <param name="ret"></param> /// <returns></returns> internal static bool TargetCheck(object ret) { Logger.LogVerbose("TargetCheck Tick"); using (new PerformanceLogger("TargetCheck")) { if (Player.IsDead) { return(TargetCheckResult(false, "Is Dead")); } _timesBlockedMoving = 0; IsAlreadyMoving = false; lastMovementCommand = DateTime.MinValue; _isWaitingForPower = false; _isWaitingAfterPower = false; _isWaitingBeforePower = false; _isWaitingForPotion = false; wasRootedLastTick = false; ClearBlacklists(); using (new PerformanceLogger("TargetCheck.RefreshCache")) { // Refresh Cache if needed RefreshDiaObjectCache(); } // We have a target, start the target handler! if (CurrentTarget != null) { _shouldPickNewAbilities = true; return(TargetCheckResult(true, "Current Target is not null")); } MonkCombat.RunOngoingPowers(); // if we just opened a horadric cache, wait around to open it if (DateTime.UtcNow.Subtract(Composites.LastFoundHoradricCache).TotalSeconds < 5) { return(TargetCheckResult(true, "Recently opened Horadric Cache")); } using (new PerformanceLogger("TargetCheck.OOCPotion")) { // Pop a potion when necessary if (Player.CurrentHealthPct <= CombatBase.EmergencyHealthPotionLimit) { UsePotionIfNeededTask(); } } _statusText = "[Trinity] No more targets - DemonBuddy/profile management is now in control"; if (Settings.Advanced.DebugInStatusBar && _resetStatusText) { _resetStatusText = false; BotMain.StatusText = _statusText; } // Nothing to do... do we have some maintenance we can do instead, like out of combat buffing? if (DateTime.UtcNow.Subtract(_lastMaintenanceCheck).TotalMilliseconds > 150) { using (new PerformanceLogger("TargetCheck.OOCBuff")) { _lastMaintenanceCheck = DateTime.UtcNow; bool isLoopingAnimation = ZetaDia.Me.LoopingAnimationEndTime > 0; if (!isLoopingAnimation && !WantToTownRun && !ForceVendorRunASAP) { BarbarianCombat.AllowSprintOOC = true; DisableOutofCombatSprint = false; powerBuff = AbilitySelector(UseOOCBuff: true); if (powerBuff.SNOPower != SNOPower.None) { Logger.Log(TrinityLogLevel.Verbose, LogCategory.Behavior, "Using OOC Buff: {0}", powerBuff.SNOPower.ToString()); ZetaDia.Me.UsePower(powerBuff.SNOPower, powerBuff.TargetPosition, powerBuff.TargetDynamicWorldId, powerBuff.TargetACDGUID); LastPowerUsed = powerBuff.SNOPower; CacheData.AbilityLastUsed[powerBuff.SNOPower] = DateTime.UtcNow; // Monk Stuffs get special attention { if (powerBuff.SNOPower == SNOPower.Monk_TempestRush) { MonkCombat.LastTempestRushLocation = CombatBase.CurrentPower.TargetPosition; } if (powerBuff.SNOPower == SNOPower.Monk_SweepingWind) { MonkCombat.LastSweepingWindRefresh = DateTime.UtcNow; } } } } else if (isLoopingAnimation) { _keepKillRadiusExtendedForSeconds = 20; _timeKeepKillRadiusExtendedUntil = DateTime.UtcNow.AddSeconds(_keepKillRadiusExtendedForSeconds); } } } CurrentTarget = null; if ((ForceVendorRunASAP || WantToTownRun) && TownRun.TownRunTimerRunning()) { Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Waiting for town run timer (Target Check)", true); return(TargetCheckResult(true, "Waiting for TownRunTimer")); } return(TargetCheckResult(false, "End of TargetCheck")); } }