예제 #1
0
        internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction, ref DirectBookmark undockBookmark)
        {
            // The bookmark no longer exists, assume we aren't there
            if (bookmark == null)
                return false;

            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We have arrived
                if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId)
                    return true;

                // We are apparently in a station that is incorrect
                Logging.Log("TravelerDestination.BookmarkDestination: We're docked in the wrong station, undocking");
                //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix))
                //{
                //    var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).OrderByDescending(b => b.CreatedOn).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case
                //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                //    if (bookmarks != null && bookmarks.Count() > 0)
                //    {
                //        undockBookmark = bookmarks.FirstOrDefault();
                //        if (undockBookmark.X == null || undockBookmark.Y == null || undockBookmark.Z == null)
                //        {
                //            Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark [" + undockBookmark.Title + "] is unusable: it has no coords");
                //            undockBookmark = null;
                //        }
                //        else Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark [" + undockBookmark.Title + "] is usable: it has coords");
                //    }
                //    else Logging.Log("TravelerDestination.BookmarkDestination: you do not have an undock bookmark that contains [" + Settings.Instance.UndockPrefix + "] in local");
                //}
                //else Logging.Log("TravelerDestination.BookmarkDestination: UndockPrefix is not configured");
                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds);
                return false;
            }

            // Is this a station bookmark?
            if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station)
            {
                var arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction, ref undockBookmark);
                if (arrived)
                    Logging.Log("TravelerDestination.BookmarkDestination: Arrived at bookmark [" + bookmark.Title + "]");
                return arrived;
            }

            // Its not a station bookmark, make sure we are in space
            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.Now)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination: We're docked but our destination is in space, undocking");

                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds);
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in space and not in a station, wait a bit
                return false;
            }

            if (undockBookmark != null)
            {
                if (Cache.Instance.DistanceFromMe(undockBookmark.X ?? 0, undockBookmark.Y ?? 0, undockBookmark.Z ?? 0) < (int)Distance.WarptoDistance)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination: Arrived at undock bookmark [" + undockBookmark.Title + "]");
                    undockBookmark = null;
                }
                else
                {
                    Logging.Log("TravelerDestination.BookmarkDestination: Warping to undock bookmark [" + undockBookmark.Title + "]");
                    undockBookmark.WarpTo();
                    nextAction = DateTime.Now.AddSeconds((int)Time.TravelerInWarpedNextCommandDelay_seconds);
                    //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay);
                    return false;
                }
            }

            // This bookmark has no x / y / z, assume we are there.
            if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1)
            {
                Logging.Log("TravelerDestination.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "][No XYZ]");
                return true;
            }

            var distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
            if (distance < warpDistance)
            {
                Logging.Log("TravelerDestination.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]");
                return true;
            }

            if (nextAction > DateTime.Now)
                return false;

            Logging.Log("TravelerDestination.BookmarkDestination: Warping to bookmark [" + bookmark.Title + "]");
            Cache.Instance.DoNotBreakInvul = false;
            bookmark.WarpTo();
            nextAction = DateTime.Now.AddSeconds((int)Time.TravelerInWarpedNextCommandDelay_seconds);
            return false;
        }
