internal static void CheckForCacheRemoval() { //Check Cached Object Removal flag if (RemovalCheck) { //Remove flagged objects var RemovalObjs = (from objs in Objects.Values where objs.NeedsRemoved select objs.RAGUID).ToList(); foreach (var item in RemovalObjs) { CacheObject thisObj = Objects[item]; //remove prioritized raguid if (FunkyGame.Navigation.PrioritizedRAGUIDs.Contains(item)) { FunkyGame.Navigation.PrioritizedRAGUIDs.Remove(item); } //Blacklist flag check if (thisObj.BlacklistFlag != BlacklistType.None) { BlacklistCache.AddObjectToBlacklist(thisObj.RAGUID, thisObj.BlacklistFlag); } Objects.Remove(thisObj.RAGUID); } RemovalCheck = false; } }
public void ProfileChanged(string sThisProfile) { //fresh profile? if (Profiles.Count == 0) { //Lets create a new profile Profiles.Add(new TrackedProfile(sThisProfile)); //Reference it to the Collection currentprofile = Profiles[Profiles.Count - 1]; } //Did we really change profiles? if (Profiles.Count > 0 && Profiles.Last().ProfileName != sThisProfile) { //Refresh Profile Target Blacklist BlacklistCache.UpdateProfileBlacklist(); //Set the "end" date for current profile Profiles.Last().UpdateRangeVariables(); bool foundPreviousEntry = false; foreach (TrackedProfile item in Profiles) { //Found the profile so lets use that instead! if (item.ProfileName == sThisProfile) { foundPreviousEntry = true; item.RestartRangeVariables(); //reset Starting variables //Reference it to the Collection currentprofile = item; break; } } //Profile was not found.. so lets add it and set it as current. if (!foundPreviousEntry) { //Lets create a new profile Profiles.Add(new TrackedProfile(sThisProfile)); //Reference it to the Collection currentprofile = Profiles[Profiles.Count - 1]; } } }
public static void ResetBot() { Logger.DBLog.InfoFormat("Preforming reset of bot data..."); BlacklistCache.ClearBlacklistCollections(); GoldInactivity.LastCoinageUpdate = DateTime.Now; PlayerMover.iTotalAntiStuckAttempts = 1; PlayerMover.vSafeMovementLocation = Vector3.Zero; PlayerMover.vOldPosition = Vector3.Zero; PlayerMover.iTimesReachedStuckPoint = 0; PlayerMover.timeLastRecordedPosition = DateTime.Today; PlayerMover.timeStartedUnstuckMeasure = DateTime.Today; PlayerMover.iTimesReachedMaxUnstucks = 0; PlayerMover.iCancelUnstuckerForSeconds = 0; PlayerMover.timeCancelledUnstuckerFor = DateTime.Today; //Reset all data with bot (Playerdata, Combat Data) Reset(); PlayerClass.CreateBotClass(); //Update character info! FunkyGame.Hero.Update(); //OOC ID Flags Targeting.Cache.ShouldCheckItemLooted = false; Targeting.Cache.CheckItemLootStackCount = 0; //ItemIdentifyBehavior.shouldPreformOOCItemIDing = false; //TP Behavior Reset TownPortalBehavior.ResetTPBehavior(); //Sno Trim Timer Reset ObjectCache.cacheSnoCollection.ResetTrimTimer(); //clear obstacles ObjectCache.Obstacles.Clear(); ObjectCache.Objects.Clear(); //EventHandlers.EventHandlers.DumpedDeathInfo = false; }
// ///<summary> ///Adds/Updates CacheObjects inside collection by Iteration of RactorList ///This is the method that caches all live data about an object! ///</summary> internal static bool UpdateCacheObjectCollection() { //Update Character (just incase it wasnt called before..) FunkyGame.Hero.Update(false, true); Obstacles.AttemptToClearEntries(); HashSet <int> hashDoneThisRactor = new HashSet <int>(); using (ZetaDia.Memory.AcquireFrame(true)) { if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld || !ZetaDia.Me.IsValid) { return(false); } foreach (Actor thisActor in ZetaDia.Actors.RActorList) { int tmp_raGUID; DiaObject thisObj; if (!thisActor.IsValid) { continue; } //Convert to DiaObject thisObj = (DiaObject)thisActor; tmp_raGUID = thisObj.RActorGuid; // See if we've already checked this ractor, this loop if (hashDoneThisRactor.Contains(tmp_raGUID)) { continue; } hashDoneThisRactor.Add(tmp_raGUID); //Update RactorGUID and check blacklisting.. if (BlacklistCache.IsRAGUIDBlacklisted(tmp_raGUID)) { continue; } CacheObject tmp_CachedObj; if (!Objects.TryGetValue(tmp_raGUID, out tmp_CachedObj)) { ActorType Actortype; Vector3 tmp_position; int tmp_acdguid; int tmp_SNOID; #region SNO //Lookup SNO try { tmp_SNOID = thisObj.ActorSNO; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting SNO for {0}", tmp_raGUID); //Logger.DBLog.InfoFormat("Failure to get SNO from object! RaGUID: {0}", tmp_raGUID); continue; } #endregion //check our SNO blacklist (exclude pets?) if (BlacklistCache.IsSNOIDBlacklisted(tmp_SNOID)) { continue; } #region Position try { tmp_position = thisObj.Position; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting Position for {0}", tmp_SNOID); continue; } #endregion #region AcdGUID try { tmp_acdguid = thisObj.ACDGuid; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting ACDGuid for {0}", tmp_SNOID); continue; } #endregion tmp_CachedObj = new CacheObject(tmp_SNOID, tmp_raGUID, tmp_acdguid, tmp_position); } else { //Reset unseen var tmp_CachedObj.LoopsUnseen = 0; } ////Validate (ignore special object SNO Ids) //if (!CacheIDLookup.hashSNOSkipCommonDataCheck.Contains(tmp_CachedObj.SNOID)) //{ // try // { // if (thisObj.CommonData == null) // { // Logger.Write(LogLevel.Cache, "CommonData is no longer valid! {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } // if (thisObj.CommonData.ACDGuid != thisObj.ACDGuid) // { // Logger.Write(LogLevel.Cache, "ACDGuid Mismatched! {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } // } // catch (Exception ex) // { // //Logger.Write(LogLevel.Cache, "Object is no longer valid! (Exception) SNOID {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } //} //Update any SNO Data. #region SNO_Cache_Update if (tmp_CachedObj.ref_DiaObject == null || tmp_CachedObj.ContainsNullValues()) { if (!tmp_CachedObj.UpdateData(thisObj, tmp_CachedObj.RAGUID)) { continue; } } else if (!tmp_CachedObj.IsFinalized) { //Finalize this data by recreating it and updating the Sno cache with a new finalized entry, this also clears our all Sno cache dictionaries since we no longer need them! cacheSnoCollection.FinalizeEntry(tmp_CachedObj.SNOID); } #endregion //Check if this object is a summoned unit by a player... #region SummonedUnits if (tmp_CachedObj.IsSummonedPet && CacheIDLookup.hashSNOSkipCommonDataCheck.Contains(tmp_CachedObj.SNOID)) { PetTypes PetType = (PetTypes)TheCache.ObjectIDCache.UnitPetEntries[tmp_CachedObj.SNOID].ObjectType; if (PetType == PetTypes.WIZARD_ArcaneOrbs) { FunkyGame.Targeting.Cache.Environment.HeroPets.WizardArcaneOrbs++; tmp_CachedObj.NeedsRemoved = true; continue; } } #endregion //Special Cache for Interactable Server Objects if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.ServerInteractable)) { if (!InteractableObjectCache.ContainsKey(tmp_CachedObj.RAGUID)) { InteractableObjectCache.Add(tmp_CachedObj.RAGUID, tmp_CachedObj); //Adventure Mode -- Rifting we add Exit to LOS movement! //if (FunkyGame.AdventureMode && FunkyGame.Bounty.IsInRiftWorld && FunkyBaseExtension.Settings.AdventureMode.EnableAdventuringMode) //{ // if (tmp_CachedObj.InternalName.Contains("Exit")) // { // int index = FunkyGame.Bounty.CurrentBountyMapMarkers.Count; // FunkyGame.Bounty.CurrentBountyMapMarkers.Add(index, new BountyCache.BountyMapMarker(tmp_CachedObj.Position, FunkyGame.Hero.CurrentWorldDynamicID, index)); // } //} } //Whymsdal Portal! if (tmp_CachedObj.SNOID == 405590) { GoblinBehavior.Portal = tmp_CachedObj; } else if (tmp_CachedObj.SNOID == 393030) { GoblinBehavior.Portal = tmp_CachedObj; } //Do not add to main cache! continue; } //Objects with static positions already cached don't need to be updated here. if (!tmp_CachedObj.NeedsUpdate) { continue; } //Obstacles -- (Not an actual object we add to targeting.) if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.Avoidance) || tmp_CachedObj.IsObstacle || tmp_CachedObj.HandleAsAvoidanceObject) { #region Obstacles CacheObstacle thisObstacle; //Do we have this cached? if (!Obstacles.TryGetValue(tmp_CachedObj.RAGUID, out thisObstacle)) { AvoidanceType AvoidanceType = AvoidanceType.None; if (tmp_CachedObj.IsAvoidance) { AvoidanceType = AvoidanceCache.FindAvoidanceUsingSNOID(tmp_CachedObj.SNOID); if (AvoidanceType == AvoidanceType.None) { AvoidanceType = AvoidanceCache.FindAvoidanceUsingName(tmp_CachedObj.InternalName); if (AvoidanceType == AvoidanceType.None) { continue; } } } if (tmp_CachedObj.IsAvoidance && tmp_CachedObj.IsProjectileAvoidance) { //Ranged Projectiles require more than simple bounding points.. so we create it as avoidance zone to cache it with properties. //Check for intersection.. try { ActorMovement thisMovement = thisObj.Movement; Vector2 Direction = thisMovement.DirectionVector; Ray R = new Ray(tmp_CachedObj.Position, Direction.ToVector3()); double Speed; //Lookup Cached Speed, or add new entry. if (!dictProjectileSpeed.TryGetValue(tmp_CachedObj.SNOID, out Speed)) { Speed = thisMovement.DesiredSpeed; dictProjectileSpeed.Add(tmp_CachedObj.SNOID, Speed); } thisObstacle = new CacheAvoidance(tmp_CachedObj, AvoidanceType, R, Speed); Obstacles.Add(thisObstacle); } catch { Logger.Write(LogLevel.Cache, "Failed to create projectile avoidance with rotation and speed. {0}", tmp_CachedObj.InternalName); } } else if (tmp_CachedObj.IsAvoidance) { //Poison Gas Can Be Friendly... if (AvoidanceType == AvoidanceType.PoisonGas) { int TeamID = 0; try { TeamID = thisObj.CommonData.GetAttribute <int>(ActorAttributeType.TeamID); } catch { Logger.Write(LogLevel.Cache, "Failed to retrieve TeamID attribute for object {0}", tmp_CachedObj.InternalName); } //ID of 1 means its non-hostile! (-1?) 2?? //if (TeamID==1||TeamID==-1) if (TeamID != 10) { //Logger.Write(LogLevel.None, "Ignoring Avoidance {0} due to Friendly TeamID match!", tmp_CachedObj.InternalName); BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Permanent); continue; } } thisObstacle = new CacheAvoidance(tmp_CachedObj, AvoidanceType); Obstacles.Add(thisObstacle); } else { //Obstacles. thisObstacle = new CacheServerObject(tmp_CachedObj); Obstacles.Add(thisObstacle); } } continue; #endregion } if (tmp_CachedObj.ObjectShouldBeRecreated) { //This is where we create the real object after its done with SNO Update. //Specific updates if (tmp_CachedObj.Actortype.Value == ActorType.Item) { tmp_CachedObj = new CacheItem(tmp_CachedObj); } else if (tmp_CachedObj.Actortype.Value == ActorType.Monster) { if (!tmp_CachedObj.IsSummonedPet) { tmp_CachedObj = new CacheUnit(tmp_CachedObj); } else { PetTypes PetType = (PetTypes)TheCache.ObjectIDCache.UnitPetEntries[tmp_CachedObj.SNOID].ObjectType; #region Summoner ID Check // Get the summoned-by info, cached if possible if (!tmp_CachedObj.SummonerID.HasValue) { try { tmp_CachedObj.SummonerID = thisObj.CommonData.GetAttribute <int>(ActorAttributeType.SummonedByACDID); } catch (Exception ex) { //Logger.DBLog.InfoFormat("[Funky] Safely handled exception getting summoned-by info [" + tmp_CachedObj.SNOID.ToString(CultureInfo.InvariantCulture) + "]"); //Logger.DBLog.DebugFormat(ex.ToString()); continue; } } if (FunkyGame.Hero.iMyDynamicID != tmp_CachedObj.SummonerID.Value) { BlacklistCache.IgnoreThisObject(tmp_CachedObj, false, false); tmp_CachedObj.NeedsRemoved = true; continue; } #endregion tmp_CachedObj = new CachePet(tmp_CachedObj, PetType); } } else if (tmp_CachedObj.Actortype.Value == ActorType.Gizmo) { if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.Interactables)) { tmp_CachedObj = new CacheInteractable(tmp_CachedObj); } else { tmp_CachedObj = new CacheDestructable(tmp_CachedObj); } } //Update Properties (currently only for units) try { tmp_CachedObj.UpdateProperties(); } catch { Logger.Write(LogLevel.Cache, "Failed to update properties for {0}", tmp_CachedObj.DebugStringSimple); } } if (!tmp_CachedObj.UpdateData()) { //Logger.Write(LogLevel.Cache, "Update Failed for {0}", tmp_CachedObj.DebugStringSimple); if (!tmp_CachedObj.IsStillValid()) { tmp_CachedObj.NeedsRemoved = true; } continue; } //Obstacle cache if (tmp_CachedObj.Obstacletype.Value != ObstacleType.None && (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.ServerObjects))) { CacheObstacle thisObstacleObj; if (!Obstacles.TryGetValue(tmp_CachedObj.RAGUID, out thisObstacleObj)) { CacheServerObject newobj = new CacheServerObject(tmp_CachedObj); Obstacles.Add(tmp_CachedObj.RAGUID, newobj); //Add nearby objects to our collection (used in navblock/obstaclecheck methods to reduce queries) if (CacheIDLookup.hashSNONavigationObstacles.Contains(newobj.SNOID)) { Navigation.Navigation.MGP.AddCellWeightingObstacle(newobj.SNOID, newobj.Radius); } } else { if (thisObstacleObj.targetType.Value == TargetType.Unit) { //Since units position requires updating, we update using the CacheObject thisObstacleObj.Position = tmp_CachedObj.Position; Obstacles[tmp_CachedObj.RAGUID] = thisObstacleObj; } } } //cache it if (Objects.ContainsKey(tmp_CachedObj.RAGUID)) { Objects[tmp_CachedObj.RAGUID] = tmp_CachedObj; } else { Objects.Add(tmp_CachedObj.RAGUID, tmp_CachedObj); } } //End of Loop } // End of Framelock //Tally up unseen objects. var UnseenObjects = Objects.Keys.Where(O => !hashDoneThisRactor.Contains(O)).ToList(); if (UnseenObjects.Any()) { for (int i = 0; i < UnseenObjects.Count(); i++) { Objects[UnseenObjects[i]].LoopsUnseen++; } } //Trim our collection every 5th refresh. UpdateLoopCounter++; if (UpdateLoopCounter > 4) { UpdateLoopCounter = 0; //Now flag any objects not seen for 5 loops. Gold/Globe only 1 loop. foreach (var item in Objects.Values.Where(CO => (CO.LoopsUnseen >= 5 || //5 loops max.. (CO.targetType.HasValue && (CheckFlag(CO.targetType.Value, TargetType.Gold | TargetType.Globe)) && CO.LoopsUnseen > 0)))) //gold/globe only 1 loop! { item.NeedsRemoved = true; } } CheckForCacheRemoval(); _lastUpdatedCacheCollection = DateTime.Now; return(true); }
public static bool GlobalOverlord(object ret) { // If we aren't in the game of a world is loading, don't do anything yet if (FunkyGame.GameIsInvalid) { FunkyGame.Navigation.lastChangedZigZag = DateTime.Today; FunkyGame.Navigation.vPositionLastZigZagCheck = Vector3.Zero; return(false); } // Clear target current and reset key variables used during the target-handling function FunkyGame.Targeting.ResetTargetHandling(); FunkyGame.Targeting.Cache.DontMove = false; // Should we refresh target list? if (FunkyGame.Targeting.Cache.ShouldRefreshObjectList) { FunkyGame.Targeting.Cache.Refresh(); // We have a target, start the target handler! if (FunkyGame.Targeting.Cache.CurrentTarget != null) { FunkyGame.Targeting.cMovement.RestartTracking(); FunkyGame.Targeting.Cache.bWholeNewTarget = true; FunkyGame.Targeting.Cache.DontMove = true; FunkyGame.Targeting.Cache.bPickNewAbilities = true; FunkyGame.RunningTargetingBehavior = true; //Bot.Targeting.Cache.StartingLocation = Bot.Character_.Data.Position; return(true); } } // Pop a potion when necessary if (FunkyGame.Hero.Class.HealthPotionAbility.CheckPreCastConditionMethod()) { if (FunkyGame.Hero.Class.HealthPotionAbility.CheckCustomCombatMethod(null)) { FunkyGame.Hero.Class.HealthPotionAbility.AttemptToUseHealthPotion(); } } BlacklistCache.CheckRefreshBlacklists(); if (FunkyBaseExtension.Settings.Debugging.DebugStatusBar && FunkyGame.bResetStatusText) { FunkyGame.bResetStatusText = false; BotMain.StatusText = "[Funky] No more targets - DemonBuddy/profile management is now in control"; } FunkyGame.RunningTargetingBehavior = false; // Nothing to do... do we have some maintenance we can do instead, like out of combat buffing? FunkyGame.Navigation.lastChangedZigZag = DateTime.Today; FunkyGame.Navigation.vPositionLastZigZagCheck = Vector3.Zero; // Out of combat buffing etc. but only if we don't want to return to town etc. AnimationState myAnimationState = FunkyGame.Hero.CurrentAnimationState; if ((!FunkyGame.Hero.bIsInTown || FunkyBaseExtension.Settings.General.AllowBuffingInTown) && !FunkyGame.IsInNonCombatBehavior && myAnimationState != AnimationState.Attacking && myAnimationState != AnimationState.Casting && myAnimationState != AnimationState.Channeling) { Skill Buff; if (FunkyGame.Hero.Class.FindBuffPower(out Buff)) { Skill.SetupAbilityForUse(ref Buff, null); FunkyGame.Hero.WaitWhileAnimating(4, true); Skill.UsePower(ref Buff); Buff.OnSuccessfullyUsed(); FunkyGame.Hero.WaitWhileAnimating(3, true); } } // Ok let DemonBuddy do stuff this loop, since we're done for the moment return(false); }
///<summary> ///Resets/Updates cache and misc vars ///</summary> private void InitObjectRefresh() { //Cache last target only if current target is not avoidance (Movement). LastCachedTarget = CurrentTarget != null ? CurrentTarget : ObjectCache.FakeCacheObject; //Traveling Flag Reset TravellingAvoidance = false; //Reset target CurrentTarget = null; //CurrentUnitTarget = null; //Kill Loot Radius Update UpdateKillLootRadiusValues(); // Refresh buffs (so we can check for wrath being up to ignore ice balls and anything else like that) Hotbar.RefreshHotbarBuffs(); // Reset the counters for monsters at various ranges Environment.Reset(); ////Check if we should trim our SNO cache.. //if (DateTime.Now.Subtract(ObjectCache.cacheSnoCollection.lastTrimming).TotalMilliseconds > FunkyBaseExtension.Settings.Plugin.UnusedSNORemovalRate) // ObjectCache.cacheSnoCollection.TrimOldUnusedEntries(); ////Check Cached Object Removal flag //if (RemovalCheck) //{ // //Remove flagged objects // var RemovalObjs = (from objs in ObjectCache.Objects.Values // where objs.NeedsRemoved // select objs.RAGUID).ToList(); // foreach (var item in RemovalObjs) // { // CacheObject thisObj = ObjectCache.Objects[item]; // //remove prioritized raguid // if (FunkyGame.Navigation.PrioritizedRAGUIDs.Contains(item)) // FunkyGame.Navigation.PrioritizedRAGUIDs.Remove(item); // //Blacklist flag check // if (thisObj.BlacklistFlag != BlacklistType.None) // BlacklistCache.AddObjectToBlacklist(thisObj.RAGUID, thisObj.BlacklistFlag); // ObjectCache.Objects.Remove(thisObj.RAGUID); // } // RemovalCheck = false; //} ////Increase counter, clear entries if overdue. //ObjectCache.Obstacles.AttemptToClearEntries(); //Non-Combat behavior we reset temp blacklist so we don't get killed by "ignored" units.. if (FunkyGame.IsInNonCombatBehavior) { BlacklistCache.CheckRefreshBlacklists(10); } //Check Gold Inactivity //Bot.Game.GoldTimeoutChecker.CheckTimeoutTripped(); }
///<summary> ///Resets/Updates cache and misc vars ///</summary> private void InitObjectRefresh() { //Cache last target only if current target is not avoidance (Movement). LastCachedTarget = CurrentTarget != null ? CurrentTarget : ObjectCache.FakeCacheObject; if (CurrentTarget != null && CurrentTarget.targetType.HasValue && ObjectCache.CheckTargetTypeFlag(CurrentTarget.targetType.Value, TargetType.AvoidanceMovements)) { if (CurrentTarget.targetType.Value == TargetType.Fleeing) { LastFleeAction = DateTime.Now; FleeingLastTarget = true; } else { LastAvoidanceMovement = DateTime.Now; AvoidanceLastTarget = true; } } else { FleeingLastTarget = false; AvoidanceLastTarget = false; } //Traveling Flag Reset TravellingAvoidance = false; //Reset target CurrentTarget = null; CurrentUnitTarget = null; //Kill Loot Radius Update UpdateKillLootRadiusValues(); // Refresh buffs (so we can check for wrath being up to ignore ice balls and anything else like that) Bot.Character.Class.HotBar.RefreshHotbarBuffs(); // Bunch of variables used throughout Bot.Character.Data.PetData.Reset(); // Reset the counters for monsters at various ranges Environment.Reset(); //Check if we should trim our SNO cache.. if (DateTime.Now.Subtract(ObjectCache.cacheSnoCollection.lastTrimming).TotalMilliseconds > Bot.Settings.Plugin.UnusedSNORemovalRate) { ObjectCache.cacheSnoCollection.TrimOldUnusedEntries(); } //Check Cached Object Removal flag if (RemovalCheck) { //Remove flagged objects var RemovalObjs = (from objs in ObjectCache.Objects.Values where objs.NeedsRemoved select objs.RAGUID).ToList(); foreach (var item in RemovalObjs) { CacheObject thisObj = ObjectCache.Objects[item]; //remove prioritized raguid if (Bot.NavigationCache.PrioritizedRAGUIDs.Contains(item)) { Bot.NavigationCache.PrioritizedRAGUIDs.Remove(item); } //Blacklist flag check if (thisObj.BlacklistFlag != BlacklistType.None) { BlacklistCache.AddObjectToBlacklist(thisObj.RAGUID, thisObj.BlacklistFlag); } ObjectCache.Objects.Remove(thisObj.RAGUID); } RemovalCheck = false; } //Increase counter, clear entries if overdue. ObjectCache.Obstacles.AttemptToClearEntries(); //Non-Combat behavior we reset temp blacklist so we don't get killed by "ignored" units.. if (Bot.IsInNonCombatBehavior) { BlacklistCache.CheckRefreshBlacklists(10); } //Check Gold Inactivity Bot.Game.GoldTimeoutChecker.CheckTimeoutTripped(); }
private static bool GlobalOverlord(object ret) { // If we aren't in the game of a world is loading, don't do anything yet if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld || ZetaDia.Me == null || ZetaDia.Me.CommonData == null) { Bot.NavigationCache.lastChangedZigZag = DateTime.Today; Bot.NavigationCache.vPositionLastZigZagCheck = Vector3.Zero; return(false); } //check if we initialized the bot.. if (Bot.Character.Class == null) { PlayerClass.CreateBotClass(); } //Seconday Hotbar Check Bot.Character.Class.SecondaryHotbarBuffPresent(); // Clear target current and reset key variables used during the target-handling function Bot.Targeting.ResetTargetHandling(); Bot.Targeting.Cache.DontMove = false; //update current profile behavior. Bot.Game.Profile.CheckCurrentProfileBehavior(); // Should we refresh target list? if (Bot.Targeting.Cache.ShouldRefreshObjectList) { Bot.Targeting.Cache.Refresh(); // We have a target, start the target handler! if (Bot.Targeting.Cache.CurrentTarget != null) { Bot.Targeting.Movement.RestartTracking(); Bot.Targeting.Cache.bWholeNewTarget = true; Bot.Targeting.Cache.DontMove = true; Bot.Targeting.Cache.bPickNewAbilities = true; Bot.RunningTargetingBehavior = true; //Bot.Targeting.Cache.StartingLocation = Bot.Character_.Data.Position; return(true); } } else { if (OutOfGame.MuleBehavior) { if (BotMain.StatusText.Contains("Game Finished")) { if (ZetaDia.Actors.GetActorsOfType <GizmoPlayerSharedStash>(true, true).Any()) { return(true); } } } else if (ExitGame.ShouldExitGame) { ExitGame.BehaviorEngaged = true; return(true); } return(false); } // Pop a potion when necessary if (Bot.Character.Class.HealthPotionAbility.CheckPreCastConditionMethod()) { if (Bot.Character.Class.HealthPotionAbility.CheckCustomCombatMethod()) { Bot.Character.Class.HealthPotionAbility.AttemptToUseHealthPotion(); } } BlacklistCache.CheckRefreshBlacklists(); if (Bot.Settings.Debug.DebugStatusBar && bResetStatusText) { bResetStatusText = false; BotMain.StatusText = "[Funky] No more targets - DemonBuddy/profile management is now in control"; } Bot.RunningTargetingBehavior = false; // Nothing to do... do we have some maintenance we can do instead, like out of combat buffing? Bot.NavigationCache.lastChangedZigZag = DateTime.Today; Bot.NavigationCache.vPositionLastZigZagCheck = Vector3.Zero; // Out of combat buffing etc. but only if we don't want to return to town etc. AnimationState myAnimationState = Bot.Character.Data.CurrentAnimationState; if ((!Bot.Character.Data.bIsInTown || Bot.Settings.AllowBuffingInTown) && !TownRunManager.bWantToTownRun && myAnimationState != AnimationState.Attacking && myAnimationState != AnimationState.Casting && myAnimationState != AnimationState.Channeling) { Skill Buff; if (Bot.Character.Class.FindBuffPower(out Buff)) { Skill.SetupAbilityForUse(ref Buff); Bot.Character.Data.WaitWhileAnimating(4, true); Skill.UsePower(ref Buff); Buff.OnSuccessfullyUsed(); Bot.Character.Data.WaitWhileAnimating(3, true); } } // Ok let DemonBuddy do stuff this loop, since we're done for the moment return(false); }
private void levelareaIDchanged(int ID) { iCurrentLevelID = ID; Logger.Write(Helpers.LogLevel.Event, "Level Area ID has Changed to {0}", ID); if (!BrainBehavior.IsVendoring) { //Check for World ID change! if (FunkyGame.Hero.CurrentWorldDynamicID != LastWorldID) { Logger.Write(Helpers.LogLevel.Event, "World ID changed.. clearing Profile Interactable Cache."); LastWorldID = FunkyGame.Hero.CurrentWorldDynamicID; ObjectCache.InteractableObjectCache.Clear(); //Gold Inactivity GoldInactivity.LastCoinageUpdate = DateTime.Now; } if (!LastLevelIDChangeWasTownRun) { //Do full clear BackTrackCache.cacheMovementGPRs.Clear(); FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Clear(); FunkyGame.Game.InteractableCachedObject = null; } else { //Gold Inactivity GoldInactivity.LastCoinageUpdate = DateTime.Now; } //Clear the object cache! ObjectCache.Objects.Clear(); //ObjectCache.cacheSnoCollection.ClearDictionaryCacheEntries(); ObjectCache.RemovalCheck = false; //Every ten minutes clear perm RAGUID list BlacklistCache.CheckPermBlacklist(); ZetaDia.Actors.Clear(); ZetaDia.Actors.Update(); //Reset Skip Ahead Cache SkipAheadCache.ClearCache(); FunkyGame.Hero.UpdateCoinage = true; //Check active bounty if (FunkyGame.AdventureMode) { CheckActiveBounty(); } Navigator.SearchGridProvider.Update(); LastLevelIDChangeWasTownRun = false; } else if (FunkyGame.Hero.bIsInTown) { LastLevelIDChangeWasTownRun = true; } if (OnLevelAreaIDChanged != null) { OnLevelAreaIDChanged(ID); } }
///<summary> ///Updates SNO Cache Values ///</summary> public virtual bool UpdateData(DiaObject thisObj, int raguid) { bool failureDuringUpdate = false; if (InternalName == null) { try { InternalName = thisObj.Name; } catch { Logger.Write(LogLevel.Cache, "Failure to get internal name on object, SNO {0}", SNOID); return(false); } } if (!Actortype.HasValue) { #region ActorType try { Actortype = thisObj.ActorType; } catch { Logger.Write(LogLevel.Cache, "Failure to get actorType for object, SNO: {0}", SNOID); return(false); } #endregion } //Ignored actor types.. if (BlacklistCache.IgnoredActorTypes.Contains(Actortype.Value)) //||!LootBehaviorEnabled&&this.Actortype.Value==ActorType.Item) { BlacklistCache.IgnoreThisObject(this, raguid); return(false); } if (!targetType.HasValue) { #region EvaluateTargetType try { //Evaluate Target Type.. // See if it's an avoidance first from the SNO if (IsAvoidance || IsObstacle) { targetType = TargetType.None; if (IsAvoidance) { if (IsProjectileAvoidance) { Obstacletype = ObstacleType.MovingAvoidance; } else { Obstacletype = ObstacleType.StaticAvoidance; } AvoidanceType AT = AvoidanceCache.FindAvoidanceUsingSNOID(SNOID); //Check if avoidance is enabled or if the avoidance type is set to 0 if (!Bot.Settings.Avoidance.AttemptAvoidanceMovements || AT != AvoidanceType.None && AvoidanceCache.IgnoringAvoidanceType(AT)) { BlacklistCache.AddObjectToBlacklist(raguid, BlacklistType.Temporary); return(false); } // Avoidance isn't disabled, so set this object type to avoidance targetType = TargetType.Avoidance; } else { Obstacletype = ObstacleType.ServerObject; } } else { // Calculate the object type of this object if (Actortype.Value == ActorType.Monster || CacheIDLookup.hashActorSNOForceTargetUnit.Contains(SNOID)) { targetType = TargetType.Unit; Obstacletype = ObstacleType.Monster; if (CacheIDLookup.hashActorSNOForceTargetUnit.Contains(SNOID)) { //Fill in monster data? Actortype = ActorType.Monster; } } else if (Actortype.Value == ActorType.Item || CacheIDLookup.hashForceSNOToItemList.Contains(SNOID)) { string testname = InternalName.ToLower(); //Check if this item is gold/globe.. if (testname.StartsWith("gold")) { targetType = TargetType.Gold; } else if (testname.StartsWith("healthglobe")) { targetType = TargetType.Globe; } else if (testname.StartsWith("console_powerglobe")) { targetType = TargetType.PowerGlobe; } else { targetType = TargetType.Item; } //Gold/Globe? } else if (Actortype.Value == ActorType.Gizmo) { GizmoType thisGizmoType; try { thisGizmoType = thisObj.ActorInfo.GizmoType; } catch { Logger.Write(LogLevel.Cache, "Failure to get actor Gizmo Type!"); return(false); } if (thisGizmoType == GizmoType.DestroyableObject || thisGizmoType == GizmoType.BreakableChest) { targetType = TargetType.Destructible; } else if (thisGizmoType == GizmoType.PowerUp || thisGizmoType == GizmoType.HealingWell || thisGizmoType == GizmoType.PoolOfReflection) { targetType = TargetType.Shrine; } else if (thisGizmoType == GizmoType.Chest) { targetType = TargetType.Container; } else if (thisGizmoType == GizmoType.BreakableDoor) { targetType = TargetType.Barricade; } else if (thisGizmoType == GizmoType.Door) { targetType = TargetType.Door; } else if (thisGizmoType == GizmoType.Waypoint || thisGizmoType == GizmoType.Portal || thisGizmoType == GizmoType.DungeonPortal || thisGizmoType == GizmoType.BossPortal) { //Special Interactive Object -- Add to special cache! targetType = TargetType.ServerInteractable; } else if (thisGizmoType == GizmoType.Switch) { targetType = TargetType.CursedShrine; } else { //All other gizmos should be ignored! BlacklistCache.IgnoreThisObject(this, raguid); return(false); } if (targetType.HasValue) { if (targetType.Value == TargetType.Destructible || targetType.Value == TargetType.Barricade || targetType.Value == TargetType.Door) { Obstacletype = ObstacleType.Destructable; } else if (targetType.Value == TargetType.Shrine || IsChestContainer) { Obstacletype = ObstacleType.ServerObject; } } if (!Gizmotype.HasValue) { Gizmotype = thisGizmoType; } } else if (CacheIDLookup.hashSNOInteractWhitelist.Contains(SNOID)) { targetType = TargetType.Interactable; } else if (Actortype.Value == ActorType.ServerProp) { string TestString = InternalName.ToLower(); //Server props with Base in name are the destructibles "remains" which is considered an obstacle! if (TestString.Contains("base") || TestString.Contains("fence")) { //Add this to the obstacle navigation cache if (!IsObstacle) { CacheIDLookup.hashSNONavigationObstacles.Add(SNOID); } Obstacletype = ObstacleType.ServerObject; //Use unknown since we lookup SNO ID for server prop related objects. targetType = TargetType.None; } else if (TestString.StartsWith("monsteraffix_")) { AvoidanceType T = AvoidanceCache.FindAvoidanceUsingName(TestString); if (T == AvoidanceType.Wall) { //Add this to the obstacle navigation cache if (!IsObstacle) { CacheIDLookup.hashSNONavigationObstacles.Add(SNOID); } Obstacletype = ObstacleType.ServerObject; //Use unknown since we lookup SNO ID for server prop related objects. targetType = TargetType.None; } //else if (Bot.AvoidancesHealth.ContainsKey(T)) //{ // Logger.DBLog.InfoFormat("Found Avoidance not recongized by SNO! Name {0} SNO {1}", TestString, this.SNOID); // CacheIDLookup.hashAvoidanceSNOList.Add(this.SNOID); // this.targetType=TargetType.Avoidance; //} else { //Blacklist all other monster affixes BlacklistCache.IgnoreThisObject(this, raguid); return(false); } } else { BlacklistCache.IgnoreThisObject(this, raguid); return(false); } } else { //Misc?? Ignore it! BlacklistCache.IgnoreThisObject(this, raguid); return(false); } } } catch { Logger.Write(LogLevel.Cache, "Failure to get actorType for object, SNO: {0}", SNOID); return(false); } #endregion } if (!Obstacletype.HasValue) { Obstacletype = ObstacleType.None; } if (ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Unit)) { SNORecordMonster monsterInfo; try { monsterInfo = thisObj.CommonData.MonsterInfo; } catch { Logger.Write(LogLevel.Cache, "Safely Handled MonsterInfo Exception for Object {0}", InternalName); return(false); } if (!Monstertype.HasValue || ShouldRefreshMonsterType) { #region MonsterType try { Monstertype = monsterInfo.MonsterType; } catch { Logger.Write(LogLevel.Cache, "Failure to get MonsterType for SNO: {0}", SNOID); failureDuringUpdate = true; } #endregion } if (!Monstersize.HasValue) { #region MonsterSize try { Monstersize = monsterInfo.MonsterSize; } catch { Logger.Write(LogLevel.Cache, "Failure to get MonsterSize for SNO: {0}", SNOID); failureDuringUpdate = true; } #endregion } } if (Actortype.HasValue && targetType.HasValue && (Actortype.Value != ActorType.Item && targetType.Value != TargetType.Avoidance && targetType.Value != TargetType.ServerInteractable)) { //Validate sphere info Sphere sphereInfo = thisObj.CollisionSphere; if (!CollisionRadius.HasValue) { #region CollisionRadius try { CollisionRadius = sphereInfo.Radius; } catch { Logger.Write(LogLevel.Cache, "Failure to get CollisionRadius for SNO: {0}", SNOID); failureDuringUpdate = true; } #endregion if (CacheIDLookup.dictFixedCollisionRadius.ContainsKey(SNOID)) { //Override The Default Collision Sphere Value CollisionRadius = CacheIDLookup.dictFixedCollisionRadius[SNOID]; } } if (!ActorSphereRadius.HasValue) { #region ActorSphereRadius try { ActorSphereRadius = thisObj.ActorInfo.Sphere.Radius; } catch { Logger.Write(LogLevel.Cache, "Safely handled getting attribute Sphere radius for gizmo {0}", InternalName); failureDuringUpdate = true; } #endregion } #region GizmoProperties if (ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Destructible | TargetType.Interactable)) { //No Loot if (!DropsNoLoot.HasValue) { #region DropsNoLoot try { DropsNoLoot = thisObj.CommonData.GetAttribute <float>(ActorAttributeType.DropsNoLoot) <= 0; } catch { Logger.Write(LogLevel.Cache, "Safely handled reading DropsNoLoot for gizmo {0}", InternalName); failureDuringUpdate = true; } #endregion } //No XP if (!GrantsNoXP.HasValue) { #region GrantsNoXP try { GrantsNoXP = thisObj.CommonData.GetAttribute <float>(ActorAttributeType.GrantsNoXP) <= 0; } catch { Logger.Write(LogLevel.Cache, "Safely handled reading GrantsNoXp for gizmo {0}", InternalName); failureDuringUpdate = true; } #endregion } //Barricade flag if (!IsBarricade.HasValue) { #region Barricade try { IsBarricade = ((DiaGizmo)thisObj).IsBarricade; } catch { Logger.Write(LogLevel.Cache, "Safely handled getting attribute IsBarricade for gizmo {0}", InternalName); failureDuringUpdate = true; } #endregion } } #endregion } return(!failureDuringUpdate); }