Exemple #1
0
        private void iterateGPRectsSafeSpot(Vector3 CurrentPosition, out Vector3 safespot, Vector3 LOS, PointCheckingFlags Flags)
        {
            //blacklisted a point?.. we advance to next index!
            if (BlacklistedPoint)
            {
                lastGPRectIndexUsed++;
                BlacklistedPoint = false;
            }

            GPRectangle PositionRect = GetGPRectContainingPoint(CurrentPosition);

            if (PositionRect != null)
            {
                PositionRect.UpdateObjectCount();
            }

            GPQuadrant PositionQuadrant = PositionRect.GetQuadrantContainingPoint(CurrentPosition);
            double     CompareWeight    = PositionQuadrant != null ? PositionQuadrant.ThisWeight : PositionRect != null ? PositionRect.Weight : 0;

            safespot = Vector3.Zero;
            for (int i = lastGPRectIndexUsed; i < gridpointrectangles_.Count - 1; i++)
            {
                GPRectangle item = gridpointrectangles_[i];

                item.UpdateObjectCount(AllGPRectsFailed);

                if (item.TryFindSafeSpot(CurrentPosition, out safespot, LOS, Flags, BlacklistedGridpoints, AllGPRectsFailed, CompareWeight))
                {
                    lastUsedGPRect = gridpointrectangles_[i];
                    return;
                }
            }
            lastGPRectIndexUsed = 0;
        }
Exemple #2
0
        public GPArea(Vector3 startingLocation)
        {
            //Creation and Cache base
            centerGPRect = new GPRectangle(startingLocation, 5);
            GPRectangle centerClone = centerGPRect.Clone();

            //Get all valid points (besides current point) from our current location GPR
            GridPoint[] SearchPoints = centerGPRect.Points.Keys.Where(gp => !gp.Ignored).ToArray();
            gridpointrectangles_ = new List <GPRectangle>();
            if (SearchPoints.Length > 1)
            {
                Vector3 LastSearchVector3 = Bot.NavigationCache.LastSearchVector;
                // LastSearchVector3.Normalize();

                //we should check our surrounding points to see if we can even move into any of them first!
                for (int i = 1; i < SearchPoints.Length - 1; i++)
                {
                    GridPoint curGP  = SearchPoints[i];
                    Vector3   thisV3 = (Vector3)curGP;
                    //thisV3.Normalize();

                    //Its a valid point for direction testing!
                    float          DirectionDegrees = Navigation.FindDirection(LastSearchVector3, thisV3);
                    DirectionPoint P = new DirectionPoint((Vector3)curGP, DirectionDegrees, 125f);

                    if (P.Range > 5f)
                    {
                        gridpointrectangles_.Add(new GPRectangle(P, centerGPRect));
                    }
                }
                gridpointrectangles_.Add(centerClone);
                gridpointrectangles_ = gridpointrectangles_.OrderByDescending(gpr => gpr.Count).ToList();
            }
        }
Exemple #3
0
        public GPArea(Vector3 startingLocation)
        {
            //Creation and Cache base
            centerGPRect = new GPRectangle(startingLocation, 5);
            GPRectangle centerClone = centerGPRect.Clone();

            //Get all valid points (besides current point) from our current location GPR
            GridPoint[] SearchPoints = centerGPRect.Points.Keys.Where(gp => !gp.Ignored).ToArray();
            gridpointrectangles_ = new List<GPRectangle>();
            if (SearchPoints.Length > 1)
            {
                Vector3 LastSearchVector3 = Bot.NavigationCache.LastSearchVector;
                // LastSearchVector3.Normalize();

                //we should check our surrounding points to see if we can even move into any of them first!
                for (int i = 1; i < SearchPoints.Length - 1; i++)
                {
                    GridPoint curGP = SearchPoints[i];
                    Vector3 thisV3 = (Vector3)curGP;
                    //thisV3.Normalize();

                    //Its a valid point for direction testing!
                    float DirectionDegrees = Navigation.FindDirection(LastSearchVector3, thisV3);
                    DirectionPoint P = new DirectionPoint((Vector3)curGP, DirectionDegrees, 125f);

                    if (P.Range > 5f)
                    {
                        gridpointrectangles_.Add(new GPRectangle(P, centerGPRect));
                    }
                }
                gridpointrectangles_.Add(centerClone);
                gridpointrectangles_ = gridpointrectangles_.OrderByDescending(gpr => gpr.Count).ToList();
            }
        }