예제 #2
0
        internal static bool PerformFinalDestinationTask2(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction)
        {
            // The bookmark no longer exists, assume we are there
            if (bookmark == null)
                return true;

            DirectLocation location = GetBookmarkLocation(bookmark);
            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We have arrived
                if (location != null && location.ItemId == Cache.Instance.DirectEve.Session.StationId)
                    return true;

                if (DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(45)) //do not try to leave the station until you have been docked for at least 45seconds! (this gives some overhead to load the station env + session change timer)
                {
                    // We are apparently in a station that is incorrect
                    Logging.Log("QuestorManager.BookmarkDestination", "We're docked in the wrong station, undocking", Logging.White);

                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.UtcNow.AddSeconds(30);
                    return false;
                }

                return false;
            }

            // Is this a station bookmark?
            if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station)
            {
                bool arrived = StationDestination2.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction);
                if (arrived)
                    Logging.Log("QuestorManager.BookmarkDestination", "Arrived at bookmark [" + bookmark.Title + "]", Logging.White);
                return arrived;
            }

            // Its not a station bookmark, make sure we are in space
            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.UtcNow)
                {
                    if (DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(45)) //do not try to leave the station until you have been docked for at least 45seconds! (this gives some overhead to load the station env + session change timer)
                    {
                        Logging.Log("QuestorManager.BookmarkDestination", "We're docked but our destination is in space, undocking", Logging.White);
                        Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                        nextAction = DateTime.UtcNow.AddSeconds(30);
                    }
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.DirectEve.Session.IsInSpace)
            {
                // We are not in space and not in a station, wait a bit
                return false;
            }

            // This bookmark has no x / y / z, assume we are there.
            if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1)
            {
                Logging.Log("QuestorManager.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][No XYZ]", Logging.White);
                return true;
            }

            double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
            if (distance < warpDistance)
            {
                Logging.Log("QuestorManager.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "]", Logging.White);
                return true;
            }

            if (nextAction > DateTime.UtcNow)
                return false;

            if (Cache.Instance.GateInGrid() && (distance / 1000) < (int)Distances.MaxPocketsDistanceKm)
            {
                Logging.Log("QuestorManager.BookmarkDestination", "Bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.White + "] AU away. Which is [" + Logging.Yellow + Math.Round((distance / 1000), 2) + Logging.White + "].", Logging.White);
            }

            Logging.Log("QuestorManager.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][" + Math.Round((distance / 1000) / 149598000, 2) + "] AU away. Which is [" + Math.Round((distance / 1000), 2) + "]", Logging.White);

            bookmark.WarpTo();
            nextAction = DateTime.UtcNow.AddSeconds(30);
            return false;
        }
예제 #3
0
        internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localundockBookmark)
        {
            if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId)
            {
                Logging.Log("TravelerDestination.StationDestination: Arrived in station");
                return true;
            }

            if (Cache.Instance.InStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.Now)
                {
                    Logging.Log("TravelerDestination.StationDestination: We're docked in the wrong station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]");

                    //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix))
                    //{
                    //    var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                    //    if (bookmarks != null && bookmarks.Count() > 0)
                    //    {
                    //        localundockBookmark = bookmarks.FirstOrDefault();
                    //        if (localundockBookmark.X == null || localundockBookmark.Y == null || localundockBookmark.Z == null)
                    //        {
                    //            Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is unusable: it has no coords");
                    //            localundockBookmark = null;
                    //        }
                    //        else Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is usable: it has coords");
                    //   }
                    //    else Logging.Log("TravelerDestination.StationDestination: you do not have an undock bookmark that has the prefix: " + Settings.Instance.UndockPrefix + " in local"); //+ Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark");
                    //}
                    //else Logging.Log("TravelerDestination.StationDestination: UndockPrefix is not configured");
                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds);
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in station and not in space?  Wait for a bit
                return false;
            }

            if (nextAction > DateTime.Now)
                return false;

            if (localundockBookmark != null)
            {
                if (Cache.Instance.DistanceFromMe(localundockBookmark.X ?? 0, localundockBookmark.Y ?? 0, localundockBookmark.Z ?? 0) < (int)Distance.WarptoDistance)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination: Arrived at undock bookmark [" + localundockBookmark.Title + "]");
                    localundockBookmark = null;
                }
                else
                {
                    Logging.Log("TravelerDestination.BookmarkDestination: Warping to undock bookmark [" + localundockBookmark.Title + "]");
                    localundockBookmark.WarpTo();
                    nextAction = DateTime.Now.AddSeconds(10);
                    //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay);
                    return false;
                }
            }
            //else Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark missing: " + Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark");

            var entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault();
            if (entity == null)
            {
                // We are there but no station? Wait a bit
                return false;
            }

            if (entity.Distance < (int)Distance.DockingRange)
            {
                Logging.Log("TravelerDestination.StationDestination: Dock at [" + entity.Name + "]");
                entity.Dock();
            }
            else if (entity.Distance < (int)Distance.WarptoDistance)
                entity.Approach();
            else
            {
                Logging.Log("TravelerDestination.StationDestination: Warp to and dock at [" + entity.Name + "]");
                entity.WarpTo();
            }

            nextAction = DateTime.Now.AddSeconds(20);
            return false;
        }
