public CacheAvoidance(CacheObject parent, AvoidanceType type, Ray R, double speed) : base(parent) { AvoidanceType = type; AvoidanceValue = Bot.Settings.Avoidance.Avoidances[(int)type]; ray_ = R; Speed = speed; projectile_startPosition = base.Position; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (Bot.Settings.Debug.FunkyLogFlags.HasFlag(LogLevel.Movement)) { string avoidances = ""; Bot.Targeting.Cache.Environment.TriggeringAvoidances.ForEach(a => avoidances = avoidances + a.AvoidanceType.ToString() + ", "); Logger.Write(LogLevel.Movement, "Avoidances Triggering: {0}", avoidances); } //Reuse the last generated safe spot... if (DateTime.Now.Subtract(Bot.Targeting.Cache.LastAvoidanceMovement).TotalSeconds < this.iSecondsAvoidMoveFor) { Vector3 reuseV3 = Bot.NavigationCache.AttemptToReuseLastLocationFound(); if (reuseV3 != Vector3.Zero) { if (!ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(reuseV3)) { obj = new CacheObject(reuseV3, TargetType.Avoidance, 20000f, "SafeReuseAvoid", 2.5f, -1); return true; } } } Vector3 vAnySafePoint; //Check if we have any movement abilities we can cast.. if so lets not check avoidance intersections. PointCheckingFlags flags = Bot.Settings.Plugin.AvoidanceFlags; if (Bot.Character.Class.HasCastableMovementAbility()) flags &= ~(PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.BlockedDirection); if (Bot.NavigationCache.AttemptFindSafeSpot(out vAnySafePoint, Vector3.Zero, flags)) { float distance = vAnySafePoint.Distance(Bot.Character.Data.Position); Logger.DBLog.DebugFormat("Avoid Movement found AT {0} with {1} Distance", vAnySafePoint.ToString(), distance); //setup avoidance target obj = new CacheObject(vAnySafePoint, TargetType.Avoidance, 20000f, "SafeAvoid", 2.5f, -1); //Estimate time we will be reusing this movement vector3 this.iSecondsAvoidMoveFor = 1 + (int)(distance / 5f); return true; } else {//Failed to find any location.. //Set the future date we must wait for to retry.. AvoidRetryDate = DateTime.Now.AddMilliseconds(Bot.Settings.Avoidance.FailureRetryMilliseconds); } return false; }; }
public override void Initialize() { this.Test = (ref CacheObject obj) => { //Resuse last safespot until timer expires! if (DateTime.Now.Subtract(Bot.Targeting.Cache.LastFleeAction).TotalSeconds < this.iSecondsFleeMoveFor) { Vector3 reuseV3 = Bot.NavigationCache.AttemptToReuseLastLocationFound(); if (reuseV3 != Vector3.Zero) { if (!ObjectCache.Objects.IsPointNearbyMonsters(reuseV3, Bot.Settings.Fleeing.FleeMaxMonsterDistance) && !ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(reuseV3)) { obj = new CacheObject(reuseV3, TargetType.Fleeing, 20000f, "ReuseFleeSpot", 2.5f, -1); return true; } } } Vector3 vAnySafePoint; //Setup Line of Sight for last target if its a unit and still valid.. Vector3 LineOfSight = Bot.Targeting.Cache.LastCachedTarget.targetType.HasValue && Bot.Targeting.Cache.LastCachedTarget.targetType.Value == TargetType.Unit && Bot.Targeting.Cache.LastCachedTarget.ObjectIsValidForTargeting ? Bot.Targeting.Cache.LastCachedTarget.Position : Vector3.Zero; PointCheckingFlags flags = Bot.Settings.Plugin.FleeingFlags; if (Bot.Character.Class.HasCastableMovementAbility()) flags &= ~(PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.BlockedDirection); if (Bot.NavigationCache.AttemptFindSafeSpot(out vAnySafePoint, LineOfSight, flags)) { float distance = vAnySafePoint.Distance(Bot.Character.Data.Position); Logger.DBLog.DebugFormat("Flee Movement found AT {0} with {1} Distance", vAnySafePoint.ToString(), distance.ToString()); obj = new CacheObject(vAnySafePoint, TargetType.Fleeing, 20000f, "FleeSpot", 2.5f, -1); this.iSecondsFleeMoveFor = 1 + (int)(distance / 5f); return true; } else {//Failed to find any location.. //Set the future date we must wait for to retry.. FleeRetryDate = DateTime.Now.AddMilliseconds(Bot.Settings.Fleeing.FailureRetryMilliseconds); } return false; }; }
public CacheAvoidance(CacheObject parent, AvoidanceType avoidancetype) : base(parent) { AvoidanceType = avoidancetype; AvoidanceValue = Bot.Settings.Avoidance.Avoidances[(int)avoidancetype]; //Special avoidances that require additional loops before removal (note: the loops are checked every 150ms, but obstacles are checked twice!) if (AvoidanceType.HasFlag(AvoidanceType.TreeSpore) && SNOID == 6578) RefreshRemovalCounter = 75; else if (AvoidanceType.HasFlag(AvoidanceType.GrotesqueExplosion)) RefreshRemovalCounter = 25; else if (AvoidanceType.HasFlag(AvoidanceType.DemonicForge)) RefreshRemovalCounter = 10; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { this.bStayPutDuringAvoidance = false; //cluster update Bot.Targeting.Cache.Clusters.UpdateTargetClusteringVariables(); //Standard weighting of valid objects -- updates current target. this.WeightEvaluationObjList(ref obj); //Final Possible Target Check if (obj == null) { // No valid targets but we were told to stay put? if (this.bStayPutDuringAvoidance) { //Lets check our avoidance object list if (Bot.Targeting.Cache.objectsIgnoredDueToAvoidance.Count > 0 && DateTime.Now.Subtract(lastAvoidanceConnectSearch).TotalMilliseconds > 4000) { Logger.DBLog.InfoFormat("Preforming Avoidance Connection Search on Potential Objects"); lastAvoidanceConnectSearch = DateTime.Now; //Update or Create Bot Postion GPRect GPRectangle botrect = new GPRectangle(Bot.Character.Data.Position); Vector3 connectVector3; foreach (CacheObject testobj in Bot.Targeting.Cache.objectsIgnoredDueToAvoidance) { if (botrect.TryFindSafeSpot(Bot.Character.Data.Position, out connectVector3, testobj.Position, PointCheckingFlags.AvoidanceOverlap | PointCheckingFlags.BlockedDirection | PointCheckingFlags.MonsterOverlap | PointCheckingFlags.ObstacleOverlap | PointCheckingFlags.RaycastWalkable, new List<GridPoint>())) { obj = new CacheObject(connectVector3, TargetType.Avoidance, 20000, "Avoid Connection", 2.5f, -1); return true; } } // } if (Bot.Targeting.Cache.Environment.TriggeringAvoidances.Count == 0) { obj = new CacheObject(Bot.Character.Data.Position, TargetType.Avoidance, 20000, "StayPutPoint", 2.5f, -1); return true; } } } return false; }; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (Bot.Character.Data.Position.Distance(Bot.Targeting.Cache.StartingLocation) > Bot.Settings.Backtracking.MinimumDistanceFromStart) { //Generate the path here so we can start moving.. Navigation.NP.MoveTo(Bot.Targeting.Cache.StartingLocation, "Backtracking", true); //Setup a temp target that the handler will use obj = new CacheObject(Bot.Targeting.Cache.StartingLocation, TargetType.Backtrack, 20000, "Backtracking", Bot.Settings.Backtracking.MinimumDistanceFromStart); return true; } Bot.Targeting.Cache.Backtracking = false; 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; 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(); }
///<summary> ///Refreshes Cache and updates current target ///</summary> public void Refresh() { //Update Character (just incase it wasnt called before..) Bot.Character.Data.Update(false, true); //Reset key targeting vars always! InitObjectRefresh(); //Update object cache collection ObjectCache.UpdateCacheObjectCollection(); //Update last Refresh Time lastRefreshedObjects = DateTime.Now; //Refresh Obstacles ObjectCache.Obstacles.Values.ForEach(obj => obj.RefreshObject()); //Check avoidance requirement still valid if (RequiresAvoidance) { if (!AvoidanceLastTarget && DateTime.Now.Subtract(Bot.Targeting.Movement.LastMovementAttempted).TotalMilliseconds < 300 &&//We are moving..? !ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(Bot.Targeting.Movement.CurrentTargetLocation) && !ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(Bot.Character.Data.Position, Bot.Targeting.Movement.CurrentTargetLocation)) { RequiresAvoidance = false; } else if (AvoidanceLastTarget && LastCachedTarget.CentreDistance <= 2.5f) RequiresAvoidance = false; else if (Environment.TriggeringAvoidances.Count == 0) RequiresAvoidance = false; } //This is our list of objects we consider to be valid for targeting. ValidObjects = ObjectCache.Objects.Values.Where(o => o.ObjectIsValidForTargeting).ToList(); //Update Prioritize Flag bPrioritizeCloseRangeUnits = (Bot.Settings.Targeting.PrioritizeCloseRangeUnits && Bot.Settings.Targeting.PrioritizeCloseRangeMinimumUnits <= Environment.SurroundingUnits); // Still no target, let's end it all! if (!RefreshTargetBehaviors()) { StartingLocation = Vector3.Zero; Bot.NavigationCache.PrioritizedRAGUIDs.Clear(); } else { if (ExitGame.ShouldExitGame) { //Have not started exit behavior.. global overlord will begin so lets exit! if (!ExitGame.BehaviorEngaged) { CurrentTarget = null; } else if (DateTime.Now.Subtract(ExitGame.BehaviorEngagedTime).TotalSeconds > 60) {//We started behavior over a minute ago.. lets just exit already!! Logger.DBLog.InfoFormat("[Funky] Forcing Exiting behavior after one minute!"); CurrentTarget = null; } } } }
public CacheItem(CacheObject baseobj) : base(baseobj) { }
public CacheInteractable(CacheObject baseobj) : base(baseobj) { }
///<summary> /// ///</summary> public CacheObstacle(CacheObject fromObj) : base(fromObj) { if (!Obstacletype.HasValue) Obstacletype = ObstacleType.None; }
public override bool TestIntersection(CacheObject OBJ, Vector3 BotPosition) { if (Obstacletype.Value == ObstacleType.MovingAvoidance) { Vector3 ProjectileEndPoint = MathEx.GetPointAt(Position, ProjectileMaxRange, Rotation); return GridPoint.LineIntersectsLine(BotPosition, Position, PointPosition, ProjectileEndPoint); } return MathEx.IntersectsPath(base.Position, Radius, BotPosition, OBJ.Position); }
public CacheLineOfSight(CacheObject obj, Vector3 pos) { OrginCacheObject = obj; OrginCacheObjectRAGUID=obj.RAGUID; Position = pos; }
internal RunStatus TargetMoveTo(CacheObject obj) { #region DebugInfo if (Bot.Settings.Debug.DebugStatusBar) { string Action = "[Move-"; switch (obj.targetType.Value) { case TargetType.Avoidance: Action += "Avoid] "; break; case TargetType.Fleeing: Action += "Flee] "; break; case TargetType.Backtrack: Action += "BackTrack] "; break; case TargetType.LineOfSight: Action += "LOS] "; break; case TargetType.Unit: if (Bot.NavigationCache.groupRunningBehavior && Bot.NavigationCache.groupingCurrentUnit != null && Bot.NavigationCache.groupingCurrentUnit == obj) Action += "Grouping] "; else Action += "Combat] "; break; case TargetType.Item: case TargetType.Gold: case TargetType.Globe: Action += "Pickup] "; break; case TargetType.Interactable: Action += "Interact] "; break; case TargetType.Container: Action += "Open] "; break; case TargetType.Destructible: case TargetType.Barricade: Action += "Destroy] "; break; case TargetType.Shrine: Action += "Click] "; break; } Bot.Targeting.Handler.UpdateStatusText(Action); } #endregion // Are we currently incapacitated? If so then wait... if (Bot.Character.Data.bIsIncapacitated || Bot.Character.Data.bIsRooted) return RunStatus.Running; //Ignore skip ahead cache for LOS movements.. if (Bot.Settings.Debug.SkipAhead && obj.targetType.Value != TargetType.LineOfSight) SkipAheadCache.RecordSkipAheadCachePoint(); // Some stuff to avoid spamming usepower EVERY loop, and also to detect stucks/staying in one place for too long bool bForceNewMovement = false; //Herbfunk: Added this to prevent stucks attempting to move to a target blocked. (Case: 3 champs behind a wall, within range but could not engage due to being on the other side.) #region Non Movement Counter Reached if (NonMovementCounter > Bot.Settings.Plugin.MovementNonMovementCount) { Logger.Write(LogLevel.Movement, "non movement counter reached {0}", NonMovementCounter); if (obj.Actortype.HasValue && obj.Actortype.Value.HasFlag(ActorType.Item)) { if (NonMovementCounter > 250) { //Are we stuck? if (!Navigation.MGP.CanStandAt(Bot.Character.Data.Position)) { Logger.DBLog.InfoFormat("Character is stuck inside non-standable location.. attempting townportal cast.."); ZetaDia.Me.UseTownPortal(); NonMovementCounter = 0; return RunStatus.Running; } } //Check if we can walk to this location from current location.. if (!Navigation.CanRayCast(Bot.Character.Data.Position, CurrentTargetLocation, UseSearchGridProvider: true)) { obj.RequiresLOSCheck = true; obj.BlacklistLoops = 50; Logger.Write(LogLevel.Movement, "Ignoring Item {0} -- due to RayCast Failure!", obj.InternalName); Bot.Targeting.Cache.bForceTargetUpdate = true; return RunStatus.Running; } } else if (ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, TargetType.LineOfSight | TargetType.Backtrack)) { Logger.Write(LogLevel.Movement, "Line of Sight Movement Stalled!"); Bot.NavigationCache.LOSmovementObject = null; Bot.Targeting.Cache.bForceTargetUpdate = true; NonMovementCounter = 0; // Reset the emergency loop counter and return success return RunStatus.Running; } else { Logger.Write(LogLevel.Movement, "Ignoring obj {0} ", obj.InternalName + " _ SNO:" + obj.SNOID); obj.BlacklistLoops = 50; obj.RequiresLOSCheck = true; Bot.Targeting.Cache.bForceTargetUpdate = true; NonMovementCounter = 0; // Reset the emergency loop counter and return success return RunStatus.Running; } } #endregion //update misc movement info (rotation, state, flags, etc) Bot.NavigationCache.RefreshMovementCache(); //Do a priority check for nearby obstacle objects. Bot.NavigationCache.ObstaclePrioritizeCheck(15f); #region Evaluate Last Action // Position didn't change last update.. check if we are stuck! if (DateTime.Now.Subtract(lastPositionChange).TotalMilliseconds > 150 && (!Bot.NavigationCache.IsMoving || Bot.NavigationCache.currentMovementState == MovementState.WalkingInPlace || Bot.NavigationCache.currentMovementState.Equals(MovementState.None))) { bForceNewMovement = true; if (DateTime.Now.Subtract(LastMovementDuringCombat).TotalMilliseconds >= 250) { LastMovementDuringCombat = DateTime.Now; BlockedMovementCounter++; // Tell target finder to prioritize close-combat targets incase we were bodyblocked #region TargetingPriortize switch (BlockedMovementCounter) { case 2: case 3: if (Bot.NavigationCache.groupRunningBehavior) { Logger.Write(LogLevel.Movement, "Grouping Behavior stopped due to blocking counter"); Bot.NavigationCache.GroupingFinishBehavior(); Bot.NavigationCache.groupingSuspendedDate = DateTime.Now.AddMilliseconds(4000); Bot.Targeting.Cache.bForceTargetUpdate = true; return RunStatus.Running; } if (!ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, TargetType.AvoidanceMovements)) { //Finally try raycasting to see if navigation is possible.. if (obj.Actortype.HasValue && (obj.Actortype.Value == ActorType.Gizmo || obj.Actortype.Value == ActorType.Monster)) { Vector3 hitTest; // No raycast available, try and force-ignore this for a little while, and blacklist for a few seconds if (Navigator.Raycast(Bot.Character.Data.Position, obj.Position, out hitTest)) { if (hitTest != Vector3.Zero) { obj.RequiresLOSCheck = true; obj.BlacklistLoops = 10; Logger.Write(LogLevel.Movement, "Ignoring object " + obj.InternalName + " due to not moving and raycast failure!", true); Bot.Targeting.Cache.bForceTargetUpdate = true; return RunStatus.Running; } } } else if (obj.targetType.Value == TargetType.Item) { obj.BlacklistLoops = 10; Bot.Targeting.Cache.bForceTargetUpdate = true; } } else { if (!Navigation.CanRayCast(Bot.Character.Data.Position, CurrentTargetLocation, NavCellFlags.AllowWalk)) { Logger.Write(LogLevel.Movement, "Cannot continue with avoidance movement due to raycast failure!"); BlockedMovementCounter = 0; Bot.NavigationCache.CurrentGPArea.BlacklistLastSafespot(); Bot.NavigationCache.vlastSafeSpot = Vector3.Zero; Bot.Targeting.Cache.bForceTargetUpdate = true; return RunStatus.Running; } } break; } #endregion return RunStatus.Running; } } else { // Movement has been made, so count the time last moved! LastMovementDuringCombat = DateTime.Now; } #endregion // See if we want to ACTUALLY move, or are just waiting for the last move command... if (!bForceNewMovement && IsAlreadyMoving && CurrentTargetLocation == LastTargetLocation && DateTime.Now.Subtract(LastMovementCommand).TotalMilliseconds <= 100) { return RunStatus.Running; } // If we're doing avoidance, globes or backtracking, try to use special abilities to move quicker #region SpecialMovementChecks if (ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, Bot.Settings.Combat.CombatMovementTargetTypes)) { Skill MovementPower; Vector3 MovementVector = Bot.Character.Class.FindCombatMovementPower(out MovementPower, obj.Position); if (MovementVector != Vector3.Zero) { ZetaDia.Me.UsePower(MovementPower.Power, MovementVector, Bot.Character.Data.iCurrentWorldID, -1); MovementPower.OnSuccessfullyUsed(); // Store the current destination for comparison incase of changes next loop LastTargetLocation = CurrentTargetLocation; // Reset total body-block count, since we should have moved //if (DateTime.Now.Subtract(Bot.Targeting.Cache.Environment.lastForcedKeepCloseRange).TotalMilliseconds>=2000) BlockedMovementCounter = 0; return RunStatus.Running; } //Special Whirlwind Code if (Bot.Character.Class.AC == ActorClass.Barbarian && Bot.Character.Class.HotBar.HotbarPowers.Contains(SNOPower.Barbarian_Whirlwind)) { // Whirlwind against everything within range (except backtrack points) if (Bot.Character.Data.dCurrentEnergy >= 10 && Bot.Targeting.Cache.Environment.iAnythingWithinRange[(int)RangeIntervals.Range_20] >= 1 && obj.DistanceFromTarget <= 12f && (!Bot.Character.Class.HotBar.HotbarPowers.Contains(SNOPower.Barbarian_Sprint) || Bot.Character.Class.HotBar.HasBuff(SNOPower.Barbarian_Sprint)) && (ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, TargetType.AvoidanceMovements | TargetType.Gold | TargetType.Globe) == false) && (obj.targetType.Value != TargetType.Unit || (obj.targetType.Value == TargetType.Unit && !obj.IsTreasureGoblin && (!Bot.Settings.Class.bSelectiveWhirlwind || Bot.Targeting.Cache.Environment.bAnyNonWWIgnoreMobsInRange || !CacheIDLookup.hashActorSNOWhirlwindIgnore.Contains(obj.SNOID))))) { // Special code to prevent whirlwind double-spam, this helps save fury bool bUseThisLoop = SNOPower.Barbarian_Whirlwind != Bot.Character.Class.LastUsedAbility.Power; if (!bUseThisLoop) { if (Bot.Character.Class.Abilities[SNOPower.Barbarian_Whirlwind].LastUsedMilliseconds >= 200) bUseThisLoop = true; } if (bUseThisLoop) { ZetaDia.Me.UsePower(SNOPower.Barbarian_Whirlwind, CurrentTargetLocation, Bot.Character.Data.iCurrentWorldID); Bot.Character.Class.Abilities[SNOPower.Barbarian_Whirlwind].OnSuccessfullyUsed(); } // Store the current destination for comparison incase of changes next loop LastTargetLocation = CurrentTargetLocation; BlockedMovementCounter = 0; return RunStatus.Running; } } } #endregion // Now for the actual movement request stuff IsAlreadyMoving = true; UseTargetMovement(obj, bForceNewMovement); // Store the current destination for comparison incase of changes next loop LastMovementAttempted = DateTime.Now; LastTargetLocation = CurrentTargetLocation; //Check if we moved at least 5f.. if (LastPlayerLocation.Distance(Bot.Character.Data.Position) <= 5f) NonMovementCounter++; else { NonMovementCounter = 0; BlockedMovementCounter = 0; } //store player location LastPlayerLocation = Bot.Character.Data.Position; return RunStatus.Running; }
private void UseTargetMovement(CacheObject obj, bool bForceNewMovement = false) { float currentDistance = Vector3.Distance(LastTargetLocation, CurrentTargetLocation); if (DateTime.Now.Subtract(LastMovementAttempted).TotalMilliseconds >= 250 || (currentDistance >= 2f && !Bot.NavigationCache.IsMoving) || bForceNewMovement) { bool UsePowerMovement = true; //Check for any circumstances where we use actor movement instead of power. (click or click-hold) if (ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, TargetType.AvoidanceMovements)) { if (NonMovementCounter < 10 || currentDistance > 50f) UsePowerMovement = false; } else if (ObjectCache.CheckTargetTypeFlag(obj.targetType.Value, TargetType.LineOfSight | TargetType.Backtrack)) { if (currentDistance > 30f) UsePowerMovement = false; } else { //Use Walk Power when not using LOS Movement, target is not an item and target does not ignore LOS. if (!(NonMovementCounter < 10 && !obj.UsingLOSV3 && !obj.IgnoresLOSCheck && (obj.targetType.Value != TargetType.Item) && obj.targetType.Value != TargetType.Interactable)) { UsePowerMovement = false; } } //Preform Movement! if (!UsePowerMovement) ZetaDia.Me.Movement.MoveActor(CurrentTargetLocation); else ZetaDia.Me.UsePower(SNOPower.Walk, CurrentTargetLocation, Bot.Character.Data.iCurrentWorldID); //and record when we sent the movement.. LastMovementCommand = DateTime.Now; } }
///<summary> ///Used to recreate from temp into obstacle object. ///</summary> public CacheObject(CacheObject parent) : base(parent) { AcdGuid = parent.AcdGuid; BlacklistFlag = parent.BlacklistFlag; BlacklistLoops_ = parent.BlacklistLoops_; gprect_ = parent.gprect_; InteractionAttempts = parent.InteractionAttempts; lineofsight = new LOSInfo(this); LoopsUnseen_ = parent.LoopsUnseen_; losv3_ = parent.losv3_; LosSearchRetryMilliseconds_ = parent.LosSearchRetryMilliseconds_; NeedsRemoved = parent.NeedsRemoved; NeedsUpdate = parent.NeedsUpdate; PrioritizedDate = parent.PrioritizedDate; PriorityCounter = parent.PriorityCounter; position_ = parent.Position; radius_ = parent.Radius; RAGUID = parent.RAGUID; ref_DiaObject = parent.ref_DiaObject; removal_ = parent.removal_; RequiresLOSCheck = parent.RequiresLOSCheck; SummonerID = parent.SummonerID; weight_ = parent.Weight; HandleAsAvoidanceObject = parent.HandleAsAvoidanceObject; Properties = parent.Properties; }
///<summary> ///Tests if this intersects with current bot position using CacheObject ///</summary> public virtual bool TestIntersection(CacheObject OBJ, Vector3 BotPosition) { return MathEx.IntersectsPath(base.Position, Radius, BotPosition, BotMeleeVector); }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (obj == null) { if (Bot.NavigationCache.LOSmovementObject != null && //((Bot.Targeting.Cache.LastCachedTarget!=null&&Bot.Targeting.Cache.LastCachedTarget.Equals(Bot.NavigationCache.LOSmovementObject))|| (Bot.NavigationCache.LOSmovementObject.CentreDistance < 50f && !Bot.NavigationCache.LOSmovementObject.CacheContainsOrginObject())) {//Invalidated the Line of sight obj! Logger.Write(LogLevel.Movement, "LOS Object is No Longer Valid -- Reseting."); Bot.NavigationCache.LOSBlacklistedRAGUIDs.Add(Bot.NavigationCache.LOSmovementObject.OrginCacheObjectRAGUID); Bot.NavigationCache.LOSmovementObject = null; if (Bot.Targeting.Cache.LastCachedTarget.targetType.Value == TargetType.LineOfSight) Navigation.NP.Clear(); } if (Bot.NavigationCache.LOSmovementObject == null) {//New LOS Movement Selection. Bot.Targeting.Cache.Environment.LoSMovementObjects = Bot.Targeting.Cache.Environment.LoSMovementObjects.OrderBy(o => o.CentreDistance).ToList(); foreach (var cobj in Bot.Targeting.Cache.Environment.LoSMovementObjects) {//Iterate Units if (Bot.NavigationCache.LOSBlacklistedRAGUIDs.Contains(cobj.RAGUID)) continue; if (!Navigation.NP.CanFullyClientPathTo(cobj.Position)) continue; Logger.Write(LogLevel.Movement, "Line of Sight Started for object {0} -- with {1} vectors", cobj.InternalName, Navigation.NP.CurrentPath.Count); Bot.NavigationCache.LOSBlacklistedRAGUIDs.Add(cobj.RAGUID); //Set the object Bot.NavigationCache.LOSmovementObject = new CacheLineOfSight(cobj, cobj.Position); break; } } if (Bot.NavigationCache.LOSmovementObject != null) {//Line of Sight unit is valid //See if the orgin object is still valid.. if (Bot.NavigationCache.LOSmovementObject.CentreDistance<75f) { if (!Bot.NavigationCache.LOSmovementObject.CacheContainsOrginObject()) { Logger.Write(LogLevel.Movement, "Line of Sight Ending due to Orgin Object No Longer Available!"); Bot.NavigationCache.LOSmovementObject = null; return false; } else { //Update Position using Orgin Object? Bot.NavigationCache.LOSmovementObject.UpdateOrginObject(); } } Navigation.NP.MoveTo(Bot.NavigationCache.LOSmovementObject.Position, "LOS", true); if (Navigation.NP.CurrentPath.Count > 0) { //Setup a temp target that the handler will use obj = new CacheObject(Bot.NavigationCache.LOSmovementObject.Position, TargetType.LineOfSight, 1d, "LOS Movement", Navigation.NP.PathPrecision); return true; } } } return false; }; }
public CacheServerObject(CacheObject parent) : base(parent) { //if (IsDemonicForge) //{ // UpdateRotation(); // FacingStartVector3 = MathEx.GetPointAt(Position, 15f, Rotation); // FacingEndVector3 = MathEx.GetPointAt(FacingStartVector3, 30f, Rotation); //} }
public LOSInfo(CacheObject obj) { Obj=obj; }
internal static void IgnoreThisObject(CacheObject thisobj, bool removal = true, bool blacklistSNOID = true) { //Logger.DBLog.InfoFormat("[Blacklist] Obj RAGUID {0} SNOID {1} ({2})", thisobj.RAGUID, thisobj.SNOID, thisobj.InternalName); int sno, raguid; sno = thisobj.SNOID; raguid = thisobj.RAGUID; //Add to our blacklist so we don't create it again.. hashRGUIDIgnoreBlacklist.Add(raguid); if (blacklistSNOID) //Blacklist SNO so we don't create it ever again! hashActorSNOIgnoreBlacklist.Add(sno); if (removal) { //Clear SNO cache entries.. ObjectCache.cacheSnoCollection.Remove(sno); if (ObjectCache.Objects.ContainsKey(raguid)) ObjectCache.Objects.Remove(raguid); } }
///<summary> ///Iterates through Usable objects and sets the Bot.CurrentTarget to the highest weighted object found inside the given list. ///</summary> private void WeightEvaluationObjList(ref CacheObject CurrentTarget) { // Store if we are ignoring all units this cycle or not bool bIgnoreAllUnits = !Bot.Targeting.Cache.Environment.bAnyChampionsPresent && ((!Bot.Targeting.Cache.Environment.bAnyTreasureGoblinsPresent && Bot.Settings.Targeting.GoblinPriority >= 2) || Bot.Settings.Targeting.GoblinPriority < 2) && Bot.Character.Data.dCurrentHealthPct >= 0.85d; //clear our last "avoid" list.. Bot.Targeting.Cache.objectsIgnoredDueToAvoidance.Clear(); double iHighestWeightFound = 0; foreach (CacheObject thisobj in Bot.Targeting.Cache.ValidObjects) { thisobj.UpdateWeight(); if (thisobj.Weight == 1) { // Force the character to stay where it is if there is nothing available that is out of avoidance stuff and we aren't already in avoidance stuff thisobj.Weight = 0; if (!Bot.Targeting.Cache.RequiresAvoidance) this.bStayPutDuringAvoidance = true; continue; } // Is the weight of this one higher than the current-highest weight? Then make this the new primary target! if (thisobj.Weight > iHighestWeightFound && thisobj.Weight > 0) { //Check combat looting (Demonbuddy Setting) if (iHighestWeightFound > 0 && thisobj.targetType.Value == TargetType.Item && !CharacterSettings.Instance.CombatLooting && CurrentTarget.targetType.Value == TargetType.Unit) continue; //cache RAGUID so we can switch back if we need to int CurrentTargetRAGUID = CurrentTarget != null ? CurrentTarget.RAGUID : -1; //Set our current target to this object! CurrentTarget = ObjectCache.Objects[thisobj.RAGUID]; bool resetTarget = false; if (!Bot.Character.Class.IsMeleeClass && CurrentTarget.targetType.Value == TargetType.Unit && Bot.Targeting.Cache.Environment.NearbyAvoidances.Count > 0) {//Ranged Class -- Unit -- with Nearby Avoidances.. //We are checking if this target is valid and will not cause avoidance triggering due to movement. //set unit target (for Ability selector). Bot.Targeting.Cache.CurrentUnitTarget = (CacheUnit)CurrentTarget; //Generate next Ability.. Skill nextAbility = Bot.Character.Class.AbilitySelector(Bot.Targeting.Cache.CurrentUnitTarget, Bot.Targeting.Cache.LastCachedTarget.targetType == TargetType.NoMovement); if (nextAbility == Bot.Character.Class.DefaultAttack && !Bot.Character.Class.CanUseDefaultAttack) {//No valid ability found Logger.Write(LogLevel.Target, "Could not find a valid ability for unit {0}", thisobj.InternalName); //if (thisobj.ObjectIsSpecial) // ObjectCache.Objects.objectsIgnoredDueToAvoidance.Add(thisobj); //else resetTarget = true; } else { Vector3 destination = nextAbility.DestinationVector; if (ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(Bot.Character.Data.Position, destination)) { //if (!thisobj.ObjectIsSpecial) // resetTarget = true; //else Bot.Targeting.Cache.objectsIgnoredDueToAvoidance.Add(thisobj); } } //reset unit target Bot.Targeting.Cache.CurrentUnitTarget = null; } //Avoidance Attempt to find a location where we can attack! if (Bot.Targeting.Cache.objectsIgnoredDueToAvoidance.Contains(thisobj)) { //Wait if no valid target found yet.. and no avoidance movement required. if (!Bot.Targeting.Cache.RequiresAvoidance) this.bStayPutDuringAvoidance = true; resetTarget = true; } if (resetTarget) { CurrentTarget = CurrentTargetRAGUID != -1 ? ObjectCache.Objects[CurrentTargetRAGUID] : null; continue; } iHighestWeightFound = thisobj.Weight; } } // Loop through all the objects and give them a weight }
///<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() { 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)) { Vector3 tmp_position; int tmp_acdguid; int tmp_SNOID; #region SNO //Lookup SNO try { tmp_SNOID = thisObj.ActorSNO; } catch (NullReferenceException) { //Logger.DBLog.InfoFormat("Failure to get SNO from object! RaGUID: {0}", tmp_raGUID); continue; } #endregion //check our SNO blacklist if (BlacklistCache.IsSNOIDBlacklisted(tmp_SNOID) && !CacheIDLookup.hashSummonedPets.Contains(tmp_SNOID)) continue; #region Position try { tmp_position = thisObj.Position; } catch (NullReferenceException) { //Logger.DBLog.InfoFormat("Failure to get position vector for RAGUID {0}", tmp_raGUID); continue; } #endregion #region AcdGUID try { tmp_acdguid = thisObj.ACDGuid; } catch (NullReferenceException) { //Logger.DBLog.InfoFormat("Failure to get ACDGUID for RAGUID {0}", tmp_raGUID); continue; } #endregion tmp_CachedObj = new CacheObject(tmp_SNOID, tmp_raGUID, tmp_acdguid, tmp_position); } else //Reset unseen var tmp_CachedObj.LoopsUnseen = 0; //Validate try { if (thisObj.CommonData == null || thisObj.CommonData.ACDGuid != thisObj.ACDGuid) continue; } catch (NullReferenceException) { continue; } //Check if this object is a summoned unit by a player... #region SummonedUnits if (tmp_CachedObj.IsSummonedPet) { // 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; } } //See if this summoned unit was summoned by the bot. if (Bot.Character.Data.iMyDynamicID == tmp_CachedObj.SummonerID.Value) { //Now modify the player data pets count.. if (Bot.Character.Class.AC == ActorClass.Monk) Bot.Character.Data.PetData.MysticAlly++; else if (Bot.Character.Class.AC == ActorClass.DemonHunter) { if (CacheIDLookup.hashDHPets.Contains(tmp_CachedObj.SNOID)) Bot.Character.Data.PetData.DemonHunterPet++; else if (CacheIDLookup.hashDHSpikeTraps.Contains(tmp_CachedObj.SNOID) && tmp_CachedObj.CentreDistance <= 50f) Bot.Character.Data.PetData.DemonHunterSpikeTraps++; } else if (Bot.Character.Class.AC == ActorClass.Witchdoctor) { if (CacheIDLookup.hashZombie.Contains(tmp_CachedObj.SNOID)) Bot.Character.Data.PetData.ZombieDogs++; else if (CacheIDLookup.hashGargantuan.Contains(tmp_CachedObj.SNOID)) Bot.Character.Data.PetData.Gargantuan++; } else if (Bot.Character.Class.AC == ActorClass.Wizard) { //only count when range is within 45f (so we can summon a new one) if (CacheIDLookup.hashWizHydras.Contains(tmp_CachedObj.SNOID) && tmp_CachedObj.CentreDistance <= 45f) Bot.Character.Data.PetData.WizardHydra++; } } //We return regardless if it was summoned by us or not since this object is not anything we want to deal with.. tmp_CachedObj.NeedsRemoved = true; continue; } #endregion //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 //Special Cache for Interactable Server Objects if (CheckTargetTypeFlag(tmp_CachedObj.targetType.Value, TargetType.ServerInteractable)) { if (!Bot.Game.Profile.InteractableObjectCache.ContainsKey(tmp_CachedObj.RAGUID)) { Bot.Game.Profile.InteractableObjectCache.Add(tmp_CachedObj.RAGUID, 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 (CheckTargetTypeFlag(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}", thisObstacle.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) { //Specific updates if (tmp_CachedObj.Actortype.Value == ActorType.Item) { tmp_CachedObj = new CacheItem(tmp_CachedObj); } else if (tmp_CachedObj.Actortype.Value == ActorType.Monster) { tmp_CachedObj = new CacheUnit(tmp_CachedObj); } else if (tmp_CachedObj.Actortype.Value == ActorType.Gizmo) { if (CheckTargetTypeFlag(tmp_CachedObj.targetType.Value, TargetType.Interactables)) tmp_CachedObj = new CacheInteractable(tmp_CachedObj); else tmp_CachedObj = new CacheDestructable(tmp_CachedObj); } //Update Properties tmp_CachedObj.UpdateProperties(); } if (!tmp_CachedObj.UpdateData()) { if (!tmp_CachedObj.IsStillValid()) tmp_CachedObj.NeedsRemoved = true; continue; } //Obstacle cache if (tmp_CachedObj.Obstacletype.Value != ObstacleType.None && (CheckTargetTypeFlag(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.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 && (CheckTargetTypeFlag(CO.targetType.Value, TargetType.Gold | TargetType.Globe)) && CO.LoopsUnseen > 0)))) //gold/globe only 1 loop! { item.NeedsRemoved = true; } } return true; }
public CacheGizmo(CacheObject baseobj) : base(baseobj) { }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (obj == null) { // See if we should wait for milliseconds for possible loot drops before continuing run if (DateTime.Now.Subtract(Bot.Targeting.Cache.lastHadUnitInSights).TotalMilliseconds <= Bot.Settings.AfterCombatDelay && DateTime.Now.Subtract(Bot.Targeting.Cache.lastHadEliteUnitInSights).TotalMilliseconds <= 10000 || //Cut the delay time in half for non-elite monsters! DateTime.Now.Subtract(Bot.Targeting.Cache.lastHadUnitInSights).TotalMilliseconds <= Bot.Settings.AfterCombatDelay) { obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "WaitForLootDrops", 2f, -1); return true; } //Herbfunks wait after loot containers are opened. 3s for rare chests, half the settings delay for everything else. if ((DateTime.Now.Subtract(Bot.Targeting.Cache.lastHadRareChestAsTarget).TotalMilliseconds <= 3750) || (DateTime.Now.Subtract(Bot.Targeting.Cache.lastHadContainerAsTarget).TotalMilliseconds <= (Bot.Settings.AfterCombatDelay * 1.25)) || (DateTime.Now.Subtract(Bot.Targeting.Cache.lastSeenCursedShrine).TotalMilliseconds <= (1000))) { obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "ContainerLootDropsWait", 2f, -1); return true; } if (DateTime.Now.Subtract(Bot.Targeting.Cache.lastSeenCursedShrine).TotalMilliseconds <= (1000)) { Bot.Targeting.Cache.UpdateQuestMonsterProperty = true; obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "CursedShrineWait", 2f, -1); return true; } else { Bot.Targeting.Cache.UpdateQuestMonsterProperty = false; } // Finally, a special check for waiting for wrath of the berserker cooldown before engaging Azmodan if (Bot.Character.Class.HotBar.HotbarPowers.Contains(SNOPower.Barbarian_WrathOfTheBerserker) && Bot.Settings.Class.bWaitForWrath && !Bot.Character.Class.Abilities[SNOPower.Barbarian_WrathOfTheBerserker].AbilityUseTimer() && Bot.Character.Data.iCurrentWorldID == 121214 && (Vector3.Distance(Bot.Character.Data.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(Bot.Character.Data.Position, new Vector3(546.8467f, 551.7733f, 1.576313f)) <= 40f)) { Logger.DBLog.InfoFormat("[Funky] Waiting for Wrath Of The Berserker cooldown before continuing to Azmodan."); obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "GilesWaitForWrath", 0f, -1); InactivityDetector.Reset(); return true; } // And a special check for wizard archon if (Bot.Character.Class.HotBar.HotbarPowers.Contains(SNOPower.Wizard_Archon) && !Bot.Character.Class.Abilities[SNOPower.Wizard_Archon].AbilityUseTimer() && Bot.Settings.Class.bWaitForArchon && ZetaDia.CurrentWorldId == 121214 && (Vector3.Distance(Bot.Character.Data.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(Bot.Character.Data.Position, new Vector3(546.8467f, 551.7733f, 1.576313f)) <= 40f)) { Logger.DBLog.InfoFormat("[Funky] Waiting for Wizard Archon cooldown before continuing to Azmodan."); obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "GilesWaitForArchon", 0f, -1); InactivityDetector.Reset(); return true; } // And a very sexy special check for WD BigBadVoodoo if (Bot.Character.Class.HotBar.HotbarPowers.Contains(SNOPower.Witchdoctor_BigBadVoodoo) && !PowerManager.CanCast(SNOPower.Witchdoctor_BigBadVoodoo) && ZetaDia.CurrentWorldId == 121214 && (Vector3.Distance(Bot.Character.Data.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(Bot.Character.Data.Position, new Vector3(546.8467f, 551.7733f, 1.576313f)) <= 40f)) { Logger.DBLog.InfoFormat("[Funky] Waiting for WD BigBadVoodoo cooldown before continuing to Azmodan."); obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "GilesWaitForVoodooo", 0f, -1); InactivityDetector.Reset(); return true; } //Currently preforming an interactive profile behavior (check if in town and not vendoring) if (Bot.Game.Profile.PreformingInteractiveBehavior && (!Bot.Character.Data.bIsInTown || !BrainBehavior.IsVendoring)) { if (Bot.Game.Profile.InteractableCachedObject.Position.Distance(Bot.Character.Data.Position) > 50f) { if (Bot.Targeting.Cache.LastCachedTarget.Position != Bot.Game.Profile.InteractableCachedObject.Position) Navigator.Clear(); //Generate the path here so we can start moving.. Navigation.NP.MoveTo(Bot.Game.Profile.InteractableCachedObject.Position, "ReturnToOOCLoc", true); //Setup a temp target that the handler will use obj = new CacheObject(Bot.Game.Profile.InteractableCachedObject.Position, TargetType.LineOfSight, 1d, "ReturnToOOCLoc", 10f, Bot.Game.Profile.InteractableCachedObject.RAGUID); return true; } } //Check if we engaged in combat.. bool EngagedInCombat = false; float distanceFromStart = 0f; if (Bot.Targeting.Cache.LastCachedTarget != ObjectCache.FakeCacheObject && !Bot.Targeting.Cache.Backtracking && Bot.Targeting.Cache.StartingLocation != Vector3.Zero) { EngagedInCombat = true; distanceFromStart = Bot.Character.Data.Position.Distance(Bot.Targeting.Cache.StartingLocation); //lets see how far we are from our starting location. if (distanceFromStart > 20f && !Navigation.CanRayCast(Bot.Character.Data.Position, Funky.PlayerMover.vLastMoveTo, UseSearchGridProvider: true)) { Logger.Write(LogLevel.Movement, "Updating Navigator in Target Refresh"); SkipAheadCache.ClearCache(); Navigator.Clear(); //Navigator.MoveTo(Funky.PlayerMover.vLastMoveTo, "original destination", true); } } //Check if our current path intersects avoidances. (When not in town, and not currently inside avoidance) if (!Bot.Character.Data.bIsInTown && (Bot.Settings.Avoidance.AttemptAvoidanceMovements || Bot.Character.Data.CriticalAvoidance) && Navigation.NP.CurrentPath.Count > 0 && Bot.Targeting.Cache.Environment.TriggeringAvoidances.Count == 0) { if (ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(Bot.Character.Data.Position, Navigation.NP.CurrentPath.Current)) { obj = new CacheObject(Bot.Character.Data.Position, TargetType.NoMovement, 20000, "AvoidanceIntersection", 2.5f, -1); return true; } } //Backtracking Check.. if (EngagedInCombat && Bot.Settings.Backtracking.EnableBacktracking && distanceFromStart >= Bot.Settings.Backtracking.MinimumDistanceFromStart) { Bot.Targeting.Cache.Backtracking = true; obj = new CacheObject(Bot.Targeting.Cache.StartingLocation, TargetType.Backtrack, 20000, "Backtracking", 2.5f); return true; } } return obj != null; }; }
///<summary> ///Tracks Current Profile Behavior and sets IsRunningOOCBehavior depending on the current Type of behavior. ///</summary> internal void CheckCurrentProfileBehavior() { if (DateTime.Now.Subtract(LastProfileBehaviorCheck).TotalMilliseconds > 450) { LastProfileBehaviorCheck = DateTime.Now; if (currentProfileBehavior == null || ProfileManager.CurrentProfileBehavior != null && ProfileManager.CurrentProfileBehavior.Behavior != null && currentProfileBehavior.Behavior.Guid != ProfileManager.CurrentProfileBehavior.Behavior.Guid) { currentProfileBehavior = ProfileManager.CurrentProfileBehavior; Logger.Write(LogLevel.Event, "Profile Behavior Changed To {0}", currentProfileBehavior.GetType().ToString()); Type profileTagType = currentProfileBehavior.GetType(); if (oocDBTags.Contains(profileTagType)) { if (InteractiveTags.Contains(profileTagType)) { ProfileBehaviorIsOOCInteractive = true; Logger.DBLog.DebugFormat("Interactable Profile Tag!"); InteractableCachedObject = GetInteractiveCachedObject(currentProfileBehavior); if (InteractableCachedObject != null) Logger.DBLog.DebugFormat("Found Cached Interactable Server Object"); } else { ProfileBehaviorIsOOCInteractive = false; InteractableCachedObject = null; } Logger.DBLog.DebugFormat("Current Profile Behavior has enabled OOC Behavior."); IsRunningOOCBehavior = true; } else { ProfileBehaviorIsOOCInteractive = false; InteractableCachedObject = null; IsRunningOOCBehavior = false; } } } }
public CacheDestructable(CacheObject baseobj) : base(baseobj) { }
internal void ResetTargetHandling() { CurrentTarget = null; StartingLocation = Vector3.Zero; bWaitingForPower = false; bWaitingAfterPower = false; bWaitingForPotion = false; bWasRootedLastTick = false; recheckCount = 0; reCheckedFinished = false; CheckItemLootStackCount = 0; Backtracking = false; }
public CacheUnit(CacheObject baseobj) : base(baseobj) { //update properties }
public TargetChangedArgs(CacheObject newobj, TargetBehavioralTypes sendingtype) { newObject = newobj; targetBehaviorUsed = sendingtype; }