Exemple #4
0
 public GPRectangle(GPRectangle clone)
     : base(clone)
 {
     base.CornerPoints      = clone.CornerPoints;
     this.Quadrant          = clone.Quadrant;
     this.CreationVector    = clone.CreationVector;
     this.searchablepoints_ = clone.searchablepoints_;
 }
Exemple #5
0
 public override bool Equals(object obj)
 {
     //Check for null and compare run-time types.
     if (obj == null || this.GetType() != obj.GetType())
     {
         return(false);
     }
     else
     {
         GPRectangle p = (GPRectangle)obj;
         return(CreationVector.Equals(p.CreationVector));
     }
 }
Exemple #6
0
        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;
            };
        }
Exemple #7
0
        ///<summary>
        ///Checks if the position is total blocked from adjacent movements either by objects or non navigation
        ///</summary>
        private bool IsVectorBlocked(Vector3 location)
        {
            //Reset Navigationally Blocked GPs
            LastNavigationBlockedPoints = new List <GridPoint>();

            //Create Local GPRect!
            if (LastUsedBlockCheckGPRect == null || LastUsedBlockCheckGPRect.centerpoint != (GridPoint)location)
            {
                //Clear lists
                LastObjectblockCounter.Clear();
                LastObjectOccupiedGridPoints.Clear();
                LastUsedBlockCheckGPRect = new GPRectangle(location);
            }

            if (LastUsedBlockCheckGPRect.Count == 0)
            {
                //Logger.DBLog.DebugFormat("Current Location GP Rect has no valid Grid Points!");
                return(false);
            }

            GridPoint[]      CurrentLocationGridPoints = LastUsedBlockCheckGPRect.Keys.ToArray();
            List <GridPoint> SurroundingPoints         = new List <GridPoint>();
            int SurroundingMaxCount = LastUsedBlockCheckGPRect.Count >= 8 ? 8 : LastUsedBlockCheckGPRect.Count;

            for (int i = 0; i < SurroundingMaxCount; i++)
            {
                GridPoint gp = CurrentLocationGridPoints[i];
                if (!gp.Ignored)
                {
                    SurroundingPoints.Add(gp);
                }
                else
                {
                    LastNavigationBlockedPoints.Add(gp);
                }
            }

            List <int> NearbyObjectRAGUIDs         = new List <int>();
            List <CacheServerObject> NearbyObjects = Bot.Targeting.Cache.Environment.NearbyObstacleObjects.Where(obj => obj.RadiusDistance <= 6f).ToList();           //ObjectCache.Obstacles.Navigations.Where(obj => obj.RadiusDistance<=5f).ToList();

            //no nearby objects passed distance check..
            if (NearbyObjects.Count == 0)
            {
                //Clear list, and return pure navigational check (Zero means we are completely stuck in a non-navigable location?)
                LastObjectblockCounter.Clear();
                LastObjectOccupiedGridPoints.Clear();

                //Logger.DBLog.InfoFormat("Current Location Point has {0} usable points (NoNewObjs)", SurroundingPoints.Count);

                return(SurroundingPoints.Count == 0);
            }

            //Update ObjectBlockCounter Collection
            if (LastObjectblockCounter.Count > 0)
            {
                //Add current nearby object RAGUIDs to collection
                NearbyObjectRAGUIDs.AddRange((from objs in NearbyObjects
                                              select objs.RAGUID).ToArray());

                //Generate Removal List for ObjectBlockCounter Collections
                List <int> RemovalRAGUIDList = (from raguids in LastObjectblockCounter.Keys
                                                where !NearbyObjectRAGUIDs.Contains(raguids)
                                                select raguids).ToList();

                //Removal
                foreach (var item in RemovalRAGUIDList)
                {
                    LastObjectblockCounter.Remove(item);
                    LastObjectOccupiedGridPoints.Remove(item);
                }
            }

            //Check any exisiting block entries
            if (LastObjectblockCounter.Count > 0)
            {
                foreach (var item in LastObjectOccupiedGridPoints.Values)
                {
                    LastNavigationBlockedPoints.AddRange(item);
                }

                //Update Surrounding Points
                SurroundingPoints = SurroundingPoints.Except(LastNavigationBlockedPoints).ToList();

                if (SurroundingPoints.Count == 0)
                {
                    //Logger.DBLog.InfoFormat("NavBlocked -- No available surrounding points.");

                    return(true);
                }
            }

            //Generate new object list that contains objects that are not already accounted for
            List <CacheServerObject> NewObjects = NearbyObjects.Where(obj => !LastObjectblockCounter.ContainsKey(obj.RAGUID) || LastObjectblockCounter[obj.RAGUID] < 4).ToList();

            //No new objects to test..
            if (NewObjects.Count == 0)
            {
                //Logger.DBLog.InfoFormat("No new Objects Unaccounted");

                return(SurroundingPoints.Count == 0);
            }


            foreach (GridPoint item in SurroundingPoints)
            {
                //Find any objects that contain this GP
                CacheServerObject[] ContainedObjs = NewObjects.Where(Obj => Obj.PointInside(item) &&                                       //only objects that have hit there maximum block count.
                                                                     (!LastObjectblockCounter.ContainsKey(Obj.RAGUID) || Math.Round(Obj.PointRadius) < LastObjectblockCounter[Obj.RAGUID])).ToArray();
                if (ContainedObjs.Length > 0)
                {
                    //if (ContainedObjs.Length > 1 && Bot.Settings.Debug.FunkyLogFlags.HasFlag(LogLevel.Movement))
                    //Logger.DBLog.InfoFormat("Multiple Objects Found Occuping Grid Point!");

                    CacheServerObject ThisObjBlocking = ContainedObjs[0];
                    int ObjRAGUID = ThisObjBlocking.RAGUID;

                    if (LastObjectblockCounter.ContainsKey(ObjRAGUID))
                    {
                        int GPCount = LastObjectOccupiedGridPoints[ObjRAGUID].Length;
                        LastObjectblockCounter[ObjRAGUID]++;
                        GridPoint[] newArrayGPs = new GridPoint[GPCount];
                        LastObjectOccupiedGridPoints[ObjRAGUID].CopyTo(newArrayGPs, 0);
                        newArrayGPs[GPCount - 1] = item.Clone();
                        LastObjectOccupiedGridPoints[ObjRAGUID] = newArrayGPs;
                    }
                    else
                    {
                        LastObjectblockCounter.Add(ObjRAGUID, 1);
                        GridPoint[] NewArrayGP = new GridPoint[1] {
                            item.Clone()
                        };
                        LastObjectOccupiedGridPoints.Add(ObjRAGUID, NewArrayGP);
                    }

                    LastNavigationBlockedPoints.Add(item);
                }
            }

            //Update Surrounding Points
            SurroundingPoints = SurroundingPoints.Except(LastNavigationBlockedPoints).ToList();

            //Logger.DBLog.InfoFormat("Current Location Point has {0} usable points", SurroundingPoints.Count);


            return(SurroundingPoints.Count == 0);
        }