예제 #4
0
        internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction, ref DirectBookmark undockBookmark)
        {
            // The bookmark no longer exists, assume we are not there
            if (bookmark == null)
                return false;

            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We have arrived
                if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId)
                    return true;

                // We are apparently in a station that is incorrect
                Logging.Log("TravelerDestination.BookmarkDestination", "This is not the destination station, undocking", Logging.Green);

                //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix))
                //{
                //    var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).OrderByDescending(b => b.CreatedOn).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case
                //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                //    if (bookmarks != null && bookmarks.Count() > 0)
                //    {
                //        undockBookmark = bookmarks.FirstOrDefault();
                //        if (undockBookmark.X == null || undockBookmark.Y == null || undockBookmark.Z == null)
                //        {
                //            Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark [" + undockBookmark.Title + "] is unusable: it has no coords");
                //            undockBookmark = null;
                //        }
                //        else Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark [" + undockBookmark.Title + "] is usable: it has coords");
                //    }
                //    else Logging.Log("TravelerDestination.BookmarkDestination","you do not have an undock bookmark that contains [" + Settings.Instance.UndockPrefix + "] in local");
                //}
                //else Logging.Log("TravelerDestination.BookmarkDestination","UndockPrefix is not configured");
                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds);
                return false;
            }

            // Is this a station bookmark?
            if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station)
            {
                bool arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction, ref undockBookmark);
                if (arrived)
                    Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green);
                return arrived;
            }

            // Its not a station bookmark, make sure we are in space
            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.UtcNow)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "We're docked but our destination is in space, undocking", Logging.Green);

                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds);
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in space and not in a station, wait a bit
                return false;
            }

            if (undockBookmark != null)
            {
                double distanceToUndockBookmark = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
                if (distanceToUndockBookmark < (int)Distance.WarptoDistance)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + undockBookmark.Title + Logging.Green + "]", Logging.Green);
                    undockBookmark = null;
                }
                else
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + undockBookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distanceToUndockBookmark / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green);

                    //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false;
                    undockBookmark.WarpTo();
                    nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds);
                    return false;
                }
            }

            // This bookmark has no x / y / z, assume we are there.
            if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1)
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][No XYZ]", Logging.Green);
                return true;
            }

            double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
            if (distance < warpDistance)
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green);
                return true;
            }

            if (nextAction > DateTime.UtcNow)
                return false;

            if (Math.Round((distance / 1000)) < (int)Distance.MaxPocketsDistanceKm && Cache.Instance.AccelerationGates.Count() != 0)
            {
                Logging.Log("QuestorManager.BookmarkDestination",
                "Warp to bookmark in same pocket requested but acceleration gate found delaying."
                , Logging.White);
                return true;
            }

            Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green);
            Cache.Instance.DoNotBreakInvul = false;

            //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false;
            if (Cache.Instance.MissionWarpAtDistanceRange != 0 && bookmark.Title.Contains("Encounter"))
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + " At " + Cache.Instance.MissionWarpAtDistanceRange + Logging.Green + " km]", Logging.Green);
                bookmark.WarpTo(Cache.Instance.MissionWarpAtDistanceRange * 1000);
            }
            else
            {
                bookmark.WarpTo();
            }
            nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds);
            return false;
        }
