示例#1
0
        private void GetMissionFromAgent()
        {
            var methodName = "GetMissionFromAgent";

            LogTrace(methodName);

            var stateResult = Core.StealthBot.MissionCache.GetMissionFromAgent(SelectedAgent.Id);

            if (stateResult != ConversationStateResults.DeclineFailed)
            {
                if (stateResult == ConversationStateResults.MissionNotAccepted)
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "Did not accept mission from selected agent; selecting agent.");
                    _missionRunnerState = MissionRunnerStates.SelectAgent;
                    _getMissionState    = GetMissionStates.Idle;
                }

                if (stateResult == ConversationStateResults.MissionAccepted)
                {
                    ActiveMission = Core.StealthBot.MissionCache.GetCachedMissionForAgentId(SelectedAgent.Id);
                    LogMessage(methodName, LogSeverityTypes.Debug, "Successfully got mission from selected agent.");

                    if (Core.StealthBot.Ship.AbleToSwapAmmoLoadout)
                    {
                        _getMissionState = GetMissionStates.CheckLoadout;
                    }
                    else
                    {
                        _getMissionState    = GetMissionStates.Idle;
                        _missionRunnerState = MissionRunnerStates.RunMission;
                    }
                }
            }
            else
            {
                LogMessage(methodName, LogSeverityTypes.Debug, "Failed to decline mission from selected agent; selecting agent.");
                _missionRunnerState = MissionRunnerStates.SelectAgent;
                _getMissionState    = GetMissionStates.Idle;
            }
        }
示例#2
0
        protected override void ProcessPulseState()
        {
            var methodName = "ProcessPulseState";

            LogTrace(methodName);

            switch (_missionRunnerState)
            {
            //Update the mission cache:
            case MissionRunnerStates.UpdateMissionCache:
                //Initially shut the journal. Needs to be opened by ISXEVE or funky shit happens.
                if (!_startupJournalShut)
                {
                    _startupJournalShut = true;
                    using (var journalWindow = _eveWindowProvider.GetWindowByName(WINDOWNAME_JOURNAL))
                    {
                        if (!LavishScriptObject.IsNullOrInvalid(journalWindow))
                        {
                            journalWindow.Close();
                            return;
                        }
                    }
                }

                if (Core.StealthBot.MissionCache.UpdateCache(0, true))
                {
                    _missionRunnerState = MissionRunnerStates.SelectAgent;
                }
                break;

            //Pick an agent to use
            case MissionRunnerStates.SelectAgent:
                if (_hasMaxRuntimeExpired)
                {
                    return;
                }

                //If downtime is near, don't select an agent. Instead, pause.
                if (Core.StealthBot.MeCache.IsDowntimeNear)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "We're getting close to standard EVE downtime and are pausing missioning.");
                    IsEnabled = false;
                    return;
                }

                //Set the active agent
                SelectAgent();

                //If we didn't get an agent, return.
                if (SelectedAgent == null)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "There are currently no agents available. We're waiting 5 minutes before checking again.");
                    DelayNextPulseBySeconds(300);
                    return;
                }

                //See if we have a matching, accepted mission
                var cachedMission = Core.StealthBot.MissionCache.GetCachedMissionForAgentId(SelectedAgent.Id);
                if (cachedMission != null && cachedMission.State == (int)MissionStates.Accepted)
                {
                    //Set it active.
                    ActiveMission = cachedMission;

                    //Go to the MoveToStart state.
                    _missionRunnerState = MissionRunnerStates.RunMission;
                    goto case MissionRunnerStates.RunMission;
                }

                //No cached mission returned or it wasn't accepted, means we need to go get a mission.
                _missionRunnerState = MissionRunnerStates.MoveToAgent;
                goto case MissionRunnerStates.MoveToAgent;

            case MissionRunnerStates.MoveToAgent:
                //If I'm at the agent, go to MissionStart.
                if (Core.StealthBot.MeCache.SolarSystemId == SelectedAgent.SolarSystemId &&
                    Core.StealthBot.MeCache.InStation && Core.StealthBot.MeCache.StationId == SelectedAgent.StationId)
                {
                    _missionRunnerState = MissionRunnerStates.GetMissionFromAgent;
                    goto case MissionRunnerStates.GetMissionFromAgent;
                }

                if (Core.StealthBot.MeCache.InStation && Core.StealthBot.MeCache.StationId != SelectedAgent.StationId)
                {
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.Undock));
                }

                //If I'm not in the same system, first move there
                if (Core.StealthBot.MeCache.SolarSystemId != SelectedAgent.SolarSystemId)
                {
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.SolarSystem, SelectedAgent.SolarSystemId));
                }
                else if (!Core.StealthBot.MeCache.InStation)
                {
                    //Try to find a matching entitywrapper
                    var stationEntity = Core.StealthBot.EntityProvider.EntityWrappers.FirstOrDefault(
                        entityWrapper => entityWrapper.Name == SelectedAgent.Station);

                    //This will satisfy the conditions of the outer If check, thus it'll hit after dock.
                    Core.StealthBot.Movement.QueueDestination(new Destination(DestinationTypes.Entity, stationEntity.ID)
                    {
                        Distance = 200, Dock = true
                    });
                }
                break;

            case MissionRunnerStates.GetMissionFromAgent:
                switch (_getMissionState)
                {
                case GetMissionStates.Idle:
                    _getMissionState = GetMissionStates.GetMission;
                    goto case GetMissionStates.GetMission;

                case GetMissionStates.GetMission:
                    GetMissionFromAgent();
                    break;

                case GetMissionStates.CheckLoadout:
                    var npcResistanceProfiles = Core.StealthBot.MissionDatabase.GetNpcResistanceProfiles(ActiveMission);
                    var doneRearming          = Core.StealthBot.Ship.RearmShip(npcResistanceProfiles);

                    if (doneRearming)
                    {
                        _getMissionState    = GetMissionStates.Idle;
                        _missionRunnerState = MissionRunnerStates.RunMission;
                    }
                    break;
                }
                break;

            case MissionRunnerStates.RunMission:
                if (_duringMissionRandomWaitObject.ShouldWait())
                {
                    return;
                }

                RunMission();
                break;

            case MissionRunnerStates.TurnInMission:
                if (_betweenMissionsRandomWaitObject.ShouldWait())
                {
                    return;
                }

                TurnInMission();
                break;
            }
        }