public CacheAvoidance(CacheObject parent, AvoidanceType type, Ray R, double speed) : base(parent) { AvoidanceType = type; AvoidanceValue = FunkyBaseExtension.Settings.Avoidance.Avoidances[(int)type]; ray_ = R; Speed = speed; projectile_startPosition = base.Position; }
public override void Initialize() { this.Test = (ref CacheObject obj) => { //Resuse last safespot until timer expires! if (DateTime.Now.Subtract(FunkyGame.Targeting.Cache.LastFleeAction).TotalSeconds < this.iSecondsFleeMoveFor) { Vector3 reuseV3 = FunkyGame.Navigation.AttemptToReuseLastLocationFound(); if (reuseV3 != Vector3.Zero) { if (!ObjectCache.Objects.IsPointNearbyMonsters(reuseV3, FunkyBaseExtension.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 = FunkyGame.Targeting.Cache.LastCachedTarget.targetType.HasValue && FunkyGame.Targeting.Cache.LastCachedTarget.targetType.Value == TargetType.Unit && FunkyGame.Targeting.Cache.LastCachedTarget.ObjectIsValidForTargeting ? FunkyGame.Targeting.Cache.LastCachedTarget.Position : Vector3.Zero; PointCheckingFlags flags = FunkyBaseExtension.Settings.Plugin.FleeingFlags; if (FunkyGame.Hero.Class.HasCastableMovementAbility()) flags &= ~(PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.BlockedDirection); if (FunkyGame.Navigation.AttemptFindSafeSpot(out vAnySafePoint, LineOfSight, flags)) { float distance = vAnySafePoint.Distance(FunkyGame.Hero.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(FunkyBaseExtension.Settings.Fleeing.FailureRetryMilliseconds); } return false; }; }
public CacheAvoidance(CacheObject parent, AvoidanceType avoidancetype) : base(parent) { AvoidanceType = avoidancetype; AvoidanceValue = FunkyBaseExtension.Settings.Avoidance.Avoidances[(int)avoidancetype]; RefreshRemovalCounter = AvoidanceValue.RemovalSeconds; //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() { Test = (ref CacheObject obj) => { bStayPutDuringAvoidance = false; //cluster update FunkyGame.Targeting.Cache.Clusters.UpdateTargetClusteringVariables(); //Standard weighting of valid objects -- updates current target. WeightEvaluationObjList(ref obj); //Final Possible Target Check if (obj == null) { // No valid targets but we were told to stay put? if (bStayPutDuringAvoidance) { //Lets check our avoidance object list if (FunkyGame.Targeting.Cache.objectsIgnoredDueToAvoidance.Count > 0 && DateTime.Now.Subtract(lastAvoidanceConnectSearch).TotalMilliseconds > 2000) { Logger.DBLog.InfoFormat("Preforming Avoidance Connection Search on Potential Objects"); lastAvoidanceConnectSearch = DateTime.Now; foreach (var o in FunkyGame.Targeting.Cache.objectsIgnoredDueToAvoidance) { Vector3 safespot; if (FunkyGame.Navigation.AttemptFindSafeSpot(out safespot, o.BotMeleeVector, FunkyBaseExtension.Settings.Plugin.AvoidanceFlags)) { obj = new CacheObject(safespot, TargetType.Avoidance, 20000, "AvoidConnection", 2.5f, -1); return true; } } } if (FunkyGame.Targeting.Cache.Environment.TriggeringAvoidances.Count == 0) { obj = new CacheObject(FunkyGame.Hero.Position, TargetType.Avoidance, 20000, "StayPutPoint", 2.5f, -1); return true; } } } return false; }; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (FunkyGame.Hero.Position.Distance(FunkyGame.Targeting.Cache.StartingLocation) > FunkyBaseExtension.Settings.Backtracking.MinimumDistanceFromStart) { //Generate the path here so we can start moving.. Navigation.Navigation.NP.MoveTo(FunkyGame.Targeting.Cache.StartingLocation, "Backtracking", true); //Setup a temp target that the handler will use obj = new CacheObject(FunkyGame.Targeting.Cache.StartingLocation, TargetType.Backtrack, 20000, "Backtracking", FunkyBaseExtension.Settings.Backtracking.MinimumDistanceFromStart); return true; } FunkyGame.Targeting.Cache.Backtracking = false; return false; }; }
public CachePet(CacheObject parent, PetTypes type) : base(parent) { PetType = type; }
///<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) { //clear our last "avoid" list.. FunkyGame.Targeting.Cache.objectsIgnoredDueToAvoidance.Clear(); double iHighestWeightFound = 0; FunkyGame.Hero.Class.UpdateCastableAbilities(); foreach (CacheObject thisobj in FunkyGame.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 (!FunkyGame.Targeting.Cache.RequiresAvoidance) 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.HasValue && (thisobj.targetType.Value == TargetType.Item || thisobj.targetType.Value == TargetType.Gold)) && !CharacterSettings.Instance.CombatLooting && (CurrentTarget.targetType.HasValue && CurrentTarget.targetType.Value == TargetType.Unit)) continue; if (thisobj.targetType.HasValue && thisobj.targetType.Value == TargetType.Unit) { Skill nextAbility = FunkyGame.Hero.Class.AbilitySelector((CacheUnit)thisobj, FunkyGame.Targeting.Cache.Environment.TriggeringAvoidances.Count > 0); if (nextAbility.Equals(FunkyGame.Hero.Class.DefaultAttack) && !FunkyGame.Hero.Class.CanUseDefaultAttack) {//No valid ability found Logger.Write(LogLevel.Target, "Could not find a valid ability for unit {0}", thisobj.InternalName); continue; } //Should we check avoidances? if (FunkyGame.Targeting.Cache.Environment.NearbyAvoidances.Count > 0) { Vector3 destination = nextAbility.DestinationVector; if (destination.Equals(Vector3.Zero)) continue; if (ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(FunkyGame.Hero.Position, destination)) { FunkyGame.Targeting.Cache.objectsIgnoredDueToAvoidance.Add(thisobj); } } } //Avoidance Attempt to find a location where we can attack! if (FunkyGame.Targeting.Cache.objectsIgnoredDueToAvoidance.Contains(thisobj)) { //Wait if no valid target found yet.. and no avoidance movement required. if (!FunkyGame.Targeting.Cache.RequiresAvoidance) bStayPutDuringAvoidance = true; continue; } //Set our current target to this object! CurrentTarget = ObjectCache.Objects[thisobj.RAGUID]; iHighestWeightFound = thisobj.Weight; } } // Loop through all the objects and give them a weight }
public CacheUnit(CacheObject baseobj) : base(baseobj) { //update properties }
internal static RunStatus Behavior() { if (ZetaDia.IsLoadingWorld) return RunStatus.Running; if (FunkyGame.GameIsInvalid) return RunStatus.Success; FunkyGame.Hero.Update(false,true); //Are we inside goblin world? if (FunkyGame.Hero.CurrentWorldID != 409093 && FunkyGame.Hero.CurrentWorldID != 379962 && FunkyGame.Hero.CurrentWorldID != 380774) { //Already Loaded Profile? if (LoadedGoblinProfile) { ProfileManager.Load(LastUsedProfile); ProfileManager.UpdateCurrentProfileBehavior(); LoadedGoblinProfile = false; LastUsedProfile = String.Empty; BehaviorEngaged = false; BlacklistedRAGUIDs.Add(Portal.RAGUID); Portal = null; Logger.DBLog.Info("Finished Running Goblin World!"); return RunStatus.Success; } if (Portal == null) { Logger.DBLog.Info("Portal is null!"); BehaviorEngaged = false; return RunStatus.Success; } if (Portal.WorldID!=FunkyGame.Hero.CurrentWorldID) { Logger.DBLog.InfoFormat("Portal World ID Mismatched! Portal {0} Hero {1}", Portal.WorldID, FunkyGame.Hero.CurrentWorldID); //Not in the same world as portal object! Portal = null; BehaviorEngaged = false; return RunStatus.Success; } else { //Move to portal.. //Handle Targeting.. if (FunkyGame.Targeting.CheckHandleTarget() == RunStatus.Running) return RunStatus.Running; if (Portal.CentreDistance>10f) { Logger.DBLog.Info("Moving To Portal!"); Navigation.Navigation.NP.MoveTo(Portal.Position, "", true); return RunStatus.Running; } else { if (Portal.IsStillValid()) { if (!delayer.Test()) return RunStatus.Running; Logger.DBLog.Info("At Portal!"); Portal.ref_DiaObject.Interact(); return RunStatus.Running; } else { Logger.DBLog.Info("Portal No Longer Valid!"); return RunStatus.Running; } } } } else { Logger.DBLog.Info("Inside Goblin World!"); if (!ProfileManager.CurrentProfile.Path.Contains(FolderPaths.PluginPath + @"\Behaviors\Profiles\")) { Logger.DBLog.Info("Loading Profile.."); LastUsedProfile = ProfileManager.CurrentProfile.Path; if (FunkyGame.Hero.CurrentWorldID == 409093) { ProfileManager.Load(FolderPaths.PluginPath + @"\Behaviors\Profiles\Goblin_Whimsydale.xml"); ProfileManager.UpdateCurrentProfileBehavior(); LoadedGoblinProfile = true; } if (FunkyGame.Hero.CurrentWorldID == 379962) { Logger.DBLog.Info("Profile for world 379962 not supported!"); } if (FunkyGame.Hero.CurrentWorldID == 380774) { Logger.DBLog.Info("Profile for world 380774 not supported!"); } } return RunStatus.Success; } return RunStatus.Running; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (obj == null) { // Cursed Events that have had interaction with a cursed object in the last nth time frame we check for completed bounty. // Kill/Clear Events that are on the last area level we check for completed bounty. if ((FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyTypes.CursedEvent && DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastSeenCursedShrine).TotalSeconds < 45)) //|| ((FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyQuestTypes.Kill || FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyQuestTypes.Clear) //&& FunkyGame.Hero.iCurrentLevelID == FunkyGame.Bounty.CurrentBountyCacheEntry.EndingLevelAreaID)) { FunkyGame.Bounty.ActiveBounty.Refresh(); //Check Current Quest State! if (FunkyGame.Bounty.ActiveBounty.State == QuestState.Completed) { Logger.DBLog.Info("Bounty Is Finished.. Reloading Profile!!!"); //Refresh Active Bounty to Verify there is no active bounty still! //FunkyGame.Bounty.UpdateActiveBounty(); //if (FunkyGame.Bounty.ActiveBounty == null) //{ // //No Active Bounty.. lets reload profile! // Zeta.Bot.ProfileManager.Load(Zeta.Bot.ProfileManager.CurrentProfile.Path); //} } } else if (FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyTypes.Event) { FunkyGame.Bounty.RefreshBountyQuestStates(); FunkyGame.Bounty.RefreshActiveQuests(); if (FunkyGame.Bounty.BountyQuestStates[FunkyGame.Bounty.ActiveBounty.QuestSNO] == QuestState.InProgress) { //Check interactive object cache.. if (ObjectCache.InteractableObjectCache.Values.Any(o => o.targetType.HasValue && o.targetType.Value == TargetType.Interaction && o.CentreDistance < 75f)) { Logger.DBLog.Info("Quest Giver Nearby!"); var interactableObj = ObjectCache.InteractableObjectCache.Values.First(o => o.targetType.HasValue && o.targetType.Value == TargetType.Interaction && o.CentreDistance < 75f); if (!interactableObj.LineOfSight.LOSTest(FunkyGame.Hero.Position, interactableObj.BotMeleeVector)) { if (interactableObj.CentreDistance > 25f) { FunkyGame.Targeting.Cache.Environment.LoSMovementObjects.Add(interactableObj); FunkyGame.Navigation.LOSmovementObject = new CacheLineOfSight(interactableObj, interactableObj.Position); Navigation.Navigation.NP.MoveTo(FunkyGame.Navigation.LOSmovementObject.Position, "LOS", true); obj = new CacheObject(FunkyGame.Navigation.LOSmovementObject.Position, TargetType.LineOfSight, 1d, "LOS Movement", Navigation.Navigation.NP.PathPrecision); return true; } } else if (interactableObj.CentreDistance < 25f) { CacheUnit interactableUnit = (CacheUnit)interactableObj; if (interactableUnit.IsQuestGiver) { obj = interactableObj; return true; } } } if (FunkyGame.Bounty.CurrentBountyMapMarkers.Count > 0) { //Check map marker.. foreach (var mapmarker in FunkyGame.Bounty.CurrentBountyMapMarkers.Values) { if (mapmarker.WorldID != FunkyGame.Hero.CurrentWorldDynamicID) continue; //Check Distance var DistanceFromMarker = mapmarker.Position.Distance(FunkyGame.Hero.Position); if (DistanceFromMarker < 25f) { obj = new CacheObject(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "EventWait", 2f, -1); return true; } if (DistanceFromMarker < 100f && DistanceFromMarker > 25f) { Logger.DBLog.Info("Event Marker Nearby!"); FunkyGame.Bounty.RefreshActiveQuests(); obj = new CacheObject(mapmarker.Position, TargetType.LineOfSight, 20000, "Marker", 2f, -1); return true; } } } } else if (FunkyGame.Bounty.BountyQuestStates[FunkyGame.Bounty.ActiveBounty.QuestSNO]==QuestState.Completed) {//Bounty is Completed.. } } } return false; }; }
public Vector3 FindLocationBehindObject(CacheObject obj) { float rotation=FindDirection(FunkyGame.Hero.Position, obj.Position, true); Vector3 startLocation=MathEx.GetPointAt(obj.Position, obj.Radius, rotation); DirectionPoint dp = new DirectionPoint(startLocation, rotation, 35f); LocationalRects.Add(new GPRectangle(dp)); DirectionPoint dp2 = new DirectionPoint(startLocation, MathEx.WrapAngle(rotation + 0.7f), 35f); LocationalRects.Add(new GPRectangle(dp2)); DirectionPoint dp3 = new DirectionPoint(startLocation, MathEx.WrapAngle(rotation - 0.7f), 35f); LocationalRects.Add(new GPRectangle(dp3)); List<GridPoint> blacklisted = new List<GridPoint>(); Vector3 safespot=Vector3.Zero; foreach (var gpr in LocationalRects) { bool found=gpr.TryFindSafeSpot(FunkyGame.Hero.Position, out safespot, Vector3.Zero, PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.RaycastWalkable, blacklisted); if (found) { break; } } return safespot; }
public void UpdateOrginObject() { if (CacheContainsOrginObject()) { if (IgnoringCacheCheck) { Position = FunkyGame.Bounty.CurrentBountyMapMarkers[OrginCacheObjectRAGUID].Position; } else { OrginCacheObject = ObjectCache.Objects[OrginCacheObjectRAGUID]; Position = OrginCacheObject.Position; } } }
private void UpdateObject() { if (ObjectCache.ShouldUpdateObjectCollection) ObjectCache.UpdateCacheObjectCollection(); if (CurrentObject==null) { var objs = ObjectCache.Objects.Values.Where(o => o.SNOID == SNO).ToList(); if (objs.Count == 0) { return; //if (FunkyGame.Targeting.Cache.Environment.LoSMovementObjects.Count > 0) //{ // objs = FunkyGame.Targeting.Cache.Environment.LoSMovementObjects.Where(o => o.SNOID == SNO).ToList(); // if (objs.Count == 0) return; //} } CurrentObject = objs.FirstOrDefault(); } }
// ///<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 CacheLineOfSight(CacheObject obj, Vector3 pos) { OrginCacheObject = obj; OrginCacheObjectRAGUID = obj.RAGUID; Position = pos; }
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(FunkyGame.Targeting.Cache.lastHadUnitInSights).TotalMilliseconds <= FunkyBaseExtension.Settings.General.AfterCombatDelay && DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastHadEliteUnitInSights).TotalMilliseconds <= 10000 || //Cut the delay time in half for non-elite monsters! DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastHadUnitInSights).TotalMilliseconds <= FunkyBaseExtension.Settings.General.AfterCombatDelay) { obj = new CacheObject(FunkyGame.Hero.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(FunkyGame.Targeting.Cache.lastHadRareChestAsTarget).TotalMilliseconds <= 3750) || (DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastHadContainerAsTarget).TotalMilliseconds <= (FunkyBaseExtension.Settings.General.AfterCombatDelay * 1.25))) { obj = new CacheObject(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "ContainerLootDropsWait", 2f, -1); return true; } if (DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastSeenCursedShrine).TotalMilliseconds <= (1000)) { if (FunkyGame.AdventureMode && SettingAdventureMode.AdventureModeSettingsTag.AllowCombatModifications && FunkyGame.Bounty.CurrentBountyCacheEntry != null && FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyTypes.CursedEvent) { Logger.DBLog.Info("[Funky] Cursed Object Found During Cursed Bounty -- Enabling LOS movement for all Units!"); SettingLOSMovement.LOSSettingsTag.MiniumRangeObjects = 10; SettingLOSMovement.LOSSettingsTag.MaximumRange = 125; FunkyGame.Game.AllowAnyUnitForLOSMovement = true; SettingCluster.ClusterSettingsTag = SettingCluster.DisabledClustering; } obj = new CacheObject(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "CursedShrineWait", 2f, -1); return true; } if (DateTime.Now.Subtract(FunkyGame.Targeting.Cache.lastHadSwitchAsTarget).TotalMilliseconds <= (4000)) { obj = new CacheObject(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "SwitchWait", 2f, -1); return true; } // Finally, a special check for waiting for wrath of the berserker cooldown before engaging Azmodan if (Hotbar.HasPower(SNOPower.Barbarian_WrathOfTheBerserker) && FunkyBaseExtension.Settings.Barbarian.bWaitForWrath && !FunkyGame.Hero.Class.Abilities[SNOPower.Barbarian_WrathOfTheBerserker].AbilityUseTimer() && FunkyGame.Hero.CurrentWorldDynamicID == 121214 && (Vector3.Distance(FunkyGame.Hero.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(FunkyGame.Hero.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(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "GilesWaitForWrath", 0f, -1); InactivityDetector.Reset(); return true; } // And a special check for wizard archon if (Hotbar.HasPower(SNOPower.Wizard_Archon) && !FunkyGame.Hero.Class.Abilities[SNOPower.Wizard_Archon].AbilityUseTimer() && FunkyBaseExtension.Settings.Wizard.bWaitForArchon && ZetaDia.CurrentWorldId == 121214 && (Vector3.Distance(FunkyGame.Hero.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(FunkyGame.Hero.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(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "GilesWaitForArchon", 0f, -1); InactivityDetector.Reset(); return true; } // And a very sexy special check for WD BigBadVoodoo if (Hotbar.HasPower(SNOPower.Witchdoctor_BigBadVoodoo) && !PowerManager.CanCast(SNOPower.Witchdoctor_BigBadVoodoo) && ZetaDia.CurrentWorldId == 121214 && (Vector3.Distance(FunkyGame.Hero.Position, new Vector3(711.25f, 716.25f, 80.13903f)) <= 40f || Vector3.Distance(FunkyGame.Hero.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(FunkyGame.Hero.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 (FunkyGame.Game.InteractableCachedObject != null && (!FunkyGame.Hero.bIsInTown || !BrainBehavior.IsVendoring)) { if (FunkyGame.Game.InteractableCachedObject.Position.Distance(FunkyGame.Hero.Position) > 50f) { //if (FunkyGame.Targeting.Cache.LastCachedTarget.Position != Bot.Game.Profile.InteractableCachedObject.Position) // Navigator.Clear(); //Generate the path here so we can start moving.. Navigation.Navigation.NP.MoveTo(FunkyGame.Game.InteractableCachedObject.Position, "ReturnToOOCLoc", true); //Setup a temp target that the handler will use obj = new CacheObject(FunkyGame.Game.InteractableCachedObject.Position, TargetType.LineOfSight, 1d, "ReturnToOOCLoc", 10f, FunkyGame.Game.InteractableCachedObject.RAGUID); return true; } } //Check if we engaged in combat.. bool EngagedInCombat = false; float distanceFromStart = 0f; if (!FunkyGame.Targeting.Cache.LastCachedTarget.Equals(ObjectCache.FakeCacheObject) && !FunkyGame.Targeting.Cache.Backtracking && FunkyGame.Targeting.Cache.StartingLocation != Vector3.Zero) { EngagedInCombat = true; distanceFromStart = FunkyGame.Hero.Position.Distance(FunkyGame.Targeting.Cache.StartingLocation); //lets see how far we are from our starting location. if (distanceFromStart > 20f && !Navigation.Navigation.CanRayCast(FunkyGame.Hero.Position, 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 (!FunkyGame.Hero.bIsInTown && (FunkyBaseExtension.Settings.Avoidance.AttemptAvoidanceMovements) //|| FunkyGame.Hero.CriticalAvoidance) && Navigation.Navigation.NP.CurrentPath.Count > 0 && FunkyGame.Targeting.Cache.Environment.TriggeringAvoidances.Count == 0) { if (ObjectCache.Obstacles.TestVectorAgainstAvoidanceZones(FunkyGame.Hero.Position, Navigation.Navigation.NP.CurrentPath.Current)) { obj = new CacheObject(FunkyGame.Hero.Position, TargetType.NoMovement, 20000, "AvoidanceIntersection", 2.5f, -1); return true; } } //Backtracking Check.. if (EngagedInCombat && FunkyBaseExtension.Settings.Backtracking.EnableBacktracking && distanceFromStart >= FunkyBaseExtension.Settings.Backtracking.MinimumDistanceFromStart) { FunkyGame.Targeting.Cache.Backtracking = true; obj = new CacheObject(FunkyGame.Targeting.Cache.StartingLocation, TargetType.Backtrack, 20000, "Backtracking", 2.5f); return true; } } return obj != null; }; }
public CacheInteractable(CacheObject baseobj) : base(baseobj) { }
private void OnObjectAdded(CacheObject obj) { if (obj.SNOID == Sno) { _ConditionSuccessSkip = false; ObjectCache.Objects.OnObjectAddedToCollection -= OnObjectAdded; Logger.DBLog.DebugFormat("WhileActorExists Object {0} Added to Collection!", Sno); } }
public CacheDestructable(CacheObject baseobj) : base(baseobj) { }
public override void ResetCachedDone() { _isDone = false; _lastGeneratedNavPoint = DateTime.MinValue; _lastMoveResult = MoveResult.Moved; _tagStartTime = DateTime.MinValue; CurrentObject = null; }
public CacheServerObject(CacheObject parent) : base(parent) { //if (IsDemonicForge) //{ // UpdateRotation(); // FacingStartVector3 = MathEx.GetPointAt(Position, 15f, Rotation); // FacingEndVector3 = MathEx.GetPointAt(FacingStartVector3, 30f, Rotation); //} }
public CacheItem(CacheObject baseobj) : base(baseobj) { }
if (ObjectCache.Objects.ContainsKey(raguid)) ObjectCache.Objects.Remove(raguid); } } 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! BlacklistSnoIDs.Add(sno); if (removal) { //Clear SNO cache entries.. ObjectCache.cacheSnoCollection.Remove(sno);
public CacheGizmo(CacheObject baseobj) : base(baseobj) { }
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 LOSInfo(CacheObject obj) { Obj=obj; }
private bool UpdateObject() { if (ObjectCache.ShouldUpdateObjectCollection) ObjectCache.UpdateCacheObjectCollection(); Object = ObjectCache.Objects.Values.FirstOrDefault(o => o.SNOID == Sno); if (Object != null) MovementVector = Object.Position; return Object != null; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (obj == null) { if (FunkyGame.Navigation.LOSmovementObject != null && (FunkyGame.Navigation.LOSmovementObject.CentreDistance < MinimumDistance && (FunkyGame.Navigation.LOSmovementObject.IgnoringCacheCheck || !FunkyGame.Navigation.LOSmovementObject.CacheContainsOrginObject()))) {//Invalidated the Line of sight obj! Logger.Write(LogLevel.LineOfSight, "LOS Object is No Longer Valid -- Reseting."); if (!FunkyGame.Navigation.LOSmovementObject.IgnoringCacheCheck || (FunkyGame.Bounty.CurrentBountyCacheEntry == null || FunkyGame.Bounty.CurrentBountyCacheEntry.Type != BountyTypes.Event)) { FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Add(FunkyGame.Navigation.LOSmovementObject.OrginCacheObjectRAGUID); } FunkyGame.Navigation.LOSmovementObject = null; if (FunkyGame.Targeting.Cache.LastCachedTarget.targetType.HasValue && FunkyGame.Targeting.Cache.LastCachedTarget.targetType.Value == TargetType.LineOfSight) Navigation.Navigation.NP.Clear(); } if (FunkyGame.Navigation.LOSmovementObject == null) {//New LOS Movement Selection. FunkyGame.Targeting.Cache.Environment.LoSMovementObjects = FunkyGame.Targeting.Cache.Environment.LoSMovementObjects.OrderBy(o => o.CentreDistance).ToList(); //Iterate Objects! foreach (var cobj in FunkyGame.Targeting.Cache.Environment.LoSMovementObjects) { if (FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Contains(cobj.RAGUID)) continue; if (!Navigation.Navigation.NP.CanFullyClientPathTo(cobj.Position) && !Navigation.Navigation.NP.CanPathWithinDistance(cobj.Position, SettingLOSMovement.LOSSettingsTag.MiniumRangeObjects)) continue; Logger.Write(LogLevel.LineOfSight, "Line of Sight Started for object {0} -- with {1} vectors\r\n{2}", cobj.InternalName, Navigation.Navigation.NP.CurrentPath.Count, cobj.DebugString); FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Add(cobj.RAGUID); //Set the object FunkyGame.Navigation.LOSmovementObject = new CacheLineOfSight(cobj, cobj.Position); if (cobj.IsBurrowableUnit || cobj.IsStealthableUnit || cobj.IsWormBoss) MinimumDistance = 10; else MinimumDistance = FunkyBaseExtension.Settings.LOSMovement.MiniumRangeObjects; break; } //Check if we still found nothing and game mode is adventure mode if (FunkyGame.Navigation.LOSmovementObject == null && FunkyGame.AdventureMode && FunkyGame.Game.ShouldNavigatePointsOfInterest && FunkyGame.Bounty.ActiveBounty != null && FunkyGame.Bounty.CurrentBountyMapMarkers.Count > 0) { FunkyGame.Bounty.ActiveBounty.Refresh(); if (FunkyGame.Bounty.ActiveBounty.State == QuestState.InProgress) {//Lets make sure the bounty is not completed. foreach (var mapmarker in FunkyGame.Bounty.CurrentBountyMapMarkers.Values) { if (mapmarker.WorldID != FunkyGame.Hero.CurrentWorldDynamicID) continue; if (FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Contains(mapmarker.GetHashCode())) continue; if (mapmarker.Distance > 750f || mapmarker.Distance < 25f) continue; if (!Navigation.Navigation.NP.CanFullyClientPathTo(mapmarker.Position) && !Navigation.Navigation.NP.CanPathWithinDistance(mapmarker.Position, SettingLOSMovement.LOSSettingsTag.MinimumRangeMarkers)) continue; Logger.Write(LogLevel.LineOfSight, "Line of Sight Started for Map Marker with {0} vectors", Navigation.Navigation.NP.CurrentPath.Count); if (FunkyGame.Bounty.CurrentBountyCacheEntry == null || FunkyGame.Bounty.CurrentBountyCacheEntry.Type != BountyTypes.Event) FunkyGame.Navigation.LOSBlacklistedRAGUIDs.Add(mapmarker.GetHashCode()); //Set the object FunkyGame.Navigation.LOSmovementObject = new CacheLineOfSight(mapmarker); MinimumDistance = FunkyBaseExtension.Settings.LOSMovement.MinimumRangeMarkers; } } } } if (FunkyGame.Navigation.LOSmovementObject != null) {//Line of Sight unit is valid //See if the orgin object is still valid.. //min Distance for Map Markers is 25f if (FunkyGame.Navigation.LOSmovementObject.CentreDistance < (MinimumDistance)) { if (!FunkyGame.Navigation.LOSmovementObject.CacheContainsOrginObject()) { Logger.Write(LogLevel.LineOfSight, "Line of Sight Ending due to Orgin Object No Longer Available!"); FunkyGame.Navigation.LOSmovementObject = null; return false; } if (!FunkyGame.Navigation.LOSmovementObject.IsValidForTargeting()) {//Valid for Targeting? Logger.Write(LogLevel.LineOfSight, "Line of Sight Ending due to Orgin Object Not Valid for Targeting!"); FunkyGame.Navigation.LOSmovementObject = null; return false; } //Minimap Marker Check if (FunkyGame.Navigation.LOSmovementObject.IgnoringCacheCheck && FunkyGame.Bounty.CurrentBountyCacheEntry != null && FunkyGame.Bounty.CurrentBountyCacheEntry.Type == BountyTypes.Event) //FunkyGame.Bounty.CurrentActCache!=null && { FunkyGame.Bounty.RefreshActiveQuests(); } //Update Position using Orgin Object? FunkyGame.Navigation.LOSmovementObject.UpdateOrginObject(); } //If we had a different target.. chances are we moved, so lets reset the path. if (FunkyGame.Targeting.Cache.LastCachedTarget.targetType.HasValue && FunkyGame.Targeting.Cache.LastCachedTarget.targetType.Value != TargetType.LineOfSight) { Navigation.Navigation.NP.Clear(); } Navigation.Navigation.NP.MoveTo(FunkyGame.Navigation.LOSmovementObject.Position, "LOS", true); if (Navigation.Navigation.NP.CurrentPath.Count > 0) { //Setup a temp target that the handler will use obj = new CacheObject(FunkyGame.Navigation.LOSmovementObject.Position, TargetType.LineOfSight, 1d, "LOS Movement", Navigation.Navigation.NP.PathPrecision); return true; } } } return false; }; }
///<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); }
///<summary> /// ///</summary> public CacheObstacle(CacheObject fromObj) : base(fromObj) { if (!Obstacletype.HasValue) Obstacletype = ObstacleType.None; }
public override void Initialize() { base.Test = (ref CacheObject obj) => { if (fBaseXtensions.FunkyBaseExtension.Settings.Logging.LogFlags.HasFlag(LogLevel.Movement)) { string avoidances = ""; FunkyGame.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(FunkyGame.Targeting.Cache.LastAvoidanceMovement).TotalSeconds < this.iSecondsAvoidMoveFor) { Vector3 reuseV3 = FunkyGame.Navigation.AttemptToReuseLastLocationFound(); if (reuseV3 != Vector3.Zero) { if (!ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(reuseV3)) { obj = new CacheObject(reuseV3, TargetType.Avoidance, 20000f, "SafeReuseAvoid", 2.5f, reuseV3.GetHashCode()); return true; } } } Vector3 vAnySafePoint; //Check if we have any movement abilities we can cast.. if so lets not check avoidance intersections. PointCheckingFlags flags = FunkyBaseExtension.Settings.Plugin.AvoidanceFlags; if (FunkyGame.Hero.Class.HasCastableMovementAbility()) flags &= ~(PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.BlockedDirection); Vector3 losVector3=Vector3.Zero; if (FunkyGame.Targeting.Cache.LastCachedTarget.targetType != null && FunkyGame.Targeting.Cache.LastCachedTarget.targetType.Value == TargetType.Unit) { losVector3=FunkyGame.Targeting.Cache.LastCachedTarget.Position; } if (FunkyGame.Navigation.AttemptFindSafeSpot(out vAnySafePoint, losVector3, flags)) { float distance = vAnySafePoint.Distance(FunkyGame.Hero.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, vAnySafePoint.GetHashCode()); //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(FunkyBaseExtension.Settings.Avoidance.FailureRetryMilliseconds); } return false; }; }
public LOSInfo(CacheObject obj) { Obj = obj; }