예제 #5
0
        internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localUndockBookmark)
        {
            if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId)
            {
                Logging.Log("TravelerDestination.StationDestination", "Arrived in station", Logging.Green);
                return true;
            }

            if (Cache.Instance.InStation && DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(10))
            {
                // We are in a station, but not the correct station!
                if (DateTime.UtcNow > Cache.Instance.NextUndockAction)
                {
                    if (_undockAttempts > 10)
                    {
                        Logging.Log("TravelerDestination.StationDestination", "This is not the destination station, we have tried to undock [" + _undockAttempts + "] times - and it is evidentally not working (lag?) - restarting Questor (and EVE)", Logging.Green);
                        Cache.Instance.SessionState = "Quitting"; //this will perform a graceful restart
                    }

                    Logging.Log("TravelerDestination.StationDestination", "This is not the destination station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]", Logging.Green);

                    //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix))
                    //{
                    //    var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                    //    //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                    //    if (bookmarks != null && bookmarks.Count() > 0)
                    //    {
                    //        localUndockBookmark = bookmarks.FirstOrDefault();
                    //        if (localUndockBookmark.X == null || localUndockBookmark.Y == null || localUndockBookmark.Z == null)
                    //        {
                    //            Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localUndockBookmark.Title + "] is unusable: it has no coords");
                    //            localUndockBookmark = null;
                    //        }
                    //        else Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localUndockBookmark.Title + "] is usable: it has coords");
                    //   }
                    //    else Logging.Log("TravelerDestination.StationDestination: you do not have an undock bookmark that has the prefix: " + Settings.Instance.UndockPrefix + " in local"); //+ Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark");
                    //}
                    //else Logging.Log("TravelerDestination.StationDestination: UndockPrefix is not configured");
                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    _undockAttempts++;
                    Cache.Instance.NextUndockAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds);
                    return false;
                }

                // We are not there yet
                return false;
            }

            if ((DateTime.UtcNow > Cache.Instance.LastInStation.AddSeconds(10)) && !Cache.Instance.InSpace)
            {
                // We are not in station and not in space?  Wait for a bit
                return false;
            }

            if (nextAction > DateTime.UtcNow)
                return false;

            _undockAttempts = 0;

            if (localUndockBookmark != null)
            {
                double distance = Cache.Instance.DistanceFromMe(localUndockBookmark.X ?? 0, localUndockBookmark.Y ?? 0, localUndockBookmark.Z ?? 0);
                if (distance < (int)Distance.WarptoDistance)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + localUndockBookmark.Title + Logging.Green + "]", Logging.White);
                    localUndockBookmark = null;
                }
                else
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + localUndockBookmark.Title + Logging.Green + "][" + Math.Round((distance / 1000) / 149598000, 2) + " AU away]", Logging.White);

                    //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false;
                    localUndockBookmark.WarpTo();
                    nextAction = DateTime.UtcNow.AddSeconds(10);
                    return false;
                }
            }

            //else Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark missing: " + Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark");

            EntityCache entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault();
            if (entity == null)
            {
                // We are there but no station? Wait a bit
                return false;
            }

            if (entity.Distance < (int)Distance.DockingRange)
            {
                if (DateTime.UtcNow > Cache.Instance.NextDockAction)
                {
                    Logging.Log("TravelerDestination.StationDestination", "Dock at [" + Logging.Yellow + entity.Name + Logging.Green + "] which is [" + Math.Round(entity.Distance / 1000, 0) + "k away]", Logging.Green);
                    entity.Dock();

                    return false;
                }
            }
            else if (entity.Distance < (int)Distance.WarptoDistance)
            {
                if (DateTime.UtcNow > Cache.Instance.NextApproachAction)
                {
                    Logging.Log("TravelerDestination.StationDestination", "Approaching[" + Logging.Yellow + entity.Name + Logging.Green + "] which is [" + Math.Round(entity.Distance / 1000, 0) + "k away]", Logging.Green);
                    entity.Approach();
                    return false;
                }
            }
            else
            {
                if (DateTime.UtcNow > Cache.Instance.NextDockAction)
                {
                    Logging.Log("TravelerDestination.StationDestination", "Warp to and dock at [" + Logging.Yellow + entity.Name + Logging.Green + "][" + Math.Round((entity.Distance / 1000) / 149598000, 2) + " AU away]", Logging.Green);
                    entity.WarpToAndDock();
                    return false;
                }
            }

            nextAction = DateTime.UtcNow.AddSeconds(20);
            return false;
        }
