Exemple #1
0
        private bool GotoMissionBookmark(long agentId, string title)
        {
            MissionBookmarkDestination destination = Traveler.Destination as MissionBookmarkDestination;

            if (destination == null || destination.AgentId != agentId || !destination.Title.StartsWith(title))
            {
                Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(agentId, title));
            }

            Traveler.ProcessState();

            if (_States.CurrentTravelerState == TravelerState.AtDestination)
            {
                if (destination != null)
                {
                    Logging.Log("CourierMissionCtrl", "Arrived at Mission Bookmark Destination [ " + destination.Title + " ]", Logging.White);
                }
                else
                {
                    Logging.Log("CourierMissionCtrl", "destination is null", Logging.White); //how would this occur exactly?
                }
                Traveler.Destination = null;
                return(true);
            }

            return(false);
        }
        private bool GotoMissionBookmark(long agentId, string title)
        {
            MissionBookmarkDestination destination = Traveler.Destination as MissionBookmarkDestination;

            if (destination == null || destination.AgentId != agentId || !destination.Title.ToLower().StartsWith(title.ToLower()))
            {
                Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(agentId, title));
            }

            Traveler.ProcessState();

            if (_States.CurrentTravelerState == TravelerState.AtDestination)
            {
                Traveler.Destination = null;
                return(true);
            }

            return(false);
        }
        /// <summary>
        ///   Do a mini-questor here (goto mission, execute mission, goto base)
        /// </summary>
        /// <returns></returns>
        public StorylineState ExecuteMission(Storyline storyline)
        {
            switch (_state)
            {
            case GenericCombatStorylineState.WarpOutStation:
                DirectBookmark warpOutBookMark = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockBookmarkPrefix ?? "").OrderByDescending(b => b.CreatedOn).FirstOrDefault(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId);
                long           solarid         = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1;

                if (warpOutBookMark == null)
                {
                    Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark", Logging.Orange);
                    _state = GenericCombatStorylineState.GotoMission;
                    break;
                }

                if (warpOutBookMark.LocationId == solarid)
                {
                    if (Traveler.Destination == null)
                    {
                        Logging.Log("GenericCombatStoryline.WarpOut", "Warp at " + warpOutBookMark.Title, Logging.White);
                        Traveler.Destination           = new BookmarkDestination(warpOutBookMark);
                        Cache.Instance.DoNotBreakInvul = true;
                    }

                    Traveler.ProcessState();
                    if (_States.CurrentTravelerState == TravelerState.AtDestination)
                    {
                        Logging.Log("GenericCombatStoryline.WarpOut", "Safe!", Logging.White);
                        Cache.Instance.DoNotBreakInvul = false;
                        _state = GenericCombatStorylineState.GotoMission;
                        Traveler.Destination = null;
                        break;
                    }

                    break;
                }

                Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark in System", Logging.White);
                _state = GenericCombatStorylineState.GotoMission;
                break;

            case GenericCombatStorylineState.GotoMission:
                MissionBookmarkDestination missionDestination = Traveler.Destination as MissionBookmarkDestination;
                //
                // if we have no destination yet... OR if missionDestination.AgentId != storyline.CurrentStorylineAgentId
                //
                //if (missionDestination != null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [" + missionDestination.AgentId + "] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                //if (missionDestination == null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [ NULL ] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
                if (missionDestination == null || missionDestination.AgentId != Cache.Instance.CurrentStorylineAgentId)     // We assume that this will always work "correctly" (tm)
                {
                    string nameOfBookmark = "";
                    if (Settings.Instance.EveServerName == "Tranquility")
                    {
                        nameOfBookmark = "Encounter";
                    }
                    if (Settings.Instance.EveServerName == "Serenity")
                    {
                        nameOfBookmark = "遭遇战";
                    }
                    if (nameOfBookmark == "")
                    {
                        nameOfBookmark = "Encounter";
                    }
                    Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + Cache.Instance.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.White);
                    Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(Cache.Instance.CurrentStorylineAgentId, nameOfBookmark));
                }

                if (Cache.Instance.PotentialCombatTargets.Any())
                {
                    Logging.Log("GenericCombatStoryline", "Priority targets found while traveling, engaging!", Logging.White);
                    Combat.ProcessState();
                }

                Traveler.ProcessState();
                if (_States.CurrentTravelerState == TravelerState.AtDestination)
                {
                    _state = GenericCombatStorylineState.ExecuteMission;

                    //_States.CurrentCombatState = CombatState.CheckTargets;
                    Traveler.Destination = null;
                }
                break;

            case GenericCombatStorylineState.ExecuteMission:
                Combat.ProcessState();
                Drones.ProcessState();
                Salvage.ProcessState();
                _combatMissionCtrl.ProcessState();

                // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship
                // and try the mission again
                if (_States.CurrentCombatState == CombatState.OutOfAmmo)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("GenericCombatStoryline", "Out of Ammo!", Logging.Orange);
                    return(StorylineState.ReturnToAgent);
                }

                if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Done)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();
                    return(StorylineState.ReturnToAgent);
                }

                // If in error state, just go home and stop the bot
                if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error)
                {
                    // Clear looted containers
                    Cache.Instance.LootedContainers.Clear();

                    Logging.Log("MissionController", "Error", Logging.Red);
                    return(StorylineState.ReturnToAgent);
                }
                break;
            }

            return(StorylineState.ExecuteMission);
        }