Exemple #8
0
        private void iterateGPRectsSafeSpot(Vector3 CurrentPosition, out Vector3 safespot, Vector3 LOS, PointCheckingFlags Flags)
        {
            //blacklisted a point?.. we advance to next index!
            if (BlacklistedPoint)
            {
                lastGPRectIndexUsed++;
                BlacklistedPoint = false;
            }

            GPRectangle PositionRect = GetGPRectContainingPoint(CurrentPosition);
            if (PositionRect != null) PositionRect.UpdateObjectCount();

            GPQuadrant PositionQuadrant = PositionRect.GetQuadrantContainingPoint(CurrentPosition);
            double CompareWeight = PositionQuadrant != null ? PositionQuadrant.ThisWeight : PositionRect != null ? PositionRect.Weight : 0;

            safespot = Vector3.Zero;
            for (int i = lastGPRectIndexUsed; i < gridpointrectangles_.Count - 1; i++)
            {
                GPRectangle item = gridpointrectangles_[i];

                item.UpdateObjectCount(AllGPRectsFailed);

                if (item.TryFindSafeSpot(CurrentPosition, out safespot, LOS, Flags, BlacklistedGridpoints, AllGPRectsFailed, CompareWeight))
                {
                    lastUsedGPRect = gridpointrectangles_[i];
                    return;
                }
            }
            lastGPRectIndexUsed = 0;
        }