예제 #6
0
        internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction)
        {
            // The bookmark no longer exists, assume we aren't there
            if (bookmark == null)
                return false;

            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We have arived
                if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId)
                    return true;

                // We are apparently in a station that is incorrect
                Logging.Log("Traveler.BookmarkDestination: We're docked in the wrong station, undocking");

                Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                nextAction = DateTime.Now.AddSeconds(30);
                return false;
            }

            // Is this a station bookmark?
            if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station)
            {
                var arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction);
                if (arrived)
                    Logging.Log("Traveler.BookmarkDestination: Arrived at bookmark [" + bookmark.Title + "]");
                return arrived;
            }

            // Its not a station bookmark, make sure we are in space
            if (Cache.Instance.DirectEve.Session.IsInStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.Now)
                {
                    Logging.Log("Traveler.BookmarkDestination: We're docked but our destination is in space, undocking");

                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.Now.AddSeconds(30);
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in space and not in a station, wait a bit
                return false;
            }

            // This bookmark has no x / y / z, assume we are there.
            if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1)
            {
                Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "][No XYZ]");
                return true;
            }

            var distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
            if (distance < warpDistance)
            {
                Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]");
                return true;
            }

            if (nextAction > DateTime.Now)
                return false;

            Logging.Log("Traveler.BookmarkDestination: Warping to bookmark [" + bookmark.Title + "]");
            bookmark.WarpTo();
            nextAction = DateTime.Now.AddSeconds(30);
            return false;
        }
예제 #7
0
        internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance)
        {
            // The bookmark no longer exists, assume we are not there
            if (bookmark == null)
                return false;

            // Is this a station bookmark?
            if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station)
            {
                bool arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name);
                if (arrived)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green);
                }

                return arrived;
            }

            if (Cache.Instance.InStation)
            {
                // We have arrived
                if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId)
                    return true;

                // We are in a station, but not the correct station!
                if (DateTime.UtcNow > Cache.Instance.NextUndockAction)
                {
                    TravelerDestination.Undock();
                    return false;
                }

                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in space and not in a station, wait a bit
                return false;
            }

            if (_nextTravelerDestinationAction > DateTime.UtcNow)
                return false;

            _undockAttempts = 0;

            if (Cache.Instance.UndockBookmark != null)
            {
                double distanceToUndockBookmark = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
                if (distanceToUndockBookmark < (int)Distances.WarptoDistance)
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + Cache.Instance.UndockBookmark.Title + Logging.Green + "]", Logging.Green);
                    Cache.Instance.UndockBookmark = null;
                }
                else
                {
                    if (Cache.Instance.UndockBookmark.WarpTo())
                    {
                        Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + Cache.Instance.UndockBookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distanceToUndockBookmark / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green);
                        _nextTravelerDestinationAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds);
                        //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false;
                        return false;
                    }
                }
            }

            // This bookmark has no x / y / z, assume we are there.
            if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1)
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][No XYZ]", Logging.Green);
                return true;
            }

            double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0);
            if (distance < warpDistance)
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green);
                return true;
            }

            if (_nextTravelerDestinationAction > DateTime.UtcNow)
                return false;

            if (Math.Round((distance / 1000)) < (int)Distances.MaxPocketsDistanceKm && Cache.Instance.AccelerationGates.Count() != 0)
            {
                Logging.Log("TravelerDestination.BookmarkDestination", "Warp to bookmark in same pocket requested but acceleration gate found delaying.", Logging.White);
                return true;
            }

            Cache.Instance.DoNotBreakInvul = false;
            string nameOfBookmark = "";
            if (Settings.Instance.EveServerName == "Tranquility") nameOfBookmark = "Encounter";
            if (Settings.Instance.EveServerName == "Serenity") nameOfBookmark = "遭遇战";
            if (nameOfBookmark == "") nameOfBookmark = "Encounter";
            //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false;
            if (Cache.Instance.MissionWarpAtDistanceRange != 0 && bookmark.Title.Contains(nameOfBookmark))
            {
                if (bookmark.WarpTo(Cache.Instance.MissionWarpAtDistanceRange*1000))
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + " At " + Cache.Instance.MissionWarpAtDistanceRange + Logging.Green + " km]", Logging.Green);
                }
            }
            else
            {
                if (bookmark.WarpTo())
                {
                    Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green);
                }
            }

            return false;
        }
예제 #8
0
        internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localundockBookmark)
        {
            if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId)
            {
                Logging.Log("Traveler.StationDestination: Arrived in station");
                return true;
            }

            if (Cache.Instance.InStation)
            {
                // We are in a station, but not the correct station!
                if (nextAction < DateTime.Now)
                {
                    Logging.Log("Traveler.StationDestination: We're docked in the wrong station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]");

                    if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix))
                    {
                        var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix));
                        if (bookmarks != null && bookmarks.Count() > 0)
                        {
                            localundockBookmark = bookmarks.FirstOrDefault();
                            if (localundockBookmark.X == null || localundockBookmark.Y == null || localundockBookmark.Z == null)
                            {
                                Logging.Log("Traveler.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is unusable: it has no coords");
                                localundockBookmark = null;
                            }
                            else Logging.Log("Traveler.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is usable: it has coords");
                        }
                        else Logging.Log("Traveler.StationDestination: undock bookmark does not exist");
                    }
                    else Logging.Log("Traveler.StationDestination: UndockPrefix is not configured");
                    Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation);
                    nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds);
                    //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay);
                }

                // We are not there yet
                return false;
            }

            if (!Cache.Instance.InSpace)
            {
                // We are not in station and not in space?  Wait for a bit
                return false;
            }

            if (nextAction > DateTime.Now)
                return false;

            if (localundockBookmark != null)
            {
                if (Cache.Instance.DistanceFromMe(localundockBookmark.X ?? 0, localundockBookmark.Y ?? 0, localundockBookmark.Z ?? 0) < (int)Distance.WarptoDistance)
                {
                    Logging.Log("Traveler.BookmarkDestination: Arrived at undock bookmark [" + localundockBookmark.Title + "]");
                    localundockBookmark = null;
                }
                else
                {
                    Logging.Log("Traveler.BookmarkDestination: Warping to undock bookmark [" + localundockBookmark.Title + "]");
                    localundockBookmark.WarpTo();
                    nextAction = DateTime.Now.AddSeconds(10);
                    //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay);
                    return false;
                }
            }
            else Logging.Log("Traveler.BookmarkDestination: undock bookmark does not exist and equals null");

            var entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault();
            if (entity == null)
            {
                // We are there but no station? Wait a bit
                return false;
            }

            if (entity.Distance < (int)Distance.DockingRange)
            {
                Logging.Log("Traveler.StationDestination: Dock at [" + entity.Name + "]");
                entity.Dock();
            }
            else if (entity.Distance < (int)Distance.WarptoDistance)
                entity.Approach();
            else
            {
                Logging.Log("Traveler.StationDestination: Warp to and dock at [" + entity.Name + "]");
                entity.WarpTo();
            }

            nextAction = DateTime.Now.AddSeconds(20);
            return false;
        }