Exemple #9
0
 ///<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;
 }
Exemple #10
0
 public GPRectangle(GPRectangle clone)
     : base(clone)
 {
     base.CornerPoints = clone.CornerPoints;
     this.Quadrant = clone.Quadrant;
     this.CreationVector = clone.CreationVector;
     this.searchablepoints_ = clone.searchablepoints_;
 }
Exemple #11
0
        ///<summary>
        ///Checks if the position is total blocked from adjacent movements either by objects or non navigation
        ///</summary>
        private bool IsVectorBlocked(Vector3 location)
        {
            //Reset Navigationally Blocked GPs
            LastNavigationBlockedPoints = new List<GridPoint>();

            //Create Local GPRect!
            if (LastUsedBlockCheckGPRect == null || LastUsedBlockCheckGPRect.centerpoint != (GridPoint)location)
            {
                //Clear lists
                LastObjectblockCounter.Clear();
                LastObjectOccupiedGridPoints.Clear();
                LastUsedBlockCheckGPRect = new GPRectangle(location);
            }

            if (LastUsedBlockCheckGPRect.Count == 0)
            {
                //Logger.DBLog.DebugFormat("Current Location GP Rect has no valid Grid Points!");
                return false;
            }

            GridPoint[] CurrentLocationGridPoints = LastUsedBlockCheckGPRect.Keys.ToArray();
            List<GridPoint> SurroundingPoints = new List<GridPoint>();
            int SurroundingMaxCount = LastUsedBlockCheckGPRect.Count >= 8 ? 8 : LastUsedBlockCheckGPRect.Count;
            for (int i = 0; i < SurroundingMaxCount; i++)
            {
                GridPoint gp = CurrentLocationGridPoints[i];
                if (!gp.Ignored)
                    SurroundingPoints.Add(gp);
                else
                    LastNavigationBlockedPoints.Add(gp);
            }

            List<int> NearbyObjectRAGUIDs = new List<int>();
            List<CacheServerObject> NearbyObjects = Bot.Targeting.Cache.Environment.NearbyObstacleObjects.Where(obj => obj.RadiusDistance <= 6f).ToList();//ObjectCache.Obstacles.Navigations.Where(obj => obj.RadiusDistance<=5f).ToList();

            //no nearby objects passed distance check..
            if (NearbyObjects.Count == 0)
            {
                //Clear list, and return pure navigational check (Zero means we are completely stuck in a non-navigable location?)
                LastObjectblockCounter.Clear();
                LastObjectOccupiedGridPoints.Clear();

                //Logger.DBLog.InfoFormat("Current Location Point has {0} usable points (NoNewObjs)", SurroundingPoints.Count);

                return (SurroundingPoints.Count == 0);
            }

            //Update ObjectBlockCounter Collection
            if (LastObjectblockCounter.Count > 0)
            {
                //Add current nearby object RAGUIDs to collection
                NearbyObjectRAGUIDs.AddRange((from objs in NearbyObjects
                                              select objs.RAGUID).ToArray());

                //Generate Removal List for ObjectBlockCounter Collections
                List<int> RemovalRAGUIDList = (from raguids in LastObjectblockCounter.Keys
                                               where !NearbyObjectRAGUIDs.Contains(raguids)
                                               select raguids).ToList();

                //Removal
                foreach (var item in RemovalRAGUIDList)
                {
                    LastObjectblockCounter.Remove(item);
                    LastObjectOccupiedGridPoints.Remove(item);
                }
            }

            //Check any exisiting block entries
            if (LastObjectblockCounter.Count > 0)
            {
                foreach (var item in LastObjectOccupiedGridPoints.Values)
                {
                    LastNavigationBlockedPoints.AddRange(item);
                }

                //Update Surrounding Points
                SurroundingPoints = SurroundingPoints.Except(LastNavigationBlockedPoints).ToList();

                if (SurroundingPoints.Count == 0)
                {
                    //Logger.DBLog.InfoFormat("NavBlocked -- No available surrounding points.");

                    return true;
                }
            }

            //Generate new object list that contains objects that are not already accounted for
            List<CacheServerObject> NewObjects = NearbyObjects.Where(obj => !LastObjectblockCounter.ContainsKey(obj.RAGUID) || LastObjectblockCounter[obj.RAGUID] < 4).ToList();

            //No new objects to test..
            if (NewObjects.Count == 0)
            {
                //Logger.DBLog.InfoFormat("No new Objects Unaccounted");

                return (SurroundingPoints.Count == 0);
            }

            foreach (GridPoint item in SurroundingPoints)
            {
                //Find any objects that contain this GP
                CacheServerObject[] ContainedObjs = NewObjects.Where(Obj => Obj.PointInside(item)			   //only objects that have hit there maximum block count.
                                                                                && (!LastObjectblockCounter.ContainsKey(Obj.RAGUID) || Math.Round(Obj.PointRadius) < LastObjectblockCounter[Obj.RAGUID])).ToArray();
                if (ContainedObjs.Length > 0)
                {
                    //if (ContainedObjs.Length > 1 && Bot.Settings.Debug.FunkyLogFlags.HasFlag(LogLevel.Movement))
                        //Logger.DBLog.InfoFormat("Multiple Objects Found Occuping Grid Point!");

                    CacheServerObject ThisObjBlocking = ContainedObjs[0];
                    int ObjRAGUID = ThisObjBlocking.RAGUID;

                    if (LastObjectblockCounter.ContainsKey(ObjRAGUID))
                    {
                        int GPCount = LastObjectOccupiedGridPoints[ObjRAGUID].Length;
                        LastObjectblockCounter[ObjRAGUID]++;
                        GridPoint[] newArrayGPs = new GridPoint[GPCount];
                        LastObjectOccupiedGridPoints[ObjRAGUID].CopyTo(newArrayGPs, 0);
                        newArrayGPs[GPCount - 1] = item.Clone();
                        LastObjectOccupiedGridPoints[ObjRAGUID] = newArrayGPs;
                    }
                    else
                    {
                        LastObjectblockCounter.Add(ObjRAGUID, 1);
                        GridPoint[] NewArrayGP = new GridPoint[1] { item.Clone() };
                        LastObjectOccupiedGridPoints.Add(ObjRAGUID, NewArrayGP);
                    }

                    LastNavigationBlockedPoints.Add(item);
                }
            }

            //Update Surrounding Points
            SurroundingPoints = SurroundingPoints.Except(LastNavigationBlockedPoints).ToList();

            //Logger.DBLog.InfoFormat("Current Location Point has {0} usable points", SurroundingPoints.Count);

            return (SurroundingPoints.Count == 0);
        }